# Square pyramidal number

In mathematics, a pyramid number, or square pyramidal number, is a natural number that counts the stacked spheres in a pyramid with a square base. The study of these numbers goes back to Archimedes and Fibonacci. They are part of a broader topic of figurate numbers representing the numbers of points forming regular patterns within different shapes.
As well as counting spheres in a pyramid, these numbers can be described algebraically as a sum of the first $n$ positive square numbers, or as the values of a cubic polynomial. They can be used to solve several other counting problems, including counting squares in a square grid and counting acute triangles formed from the vertices of an odd regular polygon. They equal the sums of consecutive tetrahedral numbers, and are one-fourth of a larger tetrahedral number. The sum of two consecutive square pyramidal numbers is an octahedral number.

## History

The pyramidal numbers were one of the few types of three-dimensional figurate numbers studied in Greek mathematics, in works by Nicomachus, Theon of Smyrna, and Iamblichus. Formulas for summing consecutive squares to give a cubic polynomial, whose values are the square pyramidal numbers, are given by Archimedes, who used this sum as a lemma as part of a study of the volume of a cone, and by Fibonacci, as part of a more general solution to the problem of finding formulas for sums of progressions of squares. The square pyramidal numbers were also one of the families of figurate numbers studied by Japanese mathematicians of the wasan period, who named them "kirei saijō suida" (with modern kanji, 奇零 再乗 蓑深).
The same problem, formulated as one of counting the cannonballs in a square pyramid, was posed by Walter Raleigh to mathematician Thomas Harriot in the late 1500s, while both were on a sea voyage. The cannonball problem, asking whether there are any square pyramidal numbers that are also square numbers other than 1 and 4900, is said to have developed out of this exchange. Édouard Lucas found the 4900-ball pyramid with a square number of balls, and in making the cannonball problem more widely known, suggested that it was the only nontrivial solution. After incomplete proofs by Lucas and Claude-Séraphin Moret-Blanc, the first complete proof that no other such numbers exist was given by G. N. Watson in 1918.

## Formula

If spheres are packed into square pyramids whose number of layers is 1, 2, 3, etc., then the square pyramidal numbers giving the numbers of spheres in each pyramid are:
These numbers can be calculated algebraically, as follows. If a pyramid of spheres is decomposed into its square layers with a square number of spheres in each, then the total number $P_{n}$ of spheres can be counted as the sum of the number of spheres in each square, $P_{n}=\sum _{k=1}^{n}k^{2}=1+4+9+\cdots +n^{2},$ and this summation can be solved to give a cubic polynomial, which can be written in several equivalent ways: $P_{n}={\frac {n(n+1)(2n+1)}{6}}={\frac {2n^{3}+3n^{2}+n}{6}}={\frac {n^{3}}{3}}+{\frac {n^{2}}{2}}+{\frac {n}{6}}.$ This equation for a sum of squares is a special case of Faulhaber's formula for sums of powers, and may be proved by mathematical induction.
More generally, figurate numbers count the numbers of geometric points arranged in regular patterns within certain shapes. The centers of the spheres in a pyramid of spheres form one of these patterns, but for many other types of figurate numbers it does not make sense to think of the points as being centers of spheres. In modern mathematics, related problems of counting points in integer polyhedra are formalized by the Ehrhart polynomials. These differ from figurate numbers in that, for Ehrhart polynomials, the points are always arranged in an integer lattice rather than having an arrangement that is more carefully fitted to the shape in question, and the shape they fit into is a polyhedron with lattice points as its vertices. Specifically, the Ehrhart polynomial L(P,t) of an integer polyhedron P is a polynomial that counts the integer points in a copy of P that is expanded by multiplying all its coordinates by the number t. The usual symmetric form of a square pyramid, with a unit square as its base, is not an integer polyhedron, because the topmost point of the pyramid, its apex, is not an integer point. Instead, the Ehrhart polynomial can be applied to an asymmetric square pyramid P with a unit square base and an apex that can be any integer point one unit above the base plane. For this choice of P, the Ehrhart polynomial of a pyramid is ⁠(t + 1)(t + 2)(2t + 3)/6⁠ = P$_{t+1}$.

