Taylor series, as a procedure¶

solution set ft. Patrick's brother, Auntie Bonnie's Chex mix, and a kinda bogus reference to the Curry-Howard Correspondence¶

Jaxon Jacobs Memorial Look-Mom-No-Formula DIY Taylor Series: On the Friday before Thanksgiving, I said that if we integrate a function using integration by parts, making the stupidest possible choices at each juncture, we get a Taylor series!

Jaxon interrupted: "How does that work for, like, sine?" "Let's do the proof!," I said. "I don't get how that would work for sine,"Jaxon said. "Be patient! You'll see!"

So we did the proof. We stupidly-integrated-by-parts an arbitrary function (e.g., $f(x)$ rather than $x^2$) and as a result got the general formula for a Taylor series (rather than the specific formula for the particular Taylor series of a particular function).

Jaxon said, "Yeah, this proof is nice, but I still don't see how if you integrate sine by parts, you get its Taylor series."

And... I really like Jaxon's point. One response (which I gave) is, "we proved it for an arbitrary function; if you want to know the Taylor series for sine, just plug sine into this formula we derived." But I feel that misses the thrust of Jaxon's question, which was the distinction between a formula and a procedure.

So... maybe I'll have a bit more to say later, but, with all this in mind, compute the Taylor series of $\sin(x)$ using the procedure we did in class that day (my more-coherent writeup of it is in the notes). You know what the answer should be---you plugged $\sin(x)$ into the Taylor series formula to get it a few problem sets ago; you did it last year, etc. So, show, as a procedure, and not just by plugging it into the formula, how, if we integrate $\sin(x)$ by parts an infinite number of times, making the stupidest possible choice at every decision point, we get its Taylor series.

(I worked this out on my kitchen whiteboard the morning of Thanksgiving as I was cooking!)

OK. Let me give a bit more context here.

On the day we derived/proved Taylor series in 1D, I said that Taylor series is really just integration by parts. If we take a function and integrate it by parts (writing it as $\int 1\cdot\text{(the fxn)}$), and make the stupidest possible choice for which part is the $f'$ and which part is the $g$, and keep doing that ad infinitum, we get a Taylor series!

I meant this as an outline to how we'd prove the general formula for a Taylor series. But in Block 7, Jaxon asked how it'd work for a basic function like $\sin x$. "Like, specifically, how does that work???" I said something like, well, let's do the proof; then we'll see. So we did the very nice proof, but at the end, Jaxon was still insistent: "How does this work for something like $\sin x$? Can we really just integrate that by parts and get its Taylor series?!?"

And... I think this brought up a deep point. Every formula is really just a procedure. If we do a procedure on more general objects (e.g., letters like $x$ or $y$ instead of numbers like $5$ and $7$; arbitrary functions like $f(x)$ or $g(x)$ instead of specific functions like $\sin(x)$ or $x^2$), then we get a formula. Every time we plug things into that formula, it's like we're invisibly re-doing that procedure, every time.

For example, we have this fun logs rule (we just talked about this in Math 3, so it's on my mind):

$$\log_a(b\cdot c) = \log_a(b) + \log_a(c)$$

In Math 3, we proved it by making an argument like this:

\begin{align*} \log_a(b\cdot c) &= \log_a\left( \underbrace{a^{\log_a(b)}}_{=b}\cdot c \right) \quad\text{(stupidly, $b=a^{\log_a(b)}$)}\\ &= \log_a\left( a^{\log_a(b)}\cdot \underbrace{a^{\log_a(c)}}_{=c} \right) \quad\text{(equally stupidly, $c=a^{\log_a(c)}$)}\\ &= \log_a\left( a^{\log_a(b)+\log_a(c)} \right) \quad\text{(properties of exponents)}\\ &= \cancel{\log_a}\left( \cancel{a}^{\log_a(b)+\log_a(c)} \right) \quad\text{(an exponent and its log cancel out)}\\ &= \log_a(b)+\log_a(c) \end{align*}

In other words, we did a procedure in which we stupidly rewrote $b$ as $a^{\log_a(b)}$ and stupidly rewrote $c$ as $a^{\log_a(c)}$, and then used laws of exponents to simplify. But we could just do this procedure every time! For instance, if we wanted to simplify $\ln(3\cdot 7)$, we could, instead of applying the formula, just do the same procedure:

\begin{align*} \ln(3\cdot 7) &= \ln\left(e^{\ln 3}\cdot e^{\ln 7} \right) \\ &= \ln\left(e^{\ln 3 + \ln 7} \right) \\ &= \cancel{\ln}\left(\cancel{e}^{\ln 3 + \ln 7} \right) \\ &= \ln(3) + \ln(7) \end{align*}

So every formula is just a procedure. Conversely, every procedure can be described as a formula. This is basically a hand-wavey gloss on what mathematicians/theoretical computer scientists call the Curry-Howard correspondence, which says that every computer program is really a mathematical proof, and that every proof is really a computer program---code is the same as math.

So, back to this sine/Taylor series example.

We've found the Taylor series of sine by plugging it into the formula; we've even derived that formula. So, mathematically, we're set! Logically, we're sound. But I'm still intrigued by Jaxon's question---what does it look like if we actually apply the same procedure we used to prove the general formula for a Taylor series to this specific case?

So that was the question here! (And it's one I've wondered about for a while, but it's never been enough of a priority to actually do it!)

(Incidentally, this also works out to be a really great way for you guys to actually make sure you understand the proof we did---you basically get to work back through it, yourselves, applying it to this example!)

The actual derivation!¶

Anyway, that's some important preamble and context.

So, I worked out the Taylor series of sine, using the same procedure we did in class the Friday before Thanksgiving, but instead of using the arbitrary/generic/general/nonspecific function "$p(x)$", I ued the specific function $\sin(x)$ (which we know its derivatives, properties, how to plug things into it, etc.).

For sake of convenience, I expanded grew it around the origin ($x=0$) rather than around an arbitrary starting point/$x$-value (like $x=c$ in my notes on the proof), just to make things a little easier.

And! I did it on my kitchen whiteboard!!! This is unusual for me, because even though I know that so many of you love doing math on whiteboards, I basically never do! My handwriting is so awful that I just can't make coherent explorations... usually when I do my own math, I scribble things on pieces of paper and then start typing them up in $\LaTeX$ as soon as they start getting coherent or making sense. But on Thanksgiving morning I was in my kitchen tending to the two huge roasting trays of Alexander family chex mix that I was making, and was working on the derivation in my free moments! Here's what I came up with: