# 3

I NTERPOLATION
AND

C URVE F ITTING

Introduction Newton Interpolation: Finite Divided Difference Lagrange Interpolation Spline Interpolation Polynomial Regression Multivariable Interpolation

Chapter 3

Interpolation & Curve Fitting / 2

3.1 Introduction
• • Interpolation is a technique to estimate the value between a set of data. A general approach is to map the data into an n-th order polynomial:

f n ( x) = a0 + a1 x + L + an x n = ∑ ai x i
i =0

n

(3.1)

• •

This chapter covers three types of techniques, i.e. the Newton interpolation, the Lagrange interpolation and the Spline interpolation. The resulting equation can be used for curve fitting.

Chapter 3

Interpolation & Curve Fitting / 3

3.2 Newton Interpolation: Finite Divided Difference
• For the linear interpolation, consider Fig. 3.1 and the following relation: f1 ( x ) − f ( x0 ) f ( x1 ) − f ( x0 ) = x − x0 x1 − x0
f ( x) f(x1) f ( x) f(x0)

x0
FIGURE 3.1

x

x1

x

Linear interpolation

Rearranging the above relation leads to f1 ( x ) = f ( x0 ) + f ( x1 ) − f ( x0 ) ⋅ (x − x0 ) x1 − x0 (3.2)

The term [ f ( x1 ) − f ( x0 )] ( x1 − x0 ) is referred to as the first-order finite divided difference.
Example 3.1

Calculate an approximate value of ln 2 using the linear interpolation using the following ranges: (1,4) and (1,6). Use ln 1 = 0, ln 4 = 1.3862944 and ln 6 = 1.7917595 as the source data. Estimate the relative error if the actual value is ln 2 = 0.69314718.
Solution

For the linear interpolation between x0 = 1 and x1 = 6:
f1 (2) = 0 + 1.7917595 − 0 ⋅ (2 − 1) = 0.35835190 6 −1

This produces a relative error of εt = 48.3%.

Chapter 3

Interpolation & Curve Fitting / 4

For the linear interpolation between x0 = 1 dan x1 = 4:
f1 (2) = 0 + 1.3862944 − 0 ⋅ (2 − 1) = 0.46209812 4 −1

This produces a relative error of εt = 33.3%, which smaller than the previous case.

For the quadratic interpolation, consider Fig. 3.2 and the following relation:
y
2

f(x) = ln x

1

f1(x)

0 0 2 4 6

x

FIGURE 3.2

The result for the linear interpolation for ln 2

f 2 (x ) = b0 + b1 (x − x0 ) + b2 ( x − x0 )( x − x1 )

(3.3)

By taking the values of x equal to x0, x1 dan x2 in Eq. (3.3), the coefficients bi can be calculated as followed:
b0 = f ( x0 ) b1 = f ( x1 ) − f ( x0 ) x1 − x0

(3.4a) (3.4b)

f (x2 ) − f ( x1 ) f ( x1 ) − f ( x0 ) − x2 − x1 x1 − x0 b2 = x 2 − x0

(3.4c)

Chapter 3

Interpolation & Curve Fitting / 5

Example 3.2

Repeat Example 3.1 using the quadratic interpolation.
Solution

From Example 3.1, the data can be rewritten as followed:
x0 = 1 : x1 = 4 : x2 = 6 : Using Eq. (3.4):
b0 = 0 1.3862944 − 0 = 0.46209812 4 −1 1.7917595 − 1.3862944 1.3862944 − 0 − 6 − 4 4 −1 = −0.051873113 b2 = 6 −1 b1 =

f ( x0 ) = 0 f ( x1 ) = 1.3862944 f ( x2 ) = 1.7917595

Hence, Eq. (3.3) yields
f 2 ( x ) = 0 + 0.46209812 ( x − 1) − 0.051873113 ( x − 1)( x − 4 )

For x = 2: f 2 (2) = 0 + 0.46209812(2 − 1) − 0.051873113(2 − 1)(2 − 4 ) , = 0.56584436 . This produces the relative error εt = 18.4% as shown below.

