Old Derivative Problem solved with partial derivatives Sometimes I get my best understanding when I work older problems with new techniques.  So, I wanted to work the old derivative problem of minimizing the surface area of a cylindrical can to hold 1 liter of oil.  We solved this in single variable calculus by getting the surface area equation to have only one variable and then taking the derivative and setting it =0.  Worked perfectly.
Now, I thought, well, since I know partial derivatives, I'm thinking I don't need to get that Surface area equation to have just one variable.  I can leave it as:
$$A= 2\pi rh+ 2 \pi r^2$$
Shouldn't I just be able to find the partial derivative with respect to h
and a separate partial derivative with respect to r, set them both =0 and solve to get the critical values.
hmmmmm...when I do this, I get something weird.
(a)  $$\frac {\partial A}{\partial r} = 2\pi h + 4\pi r$$
(b)  $$\frac {\partial A}{\partial h} =  2\pi r$$
Setting $(a) =0$ I get $2\pi h=-4\pi r$
or $h = -2 r$
HUH?  This doesn't make sense.  My height is a negative number!
Why doesn't this old calculus problem work using partials?
 A: Here is one way we generalize optimization with multiple variables given a constraint. We start with the following: Surface Area $= 2\pi rh+2\pi r^2$, Volume $= \pi r^2h = 1$  
We will now apply the method of Lagrange Multipliers. If you haven't covered this already in your class the Wikipedia link should suffice.  
Note that we wish to maximize $f(x)=2\pi rh$ subject to the constraint $g(x) = \pi r^2h-1=0$
We will now construct a function $\mathcal{L}(r,h,\lambda)=f(x)-\lambda g(x)=2\pi rh+2\pi r^2-\lambda(\pi r^2h-1)$ and we will calculate the total gradient
First comes the work finding the partial derivatives
$$\begin{align}
&\frac{\partial \mathcal{L}}{\partial r} =\; -2 \pi (h (\lambda r-1)-2 r)\\
&\frac{\partial \mathcal{L}}{\partial h} =\; \pi r (2-\lambda r)\\
&\frac{\partial \mathcal{L}}{\partial \lambda} =\; h \pi r^2-1
\end{align}$$
We now find when the gradient is zero, which occurs when each of the above partial derivatives is zero.
$$\nabla_{r,h,\lambda}\mathcal{L}(r,h,\lambda)=0 \iff \begin{cases}
-2 \pi (h (\lambda r-1)-2 r)  & = 0 \\
\pi r (2-\lambda r) & = 0 \\
h \pi r^2-1  & = 0
\end{cases}$$
We now simplify this a bit, assume the height and radius are non-zero
$$\begin{cases}
h (\lambda r-1)-2 r  & = 0 \\
2-\lambda r & = 0 \\
h \pi r^2-1  & = 0
\end{cases}$$
From the second equation we get that $\lambda r=2$; substituting this into the first equation gives
$$\begin{cases}
h-2 r  & = 0 \\
h \pi r^2-1  & = 0
\end{cases}$$
This yields the solution
$$(r,h) = \left((2\pi)^{-1/3},(4/\pi)^{1/3}\right)$$
This yields a surface area of $3\sqrt[3]{2 \pi}$
Note that this is just so much easier to do the Calculus 1 way. Just note that the condition implies that $$h=\frac{1}{\pi r^2}\implies \text{Surface Area} = \frac{2}{r} + 2\pi r^2$$ 
Solving this gives the same radius as above, which can be plugged in to the simpler surface area formula to get the answer quickly.
