Professional Documents
Culture Documents
ns or evaluates mathematical expressions in the way, for examples, that humans do algebra with pencil and paper.
Symbolic Object
Symbolic object is a data structure that stores a string representation of the symbol. The two ways to create symbolic object are: 1. Using sym function Typing x=sym(x) creates the symbolic variable with name x. 2. Using syms command syms x is equivalent to typing x=sym(x). Typing syms x y z creates three symbolic variables x, y, and z.
Symbolic Constants: To create symbolic constant, use the sym function. >> pi=sym(pi) >> fraction=sym(1/4) >> sqroot2=sym(sqrt(2)) Symbolic Variables & Expressions The sequence of commands >> syms x y z >> m=sqrt(x^2+y^2+z^2) >> n=sin(x*y)/(x*y) generates the symbolic m and n.
Symbolic Constants: To create symbolic constant, use the sym function. >> pi=sym(pi) >> fraction=sym(1/4) >> sqroot2=sym(sqrt(2)) Symbolic Variables & Expressions The sequence of commands >> syms x y z >> m=sqrt(x^2+y^2+z^2) >> n=sin(x*y)/(x*y) generates the symbolic m and n.
Symbolic objects can be classified as: 1. symbolic variable (ex. x, y, z) 2. symbolic constant (ex. pi, sqrt(3)) 3. symbolic expression (ex. x^2 + y^2) 4. symbolic matrix (ex. [a, b, c; b, c, a; c, a, b]) To create symbolic constant, use the sym function. Example: >> pi = sym(pi) >> fraction = sym(1/4) >> sqroot2 = sym(sqrt(2))
pretty The pretty function displays symbolic output in a format that resembles typeset mathematics. Syntax: pretty(S) >>m=sqrt(x^2+y^2+z^2) m= (x^2+y^2+z^2)^(1/2)
Examples: >> f=x^3-6*x^2+11*x-6 >> g=(x-1)*(x-2)*(x-3) >> pretty(f) >> pretty(g) Or >> pretty(x^3-6*x^2+11*x-6) >> pretty((x-1)*(x-2)*(x-3))
double The statement double (s) converts the symbolic object S to a numeric object. Syntax: r=double(S) >> sqroot2=sym(sqrt(2)); >> z=6*sqroot2 >> double(z)
SIMPLIFICATION:
collect
collect(f) views f as a polynomial in its symbolic variables, say x, and collects all the coefficients with the same power of x.
Syntax: collect(S) Ex. 1. H=x[x(x-6)+11]-6 >> h=x*(x*(x-6)+11)-6 collect(h) ans = x^3-6*x^2+11*x-6 Syntax : collect(S, x) the 2nd argument can specify the variable in which to collect terms if there is more than one candidate.
expand
expand(f) distributes products over sums and applies other identities involving transcendental functions.
Syntax: expand(S) Ex. 1. 2 3 5 2. cos + 3. +
horner
horner(f) transforms a symbolic polynomial f into its Horner, (or nested, representation)
Syntax: horner(f) Ex. 1. 3 3 2 4 + 5 2. 2 5 4 + 3 2 4 + 5 3. 1.1 + 2.2 + 3.3 2
factor
factor(S) factors the expression S which can be positive integer, an array of symbolic expressions, or an array of symbolic integers.
Syntax: factor(S) Ex. 1. factor(x^3-y^3)
ans = x+1
simple simple(E) searches for the symbolic expressions simplest form; that is, an expression that has the fewest character. Syntax: r = simple(S) Ex. Apply the simple and simplify commands 1. log 2. cos 3 cos 1 3. + 1 1
Solving Equations If S is a symbolic expression solve (S) attempts to find values of the symbolic variable is S for which S is zero
Syntax: g = solve (eq) g = solve (eq, var) Ex. >>solve (2*x^2-x-6=0) Solve the ff equations: 2 + 9 4 = 0 2 + 3 = 54 3. 2 + 3 + 2 = 0 solve for 4. 2 + 8 + 2 = 0, solve for , then solve for .
Polynomial Algebra
Consider = 12 4 3 2 + + 7 . This function can be written in array form called coefficient array, that is, f = [12, 0, -3, 1, 7]. Command conv(a, b) Description Computes the product of the two polynomials described by the coefficient arrays a and b. The two polynomials need not be the same degree. The result is the coefficient array of the product polynomial.
Computes the result of dividing a numerator polynomial, whose coefficient array is num, by a denominator polynomial represented by the coefficient array den. The quotient polynomial is given by the coefficient array q, and the remainder polynomial is given by the coefficient array r.
poly(r)
[r,p,k] = residue(a,b)
Computes the coefficients of the polynomial whose roots are specified by the vector r. The result is a row vector that contains the polynomials coefficients arranged in descending order of power Finds the residues, poles and direct term of a partial fraction expansion of the ratio polynomials a(x) / b(x)
polyval(a, x)
roots(a)
Evaluates a polynomial at specified values of its independent variable x, which can be a matrix or a vector. The polynomials coefficients of descending powers are stored in the array a. The result is the same size as x. Computes the roots of a polynomial specified by the coefficient array a. The result is a column vector that contains the polynomials roots.
Practice Set: 1. Confirm that 20 3 7 2 + 5 + 10 4 2 + 12 3 = 80 5 + 212 4 124 3 + 121 2 + 105 30. 2. Confirm that
12 3 + 5 2 2 + 3 = 4 + 11 2 3 7 + 4
4.
a.
2 +5+8 3 +1 2
5.
+ 6 = 0.