Chapter 3

Interpolation & Curve Fitting / 6

y
2

f(x) = ln x
1

f2(x) f1(x)
0 0 2 4 6

x

FIGURE 3.3

The result for the quadratic interpolation for ln 2

The general form representing an n-th order interpolation function (requires n+1 pairs of data) is: f n ( x ) = b0 + b1 (x − x0 ) + L + bn (x − x0 )(x − x1 )L (x − xn −1 ) where the coefficients bi can be obtained via (3.5)

b0 = f ( x0 )

b2 = f [x2 , x1 , x0 ] M bn = f [xn , xn −1 , K , x1 , x0 ] where the terms […] are finite divided differences and are defined as:

b1 = f [x1 , x0 ]

f xi , x j =
f xi , x j , x k = f [xn , xn −1 ,K, x1 , x0 ] =

[

]

f ( xi ) − f (x j ) xi − x j

(3.6a)

[

]

f xi , x j − f x j , x k xi − x k

[

] [

]

(3.6b)

f [xn , xn −1 ,K, x2 , x1 ] − f [xn −1 , xn − 2 ,K, x1 , x0 ] (3.6c) x n − x0

Hence, Eq. (3.5) forms the Newton interpolation polynomial: f n (x ) = f (x0 ) + (x − x0 ) f [x1 , x0 ] + (x − x0 )(x − x1 ) f [x2 , x1 , x0 ] + L + ( x − x0 )( x − x1 )L( x − xn−1 ) f [xn , xn−1 ,K, x0 ] (3.7)

Chapter 3

Interpolation & Curve Fitting / 7

TABLE 3.1
i 0 1 2 3 xi x0 x1 x2 x3

Newton finite divided difference interpolation polynomial
f(xi ) f (x0) f (x1) f (x2) f (x3) I f [x1,x0] f [x2,x1] f [x3,x2] II f [x2,x1,x0] f [x3,x2,x1] III f [x3,x2,x1,x0]

The relation for error for the n-th order interpolation function can be estimated using: Rn ≈ f [xn+1 , xn , xn−1 ,K, x0 ]( x − x0 )( x − x1 )L( x − xn ) (3.8)

Example 3.3

Repeat Example 3.1 with an additional fourth point of x3 = 5, f(x3) = 1.6094379 using the third order Newton interpolation polynomial.
Solution

The third order Newton interpolation polynomial can be written as f 3 ( x ) = b0 + b1 ( x − x0 ) + b2 ( x − x0 )( x − x1 ) + b3 ( x − x0 )( x − x1 )( x − x2 )
i 0 1 2 3 xi 1 4 5 6 f(xi ) 0 1.3862944 1.6094379 1.7917595 I 0.46209813 0.22314355 0.18232156 II −0.0597386 −0.0204110 III 0.00786553

Thus, f 3 ( x ) = 0 + 0.46209812( x − 1) − 0.0597386( x − 1)( x − 4 ) + 0.00786553( x − 1)( x − 4 )( x − 5) ,
f 3 (2 ) = 0 + 0.46209812(2 − 1) − 0.0597386(2 − 1)(2 − 4 ) + 0.00786553(2 − 1)(2 − 4 )(2 − 5) , = 0.6287691.

and producing a relative error of εt = 9.29%.

Chapter 3

Interpolation & Curve Fitting / 8

y
2

f(x) = ln x
1

f3(x)
0 0 2 4 6

x

TABLE 3.4

The result for the cubic interpolation for ln 2

Chapter 3

Interpolation & Curve Fitting / 9

3.3 Lagrange Interpolation
• The formula for the Lagrange interpolation is:
f n ( x ) = ∑ Li ( x ) f ( x i )
i =0 n

(3.9)

where the parameter Li(x) is defined as
Li ( x ) = ∏
j =0 j ≠i n

x − xj xi − x j

(3.10)

