Mathematics with Maple

S.Duzhin

Solutions to exercises of lesson 4

Exercise 1.

> diff (x^x,x);

[Maple Math]

> subs(x=1, diff (x^x,x));

[Maple Math]

> evalf (subs(x=1, diff (x^x,x)));

[Maple Math]

Exercise 2.

f(x,y)=x^2*y+y+C,

where C is an arbitrary constant.

Exercise 3.

There is no such function.

Exercise 4.

You can check your graph with these Maple commands:

> f:=cos(x)-2*sin(2*x-1);

[Maple Math]

> plot({f,diff(f,x)},x=-3..3);

Exercise 5.

> x0:=0;

[Maple Math]

> x1:=1;

[Maple Math]

> with(plots):

> f:=unapply(cos(x)-2*sin(2*x-1),x);

[Maple Math]

> df:=unapply(diff(f(x),x),x);

[Maple Math]

> t:=unapply(f(z)+(x-z)*df(z), x,z);

[Maple Math]

> plot({f(x),t(x,x0),t(x,x1)},x=-3..3);

Exercise 6.

> f:=-(1-x^2)^(1/2);

[Maple Math]

> x0:=0;

[Maple Math]

> taylor(f, x=x0);

[Maple Math]

answer: y=-1+x^2/2.

Exercise 7.

> taylor(f, x=x0, 7);

[Maple Math]

> plot({f(x), -1+x^2/2, -1+x^2/2+x^4/8, -1+x^2/2+x^4/8+x^6/16}, x=-1.5..1.5);

Exercise 8.

[Maple Math]

Exercise 9.

Maple cannot find the Taylor expansion of this function by the simple command "taylor":

> taylor(exp(-1/x^2), x=0,5);

Error, (in series/exp) unable to compute series

We will use "limit" to find the values of the derivatives at point x=0:

> diff(exp(-1/x^2), x);

[Maple Math]

> limit( exp(-1/x^2), x=0);

[Maple Math]

> limit( diff(exp(-1/x^2), x), x=0);

[Maple Math]

> limit( diff(diff(exp(-1/x^2), x),x), x=0);

[Maple Math]

> plot (exp(-1/x^2), x=-1..1);

All the derivatives of this function at point 0 are 0! Therefore, the Taylor series is an identical 0. But the function itself is not 0.

This gives an example of a function which is smooth but not analytical.

Exercise 10.

> taylorpic := proc(func,xrange,n)

> local picture,x,y,a,b,i,p,q,taylorfunc,delay,j,v;

> if nargs = 4 then delay := args[4]; v := NULL;

> elif nargs = 5 then delay := args[4]; v:= args[5];

> else delay := 1; v := NULL;

> fi;

> x := op(1,xrange);

> y := op(2,xrange);

> a := op(1,y); b := op(2,y);

> delay := [seq(delay,j=1..n)];

> for i from 1 to n do

> taylorfunc:= convert(taylor(func,x,i),polynom);

> p := plot({func,taylorfunc},x=a..b,color=green);

> q := plots[textplot]([(a+b)/2,6.5,`Taylor Expansion to order = `.i], color=red);

> p := plots[display]({p,q});

> picture[i] := seq(p,j=1..delay[i]);

> od;

> plots[display]([seq(picture[i],i=1..n)],insequence=true,v);

> end;

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

Here is an example of usage:

> taylorpic(sin(x)+cos(x),[x,[-5,5]],7);

>