Visual Sum of Cubes
x.st
x.st
As people have noticed, the spinning diagrams are done with CSS, which was fun.
Basically it's just an `animation: linear infinite;` from `transform: rotateY(0turn);` to `transform: rotateY(1turn);`
(source here https://github.com/hrldcpr/poole/blob/master/_sass/_latex3d.... )
To keep the numbers facing forward, they're all also rotating, but in the opposite direction :p
And all of the numbers' `translate3d(...)` coordinates are generated by a Python script because I didn't want to do that by hand...
I think this sort of visualization is what makes a computer medium better than a paper medium to convey info.
To understand why this technique works with sums of arbitrary powers, the key is to show that summing together rotations of simplices gets you a simplex of constant values. The following geometric argument works:
1. Think of the numbers in the simplex as a function f(x) of the coordinate vector x for the space the simplex is embedded in. Observe that f is linear.
2. A linear function on a simplex is determined uniquely by the values it takes at the vertices. Specifically, the value at any point is a weighted average of vertex point values.
3. If we create a "sum simplex" by summing together all possible rotations of the simplex, the result will also be a linear function on a simplex, and the values at all the vertices will be the same by symmetry.
4. Therefore, the linear function giving the values of the sum simplex is constant.
A rigorous proof could be developed by considering the standard simplex generated by the coordinate unit vectors, but scaled by a factor of n. For example, the equilateral triangle is the 2D simplex generated by connecting the vertices at (n,0,0), (0,n,0), (0,0,n). On this simplex, the integral points (x,y,z), where the coordinates x,y,z are integers, are the points assigned numbers in the blog post. "Rotations" are done by switching coordinate axes (actually a reflection), which preserves the integral points.
4. Therefore, the linear function giving the values of the sum simplex is constant by #2. Since any point's value is a weighted average of vertex values, and all the vertex values are the same, every point's value must also be the same.
A rigorous proof could be developed by considering the standard simplex generated by the coordinate unit vectors, but scaled by a factor of n. For example, the equilateral triangle is the 2D simplex generated by connecting the vertices at (n,0,0), (0,n,0), (0,0,n). On this simplex, the integral points (x,y,z), where the coordinates x,y,z are integers, are the points assigned numbers in the blog post. The numbers are assigned based on the first coordinate: f(x,y,z) = x, and similarly in higher dimensions. "Rotations" are done by switching x with any other coordinate axis (actually a reflection), which maps the simplex to itself and maps integral points to integral points.
The claim that 1 + 2 + ... + n = n (n + 1) / 2 only requires you to verify it for n = 0, n = 1, and n = 2, e.g. that 0 = 0 * 1 /2, 1 = 1 * 2 / 2, and 1 + 2 = 2 * 3 / 2. I found this really surprising when I first heard it and thought I'd share :)
Note you can use this trick for all sorts of sums, not just powers. After some experience you realize lots of sums are polynomials in the size, so just guess a polynomial without the coefficients, and plug in a few items to get the coefficients. Once you have a polynomial, you can prove the result by induction.
So, for example, summing terms of form k(k+4) from k=1 to n may be hard to look up, but you can guess the result is a polynomial of degree one more than the terms (so here, a cubic), do the generic trick, obtain the sum n(n+1)(2n+13)/6, then prove it via induction.
You can do generic items too, like sum (k+a)(k+b) to get abn + n(n+1)(3(a+b)+2n+1)/6.
It's a good technique.
Or just use Mathematica :)
The article uses a typical math text layout, but is something you cannot easily print.
transform:translate3d()Most interactive or digital documents that people claim are "better than textbooks" have left me disappointed. The paper books is a pretty high standard to try and match or exceed in my mind.
Simple visualizations like this though make a case. (And search does as well, FWIW.)
There is an explanation based on symmetry, which I outlined here: https://news.ycombinator.com/item?id=32531692
Interestingly, this approach does not seem to require any induction. The argument just works directly for all powers and all dimensions.
(Footnotes 2 and 3 at the end explain why the entries all end up the same. And the same argument works for simplices in any number of dimensions—there's always two directions that change the value by +1 and -1, and the rest are all parallel / keep it the same. In higher dimensions there are more ways to be parallel!)
My observation is that the final formula is equivalent to two tetrahedra joined on a shared face. There must be a good way to manipulate that directly to get the constant sums. I can find a way but that requires relative rotation of the second tetrahedron. There might be a better way.
Now very curious why that shape corresponds to sum of cubes / why it's equivalent to a pyramid...
<link rel="stylesheet" href="/assets/katex.min.css">(Except for the diagrams, which are inserted by a Python script after the KaTeX rendering is done.)
Source here https://github.com/hrldcpr/poole/blob/master/_posts/2022-08-...