Chapter 1 Numerical Interpolation and Differentiation
Chapter 1 Numerical Interpolation and Differentiation
AND INTEGRATION
CONTENT
Page
2
Y
3
1.2 DIFFERENCE TABLE
4
∆fi = f(xi+1) - f(xi)
Corollary:
5
EXAMPLE 2: NON-POLYNOMIALS
x f(x) ∆f ∆2 f ∆3f
1.0 1.0000
-0.1667
1.2 0.8333 0.0477
-0.1190 -0.0180
1.4 0.7143 0.0297
-0.0893 -0.0098
→1.6 0.6250 0.0199
-0.0694 -0.0061
1.8 0.5556 0.0138
-0.0556
2.0 0.5000
7
NOTATIONS FOR DIFFERENCES
Forward differences:
(evenly-spaced data)
(unevenly-spaced data)
8
x f(x) 1st 2nd 3rd 4th
x-2 f-2
∆f-2
x-1 f-1 ∆2f-2
∆f-1 ∆3f-2
xo fo ∆2f-1 ∆4f-2
∆fo ∆3f-1
x1 f1 ∆2fo
∆f1
x2 f2
∆ f-1 = fo - f-1 ,
∆2f-1 = ∆ fo - ∆ f-1
9
Generally,
∆fm = fm+1 - fm
xo = 1.6,
fo = 0.6250
∆fo = -0.0694
∆2fo= 0.0138
10
EXAMPLE 3: EFFECT OF ERRORS IN X
∆f ∆ f ∆ f ∆ f
2 3 4
x f(x)
0 1
32
2 33 160
192 133
4 225 293 44
485 177
6 710 470 -66
955 111
8 1665 581 44
1536 155
10 3201 736 -11
2272 144
12 5473 880 0
3152 144
14 8625 1024
4176
16 12801
11
If one of the x data in the difference table is
wrong, but we know that the underlying
function is cubic degree beforehand, from the
difference columns, we may be able to undo
the error, and find the correct value for x.
12
∆f ∆f ∆f ∆f
2 3 4
x f(x)
144
304 0
496 144
6 721 448 0
944 144
592 0
144
0
13
Notations for differences.
= ∆fi+1 - ∆fi
∴ ∆ fi
2
= fi+2 - 2fi+1 + fi
∆ fi
3
Verify = fi+3 - 3fi+2 + 3fi+1 - fi
+1
2
+1 -2 +1 ∆
3
+1 -3 +3 -1 ∆
4
+1 -4 +6 -4 +1 ∆
14
Forward Difference method
∆fi = fi+1 - fi
Homework:
Verify ∆ fi =
4
fi+4 - 4fi+3 + 6fi+2 - 4 fi+1 + fi
15
1.3 NEWTON-GREGORY
POLYNOMIALS
Linear Interpolation
h
f1 - fo
sh
fo f1
X
xo x x1
16
The curve f(x) is approximated by a CHORD at
two adjacent x-values, xo and x1.
f(x) ≈ P1(x)
= fo + s ∆fo
x - xo
where s =
h
17
Quadratic Interpolation
(evenly-spaced data)
f(x)
P2(x)
f2 - fo
sh f1 f2
fo
h h X
xo x x1 x2
s( s − 1) 2
∆ fo
2
x - xo
where s =
h
18
At x = xo , s= 0 ,
P2(xo) = fo
At x = x1 , s= 1 ,
P2(x1) = fo + ∆ fo = f1
At x = x2 , s= 2 ,
P2(x2) = fo + 2∆ fo + ∆ fo
2
= f1 + ∆ f1 = f2
2
(Note: ∆ fo = ∆ f1 - ∆ fo )
Pn(x) = fo + s ∆ fo + s ( s − 1 ) ∆2 f + .....
o
2!
⎛ s⎞ 2
= fo + ⎛ s⎞
⎜ ⎟ ∆ fo + ⎜ ⎟ ∆ fo + ......
⎝ 1⎠ ⎝ 2⎠
19
EXAMPLE 4: EXACT INTERPOLATION
f(x) ∆f ∆f ∆f ∆f
2 3 4
x
0 0
1
1 1 12
13 12
2 14 24 0
37 12
3 51 36 0
73 12
4 124 48
121
5 245
s( s − 1)( s − 2) 3
+ ∆ fo
3!
Choose xo = 0 , s = (x/1) = x
x( x −1)
P3 (x) = 0 + x.1 + 2 . 12 +
x( x − 1)( x − 2)
. 12
6
3
= 2x - x
21
Corollaries:
Forward Interpolation
22
3.2 − 2
∴ s = = 1.2
10
.
s( s − 1) 2
Thus, f(3.2) ≈ fo + s ∆ fo + ∆ fo
2
(1.2)(0.2)
= 14 + 1.2(37) + 36
2
s( s − 1)( s − 2 )
Error Term = 12 = - 0.384
6
Truncation Errors
s( s − 1) 2
f(x) ≈ fo + s∆ fo + ∆ fo + .... +
2!
23
s( s − 1)...( s − n + 1) n
∆ fo
n!
Corollaries
24
EXAMPLE 6: FINDING BEST
ESTIMATE
∆f ∆f ∆f ∆f
2 3 4
x f(x)
0.1 0.09983
0.37960
0.5 0.47943 -0.07570
0.30390 -0.04797
0.9 0.78333 -0.12367 0.01951
0.18023 -0.02846
1.3 0.96356 -0.15213
0.02810
1.7 0.99166
25
(a) Quadratic interpolation
x - xo 0.8 - 0.5
s = = = 0.75
h 0.4
s( s − 1) 2
f(x) ≈ fo + s∆ fo + ∆ fo + ....
2!
f(0.8) ≈0.47943+0.30390(0.75)+
= 0.71895
s( s − 1)( s − 2)
ε2 (x) = (- 0.02846)
3!
26
= - 0.00111
⇒ xo = 0.1
0.8 - 0.1
∴ s = = 1.75
0.4
s( s − 1) 2
f(x) ≈ fo + s∆ fo + ∆ fo +
2!
s( s − 1) ( s-2) 3
∆ fo
3!
27
f(0.8) = 0.09983 + 1.75 (0.3796)
(1.75)(0.75)(-0.0757)
+
2
. (0.75)(- 0.25)
175
+ (- 0.04797)
6
= 0.71707
s ( s − 1 )( s − 2 )( s − 3 )
ε3 (x) = (0.01951 )
4!
= 0.00033
28
1.4 DERIVATIVES FROM INTERPOLATION
Y Numerical Integration
f(x)
Pn(x)
Numerical Differentiation
Y f(x)
f’(x)
P’n(x) Pn(x)
29
Consider the Newton-Gregory Forward
Interpolation:
s( s − 1) 2
Pn(x) = fo + s∆ fo + ∆ fo + ..
2!
+ Error
On differentiating,
d ds d
Pn' (x) = [Pn(x)] + [εn(x)]
ds dx dx
d ds 1 ⎧ 1
ds
[Pn(x)] = ⎨ ∆f o +
dx h ⎩ 2
[( s − 1) + s]∆2 f o
1 ⎫
+ [ ( s − 1)( s − 2 ) + s( s − 2 ) + s( s − 1) ] o
∆3
f + " ⎬
6 ⎭
30
For one-sided forward difference, at a specific
point, x = xo, ∴s = 0.
1⎧ 1 2 1 3 ⎫ d
P ' n ( x o ) = ⎨∆f o − ∆ f o + ∆ f − ..⎬ + [ε n ( x )]
h⎩ 2 3 ⎭ dx
(1)
( − 1)n −1 ∆n f o
=
n
31
EXAMPLE 7: DIFFERENCE TABLE
x f ∆f ∆2f
0.0 1.000000
0.105172
0.1 1.105172 0.011059
0.116231
0.2 1.221403 0.012225
0.128456
0.3 1.349859
f'(0) = 1.00
32
Numerically, using 1 term only:
1
f'(0) = {∆ fo }
0.1
⎛ 1 × 0.105172 ⎞
= ⎜ ⎟
⎝ 0.1 ⎠
= 1.05172
Using 2 terms:
⎛ 1 2 ⎞
1⎜ ∆f o − ∆ f o ⎟
⎝ 2 ⎠
f'(0) =
0 .1
1
= 1.05172 − 0.011059
0.2
= 0.99643
33
Colloraries:
f'(xo)
1 ⎧⎪ 1 2 1 3 ( − 1) n −1
⎫⎪
= ⎨∆f o − ∆ fo + ∆ fo + " + ∆ fo ⎬
n
h ⎪⎩ 2 3 n ⎪⎭
( − 1) n h n n+1
+ f ( ξ) xo < ξ < xn
(n + 1)
st
1 term on R.H.S. gives an approximation for
f'(xo).
nd
2 term on R.H.S. is the truncation error.
34
EXAMPLE 8: FORWARD DIFFERENCE
DERIVATIES
x y ∆y ∆2 y ∆3 y ∆4 y
1.3 3.669
0.813
1.5 4.482 0.179
0.992 0.041
1.7 5.474 0.220 0.007
1.212 0.048
1.9 6.686 0.268 0.012
1.480 0.060
2.1 8.166 0.328 0.012
1.808 0.072
2.3 9.974 0.400
2.208
2.5 12.182
35
1 term
1 1.212
y'(1.7) = ∆ fo = = 6.060
h 0.2
2 terms
y'(1.7)
= 1 ⎛⎜ ∆ f o − 1 ∆2 f o ⎞⎟ = 1 ⎛
⎜ 1.212 −
1 ⎞
0.268⎟
h ⎝ 2 ⎠ 0.2 ⎝ 2 ⎠
= 5.390
4 terms
36
Y y=ex
y=ln x
TKH
6 Oct 2006
37