二元函数临界点的局部极值
close figure(2) syms x y f=2.*x.^4+y.^4-2.*x.^2-2.*y.^2+3; fx=diff(f,x); fy=diff(f,y); fxx=diff(f,x,2); fyy=diff(fy,y); fxy=diff(fx,y); fx fy fxx fyy fxy [a,b]=solve(fx,fy) t=fxx*fyy-fxy^2; t tmp=2^(1/2)/2; k1= subs(t,[x,y],[-tmp,0]) k2=subs(t,[x,y],[tmp,0]) k3=subs(t,[x,y],[-tmp,-1]) k4=subs(t,[x,y],[tmp,-1]) k5=subs(t,[x,y],[-tmp,1]) k6=subs(t,[x,y],[tmp,1]) k7=subs(t,[x,y],[0,0]) k8=subs(t,[x,y],[0,-1]) k9=subs(t,[x,y],[0,1]) z1=subs(f,[x,y],[-tmp,0]) z2=subs(f,[x,y],[tmp,0]) z3=subs(f,[x,y],[-tmp,-1]) z4=subs(f,[x,y],[tmp,-1]) z5=subs(f,[x,y],[-tmp,1]) z6=subs(f,[x,y],[tmp,1]) z7=subs(f,[x,y],[0,0]) z8=subs(f,[x,y],[0,-1]) z9=subs(f,[x,y],[0,1]) u=-3/2:0.1:3/2; v=-3/2:0.1:3/2; [x,y]=meshgrid(u,v); z=2.*x.^4+y.^4-2.*x.^2-2.*y.^2+3; surf(x,y,z); hold on contourf(x,y,z) plot(-tmp,0,'*r') plot(tmp,0,'*r') plot(-tmp,-1,'*r') plot3(-tmp,0,z1,'*g') plot3(tmp,0,z2,'*g') plot3(-tmp,-1,z3,'*g') plot3(tmp,-1,z4,'*g') plot3(-tmp,1,z5,'*g') plot3(tmp,1,z6,'*g') plot3(0,0,z7,'*g') plot3(0,-1,z8,'*g') plot3(0,1,z9,'*g') % axis equal