Instructions: Any matlab programs/codes related to this assignment should be written as M-files, and use a Microsoft word to write your solutions/answers. Include your modified matlab codes and outputs/graphs in your Microsoft word document, and submit it in Bb as a single file.
Modify the codes below to solve the following problem:
A large container in the shape of a rectangular solid
must have a volume of 480 m^3. The bottom of the
container costs $5/m^2 to construct whereas the top and
sides cost $3/m^2 to construct. Use Lagrange multipliers to
find the dimensions of the container of this size that has the
minimum cost.
% Use the method of Lagrange Multipliers to find the maximum of
%f(x,y) = x^2+4y^2-2x+8y subject to the constraint x+2y=7
syms x y lambda
f = x^2+4*y^2-2*x+8*y;
g = x+2*y-7 == 0; % constraint
L = f - lambda * lhs(g); % Lagrange function
dL_dx = diff(L,x) == 0; % derivative of L with respect to x
dL_dy = diff(L,y) == 0; % derivative of L with respect to y
dL_dlambda = diff(L,lambda) == 0; % derivative of L with respect to lambda
system = [dL_dx; dL_dy; dL_dlambda]; % build the system of equations
[x_val, y_val,lambda_val] = solve(system, [x y lambda], 'Real', true) % solve the system of equations and display the results
results_numeric = double([x_val, y_val, lambda_val]) % show results in a vector of data type double
Reference:
1. https://www.mathworks.com/matlabcentral/answers/531298-finding-minimum-maximum-of-function-using-lagrange-multipliers
2. Calculus Vol 3 by Gilbert Strang (MIT) and Edwin (Jed) Hermann (U. of Wisconsin - Stevens Point)