For n = 1, the first order Lagrange interpolation function can be written as:
f1 ( x ) = x − x0 x − x1 f ( x0 ) + f ( x1 ) x0 − x1 x1 − x0

For n = 2, the second order Lagrange interpolation can be written as:
f 2 (x ) =

(x − x1 )(x − x2 ) f (x ) + (x − x0 )(x − x2 ) f (x ) (x0 − x1 )(x0 − x2 ) 0 (x1 − x0 )(x1 − x2 ) 1 (x − x0 )(x − x1 ) f (x ) + (x2 − x0 )(x2 − x1 ) 2

The error term for the Lagrange interpolation can be estimated using: Rn = f [xn+1 , xn , xn−1 ,K, x0 ] ∏ ( x − xi )
i =0 n

(3.11)

Example 3.5

Repeat Examples 3.1 and 3.2 using the first and second order Lagrange interpolation functions, respectively.
Solution

From Examples 3.1: x0 = 1 : x1 = 4 : x2 = 6 : f ( x0 ) = 0 f ( x1 ) = 1.3862944 f ( x2 ) = 1.7917595

Chapter 3

Interpolation & Curve Fitting / 10

For the first order Lagrange interpolation:

f1 ( x ) = ∴ f1 (2) =

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

2−4 (0) + 2 − 1 (1.3862944) 4 −1 1− 4 = 0.4620981

For the second order Lagrange interpolation:

f 2 (x ) =

(x − x1 )(x − x2 ) f (x ) + (x − x0 )(x − x2 ) f (x ) (x0 − x1 )(x0 − x2 ) 0 (x1 − x0 )(x1 − x2 ) 1 (x − x0 )(x − x1 ) f (x ) + (x2 − x0 )(x2 − x1 ) 2 (2 − 4)(2 − 6) (0) + (2 − 1)(2 − 6) (1.3862944) f 2 ( 2) = (1 − 4)(1 − 6) (4 − 1)(4 − 6) (2 − 1)(2 − 4) (1.7917595) + (6 − 1)(6 − 4)
= 0.5658444

Chapter 3

Interpolation & Curve Fitting / 11

3.4 Spline Interpolation
• The polynomial interpolation can cause oscillation to the function and this can be remedied by using the spline interpolation.
f(x) f(x)

x

x

(a) polynomial (b) Linear spline FIGURE 3.5 Comparison between polynomial and spline interpolation

The formula for the linear spline interpolation for n+1 data between points x0 and xn (n intervals) is f11 ( x ) = f ( x0 ) + m0 ( x − x0 ) untuk x0 ≤ x ≤ x1 f12 ( x ) = f ( x1 ) + m1 ( x − x1 ) untuk x1 ≤ x ≤ x2 M M f1n ( x ) = f ( xn−1 ) + mn−1 ( x − xn−1 ) untuk xn−1 ≤ x ≤ xn dengan mi is the gradient for the (i+1)-th interval: mi = f ( xi +1 ) − f (xi ) xi +1 − xi (3.13)

(3.12)

Example 3.6

Use the following data to estimate the function f(x) at x = 5 using the linear spline interpolation.
x 3.0 4.5 7.0 9.0 f ( x) 2.5 1.0 2.5 0.5

Chapter 3

Interpolation & Curve Fitting / 12

Solution

The value of x = 5 is in the range 4.5 ≤ x ≤ 7 , where the gradient is
m1 = 2.5 − 1.0 = 0.60 7.0 − 4.5

From Eq. (3.12): f12 (x ) = f ( x1 ) + m1 ( x − x1 ) , f12 (5) = 1.0 + 0.60(5 − 4.5) = 1.3 .

f(x)

2

0 2 4 6 8

x

FIGURE 3.6

Linear spline interpolation for Example 3.6

For the quadratic spline, the general polynomial for each interval is

f 2 i ( x ) = ai x 2 + bi x + ci
The coefficient ai, bi and ci for each interval can be evaluated using: 1. Continuity at vertices (2n−2 equations):

(3.14)

