Maximizing volume of a cylinder with $2$ cones given surface area $A$ A cylinder with a cone on either side of it. The cones have the same radius as the cylinder.
Cylinder area without the sides:
$$A_{cyl}=2\pi r h_1$$
Cone area without the base:
$$A_{cone}=\pi r \sqrt{h_2^2+r^2}$$
Total area of body:
$$A_{tot}=2\pi r h_1 + 2\pi r \sqrt{h_2^2+r^2}$$
Volume:
$$V_{tot}=\pi r^2 h_1 +\frac{2\pi r^2 h_2}{3}=\pi r^2 (h_1 + \frac{2}{3}h_2)$$
I have managed to calculate the maximum volume given surface area for the cone and the cylinder separately but together there are three variables. How would I go about calculating $r,h_1,h_2$ to maximize the volume?
 A: Since $\frac{A_{tot}}{2\pi}\geq \max\{rh_1+rh_2,r^2\}$, it follows that $r$ is bounded and the volume has to be finite:
$$V= \pi r\left(rh_1+\frac{2}{3}rh_2\right)\leq \pi r \frac{A_{tot}}{2\pi}\leq  \frac{A_{tot}^{3/2}}{2\sqrt{2\pi}}.$$
Moreover the above inequality implies that $V\to 0$ as $r\to 0$. So we may assume that $r\geq r_0$ where $r_0>0$ is sufficiently small. Then
also the positive variables $h_1$ and $h_2$ have to be bounded.
Now we apply the method of Lagrange multipliers to the function
$$V(r,h_1,h_2)=\pi r^2 h_1 +\frac{2\pi r^2 h_2}{3}=\pi r^2 \left(h_1 + \frac{2}{3}h_2\right)$$
subject to the constraint
$$A(r,h_1,h_2)=2\pi r \left(h_1 + \sqrt{h_2^2+r^2}\right)=A_{tot}.$$
Assuming $r\geq r_0$, $h_1>0$, $h_2>0$ we find
just one constrained stationary point (which has to be the maximum):
$$\begin{cases}
\frac{\partial V}{\partial r}=\lambda\frac{\partial A}{\partial r}\\
\frac{\partial V}{\partial h_1} =\lambda\frac{\partial A}{\partial h_1}\\
\frac{\partial V}{\partial h_2}=\lambda\frac{\partial A}{\partial h_2}
\end{cases}
\implies
\begin{cases}
r \left(h_1 + \frac{2}{3}h_2\right)=\lambda \Big(h_1 + \sqrt{h_2^2+r^2}+\frac{r^2}{\sqrt{h_2^2+r^2}}\Big)\\
 r^2 =\lambda 2r\\
\frac{r^2}{3} =\lambda \frac{r h_2}{\sqrt{h_2^2+r^2}}
\end{cases}
\implies 
\begin{cases}
\lambda=\frac{r}{2}\\h_1=h_2=\frac{2r}{\sqrt{5}}
\end{cases}$$
where $r$ is given by
$$A_{tot}=2\pi r \left(\frac{2r}{\sqrt{5}} +  \sqrt{\frac{4r^2}{5}+r^2}\right)\implies r=\sqrt{\frac{A_{tot}}{2\pi\sqrt{5}}}.$$
Hence, given the surface area $A_{tot}$, the maximum  volume is
$$V=\pi r^2 \frac{2r}{\sqrt{5}}\left(1 + \frac{2}{3}\right)=
\frac{2\pi\sqrt{5} }{3}r^3=
\frac{A_{tot}^{3/2}}{3\sqrt{2\pi}\,5^{1/4}}.$$
Note that the maximal shape has an inscribed sphere of radius $r$:

A: As I said yesterday, we can eliminate one variable,  $h_1=\frac{A}{2\pi r}-\sqrt{h_2^2+r^2}$ to get
$$V(h_2,r)=\frac{Ar}{2}-\pi r^2\sqrt{h_2^2+r^2}+\frac{2\pi r^2h_2}{3}.\tag1$$
The system of equations for critical points $\frac{\partial V}{\partial h_2}=\frac{\partial V}{\partial r}$ on the open region $r,h_2>0$ gives
$$\color{green}{-\frac{\pi r^2h_2}{\sqrt{h_2^2+r^2}}+\frac{2\pi r^2}{3}=0}\,\,\text{and}\,\,\color{blue}{\frac A2-2\pi r\sqrt{h_2^2+r^2}-\frac{\pi r^3}{\sqrt{h_2^2+r^2}}+\frac{4\pi rh_2}{3}=0}$$
From green $h_2=\frac{2}{\sqrt 5}r$ and from blue and this, $r=\sqrt{\frac{A}{2\sqrt 5\pi}}$ and thus $h_2=\sqrt{\frac{2A}{5\sqrt 5\pi}}$.
To show that at $(h_2,r)=(\sqrt{\frac{2A}{5\sqrt 5\pi}},\sqrt{\frac{A}{2\sqrt 5\pi}})$ we have a maximum we need to show that
$$\frac{\partial^2 V}{\partial h_2^2}\frac{\partial^2 V}{\partial r^2}-(\frac{\partial^2 V}{\partial h_2\partial r})^2>0\,\, \text{and} \,\,\frac{\partial^2 V}{\partial h_2^2}>0.$$
But, this is messy. Instead, when $r\rightarrow\infty$ and/or $h_2\rightarrow\infty$, from $(1)$, we see that $V\rightarrow -\infty$, so it is a local maximum $V_{\max}=\frac{A\sqrt A}{3\sqrt{2}\sqrt\pi\sqrt{\sqrt 5}}$.
