Lecture 24 Diffrentiation
Lecture 24 Diffrentiation
Week 05
E f ( x ) f ( x h)
E f ( x) f ( x nh)
n
E y x y x nh
n
y x y x h y x f ( x h) f ( x )
r 1 r 1
yi
r
yi 1 yi
E 1
Department of Computer Science 18
Difference operators: Backward difference operator
y x y x y x h f ( x ) f ( x h )
k 1 k 1
yi
k
yi yi 1 ,
i n, (n 1),..., k
E 1
1
1 E
Department of Computer Science
E 19
Difference operators: Differential Operator
d
Df ( x) f ( x) f ( x)
dx
2
d
D f ( x) 2 f ( x) f ( x)
2 n
dx
hD log E
Department of Computer Science 24
Differentiation using forward difference operator
dx
This would mean that
in terms of ∆ :
1 2 3
4 5
D
h 2 3 4 5
Department of Computer Science 28
Differentiation using forward difference operator
Df ( x0 ) f ( x0 )
1 2 f ( x0 ) 3 f ( x0 )
f ( x0 )
h 2 3
4 f ( x0 ) 5 f ( x0 ) d
f ( x0 )
4 5 dx
In other words
Dy0 y0
1 y0 y0 y0
2
3 4
y0
h 2 3
Department of Computer Science
4 29
Differentiation using forward difference operator
h 12 6
1 2 11 4 5 5
2
3
h 12 6
2
d y0
D y0
2
2
y0
dx
y0 y0
2 3
1
2 11 4 5 5
h y0 y0
12 6
Department of Computer Science 31
Example
1 2 f ( x) 3 f ( x)
D f ( x) 2
2
h
11 4 5 5
f ( x) f ( x)
12 6
1 11
f (0) 2 2.24 5.76 12 (3.84)
(02)
5
(0) 0.0
6 35
Department of Computer Science
Differentiation using backward difference operator
dx
On expansion, we have
1 2 3 4
D
h 2 3 4
Department of Computer Science 36
Differentiation using backward difference operator
1 2 3 4
D
h 2 3 4
d
yn Dyn yn
dx
1 yn yn y n
2 3 4
yn
h 2 3 4
Department of Computer Science 37
Differentiation using backward difference operator
1 2 3 4
D
h 2 3 4
2
1
2 3 4
D 2
2
h 2 3 4
1 2 11 4 5 5
2
3
h 12 6
Department of Computer Science 38
Differentiation using backward difference operator
1 2 11 4 5 5
2
3
h 12 6
yn D yn 2
1 2 11 4 5 5
2 yn y n yn yn
3
h 12 6
1 yn yn yn 2 3 4
yn yn
h 2 3 4
1 0.2964 0.0535
y(2.2) 1.6359
0.2 2 3
0.0094
5(1.8043) 9.0215
4
1 2 11 4
yn 2 yn y n y n
3
h 12
1
y(2.2) 2
0.2964 0.0535
(0.2)
11
(0.0094)
12
25(0.3585) 8.9629
Department of Computer Science 43
Derivation of Two and
three point formulae:
Retaining only the first term
in equation :
f ( x ) Li 1 ( x ) f ( x i 1 ) Li ( x ) f ( x i ) Li 1 ( x ) f ( x i 1 )
( x x i )( x x i 1 )
f ( x i 1 )
( x i 1 x i )( x i 1 x i 1 )
( x x i 1 )( x x i 1 )
f ( xi )
( x i x i 1 )( x i x i 1 )
( x x i 1 )( x x i )
f ( xi1 )
( x i 1 x i 1 )( x i 1 x i )
( x x 1 )( x x 2 )
f2 ( x ) f ( x0 )
( x0 x 1 )( x0 x 2 )
( x x0 )( x x 2 )
f ( x1 )
( x 1 x0 )( x 1 x 2 )
( x x0 )( x x 1 )
f ( x2 )
( x 2 x0 )( x 2 x 1 )
Department of Computer Science
Interpolation
Third-order Lagrange polynomial
( x x 1 )( x x 2 )( x x 3 )
f3 ( x ) f ( x0 )
( x0 x 1 )( x0 x 2 )( x0 x 3 )
( x x0 )( x x 2 )( x x 3 )
f ( x1 )
( x 1 x0 )( x 1 x 2 )( x 1 x 3 )
( x x0 )( x x 1 )( x x 3 )
f ( x2 )
( x 2 x0 )( x 2 x 1 )( x 2 x 3 )
( x x0 )( x x 1 )( x x 2 )
f ( x3 )
( x 3 x0 )( x 3 x 1 )( x 3 x 2 )
First derivative
2 x xi xi1 2 x xi 1 xi 1
f ( x ) f ( x i 1 ) f ( xi )
( x i 1 x i )( x i 1 x i 1 ) ( x i x i 1 )( x i x i 1 )
2 x xi 1 xi
f ( xi1 )
( x i 1 x i 1 )( x i 1 x i )
Department of Computer Science
Second Derivative
First Derivative for unequally spaced
data
2 x xi xi1 2 x xi 1 xi 1
f ( x ) f ( x i 1 ) f ( xi )
( x i 1 x i )( x i 1 x i 1 ) ( x i x i 1 )( x i x i 1 )
2 x xi 1 xi
f ( xi1 )
( x i 1 x i 1 )( x i 1 x i )