MATLAB Exercise 5 School of Mathematical Sciences Xiamen University http:/edjpkc.xmu.ed MATLAB Exercise 5-Symbol Computation 1. Compare the following commands, and show the data types and values of al, a2, a3 and a4 >>al=1/4+1/6 >>a2=sym(1/4+1/6 >>a3=1/4+1/6′ >>a4-21/4+1/6;eval(a4) 2. Input following commands, try to compare and analysis the results 1) a)>> clear; cl=a+2*a; cl 2) a)>> clear; c3=a+2*a'; eval(c3 b)>> clear; c4=a+2*a'; a=3; eval(c4) 3)a)>>clear; syms a; c5=a+2*a'; eval(c5) b)>> clear; syms a; c6=a+2*a; eval(c6) c)>>clear; syms a; c7=sym(a+2*a'); subs(c7, a, 2) d)>> clear; syms a; c8-sym(a+2*a); subs(c8, 2) 4)a)>> clear; cg=sym(a+2a+b): c9 b)>> clear; c10=sym(a+2*a+b); subs(c10, 1) c)>> clear; cll-sym(a+2*a+b); subs(cll, a, 1) d)>> clear; syms a; c12=sym(a+2*a+b): subs(c12, a, 1) e)>> clear; syms a b; c13=sym(a+2*a+b); subs(c13, a, 1, b, 2) f>> clear; syms a b; c14=sym(a+2*a+b); subs(c14, [a,b], [1, sym(pi)D 3.Let∫=x3-6x+11x-6,g=(x-1)(x-2)x-3),h=xx(x-6)+11]-6. Please use function factor, horner, expand to prove the following conclusion 1)fis the expanded form of g and h g is the factor form of f 3)h is the nested form of f 4. Please simply the following functions by using simple, simplify and pretty respectively 1612 1) 2)coS x+v-Sin x 4)e x+1x-1 sin za sin a cos a 6)cos 4a-4 cos 2a+3 (1+cos 4a)(1+cos a)(1-cos a) Help in command window input help simple (and simplify), understand the effect of these function 5. Let s express the symbolic expression asin(x)+e. Use subs function to compute the Ex5-1
MATLAB Exercise 5 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Ex51 MATLAB Exercise 5 – Symbol Computation 1. Compare the following commands, and show the data types and values of a1, a2, a3 and a4. >> a1=1/4+1/6 >> a2=sym(1/4+1/6) >> a3='1/4+1/6' >> a4='1/4+1/6'; eval(a4) 2. Input following commands, try to compare and analysis the results. 1) a) >> clear; c1= a+2*a; c1 2) a) >> clear; c3='a+2*a'; eval(c3) b) >> clear; c4=' a+2*a'; a=3; eval(c4) 3) a) >> clear; syms a; c5=’ a+2*a'; eval(c5) b) >> clear; syms a; c6= a+2*a; eval(c6) c) >> clear; syms a; c7=sym('a+2*a'); subs(c7, a, 2) d) >> clear; syms a; c8=sym('a+2*a'); subs(c8, 2) 4) a) >> clear; c9=sym(' a+2*a+b'); c9 b) >> clear; c10=sym('a+2*a+b'); subs(c10, 1) c) >> clear; c11=sym(' a+2*a+b'); subs(c11, a, 1) d) >> clear; syms a; c12=sym('a+2*a+b'); subs(c12,a,1) e) >> clear; syms a b; c13=sym('a+2*a+b'); subs(c13,a,1, b,2) f) >> clear; syms a b; c14=sym('a+2*a+b'); subs(c14, [a,b], [1, sym('pi')]) 3. Let 3 2 f = x - 6x +11x - 6 , g = (x -1)(x - 2)(x - 3) , h = x[x(x - 6) +11]- 6 . Please use function factor, horner, expand to prove the following conclusion: 1) f is the expanded form of g and h 2) g is the factor form of f 3) h is the nested form of f 4. Please simply the following functions by using simple, simplify and pretty respectively 1) 3 3 2 1 6 12 8 x x x + + + 2) 2 cos x + -sin x 3) 1 1 x 1 x 1 + + - 4) c ln a b e + 5) sin 2 sin cos (1 cos 4 )(1 cos )(1 cos ) a a a + a + a - a 6) cos 4a - 4 cos 2a + 3 Help in command window input help simple (and simplify), understand the effect of these function. 5. Let s express the symbolic expression sin( ) y a x + e . Use subs function to compute the
MATLAB Exercise School of mathematical ces Xiamen University http:/edjpkc.xmu.ed ollowing expressions, and simply the results 1)asin(x)+e 2)asin()+1 6. Set p=a+xy+2xy2+3xy. Please use collect function to 1) collects all the coefficients with the same power of x 2)views p as a polynomial in its symbolic variable y 7. Use randn function to generate a random 2X2 matrix A. Substitute a matrix A into the symbolic expression 3x--2x+5 8. Set symbolic expression f(x)=e. Please compute the value of 1)f(0) 2) f(eps) 3)f(1),f(2)f(3),…,f(20) 9. Generate two symbolic matrices s a= c d s I 1)s ats b 2)2*sa 3)s a*s b 8)sc lO)det(s a) I1)inv(s a) 10. Let a be2×2 matrIx, b be a symbolic matrⅸbs/l For the following coefficient matrices a, solve the linear equations axb 23 3 c 234 11. For the following matrix a, compute the eigenvalues and eigenvectors of a 1)numeric matrix a= 2)symbolic matrix a= 3)symbolic matrix a 4)symbolic matrix a= 34 2. For the matrices as Exll, compute their lu, schur, svd decompositions respectively Ex5-2
MATLAB Exercise 5 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Ex52 following expressions, and simply the results. 1) ln sin( ) t a x + e 2) sin( ) 1 3 a p + 6. Set 2 2 p = a + xy + 2xy + 3x y . Please use collect function to 1) collects all the coefficients with the same power of x 2) views p as a polynomial in its symbolic variable y 7. Use randn function to generate a random 2×2 matrix A. Substitute a matrix A into the symbolic expression 2 3x - 2x + 5. 8. Set symbolic expression ( ) x f x e - = . Please compute the value of 1) f (0) 2) f (eps) 3) f (1), f (2), f (3),..., f (20) 9. Generate two symbolic matrices _ , _ a b u v s a s b c d s t È ˘ È ˘ = = Í ˙ Í ˙ Î ˚ Î ˚ , compute 1) s_a+s_b 2) 2*s_a 3) s_a*s_b 4) s_a.*s_b 5) s_a\s_b 6) s_a/s_b 7) s_c=s_a+i*s_b 8) s_c’ 9) s_c .’ 10) det(s_a) 11) inv(s_a) 10. Let a be 2×2 matrix, b be a symbolic matrix 1 b x È ˘ = Í ˙ Î ˚ . For the following coefficient matrices a, solve the linear equations ax=b. 1) 1 2 3 4 a È ˘ = Í ˙ Î ˚ 2) 1 2 3 6 a È ˘ = Í ˙ Î ˚ 3) 1 2 a È ˘ = Í ˙ Î ˚ 4) 1 2 3 a c È ˘ = Í ˙ Î ˚ 5) c d a e f È ˘ = Í ˙ Î ˚ 6) 1 2 3 2 3 4 a È ˘ = Í ˙ Î ˚ 11. For the following matrix a, compute the eigenvalues and eigenvectors of a. 1) numeric matrix 1 2 3 4 a È ˘ = Í ˙ Î ˚ 2) symbolic matrix 1 2 3 4 a È ˘ = Í ˙ Î ˚ 3) symbolic matrix 1 3 4 x a È ˘ = Í ˙ Î ˚ 4) symbolic matrix s t a u v È ˘ = Í ˙ Î ˚ 12. For the matrices as Ex11, compute their lu, schur, svd decompositions respectively