Find the height of a square "pyramid" *General Form*

This is the general shape of a pyramid stacked using squares. For example, the first layer would have 1 sphere, the second layer would have 4, and each layer would have $$n^2$$ spheres. I want to know a general formula of the height with $$n$$ layers expressed with $$r$$ as a function of $$h_n(r)$$.

I've made to $$n=2$$ so far, but I can't figure out the height beyond $$2$$ or even the general form.

My progress:

Obviously, we know that the height if it's 1 layer would be $$2r$$, or $$h_1(r)=2r$$.

It is also relatively easy if we have $$2$$ layers. We can construct a pyramid by connecting the $$5$$ centers. Using Pythagorean theorem, we can know that the middle portion is $$\sqrt{2}r$$. Therefore, the total height would be $$h_2(r)=r(2+\sqrt{2})$$

I start to struggle with $$3$$ layers. Please help me solving for that as well as a general form. Hopefully this version is more detailed and well-written question.

• Well done @CellSecret. Your question now merits more attention, and has improved a lot from its previous state. See, making sure that every question of yours is like this will be an extremely beneficial attitude to have on the site : it leads to greater attention, better focus on the question, and better answers. I am sure your next question will be better. May 7 at 5:24
• @TeresaLisbon Thanks! I will try my best on every question. :) But please put your suggestions if my questions need to be improved. For this one, I just got randomly downvoted until someone said that I should revise it. May 7 at 5:32
• Good point, @CellSecret. I admit I did not explain my downvote, and I'm sorry about that. The reason is for that is because I visit about 175 questions like this everyday, trying to help improve each of them. Sometimes I'm able to leave a comment, but sometimes I can only downvote, sometimes only close. I wish I could do more, but I have time constraints, and very few people do my job for me. So thanks very much for taking the message from the answer below and improving your question, and I promise I'll give you suggestions on your next questions if and when I see them. (+1 to the question) May 7 at 5:37
• Thanks :) The process of writing the problem actually helped me into thinking it deeper too! May 7 at 5:41
• Great. That would be one of the advantage points of having you think through your problem and frame it better. Have a good day! May 7 at 5:45

Using a model with $$r=1$$ for simplicity, let $$A$$ be the center of the upper circle and $$B,C,D,E$$ be the centers of the underlying four circles. These points represent a pyramid with $$|AB|=|AC|=|AD|=|AE|=|BC|=|CD|=|DE|=|EB|=2$$.

The base $$BCDE$$ of the pyramid is a $$2\times2$$ square, all the distances from $$B,C,D,E$$ to the center of the square are equal to $$\sqrt2$$, and obviously, the height $$|AO|=\sqrt2$$. Accounting for the radii of the balls on the top and the bottom, the height of two layers of spheres in such an arrangement must be $$|AO|+2=2+\sqrt2$$. Adding one layer below, we just need to add $$\sqrt2$$, so the total height of the pyramid of 14 balls is $$2+2\sqrt2$$, and for the balls of radius $$r$$ it would be $$2(1+\sqrt2)\,r$$.

Edit

The total height of the pyramid of $$n$$ layers of balls with $$n\times n$$ balls on the bottom layer would then be

\begin{align} h_n(r) &= (2+\sqrt2 (n-1))\,r ,\\ h_1&=2 ,\\ h_2&=(2+\sqrt2)\,r ,\\ h_3&=(2+2\sqrt2)\,r ,\\ h_4&=(2+3\sqrt2)\,r ,\\ h_5&=(2+4\sqrt2)\,r ,\\ &\cdots \end{align}

This is a diagonal cross-section of the 14-balls pyramid:

• It would be super-duper wonderful if you consider reading the Enforcement of Quality Standards on meta.math.se. Have a wonderful day! May 6 at 21:40
• @g.kov I beg your pardon, you were right, I was wrong. I erase my erroneous remark. I thought it was an FCC "crystal structure" instead of a HCP structure... Besides [+1}, nice graphics. May 7 at 12:51
• @Jean Marie: Thanks, it's OK. The images were prepared using Asymptote. May 7 at 13:19
• Mine is with Matlab... less easy to manipulate. May 7 at 13:20
• I looked at these 14 balls in interactive 3d webgl from all possible angles, trying to figure out how it would be better to illustrate it. May 7 at 16:34

Spheres stacked in this way can be considered as part of a HCP (Hexagonal Closed Packed) crystal structure. This kind of sphere packing has well known properties, in particular the fact that successive parallel planes passing through the centers of spheres of a given level are distant one from the other by distance

$$d=\sqrt{2}r \ \ \ \text{where r is the common radii of spheres}$$

(see this)

Therefore, adding an initial $$r$$ and a final $$r$$ for the bottom and for the top, the answer is:

$$2d+2r=2r\left(1+\sqrt{2}\right)$$

Remark: A well-written document about these issues.

• So $2r(1+\sqrt{2})$ is just the case with $3$ layers? And we have to add $d$ for every layer added right? Therefore, $h(n)=(n-1)d+2r$? May 7 at 15:17
• That's write. I forgot to say it. May 7 at 15:18
• This diagram is a bit hard to see than the one above. Still great explanation though! (+1) May 7 at 15:24
• I have attempted to play on transparency (initial pyramid in grey)... but I should choose different colors. May 7 at 15:31

Presumably the balls in each layer are arranged in a square lattice and neighbours are touching. If four balls are at the corners of a square, figure out how high a ball must be over the centre of the square so that the distance from the four balls is twice the radius.