KeytoMatlabExercise7SchoolofMathematicalSciencesXiamenUniversityhttp:/gdjpkc.xmu.edr Key to matlab Exercise 7--calculus > clear; syms yl ux; y1=(l+ur2y(1/2): u exp(-x) >> yl= compose(yl, u, x) Or > clear; syms x: uexp(-x): yl=(1+ur2r(1/2) no recommend yI (1+exp(-x)y2)(1/2) > clear; syms y2 uvx; y2=(1+ur2y(1/2); u=log(v); v=exp(-x) > u x=compose(u, v, x); y2=compose(y2, u x, x) Or > clear; syms y2 uvx; y2=(1+ur2r(1/2); UFlog(v); v=exp(-X) > y2=compose(y2, compose(u, v, x)) > clear; syms x; v=exp(x); LFlog(v); y2=(1+ur2)(1/2) no recommend (1+log(exp(-x)y2)(1/2) > clear; syms y uv wx: y=(l+ur2y(1/2); uFlog(v); v=sin( w); w=exp(-x) >>v x=compose(v, w, x); u x=compose(u, v x, x): y=compose(y, u x, x) Or > clear; syms y uv; y=(l+ur2y(1/2); fLog(v): v=sin( w); w=exp(-x) e(y, compose(u, compose(v, w, x)) > clear; syms x; w=exp(-x); v=sin(w): u=log(v): y=(1+u2r(1/2) no recommend (1+log(sin(exp(-x)^2)(1/2) > clear; syms x y; y=(l+(log(sin(x))2y(1/2) > inverse(y, x) Warning: inverse((1+log(sin(x)2y(1/2) is not unique In sym. inverse at 43 ans asn(exp(-1+x2)(1/2) > clear; syms x u y, y=(x+log(sin(u))r(1/2) > inverse(y ans asin(exp(-X+ur2))
Key to MATLAB Exercise 7 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Key to Ex71 Key to MATLAB Exercise 7 – Calculus 1. 1) >> clear; syms y1 u x; y1=(1+u^2)^(1/2); u= exp(x); >> y1= compose(y1,u,x) Or >> clear; syms x; u=exp(x); y1=(1+u^2)^(1/2) % no recommend y1 = (1+exp(x)^2)^(1/2) 2) >> clear; syms y2 u v x; y2=(1+u^2)^(1/2); u =log(v); v=exp(x); >> u_x=compose(u,v,x); y2=compose(y2,u_x,x) Or >> clear; syms y2 u v x; y2=(1+u^2)^(1/2); u=log(v); v=exp(x); >> y2=compose(y2, compose(u, v, x)) Or >> clear; syms x; v=exp(x); u=log(v); y2=(1+u^2)^(1/2) % no recommend y2 = (1+log(exp(x))^2)^(1/2) 3) >> clear; syms y u v w x; y=(1+u^2)^(1/2); u=log(v); v=sin(w); w=exp(x); >> v_x=compose(v,w,x); u_x=compose(u,v_x,x); y=compose(y,u_x,x) Or >> clear; syms y u v w x; y=(1+u^2)^(1/2); u=log(v); v=sin(w); w=exp(x); >> y=compose(y, compose(u, compose(v, w, x))) Or >> clear; syms x; w=exp(x); v=sin(w); u=log(v); y=(1+u^2)^(1/2) % no recommend y = (1+log(sin(exp(x)))^2)^(1/2) 2. 1) >> clear; syms x y; y=(1+(log(sin(x)))^2)^(1/2); >> finverse(y,x) Warning: finverse((1+log(sin(x))^2)^(1/2)) is not unique. > In sym.finverse at 43 ans = asin(exp((1+x^2)^(1/2))) 2) >> clear; syms x u y; y=(x+log(sin(u)))^(1/2); >> finverse(y,u) ans = asin(exp(x+u^2)) 3)
Key to MATLAB Exercise 7 School of Mathematical Science http:/edjpkc.xmu.ed > clear; syms x uy; y=(x+log(sin(u)))(1/2) >>inverse(y, x) log(sin(u))+x > syms x yl y2; yl=sin(x), y2=asin(sin(x) >> x0=sym(pi/4): subs(y 1, xO) l/2*2^(1/2) ans 1/4 > syms x yl y2, yl=sin(x); y2=asin(sin(x)) > compose(yl, pi/4 ans 1/2*2^(1/2) > compose(y2, pi/4) l/4*p 4 > clear; syms n mx; yl=(tan(n*)-sin(m*x))/x Or > clear; syms n mx, yl=(tan(n*x)-sin(m*x))/x; n-m >> clear; syms x y, y2=(exp(x)-exp(y))/(x-y) >>limit(y2, x,y) ans exp(y) 3) > clear; syms x: y3=x3/(2*x+100) > limit(y3, x, +inf) ans > clear; syms x; y4=x 3/sin(x); ans NaN Ex7-2
Key to MATLAB Exercise 7 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Key to Ex72 >> clear; syms x u y; y=(x+log(sin(u)))^(1/2); >> finverse(y,x) ans = log(sin(u))+x^2 3. >> syms x y1 y2; y1=sin(x); y2=asin(sin(x)); >> x0=sym(pi/4); subs(y1,x0) ans = 1/2*2^(1/2) >> subs(y2,x0) ans = 1/4*pi Or >> syms x y1 y2; y1=sin(x); y2=asin(sin(x)); >> compose(y1,pi/4) ans = 1/2*2^(1/2) >> compose(y2,pi/4) ans = 1/4*pi 4. 1) >> clear; syms n m x; y1=(tan(n*x)sin(m*x))/x; >> limit(y1,0) Or >> clear; syms n m x; y1=(tan(n*x)sin(m*x))/x; >> limit(y1) ans = nm 2) >> clear; syms x y; y2=(exp(x)exp(y))/ (xy); >> limit(y2,x,y) ans = exp(y) 3) >> clear; syms x; y3=x^3/(2*x+100); >> limit(y3,x,+inf) ans = Inf 4) >> clear; syms x; y4=x^3/sin(x); >> limit(y4,x,inf) ans = NaN
Key to MATLAB Exercise 7 School of Mathematical Sciences Xiamen Univer http:/edjpkc.xmu.ed > clear; syms x; y5=(tan(x)(tan(x))) > limit(y5, x, pi/4, right) ans > clear; syms x; y=tan(x/2) >>limit(y, x, pi, left") 5.1) > clear; syms x n h, y=((x+h)n-x'n >>Limit(y, h,0) > simplify(z)) ans x^(-1+n)°n >>clear; syms xn, yxn, ans > simplify(difi(y, x)) x^(-1+n)°n >ssd)88(x3502x2+7) > clear; syms x g:g=(x3-5)(2x2+7) > compose(diff(g x),0) ans > clear; syms x y g:g=(x3 y-5*y)(2*x2+7) 3*x^2(2*x^2+7)4*(X^~3-5)/(2*x~2+7)^2*x > subs(g xy, 1) ans 0.5309 Ex7-3
Key to MATLAB Exercise 7 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Key to Ex73 5) >> clear; syms x; y5=(tan(x)^(tan(x))); >> limit(y5,x,pi/4,’right’) ans = 1 6) >> clear; syms x; y=tan(x/2); >> limit(y,x,pi,'left') ans = Inf 5. 1) >> clear; syms x n h; y=((x+h)^nx^n)/h; >> z=limit(y,h,0) z = x^n/x*n >> simplify(z)) ans = x^(1+n)*n 2) >> clear; syms x n ; y= x^n; >> diff(y, x) ans = x^n/x*n >> simplify(diff(y,x)) ans = x^(1+n)*n 6. 1) >> clear; syms x g; g=(x^35)/(2*x^2+7); >> subs(diff(g,x),0) Or >> clear; syms x g; g=(x^35)/(2*x^2+7); >> compose(diff(g,x),0) ans = 0 2) >> clear; syms x y g; g=(x^3*y5*y)/(2*x^2+7); >> g_xy=diff(diff(g,x),y) g_xy = 3*x^2/(2*x^2+7)4*(x^35)/(2*x^2+7)^2*x >> subs(g_xy, 1) ans = 0.5309 Or
Key to mAtlaB Exercise 7 School of Mathematical Sciences Xiamen University h http:/edjpkc.xmu.ed >>clear; syms x y,g(x3 y-5* y)(2 x2+7);g xy=diff(difi(.x),y) compose(g xy, 1) 3/81 >>clear; syms gg=(x3*y-5*y)(2x2+7) >>gy=diff(g,y) gy- (x^3-5)(2*x^2+7) > subs(g y, [x,[1 2D) 4/9 >> clear; syms x f, fsin(x)*sin(2*x)*sin(3*x); > diff(f,5 1696cos(x)*sin(2*x)*sin(3*x)+2192*sin(x)*cos(2*x)*sin(3*)+2208*sin(x)*sin(2*x)*cos(3 x)-1680*cos(x)*cos(2*x)*cos(3*) 7 >>A=[15,8-2,6,3]B=(-1)*difA) >>A=[1,5,8-2,6,3];C= difI(A2 8. >>clear; syms x y; y=1/(x+1); >> int(y) > clear; syms y; y=1/(x+1); nt(y0,1) log(2) > clear; syms xt y, y=1/(x+l) > int(y, 0, t) ans logit+ Ex7-4
Key to MATLAB Exercise 7 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Key to Ex74 >> clear; syms x y g; g=(x^3*y5*y)/(2*x^2+7); g_xy=diff(diff(g,x),y) >> compose(g_xy,1) ans = 43/81 3) >> clear; syms x y g; g=(x^3*y5*y)/(2*x^2+7); >> g_y=diff(g,y) g_y = (x^35)/(2*x^2+7) >> subs(g_y, [x y], [1 2]) ans = 4/9 4) >> clear; syms x f; f=sin(x)*sin(2*x)*sin(3*x); >> diff(f,5) ans = 1696*cos(x)*sin(2*x)*sin(3*x)+2192*sin(x)*cos(2*x)*sin(3*x)+2208*sin(x)*sin(2*x)*cos(3 *x)1680*cos(x)*cos(2*x)*cos(3*x) 7. 1) >> A=[1,5,8,2,6,3]; B=(1)*diff(A) B = 4 3 10 8 3 2) >> A=[1,5,8,2,6,3]; C=diff(A,2) C = 1 13 18 11 8. 1) >> clear; syms x y; y=1/(x+1); >> int(y) ans = log(x+1) 2) >> clear; syms x y; y=1/(x+1); >> int(y,0,1) ans = log(2) 3) >> clear; syms x t y; y=1/(x+1); >> int(y,0,t) ans = log(t+1) 4)
Key to MATLAB Exercise 7 School of Mathematical Sciences Xiamen Univer http:/edjpkc.xmu.ed > clear; syms x y f, fsin(y)/(x 2*y+1); > int(f, x, -inf, inf ans pi*sin(y/y(1/2) > clear; syms x y f; fsin(y)/(x2 y+1) >>int(int(f, x, -inf, inf), -inf, inf) ans > clear; syms x f, fx2+ >>f int diff=int(diff(f)) f int diffe >>f diff int=diff(int(f)) f diff int= x^2+1 diff(int(f)) is not equal to int(difi(f)), the difference between them is the constant item C >> clear > simplify(symsum(k 3, 1,n)) 1/4*n^4+1/2*n^3+1/4*n^2 > clear; syms k; >> symsum(1/(k^2-1),1,nf) m(1/(k2-1)k=1…Int) > symsum(1/(k 2-1), 2, inf) ans > clear; syms kx f; fk xk; > symsum(f, k, 1, inf) x*(x+1)/(x-1)~3 > clear; syms x f, fexp(2x) > taylor(f, 15) ans Ex7-5
Key to MATLAB Exercise 7 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Key to Ex75 >> clear; syms x y f; f=sin(y)/(x^2*y+1); >> int(f,x,inf,inf) ans = pi*sin(y)/y^(1/2) 5) >> clear; syms x y f; f=sin(y)/(x^2*y+1); >> int(int(f,x,inf,inf),inf,inf) ans = 0 9. >> clear; syms x f; f=x^2+1; >> f_int_diff=int(diff(f)) f _int_diff= x^2 >> f_diff_int=diff(int(f)) f_diff_int = x^2+1 diff(int(f)) is not equal to int(diff(f)), the difference between them is the constant item C. 10. 1) >> clear; syms k n; >> simplify(symsum(k^3,1,n)) ans = 1/4*n^4+1/2*n^3+1/4*n^2 2) >> clear; syms k; >> symsum(1/(k^21),1,inf) ans = sum(1/(k^21),k = 1 .. Inf) 3) >> clear; syms k; >> symsum(1/(k^21),2,inf) ans = 3/4 4) >> clear; syms k x f; f=k^2*x^k; >> symsum(f,k,1,inf) ans = x*(x+1)/(x1)^3 11. 1) >> clear; syms x f; f=exp(2*x); >> taylor(f,15) ans =
KeytoMatlabexErcise7SchoolofMathematicalSciencesXiamenUniversityhttp:/gdjpkc.xmu.edu.cn 1+2*x+2*x^2+4/3*x^3+2/3*x^4+4/15*x^5+445*x^6+8/315*x^7+2/315*x^8+4/2835*x^9+4/14 175*x^10+8/155925*x^11+4/467775*x^12+8/6081075*X^13+8/42567525*x^14 >> clear; syms x f, f-exp(2*x); exp(-2)2*exp(-2)(x+1)+2exp(-2)°(x+1)2+4/3exp(-2)(x+1)^3+2/3°exp(-2)*(x+1)^4+4/ 15*exp(-2)*(x+1)^+4/45*exp(-2)*(x+1)^6+8/315*eXp(-2)(x+1)^7+2/315*exp(-2)°(x+1)^8 3) > clear; syms x y f; fexp(2*y > taylor(f, 5, x) ans 1+2*x*y+2*y^2*x^2+4/3*y3*x3+2/3*y4*x4 > clear; format short e, syms a x; fcos(x)+2*x, f int=int(f) >>b=a+10*pi, a+5 pi, a+pi, a+ 1/2*pi, a+1/16*pi, a+ 1/1024 pi]: >>fork=1:6 y(kint(f,a, b(k)); y app(k =(subs(f int, b(k)-subs(f int, a)*(b(k)-a) >>y, y app -2*sin(a)+10*a*pi+25pi^2, 2*sin(a)+2°a*p+pi^2 cos(a)+a*pi+1/4*pi"2-sin(a) sin(a+l/6°p1)+l/8°a*pi+1/256pi^2-sina) sin(a+1/l024°p)+1/512*api+1/048576*p^2-sin(a) 10°(a+10*p)2-a^2)* a+5*p)^2-a^2)pi, (-2*sin(a)+(a+pi)^2-a2)*pl, l/2*(cos(a)+(a+1/2°pi)^2-sin(a)a^2)°pi 1/16*(sin(a+1/16*pi)+(a+ 1/16 *pir2-sin(a)-ar2)*pi, l/1024(sin(a+1/1024*p)+(a+1/l024p)y2-sn(a)a^2)°pl >>y 0=subs(y, 0); y app 0=subs(y app, 0); error y=y o-y app 0 -3.0019e+004-3.6290e+0032.1137e+001-1.9792e+0001.8777e-0013.0679e-003 (a+ Conclusion While b closes to a 2(b-a)approaches >>clear; format long e; syms x xi; f1/(x+1)2: >> f int=int(f, 0, 1); Xi subs( inverse(f), f int)
Key to MATLAB Exercise 7 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Key to Ex76 1+2*x+2*x^2+4/3*x^3+2/3*x^4+4/15*x^5+4/45*x^6+8/315*x^7+2/315*x^8+4/2835*x^9+4/14 175*x^10+8/155925*x^11+4/467775*x^12+8/6081075*x^13+8/42567525*x^14 2) >> clear; syms x f; f=exp(2*x); >> taylor(f,9,1) ans = exp(2)+2*exp(2)*(x+1)+2*exp(2)*(x+1)^2+4/3*exp(2)*(x+1)^3+2/3*exp(2)*(x+1)^4+4/ 15*exp(2)*(x+1)^5+4/45*exp(2)*(x+1)^6+8/315*exp(2)*(x+1)^7+2/315*exp(2)*(x+1)^8 3) >> clear; syms x y f; f=exp(2*x*y); >> taylor(f,5,x) ans = 1+2*x*y+2*y^2*x^2+4/3*y^3*x^3+2/3*y^4*x^4 12. >> clear; format short e; syms a x; f=cos(x)+2*x; f_int=int(f); >> b=[a+10*pi, a+5*pi, a+pi, a+1/2*pi, a+1/16*pi, a+1/1024*pi]; >> for k=1:6 y(k)=int(f,a,b(k)); y_app(k)=(subs(f_int, b(k))subs(f_int, a))*(b(k)a); end >> y, y_app y = [ 20*a*pi+100*pi^2, 2*sin(a)+10*a*pi+25*pi^2, 2*sin(a)+2*a*pi+pi^2, cos(a)+a*pi+1/4*pi^2sin(a), sin(a+1/16*pi)+1/8*a*pi+1/256*pi^2sin(a), sin(a+1/1024*pi)+1/512*a*pi+1/1048576*pi^2sin(a)] y_app = [ 10*((a+10*pi)^2a^2)*pi, 5*(2*sin(a)+(a+5*pi)^2a^2)*pi, (2*sin(a)+(a+pi)^2a^2)*pi, 1/2*(cos(a)+(a+1/2*pi)^2sin(a)a^2)*pi, 1/16*(sin(a+1/16*pi)+(a+1/16*pi)^2sin(a)a^2)*pi, 1/1024*(sin(a+1/1024*pi)+(a+1/1024*pi)^2sin(a)a^2)*pi] >> y_0=subs(y, 0); y_app_0=subs(y_app, 0); error_y=y_0y_app_0 error_y = 3.0019e+004 3.6290e+003 2.1137e+001 1.9792e+000 1.8777e001 3.0679e003 Conclusion: While b closes to a, ( ) sin 2 ( ) 2 2 a b a b b a Ê Ê + ˆ + ˆ Á ˜ + - Á ˜ Ë Ë ¯ ¯ approaches to (cos 2 ) b a x + x dx Ú . 13. >> clear; format long e; syms x xi; f=1/(x+1)^2; >> f_int=int(f, 0, 1); xi= subs(finverse(f),f_int)
KeytoMatlabExercise7SchoolofMathematicalSciencesXiamenUniversityhttp:/gdjpkc.xmu.edr Warning: inverse(1/(x+lr2)is not unique In C: MATLAB6p5 toolboxlsymbolic\@sym\inverse m at line xi is in(0, 1) > abs(subs(f, xi)-f int) ans (x+1)(5+1)2
Key to MATLAB Exercise 7 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Key to Ex77 Warning: finverse(1/(x+1)^2) is not unique. > In C:\MATLAB6p5\toolbox\symbolic\@sym\finverse.m at line 43 xi = 2^(1/2)1 % xi is in (0, 1) >> abs(subs(f, xi)f_int) ans = 0 % 1 2 2 0 1 1 ( 1) ( 1) dx x x = + + Ú