A cylindrical can is to be made to hold 1 L of oil. Find the dimensions that will minimize the cost of the metal to manufacture the can.

This is a standard calculus problem.

The volume of the cylinder is:

V == π r^2 h

The area of the cylinder is:

A[r_] := 2 π r^2 + 2 π r h /. h -> V/(π r^2)

Find r when the slope of the area is zero:

Reduce[A'[r] == 0]


(r == -(-(1/(2 π)))^(1/3) V^(1/3) || 
   r == V^(1/3)/(2 π)^(1/3) || 
   r == ((-1)^(2/3) V^(1/3))/(2 π)^(1/3)) && r != 0

As you can see, when I defined A[r], I replaced h with an expression produced by solving the volume equation for h.

My question is, is there a way to express the problem in terms of Reduce and a set of equations, without the manual solving for h?

I.e. something along the lines of:

A[r_] := 2 π r^2 + 2 π r h

Reduce[{A'[r] == 0, V == π r^2 h}]

Of course, that doesn't yield the correct answer because A'[r] doesn't treat h as being in terms of r.

  • 2
    $\begingroup$ Why not use Minimize[{2 Pi r^2 + 2 Pi r h, Pi r^2 h == 1/1000, r > 0, h > 0}, {r, h}]? $\endgroup$ Commented Aug 6, 2012 at 3:54
  • $\begingroup$ @J.M. Wasn't familiar with Minimize... Thanks for the suggestion! However, is there a way to get the answer not in terms of Root? $\endgroup$
    – dharmatech
    Commented Aug 6, 2012 at 4:00
  • $\begingroup$ @J.M. I'm still curious as to how to solve it with Reduce. I added an answer which takes the approach I was looking for, but uses a rewrite kludge. $\endgroup$
    – dharmatech
    Commented Aug 6, 2012 at 4:01
  • 1
    $\begingroup$ "However, is there a way to get the answer not in terms of Root[]?" - yes, use ToRadicals[]; it will work here since it is the root of a cubic polynomial. $\endgroup$ Commented Aug 6, 2012 at 4:07
  • 2
    $\begingroup$ It seems there is a bug in ToRadicals. Try ToRadicals[ Root[1000 Pi #^3 - 15 (2 Pi)^(1/3) # + 1 &, 2]] $\endgroup$
    – Artes
    Commented Aug 6, 2012 at 8:49

2 Answers 2


As requested, here is a method that uses Reduce[]:

Reduce[Dt[2 Pi r^2 + 2 Pi r h, r] == 0 && Pi r^2 h == 1/1000 && Positive[r], {r, h}]

I'd still prefer using Minimize[], though.

  • $\begingroup$ Aha... I had been using D (partial derivative) necessitating the expression of h in terms of r. I see that Dt takes care of this. Thanks again J.M.! $\endgroup$
    – dharmatech
    Commented Aug 6, 2012 at 4:34

OK, I found one approach:

A[r_] := 2 \[Pi] r^2 + 2 \[Pi] r h
V[r_] := \[Pi] r^2 h
Reduce[{Dt[A[r], r] == 0, V[r] == 1, r > 0}]


r == 1/(2 \[Pi])^(1/3) && h == 2^(2/3)/\[Pi]^(1/3)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.