Math Review with Matlab Solving Algebraic Equations Single
Math Review with Matlab: Solving Algebraic Equations Single Variable Transcendental Equations S. Awad, Ph. D. M. Corless, M. S. E. E. D. Cinpinski E. C. E. Department University of Michigan-Dearborn
Solving Algebraic Equations: Transcendental Equations Solving Transcendental Equations n Solve Command n Polynomial Transcendental Example n Poly 2 sym Command n Exponential Transcendental Example n Complex Solution Example 2
Solving Algebraic Equations: Transcendental Equations Solve Command n n n The Symbolic Toolbox’s solve command is used to solve both transcendental and algebraic equations solve(f) solves f in terms of the independent symbolic variable closest to x. f must be a symbolic expression or a entered as a text string enclosed by single quotes solve(f 1, f 2, . . . , fn) is used to solve multiple equations by separating the symbolic equations by commas as follows 3
Solving Algebraic Equations: Transcendental Equations Polynomial Transcendental Equation Example n Use Matlab’s Symbolic Toolbox solve command to solve the transcendental equation: » syms x » xs_sym=solve(x^2 -3*x+2) xs_sym = [ 1] [ 2] » xs_dbl=double(xs) xs_dbl = 1 2 4
Solving Algebraic Equations: Transcendental Equations Poly 2 Sym Command n n n The poly 2 sym(f) command converts a polynomial coefficient vector to symbolic polynomial expression in terms of the default symbolic variable x The poly 2 sym(f, 'v') command converts a polynomial coefficient vector to symbolic polynomial expression in terms of the symbolic variable v The sym 2 poly command converts a symbolic polynomial expression to a polynomial coefficient vector 5
Solving Algebraic Equations: Transcendental Equations Poly 2 sym Example n Example: » p=[5, 2, -1, 1, 10]; » sym_exp=poly 2 sym(p) sym_exp = 5*x^4+2*x^3 -x^2+x+10 Polynomial Vector Symbolic Expression » poly_vec=sym 2 poly(sym_exp) poly_vec = 5 2 -1 1 10 Polynomial Vector 6
Solving Algebraic Equations: Transcendental Equations Exponential Transcendental Equation Example n Use the solve command to solve the transcendental equation: » xs_sym=solve(exp(2*x)+3*exp(x)-54) xs_sym = [ log(-9)] [ log(6)] » xs_dbl=double(xs) xs_dbl = 2. 1972 + 3. 1416 i 1. 7918 Complex Solution Real Solution 7
Solving Algebraic Equations: Transcendental Equations Verify Loge(-9) n n n In Matlab, log is the natural log of base e: Verify ln(-a) is a complex number : In this case -a = -9, so: 8
Solving Algebraic Equations: Transcendental Equations Complex Solution Example n n Solve the nonlinear equation: Verify the result » syms x » rt = solve('x^2+exp(x)+5') rt = 3. 5668799472626199482146544957277+ 4. 8873680198538466074569067078051*i » z=subs('x^2+exp(x)+5', rt) z =. 2 e-30 9
Solving Algebraic Equations: Transcendental Equations Summary n n The solve command can be used to solve symbolic transcendental equations with real or complex solutions poly 2 sym and sym 2 poly commands can be used to convert polynomial vectors to/from symbolic expressions 10
- Slides: 10