Chapter 5 Curve Fitting

download Chapter 5 Curve Fitting

of 12

Transcript of Chapter 5 Curve Fitting

  • 8/8/2019 Chapter 5 Curve Fitting

    1/12

    Chapter 5 Curve Fitting : Splines5.1 Introduction

    Fig. 5.1

  • 8/8/2019 Chapter 5 Curve Fitting

    2/12

    Fig. 5.25.2 Linear Splineso Piecewise interpolating polynomial :

    Fig. 5.3 Notation used to drive splines.(n-1) intervals and n data points

    o Piecewise linear interpolating funtionsn set data points :

    Piecewise linear polynomial in interval:

    , i = 1, 2, , n-1

  • 8/8/2019 Chapter 5 Curve Fitting

    3/12

    Fig. 5.4 (a) linear spline, (b) quadratic spline, (c) cubic spline

    5.3 Quadratic SplinesPiecewise quadratic polynomial in interval :

    (5.5)

  • 8/8/2019 Chapter 5 Curve Fitting

    4/12

    In each interval we need 3 conditions. So total 3(n-1) conditions.1. : (n-1) eqns2. : (n-1) eqns3. : (n-2) eqnsThe 3

    rdcondition is not satisfied for , :

    4. or : 2 eqnsTotal number of equations : 3(n-1)

    By 1st

    condition:

    (5.6),

    By 2nd condition:

    (5.7)Let ,

    (5.8),

    By 3rd condition:

    Then(5.9)

    i=2,3,,n-1;By 4th condition:

  • 8/8/2019 Chapter 5 Curve Fitting

    5/12

    [Ex 15.2]

    1 3.0 2.52 4.5 1.03 7.0 2.54 9.0 0.5

    Unknowns (i

    b ) :2

    stcondition:

    3nd

    condition :

    ,,

    ,

    5.4 Piecewise cubic splinen data points

    (5-10)

  • 8/8/2019 Chapter 5 Curve Fitting

    6/12

    There are 4(n-1) unknowns. We need 4(n-1) conditions.1)

    (5-11)(5-12)

    2)

    (5-13)3)1st derivative conditions: (n-2).

    (5-14)(5-15)

    4) 2nd derivative conditions: (n-2).

    (5-16), (5-17)

    (5-18)(5-18) is substituted in (5-13):

    (5-19)(5-18) is substituted in (5-15):

    (5-20)(5-23)

    Rewrite the equation (5-19):

  • 8/8/2019 Chapter 5 Curve Fitting

    7/12

    (5-21)

    (5-22)(5-21) and (5-22) are substituted in (5-23):

    (5-24)for

    In equation (15-24), there are (n-3) equations and (n-1) unknowns. Hencewe need an extra 2 conditions:

    How to give extra conditions?Type:1) natural spline :

    ( See equation (5-17))In equation (5-24), Take the interior points (i=2, , n-2):

    i = 2 :

    i = 3 :

  • 8/8/2019 Chapter 5 Curve Fitting

    8/12

    i = n-2 :

    Matrix form :

    [Ex 5.3]

    1 3.0 2.52 4.5 1.03 7.0 2.54 9.0 0.5

  • 8/8/2019 Chapter 5 Curve Fitting

    9/12

  • 8/8/2019 Chapter 5 Curve Fitting

    10/12

    Suppose that ,211

    xzx ,21 nn xzx and suppose that ),( 1zf )( 2zf are

    known. Then use the extra condition

    )()( 11 zfzs , )()( 22 zfzs (not-a-knot interpolation boundary conditions)

    Periodic spline: Complete spline:

    [ Matlab function ] lookfor spliney=spline(x_nodes, y_nodes, x)

    If one uses the statements

    pp=spline(x_nodes, y_nodes)

    [breaks, coefs, l, k, d]=unmkpp(pp)

    yi = interp1(x, y, xi, 'method')

    yi = interp1(x, y, xi, 'spline')yi = interp1(x, y, xi, 'linear')yi = interp1(x, y, xi, 'cubic')[Ex] x=0:10;y=sin(x);xi=0:0.25:1yi=interp1(x,y,xi);plot(x,y,'o',xi,yi)

  • 8/8/2019 Chapter 5 Curve Fitting

    11/12

    yi=interp1(x,y,xi.'spline');

  • 8/8/2019 Chapter 5 Curve Fitting

    12/12

    Homework:

    Is there a choice of coefficients {a, b,c,} for which the following function is a cubic

    spline?