Lecture_22_to_24_171093041042445890665fab9eabb603 (2)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Lec 22 to 24

Numerical Differentiation
Forward Difference Approximation of the First Derivative
Taylor Series Approximation
f 00 (x)(∆x)2 f 000 (x)(∆x)3
f (x + ∆x) = f (x) + f 0 (x)∆x + + + ··· (1)
2! 3!
On rearranging some terms in Eq.(1)

f (x + ∆x) − f (x) f 00 (x)(∆x) f 000 (x)(∆x)2


= f 0 (x) + + + ··· (2)
∆x 2! 3!
Eq.(2) can also be written as,

f (x + ∆x) − f (x)
= f 0 (x) + O(∆x) (3)
∆x
On truncating the term in Eq.(3) after first derivative gives,

f (x + ∆x) − f (x)
f 0 (x) ≈ (4)
∆x

2 / 15
Backward Difference Approximation of the First Derivative
Taylor Series Approximation
f 00 (x)(∆x)2 f 000 (x)(∆x)3
f (x − ∆x) = f (x) − f 0 (x)∆x + − + ··· (5)
2! 3!
Rearranging Eq.(5)

f (x) − f (x − ∆x) f 00 (x)(∆x) f 000 (x)(∆x)2


= f 0 (x) − + − ··· (6)
∆x 2! 3!
Eq.(6) can also be written as,

f (x) − f (x − ∆x)
= f 0 (x) + O(∆x) (7)
∆x
On truncating the term in Eq.(7) after first derivative gives,

f (x) − f (x − ∆x)
f 0 (x) ≈ (8)
∆x

3 / 15
Graphical Representation

Figure 1: Graphical representation of forward difference approximation of


first order derivative.

4 / 15
Figure 2: Graphical representation of backward difference approximation of
first order derivative.

5 / 15
Centered Difference Approximation of the First Derivative

Subtract Eq.(5) from Eq.(1)


f 000 (x)(∆x)3
f (x + ∆x) − f (x − ∆x) = 2f 0 (x)∆x + 2 + ··· (9)
3!
Rearrangement of Eq.(9) gives,

f (x + ∆x) − f (x − ∆x) f 000 (x)(∆x)2


= f 0 (x) + + ··· (10)
2∆x 3!
Eq.(10) can also be written as,

f (x + ∆x) − f (x − ∆x)
= f 0 (x) + O(∆x 2 ) (11)
2∆x
On truncating the term in Eq.(11) after first derivative gives,

f (x + ∆x) − f (x − ∆x)
f 0 (x) ≈ (12)
2∆x

6 / 15
Figure 3: Graphical representation of centered difference approximation of
first order derivative.

7 / 15
Finite Difference Approximations of Higher Derivatives

The Taylor series expansion for f (x + 2∆x) in terms of f (x) is


expressed as,

f 00 (x)(2∆x)2
f (x + 2∆x) = f (x) + f 0 (x)(2∆x) + + ··· (13)
2!
Similarly, the Taylor series expansion for f (x + ∆x) is given by,

f 00 (x)(∆x)2
f (x + ∆x) = f (x) + f 0 (x)∆x + + ··· (14)
2!
Multiply Eq.(14) by 2 and then subtract it from Eq.(13) gives,

f 00 (x)(2∆x 2 )
f (x + 2∆x) − 2f (x + ∆x) = −f (x) + + ··· (15)
2!

11 / 15
Eq.(15) can also be written as,

f (x + 2∆x) − 2f (x + ∆x) + f (x)


= f 00 (x) + O(∆x) (16)
∆x 2

On truncating the higher order terms, Eq.(16) becomes,

f (x + 2∆x) − 2f (x + ∆x) + f (x)


f 00 (x) = + O(∆x) (17)
∆x 2

Eq.(17) is the forward difference approximation of second derivative.

In a similar way, backward difference approximation of second deriva-


tive can be derived and written as,

f (x) − 2f (x − ∆x) + f (x − 2∆x)


f 00 (x) = + O(∆x) (18)
∆x 2

12 / 15
Similarly, second-order central difference approximation can be repre-
sented as,

f (x + ∆x) − 2f (x) + f (x − ∆x)


f 00 (x) = + O(∆x 2 ) (19)
∆x 2

As was the case with the first-derivative approximations, the centered


case is more accurate. Alternatively, Eq.(19) can also be expressed
as,

f (x+∆x)−f (x)
− f (x)−f∆x
(x−∆x)
f 00 (x) ≈ ∆x
(20)
∆x

As second derivative is a derivative of a derivative, the second divided


difference approximation is a difference of two first divided differences.

13 / 15

You might also like