Graphics Reference
In-Depth Information
1.5 Symbolic Calculations with MATLAB
MATLAB handles symbolic mathematical computation using the Symbolic Math Toolbox, manipulating formulae
and algebraic expressions easily and quickly and can perform most operations with them. You can expand, factor
and simplify polynomials, rational and trigonometric expressions, you can find algebraic solutions of polynomial
equations and systems of equations, can evaluate derivatives and integrals symbolically, and find function solutions
for differential equations, you can manipulate powers, limits and many other facets of algebraic mathematical series.
To perform this task, MATLAB requires all the variables (or algebraic expressions) to be written between single
quotes to distinguish them from numerical solutions. When MATLAB receives a variable or expression in quotes, it is
considered symbolic.
Here are some examples of symbolic computation with MATLAB.
1.
You can raise the following algebraic expression to the third power: (x + 1) (x+2) - (x+2) ^ 2.
This is done by typing the following expression: expand ('((x + 1) (x+2) - (x+2) ^ 2) ^ 3').
The result will be another algebraic expression:
>> syms x; expand (((x + 1) *(x + 2)-(x + 2) ^ 2) ^ 3)
Ans =
-x ^ 3-6 * x ^ 2-12 * x-8
Note that syms x is used to declare x for symbolic computations.
You can then factor the result of the calculation in the example above by typing:
factor ('((x + 1) *(x + 2)-(x + 2) ^ 2) ^ 3')
>> syms x; factor(((x + 1)*(x + 2)-(x + 2)^2)^3)
ans =
-(x+2)^3
2.
You can resolve the indefinite integral of the function (x ^ 2) Sine (x) ^ 2 by typing:
int ('x ^ 2 * sin (x) ^ 2, 'x')
>> int('x^2*sin(x)^2', 'x')
ans =
x ^ 2 * (-1/2 * cos (x) * sin (x) + 1/2 * x)-1/2 * x * cos (x) ^ 2 + 1/4 *
cos (x) * sin (x) + 1/4 * 1/x-3 * x ^ 3
You can simplify the previous result:
>> syms x; simplify(int(x^2*sin(x)^2, x))
ans =
sin(2*x)/8 - (x*cos(2*x))/4 - (x^2*sin(2*x))/4 + x^3/6
 
Search WWH ::




Custom Search