ai −1 xi2−1 + bi −1 xi −1 + ci −1 = f ( xi −1 ) ai xi2−1 + bi xi −1 + ci = f ( xi −1 )
2. Conditions at end points (2 equations):
2 a1 x0 + b1 x0 + c1 = f ( x0 ) 2 an xn + bn xn + cn = f ( xn )

(3.15) (3.16)

(3.17) (3.18)

Chapter 3

Interpolation & Curve Fitting / 13

3.

Differentiability at vertices (n−1 equations):
f ′( x ) = 2ax + b

2ai −1 xi −1 + bi −1 = 2ai xi −1 + bi 4. Assumption at the first interval (1 persamaan):

(3.19)

a1 = 0
f (x)

(3.20)

2

0

2

4

6

8

x

FIGURE 3.7

The quadratic spline interpolasi for example 3.7

For the cubic spline, the general polynomial for each interval is

f 3i ( x ) = ai x 3 + bi x 2 + ci x + d i
• The formulation for the cubic spline can be derived as followed: For interval (xi−1, xi), the second derivative can be written as:

(3.21)

(x ) = f i′′(xi−1 ) f i′′

x − xi (xi ) x − xi−1 + f i′′ xi −1 − xi xi − xi −1

(3.22)

The integration of Eq. (3.22) twice produces two integration constants, which can be evaluated using f ( x ) = f ( xi −1 ) at xi−1 and f ( x ) = f ( xi ) at xi, thus produces

f 3i (x ) =

′′ f ′′( xi −1 ) (xi − x )3 + f (xi ) (x − xi−1 )3 6( xi − xi −1 ) 6( xi − xi −1 ) ⎡ f (xi −1 ) f ′′( xi −1 )( xi − xi −1 ) ⎤ +⎢ − ⎥ ( xi − x ) ( ) x x 6 − i −1 ⎣ i ⎦ ⎡ f ( xi ) f ′′( xi )( xi − xi −1 ) ⎤ +⎢ − ⎥ ( x − xi −1 ) 6 ⎣ ( xi − xi −1 ) ⎦
(3.23)

Chapter 3

Interpolation & Curve Fitting / 14

The differentiability can be maintained troughout the function via ′ f i′ −1 ( xi ) = f i ( xi ) (3.24)

Eq. (3.23) can be differentiated for both the (i−1)-th and i-th intervals and following Eq. (3.24):

(xi − xi−1 ) f ′′(xi−1 ) + 2(xi+1 − xi−1 ) f ′′(xi ) + (xi+1 − xi ) f ′′(xi+1 )
= 6 [ f (xi+1 ) − f (xi )] + 6 [ f (xi−1 ) − f (xi )] (xi − xi−1 ) (xi+1 − xi ) (3.25)

Example 3.8

Repeat Example 3.6 using the cubic spline interpolation.
Solution

Using Eq. (3.25) for the first interval (i = 1):

(4.5 − 3) f ′′(3) + 2(7 − 3) f ′′(4.5) + (7 − 4.5) f ′′(7 )
= 6 (2.5 − 1) + 6 (2.5 − 1) (7 − 4.5) (4.5 − 3) It is known that f ′′(3) = 0 . Hence

8 f ′′(4.5) + 2.5 f ′′(7 ) = 9.6
For the second interval (i = 2):
2.5 f ′′(4.5) + 9 f ′′(7 ) = −9.6

Both equations is solved simultaneously to yield f ′′(4.5) = 1.67909 f ′′(7 ) = 1.53308 Using Eq. (3.23) for the first interval: f 31 ( x ) = 1.67909 (x − 3)3 + 2.5 (4.5 − x ) 6(4.5 − 3) 4. 5 − 3

= 0.186566( x − 3) + 1.666667(4.5 − x ) + 0.246894( x − 3).
3

1.67909(4.5 − 3) ⎤ ⎡ 1 ( x − 3) , +⎢ − ⎥ 6 ⎣ 4. 5 − 3 ⎦

Chapter 3

Interpolation & Curve Fitting / 15

