20.4 Interpolation 567
Linear interpolation
The straight liney 1 = 1 p
1
(x) 1 = 1 a
0
1 + 1 a
1
xthrough the two
points (x
0
, y
0
) and (x
1
, y
1
), as in Figure 20.4, satisfies
the pair of linear equations
y
0
1 = 1 a
0
1 + 1 a
1
x
0
, y
1
1 = 1 a
0
1 + 1 a
1
x
1
with solution
Then
and this can be rearranged as
(20.17)
The linear interpolation formula is used to find an approximate value of a function at
a point xin the intervalx
0
tox
1
. The method is illustrated in the following example
for the (known) functione
x
.
EXAMPLE 20.7Linear interpolation
Two points on the graph ofy 1 = 1 e
x
are (to 4 decimal places in y)(x
0
, y
0
) 1 = 1 (0.80, 2.2255)
and(x
1
, y
1
) 1 = 1 (0.84, 2.3164). The linear interpolation formula (20.17) is then
Then, atx 1 = 1 0.832,
e
0.832
1 ≈ 1 2.2255 1 + 1 0.0727 1 = 1 2.2982
The true value is 2.2979 (to 4 decimal places).
0 Exercise 16
When linear interpolation is used between each pair of neighbouring points we have
piecewise linear interpolation, as illustrated in Figure 20.5 for the points listed in
Table 20.4 (compare with Figures 20.6 to 20.8).
ey x
x
≈=. + −.
.−.
.−.
2 2255 0 80
2 3164 2 2255
084 080
()
yy xx
yy
xx
=+−
−
−
00
10
10
()
y
yx yx
xx
yy
xx
=
−
−
−
−
01 10
10
10
10
xx
a
yx yx
xx
a
yy
xx
0
01 10
10
1
10
10
=
−
−
,=
−
−
...........
.......
......
..
.........
.......
.
..
..
..
...
..
...
...
..
...
.
..
...
..
...
...
..
...
.
...
....
...
...
...
....
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
....
...
...
...
...
...
....
...
...
....
...
...
....
...
....
....
...
....
....
....
....
....
....
....
.....
.....
.....
.....
......
.....
........
.......
.........
........
y
x
x
0
x
1
x
y
0
y
1
y
.
.....
.....
....
.....
.....
.....
....
.....
.....
....
.....
.....
....
......
....
.....
.....
....
.....
.....
....
.....
.....
.....
....
.....
.....
....
.....
.....
....
......
....
.....
.....
....
.....
.....
....
.....
.....
.....
....
.....
.....
....
.....
.....
....
.....
.....
.....
.....
....
.....
.....
Figure 20.4