22
3 I NTERPOLATION AND C URVE F ITTING Introduction Newton Interpolation: Finite Divided Difference Lagrange Interpolation Spline Interpolation Polynomial Regression Multivariable Interpolation

NTERPOLATION AND CURVE FITTING · Chapter 3 Interpolation & Curve Fitting / 2 3.1 Introduction • Interpolation is a technique to estimate the value between a set of data. • A

  • Upload
    others

  • View
    13

  • Download
    0

Embed Size (px)

Citation preview

  • 3 INTERPOLATION AND CURVE FITTING

    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:

    (3.1) ∑=

    =+++=n

    i

    ii

    nnn xaxaxaaxf

    010)( L

    • 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:

    ( ) ( ) ( ) ( )01

    01

    0

    01

    xxxfxf

    xxxfxf

    −−

    =−−

    x

    f(x)

    x x1

    f(x1)

    f(x0)

    x0

    f(x)

    FIGURE 3.1 Linear interpolation

    Rearranging the above relation leads to

    ( ) ( )( ) ( ) ( 0

    01

    0101 xxxx

    xfxfxfxf −⋅−

    )−+= (3.2)

    The term ( ) ( )[ ] ( )0101 xxxfxf −− 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:

    ( ) ( ) 35835190.01216

    07917595.1021 =−⋅−−

    +=f

    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:

    ( ) ( ) 46209812.01214

    03862944.1021 =−⋅−−

    +=f

    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:

    0

    1

    2

    0 2 4 6

    yf(x) = ln x

    x

    f1(x)

    FIGURE 3.2 The result for the linear interpolation for ln 2

    ( ) ( ) ( )( )1020102 xxxxbxxbbxf −−+−+= (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:

    ( )00 xfb = (3.4a)

    ( ) ( )

    01

    011 xx

    xfxfb−−

    = (3.4b)

    ( ) ( ) ( ) ( )

    02

    01

    01

    12

    12

    2 xxxx

    xfxfxx

    xfxf

    b−

    −−

    −−−

    = (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:

    7917595.1)(:63862944.1)(:4

    0)(:1

    22

    11

    00

    ======

    xfxxfxxfx

    Using Eq. (3.4):

    051873113.016

    1403862944.1

    463862944.17917595.1

    46209812.014

    03862944.10

    2

    1

    0

    −=−

    −−

    −−−

    =

    =−

    −=

    =

    b

    b

    b

    Hence, Eq. (3.3) yields ( ) ( )( )41051873113.0146209812.00)(2 −−−−+= xxxxf

    For x = 2:

    ( ) ( ) ( )( ).56584436.0

    ,4212051873113.01246209812.0022=

    −−−−+=f

    This produces the relative error εt = 18.4% as shown below.

  • Chapter 3 Interpolation & Curve Fitting / 6

    0

    1

    2

    0 2 4 6

    y

    f(x) = ln x

    x

    f2(x)

    f1(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:

    ( ) ( ) ( )( ) ( )110010 −−−−++−+= nnn xxxxxxbxxbbxf LL (3.5)

    where the coefficients bi can be obtained via

    ( )[ ][ ]

    [ ]011

    0122

    011

    00

    ,,,,

    ,,,

    xxxxfb

    xxxfbxxfb

    xfb

    nnn K

    M

    −=

    ===

    where the terms […] are finite divided differences and are defined as:

    [ ] ( ) ( )ji

    jiji xx

    xfxfxxf

    −=, (3.6a)

    [ ] [ ] [ ]ki

    kjjikji xx

    xxfxxfxxxf

    −=

    ,,,, (3.6b)

    [ ] [ ] [ ]0

    0121121011

    ,,,,,,,,,,,,xx

    xxxxfxxxxfxxxxfn

    nnnnnn −

    −= −−−−

    KKK (3.6c)

    Hence, Eq. (3.5) forms the Newton interpolation polynomial:

    ( ) ( ) ( ) [ ] ( )( ) [ ]

    ( )( ) [ 01110012100100

    ,,,)(,,,

    xxxfxxxxxxxxxfxxxxxxfxxxfxf

    nnn

    n

    KLL −−−−−++ ]−−+−+=

    (3.7)

  • Chapter 3 Interpolation & Curve Fitting / 7

    TABLE 3.1 Newton finite divided difference interpolation polynomial

    i xi f(xi ) I II III0 x0 f (x0) f [x1,x0] f [x2,x1,x0] f [x3,x2,x1,x0]

    1 x1 f (x1) f [x2,x1] f [x3,x2,x1]

    2 x2 f (x2) f [x3,x2]

    3 x3 f (x3)

    • The relation for error for the n-th order interpolation function can be estimated using:

    [ ]( )( ) ( )nnnnn xxxxxxxxxxfR −−−≈ −+ LK 10011 ,,,, (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

    ( ) ( ) ( )( ) ( )( )( )21031020103 xxxxxxbxxxxbxxbbxf −−−+−−+−+=

    i xi f(xi ) I II III0 1 0 0.46209813 −0.0597386 0.00786553

    1 4 1.3862944 0.22314355 −0.0204110

    2 5 1.6094379 0.18232156

    3 6 1.7917595

    Thus,

    ( ) ( ) ( )( )( )( )( ),54100786553.0

    410597386.0146209812.003−−−+

    −−−−+=xxx

    xxxxf

    ( ) ( ) ( )( )( )( )( )

    .6287691.0,52421200786553.0

    42120597386.01246209812.0023

    =−−−+

    −−−−+=f

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

  • Chapter 3 Interpolation & Curve Fitting / 8

    0

    1

    2

    0 2 4 6

    y

    f(x) = ln x

    x

    f3(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:

    (3.9) ( ) ( ) ( )∑=

    =n

    iiin xfxLxf

    0

    where the parameter Li(x) is defined as

    ( ) ∏≠= −

    −=

    n

    ijj ji

    ji xx

    xxxL

    0 (3.10)

    • For n = 1, the first order Lagrange interpolation function can be written as:

    ( ) ( ) ( )101

    00

    10

    11 xfxx

    xxxfxxxxxf

    −−

    +−−

    =

    • For n = 2, the second order Lagrange interpolation can be written as:

    ( ) ( )( )( )( ) ( )( )( )

    ( )( ) ( )

    ( )( )( )( ) ( )21202

    10

    12101

    200

    2010

    212

    xfxxxx

    xxxx

    xfxxxx

    xxxxxfxxxx

    xxxxxf

    −−−−

    +

    −−−−

    +−−

    −−=

    • The error term for the Lagrange interpolation can be estimated using:

    (3.11) [ ] (∏=

    −+ −=n

    iinnnn xxxxxxfR

    0011 ,,,, K )

    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:

    7917595.1)(:63862944.1)(:4

    0)(:1

    22

    11

    00

    ======

    xfxxfxxfx

  • Chapter 3 Interpolation & Curve Fitting / 10

    For the first order Lagrange interpolation:

    ( ) ( ) ( )

    ( ) ( ) ( )

    4620981.0

    3862944.114120

    414221

    101

    00

    10

    11

    =−−

    +−−

    =∴

    −−

    +−−

    =

    f

    xfxxxxxf

    xxxxxf

    For the second order Lagrange interpolation:

    ( ) ( )( )( )( ) ( )( )( )

    ( )( ) ( )

    ( )( )( )( ) ( )21202

    10

    12101

    200

    2010

    212

    xfxxxx

    xxxx

    xfxxxx

    xxxxxfxxxx

    xxxxxf

    −−−−

    +

    −−−−

    +−−

    −−=

    ( )( )( )( ) ( )

    ( )( )( )( ) ( )

    ( )( )( )( ) ( )

    5658444.0

    7917595.146164212

    3862944.1641462120

    61416242)2(2

    =−−−−

    +

    −−−−

    +−−−−

    =f

  • 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.

    x

    f(x)

    x

    f(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

    ( ) ( ) ( )( ) ( ) ( )

    ( ) ( ) ( ) nnnnnn xxx

    xxxxxx

    xxmxfxf

    xxmxfxfxxmxfxf

    ≤≤

    ≤≤≤≤

    −+=

    −+=−+=

    −−−− 1

    21

    10

    1111

    11121

    00011

    untuk

    untuk untuk

    MM (3.12)

    dengan mi is the gradient for the (i+1)-th interval:

    ( ) ( )

    ii

    iii xx

    xfxfm−−

    =+

    +

    1

    1 (3.13)

    Example 3.6

    Use the following data to estimate the function f(x) at x = 5 using the linear spline interpolation.

    x f(x) 3.0 2.5 4.5 1.0 7.0 2.5 9.0 0.5

  • Chapter 3 Interpolation & Curve Fitting / 12

    Solution

    The value of x = 5 is in the range 75.4 ≤≤ x , where the gradient is

    60.05.40.70.15.2

    1 =−−

    =m

    From Eq. (3.12): ( ) ( ) ( )( ) ( ) .3.15.4560.00.15

    ,

    21

    11121

    =−+=

    −+=

    fxxmxfxf

    0

    2

    2 4 6 8 x

    f(x)

    FIGURE 3.6 Linear spline interpolation for Example 3.6

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

    ( ) iiii cxbxaxf ++= 22 (3.14)

    The coefficient ai, bi and ci for each interval can be evaluated using:

    1. Continuity at vertices (2n−2 equations):

    ( )11112 11 −−−−−− =++ iiiiii xfcxbxa (3.15) ( )112 1 −−− =++ iiiiii xfcxbxa (3.16)

    2. Conditions at end points (2 equations):

    ( )0101201 xfcxbxa =++ (3.17) ( )nnnnnn xfcxbxa =++2 (3.18)

  • Chapter 3 Interpolation & Curve Fitting / 13

    3. Differentiability at vertices (n−1 equations):

    ( ) baxxf +=′ 2 iiiiii bxabxa +=+ −−−− 1111 22 (3.19)

    4. Assumption at the first interval (1 persamaan):

    01 =a (3.20)

    x

    f(x)

    0

    2

    2 4 6 8

    FIGURE 3.7 The quadratic spline interpolasi for example 3.7

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

    (3.21) ( ) iiiii dxcxbxaxf +++= 233

    • The formulation for the cubic spline can be derived as followed:

    For interval (xi−1, xi), the second derivative can be written as:

    ( ) ( ) ( )1

    1

    11

    −− −

    −′′+−

    −′′=′′ii

    iii

    ii

    iiii xx

    xxxfxx

    xxxfxf (3.22)

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

    ( ) ( )( ) ( )( )

    ( ) ( )

    ( )( )

    ( )( ) ( )

    ( )( )

    ( )( ) ( )111

    11

    1

    1

    31

    1

    3

    1

    13

    6

    6

    66

    −−

    −−

    −−−

    −⎥⎦

    ⎤⎢⎣

    ⎡ −′′−

    −+

    −⎥⎦

    ⎤⎢⎣

    ⎡ −′′−

    −+

    −−′′

    +−−

    ′′=

    iiii

    ii

    i

    iiii

    ii

    i

    iii

    ii

    ii

    ii

    xxxxxfxxxf

    xxxxxfxx

    xf

    xxxx

    xfxxxx

    xfxf

    (3.23)

  • Chapter 3 Interpolation & Curve Fitting / 14

    The differentiability can be maintained troughout the function via

    ( ) ( )iiii xfxf ′=′−1 (3.24)

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

    ( ) ( ) ( ) ( ) ( ) ( )

    ( ) ( ) ( )[ ] ( ) ( ) ( )[ iiiiiiii

    iiiiiiiii

    xfxfxx

    xfxfxx

    xfxxxfxxxfxx

    −−

    +−−

    =

    ′′

    ]

    −+′′−+′′−

    −−

    ++

    ++−+−−

    11

    11

    111111

    662

    (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):

    ( ) ( ) ( ) ( ) ( ) (

    ( )

    )

    ( ) ( ) ( )15.235.4615.2

    5.476

    75.475.4372335.4

    −−

    +−−

    =

    ′′−+′′−+′′− fff

    It is known that . Hence ( ) 03 =′′f( ) ( ) 6.975.25.48 =′′+′′ ff

    For the second interval (i = 2): ( ) ( ) 6.9795.45.2 −=′′+′′ ff

    Both equations is solved simultaneously to yield ( )

    ( ) 53308.1767909.15.4

    =′′=′′

    ff

    Using Eq. (3.23) for the first interval:

    ( ) ( ) ( ) ( )

    ( ) ( )

    ( ) ( ) ( ).3246894.05.4666667.13186566.0

    ,36

    35.467909.135.4

    1

    5.435.4

    5.2335.46

    67909.1

    3

    313

    −+−+−=

    −⎥⎦⎤

    ⎢⎣⎡ −−

    −+

    −−

    +−−

    =

    xxx

    x

    xxxf

  • Chapter 3 Interpolation & Curve Fitting / 15

    For the second and third intervals:

    ( ) ( ) ( ) (( )

    ( ) ( ) ( ) ( )725.09761027.19127757.05.4638783.1

    7299621.05.4102205.07111939.0

    333

    3323

    −+−+−−=

    −+

    −−−−−=

    xxxxf

    xxxxxf )

    At x = 5, use the function for the second interval:

    ( ) ( ) ( ) (( )

    .102886.1,5.45638783.1

    57299621.05.45102205.057111939.05 3323

    =−+

    −−−−−=f )

    0

    2

    2 4 6 8 x

    f(x)

    Cubic Spline

    Cubic Newton/ Lagrange Interpolation

    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:

    (3.26) ( ) nn xaxaxaaxf ++++= L2210where the error for the i-th data (xi,yi) is

    ( ) niniiiiii xaxaxaayxfye −−−−−=−= L2210

    The sum of the squares of error for N data is

    (3.27) ( )∑∑==

    −−−−−==N

    i

    niniii

    N

    ii xaxaxaayeS

    1

    22210

    1

    2 L

    These errors can be minimised as followed:

    ( )( )

    ( )( )

    ( )∑

    =

    =

    =

    −−−−−−==∂∂

    −−−−−−==∂∂

    −−−−−−==∂∂

    N

    i

    ni

    niniii

    n

    N

    ii

    niniii

    N

    i

    niniii

    xxaxaxaayaS

    xxaxaxaayaS

    xaxaxaayaS

    1

    2210

    1

    2210

    1

    1

    2210

    0

    20

    20

    120

    L

    M

    L

    L

    ( )

    producing the following system of equations:

    (3.28)

    ini

    nin

    ni

    ni

    ni

    iininiii

    iininiii

    ininii

    yxxaxaxaxa

    yxxaxaxaxa

    yxxaxaxaxa

    yxaxaxaNa

    ∑=∑++∑+∑+∑

    ∑=∑++∑+∑+∑

    ∑=∑++∑+∑+∑

    ∑=∑++∑+∑+

    ++

    +

    +

    222

    110

    2242

    31

    20

    132

    210

    2210

    L

    M

    L

    L

    L

  • Chapter 3 Interpolation & Curve Fitting / 17

    or, in a form of matrix equation:

    (3.29)

    ⎪⎪⎪

    ⎪⎪⎪

    ⎪⎪⎪

    ⎪⎪⎪

    ∑∑∑

    =

    ⎪⎪⎪

    ⎪⎪⎪

    ⎪⎪⎪

    ⎪⎪⎪

    ⎥⎥⎥⎥⎥⎥

    ⎢⎢⎢⎢⎢⎢

    ∑∑∑∑

    ∑∑∑∑∑∑∑∑∑∑∑

    ++

    +

    +

    ini

    ii

    ii

    i

    nn

    ini

    ni

    ni

    niiii

    niiii

    niii

    yx

    yxyx

    y

    a

    aaa

    xxxx

    xxxxxxxxxxxN

    MM

    L

    MOMMM

    L

    L

    L

    22

    1

    0

    221

    2432

    132

    2

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

    111

    2

    +−=

    +−=

    ∑=

    nN

    e

    nNS

    N

    ii

    σ (3.30)

    • The case for n = 1 is referred to as the linear regression:

    xaay 10 +=

    (3.31) ⎭⎬⎫

    ⎩⎨⎧

    ∑∑

    =⎭⎬⎫

    ⎩⎨⎧

    ⋅⎥⎦

    ⎤⎢⎣

    ⎡∑∑∑

    ii

    i

    ii

    i

    yxy

    aa

    xxxN

    1

    02

    Example 3.9

    Determine a best-fit quadratic equation which can represent the following experimental data:

    xi 0.05 0.11 0.15 0.31 0.46 0.52 yi 0.956 0.890 0.832 0.717 0.571 0.539

    xi 0.70 0.74 0.82 0.98 1.17 yi 0.378 0.370 0.306 0.242 0.104

    Solution

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

    ( ) 2210 xaxaaxf ++=

  • Chapter 3 Interpolation & Curve Fitting / 18

    From Eq. (3.28):

    ⎪⎭

    ⎪⎬

    ⎪⎩

    ⎪⎨

    ∑∑∑

    =⎪⎭

    ⎪⎬

    ⎪⎩

    ⎪⎨

    ⎧⋅

    ⎥⎥⎥

    ⎢⎢⎢

    ∑∑∑∑∑∑∑∑

    ii

    ii

    i

    iii

    iii

    ii

    yxyx

    y

    aaa

    xxxxxxxxN

    22

    1

    0

    432

    32

    2

    From the following table:

    3357.19161.31839.21150.4905.56545.4

    1101.6

    24

    3

    2

    =∑=∑=∑=∑=∑=∑==∑

    iii

    iii

    ii

    i

    yxxyxxyxNx

    Hence the matrix equation becomes:

    225.0018.1998.03357.11839.2905.5

    9161.31150.46545.41150.46545.401.66545.401.611

    210

    2

    1

    0

    =−==

    ⎪⎭

    ⎪⎬

    ⎪⎩

    ⎪⎨

    ⎧=

    ⎪⎭

    ⎪⎬

    ⎪⎩

    ⎪⎨

    ⎧⋅

    ⎥⎥⎥

    ⎢⎢⎢

    aaaaaa

    Hence, the quadratic function which can represent the data is

    ( ) 2225.0018.1998.0 xxxf +−=

    0

    0.2

    0.4

    0.6

    0.8

    1

    0 0.2 0.4 0.6 0.8 1 1.2

    y

    x

    f(x)

    FIGURE 3.9 The fitting of data using a quadratic function

  • 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:

    (3.32) ( ) ( ) ( ) (∑∑= =

    ⋅=p

    i

    q

    jjiyxpq yxfyLxLyxf ji

    0 0,, )

    ) (3.33) ( ) ( ) ( ) ( ) (∑∑∑= = =

    ⋅⋅=p

    i

    q

    j

    r

    kkjizyxpqr zyxfzLyLxLzyxf kji

    0 0 0

    ,,,,

    where

    ( ) ( ) ( ) ∏∏∏≠=

    ≠=

    ≠= −

    −=

    −−

    =−−

    =r

    kll lk

    lz

    q

    jll lj

    ly

    p

    ill li

    lx zz

    zzzLyyyyyL

    xxxxxL

    kji000

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

    ( ) ( )( )( )( ) ( )( )( )

    ( )( ) ( )

    ( )( )( )( ) ( )

    ( )( )( )( ) ( )110101

    0010

    0110

    01

    011001

    1000

    1010

    111,1

    ,,

    ,,,

    yxfyyxx

    yyxxyxfxyxx

    yyxx

    yxfyyxx

    yyxxyxfyyxx

    yyxxyxf

    −−−−

    +−−

    −−+

    −−−−

    +−−

    −−=

    Example 3.10

    The following table show the topology of a 3-D non-planar surface:

    y z = f(x,y)

    0.2 0.3 0.4 0.5

    1.0 0.640 1.003 1.359 1.703

    1.5 0.990 1.524 2.045 2.549 x

    2.0 1.568 2.384 3.177 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

    ( ) 1.0sin, −+= yyeyxf x , thus f(1.6, 0.33) = 1.8350.

  • Chapter 3 Interpolation & Curve Fitting / 20

    Solution

    At x = 1.0:

    j yj f(1.0, yj) I II III0 0.2 0.640 0.363 −0.007 0.005

    1 0.3 1.003 0.356 −0.012

    2 0.4 1.359 0.344

    3 0.5 1.703

    ( ) ( ) ( )( )( )( )( )

    ( ) .1108.133.0,0.1,4.03.02.0005.0

    3.02.0007.02.0363.0640.0,0.1

    1

    1

    =−−−+

    −−−−+=

    fyyy

    yyyyf

    At x = 1.5:

    j yj f(1.5, yj) I II III0 0.2 0.990 0.534 −0.013 −0.004

    1 0.3 1.524 0.521 −0.017

    2 0.4 2.045 0.504

    3 0.5 2.549

    ( ) ( ) ( )( )( )( )( )

    ( ) .6818.133.0,5.1,4.03.02.0004.0

    3.02.0013.02.0534.0990.0,5.1

    1

    1

    =−−−−

    −−−−+=

    fyyy

    yyyyf

    At x = 2.0:

    j yj f(2.0, yj) I II III0 0.2 1.568 0.816 −0.023 −0.004

    1 0.3 2.384 0.793 −0.027

    2 0.4 3.177 0.766

    3 0.5 3.943

    ( ) ( ) ( )( )( )( )( )

    ( ) .6245.233.0,0.2,4.03.02.0004.0

    3.02.0023.02.0816.0568.1,0.2

    1

    1

    =−−−−

    −−−−+=

    fyyy

    yyyyf

  • Chapter 3 Interpolation & Curve Fitting / 21

    Next, at y = 0.33:

    i xi f(xi, 0.33) I II0 1.0 1.1108 0.5710 0.3717

    1 1.5 1.6818 0.9427

    2 2.0 2.6245

    ( ) ( ) ( )( )( ) .8406.133.0,6.1

    ,5.10.13717.00.15710.01108.133.0,

    1,1

    1,1

    =

    −−+−+=

    fxxxxf

    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 Fuel, liter

    1.2 0.33201 1.7 0.54739 1.8 0.60496 2.0 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 0 1 2 3 4 5 6 7 8

    hi 4 5 10 17 21 16 11 3 1

    Also, calculate the corresponding standard deviation.

    3. The following data represents temperature distribution T(x,y) in a metal plate:

    y coordinate Temperature T(x,y) 0.5 1.0 1.5 2.0

    0.5 7.51 10.05 12.70 15.67

    1.0 10.00 10.00 10.00 10.00

    1.5 12.51 9.95 7.32 4.33

    x co

    ordi

    nate

    2.0 15.00 10.00 5.00 0.00

    Estimate the temperature at the coordinate (x, y) = (1.15, 1.42) using:

    a. the Newton linear interpolation, b. the Newton cubic interpolation.

    3.1 Introduction3.2 Newton Interpolation: Finite Divided DifferenceExample 3.1SolutionExample 3.2Solution

    Example 3.3Solution

    3.3 Lagrange InterpolationExample 3.5Solution

    3.4 Spline InterpolationExample 3.6SolutionExample 3.8Solution

    3.5 Polynomial RegressionExample 3.9Solution

    3.6 Multivariable InterpolationExample 3.10Solution

    Exercise