Wednesday, June 4, 2014

Crux Move #2: Substitute a Taylor Series

A CRUX MOVE is a trick that comes up over and over when doing math. If you worked lots of problems, you'd probably eventually notice them. I took the time to notice them for you and made a list. If you commit this list to memory, it may save you hours of frustration in your future mathematical endeavors. Better grades, higher-paying job, quack quack quack.

The first rule of problem solving is substitute a Taylor series. But we already have a first rule (see previous Crux Move post), so the second rule of problem solving is substitute a Taylor series. Just like fight club.

To clarify, given some ugly customer -- call it f(x) -- we substitute a Taylor series for the function and work with that instead. Sometimes the problem is doing a tough integral by integrating its series term-by-term. Sometimes we work with a simplifying approximation by truncating the series after a few terms (usually after the first two terms): f(x) = f(a) + f'(a)(x–a) which is aka linearization.

Footnote: Many students get queasy when they hear "Taylor series," perhaps because of a dreadful presentation of the topic when first encountered. I beseech you to shake that mindset. When you hear "Taylor series," you should think "polynomial." And polynomials are about the easiest things there are to work with in calculus. Sure, there's lots of things about Taylor series that can be confusing -- radius of convergence and Remainder Theorems and whatnot. We're going to ignore all that here. Our goal for now is to get you comfortable with the move.

Examples after the jump.



CRUX MOVE #2
Substitute a Taylor Series


E X A M P L E   1
Recall the small angle approximations (SAA): sin x ≈ x, cos x ≈ 1, and tan x ≈ x for small x.

You've probably been carrying these around since grade school. But they come from the Taylor series for sine and cosine:

   sin x = x – x3/ 3! + x5/ 5! – x7/ 7! + ...

   cos x = 1 – x2/ 2! + x4/ 4! – x6/ 6! + ...

Truncating after the first term gives sin x ≈  x and cos x ≈ 1 (and tan x = sin x / cos x ≈ x). Here, x must be such that the higher order terms we throw out are small compared to the term we keep. This is a requirement whenever using a truncated Taylor series.

Footnote: How small is small? That depends on what kind of accuracy you require. In the SAA, the error will be less than 1% for angles less than about 10°.

Footnote: A famous application of the small angle approximation you may have seen is the non-linear pendulum, in which a sin(displacement) term appearing in the governing differential equation is approximated by displacement. This allows the equation to be solved analytically, but the solution loses the interesting non-linear behavior exhibited by the original system for finite (i.e., large) displacements. See any differential equation textbook for details.


E X A M P L E   2
Compute: eix, where i = √-1

What does it mean to raise something to an imaginary power?? Substitute a Taylor series. Recall:

 e = 1 + x + x2/ 2! + x3/ 3! + x4/ 4! + x5/ 5! + ...

Ergo:

  eix  = 1 + i x – x2/ 2! – i x3/ 3! + x4/ 4! + ...

       = [ 1 – x2/ 2! + x4/ 4! – ... ]
           + i [ x – x3/ 3! + x5/ 5! + ... ]

Recognizing the first collection of terms as cos x and the second as sin x we have:

   eix  = cos x + i sin x

which is a point on the unit circle in the complex plane.

Footnote: If we set x = π we obtain the famous nerd equation: e+ 1 = 0.


E X A M P L E   3a and 3b
Integrate ∫ cos(x) dx and ∫-1,1 exp(–½x2) dx (the first to demonstrate the technique on a familiar integral, the latter to show a non-trivial application).

We have:

   cos(x) = 1 – x2/ 2! + x4/ 4! – x6/ 6! + ...

So:

   ∫ cos(x) dx =  ∫ [ 1 – x2/ 2! + x4/ 4! – ... ] dx

          =  ∫ 1 –   ∫ x2/ 2! +  ∫ x4/ 4! –  ∫ x6/ 6! + ...

                =  x – x3/ 3! + x5/ 5! – x7/ 7! + ...

which we recognize as the series for sin(x). Hence  ∫ cos(x) = sin(x).

Footnote: How do we know we're allowed to swap integration and summation? Sure, it works for finite sums, but how do we know the integral of an infinite sum is the same as the infinite sum of integrals? Long story short: for most real-world functions, you're golden. However, if the function definition involves a bracket (e.g., f(x) = 1 if x is the birth date of a Merovingian king and sin(x) otherwise) or if there is something else fishy about the problem (such as being preceded by a disclaimer like BONUS POINTS) watch out.

