In this blog post I will show how one can compute the sums of first n integers, squares, cubes and quads. Formally what I mean is the following four sums:









There definitely exist numerous methods to work out these sums, but I will show a geometrical approach for each of them.

Giving away the final answers the sums turn out to equal









Sum of integers

In the picture above, our sum is represented as the area of the shaded squares (drawn up to n=5).



The white area is what we would need to add to fill the whole square. If the shaded area is , then the white area is . Relating both of the areas to the area of the square we get

Writing out the sums









and so substituting



and we are done with the first of the sums.

Sum of squares

This is slightly more involved, geometrically speaking.

The idea is to stack a bunch of volume=1 cubes in layers of size as so:

Because the cubes are of volume 1, the total volume of the cube-pyramid is the sum that we are trying to find: . The idea is to extend this ‘discrete’ pyramid to a ‘full’ oblique square pyramid like so:

If we denote the volume of the ‘full’ pyramid as , then the sum we are seeking, , differs from the total volume by some amount so that . It is this difference that we are first going to calculate.

Observe, in the image above, that the difference is made up of nothing more than two types of ‘building blocks’: small oblique pyramids and half-cubes (highlighted in blue). The small pyramids each have a volume of , whereas the half-cubes each have a volume of .

We can see that each layer has only one small pyramid. The number of half-cubes, however, increases. For layers k=1, 2, 3, 4, … we have 2, 4, 6, 8… half-cubes. k-th layer will have 1 small pyramid and 2k half-cubes. To be exact, we also have to take into account the tip of the pyramid (0-th layer) which gives an additional small pyramid.

The difference between the pyramid volume and the total cube volume is thus equal to

We also know the volume of the pyramid . Its height from its tip to the base is k+1, same as the side length of its square base. Thus the total volume of the pyramid is

Our desired sum of squares is then

Skipping the details of combining the terms we get

Sum of cubes

For this sum, we draw a square grid which compactly fits together squares of size along the diagonal

Filling the rest of the square and highlighting regions

Lets work out the area of the k-th shaded region.

It can be viewed as a union of two identical rectangles, each having areas . The area of their intersection is simply . So the k-th shaded area is

Surprisingly, the area of the k-th region is the cube of k. That means that the total area of the square is exactly the sum of cubes we are looking for. What is the area of the whole square (up to n)?

The side length is the sum of integers up to n, so the total area is this sum squared. Therefore the sum of first n cubes is

Sum of quads

To compute this sum we will start off from where we left when computing the sum of cubes. We were able to express the sum of first n cubes ‘in a 2D plane’. We can use the third dimension to bring the power from to . What do I mean by that? Well, if look at the square grid we had when computing the sum of cubes, and treat it as a 3D object with depth equal to 1.

What happens to the k-th area? It becomes the k-th volume with volume . Of course if the whole grid of cubes has depth of 1 we get nowhere. But what happens if we take the k-th volume and stack it on top of itself k times?



Now our k-th volume will be . If we can then somehow compute the total volume of this 3D shape, we will obtain the sum of quads .

It is perhaps a little bit easier to analyze this shape in slices. For , the shape is made of the following 10 slices:

How can we write how many cubes (squares in this case) appear at each slice? Going from top to bottom, first, we simply have a sum of squares , which we already worked out in general.

Next, we have two slices of the same sum of squares, except with an additional square added. So the second plus third slices have squares combined.

Following the same logic, the fourth-through-sixth slices have again, the same sum of squares but with the additional square added from the previous step, AND additional three squares added in this step.

So these slices have squares in total.

The next group of slices combined have squares.

The trickiest part of this pattern is the additional squares we are adding at each step. These, as you might convince yourself, are partial sums of the number sequence , with the sequence terms being no other than the sum of first k integers: . So for each k-th group of slices we are adding additional squares per slice. Except, in our case it is useful to ‘shift’ the terms by one place, so that the first term , which makes the n-th term change to .

Putting this all together, we can write down the total sum of quads, which equals the volume of the 3D shape we were slicing:





writing down the expression for





expanding the terms in the second sum





We have obtained an expression for in terms of itself. Rearranging gives