MATLAB learning notes (2): symbol computation _-_ 1, matlab _-_ 1
2.1 symbol object and Symbol Expression
Create a basic symbol object
syms a
Create a basic symbolic number
sym('num')sc=sym('num')
The difference between a symbolic number and a numeric number
>> clear>> a=5+pi,b=sym('5+pi'),ca=class(a),cb=class(b),vpa(a-b)a = 8.1416 b = pi + 5 ca =doublecb =sym ans = -0.00000000000000012246467991473531772260691423833
Symbol Expression
An expression composed of symbol variables is called a symbol expression.
For example, the solution of the equation uz ^ 2 + vz + w = 0 is obtained.
>> clear>> syms u v w z>> Eq=u*z^2+v*z+w;>> solve(Eq) ans = - u*z^2 - v*z >> findsym(Eq),findsym(Eq,1)ans =u,v,w,zans =w
Two interesting commands: solve () solves the equation function. By default, the minimum letter from the absolute value of x is unknown. You can also solve the equation for specified variables, such as solve (Eq, z );
Findsym (Eq) confirms all the free symbol variables in the expression Eq (the expression can also be a symbol matrix)
Findsym (Eq, N) identifies N free variable closest to x from the expression
2.2 operations on symbolic numbers and expressions
Forced conversion between numeric and symbolic numeric
>> clear>> a=88;b=sym('88');>> class(sym(a)),class(double(b))ans =symans =double
Supplement: class (variable name) returns the Data Type of the variable.
Arbitrary precision calculation of symbol numbers
>> clear>> a=88;>> x=vpa(a) x = 88.0 >> class(x)ans =sym
One command: vpa (x) converts expression x to a 32-bit symbol number (which can be changed by default, using vpa (x, n ).
Symbol operations include many operation commands, such as collect, expand, factor, and numden ), pretty
Simple (Eq) Simplifies Eq into the simplest form
For example, simplified f = (1/x ^ 3 + 6/x ^ 2 + 12/x + 8) ^ (1/3)
>> clear>> syms x>> f=(1/x^3+6/x^2+12/x+8)^(1/3);>> Eq=simple(f) Eq = ((2*x + 1)^3/x^3)^(1/3)
Fuck... In fact, it can still be reduced to 2 + 1/x. I don't know what's going on, and the problem cannot be solved after many simplification. Is it a version issue?
First come here .. The second chapter is still quite a bit difficult .. QAQ