Next up:   ∫-1,1 exp(–½x2) dx

Notation alert:   ∫-1,1 is my notation for "integral from minus one to plus one."  Also, I've switched exponential notation here for ease of writing: exp(foo) is the same as efoo.

On to the solution.

This is the classic example of an integral not having a solution "expressible in terms of elementary functions" (another example is sin(x)/x. FYI). Put simply: you can't integrate this. Nobody can. What this means presently is that if you were expecting here to substitute a Taylor series, integrate term-by-term, and recognize the result as some other function as done above, that's not going to work. There is no function that corresponds to the integrated series.

However, we can get an approximate answer. Let's see what a three term Taylor series gets us.

The three term approximation of exp(x) is:

  exp(x) ≈  1 + x + x2/ 2

So:

  exp(–½x2) ≈  1 – 1/2 x2 + 1/8 x4

Hence:

  ∫-1,1 exp(–½x2) dx ≈  ∫-1,1 1 – 1/2 x2 + 1/8 x4 dx

        =  x – 1/6 x3 + 1/40 x5 |-1,1

Plugging in the limits gives a result of 1.717, compared to the "real" answer of 1.711. Where did I get this number? If we divide our integral by √2π  you may recognize the result as the Standard Normal, i.e., a Gaussian distribution with mean zero and variance one. This integral is tabulated in the back of every statistics book ever written. Or, you might remember that 68.27% of measurements in a normal population lie between ±1 standard deviation (our integral limits). Multiplying 0.6827 by √2π gives 1.711.

Our three term approximation has an error less than one percent. Not too bad, all things considered. If you ever need a Z value and don't have a statistics book handy (meh, could happen), here's an alternative.

Footnote: Are the tables in the back of statistics books computed using Taylor series? I don't know. Perhaps (using more terms, of course), but there's other ways of doing numerical integration. Also, you may have been told that transcendental functions (sin, cos, log, square root, etc.) are implemented on your calculator using Taylor series. I'm pretty sure that's not true. Instead, a more efficient approach called a CORDIC algorithm is used. FYI.


E X A M P L E   4
What could be a more majestic conclusion to Taylor series substitution than using it in the derivation of Einstein's famous equation? I'm taking this from Ramamurti Shankar's 2009 Yale physics course. The result here comes at the tail end of three 90-minute lectures on Relativity. Alas, our focus presently is Taylor series not physics, so I'm jumping in at the end of the derivation. If you feel cheated by this -- and you should -- you should hunt down Professor Shankar's Fundamentals of Physics (I and II) on iTunesU or YouTube. See: Lecture 14 - Introduction to the four-vector (at around 1:06). Or just watch all 49 lectures. They're superb.

The momentum (p) of a particle including relativistic effects is given by the following expression, which is obtained by taking the derivative of the particle's position in space-time:

   p = mc / √ 1 – v2/c2

Here, m and v are the mass and velocity of the particle and c is the speed of light. To make the Taylor series substitution more obvious, bring the square root upstairs:

   p = mc (1 – v2/c2)

The substitution we will use has the form (1 + a)n ≈ 1 + na. For us, n = -1/2 and this is a truncated Taylor series, yes, but it is also a truncated Binomial Series (as opposed to the plain old (finite) Binomial Formula, which you get when n is an integer). I'm pointing this out because the approximation (1 + a)n ≈ 1 + na is so useful it could well be its own Crux Move. It's accurate when a is small. For us, a = – v2/c2 which is indeed small for normal velocities because c is ginormous.

Substituting, we obtain:

   p = mc (1 + 1/2 v2/c2 )

      = mc + 1/2 mv2 / c

Professor Shankar (and before him, Einstein) notes the difficulty here is not so much the details of math as it is the interpretation of this expression. If we multiply both sides by c we obtain:

  pc = mc2 + 1/2 mv2

The second term on the RHS is immediately recognizable as kinetic energy. Therefore, Shankar reasons (and before him, Einstein) the first term must also be a form of energy (you can't add dissimilar quantities in an equation). When the velocity is zero, the kinetic energy vanishes (as do all higher-order terms had we included them) and we are left with

  pc = mc2

Or, just using E for "energy"

  E = mc2

which is called the rest energy of the particle. Forty years and one Manhattan project later, this becomes an atomic bomb.

Previous Move: The Change of No Change
Next Move: Assume a Solution

No comments:

Post a Comment