For the classes of Atul Roy
This is a continuation of
• Lagrange Multiplier 01
Codes based on the discussion at MathWorks website
https://www.mathworks.com/matlabcentr...
MATLAB CODE
syms x y z lambda
f=x^2+y^2+z^2
g=x^4+y^4+z^4-1
L=f-lambda*g
Lx=diff(L,x)==0;
Ly=diff(L,y)==0;
Lz =diff(L,z)==0;
system=[ Lx,Ly,Lz,g==0]
[xs,ys,zs,lambdas]=solve(system,[x y z lambda],'Real',true)
f(x,y,z)=x^2+y^2+z^2
f(xs,ys,zs)
[min(f(xs,ys,zs)),max(f(xs,ys,zs))]