Intuition for Taylor Series (DNA Analogy)

Your body has a strange property: you can learn information about theentireorganism from a single cell. Pick a cell, dive into the nucleus, and extract the DNA. You can now regrow the entire creature from that tiny sample.

这里有一个数学类比。取一个函数,选一个特定的点,然后开始研究。您可以从单个点提取足够的数据来重建整个函数。哇。这就像用一帧重拍一部电影。

泰勒级数发现了一个函数背后的“数学DNA”,并让我们从一个单一的数据点重建它。让我们看看它是如何工作的。

Pulling information from a point

Given a function like $f(x) = x^2$, what can we discover at a single location?

Normally we'd expect to calculate a single value, like $f(4) = 16$. But there's much more beneath the surface:

  • $f(x)$ = Value of function at point $x$
  • $f'(x)$ = First derivative, or how fast the function is changing (the velocity)
  • $f''(x)$ = Second derivative, or how fast thechangesare changing (the acceleration)
  • $f'''(x)$ = Third derivative, or how fast thechangesin the changes are changing (acceleration of the acceleration)
  • And so on

Investigating a single point reveals multiple, possibly infinite, bits of information about the behavior. (Some functions have an endless amount of data (derivatives) at a single point).

So, given all this information, what should we do? Regrow the organism from a single cell, of course! (Maniacal cackle here.)

Growing a Function from a point

我们的计划是从一个单一的起点增长一个函数。但是我们如何用一般的方式描述任何函数呢?

The big aha moment: imagine any function, at its core, is a polynomial (with possibly infinite terms):

\displaystyle{f(x) = c_0 + c_1 x + c_2 x^2 + c_3x^3 + \cdots}

To rebuild our function, we start at a fixed point ($c_0$) and add in a bunch of other terms based on the value we feed it (like $c_1x$). The "DNA" is the values $c_0, c_1, c_2, c_3$ that describe our function exactly.

好的,我们有一个通用的“函数格式”。But how do we find the coefficients for a specific function likesin(x)(height of angle x on the unit circle)? How do we pull out its DNA?

Time for the magic of 0.

Let's start by plugging in the function value at $x=0$. Doing this, we get:

\displaystyle{f(0) = c_0 + 0 + 0 + 0 + \cdots = c_0}

除了$c_0$以外,每个术语都消失了,这是有意义的:我们的蓝图的起点应该是$f(0)$。美元f (x) = \ sin (x)美元,我们可以计算出美元c_0 = \ sin(0) = 0美元。我们有了第一个DNA!

Getting More DNA

现在我们知道了c0,我们如何在这个方程中分离出c_1 ?

\displaystyle{f(x) = c_0 + c_1 x + c_2 x^2 + c_3x^3 + \cdots}

Hrm. A few ideas:

  • 我们能设x = 1美元吗?让美元f (1) = c_0 + c₁(1)+ c₂(1 ^ 2)+ c_3 (1 ^ 3) + \ cdots $。虽然已知$c_0$,但其他常数相加。我们不能单独提出c ?

  • 如果除以$x$呢?This gives:

\displaystyle{\frac{f(x)}{x} = \frac{c_0}{x} + c_1 + c_2 x + c_3x^2 + \cdots}

Then we can set $x=0$ to make the other terms disappear... right? It's a nice idea, except we're now dividing by zero.

Hrm. This approach is really close. How can wealmostdivide by zero?Using the derivative!

If we take the derivative of the blueprint of $f(x)$, we get:

\displaystyle{f'(x) = (c_0)' + (c_1 x)' + (c_2 x^2)' + (c_3x^3)' + \cdots}

\displaystyle{f'(x) = 0 + c_1 + (2\cdot c_2 x) + (3\cdot c_3x^2) + \cdots}

Every power gets reduced by 1 and the $c_0$, a constant value, becomes zero. It's almost too convenient.

Now we can isolate $c_1$ using our $x=0$ trick:

\displaystyle{f'(0) = 0 + c_1 + (0) + (0) + \cdots = c_1}

In our example, $\sin'(x) = \cos(x)$ so we compute: $f'(0) = \sin'(0) = \cos(0) = 1 = c_1$

耶,再来一点DNA!这就是泰勒级数的神奇之处:通过反复求导并使$x = 0$,我们可以提取出多项式DNA。

Let's try another round:

\displaystyle{f''(x) = 0 + 0 + (2\cdot c_2) + (3\cdot 2 c_3x^1) + \cdots}

After taking the second derivative, the powers are reduced again. The first two terms ($c_0$ and $c_1x$) disappear, and we can again isolate $c_2$ by setting $x=0$:

\displaystyle{f''(0) = 0 + 0 + 2\cdot c_2 + 0 + \cdots}

For our sine example, $\sin'' = -\sin$, so:

\displaystyle{f''(0) = \sin''(0) = -\sin(0) = 0 = 2\cdot c_2}

或者说$c = 0$。

As we keep taking derivatives, we're performing more multiplications and growing a factorial in front of each term (1!, 2!, 3!).

The Taylor Series for a function around point x=0 is:

\displaystyle{f(x) = f(0) + f'(0) x + \frac{f''(0)}{2!}x^2 + \frac{f'''(0)}{3!}x^3 + \cdots}

