Numerical Analysis DCS-UOK Supervisor: Dr.
Shaista Rais
Direct Method of Interpolation
x3 , y3
x1 , y1
f x
x2 , y2
x0 , y0
x
Figure 1 Interpolation of discrete data.
Direct Method
The direct method of interpolation is based on the following premise. Given n 1 data
points, fit a polynomial of order n as given below
y a0 a1 x ............... a n x n (1)
through the data, where a 0 , a1 ,........., a n are n 1 real constants. Since n 1 values of y
are given at n 1 values of x , one can write n 1 equations. Then the n 1 constants,
a 0 , a1 ,........., a n can be found by solving the n 1 simultaneous linear equations. To find
the value of y at a given value of x , simply substitute the value of x in Equation 1.
But, it is not necessary to use all the data points. How does one then choose the
order of the polynomial and what data points to use? This concept and the direct method
of interpolation are best illustrated using examples.
Qestion 1
The upward velocity of a rocket is given as a function of time in Table 1.
Table 1 Velocity as a function of time.
t (s) v(t ) (m/s)
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
Numerical Analysis DCS-UOK Supervisor: Dr. Shaista Rais
Determine the value of the velocity at t 16 seconds using the direct method of
interpolation and a first order polynomial.
Solution
For first order polynomial interpolation (also called linear interpolation), the velocity given
by
vt a0 a1t
x1 , y1
f1 x
x0 , y0
x
Figure 3 Linear interpolation.
Since we want to find the velocity at t 16 , and we are using a first order polynomial, we
need to choose the two data points that are closest to t 16 that also bracket t 16 to
evaluate it. The two points are t 0 15 and t1 20 .
Then
t 0 15, vt 0 362.78
t1 20, vt1 517.35
gives
v15 a0 a1 15 362.78
v20 a0 a1 20 517.35
Writing the equations in matrix form, we have
1 15 a 0 362.78
1 20 a 517.35
1
Solving the above two equations gives
a0 100.93
a1 30.914
Hence
vt a 0 a1t
100.93 30.914t , 15 t 20
At t 16 ,
v16 100.92 30.914 16
393.7 m/s
Question 2
The upward velocity of a rocket is given as a function of time in Table 2.
Table 2 Velocity as a function of time.
t (s) v(t ) (m/s)
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
Determine the value of the velocity at t 16 seconds using the direct method of
interpolation and a second order polynomial.
Solution
For second order polynomial interpolation (also called quadratic interpolation), the velocity
is given by
vt a0 a1t a 2 t 2
y
x1 , y1
x2 , y 2
f 2 x
x0 , y 0
x
Figure 4 Quadratic interpolation.
Since we want to find the velocity at t 16 , and we are using a second order polynomial,
we need to choose the three data points that are closest to t 16 that also bracket t 16
to evaluate it. The three points are t 0 10, t1 15, and t 2 20 .
Then
t 0 10, vt 0 227.04
t1 15, vt1 362.78
Numerical Analysis DCS-UOK Supervisor: Dr. Shaista Rais
t 2 20, vt 2 517.35
gives
v10 a 0 a1 10 a 2 10 227.04
2
v15 a 0 a1 15 a 2 15 362.78
2
v20 a 0 a1 20 a 2 20 517.35
2
Writing the three equations in matrix form, we have
1 10 100 a0 227.04
1 15 225 a 362.78
1
1 20 400 a 2 517.35
Solving the above three equations gives
a0 12.05
a1 17.733
a2 0.3766
Hence
vt 12.05 17.733t 0.3766t 2 , 10 t 20
At t 16 ,
v16 12.05 17.73316 0.376616
2
392.19 m/s
The absolute relative approximate error a obtained between the results from the first
and second order polynomial is
392.19 393.70
a 100
392.19
0.38410%
Question 3
The upward velocity of a rocket is given as a function of time in Table 3.
Table 3 Velocity as a function of time.
t (s) v(t ) (m/s)
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
a) Determine the value of the velocity at t 16 seconds using the direct method of
interpolation and a third order polynomial.
b) Find the absolute relative approximate error for the third order polynomial
approximation.
Solution
a) For third order polynomial interpolation (also called cubic interpolation), we choose the
velocity given by
vt a0 a1t a 2 t 2 a3t 3
x3 , y3
x1 , y1
f 3 x
x2 , y2
x0 , y0
x
Figure 5 Cubic interpolation.
Since we want to find the velocity at t 16 , and we are using a third order polynomial, we
need to choose the four data points closest to t 16 that also bracket t 16 to evaluate it.
The four points are t 0 10, t1 15, t 2 20 and t 3 22.5 .
Then
t 0 10, vt 0 227.04
t1 15, vt1 362.78
t 2 20, vt 2 517.35
t 3 22.5, vt 3 602.97
gives
v10 a 0 a1 10 a 2 10 a3 10 227.04
2 3
v15 a 0 a1 15 a 2 15 a3 15 362.78
2 3
v20 a 0 a1 20 a 2 20 a3 20 517.35
2 3
v22.5 a 0 a1 22.5 a 2 22.5 a3 22.5 602.97
2 3
Writing the four equations in matrix form, we have
1 10 100 1000 a 0 227.04
1 15
225 3375 a1 362.78
1 20 400 8000 a 2 517.35
1 22.5 506.25 11391 a3 602.97
Solving the above four equations gives
Numerical Analysis DCS-UOK Supervisor: Dr. Shaista Rais
a0 4.2540
a1 21.266
a 2 0.13204
a3 0.0054347
Hence
vt a0 a1t a 2 t 2 a3t 3
4.2540 21.266t 0.13204t 2 0.0054347t 3 , 10 t 22.5
v16 4.2540 21.26616 0.1320416 0.005434716
2 3
392.06 m/s
b) The absolute percentage relative approximate error a for the value obtained for v(16)
between second and third order polynomial is
392.06 392.19
a 100
392.06
0.033269%