Taylor Series
Taylor Series
Taylor Series
With each extra piece of information, you get a better and better idea of what the curve looks like near
that point. The more terms you add, the more accurate the approximation becomes.
In short, the Taylor series lets you approximate complex curves or functions using simpler terms—
essentially breaking down a complicated shape into small, easy-to-understand pieces, one step at a time.
It’s used in everything from computer graphics to engineering, where precise calculations are needed
but exact solutions are difficult.
APPLICATION IN CS
MATHEMATICAL REPRESENTATION
Taylor series and polynomials are of basic importance and used extensively in numerical
analysis, in approximating a differentiable function and its integral etc.
Taylor Series
Let f and its higher order derivatives be continuous on [a, b] and x0 be a fixed point in [a, b].
Then, for x ∈ [a, b], 𝑓(𝑥) can be expressed as the infinite series (called Taylor’s Series)
𝑓 ′′ (𝑥0 ) 𝑓 (𝑛) (𝑥0 ) 𝑓 (𝑛+1) (𝑥0 )
𝑓(𝑥) = 𝑓(𝑥0 ) + 𝑓 ′ (𝑥0 )(𝑥 − 𝑥0 ) + 2
(𝑥 − 𝑥0 ) + ⋯ + 𝑛
(𝑥 − 𝑥0 ) + (𝑥 − 𝑥0 )𝑛+1 + ⋯
2! 𝑛! (𝑛 + 1)!
Taylor Polynomial
𝑓(𝑛) (𝑥0 )
If the Taylor’s series is truncated to the term (𝑥 − 𝑥0 )𝑛 , then the polynomial
𝑛!
obtained is called the Taylor’s polynomial
′′ 𝑛 ( )
′ 𝑓 (𝑥0 ) 2 𝑓 (𝑥0 )
𝑓(𝑥) ≈ 𝑃𝑛 (𝑥) = 𝑓(𝑥0 ) + 𝑓 (𝑥0 )(𝑥 − 𝑥0 ) + (𝑥 − 𝑥0 ) + ⋯ + (𝑥 − 𝑥0 )𝑛
2! 𝑛!
Theorem (Taylor’s Theorem)
Suppose f ∈ Cn [a, b], that f (n+1) exists on [a, b], and x0 ∈ [a, b]. For every x ∈ [a, b],there
exists a number ξ(x) between x0 and x with
𝑓(𝑥) = 𝑃𝑛 (𝑥) + 𝑅𝑛 (𝑥)
Where
′(
𝑓 ′′ (𝑥0 ) 2
𝑓 (𝑛) (𝑥0 )
𝑃𝑛 (𝑥) = 𝑓 (𝑥0 ) + 𝑓 𝑥0 )(𝑥 − 𝑥0 ) + (𝑥 − 𝑥0 ) + ⋯ + (𝑥 − 𝑥0 )𝑛
2! 𝑛!
and
𝑓 (𝑛+1) (𝜉(𝑥))
𝑅𝑛 (𝑥) = (𝑥 − 𝑥0 )𝑛+1 .
(𝑛 + 1)!
Here 𝑃𝑛 (𝑥) is the nth Taylor polynomial for f about x0, and 𝑅𝑛 (𝑥) is the remainder term (or
truncation error) associated with 𝑃𝑛 (𝑥). Since the number ξ(x) in the truncation error 𝑅𝑛 (𝑥)
depends on the value of x at which the polynomial 𝑃𝑛 (𝑥) is being evaluated, it is a function of
the variable x. However, we should not expect to be able to explicitly determine the function
ξ(x). Taylor’s Theorem simply ensures that such a function exists, and that its value lies
between x and x0.
In the case x0 = 0, the Taylor polynomial is often called a Maclaurin polynomial, and the
Taylor series is often called a Maclaurin series.
The term truncation error in the Taylor polynomial refers to the error involved in using a
truncated, or finite, summation to approximate the sum of an infinite series.
GRAPHICAL REPRESENTATION
EXAMPLES
⟹ 𝑃4 (0.02) =0.99980001
Example 2.
Find Taylor series and polynomials of degree 4 and 5 for the function sin 𝑥 about 𝑥0 = 0 and
use the polynomial to find the actual error at 𝑥 = 0.1 and 𝑥 = 0.5.
Solution: 𝑓(𝑥) = sin 𝑥 , 𝑓(0) = 0
′ (𝑥)
𝑓 = cos 𝑥, 𝑓 ′ ( 0) = 1
𝑓 ′′ (𝑥) = − sin 𝑥, 𝑓 ′′ (0) = 0
𝑓 ′′′ (𝑥) = − cos 𝑥, 𝑓 ′′′ (0) = −1
𝑓 (4) (𝑥) = sin 𝑥, 𝑓 (4) (0) = 0
′
𝑓′′ (0) 𝑓′′′ (0) 𝑓(4) (0)
𝑓(𝑥) = 𝑓(0) + 𝑓 (0)𝑥 + 𝑥 + 2 3
𝑥 ++ 𝑥4 + ⋯
2! 3! 4!
𝑥3 𝑥5 𝑥7
sin 𝑥 = 𝑥 − + − +⋯
3! 5! 7!
𝑥3 𝑥3 𝑥5
or sin 𝑥 ≈ 𝑃4 (𝑥) = 𝑥 − and sin 𝑥 ≈ 𝑃5 (𝑥) = 𝑥 − +
3! 3! 5!
Therefore, 𝐀𝐜𝐭𝐮𝐚𝐥 𝐞𝐫𝐫𝐨𝐫 for 𝑃4 (0.1) = 8.7 × 10−8 and for 𝑃5 (0.1) = 2 × 10−11 , resp.
* But if we check error at 𝑥 = 0.5, with 𝑃5 (0.5) = 0.4794271
and exact value is sin 0.5 = 0.4794255,
≤ 0.103 taking 𝜉 (𝑥) = 0.5, cos 𝜉 (𝑥) = 1 and sin 𝜉 (𝑥) = 𝜉 (𝑥) .
(c) To find upper bound of error for 𝑃2 (𝑥) on the interval [0,1]
1 1
∫0 𝑃2 (𝑥) 𝑑𝑥 = ∫0 (1 + 𝑥) 𝑑𝑥 = 1.5
1
While exact value is ∫0 𝑒 𝑥 cos 𝑥 𝑑𝑥 = 1.378.
𝑃3 (0.2) = 0.8945
While exact value is 𝑓(0.2) = √1 − 0.2 = 0.8944272
So, 𝐀𝐜𝐭𝐮𝐚𝐥 𝐞𝐫𝐫𝐨𝐫 = 7 × 10−5 .
For n = 4 and 𝑥0 = 0, we have
′
𝑓′′ (0) 𝑓′′′ (0) 𝑓(4) (0)
𝑃4 (𝑥) = 𝑓(0) + 𝑓 (0)𝑥 + 𝑥 + 2 3
𝑥 + 𝑥4
2! 3! 4!
1 1 1 5
= 1 − 𝑥 − 𝑥2 − 𝑥3 − 𝑥4
2 8 16 128
⟹ 𝑃4 (0.2) = 0.8944375.
Therefore, 𝐀𝐜𝐭𝐮𝐚𝐥 𝐞𝐫𝐫𝐨𝐫 = 1.03 × 10−5 .
(b) To find upper bound of error for 𝑃3 (𝑥) will be
𝑓 (4) (𝜉 (𝑥)) 4 5
𝑅3 (𝑥) = 𝑥 =− (1 − 𝜉 (𝑥))−7/2 𝑥 4
4! 128
so 𝑅3 (0.2) ≤ 1.365 × 10−4 taking 𝜉(𝑥) = 0.2.
0.5
(c) To approximate ∫0 𝑓(𝑥)𝑑𝑥 , we use
0.5 0.5 1 1 1
∫0 𝑃3 (𝑥) 𝑑𝑥 = ∫0 (1 − 2 𝑥 − 8 𝑥 2 − 16 𝑥 3 ) 𝑑𝑥 = 0.431315
0.5
While exact value is ∫0 √1 − 𝑥 𝑑𝑥 = 0.430964.
Therefore, 𝐀𝐜𝐭𝐮𝐚𝐥 𝐞𝐫𝐫𝐨𝐫 = 3.51 × 10−4 .
PROBLEM STATEMENT
ANSWERS
(Solve it yourself!)
ERROR ANALYSIS
PYTHON CODE