Came to the Taylor series while I was studying the fundamental element of chaos theory.

So what is Taylor series?

Taylor series is a representation of a function as an infinite sum of terms, calculated from the values of its derivative at a single point [Wikipedia].

Let’s look at the definition.

Given a function f(x) and f(x) is differentiable infinitely at a point a of a real or complex domain. Then, we say that, for a value x near a, f(x) can be approximated with Taylor series. That is,

\displaystyle \sum^{\infty}_{n=0} \frac{f^{(n)}(a) }{n !} (x-a)^n  .

where n! denotes the factorial of n and f^{(n)}(a) denotes the nth derivatives of f at point a.

#

OK. Let’s see for an example.

We all know that the derivative of e^x is also e^x. In other words, e^x can be differentiated infinitely.

Every algebra has a value of 1 when power with 0, except 0^0 which is undefined. So, how about e^{0.001} ?

Of cause we can use calculator to find out the value. But, let’s try with Taylor series method, i.e.

f(0.001) = \frac{f^{(0)}(0)}{0!}(0.001)^0 +  \frac{f^{(1)}(0)}{1!}(0.001)^1 + \cdots + \frac{f^{(n)}(0)}{n!}(0.001)^n

#

#
Let’s calculate this with Python.

#python code

import scipy

scipy.e**0

def taylor_euler(a, x, n):

result = 0

for i in range(0, n):

t1 = scipy.e ** (a)

t2 = (x - a) ** i

t3 = scipy.factorial(i)

result += t1 * t2 / t3

return result

print 'Answer of e^0.001 is %0.20f' % scipy.e **0.001

print 'OK. Let''s approximate e^0.001 from e^0 by slowly increase the iterations...'

for i in range(10):

ans = taylor_euler(0,0.001, i)

print '[%02d] ans = %0.20f' % (i+1, ans)

The output is:

Answer of e^0.001 is 1.00100050016670838460

OK. Lets approximate e^0.001 from e^0 by slowly increase the iterations...

[01] ans = 0.00000000000000000000

[02] ans = 1.00000000000000000000

[03] ans = 1.00099999999999988987

[04] ans = 1.00100049999999995975

[05] ans = 1.00100050016666664021

[06] ans = 1.00100050016670838460

[07] ans = 1.00100050016670838460

[08] ans = 1.00100050016670838460

[09] ans = 1.00100050016670838460

[10] ans = 1.00100050016670838460

As you may see, we have obtained a reasonable close value of e^{0.001} at iteration 6.