Lec 08. Symbolic Math Toolbox I

Download Lec 08. Symbolic Math Toolbox I

Post on 15-Jun-2015

850 views

Category:

Education

28 download

Embed Size (px)

TRANSCRIPT

<ul><li> 1. MATLAB ProgrammingSymbolic Math Toolbox I kmste2@kaist.ac.kr1</li></ul><p> 2. MATLAB ProgrammingSymbolic Math Toolbox , &gt;&gt; x = 1; &gt;&gt; y = x + x y= 2y = x + x y = 2*x ?Symbolic Math Toolbox ! Symbolic Expression 2 3. MATLAB Programming Symbolic Expression Symbolic Expression syms x, y, z symbolic &gt;&gt; syms x y z Symbolic Expression , symbol &gt;&gt; y = x + x + 2*z y= 2*x + 2*z3 4. MATLAB Programming Symbolic Expression Symbolic Symbolic Expression &gt;&gt; syms x &gt;&gt; y = x + k Undefined function or variable 'k'. Symbol , &gt;&gt; syms x &gt;&gt; class(x) ans = sym &gt;&gt; x = single(10.3125); &gt;&gt; class(x) ans = single 4 5. MATLAB ProgrammingSymbolic Toolbox Calculus , , , , Linear Algebra, , determinant, canonical forms, Simplification, , , Equation Solving Variable-Precision Arithmetics Transformation Special Functions, , Fourier Transform, Laplace Transform, Z-transform, 5 6. MATLAB Programmingsym S = sym(A) A symbolic number/variable/object A , symbolic representation &gt;&gt; x = magic(2); &gt;&gt; xsym = sym(x) xsym = [ 1, 3] [ 4, 2] &gt;&gt; class(xsym) ans = sym6 7. MATLAB Programmingsym x = sym(x) x symbolic variable x= sym(x, real)x symbolic variable &gt;&gt; syms x real real &gt;&gt; x = sym(x, unreal)k = sym(k, positive) symbolic variable k &gt;&gt; A = sym('A', [2 3]) A= [ A1_1, A1_2, A1_3] [ A2_1, A2_2, A2_3] &gt;&gt; A = sym('A', [1 3])x = sym(x, clear) symbolic variable x real, positive A = sym(A, [M N]) A M x N symbolic variable Ai_j . Ak [ A1, A2, A3]A = sym(A, N) A N x N symbolic variable Ai_j . Ak A=A=&gt;&gt; A = sym('A', 2)[ A1_1, A1_2] [ A2_1, A2_2] 7 8. MATLAB Programmingsym A = sym(A_%d_%d, [M N]) A_i_j , A M x N symbolic variable A_k A(i, j) S = sym(A, flag) A , flag r, f, e, d r : rational (default) f : floating point e : estimated error d : decimal &gt;&gt; r = sym(1/3) r = 1/3&gt;&gt; A = sym('A_%d_%d', [3 2]) A= [ A_1_1, A_1_2] [ A_2_1, A_2_2] [ A_3_1, A_3_2] &gt;&gt; B = sym(B_%d_%d', [3 1]) B= B_1_1 B_2_1 B_3_1&gt;&gt; f = sym(1/3, 'f') f = 6004799503160661/18014398509481984&gt;&gt; A(2,2)&gt;&gt; d = sym(1/3, 'd') d = 0.33333333333333331482961625624739ans =&gt;&gt; e = sym(1/3, 'e') e = 1/3 - eps/12A_2_2 8 9. MATLAB Programming , 2 x 3 A, B, c, d symbolic variable , &gt;&gt; A = sym('A_%d_%d', [2, 3]); &gt;&gt; B = sym('B_%d_%d', [2, 3]); &gt;&gt; syms c d % &gt;&gt; A = sym(A, real); A, &gt;&gt; B = sym(B, real);B &gt;&gt; A+B ans = [ A_1_1 + B_1_1, A_1_2 + B_1_2, A_1_3 + B_1_3] [ A_2_1 + B_2_1, A_2_2 + B_2_2, A_2_3 + B_2_3] &gt;&gt; A-B ans = [ A_1_1 - B_1_1, A_1_2 - B_1_2, A_1_3 - B_1_3] [ A_2_1 - B_2_1, A_2_2 - B_2_2, A_2_3 - B_2_3]9 10. MATLAB Programming ( /) &gt;&gt; c*A+d ans = [ d + A_1_1*c, d + A_1_2*c, d + A_1_3*c] [ d + A_2_1*c, d + A_2_2*c, d + A_2_3*c] &gt;&gt; c./A ans = [ c/A_1_1, c/A_1_2, c/A_1_3] [ c/A_2_1, c/A_2_2, c/A_2_3] &gt;&gt; A .* B ans = [ A_1_1*B_1_1, A_1_2*B_1_2, A_1_3*B_1_3] [ A_2_1*B_2_1, A_2_2*B_2_2, A_2_3*B_2_3] &gt;&gt; A * B' ans = [ A_1_1*B_1_1 + A_1_2*B_1_2 + A_1_3*B_1_3, A_1_1*B_2_1 + A_1_2*B_2_2 + A_1_3*B_2_3] [ A_2_1*B_1_1 + A_2_2*B_1_2 + A_2_3*B_1_3, A_2_1*B_2_1 + A_2_2*B_2_2 + A_2_3*B_2_3]10 11. MATLAB Programming &gt;&gt; A = sym('A_%d_%d', [2 2]); &gt;&gt; inv(A) ans = 1=1 [ A_2_2/(A_1_1*A_2_2 - A_1_2*A_2_1), -A_1_2/(A_1_1*A_2_2 - A_1_2*A_2_1)] [ -A_2_1/(A_1_1*A_2_2 - A_1_2*A_2_1), A_1_1/(A_1_1*A_2_2 - A_1_2*A_2_1)] &gt;&gt; pretty(ans)Determinant &gt;&gt; det(A) ans = A_1_1*A_2_2 - A_1_2*A_2_111 12. MATLAB ProgrammingComplex Value real , i &gt;&gt; x = sym('x', 'real'); &gt;&gt; class(z) &gt;&gt; y = sym('y', 'real'); &gt;&gt; z = x + i * yans = symz=&gt;&gt; conj(z) ans = x - y*ix + y*i real , &gt;&gt; x = sym('x'); &gt;&gt; y = sym('y'); &gt;&gt; z = x+y*i z= x + y*i &gt;&gt; conj(z) ans = conj(x) - conj(y)*i 12 13. MATLAB Programming &gt;&gt; syms f(t) &gt;&gt; syms g(x,y) &gt;&gt; f(t) = 1/2*9.8*t^2 f(t) = (49*t^2)/10 &gt;&gt; g(x,y) = cos(x)*cos(y)+sin(x)*sin(y) g(x, y) = cos(x)*cos(y) + sin(x)*sin(y) &gt;&gt; f(5) ans = 245/2 &gt;&gt; g(3,4) ans = cos(3)*cos(4) + sin(3)*sin(4)13 14. MATLAB Programming &gt;&gt; syms f(t) &gt;&gt; syms g(x,y) &gt;&gt; f(t) = 1/2*9.8*t^2 f(t) =&gt;&gt; ezplot( f ) &gt;&gt; t = linspace(-2*pi, 2*pi, 50); &gt;&gt; plot( t, f(t) )(49*t^2)/10 &gt;&gt; g(x,y) = cos(x)*cos(y)+sin(x)*sin(y) g(x, y) = cos(x)*cos(y) + sin(x)*sin(y) &gt;&gt; ezsurf(g) &gt;&gt; t = linspace(-2*pi,2*pi,50) &gt;&gt; [X,Y] = meshgrid( t ); &gt;&gt; Z = double( g(X,Y) ); &gt;&gt; surf(X,Y,Z)14 15. MATLAB Programmingsym Expression y = sym(5*x^2 3)&gt;&gt; y = sym('5*x^2+3') y= 5*x^2 + 3 &gt;&gt; ezplot(y)15 16. MATLAB Programmingsym Expression expression ) y = sym(5*x^2 3 = 2)&gt;&gt; y = sym('5*x^2+3=2') y= 5*x^2 + 3 == 2 &gt;&gt; solve(y) ans = (5^(1/2)*i)/5 -(5^(1/2)*i)/516 17. MATLAB Programming expression , , &gt;&gt; z1 = sym('3*(1-x)^2+5*x-(y+1)^2'); &gt;&gt; z2 = sym('y^2-5*x*y+2*(x+y)-5'); &gt;&gt; z1 z1 = 5*x + 3*(x - 1)^2 - (y + 1)^2 &gt;&gt; z2 z2 = 2*x + 2*y - 5*x*y + y^2 - 5 &gt;&gt; z1+z2 ans = 7*x + 2*y + 3*(x - 1)^2 - (y + 1)^2 - 5*x*y + y^2 - 5 &gt;&gt; z1-z2 ans = 3*x - 2*y + 3*(x - 1)^2 - (y + 1)^2 + 5*x*y - y^2 + 5 &gt;&gt; z1*z2 ans = (5*x + 3*(x - 1)^2 - (y + 1)^2)*(2*x + 2*y - 5*x*y + y^2 - 5)17 18. MATLAB ProgrammingSymbolic Math , diff symbolic math &gt;&gt; help diff symbolic math diff help toolbox ) Overloaded methods: sym/diff &gt;&gt; help sym/diff 18 19. MATLAB ProgrammingSymbolic Math f(x) 1. symbolic &gt;&gt; syms x n 2. &gt;&gt; f = x^n 3. sym/diff f(x) &gt;&gt; df = diff( f ) df = n*x^(n - 1)&gt;&gt; df = diff( f, x ) df = n*x^(n - 1) 19 20. MATLAB ProgrammingSymbolic Math f(x) 1. symbolic &gt;&gt; syms x nx ? 2. symbolic toolbox x , x x &gt;&gt; f = x^n 3. sym/diff f(x) &gt;&gt; df = diff( f ) df = n*x^(n - 1)&gt;&gt; df = diff( f, x ) df = n*x^(n - 1) 20 21. MATLAB Programming n diff( , , n) &gt;&gt; syms a b t &gt;&gt; g = cos(a*t+b); &gt;&gt; dg1 = diff(g, t)&gt;&gt; syms x n &gt;&gt; f = x^n; &gt;&gt; df = diff(f, x, 2)dg1 =df = n*x^(n - 2)*(n - 1) f 2 &gt;&gt; dg2 = diff(gd1, t)&gt;&gt; df = diff(f, x, 3) df = n*x^(n - 3)*(n - 1)*(n - 2)-a*sin(b + a*t)dg2 = f 3 -a^2*cos(b + a*t) g 1 g 1 1 &gt;&gt; gd = diff(g, 2) gd = g 2 -a^2*cos(b + a*t)21 22. MATLAB Programming A = diff( ) m x n , , A &gt;&gt; syms a b x &gt;&gt; M = [a*x^2+b x*exp(-a*x); cos(a*x) -sin(a*x+b)] M= [ a*x^2 + b, x*exp(-a*x)] [ cos(a*x), -sin(b + a*x)] &gt;&gt; gM = diff(M, x, 1) gM = [ 2*a*x, exp(-a*x) - a*x*exp(-a*x)] [ -a*sin(a*x), -a*cos(b + a*x)] 22 23. MATLAB Programming n , &gt;&gt; syms x y &gt;&gt; f = x^2*exp(-y^2)-y/x; &gt;&gt; fx = diff(f, x) fx = 2*x*exp(-y^2) + y/x^2 &gt;&gt; fxy1 = diff(fx, y) fxy1 = 1/x^2 - 4*x*y*exp(-y^2) &gt;&gt; fxy2 = diff(fy, x)&gt;&gt; fy = diff(f, y)fxy2 =fy =1/x^2 - 4*x*y*exp(-y^2)- 1/x - 2*x^2*y*exp(-y^2)23 24. MATLAB Programming P(t) = (x(t), y(t), z(t)) v(t) = [x(t0), y(t0), z(t0)] P(t) = (cos(t), sin(t), t/2pi) . syms t x = cos(t); y = sin(t); z = t/(2*pi); m = 0:0.1:4*pi; plot3( subs(x,m), subs(y,m), subs(z,m) ); hold on; dx = diff(x); dy = diff(y); dz = diff(z); for s = linspace(0, 4*pi, 20) p = [subs(x,s), subs(y,s), subs(z,s)]; v = [subs(dx,s), subs(dy,s), subs(dz,s)]; nv = v / norm(v); ar = [p' p'+nv']; plot3(ar(1,:), ar(2,:), ar(3,:), 'color', 'r'); end grid on; axis on;24 25. MATLAB Programming &gt;&gt; syms x a t h; &gt;&gt; limit(sin(x)/x) ans = 1limit( F, x, a ) F x a limit( F ) F a 0 limit( F, x, a, right ) F x a limit( F, x, a, left ) F x a lim () 0lim () lim ()lim ()+MATLAB limit( f ) limit( f, x, 0 ) limit( f, x, a ) limit( f, a) limit( f, x, a, left ) limit( f, x, a, right )&gt;&gt; limit((x-2)/(x^2-4),2) ans = 1/4sin 0 lim lim2 2 2 42 &gt;&gt; limit((1+2*t/x)^(3*x),x,inf) lim 1 + ans = exp(6*t)&gt;&gt; limit(1/x,x,0,'right') ans = Inf &gt;&gt; limit(1/x,x,0,'left') ans = -Inflim+0lim031 1 &gt;&gt; limit((sin(x+h)-sin(x))/h,h,0) sin + sin ans = lim 0 cos(x) &gt;&gt; v = [(1 + a/x)^x, exp(-x)]; &gt;&gt; limit(v,x,inf,'left') ans = [ exp(a), 0] lim 1 + lim 25 26. MATLAB Programming Symbolic Math Toolbox MATLAB = lim 1 2 1% MATLAB % Symbolic Math Toolbox&gt;&gt; n = realmax&gt;&gt; syms n &gt;&gt; f = n*(2^(1/n)-1); &gt;&gt; limit(f, inf)n= 1.7977e+308ans = &gt;&gt; x = n*(2^(1/n)-1) log(2) x= 0 26 27. MATLAB ProgrammingQuiz limit . = lim 1 + = lim 1 = =0 4 2 3+1 lim 3 2 +25 1 lim 0 sin 27 28. MATLAB ProgrammingQuiz Sol. limit . = lim 1 + = lim 1 0 2 1 = lim sin 0ans = exp(x) &gt;&gt; syms x &gt;&gt; limit( 1/x, x, 0, 'left' ) = lim 423+1 3 +25 &gt;&gt; syms n x &gt;&gt; limit( (1+x/n)^n, n, inf )ans = -Inf &gt;&gt; syms x &gt;&gt; f = (4*x^2 - 3*x + 1) / (3*x^2 + 2*x - 5); &gt;&gt; limit( f, x, inf ) ans = 4/3 &gt;&gt; syms x &gt;&gt; limit( (exp(x)-1) / sin(x), x, 0 ) ans = 128 29. MATLAB ProgrammingQuiz . = lim 0+ () = diff , .29 30. MATLAB ProgrammingQuiz Sol. . = lim 0+ () = diff , . &gt;&gt; syms x &gt;&gt; diff(cos(x)) ans = -sin(x)&gt;&gt; syms x h &gt;&gt; limit( (cos(x+h) - cos(x))/h, h, 0 ) ans = -sin(x) 30 31. MATLAB Programming&gt;&gt; syms x x1 alpha u t; &gt;&gt; int(1/(1+x^2)) int( int( int( int( F F, v )&gt;&gt; int(x1*log(1+x1),0,1) F v S, a, b ) F [a, b] S, v, a, b )ans = 1/4 &gt;&gt; int(4*x*t,x,2,sin(t)) F v [a, b] ans = -2*t*(cos(t)^2 + 3) () () () ans = atan(x)F)MATLAB int( f ) int( f, x )ans = [ sin(t*x)/x, -cos(t*x)/x] [ cos(t*x)/x, sin(t*x)/x] &gt;&gt; int([exp(t),exp(alpha*t)]) C !!1 1 + 21 1 log 1 + 1 1 0sin 24 cos &gt;&gt; A = [cos(x*t),sin(x*t);-sin(x*t),cos(x*t)]; &gt;&gt; int(A,t)int( f, t )int( f, x, a, b )ans = [ exp(t), exp(alpha*t)/alpha] sin sin cos 31 32. MATLAB ProgrammingQuiz int . = () , = sin 2 = 3 2 2 + 1, 0 2 = tan32 , 0 1 1 = 3 sin , 0 32 33. MATLAB ProgrammingQuiz Sol. int . = 2, = sin = 3 2 2 + 1, 0 2 =tan1 , 320 1 = 3 sin , 0 &gt;&gt; syms x &gt;&gt; int( exp(-x^2), x, -inf, inf ) ans = pi^(1/2) &gt;&gt; syms x &gt;&gt; int( x*sin(x), x) ans = sin(x) - x*cos(x) &gt;&gt; syms x &gt;&gt; int( x^3-2*x^2+x-1, x, 0, 2 ) ans = -4/3 &gt;&gt; syms x &gt;&gt; int(atan(x)/x^(3/2), x, 0, 1) ans = - pi/2 + 2^(1/2)*atan(2^(1/2)*(1/2 - i/2))*(1 + i) + 2^(1/2)*atan(2^(1/2)*(1/2 + i/2))*(1 - i) &gt;&gt; syms x &gt;&gt; int(x^3-exp(x)*sin(x), 0, pi) ans = pi^4/4 - exp(pi)/2 - 1/233 34. MATLAB Programming 34 35. MATLAB Programming (analytic) trapz trapezoidal method quad Simpson quadrature rule quadl Lobatto quadrature rule 35 36. MATLAB Programming &gt;&gt; syms x real &gt;&gt; int( x*log(x), x, 2, 4 ) 4 2 log 01 ans = 14*log(2) 3 2&gt;&gt; quad( @(x) x.*log(x), 2, 4 ) ans = 6.7041 &gt;&gt; syms x real &gt;&gt; int( exp(-x^2)*log(1+x^2), x, 0, 1 ) Warning: Explicit integral could not be found.log 1 + 2 2 2 0 1+ 2 ()ans = int(exp(-x^2)*log(x^2 + 1), x == 0..1) &gt;&gt; quadl( @(x) exp(-x.^2).*log(1+x.^2), 0, 1 ) ans = 0.1539 &gt;&gt; syms x real &gt;&gt; int( sin(x)^2/sqrt(1+cos(x)^2), x, 0, 2*pi ) Warning: Explicit integral could not be found. ans = int(sin(x)^2/(cos(x)^2 + 1)^(1/2), x == 0..2*pi) &gt;&gt; quadl( @(x) sin(x).^2./sqrt(1+cos(x).^2), 0, 2*pi ) ans = 2.847836 37. MATLAB Programming x(t), y(t) t = cos 02 = sin 2 0clear all; n = 1000; x = zeros(1, n); y = zeros(1, n); t = linspace(0, 4*pi, n+1); for i = 1:n x(i) = quadl(@(x) cos(x.^2), t(i), t(i+1), 1e-3); y(i) = quadl(@(x) sin(x.^2), t(i), t(i+1), 1e-3); end x = cumsum(x); y = cumsum(y); plot([-x(end:-1:1) 0 x], [-y(end:-1:1) 0 y]) axis equal;37 38. MATLAB Programming , = , = , 1 0 ( 2 + + ) 23 4 0 ( 2 + cos ) 61&gt;&gt; syms x y real &gt;&gt; f = x^3 + x + y; &gt;&gt; int(int(f,y,0,3),x,1,2)ans = 81/4 &gt;&gt; syms x y real &gt;&gt; f = y^2*exp(x)+x*cos(y); &gt;&gt; int(int(f,x,0,1), y,4,6) ans = (152*exp(1))/3 - sin(4)/2 + sin(6)/2 - 152/3 &gt;&gt; double(ans) ans = 87.298338 39. MATLAB Programming numerical method dblquad, triplequad , 4 0 ( 2 + cos ) 61 0 0 0 ( + ) sin 2 + 2 111&gt;&gt; syms x y z real &gt;&gt; f = (y+z)*sin(pi*(x^2+y^2)); &gt;&gt; int(int(int(f,x,0,1),y,0,1),z,0,1)&gt;&gt; fxy = @(x, y) (y^2*exp(x) + x*cos(y)); &gt;&gt; dblquad(fxy, 0, 1, 4, 6) ans =87.2983ans =&gt;&gt; f = @(x,y,z) (y+z).*sin(pi*(x.^2+y.^2)); &gt;&gt; triplequad(f,0,1,0,1,0,1)(fresnelC(2^(1/2))*(2^(1/2) + pi*fresnelS(2^(1/2))))/(2*pi)ans =&gt;&gt; double(ans) ans = 0.30780.307839 40. MATLAB ProgrammingSymbolic : ( 2 + + ) &gt;&gt; syms x y a b c d real &gt;&gt; f = x^3 + x + y; &gt;&gt; int(int(f,y,c,d),x,a,b) ans = ((a - b)*(c - d)*(a^3 + a^2*b + a*b^2 + 2*a + b^3 + 2*b + 2*c + 2*d))/4 eg) 0 0 0 2&gt;&gt; syms r theta z h a real &gt;&gt; V = int(int(int(r,r,0,a),theta,0,2*pi),z,0,h) V= pi*a^2*h 40 41. MATLAB Programming (factor ) &gt;&gt; syms x y &gt;&gt; f = x^3 - 6*x^2 + 11*x - 6; &gt;&gt; factor(f) ans = (x - 3)*(x - 1)*(x - 2) (expand ) &gt;&gt; expand(ans) ans = x^3 - 6*x^2 + 11*x 6 &gt;&gt; expand(cos(x+y)) ans = cos(x)*cos(y) - sin(x)*sin(y) 41 42. MATLAB Programming (simplify ) &gt;&gt; syms x c alpha beta &gt;&gt; simplify(sin(x)^2 + cos(x)^2) ans = 1 &gt;&gt; simplify(exp(c*log(sqrt(alpha+beta)))) ans = (alpha + beta)^(c/2)42 43. MATLAB Programming (collect ) &gt;&gt; syms x y &gt;&gt; collect(x^2*y + y*x - x^2 - 2*x) ans = (y - 1)*x^2 + (y - 2)*xcollect(S, v) : S v polynomial &gt;&gt; syms x &gt;&gt; f = -1/4*x*exp(-2*x)+3/16*exp(-2*x) f= (3*exp(-2*x))/16 - (x*exp(-2*x))/4 &gt;&gt; collect(f, exp(-2*x)) ans = (3/16 - x/4)*exp(-2*x) 43 44. MATLAB Programming (pretty ) &gt;&gt; syms x y &gt;&gt; f = 1/(x-1)*sin(x) f= sin(x)/(x - 1) &gt;&gt; pretty(f) sin(x) -----x-1&gt;&gt; syms x &gt;&gt; int(sqrt(tan(x))) ans = (2^(1/2)*(log(2^(1/2)*tan(x)^(1/2) - tan(x) - 1) - log(tan(x) + 2^(1/2)*tan(x)^(1/2) + 1)))/4 + (2^(1/2)*(atan(2^(1/2)*tan(x)^(1/2) - 1) + atan(2^(1/2)*tan(x)^(1/2) + 1)))/2 &gt;&gt; pretty(ans) 1/2 1/2 1/2 1/2 1/2 1/2 1/2 1/2 1/2 1/2 2 (log(2 tan(x) - tan(x) - 1) - log(tan(x) + 2 tan(x) + 1)) 2 (atan(2 tan(x) - 1) + atan(2 tan(x) -------------------------------------------------------------------------- + ---------------------------------------------------------4 2+ 1))44 45. MATLAB Programming subs symbolic substitution subs(S) S MATLAB workspace subs(S, NEW) S (free variable) NEW subs(S, OLD, NEW) S OLD NEW OLD NEW , OLD NEW 1:1 45 46. MATLAB Programming subs( S ) , &gt;&gt; syms a t y C1 &gt;&gt; y = exp(-a*t)*C1 y= C1*exp(-a*t) a, C1 &gt;&gt; a = 980; C1= 3; &gt;&gt; y y= C1*exp(-a*t) workspace a, C1 &gt;&gt; y = subs(y) y= 3*exp(-980*t) 46 47. MATLAB Programming subs( S, NEW ) &gt;&gt; syms a b c x t &gt;&gt; f = a*sin(b*x)*exp(-a*x^c+t) f= a*exp(t - a*x^c)*sin(b*x) &gt;&gt; syms h &gt;&gt; subs(f, h) ans = a*exp(t - a*h^c)*sin(b*h)subs( S, OLD, NEW ) &gt;&gt; syms a b omega &gt;&gt; f = sin(t) f= sin(t) &gt;&gt; f = subs(f, t, omega*t) f= sin(omega*t)47 48. MATLAB Programming substitution&gt;&gt; syms a b alpha &gt;&gt; subs(cos(a)+sin(b),{a,b},[alpha,2]) ans = sin(2) + cos(alpha) substitution&gt;&gt; syms a t &gt;&gt; subs(exp(a*t), a,-magic(2)) ans = [ exp(-t), exp(-3*t)] [ exp(-4*t), exp(-2*t)] substitution&gt;&gt; syms x y &gt;&gt; subs(x*y,{x,y},{[0 1;-1 0],[1 -1;-2 1]}) ans = [ 0, -1] [ 2, 0]48 49. MATLAB ProgrammingSymbolic Summation symsum( f ) (default variable) f(0) + f(1) + + f(n-1) symsum( f, x ) x f(0) + f(1) + + f(n-1) symsum( f, a, b ) (default variable) f(a) + f(a+1) + + f(b) symsum( f, x, a, b ) x f(a) + f(a+1) + + f(b) 49 50. MATLAB ProgrammingSymbolic Summation &gt;&gt; sy...</p>