A rectangular box open at the top is to have volume of 32 cubic ft. Find the dimensions of the box requiring least material for | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

A rectangular box open at the top is to have volume of 32 cubic ft. Find the dimensions of the box requiring least material for

My Attempt: clc %clears the command window clear all %clears the workspace clear vars %clear all the variables in the workspace syms x y z t %declaring new variables surf = x*y + 2*x*z + 2*y*z %writing the surface area function vol = x*y*z - 32 %writing the volume function func = surf + t*vol %writing the lagrange multiplier theorem S = x*y + 64/y + 64/x %modifying the surface area equation dfx = diff(S,x); %differentiating the function wrt x dfy = diff(S,y); %differentiating the function wrt y eqns = [dfx,dfy]; %creating the eqns of dfx and dfy [vx,vy] = solve(eqns,[x y],'Real',true) %getting the real values of x and y r = diff(dfx,x); %getting the r value by differentiating t = diff(dfy,y); %getting the t value by differentiating s = diff(dfx,y); %getting the s value by differentiating check = r*t - s^2 if check > 0 disp('ac') end But unfortunately gives an error in the 'if' while checking whether check>0. The error is 'conversion to logical from sym is not possible' Concepts used to solve this question: Lagrange's Multiplier Theorem Any HELP, please!!!

29th Jan 2021, 5:04 PM
Arun Bhattacharya
Arun Bhattacharya - avatar
3 Answers
+ 2
Thanks a lot @Benjamin and @Martin for your effort, I am glad Benjamin it gave you a opportunity but maybe you overlooked the question which mentioned for the dimensions. And thanks Martin for your solution, it was useful enough. Though the error in the check was not solved.
30th Jan 2021, 6:53 AM
Arun Bhattacharya
Arun Bhattacharya - avatar
+ 1
I'm wondering why you sutract 32 for vol. x*y*z should equal 32, so vol would be 0. I can't say much else about your code. I didn't really try to understand the idea and successfully avoided Matlab in my studies. The line "S = ..." is correct, at least I can say that. This really is just a math problem, namely a minimization problem. You can solve it with pen and paper. The answer is 42. Well kind of... Just a tip to make things easier: You can assume two of the variables (length*width*height) to be equal by simple reasoning. Thanks for the opportunity to refresh my math knowledge 🙃
29th Jan 2021, 7:25 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
0
Arun Bhattacharya I also wrote some tips regarding your code, did you try them? So y can be substituted with x everywhere and in line 3 there seems to be an error. Maybe you meant to set vol to 32. So line 3 should be this I think: vol = x*x*z = 32 And regarding the math I didn't overlook that. I wanted to point you in the right direction instead of just giving you the solution. Which is x=y=4 and z=2 as should be clear by now. That's why I said the answer is 42. A bit silly I know, but I figured you'll understand it when you found the solution yourself. Feel free to ask if you want further explanation to solve it mathematically
30th Jan 2021, 10:16 AM
Benjamin Jürgens
Benjamin Jürgens - avatar