For the second and third intervals:

f 3 2 ( x ) = 0.111939(7 − x ) − 0.102205( x − 4.5) − 0.299621(7 − x )
3 3

+ 1.638783( x − 4.5)
3

f 33 ( x ) = −0.127757(9 − x ) + 1.761027(9 − x ) + 0.25( x − 7 )
At x = 5, use the function for the second interval:
f 3 2 (5) = 0.111939(7 − 5) − 0.102205(5 − 4.5) − 0.299621(7 − 5)
3 3

+ 1.638783(5 − 4.5) ,

= 1.102886 .

f(x)
Cubic Newton/ Lagrange Interpolation

2
Cubic Spline

0

2

4

6

8

x

FIGURE 3.8

The cubic spline interpolation for Example 3.8

Chapter 3

Interpolation & Curve Fitting / 16

3.5 Polynomial Regression
• A “best fit” polynomial of an order lower than the number of intervals is sometimes required to represent the data and can be evaluated via polynomial regression. Consider the following form of polynomial:

f ( x ) = a0 + a1 x + a2 x 2 + L + an x n
where the error for the i-th data (xi,yi) is

(3.26)

ei = yi − f ( xi ) = yi − a0 − a1 xi − a2 xi2 − L − an xin
The sum of the squares of error for N data is S = ∑ e = ∑ yi − a0 − a1 xi − a2 xi2 − L − an xin
i =1
2 i

N

N

(

)

2

i =1

(3.27)

These errors can be minimised as followed:
N ∂S = 0 = ∑ 2 yi − a0 − a1 xi − a2 xi2 − L − an xin (− 1) ∂a0 i =1

( ( (

) )

N ∂S = 0 = ∑ 2 yi − a0 − a1 xi − a2 xi2 − L − an xin (− xi ) ∂a1 i =1

M
N ∂S = 0 = ∑ 2 yi − a0 − a1 xi − a2 xi2 − L − an xin − xin ∂an i =1

)(

)

producing the following system of equations:
a0 N + a1 ∑ xi + a 2 ∑ xi2 + L + a n ∑ xin = ∑ yi a0 ∑ xi + a1 ∑ xi2 + a 2 ∑ xi3 + L + a n ∑ xin+1 = ∑ xi yi a0 ∑ xi2 + a1 ∑ xi3 + a 2 ∑ xi4 + L + a n ∑ xin + 2 = ∑ xi2 yi

(3.28)

M
a0 ∑ xin + a1 ∑ xin+1 + a 2 ∑ xin + 2 + L + a n ∑ xi2 n = ∑ xin yi

Chapter 3

Interpolation & Curve Fitting / 17

or, in a form of matrix equation:

⎡ N ⎢ ⎢ ∑ xi ⎢∑ xi2 ⎢ ⎢ M ⎢∑ x n ⎣ i

∑ xi ∑ xi2 ∑ xi3 M ∑ xin+1

∑ xi2 ∑ xi3 ∑ xi4 M ∑ xin+ 2

L ∑ xin ⎤ ⎧a0 ⎫ ⎧ ∑ yi ⎫ ⎥ ⎪ ⎪ ⎪ ⎪ L ∑ xin+1 ⎥ ⎪ a1 ⎪ ⎪ ∑ xi yi ⎪ ⎪ ⎪ ⎪ 2 ⎪ L ∑ xin+ 2 ⎥ ⋅ ⎨a2 ⎬ = ⎨∑ xi yi ⎬ ⎥ O M ⎥ ⎪M⎪ ⎪ M ⎪ ⎪ ⎪ ⎪ n ⎪ L ∑ xi2 n ⎥ ⎭ ⎩ ∑ xi y i ⎪ ⎭ ⎪ ⎩a n ⎪ ⎦ ⎪

(3.29)

The standard deviation σ for this case can be evaluated as followed:

σ=

S = N − n +1

∑e
i =1

N

2 i

N − n +1

(3.30)

