Thursday, February 11, 2010

1^2 + 2^2 + 3^2 + 4^2 + 5^2 + ... + n^2

It is well know that the sum of the squares of integers S is n(n+1)(2n+1)/6. And proofs abound. Although this relationship is not difficult to prove by mathematical induction, it is not intuitively satisfying. This visual proof is very clear and easy to understand.

Elizabeth, my 10-year-old daughter, wanted to figure out the volume of a sphere. Making approximations using 16 equal thickness coin shaped cylinders as seen below.

We ended up with an expression that contained in part, the sum 1 + 4 + 9 + 16 + 25 + 36 + 49 + 64.  It was clear that if we had used instead n coins each of width 1/n, to approximate the volumn, part of that expression would intail the sum Sn = 1 + 4 + 9 + 25 + ... + n^2.  To no avail, I looked around for a simple way to demonstrate the well known relationship:
Sn = n(n+1)(2n+1)/6.


Imagine the sum Sn as the volume of the pyramid of 1 x 1 x 1 cubes with one cube on the top layer, 4 on the next, 9 on the next and so on up to n x n cubes on the bottom layer as seen in the figure above.
From the expression Sn =n(n+1)(2n+1)/6, we see that Sis one sixth the volume of a box with dimensions n x (n + 1) x (2n + 1). So it is at least conceivable that six of these pyramids could be packed into that rectangular volume. Elizabeth and I glued 30 wooden cubes into 6 two-layer pyramids (1 x 1 + 2 x 2) as shown

and without too much effort arranged them into a 2 x 3 x 5 rectangular volume.


The configuration is general, in that it can be scaled up to any positive integer n. Here are some screen shots of a Python simulation using n=4 demonstrating the configureation.


Now fast forward a few days. Snowmaggeddon has snowed me OUT of Reston, VA, and I'm stuck in LA on a rainy Saturday. Amy (lovely wife) scouts out a meeting of the LA Microcontrollers Club from the Make Blog. The once-a-month meeting was scheduled to start in only three hours. A quick peak at the map revealed Topanga, CA, to be just up the mountain North of Santa Montica, about a forty-five minute drive from my hotel. Sweet.

Luckily, I got an early start because the direct route was closed because of the Niagra of mudslides. Rerouting was tricky with my gps-phone rebooting every two minutes. I finally arrived at this beautiful location at the end of a mile-long jeep trail.  The Ford Focus I was driving had trouble negotiating the rutted climb, but the view was worth it.


It was fun getting to know Jack, the founder of the LA Mircrocontroller Club and freelance maker (see see buffingtonfx.com) and Nick, a freelance Hollywood tech.

Nick brought his Arduino-based movie prop clock that stays on whatever time you set it and won't flicker when filmed. Jacked showed off his awesome shop, with a DIY CNC router, and shared his recent experience with the Propeller development board.

Getting to the point, Jack kindly offered to route out the pyramid shapes with his CNC router. Literally, an hour later, Jack had produced three perfect five-layer pyramids. He would have made all six, but I was already late for another appointment. Had I known that Jack was planning to give the pyramids to me, I definitely would have waited for the top half of the retangular volume!


Thanks Jack!