Taylor's series

From Wikiversity
Jump to navigation Jump to search

A well-behaved function can be expanded into a power series. This means that for all non-negative integers there are real numbers such that

Let us calculate the first four derivatives using :

Setting equal to zero, we obtain

Let us write for the -th derivative of  We also write — think of as the "zeroth derivative" of  We thus arrive at the general result where the factorial  is defined as equal to 1 for and and as the product of all natural numbers for Expressing the coefficients in terms of the derivatives of at we obtain

This is the Taylor series for 

A remarkable result: if you know the value of a well-behaved function and the values of all of its derivatives at the single point then you know at all points  Besides, there is nothing special about so is also determined by its value and the values of its derivatives at any other point :



Some basic checking:


. See .

Second derivative [edit]

Third derivative [edit]


If you continue to calculate derivatives, you will produce the following sequence:

Some basic checking:


Simple differential equations eliminate the square root and make calculations so much easier.


Then where and

Differentiating both sides:



Differentiating both sides:



When Calculation of more derivatives yields:

and so on.

As programming algorithm:[edit]

As implemented in Python:[edit]

from decimal import * # Default precision is 28.

π = ("3.14159265358979323846264338327950288419716939937510582097494459230781")
π = Decimal(π)

x = Decimal(2).sqrt()/2 # Expecting result of π/4

xSQ = x*x
X = x*xSQ

top = Decimal(1)
bottom = Decimal(2)

bottom1 = bottom*3
sum = x + X*top / bottom1

status = 1
for n in range(5,200,2) :
    X = X*xSQ
    top = top*(n-2)
    bottom = bottom*(n-1)
    bottom1 = bottom*n
    added = X*top/bottom1
    if (added < 1e-29) :
        status = 0
    sum += added

if status :
    print ('error. count expired.')
else :
    print (x, sum==π/4, n)
0.707106781186547524400844362 True 171

In practice[edit]

If is close to the calculation of will take forever.

If you limit to then and each term is guaranteed to be less than half the preceding term.

If let


External links[edit]