Notes on Taylor and Maclaurin Series
eli.thegreenplace.net
eli.thegreenplace.net
For instance for the family of functions f(x0,x1,...) = exp(poly(x0,x1,...)), where poly is a multivariate polynomial of order m, you can compute the Taylor coefficients with a recurrence relation of order m (that needs to look back m steps). This shows up in quantum optics, for example.
The Remez algorithm linked at the end still inspires curiosity though. Any other "numerically more useful" approximation algorithms folks want to highlight? The Padé approximant looks like another interesting candidate to read about.
A really good place to read up on it is the documentation for Chebfun.
https://www.chebfun.org/docs/guide/guide04.html
Also: be on the lookout for a blog post on using Chebyshev polynomials to efficiently compute error metrics for curves.
IMO it sits at a really interesting spot as a sort of “more robust” (hand-waves) iterative solver that doesn’t require inner products. You need to know something about the spectrum sure, but sneakily figuring out things about the spectrum is somewhere where people can show off their expertise I think.
I actually spent a little time digging into this, and I'm not sure if this method is actually due to Chebyshev! This link has the most extensive references I found:
https://encyclopediaofmath.org/wiki/Chebyshev_iteration_method
and from what I can tell it's actually due to Richardson.Math department: “oh, look, we are very clever, see these pretty plots the differential equations generate and all the beautiful closed form solution we can make”
Me: “Hmm, very nice, I am not smart enough for this.”
Engineering department: “Complicated equation bad, smash with Taylor series, little part go bye-bye, big part is smooth.”
Me: “Yes this equation will match my brain nicely.”
In my undergrad, I was made to take 6 math courses, and about 18 physics courses which used that math [1]. Plus additional Engineering/CS electives. So over a 25-75 ratio of exercise to "real" stuff.
Much better ratio than boxing.
[1] If you decide that the math courses have nothing real/interesting in them. Which is not true.
Of course this "interested in applying concepts to solve the problem, not calculating the values in said solution" lean is probably why I was in a computer program instead of a math program in the first place :).
To build competence at these problems, you need to exercise the basic skills, of which computational skills are a big part. If you don't exercise your computational skills, you can't become good at mathematics in the sense of (1), (2), or (3). The same way you can't get to be good at boxing without doing a lot of pushups.
Now, not all teachers are good. Many certainly try to force students to do too much computational practice, compared to their level. But both as a student and later as a prof, I discovered that there is value is doing really dumb and complicated calculations by hand sometimes during your education. The reason is that many times when people your computational algorithm fails, you have to do the dirty thing by hand to figure out what went wrong. And depending on what you do, computing the 3rd derivative of a random trig function manually correctly with nuances is exactly what you need to do [1].
Well, not everyone. Many/most people do jobs that only require low levels of maths, and they might never need to do any of that. But a math course taught to everyone has to take a cookie cutter approach and that usually requires setting a high enough bar, so people who have to do the hard math at their job, have those skills. This is an unfortunate fact of resource optimization.
[1] I am an industry researcher now, and have to do all kinds of these crappy calculations.
What I mean by randomly calculate in this case is be given a random trig equation, be told to hand calculate an nth level Taylor series, compute the numerical answer to a few values, and move on to the next problem until you've done hundreds in the course. I do NOT mean running through dozens practice problems to get better at learning when/how to apply Taylor series (though that did come in a later course, it thankfully didn't need to be done by hand just as nobody was expecting you to calculate sqrt(5.7) by hand to learn calculus either).
This no doubt makes me a great calculator of 5th derivatives of trig functions but, except for the first few perhaps, at the expense of dozens of hours of being great at actually applying tricks to do things with what the Taylor series spits out instead. Like you say, the math course has to give cookie cutter training sometimes not about the direct concept at hand but that means you can be shit out of luck if that cookie cutter training wasn't relevant for boxing even though the topic itself can be.
e^-100 = 1 - 100 + 5000 - 166,666.6 + 4,166,666.6 - ...
If you were just given this sum and knew nothing about Taylor series or the exponential function you'd assume that its value was some extremely large number. Yet everything manages to cancel out just right so that the resulting sum is almost exactly zero, but not quite.
I can't help but wonder if there's some parallel to parts of quantum field theory. If you expand out the interactions between two particles you also end up with a series that is apparently divergent. Yet we know experimentally that the first few terms work quite well as an approximation. It feels a bit like you're looking at the series of e^-100 without knowing about the exponential function.
Not only is it a stretch to wonder about parallels between a basic Calc II concept and Quantum Field Theory, but is seems like the exponential function is the exact opposite of the example you provided.
The idea you mention at the end is not specific to something mathematically advanced like quantum field theory. Useful truncations of divergent series show up in many more elementary situations in calculus and applied math; here is a nice class taught by the excellent Steven Strogatz where he talks about a simple example in the first lecture:
https://www.youtube.com/watch?v=KZsk8B_z8pI&list=PL5EH0ZJ7V0...
Real analysis is a zoo of weird exceptions. Including 1/e^(-1/x^2) away from 0, 0 at 0. Its Maclaurin series is just 0, which is clearly not the function we wrote down.
I can't explain why real analysis fit my brain and complex analysis doesn't. But to me complex analysis looks like, "We draw a path, then calculate this contour integral, and magic happens."
Picard's great theorem is totally insane. As is even its little brother, and even Liouville's theorem.
The proofs aren't even that long. They just feel totally false.
I think it is because being holomorphic is so much stronger even than C^\infty (continuous with all derivatives continuous) real much less just continuous or merely integrable.
But once you have the machine...
-----
Fundamental Theorem of Algebra: Every nonconstant polynomial over the complex numbers has a complex root.
Proof: Suppose that p(z) is a polynomial over the complex numbers with no root.
Consider the function 1/p(z). If p(z) had no roots, then 1/p(z) is entire. But we can bound it for everything outside of a large circle because the leading term dominates the others. And since the large circle is compact, we can bound p(z) away from 0 inside the circle. Between the two, 1/p(z) is bounded, and so much be constant by Liouville's theorem.
But 1/p(z) is only constant if p(z) is constant. Therefore any complex polynomial with no complex roots must be constant.
-----
I'm convinced by the proof. But part of me still says that it is magic.
As you say, there's no guarantee that even a convergent Taylor series[0] converges to the correct value in any interval around the point of expansion. Though the series is of course trivially[1] convergent at the point of expansion itself, since only the constant term doesn't vanish.
The typical example is f(x) = exp(-1/x²) for x ≠ 0; f(0) = 0. The derivatives are mildly annoying to compute, but they must look like f⁽ⁿ⁾(x) = exp(-1/x²)pₙ(1/x) for some polynomials pₙ. Since exponential growth dominates all polynomial growth, it must be the case that f(0) = f'(0) = f"(0) = ··· = 0. In other words, the Taylor series is 0 everywhere, but clearly f(x) ≠ 0 for x ≠ 0. So the series converges only at x = 0. At all other points it predicts the wrong value for f.
The straight-forward real-analytic approach to resolve this issue of goes through the full formulation of Taylor's theorem with an explicit remainder term[2]:
f(x) = Σⁿf⁽ᵏ⁾(a)(x-a)ᵏ/k! + Rₙ(x),
where Rₙ is the remainder term. To clarify, this is a _truncated_ Taylor expansion containing terms k=0,...,n.
There are several explicit expressions for the remainder term, but one that's useful is
Rₙ(x) = f⁽ⁿ⁺¹⁾(ξ)(x-a)ⁿ⁺¹/(n+1)!,
where ξ is not (a priori) fully known but guaranteed to exist in [min(a,x), max(a,x)]. (I.e the closed interval between a and x.)
Let's consider f(x) = cos(x) as an easy example. All derivatives look like ±sin(x) or ±cos(x). This lets us conclude that |f⁽ⁿ⁺¹⁾(ξ)| ≤ 1 for all ξ∈(-∞, ∞). So |Rₙ(x)| ≤ (x-a)ⁿ⁺¹/(n+1)! for all n. Since factorial growth dominates exponential growth, it follows that |Rₙ(x)| → 0 as n → ∞ regardless of which value of a we choose. In other words, we've proved that f(x) - Σⁿf⁽ᵏ⁾(a)(x-a)ᵏ/k! = Rₙ(x) → 0 as n → ∞ for all choices of a. So this is a proof that the value of the Taylor series around any point is in fact cos(x).
Similar proofs for sin(x), exp(x), etc are not much more difficult, and it's not hard to turn this into more general arguments for "good" cases. Trying to use the same machinery on the known counterexample exp(-1/x²) is obviously hopeless as we already know the Taylor series converges to the wrong value here, but it can be illustrative to try (it is an exercise in frustration).
A nicer, more intuitive setting for analysis of power series is complex analysis, which provides an easier and more general theory for when a function equals its Taylor series. This nicer setting is probably the reason the topic is mostly glossed over in introductory calculus/real analysis courses. However, it doesn't necessarily give detailed insight into real-analytic oddities like exp(-1/x²) [3].
[0]: For reference, the Taylor series of a function f around a is: Σf⁽ᵏ⁾(a)(x-a)ᵏ/k!. (I use lack of upper index to indicate an infinite series as opposed to a sum with finitely many terms.)
[1]: At x = a, the Taylor series expansion is f(a) = Σⁿf⁽ᵏ⁾(a)(a-a)ᵏ/k! = f(a) + f'(a)·0 + f"(a)·0² + ··· = f(a). All the terms containing (x-a) vanish.
[2]: https://en.wikipedia.org/wiki/Taylor%27s_theorem#Taylor's_th...
[3]: Something very funky goes on with this function as x → 0 in the complex plane, but this is "masked" in the real case. In the complex case, this function is said to have an essential singularity at x = 0.
Gauss-Newton algorithm, GNSS (GPS) solution solving, financial calculus (Ito calculus), and more.
> Let's start with our Maclaurin series for cos(x):
> p(x) = 1 - x^2/2! + x^4/4! - x^6/6! + x^8/8! - ... = 1 + \sum_{n=1}^∞ ((-1)^n x^(2n)) / (2n)!
> Ignoring the constant term, we'll write out the ratio limit. [...]
No need to ignore the constant term: it fits the formula just fine! Evaluating ((-1)^n x^(2n)) / (2n)! at n=0 gives ((-1)^0 x^0) / 0! = (1 * 1) / 1 = 1, which is precisely the constant term.
Each of those three 1s is because the empty product, i.e. the product of an empty list of numbers, is 1. This is sensible because it means that (product of L1) * (product of L2) = product of (L1 append L2).
This is very much in the spirit of 3Blue1Brown. Very nice work.