# Symbolic Processing

Topics: Mathematics, Differential equation, Polynomial Pages: 5 (1055 words) Published: August 9, 2011
Symbolic processing is the most powerful feature of matlab. We can solve even most complex equations very easily in matlab that are very difficult to solve by hand. Matlab performs symbolic processing to obtain answers in the form of expressions. Symbolic processing is the term used to describe how a computer performs operations on mathematical expressions. To improve engineering designs by modeling it with mathematical expressions that do not have specific parameter values are very difficult to solve by hand on paper but matlab performs these tasks very easily through symbolic processing symbolic processing is used for solving algebraic and transcendental equations, for solving ordinary differential equations and for symbolic calculus including integration, differentiation, limits and series. Symbolic expressions and algebra:

The “sym” function can be used to create a “symbolic objects” in MATLAB. If the input argument to sym is a string, the result is a symbolic number or variable. If the input argument is a numeric, scalar or matrix, the resulting is a symbolic representation of the given numeric values. For example, typing x=sym (‘x’) creates the symbolic variable with name x, and typing y=sym(‘y’) creates a symbolic variable named y. typing x=sym(‘x’,’real’) tells MATLAB to assume that x is real. Typing x=sym(‘x’,’unreal’) tells MATLAB to assume that x is not real. The “syms” function enables you to combine more than one such statement into a single statement. For example typing syms x is equivalent to typing x=sym(‘x’), and typing syms x y u v creates the four symbolic variables x, y, u and v. when used without arguments, syms lists the symbolic objects in the work space. The syms command, however, cannot be used to create symbolic constants. The syms command enables you to specify that certain variables are real. For example, >>syms x y real

Manipulating expressions:
The following functions can be used to manipulate expressions by collecting coefficients of like powers, expanding powers, and factoring expressions, for example. The function collect (E) collects coefficients of like powers in the expression E. if there is more than one variable, you can see the optional form collect(E,v), which collects all the coefficients with the same power of v. >>syms x y

>>E = ( x - 5 ) ^ 2 + ( y - 3 ) ^ 2;
>>collect ( E )
ans=
x ^ 2 – 10 * x + 25 + ( y – 3 ) ^ 2
>>collect ( E , y )
ans=
y ^ 2 – 6 * y + ( x – 5 ) ^ 2 + 9
the function simplify (E) simplifies the expression E. For example, >>syms x y
>>simplify ( x * sqrt ( x ^ sqrt ( x ^ 8 * y ^ 2 ))
ans=
x * ( x ^ 8 * y ^ 2 ) ^ ( 1 / 2 )
The operators +, -, *, / and ^ can be used with symbolic expressions to obtain new expressions. This is shown below. >>syms x y
>>E1 = x ^ 2 + 5 ; % define two expressions >>E2 = y ^ 3 – 2 ;
>>S1 = E1 + E2 % add the expressions
S1 =
x ^ 2 + 3 + y ^ 3
>> E3 = x ^ 3 + 2 * x ^ 2 + 5 * x + 10 ; % define the third expression >>S3 = E3 / E1
S3 = ( x ^ 2 + 2 * x ^ 2 + 5 * x + 10 ) / ( x^ 2 + 5 )
>>simplify ( S3 )
ans=
x + 2
The function “subs(E, old, new) substitutes “new” for “old” in the expression “E”, where old can be a symbolic variable or expression and new can be a symbolic variable, expression, or matrix, or a numeric value or matrix. For example, >>syms x y

>>E = x ^ 2 + 6 * x + 7 ;
>>F = subs ( E, x, y )
F =
Y ^ 2 + 6 * y + 7
Another example is shown below to perform multiple substitutions. For example, to substitute a = x and b = 2 into the expression E = a sin b, the session is >>syms a b x
>>E = a * sin ( b ) ;
>>F = subs ( E, { a, b }, { x, 2 } )
F =
x * sin (2)
The function “double (E)” converts the expression E to numeric form. The expression E must not contain any symbolic variables. The term “double” stands for floating point, double precision. For example,...

Please join StudyMode to read the full document