A container with an open top is to have 10 m^3 capacity and be made of thin sheet metal. Calculate the dimensions of the box if it is to use the minimum possible amount of metal. Use Lagrange multipliers method.
f=x*y+2*x*z+2*y*z s.t g=x*y*z-10=0
I wrote these codes and found this answer. Is it correct solution?
syms x y z r llf=x*y+2*x*z+2*y*z;g=x*y*z-10;L=f-r*g;gradL=gradient(L);[xs ys zs rs]=solve(gradL==0,[x y z r],'Real',true);h=.01;k=.01;for i=1:numel(xs) fopt=double(subs(f,[x y z],[xs(i) ys(i) zs(i)])); gc=subs(g,[x y z],[xs(i)+h ys(i)+k zs(i)+ll]); l=double(solve(gc==0,ll)); [a j]=min(abs(l)); l=l(j); fnear=double(subs(f,[x y z],[xs(i)+h ys(i)+k zs(i)+l])); [xs(i) ys(i) zs(i)] fopt if fopt<fnear disp('min') elseif fopt>fnear disp('max') endend ans = [ (5^(1/3)*16^(2/3))/4, (5^(1/3)*16^(2/3))/4, (5^(1/3)*16^(2/3))/8] fopt = 22.1042 min
Best Answer