Using integrals to find sum of squares closed form
As with all my posts here I’ll try to give a more verbose version of what the book covers; specifically how to get the sum of squares closed form using “Method 4: Replace sums by integrals”. All the book explains is finding the error in the approximation and the approximation itself.
This post assumes you have the book to hand although hopefully it’s readable on it’s own. Any mistakes in this text are my own.
In Concrete Mathematics (Knuth, Graham, Patashnik) they use integrals to as a stepping stone to find the closed form for the sum of squares. I am not as eloquent as they are so I’ll just quote them here
In calculus, an integral can be regarded as the area under a curve, and we can approximate this area by adding up the areas of long, skinny rectangles that touch the curve. We can also go the other way if a collection of long, skinny rectangles is given: Since
is the sum of the areas of rectangles whose sizes are , , . . . , , it is approximately equal to the area under the curve between and .
I am not even going to try and replicate the graph in the book so here is one made with
mathisfun.com integral approximation
calculator. The area under this graph is approximately
This post covers the first “sub-method” in Method 4: Replace sums by integrals
Method 1 - Examine Error in Approximation Permalink
What confused me is this is not exactly the same as counting the error wedges on the beautiful graph in the book (that
comes in the next method). This is literally the error in our first pass closed form approximation using the integration
rules where the area under
Thus the error in approximation is
We also know what
Method 2 - Summing Wedge Shaped Error TermsPermalink
This means summing the error shaped wedges above the curve
What I needed some pondering to understand is that a given rectangle is
Now let’s step-wise sum of each
Then, by using the rules of integration to find the anti-derivative of something squared, we will find the area under
graph of just that section
And finally we land at our error in the approximation recurrence again
Stepping Stone: Finding Recurrence Closed FormPermalink
Therefore if we could just find the closed form of
- Here we are just summing in which we can do with Gauss’ formula: - This is just a constant so to find the sum we simply multiply by how many times we’re summing so
THUS our
Tying it Together: Using to Find Closed FormPermalink
We can prove
Which is equivalent to what the book provides in equation 2.39
TODO: Convert from the form I have above to the book’s closed form 2.39.
Appendix: Induction Proof of Permalink
For the recurrence
And RHS is the same as LHS so closed form is OK.