166
Numerical methods in Electronics
7
INTERPOLATION)
Interpolation is one of the methods used in functions
approximation.
In the following paragraphs we take into consideration a
function defined through a table, so-called tabular function.
Knowing the value for the function in certain points (xi, f(xi)) in
which the function is defined, we pose the problem of trying to
find out the values of the function in some other, different
points, where the function is currently unknown. This problem
can appear in the case of the graphical representation of the
tabular function or in another case that necessitates knowing
the value of the function in a point for which the value isnt
known - that is, the ordinate value for some unknown
abscissa.
When one knows the analytical expression for some
function: y f (x) , the unknown functions values (the
ordinates) are calculated by replacing the proper argument in
that function. When we do not know the functions analytical
expression, we approximate the function with another one,
which we think it best approximates the first function in the
points where the unknown functions value is required.
Approximating a given function either by a linear variation or
by an nth degree polynomial can lead to ordinates that are
very close to the original ones.
7.1.
POLYNOMIAL
INTERPOLATION.
THE
LAGRANGEs INTERPOLATION POLYNOMIAL
Lets consider the tabular function defined in the Table 7.1:
Table 7.1.
x0
x1
xk
x n 1
y0
y1
yk
y n 1
Bibliography: [1],[6],[7],[15],[21],[22]
167
Numerical methods in Electronics
We know the values of the function in n points. Through n
points we can draw a uniquely defined polynomial of (n-1)th
degree.
Given the polynomial:
Pn 1 ( x ) a n 1 x n 1 a n 2 x n 2 ... a1 x a 0
(7.1)
According to Table 7.1 we have the system:
n 1
This
n2
a n 1 x 0 a n 2 x 0 a1 x 0 a 0 y 0
n 1
n2
a n 1 x1 a n 2 x1 a1 x1 a 0 y1
a n 1 x nn11 a n 2 x nn12 a1 x n 1 a 0 y n 1
(7.2)
system
has
equations
with
unknowns,
a 0 , a1 , a 2 ,..., a n 2 , a n 1 . , so it is a linear system of equations.
We consider the homogenous system:
n 1
n2
a n 1 x 0 a n 2 x 0 a1 x 0 a 0 0
n 1
n2
a n 1 x1 a n 2 x1 a1 x1 a 0 0
a n 1 x nn11 a n 2 x nn12 a1 x n 1 a 0 0
(7.3)
The homogenous systems determinant is different than 0.
If the determinant would be null, the (n-1)th degree polynomial
would have n solutions: x 0 , x1 , x 2 ,..., x n 1 which is impossible.
This homogenous system only accepts the trivial solution.
Therefore the determinant of the system is not null. This
determinant is also the determinant of the system (7.2). This
system is a CRAMER system having unique solutions.
Consequently the (n-1)th degree polynomial is unique. For the
sake of computations simplification we will write the
polynomial using the following form:
Pn 1 ( x) x n 1 a n 2 x n 2 ... a1 x a 0
(7.4)
It is obtained from the polynomial (7.1) through division by
a n 1 while leaving the after division coefficients notation
unchanged.
Let us consider the following polynomials, that verify (7.2)
or (7.3):
Interpolation
168
0 ( x ) ( x x1 )( x x 2 )...( x x n 1 )
1 ( x) ( x x 0 )( x x 2 )...( x x n 1 )
n 1 ( x ) ( x x 0 )( x x1 )...( x x n 2 )
We will write the polynomial Pn 1 ( x ) under the form:
Pn 1 ( x) b0 0 ( x) b1 1 ( x) ... b k k ... b n 1 n 1 ( x)
(7.5)
(7.6)
We must find out the coefficients b0 , b1 ,..., bn 1 .
P ( x0 )
P (x )
P ( xk )
Pn 1 ( x n 1 )
b0 n 1
, b1 n 1 1 ,..., bk n 1
,..., bn 1
0 ( x0 )
2 ( x1 )
k ( xk )
n 1 ( x n 1 )
(7.7)
Following as such, by replacing (7.7) into (7.6) we can
write:
n1
n1
Pn1(x) Pn1(xi )
i 0
i (x) n1
yi
i (xi ) i 0
x x
j
j 0, j i
n1
x x
j 0, j i
n1
x xj
j 0, j i
xi xj
n1
yi
i 0
th
The (n-1) degree polynomial that passes through n given
points, also called the Lagrange interpolation polynomial, has
the formula:
n1 x x
n1
j
Pn1 x yi
x
i 0
j 0, j i
i
j
(7.8)
The expression of the Lagrange polynomial depends upon
the known data point coordinates and the variable x . With the
aid of polynomial formula (7.8), which approximates a
function, we can compute the functions value in any unknown
point placed in-between x 0 and x n 1 , so we can say that we
compute the ordinates pair for an unknown abscissa.
7.1.1.
TRUNCATION
ERROR
INTERPOLATION
IN
LAGRANGES
The truncation error is given by the difference between the
function we want to interpolate f (x) and the interpolation
polynomial in the LAGRANGE form:
n 1
eT f x y i
i 0
n 1
x xj
j 0, j i
xi x j
F x
(7.9)
169
Numerical methods in Electronics
We build the function:
G ( x ) ( x x1 )( x x 2 )...( x x n )
both F (x ) from (7.9) and G ( x )
(7.10)
from (7.10) we
H (t ) F ( x )G (t ) F (t )G ( x )
(7.11)
With
conclude the following function:
that has the following properties:
1) Since any H ( x j ) 0 for j = 1,...,n-1, while replacing
x x j in formula (7.9) the resulting F ( x j ) 0 ; j = 1, 2,...,
(n-1) and G ( x j ) 0 ; j=1, 2, . . . ,(n-1);
2) H ( x) 0
On the basis of the mean value theorem it results that
there are n points 0 , 1 , 2 ,..., n 1 for which the derivative
H'(t) = 0,
H ' ( 0 ), H ' (1 ), H ' ( 2 ),..., H '( n ), H ' ( n1 ) , i [ x0 , x n ] i = 0,,n-1
Continuing to apply the mean value theorem, we end up to
the equality:
H ( n ) ( ) 0 , where x1 x n
From (7.11) we have:
H n t F x G n t F n t G x n! F x f
H
0 n! F x
G x
t G x
(7.12)
or, equivalently:
f n
G x , with: x1 x n
n!
This formula represents the truncation error
Lagranges interpolation method.
eT F x
7.1.2 ROUNDING
ERROR
INTERPOLATION
IN
(7.13)
for the
LAGRANGES
We consider the LAGRANGE polynomial given by equation
(7.8) which we will write under the form:
n 1
P ( x ) yi zi , where z i
i 0
n 1
j 0 ,j i
x xj
xi x j
and p i y k z k , P ( x ) p n
k 0
(7.14)
We build the procedural graph (see Chapter 1 - Errors) for
computing the rounding error for expression (7.14) which
Interpolation
170
represents the ith order product from the Lagrange polynomial
expression. In the product expression there are operations of
subtraction, division and multiplication. For each node in the
graph where there is an arithmetic operation involved we give
the symmetric type rounding error. For the total rounding error
calculation of the Lagrange polynomial expression we create a
procedure graph and for the sum expression in (7.14).
x
1
-
xj
-1
-1
xi
z j 1
zj
Fig.7.1. - The procedural graph for expression z.
Lets consider all the values xi , i=1,2,... ,n, without errors
and we note with ki , k 0...n 1; i 0,1,...n 1 , the errors in
the members of the product. In these conditions, for z 0 we
obtain the rounding error: 0 =0, because z 0 is initialized with
1 and therefore is assumed as an exact representation, that is
its error is null.
0 0
i
i
i
i
0i 11
21
31
41
i
i
i
i
1i 12
22
32
42
0i
(7.15)
ni 1 1i, n 1 2i , n 1 3i , n 1 4i , n 1 ni 2
In the expression (7.15) the term ii is missing. From (7.15)
results:
n1
ni 1 1 j 2 j 3 j 4 j
j 0
i j
(7.16)
171
Numerical methods in Electronics
t
If we consider kj 10 where t is the computing
machine and note with i the product z i s error, we have
i 4 n 1
(7.17)
or, for z i , i=0,1,2,n-1, we have
i=0,1,2,...,n-1
(7.18)
i 4 n 1
We build the procedure graph for pi .
i
zi
z i yi
pi
.
1
pi 1
pi
yi
ei
pi
pi-1
n 1
Fig.7.2. - The procedural graph for the expression
pi y k z k
k 0
We consider the initial error in point pi to be null, the
rounding
errors
in
nodes
5,
6
being
noted
as
5i , 6i , i 0,1,.., n 1 and the errors in the sums terms
i , i 0,1,...n 1 .
z y
0 0 e0 50 0 0 60
p0
zy
p
1 1 e1 31 1 1 1 1 61
p1
p2
-----------------------------------------------------------(7.19)
z y
p
n 1 n 1 en 1 5, n 1 n n 1 n 1 n 2 6, n 1
pn 1
pn 1
We know that i 4 n 1 for i=0, 1,..,n-1 and consider that
ei e for i=0.1.,n-1.
In these conditions we will obtain:
kj
n 1
n 1
n 1
n 1
i 0
i 0
i 0
i 0
n 1 | pn 1 | 4n 3 e zi yi pi 4n 3 e pi pi
Interpolation
172
n 1
We can perform the following increase
|
i 0
pi | np n 1
and result in:
n 1 2n 2n 1 en
(7.20)
The expression that represents the rounding error is
actually the rounding error for the Lagranges interpolation.
7.1.3.
SINGULARITIES FOR LAGRANGEs POLYNOMIAL
If we consider two points, the interpolation becomes linear:
x x2
x x1
y y1
y2
(7.21)
x1 x2
x2 x1
The truncation error for linear interpolation becomes:
f
eT
x x1 x x2 x1 x2
(7.22)
2!
and the rounding error:
2 12 2e
(7.23)
where and e are stated in paragraph 7.1.2.
For three points, the interpolation becomes a 2nd degree
polynomial interpolation, that is, a quadratic interpolation
polynomial - in fact a parabola).
7.1.
NEWTONS FIRST KIND INTERPOLATION
POLYNOMIAL
This interpolation polynomial is expressed as a function of
finite differences. Let us assume some function f : a, b R and
the net x1 , x2 , x3 ,..., xn with a constant step k.
Definition 7.1. We denote by first order finite
difference the expression:
f x f x h f x
(7.24)
th
where h is the constant step among abscissas. The n order
finite difference is then computed using:
173
Numerical methods in Electronics
n f x n1 f x
(7.25)
The finite differences have the following properties:
1. The finite difference operator is linear:
c1 f1 c2 f 2 c1f1 c2 f 2
(7.26)
th
2. The n order finite difference is computed with the
formula:
n
n f x 1 Cnk f x n k h
k
(7.27)
k 0
3. The finite differences can also be obtained using Table 7.2
below.
Definition 7.2. We define the generalized nth order power
of x the expression:
x n x x h x 2h ... x n 1 h
(7.28)
For h=0 the generalized power is the same as the ordinary
power.
1. The finite difference over the generalized power is
computed as:
(7.29)
x n nhx n 1
2. The kth order finite difference of generalized power is:
k x n n n 1 n 2 ... n k 1 x n k
(7.30)
xi
yi
yi
x0
y0
y0
x1
y1
x2
Table 7.2
yi
yi
y1
2 y0
3 y0
y2
y 2
x3
y3
y3
2 y1
2 y2
x4
y4
y 4
2 y3
x5
y5
y5
2 y 4
x6
y6
yi
yi
3 y1
3 y 2
4 y0
5 y0
4 y1
5 y1
3 y3
4 y 2
6 yi
6 y0
Let us consider the tabular function from table (7.1), where
the net x0 , x1 , x2 , x3 ,..., xn has a constant step h.
An nth order polynomial passes through n+1 points and we
can look for it using the form:
Pn ( x ) C0 C1 ( x x0 )[1] C2 ( x x0 )[ 2 ] ... Cn ( x x0 )[ n ]
(7.31)
Interpolation
174
( x x0 )[ i ] ( x x0 )( x x1 )...( x xi 1 )
where
, i
=1, 2, ,n
and the coefficients C 0 , C1 ,..., C n represent unknowns that we
will compute. We can observe that
Pn ( x0 ) y 0 C0
(7.32)
st
We calculate the 1 order finite difference:
Pn ( x ) C1h 2C 2 h( x x0 )[1] ... nC n h( x x0 )[ n 1]
After
performing
Pn ( x0 ) C11!h .
the
substitution
We can also compute:
C1
x x0
we
(7.33)
get
Pn x0
1!h
(7.34)
By continuing the finite difference calculus in point x0 we
observe that:
Ck
k Pn x0
, k Pn x0 k y0 , with k=0, 1, 2, ... n.
k
k! h
(7.35)
Taking into account the coefficient computation formulas,
the 1st kind Newton interpolation polynomial can be written as:
2
y
n y0
1 y0
2
x x0 n (7.36)
Pn x0 y0 0 x x0
x
0
2
n
1!h
2!h
n!h
Because in the computation required for the coefficients we
have used forward finite differences (see Table 7.2), the
polynomial is therefore named as NEWTONs interpolation
polynomial of the first kind.
If the approximation point is placed near x 0 (or in the
neighborhood of x 0 ), we recommend the utilization of this
method because it leads to smaller errors.
7.2.
NEWTONs SECOND KIND INTERPOLATION
POLYNOMIAL
175
Numerical methods in Electronics
For the function given in Table 7.1 we look for an nth degree
polynomial that passes through all n+1 points. The
interpolation polynomial is of the following form:
Pn ( x) C 0 C1 ( x xn ) C 2 ( x xn )( x xn 1 ) ... C n ( x xn )( x xn 1 )...( x x1 )
(7.37)
The above polynomial can also be written as a function of
generalized power as:
Pn ( x) C 0 C1 ( x xn )[1] C 2 ( x xn 1 )[ 2 ] C3 ( x xn 2 )[ 3] ... C n ( x x1 )[ n ]
It can be observed that:
(7.38)
Pn ( xn ) y n C0
(7.39)
We compute the 1st order finite difference over the
polynomial in (7.38):
Pn ( x) C11!h 2C 2 h( x xn 1 )[1] 3C3 h( x xn 2 )[ 2 ] ... nC n h( x x1 )[ n 1]
For
x xn 1 ,
y n 1 C11!h
(7.40)
and
from (7.40) we have
y n 1
therefore: C1
.
1!h
By continuing the finite difference calculus in the points
xn 2 , xn 3 ,..., xn k , for the rank k we obtain the general formula
used to compute the C k coefficient:
Ck
k yn k
k! h k
(7.41)
By substituting k 0,1,2,.., n in (7.41) we obtain all the
polynomials coefficients. Taking into account formula (7.41)
then the nth degree polynomial (7.38) can be written as:
2
y n
n y1
1 y n 1
2
Pn x yn
x xn 2 x xn1 n x x1 n
1!h
2!h
n!h
(7.42)
This polynomial is called NEWTONs interpolation polynomial
of second kind, because the backward finite differences were
used (see Table 7.2).
If the approximation point is placed near xn (or in the
neighborhood of xn ), we recommend the utilization of this
method because it leads to smaller errors.
Interpolation
7.3.
176
NEWTONS INTERPOLATION POLYNOMIAL
USING DIVIDED DIFFERENCES
(aka Newtons third kind interpolation polynomial)
Let us consider the function f (x ) given under the form
described in Table 7.1 where the network x0 , x1 , x2 ,..., xn from
the definition domain of the function hasnt got a constant
step.
Definition 7.3. We call divided difference of (k+i) th order
of some function f(x) the expression:
f xi , xi 1 ,..., xi k f xi 1 , xi ,..., xi k 1
f xi 1 , xi , xi 1 ,..., xi k
xi k xi 1
(7.43)
th
We consider the n degree polynomial, under the following
format:
Pn ( x) C0 C1 ( x x0 ) C 2 ( x x0 )( x x1 ) ... C n ( x x0 )( x x1 )...( x xn 1 )
(7.44)
knowing
n+1 points ( xi , yi ) , i=0, ...,n , that verify the
polynomial.
Pn ( x0 ) y 0 C0
It can be observed that:
(since
our
polynomial must pass through the pairs of point that we have
in the input table).
We compute the divided difference of first order for the
polynomial Pn (x ) and substitute x x1 in (7.44). We get:
Pn ( x0 , x1 ) C1 .
Continuing to compute, we determine the kth order divided
difference and taking x x k we obtain the value for coefficient
Ck :
C k Pn ( x0 , x1 , x 2 ,..., x k ) , k=0, 1,, n
(7.45)
Taking into account formula (7.45), the polynomial in (7.44)
can be written as:
Pn ( x ) y 0 Pn ( x0 , x1 )( x x0 ) Pn ( x0 , x1 , x 2 )( x x0 )( x
Pn ( x0 ,..., x n )( x x0 )( x x1 )...( x x n 1 )
(7.46)
where each divided difference is computed using (7.43). The
resulting polynomial (7.46) is also called NEWTONs
interpolation polynomial using divided difference.
177
Numerical methods in Electronics
7.4.
AITKENS INTERPOLATION METHOD
AITKENs interpolation method gives the same result as
LAGRANGEs method, except that using this method the result is
not a polynomial, but we realize multiple linear interpolations.
With each interpolation, the number of remaining points is
shrunk by 1, and the function that passes through two points
increases with a degree of 1, so in the final iteration, if n+1
points are given, we obtain a nth degree function.
Let us consider the tabular function in Table 7.3.
Table 7.3
x0
y0
x1
x2
y1
y2
y02
y012
x3
y3
y 03
y 013
y0123
x4
y4
y04
y 014
y0124
-----
----
----
----
----
xn
yn
y0 n
y 01n
y012 n
y 01
----------
y 0123...n
Then, writing the straight-lines analytical equations, given
the first pair (x0, y0) combined successively with all the other
pairs (xi, yi) with i != 0 we get, for the first step, all the
equations y0j of the following straight-lines:
y0 j
xj x
x j x0
y0
x x0
yj
x j x0
j=1, 2, 3, ..., n
Similarly, at the second step of linear interpolation, the first
pair is (x1, y01) and the other pairs are (xj, y0j), with j=1, , n.
The new straight-lines are now denoted by y01j:
y01 j
xj x
x j x1
y01
x x1
y0 j
x j x1
j=2, 3, ..., n (7.47)
We continue likewise, by using the analytical equation for a
straight line. In fact, what we are going to do is not indeed a
straight line. We only use that equation, but at every step we
use the equations computed before.
Finally, the only two pairs remain: (xn-1, y012n-2) and (xn,
y012n-1).
Interpolation
178
Conclusively, the AITKENs final interpolation polynomial, for
some abscissa x , is given by the following formula:
x x
x xn1
y012...n n
y 012... n 2 n1
y012... n2 n
(7.48)
xn xn1
xn xn1
7.7.
APPLICATIONS
1. Let us consider the experimental data obtained for a
temperature coefficient characteristic [mV/ 0C ],
function of voltage, for a Zener diode, in the following
table:
Table 7.6
U [mV]
10
20
55
60
70
11
5
I [mA]
0.
5
1.
0
1.
5
2.
0
2.
3
2.0
15
0
28
0
30
0
43
5
1.5
0.5
0.3
1.0
It must be determined points between the given values for
a most-precise graphical representation.
The value of function for U=90mV has been determined,
resulting in the following values:
for LAGRANGEs method
=81.82715;
st
for NEWTONs 1 kind method =81.82715;
for NEWTONs 2nd kind method =81.82715;
for AITKENs method
=85.80118;