If you’re a regular reader of this site, you might remember a post about this fascinating specimen from the collection of unusual functions. I’m only showing it on the interval [-1,1] for reasons that will become apparent, but outside that region the growth tapers off rapidly and the function approaches 1 for large negative and large positive x.
It’s continuous once you define the point at the origin, and it has continuous derivatives of all orders. Nevertheless, if you try to find the power series about the origin, you see that every term in the series is 0. You can try offsetting the point you’re expanding about, but then the series will only converge to the distance of the origin. We talked about the why of this in the post linked above.
But for whatever reason we would really like a series approximation to this function. There’s any number of physics reasons why power series are a very useful thing to have available, and it looks in some sense like the function ought to be representable by a power series. The function on this interval does have a shape which sort of vaguely resembles a parabola, so surely there’s some second-order polynomial which is less bad than the others at approximating this function.
There is, if we’re willing to accept a few sacrifices. This particular trick only works over a finite interval, because fundamentally it approximates a function over an interval – not about a point. This means it’s not a Taylor series and so it won’t give us the luxury of having a single point of expansion with such pretty bounds on the error of the approximation in its neighborhood. But if that’s not too bad, sign on the dotted line and hire the services of the Legendre polynomials.
The Legendre polynomials are just standard, ordinary polynomials which happen to satisfy the Legendre differential equation. The Legendre polynomial of order 0 is 1, the one of order 1 is x, the one for order 2 is (3/2)x^2 + 1, and so on. There’s a list at the link. To cut down on notation they’re usually just called by the label Pn, where n is the order of the polynomial.
But (and this is a long and complicated story), it turns out that the solutions to these sorts of differential equations have a very interesting property. They are complete sets of orthogonal functions, which means that you can expand just about any function you want in terms of those polynomials over some interval. So for any particular f(x) including ours,
All you have to do is find the cn coefficients. Without going into detail, here’s how:
That coefficient in front of the integral is a historical idiosyncrasy. Had the Legendre polynomials first been developed using modern ideas of Hilbert spaces, they would have been rescaled to make that coefficient a 1.
Notice that this procedure only works on functions on the interval [-1,1]. But this is really no limitation: if you want to expand over a different interval, just offset and rescale your original f(x), find the polynomial approximation, and then do the reverse transformation on your polynomial approximation.
All that out of the way, here’s what I get for the first three non-zero cn. It will turn out that for all odd n, cn is zero due to parity.
c0 = 0.1781477
c2 = 0.1006579
c4 = 0.0149114
Here’s the approximation for just the first two of the above:
And here for all three:
Further terms would improve the approximation. Not bad, huh?