(Formally, the Taylor series around the point $x=0$ is called the MacLaurin series.)

The generalized Taylor series, extracted from any point a is:

\displaystyle{f(x) = f(a)+{\frac {f'(a)}{1!}}(x-a)+{\frac {f''(a)}{2!}}(x-a)^{2}+{\frac {f'''(a)}{3!}}(x-a)^{3}+\cdots }

The idea is the same. Instead of our regular blueprint, we use:

\displaystyle{f(x) = c_0 + c_1 (x - a) + c_2 (x-a)^2 + c_3(x-a)^3 + \cdots}

Since we're growing from $f(a)$, we can see that $f(a) = c_0 + 0 + 0 + \dots = c_0$. The other coefficients can be extracted by taking derivatives and setting $x = a$ (instead of $x =0$).

Example: Taylor Series of sin(x)

Plugging in derivatives into the formula above, here's the Taylor series of $\sin(x)$ around $x = 0$:

\displaystyle{\sin(x) = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \dots}

And here's what that looks like:

A few notes:

1) Sine has infinite terms

正弦是一个无限的波,正如你所猜测的,需要无限个数的项来维持它。更简单的函数(如$f(x) = x^2 + 3$)已经是它们的“多项式格式”,没有无限的导数来保持DNA的运行。

2) Sine is missing every other term

If we repeatedly take the derivative of sine at x = 0 we get:

\displaystyle{\sin(0) \xrightarrow{\text{derive}} \cos(0) \xrightarrow{\text{derive}} -\sin(0) \xrightarrow{\text{derive}} -\cos(0) \xrightarrow{\text{derive}} \sin(0) \dots}

with values:

\displaystyle{0, 1, 0, -1, \dots}

Ignoring the division by the factorial, we get the pattern:

\displaystyle{(0) + (1)x^1 + (0)x^2 + (-1)x^3 + (0)x^4 + (-1)x^5+ \dots }

So the DNA of sine is something like [0, 1, 0, -1] repeating.

3) Different starting positions have different DNA

For fun, here's the Taylor series of $\sin(x)$ starting at $x =\pi$ (link):

taylor series sin x at x=pi - Wolfram|Alpha 2019-01-18 16-45-04

A few notes:

  • DNA现在是[0,-1,0,1]。循环是类似的,但是起始值改变了,因为我们从$x=\pi$开始。

  • 分母1、6、120、5040写成计算过的数字,看起来很奇怪。但它们只是其他的阶乘:1!= 1, 3 !5 = 6日!= 120, 7 != 5040。一般来说,泰勒级数的分母可能很复杂。

  • The $O(x^{12})$ term means there are other components of order (power) $x^{12}$ and higher. Because $\sin(x)$ has infinite derivatives, we have infinite terms and the computer has to cut us off somewhere. (You've had enough Tayloring for today, buddy.)

Application: Function Approximations

A popular use of Taylor series is getting a quick approximation for a function. If you want a tadpole, do you need the DNA for the entire frog?

The Taylor series has a bunch of terms, typically ordered by importance:

\displaystyle{f(x) = f(0) + f'(0) x + \frac{f''(0)}{2!}x^2 + \frac{f'''(0)}{3!}x^3 + \cdots}

  • $c_0 = f(0)$, the constant term, is the exact value at the point
  • $c_1 = f'(0)x$, the linear term, tells us what speed to move from our point
  • $c_2= \frac{f''(0)}{2!}x^2 $, the quadratic term, tells us how much to accelerate away from our point
  • and so on

If we only need a prediction for a few instants around our point, the initial position & velocity may be good enough:

