MA1104 Lab 4 command lines. 1. restart:with(plots):with(linalg):with(student): f:=(x,y)-> x*y*exp(-x^2/2-y^2/8); gradient:=grad(f(x,y),vector([x,y])); eqs:=equate(gradient,vector([0,0])); critpts:=solve(eqs,{x,y}); p1:=subs(critpts[1],[x,y]); p2:=subs(critpts[2],[x,y]); p3:=subs(critpts[3],[x,y]); p4:=subs(critpts[4],[x,y]); p5:=subs(critpts[5],[x,y]); h:=hessian(f(x,y),[x,y]):dd:=det(h);dd1:=h[1,1]; D(p1):=simplify(subs(x=p1[1],y=p1[2],dd)); f_xx(p1):=subs(x=p1[1],y=p1[2],dd1); D(p2):=simplify(subs(x=p2[1],y=p2[2],dd)); f_xx(p2):=subs(x=p2[1],y=p2[2],dd1); D(p3):=simplify(subs(x=p3[1],y=p3[2],dd)); f_xx(p3):=subs(x=p3[1],y=p3[2],dd1); D(p4):=simplify(subs(x=p4[1],y=p4[2],dd)); f_xx(p4):=subs(x=p4[1],y=p4[2],dd1); D(p5):=simplify(subs(x=p5[1],y=p5[2],dd)); f_xx(p5):=subs(x=p5[1],y=p5[2],dd1); contourplot3d(f(x,y), x=-2..2, y=-3..3, filled=true,coloring = [yellow,blue], orientation=[-90,0], axes=boxed); 2. restart:with(plots):with(linalg):with(plottools): f:=(x,y)-> x^2+45*x+7*x*y+45*y+y^2; g:=(x,y)-> y+x^2-x*y/3; contour:=contourplot(f(x,y),x=-2..2,y=-2..2,filled=true,coloring=[white,orange],axes=none): constraint:=implicitplot(g(x,y)=1,x=-2..2,y=-2..2,thickness=3,color=blue): display(contour,constraint); h:=0.35:k:=solve(g(h,y)=1,y):p:=[h,k]; grad(g(x,y), vector([x,y])); ng:=subs(x=h,y=k,%):ung:=evalm(ng/norm(ng,2)): vg:=arrow([h,k],ung, 0.02, 0.07, 0.2): grad(f(x,y), vector([x,y])); nf:=subs(x=h,y=k,%):unf:=evalm(nf/norm(nf,2)): vf:=arrow([h,k],unf, 0.01, 0.05, 0.1): f(p):=f(op(p)); display(contour,constraint,vf,vg,scaling=constrained);