Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

When working with symbolic expressions, a common task is to substitute a particular value into the expression for one of the symbolic variables that make

When working with symbolic expressions, a common task is to substitute a particular value into the expression for one of the symbolic variables that make up that expression. For example, we might like to substitute the value for in the expression and obtain the result. To do this with an existing symbolic expression in MATLAB, we use the subs function. For example, the code below creates the symbolic expression y equal to substitutes pi for the symbolic variable x:
syms x
y = cos(x)
z = subs(y,pi)
The result is the symbolic variable z equal to 1(as . Note that the first argument to subs was the symbolic expression being substituted into, the second is the value being substituted for x.
We can also substitute other symbolic variables - and even entire symbolic expressions - into other symbolic expressions using the subs function, as demonstrated in the commands below:
syms x a
y = sqrt(x)
z1= subs(y,a)
z2= subs(y,2*a+1)
The result of these commands are two new symbolic expressions:
z1 equal to
z2 equal to
Note that we don't have to specify which variable we are substituting for if the expression only contains one symbolic variable. To substitute into an expression that contains multiple symbolic variables, specify the expression followed by the name of the variable you are substituting for and the variable or expression you are replacing it with, as in the example below which substitutes for in the expression :
syms x y
z = x^2+y^2
subs(z,y,1)
Your Task
Below you will substitute values and symbolic expressions into other symbolic expressions. The symbolic expression f, equivalent to , has been defined for you in the solution template, along with the symbolic variables x and y. Follow the steps below to complete the script:
Use the subs function to substitute x for y in the expression f and assign the result back to f, so that f is now a symbolic expression of x.
Substitute the value 0.25 for x in f and store the result in the variable val1
Obtain the composition of f with itself by substituting f for x in f. Store the resulting expression in the variable ff.
Substitute the value of 0.75 x in ff and store the result in the variable val2.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

Students also viewed these Databases questions

Question

Please help me evaluate this integral. 8 2 2 v - v

Answered: 1 week ago

Question

What is a key public for this product/service/concept?

Answered: 1 week ago