Presentation is loading. Please wait.

Presentation is loading. Please wait.

S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan Math Review with Matlab: Simplification Symbolic Math Toolbox.

Similar presentations


Presentation on theme: "S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan Math Review with Matlab: Simplification Symbolic Math Toolbox."— Presentation transcript:

1

2 S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan Math Review with Matlab: Simplification Symbolic Math Toolbox

3 Symbolic Toolbox:Simplifications and Substitutions 2 Symbolic Simplifications n Pretty Command n Factor Command n Collect Command n Expand Command n Simplify Command n Simple Command

4 Symbolic Toolbox:Simplifications and Substitutions 3 Pretty Command The pretty command can be used to display symbolic expression in a format that resembles type-set mathematics PrettyPretty pretty(s) prints the symbolic expression s pretty(s,n) prints s using screen width n instead of the default 79

5 Symbolic Toolbox:Simplifications and Substitutions 4 Pretty Examples » syms x » f=x^3 - 6*x^2 + 21*x -6; » g=(x-1)*(x-2)*(x-3); » pretty(g) (x - 1) (x - 2) (x - 3) » h=x*(x*(x-6)+11)-6; » pretty(h) x (x (x - 6) + 11) - 6 Product Polynomial Nested Products Polynomial » pretty(f) 3 2 x - 6 x + 21 x - 6

6 Symbolic Toolbox:Simplifications and Substitutions 5 Factor Command The factor(f) command factors f into polynomial products » f = x^3 -6*x^2 +11*x -6; » y = factor(f) y = (x-1)*(x-2)*(x-3) » y = factor(x^5-1) y = (x-1)*(x^4+x^3+x^2+x+1)

7 Symbolic Toolbox:Simplifications and Substitutions 6 Collect Command The collect command collects coefficients of a symbolic expression and rewrites it as powers of a polynomial collect(s,v) s is a symbolic expression matrix v is the independent polynomial variable If v is omitted, collect uses rules to determine a default variable

8 Symbolic Toolbox:Simplifications and Substitutions 7 Collect Examples n Create symbolic expression f(x,t)=(1+x)t+xt » syms x t » f=(1+x)*t+x*t f = (1+x)*t+x*t n Specify collecting the x terms n Specify collecting the t terms n Unspecified independent variable collects the x variable » f_col_x = collect(f,x) f_col_x = 2*x*t+t » f_col_t = collect(f,t) f_col_t = (1+2*x)*t » f_col = collect(f) f_col = 2*x*t+t

9 Symbolic Toolbox:Simplifications and Substitutions 8 Expand Command The expand(s) command writes each element of the symbolic expression s as a product of its factors n Types of expandable expressions include: u Polynomial expressions u Trigonometric expressions u Exponential expressions u Logorithmetic expressions This is the inverse of the collect command

10 Symbolic Toolbox:Simplifications and Substitutions 9 Expand Examples » syms a x y » expand(a*(x+y)) ans = a*x+a*y » expand(exp(x+y)) ans = exp(x)*exp(y) Polynomial Expansion Exponential Expansion n Polynomial and exponential expansion examples

11 Symbolic Toolbox:Simplifications and Substitutions 10 Involved Expand Example n Given the following function of x: 1)Expand f(x) by hand to get a polynomial function of x 2)Verify the result using the symbolic expand command

12 Symbolic Toolbox:Simplifications and Substitutions 11 Expansion Approach n To expand f(x) by hand, represent the inverse cosine portion as a new function z n Expand cos(3z) in terms of z n Once cos(3z) is expanded, substitute back in z=cos -1 (x) Let: Thus:

13 Symbolic Toolbox:Simplifications and Substitutions 12 Expand cos(3z) Term n Begin by expanding f(x) in terms of z

14 Symbolic Toolbox:Simplifications and Substitutions 13 Substitute and Simplify n From the previous work: n Substitute: n Simplify:

15 Symbolic Toolbox:Simplifications and Substitutions 14 Expand Verification n This is easily verified in Matlab » expand( cos(3*acos(x)) ) ans = 4*x^3-3*x

16 Symbolic Toolbox:Simplifications and Substitutions 15 » syms x » f1=sin(x)^2 + cos(x)^2 + log(x); » f1_smplfy = simplify(f1) f1_smplfy = 1+log(x) Simplify Command The simplify(s) command performs algebraic, trigonometric, and logarithmic identities and relationships to simplify each element of the the symbolic matrix s Trigonometric Identity:

17 Symbolic Toolbox:Simplifications and Substitutions 16 » syms a b » f=exp(a*log(b)); » f_smplfy=simplify(f) f_smplfy = b^a » f_expnd = expand(f) f_expnd = b^a Simplify Example n Simplify the expression: Expand gives the same result

18 Symbolic Toolbox:Simplifications and Substitutions 17 n Example Methods for Simplification:  Collect Similar Terms  Trigonometric Identities  Log/Complex Number Relations Simple Command r = simple(s) tries different algebraic simplifications and looks for the shortest form of the entire symbolic matrix s. If the result r is not specified, all intermediate steps are displayed to the screen. [r,how] = simple(s) does not display intermediate simplifications, but returns the shortest form, as well as a string describing the simplification method used

19 Symbolic Toolbox:Simplifications and Substitutions 18 Simplify Example n Use the simple command to simplify the function f from the previous example and show intermediate steps » f=exp(a*log(b)); » f_smpl=simple(f) simplify: b^a radsimp: exp(a*log(b)) combine(trig): exp(a*log(b)) convert(sincos): exp(a*log(b)) convert(tan): exp(a*log(b)) collect(b): exp(a*log(b)) f_smpl = b^a factor: exp(a*log(b)) expand: b^a combine: exp(a*log(b)) convert(exp): exp(a*log(b))

20 Symbolic Toolbox:Simplifications and Substitutions 19 Best Simplify Method n Perform the simplification again but show only the result » [f_smpl]=simple(f) f_smpl = b^a Recall from a previous example that the expand and simplify methods gave the same results n Also show which simplification was used » [f_smpl,how]=simple(f) f_smpl = b^a how = expand

21 Symbolic Toolbox:Simplifications and Substitutions 20 Simple Example » f=sym( '(1+1/2*2^(1/2))^2+1+1/2*2^(1/2)') f = (1+1/2*2^(1/2))^2+1+1/2*2^(1/2) » f_smpl=simple(f) f_smpl = 5/2+3/2*2^(1/2) n The simple command can also be used to simplify symbolic mathematical expressions without dependent variables

22 Symbolic Toolbox:Simplifications and Substitutions 21 Summary The pretty command can be used to display symbolic expressions in mathematical type-set form The factor, collect, expand, and simplify commands can be used to reduce a symbolic expression to shorter forms The simple command implements multiple simplification methods to simplify a symbolic expression to its shortest form The simple command can also return the best simplification method used to reduce the symbolic expression


Download ppt "S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan Math Review with Matlab: Simplification Symbolic Math Toolbox."

Similar presentations


Ads by Google