Mathematics with Maple
S.Duzhin
Solutions to exercises of lesson 4
Exercise 1.
> diff (x^x,x);
> subs(x=1, diff (x^x,x));
> evalf (subs(x=1, diff (x^x,x)));
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);
> plot({f,diff(f,x)},x=-3..3);
Exercise 5.
> x0:=0;
> x1:=1;
> with(plots):
> f:=unapply(cos(x)-2*sin(2*x-1),x);
> df:=unapply(diff(f(x),x),x);
> t:=unapply(f(z)+(x-z)*df(z), x,z);
> plot({f(x),t(x,x0),t(x,x1)},x=-3..3);
Exercise 6.
> f:=-(1-x^2)^(1/2);
> x0:=0;
> taylor(f, x=x0);
answer: y=-1+x^2/2.
Exercise 7.
> taylor(f, x=x0, 7);
> 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.
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);
> limit( exp(-1/x^2), x=0);
> limit( diff(exp(-1/x^2), x), x=0);
> limit( diff(diff(exp(-1/x^2), x),x), x=0);
> 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;
Here is an example of usage:
> taylorpic(sin(x)+cos(x),[x,[-5,5]],7);
>