Numerical Analysis: (MA214) : Instructor: Prof. Tony J. Puthenpurakal
Numerical Analysis: (MA214) : Instructor: Prof. Tony J. Puthenpurakal
Lecture 3
Department of Mathematics
Indian Institute of Technology Bombay
[email protected]
Lagrange’s form
n
Y x − xi
lk (x) = , k = 0, 1, · · · , n
xk − xi
i=0,i6=k
Xn
Pn (x) = f (xi )li (x)
i=0
Example:-
dy
= g (x, y ) , y (x0 ) = y0
dx
Note:- y 0 (xi ) = g (xi , yi ) can be readily computed.
Set z0 = x0 , and z1 = x0
z2 = x1 , and z3 = x1
..
.
z2i = xi , and z2i+1 = xi
..
.
z2n = xn , and z2n+1 = xn
( )
f 0 (zi ) if zi = zi+1
Set f [zi , zi+1 ] = f (zi+1 )−f (zi )
zi+1 −zi if zi 6= zi+1
For higher order computation
f [zi+1 , · · · , zi+k ] − f [zi , · · · , zi+k−1 ]
f [zi , zi+1 , · · · , zi+k ] =
zi+k − zi
P2n+1 (x) = f [z0 ] + f [z0 , z1 ](x − z0 ) + f [z0 , z1 , z2 ](x − z0 )(x − z1 )
2n
Y
+ · · · + f [z0 , · · · , z2n+1 ] (x − zj )
Instructor: Prof. Tony J. Puthenpurakal j=0 Analysis : [ MA214 ] Lecture 3
Numerical
Problem
Set z0 = 0, z1 = 0, z2 = 1, z3 = 1
z f (z) f [, ] f [, , ] f [, , , ]
0 1 2 −1.1 2.7
0 1 0.9 1.6
1 1.9 2.5
1 1.9
f [0, 0] = f 0 (0) = 2
f [1, 1] = f 0 (1) = 2.5
f (1) − f (0) 1.9 − 1
f [0, 1] = = = 0.9
1−0 1
f [0, 1] − f [0, 0]
f [0, 0, 1] = = 0.9 − 2 = −1.1
1−0
f [1, 1] − f [0, 1]
f [0, 1, 1] = = 2.5 − 0.9 = 1.6
1−0
finally
f [0, 1, 1] − f [0, 0, 1]
f [0, 0, 1, 1] = = 1.6 − (−1.1) = 2.7
1−0
P3 (x) = 1 + 2(x − 0) + (−1.1)(x − 0)2 + 2.7(x − 0)2 (x − 1)
= 1 + 2x − 1.1x 2 + 2.7x 2 (x − 1)
f (0.4) ≈ P3 (0.4) = 1.365
Convention:-
f (1) = g (1)
f 0 (1) = g 0 (1)
f (2) = g (2)
f 0 (2) = g 0 (2)
f 00 (2) = g 00 (2)
f (3) = g (3)
Problem:-
Given x0 , x1 , · · · , xm not necessarily distinct points and f : [a, b] → R.
We need a polynomial p(x) of degree ≤ m such that p(x) and f (x) agree
at x0 , x1 , · · · , xm .
Instructor: Prof. Tony J. Puthenpurakal Numerical Analysis : [ MA214 ] Lecture 3
Exercise:- Show that if two polynomials of degree ≤ m agree at
x0 , x1 , · · · , xm , then they are equal.
Uniqueness-Exercise
Existence:-
Assume x0 ≤ x1 ≤ · · · ≤ xm
for m = 0 there is nothing to show.
Case 1 x0 = xk . Then x0 = x1 = x2 = · · · = xk .
So r ≥ k. By assumption f has at least k continuous derivatives.
Then the Taylor polynomial Pk (x) for f (x) around the center c = x0 does
the job.
f (k) (x0 )
Remark:- Note that its leading coefficient is k!
Case 2 x0 < xk
Verify
x − x0 xk − x
Pk (x) = qk−1 (x) + Pk−1 (x)
xk − x0 xk − x0
does the job.
[ Slightly tricky to show. See textbook Conte and de Boor page 64. ]
We have
m−1
Y
Pm (x) = Pm−1 (x) + f [x0 , x1 , · · · , xm ] (x − xi )
i=0
Proof:-
m−1
Y
Pm (x) − f [x0 , x1 , · · · , xm ] (x − xi )
i=0
has degree ≤ m − 1 and agrees with f (x) at x0 , x1 , · · · , xm .
Case 1 x0 = x1 = x2 = · · · = xm .
z f (z) f [, ] f [, , ] f [, , , ]
0 1 0 0.5 −10
0 1 0 −5E −1
0 1 −5E −2
0.1 9.95E −1
z0 = 0, z1 = 0, z2 = 0, z3 = 0.1
f [z0 , z1 ] = f 0 (0) = 0
f [z1 , z2 ] = f 0 (0) = 0
f (z3 ) − f (z2 )
f [z2 , z3 ] = = −5E −2
z3 − z2
f 00 (z0 )
f [z0 , z1 , z2 ] = = 0.5
2
f [z2 , z3 ] − f [z1 , z2 ] −5E −2 − 0
f [z1 , z2 , z3 ] = = = −5E −1
z3 − z1 0.1
f [z1 , z2 , z3 ] − f [z0 , z1 , z2 ]
f [z0 , z1 , z2 , z3 ] = = −10
z3 − z0
P3 (x) = f (a) + f [a, a](x − a) + f [a, a, b](x − a)2 + f [a, a, b, b](x − a)2 (x − b)
P3 (a) = f (a)
P30 (a) = f [a, a] = f 0 (a)
f (b) − f (a)
f [a, b] =
b−a
f [a, b] − f [a, a]
f [a, a, b] =
b−a
f (b)−f (a)
b−a − f 0 (a)
=
b−a
f (b) − f (a) − (b − a)f 0 (a)
=
(b − a)2
Verify
Theorem
f [x0 , x1 , · · · , xn ] is a continuous function of x0 , x1 , · · · , xn . (Assume f has
n continuous derivatives )
(r ) (r )
i.e. for each r , x0 , · · · , xn are n + 1 points in [a, b] and
(r )
lim x = yi for i = 0, 1, · · · , n
r →∞ i
Then
(r ) (r ) (r )
lim f [x0 , x1 , · · · , xn ] = f [y0 , y1 , · · · , yn ]
r →∞
Proof.
See textbook Conte and de Boor page 65.
Strategy:-
Use piecewise-polynomial approximation
Note that if N is large and so |xi − xi+1 | is small then this is a good
approximation of f (x).
We study 2 cases
1 Piecewise-Cubic Hermite interpolation
2 Cubic-Spline interpolation
By Newtone formula
For i = 1, 2, · · · , N + 1
fi = f xi
4xi = xi+1 − xi
si = f 0 (xi ), c1,i = fi , c2,i = si
dy
= y − x 2 + 1, and y (0) = 0.5, 0 ≤ x ≤ 1
dx
xi y (xi ) y 0 (xi )
0 0.5 1.5
0.2 0.826 1.786
0.4 1.207 2.047
0.6 1.637 2.277
0.8 2.110 2.470
1.0 2.618 2.618
x y (x) f [, ] f [, , ] f [, , , ]
0.6 1.637 2.277 4.4E −1 4.25E −1
0.6 1.637 2.365 5.25E −1
0.8 2.110 2.470
0.8 2.110