Parts of an expression may be replaced by other expressions using subst(a,b,c): a is substituted for b in c. This is a powerful function with many uses.
First, it may be used to insert numbers for variables, in the example for in der formula .
Second, one can replace a symbolic variable by a complex term. The expression is automatically updated to the canonical format. In the following example is inserted for in .
>> syms x,z >> p=x^3+2*x^2+x+7; >> subst(z^3+2,x,p) ans = z^9+8*z^6+21*z^3+25
Finally, the term b itself may be a complex expression (in the example ). Jasymca then tries to identify this expression in c (example: ). This is accomplished by solving the equation for the symbolic variable in b (example: ), and inserting the solution in c. This does not always succeed, or there may be several solutions, which are returned as a vector.
The function trigrat(expression) applies a series of algorithms to expression.
It is often required to apply float(expression) to the final result.
>> syms x >> trigrat(sin(x)^2+cos(x)^2) ans = 1 >> b=sin(x)^2+sin(x+2*pi/3)^2+sin(x+4*pi/3)^2; >> trigrat(b) ans = 3/2 >> trigrat(i/2*log(x+i*pi)) ans = 1/4*i*log(x^2+pi^2)+(1/2*atan(x/pi)-1/4*pi) >> trigrat(sin((x+y)/2)*cos((x-y)/2)) ans = 1/2*sin(y)+1/2*sin(x) >> trigrat(sqrt(4*y^2+4*x*y-4*y+x^2-2*x+1)) ans = y+(1/2*x-1/2)
trigexpand(expression) expands trigonometric expressions to complex exponentials. It is the first step of the function trigrat above.