hi guys.
I'm beginer. Can you help me to fix the errors?
Thank you for your supporting.
syms x y lambda dx dyclcf=x^2*y;c=x^2+2*y^2;k=6;L=f-lambda*(c-k);Lx=diff(L,x);Ly=diff(L,y);root=solve(Lx,Ly,c==k,x,y,lambda);X=root.x;Y=root.y;Lambda=root.lambda;Lxx=diff(Lx,x);Lxy=diff(Lx,y);Lyy=diff(Ly,y);dc=(diff(c,x)*dx)+(diff(c,y)*dy);d2L=Lxx*(dx)^2+2*Lxy*(dx*dy)+Lyy*(dy)^2;for a=1:4 d=solve(subs(dc,[x,y],[X(a),Y(a)]),dx); newd2L=solve(subs(d2L,[x,y,lambda,dx],[X(a),Y(a),lambda(a),d])); finald2L=subs(newd2L,dy,1); if finald2L > 0 disp ('Local minimum point subject to the constraint at x='); disp(X(a)); disp('y='); disp(Y(a)); elseif finald2L ==0 disp ('Function does not have extreme at x='); disp(X(a)); disp('y='); disp(Y(a)); else disp ('Local maximum point subject to the constraint at x='); disp(X(a)); disp('y='); disp(Y(a)); endend
Best Answer