The case for n = 1 is referred to as the linear regression: y = a0 + a1 x
⎡ N ⎢∑ x ⎣ i ∑ x i ⎤ ⎧a 0 ⎫ ⎧ ∑ y i ⎫ ⋅⎨ ⎬ = ⎨ ⎬ ∑ xi2 ⎥ ⎦ ⎩ a1 ⎭ ⎩∑ xi yi ⎭

(3.31)

Example 3.9

Determine a best-fit quadratic equation which can represent the following experimental data:
xi yi 0.05 0.956 0.11 0.890 0.15 0.832 0.31 0.717 0.46 0.571 0.52 0.539

xi yi

0.70 0.378

0.74 0.370

0.82 0.306

0.98 0.242

1.17 0.104

Solution

For n = 2, the quadratic polynomial can be written as

f (x ) = a0 + a1 x + a2 x 2

Chapter 3

Interpolation & Curve Fitting / 18

From Eq. (3.28):
⎡ N ⎢ ⎢ ∑ xi ⎢∑ xi2 ⎣ ∑ xi ∑ xi2 ∑ xi3 ∑ xi2 ⎤ ⎧a0 ⎫ ⎧ ∑ yi ⎫ ⎥ ⎪ ⎪ ⎪ ⎪ ∑ xi3 ⎥ ⋅ ⎨ a1 ⎬ = ⎨ ∑ xi yi ⎬ ⎪ ⎪ ⎪ 2 ⎪ ∑ xi4 ⎥ ⎦ ⎩a2 ⎭ ⎩∑ xi yi ⎭

From the following table: ∑ xi ∑ xi2 ∑ xi3 ∑ xi4 = 6.01 = 4.6545 = 4.1150 = 3.9161 N ∑ yi ∑ xi yi ∑ xi2 yi = 11 = 5.905 = 2.1839 = 1.3357

Hence the matrix equation becomes:

6.01 4.6545⎤ ⎧a0 ⎫ ⎧ 5.905 ⎫ ⎡ 11 ⎢ 6.01 4.6545 4.1150⎥ ⋅ ⎪ a ⎪ = ⎪2.1839⎪ ⎬ ⎥ ⎨ 1⎬ ⎨ ⎢ ⎪ ⎪ ⎪ ⎪ ⎢ ⎦ ⎩a2 ⎭ ⎩1.3357 ⎭ ⎣4.6545 4.1150 3.9161⎥ a0 = 0.998 a1 = −1.018 a2 = 0.225
Hence, the quadratic function which can represent the data is f ( x ) = 0.998 − 1.018 x + 0.225 x 2

y
1

0.8

0.6

f(x)

0.4

0.2

0 0 0.2 0.4 0.6 0.8 1 1.2

x
The fitting of data using a quadratic function

FIGURE 3.9

Chapter 3

Interpolation & Curve Fitting / 19

3.6 Multivariable Interpolation
• The Newton, Lagrange and spline interpolation method can be applied for multivariable cases, e.g. for two and three variables:

f pq (x, y ) = ∑∑ Lxi (x ) ⋅ Ly j ( y ) f (xi , y j )
p q i =0 j =0 r

(3.32) (3.33)

f pqr ( x, y, z ) = ∑∑∑ Lxi ( x ) ⋅ Ly j ( y ) ⋅ Lzk ( z ) f (xi , y j , z k )
p q i = 0 j =0 k =0

where

x − xl Lxi ( x ) = ∏ l = 0 xi − xl
p l ≠i

y − yl Ly j ( y ) = ∏ l =0 y j − yl
q l≠ j

Lzk ( z ) = ∏
l =0 l ≠k

r

z − zl z k − zl

For example, Eq. (3.32) can be expanded as

f1,1 ( x, y ) =

(x − x1 )( y − y1 ) f (x , y ) + (x − x0 )( y − y1 ) f (x , y ) (x0 − x1 )( y0 − y1 ) 0 0 (x1 − x0 )( y0 − y1 ) 1 0 (x − x1 )( y − y0 ) f (x , y ) + (x − x0 )( y − y0 ) f (x , y ) + (x0 − x1 )( y1 − x0 ) 0 1 (x1 − x0 )( y1 − y0 ) 1 1

