# Lab sheet 6

## Maxima and minima

Exercise 1.1

y:x^n*exp(-x);

dy:factor(diff(y,x));

wxplot2d(makelist(subst(n=i,y),i,1,4),[x,0,10],[legend,false]);

sol: solve(dy=0,x);

subst(sol[1],y);

kill(y,dy,sol)$

Exercise 1.2

p(x) := -10*x^6+156*x^5-945*x^4+2780*x^3-4080*x^2+2880*x;

wxplot2d(p(x),[x,-0.1,5.3]);

sols: sort(solve(diff(p(x),x)),lambda([e1,e2],rhs(e1)<rhs(e2)));

map(lambda([e],subst(e,[x,p(x),diff(p(x),x,2)])),sols);

kill(p)$

## Implicit derivatives

Exercise 2.1

u: x*sin(x^2+y^2)-y*cos(x^2+y^2);

wxdraw(gr2d(proportional_axes=xy,implicit(u=0,x,-5,5,y,-5,5)));

slope1: -diff(u,x)/diff(u,y);

slope1: factor(subst(cos(x^2+y^2)=x/y*sin(x^2+y^2),slope1));

xt: t * cos(t^2); yt: t*sin(t^2);

trigsimp(subst([x=xt,y=yt],u));

wxdraw2d(nticks=500,proportional_axes=xy,parametric(xt,yt,t,-5,5));

slope2: diff(yt,t)/diff(xt,t);

slope1t: factor(trigsimp(subst([x=xt,y=yt],slope1)));

trigsimp(factor(slope2-slope1t));

kill(u,xt,yt,slope1,slope1t,slope2)$

Exercise 2.2

u:(x^2+y^2)^2+85*(x^2+y^2)-500+18*x*(3*y^2-x^2);

slope1: factor(-diff(u,x)/diff(u,y));

xt: 6*cos(t)+8*cos(t)^2-4;
yt: 2*sin(t)*(3-4*cos(t));

wxdraw2d(
    nticks=500,
    proportional_axes=xy,
    xtics=false,ytics=false,
    axis_top=false,axis_bottom=false,axis_left=false,axis_right=false,
    parametric(xt,yt,t,0,2*%pi));

slope1t: factor(trigsimp(subst([x=xt,y=yt],slope1)));

slope2: factor(trigsimp(diff(yt,t)/diff(xt,t)));

slope1t-slope2;

kill(u,xt,yt,slope1,slope1t,slope2)$

## Higher derivatives

Exercise 3.1

r(n) := diff(x^n*log(x)/n!,x,n);

makelist(r(n),n,1,10);

makelist([n,r(n)-r(n-1)],n,2,10);

r1(n) := log(x) + sum(1/k,k,1,n);

makelist(r(n) - r1(n),n,1,20);

kill(r,r1)$

Exercise 3.2

y: t^2*exp(t);

z: factor(diff(y,t,3) + a*diff(y,t,2) + b*diff(y,t,1) +  c*y);

sol: solve(makelist(coeff(expand(z/exp(t)),t,i),i,0,2))[1];

kill(y,z,sol)$

Exercise 3.3

p(n) := expand(exp(x^2) * diff(exp(-x^2),x,n));

for i from 0 thru 10 do print(p(i));

load("orthopoly")$

makelist(factor((-1)^n*p(n)/hermite(n,x)),n,1,10);