%%

clear all

%%

syms x y;
ezsurf(sqrt(x^2+y^2))
view([10,10,10])

%%

ezsurf(sqrt(9-x^2-y^2))
view([10,10,10])

%%

[xbunch,zbunch]=meshgrid(-5:0.1:5,-5:0.1:5);
f=4-x^2;
surf(xbunch,subs(f,{x,y},{xbunch,zbunch}),zbunch)
view([10 10 10])

%%

diff(x*sin(x^2*y),x)

%%

diff(diff((x^2-y)/(x+y),y),x)

%%

jacobian(x*log(x*y^2)+x*y,[x y])

%%

subs(jacobian(5*x^3*y^2-y/x,[x y]),{x,y},{-1,0})

%%

a=[2 -3];
dot((a/norm(a)),subs(jacobian(x^2+y^3,[x y]),{x,y},{2,-2}))

%%

f=(y-2)*log(x*y);
[xsoln,ysoln]=solve(jacobian(f,[x y]))

%%
% So the solution above is just (1/2,2).

%%

f=x^3+y^3-6*x*y;
[xsoln,ysoln]=solve(jacobian(f,[x y]))

%% 
% So the solutions above are (0,0) and (2,2).  Ignore the complex.

%%

clear all;
syms x y L;
f=x*y^2;
g=x^2+y^2-16;
firstpart=jacobian(f,[x y])-L*jacobian(g,[x y]);
[Lsoln,xsoln,ysoln]=solve(firstpart,g)
subs(f,{x,y},{xsoln,ysoln})

%%
% So the maximum is (128*3^(1/2))/9 at (4*3^(1/2)/3,+/-(4*6^(1/2))/3)
% and the minimum is -(128*3^(1/2))/9 at (-4*3^(1/2)/3,+/-(4*6^(1/2))/3).