## Geometric enumeration

As well as counting spheres in a pyramid, these numbers can be used to solve several other counting problems. For example, a common mathematical puzzle involves counting the squares in a large n by n square grid. This count can be derived as follows:
* The number of 1 × 1 squares in the grid is n$^2$.
* The number of 2 × 2 squares in the grid is (n − 1)$^2$. These can be counted by counting all of the possible upper-left corners of 2 × 2 squares.
* The number of k × k squares (1 ≤ k ≤ n) in the grid is (n − k + 1)$^2$. These can be counted by counting all of the possible upper-left corners of k × k squares.
It follows that the number of squares in an n × n square grid is: $n^{2}+(n-1)^{2}+(n-2)^{2}+(n-3)^{2}+\ldots ={\frac {n(n+1)(2n+1)}{6}}.$ That is, the solution to the puzzle is given by the n-th square pyramidal number. The number of rectangles in a square grid is given by the squared triangular numbers.
The square pyramidal number $P_{n}$ also counts the acute triangles formed from the vertices of a $(2n+1)$-sided regular polygon. For instance, an equilateral triangle contains only one acute triangle (itself), a regular pentagon has five acute golden triangles within it, a regular heptagon has 14 acute triangles of two shapes, etc. More abstractly, when permutations of the rows or columns of a matrix are considered as equivalent, the number of $2\times 2$ matrices with non-negative integer coefficients summing to $n$, for odd values of $n$, is a square pyramidal number.

## Relations to other figurate numbers

The cannonball problem asks for the sizes of pyramids of cannonballs that can also be spread out to form a square array, or equivalently, which numbers are both square and square pyramidal. Besides 1, there is only one other number that has this property: 4900, which is both the 70th square number and the 24th square pyramidal number.
The square pyramidal numbers can be expressed as sums of binomial coefficients: $P_{n}={\binom {n+2}{3}}+{\binom {n+1}{3}}={\binom {n+1}{2}}+2{\binom {n+1}{3}}.$
The binomial coefficients occurring in this representation are tetrahedral numbers, and this formula expresses a square pyramidal number as the sum of two tetrahedral numbers in the same way as square numbers split into two consecutive triangular numbers.
If a tetrahedron is reflected across one of its faces, the two copies form a triangular bipyramid. The square pyramidal numbers are also the figurate numbers of the triangular bipyramids, and this formula can be interpreted as an equality between the square pyramidal numbers and the triangular bipyramidal numbers. Analogously, reflecting a square pyramid across its base produces an octahedron, from which it follows that each octahedral number is the sum of two consecutive square pyramidal numbers.
Square pyramidal numbers are also related to tetrahedral numbers in a different way: the points from four copies of the same square pyramid can be rearranged to form a single tetrahedron with twice as many points along each edge. That is, $4P_{n}=Te_{2n}={\binom {2n+2}{3}}.$
To see this, arrange each square pyramid so that each layer is directly above the previous layer, e.g. the heights are
Four of these can then be joined by the height 4 pillar to make an even square pyramid, with layers $4,16,36,\dots$.
Each layer is the sum of consecutive triangular numbers, i.e. $(1+3),(6+10),(15+21),\dots$, which, when totalled, sum to the tetrahedral number.

## Other properties

The alternating series of unit fractions with the square pyramidal numbers as denominators is closely related to the Leibniz formula for π, although it converges faster. It is: ${\begin{aligned}\sum _{i=1}^{\infty }&(-1)^{i-1}{\frac {1}{P_{i}}}\\&=1-{\frac {1}{5}}+{\frac {1}{14}}-{\frac {1}{30}}+{\frac {1}{55}}-{\frac {1}{91}}+{\frac {1}{140}}-{\frac {1}{204}}+\cdots \\&=6(\pi -3)\\&\approx 0.849556.\\\end{aligned}}$
In approximation theory, the sequences of odd numbers, sums of odd numbers (square numbers), sums of square numbers (square pyramidal numbers), etc., form the coefficients in a method for converting Chebyshev approximations into polynomials.