\displaystyle{\text{Linear model} = \text{initial point} + \text{velocity effect} = f(0) + f'(0)x}

If we're tracking for longer, then acceleration becomes important:

\displaystyle{\text{Quadratic model} = \text{initial point} + \text{velocity effect} + \text{acceleration effect}}\displaystyle{ = f(0) + f'(0)x + \frac{1}{2}f''(0)x^2}

As we get further from our starting point, we need more terms to keep our prediction accurate. For example, the linear model $\sin(x) = x$ is a good prediction around $x=0$. As we get further out, we need to account for more terms.

Similarly, $e^x \sim 1 + x$ works well for small interest rates: 1% discrete interest is 1.01 after one time period, 1% continuous interest is a tad higher than 1.01. As time goes on, the linear model falls behind because it ignores the compounding effects.

Application: Comparing Functions

DNA的常见应用是什么?亲子鉴定。

If we have a few functions, we can compare their Taylor series to see if they're related.

Here's the expansions of $\sin(x)$, $\cos(x)$, and $e^x$:

\displaystyle{ \sin x = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \dots \xrightarrow{DNA} [0, 1, 0 -1, \dots] }

\displaystyle{ \cos x = 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \dots \xrightarrow{DNA} [1, 0, -1, 0, \dots] }

\displaystyle{ e^x = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \dots \xrightarrow{DNA} [1, 1, 1, 1, \dots] }

序列上有家族相似性,对吧?$x$的净幂除以一个阶乘?

One problem is the sequence for $e^x$ has positive terms, while sine and cosine alternate signs. How can we link these together?

Euler's great insight was realizing animaginary numbercould swap the sign from positive to negative:

{\begin{aligned}e^{ix}&=1+ix+{\frac {(ix)^{2}}{2!}}+{\frac {(ix)^{3}}{3!}}+{\frac {(ix)^{4}}{4!}}+{\frac {(ix)^{5}}{5!}}+{\frac {(ix)^{6}}{6!}}+{\frac {(ix)^{7}}{7!}}+{\frac {(ix)^{8}}{8!}}+\cdots \\[8pt]&=1+ix-{\frac {x^{2}}{2!}}-{\frac {ix^{3}}{3!}}+{\frac {x^{4}}{4!}}+{\frac {ix^{5}}{5!}}-{\frac {x^{6}}{6!}}-{\frac {ix^{7}}{7!}}+{\frac {x^{8}}{8!}}+\cdots \\[8pt]&=\left(1-{\frac {x^{2}}{2!}}+{\frac {x^{4}}{4!}}-{\frac {x^{6}}{6!}}+{\frac {x^{8}}{8!}}-\cdots \right)+i\left(x-{\frac {x^{3}}{3!}}+{\frac {x^{5}}{5!}}-{\frac {x^{7}}{7!}}+\cdots \right)\\[8pt]&=\cos x+i\sin x.\end{aligned}}

哇。使用虚指数和分离成奇数/偶数次幂揭示了正弦和余弦隐藏在指数函数中。很神奇的。

Although this proof ofEuler's Formuladoesn't showwhythe imaginary number makes sense, it reveals the baby daddy hiding backstage.

附录:什锦啊哈!Moments

Relationship to Fourier Series

The Taylor Series extracts the "polynomial DNA" and theFourier Series/Transformextracts the "circular DNA" of a function. Both see functions as built from smaller parts (polynomials or exponential paths).

泰勒级数总是成立吗?

这涉及到超出我深度的数学分析,但某些函数不容易(或从来没有)用多项式逼近。

Notice that powers like $x^2, x^3$ explode as $x$ grows. In order to have a slow, gradual curve, you need an army of polynomial terms fighting it out, with one winner barely emerging. If you stop the train too early, the approximation explodes again.

例如,这是$\ln(1 + x)$的泰勒级数。这条黑线就是我们想要的曲线,添加更多的项,即使是几十项,也很难让我们的精确度超过$x=1.0$。对于那些想要肆意发展的术语来说,要保持一个平缓的坡度太难了。

source

在这种情况下,我们只有在近似保持准确的情况下才有收敛半径(例如大约$|x| < 1$)。

Turning geometric to algebraic definitions

Sine is often defined geometrically: the height of a line on a circular figure.

Turning this into an equation seems really hard. The Taylor Series gives us a process: If we know a single value and how it changes (the derivative), we can reverse-engineer the DNA.

Similarly, the description of $e^x$ as "the function with its derivative equal to the current value" yields the DNA [1, 1, 1, 1], and polynomial $f(x) = 1 + \frac{1}{1!}x + \frac{1}{2!}x^2 + \frac{1}{3!}x^3 + \dots $. We went from a verbal description to an equation.

Phew! A few items to ponder.

快乐数学。

Other Posts In This Series

  1. A Gentle Introduction To Learning Calculus
  2. Understanding Calculus With A Bank Account Metaphor
  3. Prehistoric Calculus: Discovering Pi
  4. A Calculus Analogy: Integrals as Multiplication
  5. Calculus: Building Intuition for the Derivative
  6. How To Understand Derivatives: The Product, Power & Chain Rules
  7. How To Understand Derivatives: The Quotient Rule, Exponents, and Logarithms
  8. An Intuitive Introduction To Limits
  9. Intuition for Taylor Series (DNA Analogy)
  10. Why Do We Need Limits and Infinitesimals?
  11. Learning Calculus: Overcoming Our Artificial Need for Precision
  12. 关于是否0.999…= 1
  13. Analogy: The Calculus Camera
  14. Abstraction Practice: Calculus Graphs
  15. Quick Insight: Easier Arithmetic With Calculus
  16. How to Add 1 through 100 using Calculus
  17. Integral of Sin(x): Geometric Intuition

Join 450k Monthly Readers

Enjoy the article? There's plenty more to help you build a lasting, intuitive understanding of math. Join the newsletter for bonus content and the latest updates.