Okay this has been a day since I started trying the problem with no success till yet. The solution that includes equalizing two dimensions and solving the third dimension so as to maximize the volume is a bit difficult to understand. Can anybody explain the complete logic step by step as my maths is a bit weak?
i will try my best to explain u the logic inside this problem. it is more of maths though:(.if you know the concept of derivative and maxima and minima then this post will clearly help u.
let us first take a look at the given constraints.
let l, b and h be the dimensions of the box.let V be the volume of the box that we need to maximise.
Since it is given that the entire wire and paper must be used we have these 2 eqns:
From here onwards i will refer p/4 by p and s/2 by s.
Now from 1st equation we can obtain (l+b)=p-h.let this be 4th equation
2nd equation can be written as lb+h(l+b)=s.Now if we substitute the 4th euation in this equation we get:
lb+h(p-h)=s.We can further substitute h=V/lb in this equation which gives the final equation as:
Here we have succeded in representing V as a function of a single variable’h’(ie)V=f(h).
Now if we want to maximise V then the conditions of maxima can be imposed,which is:
this wil result in the foll eqn:
3*(h^2)-2hp+s=0,which is basically a quadratic eqn in ‘h’.
This equation can be solved resulting in two values of h.let them be h1 and h2.
Now compute f(h1) and f(h2)…the maximum of these two values will be the answer.
Now coming to your question,you might have observed that the final equation of V is only dependenent on ‘h’…hence even if we equalize the two variables ‘l’ and ‘b’ to some x, even then it will result in the same final eqn.it is actually awkward to be discussing maths in a coding website but i could not think of any other explantion to this problem.if you still have any doubts comment below .if you find this post helpful upvote and mark it as accepted answer…CHEERS HAPPY CODING :).
here is link to my java code according to your explanation and derived formulae .The problem is that codechef says wrong answer…Can u tell what the bug is?Thank You,
Thank you for the nice explanation. It has clearly put some sense in me.
From the independent nature of the final equation from ‘l’ and ‘b’ , it looks like i can put the highest value in ‘l’ or ‘b’ which satisfy the ‘p’ and ‘S’ constraints.
Is this correct?
Not necessarily the highest values(actually there is nothing like highest value bcoz there will be infinite pairs (l,b) satisfying the constraints).Any value of ‘l’ and ‘b’ such that
l*b=V/h(where V is the max volume and ‘h’ is the height for which V is max as found from the final eqn) will be ok.
prem_93: The Max volume is calculated from the final equation depending on the optimal ‘h’ so what is the need to discuss anything about ‘l’ and ‘b’ ?
yes.there is absolutely no need of discussing abt l and b. i was just clarifying your doubt,and anyway u were the one who first started that discussion.
Yes absolutely Thanks a ton for the help. I meant no offence.
Really nice effort and explanation…