Taylor Series

The idea behind Taylor Series is that any well-behaving Function (e.g. Continuous Functions) can be represented as a sum of Polynomials


Taylor and Maclaurin Series

A Taylor Series of f(x) at x=0 is

  • f(x)=k=0f(k)(0)k!xk
  • where f(k)(0) is kth Derivative of f evaluated at x=0
  • this kind of Taylor Series about x=0 is sometimes called Maclaurin Series


Taylor Series of f(x) at x=a is

  • f(x)=k=0f(k)(a)k!(xa)k
  • this is the general form


Expansion as an Operator

Taylor Expansion is the process of turning a function to a Taylor Series

  • can think of it as an operator that takes a function and returns a Series
  • taylor-expansion.png


Examples

Famous expansions:

  • Exponential Function: ex=k=01k!xk of Exponential Function
  • Trigonometric Functions:
    • cosx=k=0(1)kx2k(2k)! of Cosine
    • sinx=k=0(1)kx2k+1(2k+1)! of Sine
  • it allows us to deal with these functions as with long sums of polynomials


Approximation

Taylor Series are used for approximations

Exponential

  • as we add more terms, we are closer and closer to the function
  • taylor-exp.png (source: [1])
  • order n approximation is shown with n dots


Trigonometric Functions:

  • taylor-cos.png (source: [2])
  • taylor-sin.png (source: [3])
  • by taking only polynomials of odd (even) powers, we get cosines or sines

Approximation near the expansion point 0:

  • Note that these approximations work best near 0
  • It's clear from the sin/cos graphs - the more away from 0, need more terms


Computing Taylor Series

How to compute Taylor Series? There are several ways of doing it

Derivatives

  • This is the straightforward way:
  • use the definitions and compute all the Derivatives
  • if a function is complex, it may be hard

Substitution

Example: 1xsin(x2)

  • hard to take derivatives
  • but we know the expansion of sinx, so
  • 1xsin(x2)=1x((x2)13!(x2)3+15!(x2)5 ...)= ...
    • ... =x13!x5+15!x9 ...=k=0(1)kx4k+1(2k+1)!


Combination

cos2x=cosxcosx

  • expand each one separately
  • cosxcosx=(112!x2+14!x4 ...)(112!x2+14!x4 ...)= ...
    • ... =11+1(12!x2)+1(14!x4)+ ... 12x2112x2(12!x2)12x2(14!x4) ... = ...
    • ... =1x2+13x4245x6+ ...
  • since cos2x=1sin2x, we also obtained the expansion of sin2x!


Higher Order Terms

Instead of writing "..." can just say "HOT" meaning "Higher order terms":

  • ex=1+x+12x2+13!x3+HOT
  • we mean that we don't care what terms are there - it's fine to consider just leading terms for some purposes
  • it can simplify our calculations


For example:

  • f(x)=12xesin(x2)
  • How can we Taylor Expand it?
  • sin(x2)=x213!(x2)3+HOT=x213!x6+HOT
  • esin(x2)=1+(x213!x6+HOT)+12!(x213!x6+HOT)2+13!(x2+HOT)3+HOT=1+x2+12x4+HOT
  • so f(x)=12xesin(x2)=12x(1+x2+12x4+HOT)


To show what behavior HOTs have, we use Orders of Growth: the Big-O notation:

  • ex11x=(1+x+O(x2))(1+x+O(x2))= ...
    • ... =(1+x)2+2(1+x)O(x)+(O(x2))2=1+2x+O(x2)+O(x3)+O(x4)=1+2x+O(x2)


Convergence

Series = adding an infinite number of terms

  • it can be dangerous
  • Problem: not all functions can be expressed as sum of Polynomial Functions, i.e. as f(x)=ckxk

for example, natural Logarithm:

  • log.png
  • lnx is not even defined at x=0
  • polynomials are too simple to capture all the complexity of lnx


Convergence Domain

Taylor Series has a convergence domain on which the series is well behaved

  • for many functions, e.g. ex, sinx, cosx, sinhx, etc, the domain is R=(,)

Within the domain of convergence you can do with series whatever you want:

  • rearrange terms
  • differentiate/integrate
  • combine

For example, ln(1+x)

  • ln(1+x)=11+xdx
  • ln(1+x)=(k=0(x)k)dx= ...
    • can rearrange integral and sum:
    • ... =k=0((x)kdx)= ...
    • ... =k=0(1)kxk+1k+1+C= ...
  • C=0 because ln1=0, so we have
    • ln(1+x)=k=1(1)k+1xkk=x12x2+13x314x4+ ...
  • no factorials involved!


Convergence domain:

  • we used Geometric Series here, so we must be in the domain of convergence of this series
  • which is |x|<1
  • Taylor Series approximates well only on the domain of convergence
  • log-domain-of-conv.png
  • outside of the domain, we don't get better approximation when we add more terms!


Another example: arctanx

  • arctanx=11+x2dx
    • we also have a Geometric Series here, with x2, so
  • arctanx=11+x2dx=k=0(x2)kdx= ...
    • ... =k=0(1)kx2kdx=k=0((1)kx2kdx)= ...
    • ... =k=0(1)k2k+1x2k+1+C
  • C=0 because arctan0=0
    • so arctanx=x13x3+15x517x7+ ...
  • arctan-domain-of-conv.png
  • the domain of convergence is also |x|<1


Expansion Points

  • Maclaurin Series give good approximation at points near 0.
  • But what if we want to have good approximations at some other points?
  • In many applications 0 is not the most interesting point

Taylor Series of f(x) at x=a is

  • f(x)=k=0f(k)(a)k!(xa)k=f(a)+dfdx|a(xa)+12!d2fdx2|a(xa)2+13!d3fdx3|a(xa)3+ ...
  • this is polynomial in (xa) instead of just x

Approximation

taylor-approx.png

  • The bigger |ax| is, the more high-order terms we need to have good approximation
  • Taylor Series converge only within the domain of convergence - so need to stay within the domain


Example:

  • estimate 10
  • x expanded at x=a is x=a+12a(xa)18a3(xa)2+HOT
  • let's approximate it at a=1:
    • x=1+12(x1)18(x1)2+HOT
    • for x=10, we get 4.122
    • bad approximation! a=1 is far from x=10, so need more derivatives to approximate better
  • let's consider a=9 (9=3)
    • x=3+16(x9)1216(x9)24.122
    • for x=10 we get 3+1/61/2163.1620 (real is 3.1623)
    • quite close!
  • so it's important to select a which is close to the value x where you want to approximate f(x)


Taylor Expansion via Decomposition

Be careful with expansion points when doing Taylor Expansion via decomposition Expand about the correct value!

taylor-expansion-composition.png

For example, compute expansion for ecosx about x=0

  • we have: 0cos()e()
  • first, we expand about 0
  • but for e, we don't expand about 0 - we expand about cos0=1!
  • cosx=112!x2+14!x4 ...
  • eu=e+e(u1)+12!e(u1)2+ ...


Sources