Do you remember that formula from calculus that states

$f(x) = f(0) + f'(0)x + \frac{f''(0)}{2!}x^2 + \frac{f'''(0)}{3!}x^3 + \dots + \frac{f^{(n)}(0)}{n!}x^n + \ldots$

Two questions: why is it true and why is it useful?

## Why it’s true

What are we trying to accomplish with Maclaurin Series? We are trying to find a polynomial which equals the function $$f(x)$$ (e.g. $$e^x$$ or $$sin^2(x)$$).

When are two functions equal? Two functions are equal if they have the same value for all inputs (all values of $$x$$, in this case). One way that could be true is that the functions have the same value at $$x = 0$$, as well as the same derivative, the same second derivative, the same third derivative, etc. This isn’t air tight (and indeed, it isn’t always true), but it holds for many functions1 and should seem somewhat intuitive. If a function is the same at a certain point, and the amount it changes around that point (its first derivative) is the same, and the amount that changes around that point (its second derivative) is the same, all the way down, then how can these functions ever diverge? Well, often they don’t.

So, to recap, we’re going to look for a polynomial, $$p$$, that has the same value as $$f$$ at $$x=0$$, as well as the same derivative, for all derivatives.

What’s the form of a polynomial? It looks something like this:

$p(x) = a + bx + cx^2 + dx^3 + ex^4 + \ldots$

#### 0th derivative

We need $$p(0) = f(0)$$. When $$x = 0$$ all terms of the polynomial $$p$$ go to zero, other than the first. In other words:

\begin{align*} f(0) &= p(0) \\ &= a + bx + cx^2 + dx^3 + ex^4 + \ldots |_{x=0} \\ &= a \end{align*}

We’ve discovered our first coefficient in $$p$$: $$p(x) = f(0) + bx + cx^2 + dx^3 + ex^4 + \ldots$$

#### 1st derivative

We need $$p'(0) = f'(0)$$.

\begin{align*} f'(0) &= p'(0) \\ &= 0 + b + 2cx + 3dx^2 + 4ex^3 + \ldots |_{x=0} \\ &= b \end{align*}

We’ve discovered our second coefficient in $$p$$: $$p(x) = f(0) + f'(0)x + cx^2 + dx^3 + ex^4 + \ldots$$

#### 2nd derivative

We need $$p''(0) = f''(0)$$.

\begin{align*} f''(0) &= p''(0) \\ &= 0 + 0 + 2c + 3 \cdot 2dx + 4 \cdot 3ex^2 + \ldots |_{x=0} \\ &= 2c \end{align*}

We’ve discovered our third coefficient in $$p$$: $$p(x) = f(0) + f'(0)x + \frac{f''(0)}{2}x^2 + dx^3 + ex^4 + \ldots$$

#### 3rd derivative

We need $$p'''(0) = f'''(0)$$.

\begin{align*} f'''(0) &= p'''(0) \\ &= 0 + 0 + 0 + 3 \cdot 2d + 4 \cdot 3 \cdot 2 ex + \ldots |_{x=0} \\ &= 3!d \end{align*}

We’ve discovered our fourth coefficient in $$p$$: $$p(x) = f(0) + f'(0)x + \frac{f''(0)}{2}x^2 + \frac{f'''(0)}{3!}x^3 + ex^4 + \ldots$$

#### And beyond

We could continue this pattern (seriously, try a few), but at this point you’re probably seeing a pattern emerge. The $$n$$th term of the polynomial seems to be

$\frac{f^{(n)}(0)}{n!}x^n$

making the entire function

$p(x) = \sum_{n=0}^{\infty} \frac{f^{(n)}(0)}{n!}x^n$

## Why it’s useful

Take this section with a grain of salt. It’s very possible that I don’t know the most important or useful practical applications of the Maclaurin Series. But here is my answer: polynomials are easy! They’re way nicer to deal with than arbitrary functions. In addition, derivative are (pretty) easy, and that’s all we need to turn an arbitrary function into polynomial.

For example, what’s the integral of $$ln(x + e^{a + x^2})$$? Uhh…. wolfram alpha, anyone?

$p(x) = e^{-a} + (2 - e^{-2a})x + e^{-3a}(2 - 6e^{2a})x^2 + \ldots$

Sure, it’s a big equation, but it’s completely trivial to take that integral (remember, $$a$$ is just a constant).

$\int p(x) = c + e^{-a}x + \frac{(2 - e^{-2a})}{2} x^2 + \frac{e^{-3a}(2 - 6e^{2a})}{3} x^3 + \ldots$

And (big surprise) $$p(x)$$ is the first few terms of the Maclaurin Series of $$ln(x + e^{a + x^2})$$.

They’re also fast. Let’s say you have a function which is expensive to compute, and whose input is changing relatively quickly. Maybe instead of recomputing your expensive function every time your input changes, you could approximate it with some large, but finite number of terms of its Maclaurin Series. Then, re-evaluating it will take almost no time at all!

## Bonus section!

Hopefully you’ve followed the sections above, but if not, maybe a concrete example can help.

Let’s consider the function $$f(x) = sin(x) + 1$$ in the domain of $$[-10, 10]$$. We can approximate this function using the first $$n$$ terms of the Maclaurin Series. As $$n$$ increases, our approximation looks closer and closer to the original $$f(x)$$.

Notice how the red line (the Maclaurin Series approximation of $$f(x)$$) only seems to change when going from an odd number of terms to an even number of terms. Can you figure out why that is?

1. Analytic functions is the technical term for the class of functions for which the Maclaurin Series (and the more general Taylor Series) holds.