Solution (source code)

= Solution

An axial section gives similar right triangles. At height $x$ above the base, the cone's remaining height is $h-x$, so the cylinder's radius is $r=(h-x)\tan\alpha$. Therefore its <volume> is
$$
\boxed{V(x)=\pi x(h-x)^2\tan^2\alpha,\qquad0\leq x\leq h.}
$$
Assume $h>0$ and $0<\alpha<\pi/2$ for a nondegenerate cone. The geometry and the dimensionless optimization curves are illustrated below.

\Image[/past-exam-of-the-mathematics-course-of-the-year-1-of-the-natural-sciences-course-of-the-university-of-cambridge/2009/paper-1-cylinder-in-cone.png]
{title=Axial section and different optimal heights for cylinder volume and curved area inside a cone}