There are $(n \ge 2)$ identical (solid) cylinders, each has radius $=r$ and height $=h$. These $n$ cylinders are to be placed in a big (hollow) cylinder, with radius $=R$ and height $=H$. The base of each cylinder is parallel to the base of the big cylinder.
Having $n$, $r$ and $h$, how to find $R$ and $H$ so that
(CONDITION $\text{#}1$): $\pi R^2 H - n\pi r^2 h$ is minimized.
(CONDITION $\text{#}2$): The cylinders can be put on each other (base-to-base), with at least $2$ cylinders per layer, and the number of cylinders in each layer must be less than or equal to the number of cylinders in the layer below it.
For example, Let $n=2,r=3,h=4$. Then:
If we let $R=3$ and $H=8$, then the first condition is satisfied, but the second condition is not.
So $R=6$, and $H=4$ will minimize the quantity $\pi R^2 H - n\pi r^2 h$.
For $n=3, r=4, h=5$:
- Putting two cylinders at the bottom layer and one cylinder above.
In this case we have $R=8,H=10$. This makes $\pi R^2 H - n\pi r^2 h=\pi(8)^2(10)-(3)\pi(4)^2(5)=400\pi$
- Putting three of them in one layer.
In this case we have $R=\frac{12+8\sqrt{3}}{3},H=5$. This makes $\pi R^2 H - n\pi r^2 h=\pi(\frac{12+8\sqrt{3}}{3})^2(5)-(3)\pi(4)^2(5) \approx 131.2\pi$ (which is better) (hopefully I have no mistake in the calculations).
How to find $R$ and $H$ for a general case? Do we need to use only trial-and-error way? In $n$ is high we will have many cases to check then.
Consider the example: $n=17, r=2, h=3$, then how to find $R$ and $H$?
Your help would be appreciated. Thanks!