MATEMATICKA ANALYZA V MAPLU Symbolicke derivovani > restart; Pomoci procedury diff muzeme derivovat formule (vyrazy): > 'diff(exp(-x^2),x)'; d d x ( )e ( )-x 2 Apostrofy kolem predchazejiciho vyrazu zamezi vyhodnoceni. Stejneho efektu dosahneme i procedurou Diff. Diff se pouziva pro vetsi prehlednost a z duvodu kontroly spravnosti zadani. > %; -2 x e ( )-x 2 > Diff(ln(x/(x^2+1)),x):%=value(%); = d d x ln x +x2 1 - 1 +x2 1 2 x2 ( )+x2 1 2 ( )+x2 1 x > normal(%); = d d x ln x +x2 1 - -x2 1 x ( )+x2 1 > Diff(x^(x^x),x):%=value(%); = d d x x ( )x x x ( )x x +xx ( )+( )ln x 1 ( )ln x xx x > collect(%,ln(x), simplify); #diva se na vyraz jako na polynom v promenne ln(x) = d d x x ( )x x + +x ( )+x x x ( )ln x 2 x ( )+x x x ( )ln x x ( )+ -x x x 1 Derivace vyssich radu: > Diff(exp(-x^2),x,x):%=value(%); = d d2 x2 ( )e ( )-x 2 - +2 e ( )-x 2 4 x2 e ( )-x 2 > Diff(exp(-x^2), x$5):%=value(%); = d d5 x5 ( )e ( )-x 2 - + -120 x e ( )-x 2 160 x3 e ( )-x 2 32 x5 e ( )-x 2 Derivace funkce dane implicitne > restart; > alias(y=y(x)): #y povazujeme za funkci x > eq:=x^2+y^2=c; :=eq =+x2 y2 c > diff(eq,x); =+2 x 2 y x y 0 > dydx:=solve(%, diff(y,x)); # 1. derivace :=dydx - x y > diff(eq,x$2); =+ +2 2 x y 2 2 y 2 x2 y 0 > solve(%,diff(y,x$2)); - +1 x y 2 y > d2ydx2:=normal(subs(diff(y,x)=dydx,%)); :=d2ydx2 - +x2 y2 y3 > alias(y=y): > restart; > implicitdiff(x^2+y^2,y,x,x); - +x2 y2 y3 Parcialni derivace: > Diff(exp(a*x*y^2),x,y$2):%=value(%); = 3 y2 x ( )e ( )a x y 2 + +2 a e ( )a x y 2 10 a2 y2 x e ( )a x y 2 4 a3 y4 x2 e ( )a x y 2 > factor(%); = 3 y2 x ( )e ( )a x y 2 2 a e ( )a x y 2 ( )+ +1 5 a x y2 2 a2 y4 x2 > Diff(sin(x+y)/y^4, x$5, y$2):%=value(%); = 7 y2 x5 ( )sin +x y y4 - + + ( )cos +x y y4 8 ( )sin +x y y5 20 ( )cos +x y y6 > collect(%,cos(x+y),normal); = 7 y2 x5 ( )sin +x y y4 - + ( )-y2 20 ( )cos +x y y6 8 ( )sin +x y y5 Pokud derivuje funkci (ve smyslu datove struktury Maplu), musime pouzit funkcniho operatoru D. > g:=x->x^n*exp(sin(x)); :=g x xn e ( )sin x > D(g); x + xn n e ( )sin x x xn ( )cos x e ( )sin x > D(g)(Pi/6); + 6 6 n n e ( )/1 2 1 2 6 n 3 e ( )/1 2 diff derivuje vzorec a na vystupu vraci vzorec, D derivuje funkci a na vystupu vraci funkci. Priklady: > Eval(Diff(g(x), x), x=Pi/6); x ( )xn e ( )sin x =x 6 > value(%); + 6 6 n n e ( )/1 2 1 2 6 n 3 e ( )/1 2 > diff(cos(t),t); #derivace vzorce - ( )sin t > D(cos); #derivace funkce -sin > (D@@2)(cos); #pro druhou derivaci funkce musime pouzit operatoru skladani funkci -cos > D(cos)(t); # derivace funkce v danem bode - ( )sin t Vsimnete si rozdilu mezi nasledujicimi dvema prikazy: > D(cos(t)); ( )D ( )cos t Maple povazuje cos(t) za slozeni funkci cos a t, spravny zapis je tedy: > D(cos @ t); ( )@( )-sin t ( )D t Derivace implicitni funkce pomoci operatoru D: > eq:=x^2+y^2=c: > D(eq); =+2 ( )D x x 2 ( )D y y ( )D c > solve(%,D(y)); - 1 2 -2 ( )D x x ( )D c y > dydx:=subs(D(x)=1, D(c)=0, %); :=dydx - x y > (D@@2)(eq); =+ + +2 ( )( )D ( )2 x x 2 ( )D x 2 2 ( )( )D ( )2 y y 2 ( )D y 2 ( )( )D ( )2 c > solve(%,(D@@2)(y)); - 1 2 + + -2 ( )( )D ( )2 x x 2 ( )D x 2 2 ( )D y 2 ( )( )D ( )2 c y > d2ydx2:=normal(subs(D(x)=1, (D@@2)(x)=0, (D@@2)(c)=0, D(y)=dydx, %)); :=d2ydx2 - +x2 y2 y3 Operatoru D je mozno pouzit i pro vypocet parcialnich derivaci: > h:=(x,y,z)->1/(x^2+y^2+z^2)^(1/2); :=h ( ), ,x y z 1 + +x2 y2 z2 > 'D[1](h)'=D[1](h); =( )D1 h ( ), ,x y z - x ( )+ +x2 y2 z2 ( )/3 2 Zde D[1](h) je parcialni derivace vzhledem k x. > 'D[1,2](h)'=D[1,2](h); =( )D ,1 2 h ( ), ,x y z 3 y x ( )+ +x2 y2 z2 ( )/5 2 D[1,2](h) je vlastne D[1](D[2](h)) - smisena parcialni derivace vzhledem k x a y. > 'D[1,1](h)'=D[1,1](h); =( )D ,1 1 h ( ), ,x y z - 3 x2 ( )+ +x2 y2 z2 ( )/5 2 1 ( )+ +x2 y2 z2 ( )/3 2 Druha parcialni derivace vzhledem k x. > L[h]:=(D[1,1]+D[2,2]+D[3,3])(h); Lh ( ), ,x y z - 3 x2 ( )+ +x2 y2 z2 ( )/5 2 1 ( )+ +x2 y2 z2 ( )/3 2 := ( ), ,x y z - 3 y2 ( )+ +x2 y2 z2 ( )/5 2 1 ( )+ +x2 y2 z2 ( )/3 2 + ( ), ,x y z - 3 z2 ( )+ +x2 y2 z2 ( )/5 2 1 ( )+ +x2 y2 z2 ( )/3 2 + > normal(L[h](x,y,y)); 0 Maple muze derivovat i po castech definovane funkce: > F:=x->piecewise(x>0, sin(x), arctan(x)); :=F x ( )piecewise , ,<0 x ( )sin x ( )arctan x > Fp:=D(F); :=Fp x piecewise , , ,x 0 1 +1 x2 <0 x ( )cos x > plot({F, Fp}, -3*Pi..3*Pi); ­1.5 ­1 ­0.5 0.5 1 ­8 ­6 ­4 ­2 2 4 6 8 > F:=x->if x>0 then sin(x) else arctan(x) fi; :=F proc( ) end procx option ;,operator arrow if then else end if<0 x ( )sin x ( )arctan x > Fp:=D(F); :=Fp proc( ) end procx option ;,operator arrow if then else end if<0 x ( )cos x / ( )1 +1 ^x 2 > plot({F, Fp}, -3*Pi..3*Pi); ­1.5 ­1 ­0.5 0.5 1 ­8 ­6 ­4 ­2 2 4 6 8 > restart; Integrace a sumace Maple pouziva k integraci specialni algoritmy (napr. tzv. Rischuv algoritmus). Procedura Int integral nevyhodnocuje, pouze prepisuje. > Int(x/(x^3+1), x):%=value(%); =d x +x3 1 x - + + 1 3 ( )ln +x 1 1 6 ( )ln - +x2 x 1 1 3 3 arctan ( )-2 x 1 3 3 > diff(rhs(%), x); - + + 1 3 ( )+x 1 -2 x 1 6 ( )- +x2 x 1 2 3 +1 ( )-2 x 1 2 3 Pomoci rhs() se odkazujeme na pravou stranu rovnice, lhs() na levou. > normal(%,'expanded'); x +x3 1 > infolevel[int]:=2: > Int(x/(x^5+1),x): %=value(%); int/indef1: first-stage indefinite integration int/ratpoly: rational function integration int/ratpoly: rational function integration d x +x5 1 x 1 5 ( )ln +x 1 1 20 ( )ln - + + -2 x2 x 5 x 2 1 20 ( )ln - + + -2 x2 x 5 x 2 5- + -= 2 5 arctan - + +4 x 1 5 -10 2 5 5 -10 2 5 1 20 ( )ln - + +2 x2 x 5 x 2 5 1 20 ( )ln - + +2 x2 x 5 x 2- + + 2 5 arctan - +4 x 1 5 +10 2 5 5 +10 2 5 > normal(diff(rhs(%),x), 'expanded'); x +x5 1 > infolevel[int]:=0: Maple pri vypoctech automaticky voli nulovou integracni konstantu. > Int(2*x*(x^2+1)^24, x); d 2 x ( )+x2 1 24 x > value(%); 208012 x24 81719 x32 7084 x38 19228 x14 19228 x36 653752 5 x30 7084 x12 43263 x34 + + + + + + + x2 92 x44 506 x42 653752 5 x20 81719 x18 43263 x16 10626 5 x40 178296 x22 + + + + + + + + 208012 x26 1 25 x50 x48 10626 5 x10 178296 x28 12 x46 12 x4 92 x6 506 x8 + + + + + + + + + > factor(%); x2 ( )+ + + +x8 5 x6 10 x4 10 x2 5 x40 20 x38 190 x36 1140 x34 4845 x32 15505 x30 + + + + +( 38775 x28 77625 x26 126425 x24 169325 x22 187760 x20 172975 x18 132450 x16 + + + + + + + 84075 x14 43975 x12 18760 x10 6425 x8 1725 x6 350 x4 50 x2 5+ + + + + + + + ) 25/ > factor(%+1/25); ( )+x2 1 25 25 > restart; Urcity integral: > Integrate(x/(x^3+1), x=1..2): %=value(%); =d 1 2 x +x3 1 x + - 1 3 ( )ln 2 3 18 1 6 ( )ln 3 > Int(1/((1+x^2)*(1+2*x^2)), x=0..1): > %=value(%); =d 0 1 1 ( )+1 x2 ( )+1 2 x2 x - + 4 2 ( )arctan 2 > Int(1/x^2, x=-1..1): %=value(%); =d -1 1 1 x2 x > Int(1/x^2, x): %=value(%); =d 1 x2 x - 1 x > subs(x=1, rhs(%)) - subs(x=-1, rhs(%)); -2 > plot(1/x^2, x=-1..1, y=-10..10); ­10 ­8 ­6 ­4 ­2 0 2 4 6 8 10 y ­1 ­0.8 ­0.6 ­0.4 ­0.2 0.2 0.4 0.6 0.8 1 x Maple kontroluje nespojitosti integrandu na zadanem intervelu. Nevlastni integraly: > Int(t^4*ln(t)^2/(1+3*t^2)^3, t=0..infinity): %=value(%); =d 0 t4 ( )ln t 2 ( )+1 3 t2 3 t + - + 3 216 3 3 576 1 108 3 ( )ln 3 1 576 3 ( )ln 3 2 V pripade, ze Maple neni schopen najit reseni symbolicky, muzeme pouzit numerickeho integrovani: > int(exp(arcsin(x)), x=0..1); d 0 1 e ( )arcsin x x > evalf(%); 1.905238690 Nekdy je vyhodne Maplu pri reseni asistovat (pokud chceme i postup reseni): > with(student): > Int(sqrt(9-x^2), x); d -9 x2 x > changevar(x=3*sin(t), Int(sqrt(9-x^2), x),t); d 3 -9 9 ( )sin t 2 ( )cos t t > value(%); + 9 2 -1 ( )sin t 2 ( )sin t 9 t 2 > simplify(subs(t=arcsin(x/3), %)); + -9 x2 x 2 9 2 arcsin x 3 Pro metodu per - partes: > i:=Int((x^2+1)*ln(x), x); :=i d ( )+x2 1 ( )ln x x > i=intparts(i, ln(x)); =d ( )+x2 1 ( )ln x x -( )ln x +x 1 3 x3 d +x 1 3 x3 x x > i=value(lhs(%)); =d ( )+x2 1 ( )ln x x - + -x ( )ln x x 1 3 x3 ( )ln x x3 9 Zobrazeni postupu vypoctu: > read "VypocetIntegralu.txt": > VypocetIntegralu(exp(x)*sin(x), czech); =d ex ( )sin x x [ ], ,uijeme metodu per partes =u ex =v - ( )cos x = - -ex ( )cos x d -ex ( )cos x x [ ], ,uijeme metodu per partes =u ex =v ( )sin x = - + -ex ( )cos x ex ( )sin x d ex ( )sin x x [ ]integrl spotme algebraicky = - + 1 2 ex ( )cos x 1 2 ex ( )sin x [ ]upravme v raz = 1 2 ex ( )- +( )cos x ( )sin x > with(Student[Calculus1]): > IntTutor(); Initializing Java runtime environment. =d ex ( )sin x x - + 1 2 ex ( )cos x 1 2 ex ( )sin x > Int(exp(x)*sin(x), x); d ex ( )sin x x > Hint(%); [ ], ,parts ex - ( )cos x > restart; Konecne a nekonecne soucty: > Sum(k^7, k=1..20): %=value(%); = =k 1 20 k7 3877286700 > Sum(k^7, k=1..n): %=value(%); = =k 1 n k7 - + - + ( )+n 1 8 8 ( )+n 1 7 2 7 ( )+n 1 6 12 7 ( )+n 1 4 24 ( )+n 1 2 12 > factor(%); = =k 1 n k7 n2 ( )+ - - +3 n4 6 n3 n2 4 n 2 ( )+n 1 2 24 > Sum(1/(k^2-4), k=3..infinity): %=value(%); = =k 3 1 -k2 4 25 48 Tayloruv rozvoj > taylor(sin(tan(x))-tan(sin(x)), x=0, 25); 1 30 x7 29 756 x9 1913 75600 x11 95 7392 x13 311148869 54486432000 x15 10193207 4358914560 x17 1664108363 1905468364800 - - - - - - - x19 2097555460001 7602818775552000 x21 374694625074883 6690480522485760000 x23 ( )O x25 - - + > whattype(%); series > order(%%); 25 > 25; 25 > Order; 6 > Order:=3: taylor(f(x), x=a); + + +( )f a ( )( )D f a ( )-x a 1 2 ( )( )( )D ( )2 f a ( )-x a 2 ( )O ( )-x a 3 > sin_series:=taylor(sin(x), x=0, 6); :=sin_series - + +x 1 6 x3 1 120 x5 ( )O x7 > sin_series := series(1*x-1/6*x^3+1/120*x^5+O(x^7),x,7); :=sin_series - + +x 1 6 x3 1 120 x5 ( )O x7 I kdyz struktura rozvoje nam pripomina polynom, interni datova reprezentace je jina: > subs(x=2, sin_series); Error, invalid substitution in series > op(sin_series); , , , , , , ,1 1 -1 6 3 1 120 5 ( )O 1 7 > sin_series*sin_series; - + +x 1 6 x3 1 120 x5 ( )O x7 2 > expand(%); - + +x 1 6 x3 1 120 x5 ( )O x7 2 > taylor(%,x); +x2 ( )O x4 > mtaylor(sin(x), x=0,6); - +x 1 6 x3 1 120 x5 mtaylor pocita Taylorovy rozvoje i pro funkce vice promennych a vysledkem je datova struktura typu polynom. > subs(x=2, %); 14 15 > whattype(%%); + Muzeme urcovat i koeficienty u danych mocnin x bez nutnosti pocitat cely rozvoj: > coeftayl(sin(x), x=0, 19); -1 121645100408832000 > sin_series; - + +x 1 6 x3 1 120 x5 ( )O x7 > diff(sin_series, x); - + +1 1 2 x2 1 24 x4 ( )O x6 > integrate(sin_series, x); - + + 1 2 x2 1 24 x4 1 720 x6 ( )O x8 > convert(sin_series, 'polynom'); - +x 1 6 x3 1 120 x5 > restart; > with(powseries); #procedury, slouzici k praci s mocninnymi radami compose evalpow inverse multconst multiply negative powadd powcos powcreate powdiff, , , , , , , , , ,[ powexp powint powlog powpoly powsin powsolve powsqrt quotient reversion subtract, , , , , , , , , , template tpsform, ] > powcreate(f(n)=a^n/n!); > powcreate(g(n)=(-1)^(n+1)/n,g(0)=0); > f(2); a2 2 > f_series:=tpsform(f,x,5); :=f_series + + + + +1 a x a2 2 x2 a3 6 x3 a4 24 x4 ( )O x5 > g_series:=tpsform(g,x,5); :=g_series - + - +x 1 2 x2 1 3 x3 1 4 x4 ( )O x5 > s:=powadd(f,g): tpsform(s,x,3); + + +1 ( )+a 1 x - a2 2 1 2 x2 ( )O x3 > series(1+(a+1)*x+(1/2*a^2-1/2)*x^2+O(x^3),x,3); + + +1 ( )+a 1 x - a2 2 1 2 x2 ( )O x3 > p:=multiply(f,g): tpsform(p,x,4); + + +x - + 1 2 a x2 - + 1 3 1 2 a 1 2 a2 x3 ( )O x4 > d:=powdiff(f): tpsform(d,x,4); + + + +a a2 x a3 2 x2 a4 6 x3 ( )O x4 > i:=powint(f): tpsform(i,x,4); + + +x a 2 x2 a2 6 x3 ( )O x4 Vypocty limit > Limit( cos(x)^(1/x^3), x=0): %=value(%); =lim x 0 ( )cos x 1 x 3 undefined Jednostranne limity: > Limit(cos(x)^(1/x^3), x=0, 'right'): > %=value(%); =lim +x 0 ( )cos x 1 x 3 0 > Limit(cos(x)^(1/x^3), x=0, 'left'): > %=value(%); =lim -x 0 ( )cos x 1 x 3 > y:=exp(a*x)*cos(b*x); :=y e ( )a x ( )cos b x > limit(y, x=-infinity); lim x ( )- e ( )a x ( )cos b x > assume(a>0): > limit(y, x=-infinity); 0 > limit(y, x=-infinity) assuming a>0; 0 Student Calculus Package > restart; > with(student): > f:=x->-2/3*x^2+x; :=f x - + 2 3 x2 x > (f(x+h)-f(x))/h; - + + 2 ( )+x h 2 3 h 2 x2 3 h > Limit(%,h=0); lim h 0 - + + 2 ( )+x h 2 3 h 2 x2 3 h > value(%); - + 4 x 3 1 > eval(%, x=0); 1 > showtangent(f(x), x=0); ­60 ­40 ­20 0 ­10 ­8 ­6 ­4 ­2 2 4 6 8 10 x > intercept(y=f(x), y=0); ,{ },=y 0 =x 0 { },=y 0 =x 3 2 > middlebox(f(x), x=0..3/2); 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.2 0.4 0.6 0.8 1 1.2 1.4 x > middlebox(f(x), x=0..3/2, 10); 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.2 0.4 0.6 0.8 1 1.2 1.4 x > middlesum(f(x), x=0..3/2, 10); 3 20 =i 0 9 - + + 2 + 3 i 20 3 40 2 3 3 i 20 3 40 > value(%); 603 1600 > middlesum(f(x), x=0..3/2, n); 3 2 =i 0 -n 1 - + 3 +i 1 2 2 2 n2 3 +i 1 2 2 n n > Limit(%, n=infinity); lim n 3 2 =i 0 -n 1 - + 3 +i 1 2 2 2 n2 3 +i 1 2 2 n n > value(%); 3 8 > Int(f(x), x=0..3/2); d 0 /3 2 - + 2 3 x2 x x > value(%); 3 8 > with(Student[Calculus1]): > DiffTutor(); = d d x ( )x ( )sin x +( )sin x x ( )cos x > IntTutor(); Initializing Java runtime environment. =d x2 ( )sin x x - + +x2 ( )cos x 2 x ( )sin x 2 ( )cos x >