May 2020
Intermediate to advanced
656 pages
16h 6m
English
To declare any variable(s) as a symbolic variable, you should use the command ‘
sym’ or ‘
syms’ as follows:
>a=sym('a'); t=sym('t'); x=sym('x');>syms a x y t % or, equivalently and more efficiently
Once the variables have been declared as symbolic, they can be used in expressions and as arguments to many functions without being evaluated as numeric:
>f=x^2/(1+tan(x)^2);>ezplot(f,[-pi pi])>simplify(cos(x)^2+sin(x)^2) % simplify an expressionans = 1>simplify(cos(x)^2-sin(x)^2) % simplify an expressionans = cos(2*x)>simplify(2*sin(x)*cos(x)) % simple expressionans = sin(2*x)>simplify(sin(x)*cos(y)+cos(x)*sin(y)) % simple expressionans = sin(x+y)>eq1=expand((x+y)^3-(x+y)^2) % expandeq1 = x^3 + 3*x^2*y - x^2 + 3*x*y^2 - 2*x*y + y^3 - y^2>collect(eq1,y) % collect similar terms in descending order w.r.t. yans = y^3 + (3*x-1)*y^2 + (3*x^2-2*x)*y + x^3 - x^2>factor(eq1) % factorizeans = [ x + y - 1, x + y, x + y]>horner(eq1) % nested multiplication formans = x*(x*(x + 3*y - 1) - 2*y + 3*y^2) - y^2 + y^3>pretty(ans) % pretty form2 2 3x (x (x ...
Read now
Unlock full access