Example 3.10

The following table show the topology of a 3-D non-planar surface:
z = f(x,y) 1.0 x 1.5 2.0 y 0.2 0.640 0.990 1.568 0.3 1.003 1.524 2.384 0.4 1.359 2.045 3.177 0.5 1.703 2.549 3.943

Use the Newton interpolation to estimate the value of z at the coordinat (1.6, 0.33). As a comparison, the above data follows the function f ( x, y ) = e x sin y + y − 0.1 , thus f(1.6, 0.33) = 1.8350.

Chapter 3

Interpolation & Curve Fitting / 20

Solution

At x = 1.0:
j 0 1 2 3 yj 0.2 0.3 0.4 0.5 f(1.0, yj) 0.640 1.003 1.359 1.703 I 0.363 0.356 0.344 II −0.007 −0.012 III 0.005

f1 (1.0, y ) = 0.640 + 0.363( y − 0.2 ) − 0.007 ( y − 0.2 )( y − 0.3) f1 (1.0, 0.33) = 1.1108 . + 0.005( y − 0.2 )( y − 0.3)( y − 0.4 ) ,

At x = 1.5:
j 0 1 2 3 yj 0.2 0.3 0.4 0.5 f(1.5, yj) 0.990 1.524 2.045 2.549 I 0.534 0.521 0.504 II −0.013 −0.017 III −0.004

f1 (1.5, y ) = 0.990 + 0.534( y − 0.2 ) − 0.013( y − 0.2 )( y − 0.3) f1 (1.5, 0.33) = 1.6818 . − 0.004( y − 0.2 )( y − 0.3)( y − 0.4 ) ,

At x = 2.0:
j 0 1 2 3 yj 0.2 0.3 0.4 0.5 f(2.0, yj) 1.568 2.384 3.177 3.943 I 0.816 0.793 0.766 II −0.023 −0.027 III −0.004

f1 (2.0, y ) = 1.568 + 0.816( y − 0.2 ) − 0.023( y − 0.2 )( y − 0.3) f1 (2.0,0.33) = 2.6245 . − 0.004( y − 0.2 )( y − 0.3)( y − 0.4 ) ,

Chapter 3

Interpolation & Curve Fitting / 21

Next, at y = 0.33:
i 0 1 2 xi 1.0 1.5 2.0 f(xi, 0.33) 1.1108 1.6818 2.6245 I 0.5710 0.9427 II 0.3717

f1,1 (1.6, 0.33) = 1.8406 .

f1,1 ( x, 0.33) = 1.1108 + 0.5710 ( x − 1.0 ) + 0.3717 ( x − 1.0 )( x − 1.5) ,

This produces a relative error of εt = 0.305%.

Chapter 3

Interpolation & Curve Fitting / 22

Exercise
1. The fuel consumption of an engine has been recorded as shown in the following table. Time, hour 1.2 1.7 1.8 2.0 Fuel, liter 0.33201 0.54739 0.60496 0.73891

If a user runs the engine for 1.55 hours, determine the estimated fuel consumption using the Newton and Lagrange interpolation methods. 2. The following data shows the height function of a hill a a distance x from a reference. Form a cubic polynomial via regression. xi hi 0 4 1 5 2 10 3 17 4 21 5 16 6 11 7 3 8 1

Also, calculate the corresponding standard deviation. 3. The following data represents temperature distribution T(x,y) in a metal plate: Temperatur e T(x,y) x coordinate 0.5 1.0 1.5 2.0 y coordinate 0.5 7.51 10.00 12.51 15.00 1.0 10.05 10.00 9.95 10.00 1.5 12.70 10.00 7.32 5.00 2.0 15.67 10.00 4.33 0.00

Estimate the temperature at the coordinate (x, y) = (1.15, 1.42) using: a. b. the Newton linear interpolation, the Newton cubic interpolation.