Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

syms x y z lambda real

f=7*x*y+6*y*z+6*x*z % volume of box

f =

g=x*y*z-252000 % constraint : surface area of the box without

g =

ae=f+lambda*g

ae =

dae_x=diff(ae,x)

dae_x =

dae_y=diff(ae,y)

dae_y =

dae_z=diff(ae,z)

dae_z =

L1=solve(dae_x,lambda)

L1 =

L2=solve(dae_y,lambda)

L2 =

L3=solve(dae_z,lambda)

L3 =

eqns = [L1-L2 ==0, L1-L3==0];

% vars
[solx, soly]=solve(eqns,x,y)

solx =

1
soly =

g1=subs(g,{x,y},{solx,soly})

g1 =

z1=solve(g1,z>0)

z1 =

x1=subs(solx,{z},{z1})

x1 =

y1=subs(soly,{z},{z1})

y1 =

min_cost = subs (f,{x,y,z},{x1,y1,z1})

min_cost =

fprintf("Maximum cost",min_cost)

Maximum cost

You might also like