You are on page 1of 3

Chapter 3

An Introduction to the
Approximation of Functions
In this Chapter, we will look at various ways of approximating functions from a given set of discrete
data points.
Interpolation is a method for constructing a function f (x) that ts a known set of data points
(xk , yk ), i.e. a method for constructing new data points within the range of a discrete set of known
data points. There are various ways in which this can be done.
Given a sequence of n + 1 distinct numbers xk (called knots) with corresponding numbers yk we are
looking for a function f (x) such that
f (xk ) = yk ,

k = 0, 1, ..., n

Each pair (xk , yk ) is called a data point and f is called an interpolant for the data points.

3.1

Linear Interpolation

Given 2 discrete data points, for instance, (x0 , y0 ) and (x1 , y1 ), then it is possible to nd a unique
straight line that ts these two points (Figure 3.1). The unique straight line can found by solving
the linear system
y0

= a1 x0 + a0 ,

y1

= a1 x1 + a0 .
39

Figure 3.1: Linear approximation (solid blue line) to the 2 data points (red), (x0 , f (x0 )) and
(x1 , f (x1 )), where f (x) is the function given by the purple dashed line.
This pair of simultaneous equations yields the result
a1 =

y1 y0
,
x1 x0

a0 = y0

and

(y1 y0 )
x0 .
(x1 x0 )

So the interpolant for any x [x0 , x1 ] is


(y1 y0 )
(y1 y0 )
x + y0
x0 ,
(x1 x0 )
(x1 x0 )
(y1 y0 )
(x x0 ) .
= y0 +
(x1 x0 )

p1 (x) =

p1 (x) is a rst-degree polynomial and if y0 = f (x0 ) and y1 = f (x1 ) the equation above can easily
be re-arranged to give
p1 (x) =
=

3.2

(x0 x1 )
f (x0 ) +
(x0 x1 )
(x x1 )
f (x0 ) +
(x0 x1 )

(x x0 )
(x x0 )
f (x0 )
f (x1 ) .
(x0 x1 )
(x0 x1 )
(x x0 )
f (x1 ) .
(x1 x0 )

(3.1)

Piecewise Linear Interpolation

Given a known set of n + 1 discrete data points (xk , f (xk )) k = 0, 1, . . . , n that partition an interval
[a, b] into n sub-intervals [xk , xk+1 ] where
a = x0 < x1 < < xn = b .
One of the easiest ways of approximating a given function f in C[a, b] is to form a function connecting
consecutive pairs of data points with straight line segments. This is known as piecewise linear
interpolation.
40

To nd the unique straight line through any pair of consecutive data points (xk , f (xk )) and (xk+1 , f (xk+1 ))
we generalise the formula in (3.1). So the interpolant for any x [xk , xk+1 ] is equal to
p1k (x)

(x xk+1 )
(x xk )
f (xk ) +
f (xk+1 ) .
(xk xk+1 )
(xk+1 xk )

(3.2)

By choosing n suciently large, i.e. ensuring the sub-intervals are suciently small, we can approximate f as closely as we wish. In general, this interpolating function will be continuous but not
dierentiable.
Example 3.1.1: Using the 4 data points given below and nd the piecewise linear approximation to
these points.
k

(xk , f (xk ))

(0.0, 0.0)

(/3, 0.8660)

(2/3, 0.8660)

(, 0.0)

By applying the formula (3.2) to each pair of adjacent data points we nd the following 3 straight
lines:

P (x) =

0.8270x

x [0.0, /3]

0.0000x + 0.8660

0.8270x + 2.5981

x [/3, 2/3]
x [2/3, ]

This produces the plot given in Figure 3.2

Figure 3.2: (Example 3.1.1) Piecewise linear approximation (solid blue lines) to the 4 data points
(red). The purple dotted line is the function that created the data points.

41

You might also like