sauernumanalyism 286855 04 ch3

Upload: elvarg09

Post on 02-Jun-2018

223 views

Category:

Documents


3 download

TRANSCRIPT

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    1/26

    CHAPTER 3

    Interpolation

    Exercises 3.1

    1 (a) The Lagrange interpolating polynomial through the points(0, 1), (2, 3), (3, 0)is

    P(x) = 1(x 2)(x 3)(0 2)(0 3)+ 3

    (x 0)(x 3)(2 0)(2 3)+ 0

    (x 0)(x 2)(3 0)(3 2)

    1 (b) The Lagrange interpolating polynomial is

    P(x) = 1(x+ 1)(x 3)(x 5)(2 + 1)(2 3)(2 5) + 1

    (x+ 1)(x 2)(x 5)(3 + 1)(3 2)(3 5) + 2

    (x+ 1)(x 2)(x 3)(5 + 1)(5 2)(5 3)

    1 (c) The Lagrange interpolating polynomial is

    P(x) = 2(x 2)(x 4)(0 2)(0 4) + 1

    (x 0)(x 4)(2 0)(2 4) + 4

    (x 0)(x 2)(4 0)(4 2)

    2 (a) P(x) = 1 +x 43

    x(x 2)2 (b) P(x) =1

    3(x+ 1) 1

    12(x+ 1)(x 2) + 1

    24(x+ 1)(x 2)(x 3)

    2 (c) P(x) = 2 +32

    x

    3 (a) Compute the Newtons divided differences of the data points:

    1 31

    1 1 12 0

    2 3 1

    43 7

    The interpolating polynomial is given byP(x) = 3 (x+ 1) + (x+ 1)(x 1).3 (b) By Theorem 3.2, there is exactly one polynomial of degree 3that passes through all four

    points. This is the degree2 polynomial in (a). No degree3 polynomial exists.3 (c) There are infinitely many interpolating polynomials of degree6, each of form

    P(x) = 3 (x+ 1) + (x+ 1)(x 1) + (x+ 1)(x 1)(x 2)(x 3)Q(x)

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    2/26

    52 CHAPTER 3 INTERPOLATION

    for an arbitrary degree 2 polynomial Q(x).

    4 (a) P(x) =x+

    2

    3x(x 1)(x 2)4 (b) For example,P1(x) =P(x)+x(x1)(x2)(x3), P2(x) =P(x)+2x(x1)(x2)(x3)4 (c) No, sinceP(4) = 20from part (a).

    5 (a) Compute the Newtons divided differences of the data points:

    2 82

    0 4 02 0

    1 2 0

    2

    3 2The polynomialP(x) = 8 2(x+ 2) passes through the four data points.

    5 (b) According to Theorem 3.2, there are no other degree 3polynomials through the four datapoints, butP4(x) = 8 2(x+ 2) +c(x+ 2)x(x 1)(x 3)interpolates for allc.

    6 P(x) = 1+ 2(x1)(x1)(x2) + 12

    (x1)(x2)(x3) + x(x1)(x2)(x3)(x4)7 By definition,P(x)passes through the points(1, 0),..., (10, 0), (12, 44). In Lagrange form, the

    interpolating polynomial can be written

    P(x) = 44 (x 1) (x 10)(12 1) (12 10)Substitutingx = 0gives

    P(x) = 44 (0 1) (0 10)(12 1) (12 10) = 44

    1 2 1011 10 2= 4

    8 1118

    9 (a) For the data points(1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 10), the Lagrange interpolat-ing polynomial is

    L(x) = 10(x 1)(x 2) (x 6)(7 1)(7 2) (7 6)

    9 (b) The degree6 polynomial asked for contains the seven data points in (a). According toTheorem 3.2, there is only one polynomial that does so, the one computed above. Therefore

    it suffices to check whether the L(x)from part (a) passes through(8, 70). Since

    L(8) = 107 6 26 5 1= 70

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    3/26

    Section 3.1 53

    the polynomialL(x)from part (a) also works for part (b).

    10 40

    11 Since the four points have distinct x-coordinates, Theorem 3.2 implies that only one poly-

    nomial of degree 3 passes through them. This polynomial is obviously the parabolay=ax2 +bx+c. Therefore no cubic polynomials pass through the four points.

    12 No, a set of 5 points can be contained by only one polynomial of degree 4 or less.

    13 (a) The Newtons divided difference triangle follows:

    1800 2800.06

    1850 283 0.00100.16 0.0000161900 291 0.0042

    0.792000 370

    The interpolating polynomial is

    P(x) = 280 + 0.06(x 1800) + 0.001(x 1800)(x 1850)+ 0.000016(x 1800)(x 1850)(x 1900)

    Estimate the1950carbon dioxide concentration by

    P(1950) = 280 + 0.06(150) + 0.001(150)(100) + 0.000016(150)(100)(50) = 31613 (b) Estimate the2050concentration by

    P(2050) = 280 + 0.06(250) + 0.001(250)(200) + 0.000016(250)(200)(150) = 465

    14 (a) 48

    14 (b) 49.66

    15 (a) A reasonably simple approach to evaluating the Lagrange interpolating polynomial is to

    first form then sumsx x1,...,x xnandn(n 1)/2sumsxi xj. Then each term of thepolynomial requiresn2multiplications in the numerator,n2in the denominator, plus onemultiplication and one division (which we count as a multiplication), for a total of2n

    2for

    each of thenterms. Therefore there aren(2n2)multiplications andn+n(n1)/2+ n1 =12

    n2 + 32

    n 1additions.15 (b) The nested Newton divided difference polynomial needs2 adds and1 multiplication in

    each nesting, for a total ofn 1multiplications and2n 2additions.

    Computer Problems 3.1

    1 (a) The newtdd MATLAB code can be used to construct the coefficients of the degree oneinterpolating polynomial. The commands

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    4/26

    54 CHAPTER 3 INTERPOLATION

    >> x=[1970 1990];y=[3707475887 5281653820];

    >> c=newtdd(x,y,2);

    >> nest(1,c,1980,x)

    return 4494564853.5 as the 1980 population linear estimate, compared to the actual 4452584502,a difference of only 400 million.

    1 (b) Follow the steps in (a), but use the three data points and construct a degree two interpolating

    polynomial. The resulting 1980 estimate is 4454831983.7, differing by only 2 million or sofrom the actual population.

    1 (c) Following the steps in (a) for all four data points results in an estimate of4472888287.8,about 20 million more than the actual population.

    3 The MATLABfunction could have the form:

    function y0=polyinterp(x,y,x0)

    len=length(x);

    c=newtdd(x,y,len);

    y0=nest(len-1,c,x0,x);

    4 The fundamental domain for cosine can be chosen to be[0, /2].

    5 (a) tan(

    2 x) = sin(

    2 x)

    cos(2 x)=

    sin 2

    cos x cos 2sin x

    cos 2

    cos x+ sin 2

    sin x=

    cos x

    sin x.

    5 (b) Thetan x function is periodic with period , or in other words, tan(x+ ) = tan x.

    Therefore if we can computetan xon the domain[

    2 ,

    2 ), all otherx can be referred to thisinterval by subtracting integer multiples of.Likewise, the identity tan(

    2 x) = 1/ tan x shows that for x satisfying

    4 < x <

    2,

    tan x = 1/ tan(2 x) where

    2 x lies in[0,

    4]. Furthermore,tan x for x in [

    2, 0]is the

    negative oftan |x|.Summarizing, given any real number, first subtract enough integer multiples of to locate

    a correspondingx in[2

    , 2

    ]. Ifx 4

    , settan x= 1/ tan(2 x).

    5 (c) The following MATLAB code moves the input x to the fundamental domain [0, /4] andcarries out the evaluation of the interpolating polynomial.

    function y=tan1(x)

    b=pi*(0:3)/12;yb=tan(b);

    c=newtdd(b,yb,4);

    s=1;d=1;

    x=mod(x+pi/2,pi)-pi/2;

    i f x < 0

    s=-1;x=abs(x);

    end

    if x > pi/4

    d=-1; x=pi/2-x;

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    5/26

    Section 3.2 55

    end

    y=s*nest(3,c,x,b)d;

    nest(3,c,x,b)

    5 (d) The maximum error in the interval[0, /4]is approximately0.003.

    Exercises 3.2

    1 (a) The Newton divided difference triangle is

    0 02

    2

    1

    4

    2

    2 0

    The degree 2 interpolating polynomial isP2(x) = 2

    x 4

    2x(x

    2).

    1 (b) P2(

    4) =

    2

    4 4

    2

    4(

    4) =

    1

    2+

    1

    4=

    3

    41 (c) The interpolation error formula for Theorem 3.3 applies to give

    sin

    4 P2

    4

    4434

    6 =

    3

    128 0.242.

    1 (d) The error is sin4 P2

    4

    =

    2

    2 3

    4

    0.043,less than the error bound in (c).

    2 (a) P2(x) = (ln 2)(x 1) 16(ln2)(x 1)(x 2)2 (b) P2(3) = 5(ln 2)/3 1.1552452 (c) 2/32 (d) 0.0566

    3 (a) According to Theorem 3.3,

    |f(x) P9(x)| =(x 0)(x 19) (x 1)10!

    210e2cwhere c is between0 and1. Atx = 1

    2, the error is

    f

    1

    2

    P9

    1

    2

    918

    718

    518

    318

    118

    118

    318

    518

    718

    918

    10! 210 1 7.06 1011.

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    6/26

    56 CHAPTER 3 INTERPOLATION

    3 (b) Sincef(12

    ) = 1/e, we can useP9(12

    )as an approximation for1/e. According to (a), since7.06

    1011

    0.5

    109, the approximation will have at least9 correct decimal places.

    4 (a) 3 5 7 9/57 0.01214 (b) 5 3 3 5/57 0.00288

    5 By Theorem 3.3, the interpolation error atx is

    |f(x) P(x)| |(x 0.1)(x 0.2) (x 0.6)6!

    ||f(6)(c)|

    whenc is between the smallest and largest of0.1, 0.2, . . . , 0.6, andx. We are given no infor-mation aboutf(6)(c). All things being equal, the ratio of the errors atx = 0.55andx = 0.35

    is|(0.55 0.1)(0.55 0.2) (0.55 0.6)||(0.35 0.1)(0.35 0.2) (0.35 0.6)| =

    (0.45)(0.35)(0.25)(0.15)(0.05)(0.05)

    (0.25)(0.15)(0.05)(0.05)(0.15)(0.25)= 4.2.

    6 0.00000714, making the assumption that f(6)(x) is similar in size to f(8)(x) on the interval[0, 1].

    Computer Problems 3.2

    1 (a) Using the MATLAB program newtdd to generate the coefficients of the interpolatingpolynomial results in

    P4(x) = 1.433329 + 1.989870(x 0.6) + 3.258900(x 0.6)(x 0.7)+ 3.680667(x 0.6)(x 0.7)(x 0.8)+ 4.0000417(x 0.6)(x 0.7)(x 0.8)(x 0.9),

    or in nested form,

    P4(x) = 1.433329 + (x 0.6)(1.989870 + (x 0.7)(3.258900

    + (x 0.8)(3.680667 + (x 0.9)4.0000417))).1 (b) Substitute intoP4(x)to getP4(0.82) = 1.958910 andP4(0.98) = 2.612848.1 (c) According to Theorem 3.3, the interpolation error satisfies

    |ex2 P4(x)| =|(x 0.6)(x 0.7)(x 0.8)(x 0.9)(x 1)|5!

    |f(v)(c)|

    where

    f(v)(x) = (32x5 + 160x3 + 120x)ex2

    .

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    7/26

    Section 3.2 57

    Forc 1, an upper bound forf(v)(c)is

    |f(v)

    (c)| (32 + 160 + 120)e1

    = 312e 848.1.Substituting into the error formula gives the error bounds

    |e(0.82)2 P4(0.82)| 0.0000537

    and

    |e(0.98)2 P4(0.98)| 0.000217.The actual errors, using the results of part (b), are

    |e(0.82)

    2

    P4(0.82)

    | 0.0000234

    and

    |e(0.98)2 P4(0.98)| 0.000107.1 (d)

    0.0002

    0.0002

    0.0001

    0.0001

    0.5 1.0

    (a)

    1 2

    1

    1

    2

    3

    (b)

    2 Write aforloop to subtract the output ofsin1from the MATLAB sinfunction for a grid of

    xinputs, and plot the result:

    6 3 3 6

    0.003

    0.003

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    8/26

    58 CHAPTER 3 INTERPOLATION

    3 The degree 9 interpolating polynomial from Newtons divided differences, written in nested

    form, is

    P9(x) = 67.052 + (x 1994)(0.9556 + (x 1995)(0.4195+ (x 1996)(0.6883 + (x 1997)(0.03575 + (x 1998)(0.002175+ (x 1999)(0.0123056 + (x 2000)(0.007915+ (x 2001)(0.0028646 + (x 2002)(0.0007352)))))))))

    and is plotted below.

    1994 1999 2004

    50

    100

    Substitutingx = 2010givesP9(2010) 1.952 1012 barrels, which is mathematicallycorrect but nonsensical, and not consistent with the data shown. This is a typical example of

    the Runge phenomenon, which prevents the degree-9 interpolating polynomial from being ausable model for extrapolating this data

    4 The degree 3 interpolating polynomial from Newtons divided differences, written in nested

    form, is

    P3(x) = 67.052 + (x 1994)(0.9556 + (x 1995)(0.4195 + (x 1996)(0.6883)))and is plotted below.

    1994 1999 2004

    50

    100

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    9/26

    Section 3.3 59

    Substitutingx= 1998gives the estimate74.258106 for the 1998 oil production, a slightoverestimate of the actual value73.400

    106. The Runge phenomenon has disappeared due

    to the lower degree of the interpolating polynomial.

    Exercises 3.3

    1 (a) Using the formulax = cos(2i 1)/(2n)fori = 1, . . . , n, the interpolation nodes are

    cos

    12, cos

    3

    12, cos

    5

    12, cos

    7

    12, cos

    9

    12, cos

    11

    12 .

    1 (b) The general formula for Chebyshev nodes on[a, b]is(a +b)/2+((ba)/2) cos(2i1)/nfori = 1, . . . , n. The 4 nodes on[2, 2]are therefore2cos(2i 1)/8fori = 1, . . . , 4or

    2cos

    8, 2cos

    3

    8 , 2cos

    5

    8 , 2cos

    7

    8 .

    1 (c) Using the general formula from (b), the6 nodes in[4, 12]are

    8 + 4 cos

    12, 8 + 4 cos

    3

    12, 8 + 4 cos

    5

    12, 8 + 4 cos

    7

    12, 8 + 4 cos

    9

    12, 8 + 4 cos

    11

    12 .

    1 (d) Using the general formula from (b), the5 nodes in[0.3, 0.7]are

    0.2 + 0.5cos 10 , 0.2 + 0.5cos310 , 0.2 + 0.5cos510 , 0.2 + 0.5cos710 , 0.2 + 0.5cos910 .

    2 (a) 1/322 (b) 22 (c) 1282 (d) 1/512

    3 To find a degree5 interpolating polynomial, we need n = 6 nodes. By Theorem 3.3, theinterpolation error is

    ex Q5(x) =(x x1) (x x6)6! f(vi)(c)

    where 1 c 1. Using (3.20),

    |ex Q5(x)| |f(vi)(c)|256!

    = ec

    256! e

    256! 1.1798 104.

    Since0.11798 103 < 0.5 103,Q5(x)and ex will agree to3 decimal places for 1x 1.

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    10/26

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    11/26

    Section 3.3 61

    2 1 1 2

    1

    1

    3 According to Theorem 3.3 and formula (3.20), the interpolation error of the degreen

    1

    interpolation polynomial on the fundamental domain[1, e]is at most

    e12

    |f(n)(c)|2n1n!

    where |f(n)(x)| = (n1)!xn| and1 c e. The maximum value of|f(n)(c)| for1 c eis(n 1)!, so the interpolation error is bounded above by (e 1)n/22n1n. Checking showsthat this expression is less than 0.5 1010 forn = 26. Program 3.4 can be adapted to findthe degree 25 interpolating polynomial at 26 Chebyshev nodes in[1, e].

    The part of Program 3.4 that moves any input between104 and104 into the fundamentaldomain must also be changed. Since e10 >104, the exponentk satisfyingek x < ek+1 canbe found using MATLAB code

    k = 10;

    while exp(k)>x

    k = k-1;

    end

    Now thatxek is in[1, e], it can be substituted into the interpolation polynomial, and the resultis added tok to get the approximate natural logarithm.

    4 The functionsf(x) = e|x| (thin curve), the interpolating polynomial at evenly-spaced points(dashed curve), and the interpolating polynomial at the Chebyshev nodes (thick curve) are

    shown for (a) n = 10and (b)n = 20. The evenly-spaced data points are plotted in (a), andthe Chebyshev points in (b).

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    12/26

    62 CHAPTER 3 INTERPOLATION

    1 1

    1

    2

    3

    (a)

    1 1

    1

    2

    3

    (b)

    Note the Runge phenomenon, especially evident in (b). The empirical interpolation errorsare plotted in (c) n = 10 and (d) n = 20. The dashed curve is the interpolation error forevenly-spaced interpolation, and the solid curve is the Chebyshev interpolation error.

    error

    100

    102

    104

    106

    1 0 1

    (c)

    error

    100

    102

    104

    106

    1 0 1

    (d)

    5 The MATLABcommands

    >> b=2*(0:(n-1))/(n-1)-1;

    or

    >> b=cos((1:2:2*n-1)*pi/(2*n));

    together with

    >> yb=exp(-b.2);

    >> c=newtdd(b,yb,n);

    define the coefficients of the degree n 1 interpolating polynomial for evenly-spaced orChebyshev nodes, respectively. Setting (a) n = 10 or (b) n = 20 gives the interpolationcurves below. For bothn = 10 and20, the evenly-spaced and Chebyshev interpolants are

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    13/26

    Section 3.4 63

    indistinguishable in the plot. In (a), the10 evenly-spaced interpolation points are plotted andin (b), the Chebyshev nodes are shown.

    1 1

    1

    (a)

    1 1

    1

    (b)

    The reason the curves are indistinguishable is clear when the empirical interpolation errors

    are plotted, in (c) n = 10 and (d) n = 20. The dashed curve is the interpolation error forevenly-spaced interpolation, and the solid curve is the Chebyshev interpolation error. There is

    a small hint of Runge phenomenon at the ends of the interval.

    100

    108

    104

    1 0 1

    (c)

    100

    104

    108

    1012

    1016

    1 0 1

    (d)

    Exercises 3.4

    1 (a) CalculatingS1(x) = 3x2 + 1andS2(x) = 3(x 1)2 + 6(x 1 ) + 3, note thatS1(1) = 4andS2(1) = 3, so thatS(x)is not a cubic spline.

    1 (b) The derivatives are

    S1(x) = 6x2 + 2x+ 4

    S1 (x) = 12x+ 2

    S2(x) = 3(x 1)2 + 4(x 1) + 12S2 (x) = 6(x 1) + 14

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    14/26

    64 CHAPTER 3 INTERPOLATION

    CalculatingS1(1) = 12,S1(1) = 12,S

    1 (1) = 14, andS2(1) = 12,S

    2(1) = 12,S

    2 (1) = 14,

    we conclude thatS(x)is a cubic spline.

    2 (a) cubic spline

    2 (b) not-a-knot only

    3 (a) The second derivativesS1 (x) = 92

    x and S2 (x) = 92(x 1) + 2cmust agree at x = 1,implying that 9

    2 = 2c, orc = 9

    4. SinceS1 (0) = 0 andS

    2 (2) = 92 + 92 = 0, the spline is

    natural. The spline fails the not-a-knot condition because S1 (1) = 92=9

    2 =S2 (1), and is

    not parabolically terminated because of the degree3 terms.3 (b) The second derivativesS1 (x) = 8andS

    2 (x) = 2cmust agree atx = 1, thusc = 4. The

    spline is parabolically terminated because of the absence of degree 3 terms, and is not-a-knotbecauseS

    1(1) = 0 = S

    2(1). It fails to be natural because S

    1(0) = 8

    = 0.

    3 (c) The first derivativesS1(x) =32 + 7x 3x2 andS2(x) = c+ (x 1) 3(x 1)2 mustagree atx = 1, soc = 5

    2. SinceS1 (0) = 7 6(0) = 7= 0, the spline is not natural. It is

    not parabolically terminated because of the nonzero degree 3 terms. The spline is not-a-knotbecauseS1 (1) =S

    2(1) = 6andS2 (2) =S3 (2) = 6.

    4 k1 = 29/6, k2= 3/2, k3= 7/6; not-a-knot

    5 By Theorem 3.9, there is exactly one natural cubic spline through any three points with distinct

    xcoordinates. The cubic splineS1(x) = S2(x) = x on [0, 1]and[1, 2], respectively, satisfiesthe conditions.

    6 S(x) = 1. Spline is also not-a-knot and natural.

    7 (a) There aren= 3given data points. First calculate1 = x2x1= 10 = 1,2 = x3x2=2 1 = 1,1 =y2 y1 = 1 0 = 1,2 =y3 y2 = 4 1 = 3. Equation (3.30) has theform

    1 0 01 4 10 0 1

    c1c2

    c3

    =

    06

    0

    with solutionsc1 = 0,c2 = 32

    ,c3 = 0. Equation (3.28) yields

    d1=c2 c1

    31=

    32 03(1)

    =1

    2

    d2 = c3 c2

    32=

    0 32

    3(1) = 1

    2

    and equation (3.29) gives

    b1=1

    11

    3(2c1+c2) =

    1

    2

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    15/26

    Section 3.4 65

    b2=2

    22

    3(2c2+c3) = 2

    The cubic spline is therefore

    S1(x) = 0 +1

    2x+ 0x2 +

    1

    2x3 on [0, 1]

    S2(x) = 1 + 2(x 1) +32

    (x 1)2 12

    (x 1)3 on [1, 2].

    7 (b) There aren= 3data points. Calculate1= 2,2= 1,1= 0,2 = 3. System (3.30) is

    1 0 02 6 10 0 1

    c1c2c3=

    090

    with solutionsc1 = 0,c2 = 32

    ,c3= 0. Equation (3.28) impliesd1 = 14

    ,d2 = 12 and equation(3.29) impliesb1= 1,b2 = 2. The cubic spline is therefore

    S1(x) = 1 (x+ 1) +14

    (x+ 1)3 on [1, 1]

    S2(x) = 1 + 2(x 1) +32

    (x 1)2 12

    (x 1)3 on [1, 2].

    8 (a)

    1 + 53x 16x3 on[0, 2]3 1

    3(x 2) (x 2)2 + 1

    3(x 2)3 on[2, 3]

    8 (b)

    x3 on[0, 1]

    1 + 3(x 1) + 3(x 1)2 (x 1)3 on[1, 2]

    9 SettingS1(1) =S2(1)implies4 + b1= 1, or b1= 3. SettingS1(1) =S2(1)impliesb1+ 3 =b2, or b2= 0. Therefore S

    1(0) =b1+3(0)

    2 = 3, and S2(3) =b2+6(31)6(31)2 = 12.

    10 True

    11 (a) By Theorem 3.10, there is exactly one parabolically terminated cubic spline through thethree points. The parabola passing through the three points, used on both intervals[0, 1] and[1, 2], will be the unique spline. By Newton divided differences:

    0 22

    1 0 22

    2 2

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    16/26

    66 CHAPTER 3 INTERPOLATION

    The parabola isS(x) = 2 2x+ 2x(x 1) = 2x2 4x+ 2.11 (b) We know from Section 3.1 that there are infinitely many degree3 polynomials through

    the three points. Each can be used as a not-a-knot spline. The cubic polynomials are S(x) =2x2 4x+ 2 +cx(x 1)(x 2)for arbitraryc = 0.

    12 One. Cubic interpolating polynomialP(x) = 3 13

    (x 1)(x 3) 124

    (x 1)(x 3)(x 4)is a not-a-knot spline.

    13 If a cubic spline is natural and parabolically terminated, thenS1(x) = a1+b1(x x1) +c1(x x1)2 andS1 (x1) = 0. Differentiating givesS1 (x) = 2c1, implyingc1 = 0, andS1(x)is linear. The same argument applies to show that Sn1(x)is linear.

    14 No. The leftmost three data points must be collinear, and so must the rightmost three data

    points.

    15 We haveS1(x) = 1,S2(x) = 1+b2x+c2x2+d2x

    3. Differentiating,S2(x) =b2+2c2x+3d2x2

    andS2 (x) = 2c2 + 6d2x. The spline conditions imply0 = S1(0) = S

    2(0) = b2 and0 =

    S1 (0) = S2 (0) = 2c2; in other words, the conditions are satisfied provided that 0 =b2 =c2,

    for arbitraryd2. ThusS2(x) = 1 +d2x3 works for anyd2.

    16 Clamped.

    17 Since there are infinitely many parabolas through n= 2 data points with distinct x coordinates,there are infinitely many parabolically terminated cubic splines. Thus existence holds but

    uniqueness fails.

    18 n= 2: There are infinitely many parabolas through two arbitrary points withx1= x2; eachis a not-a-knot cubic spline. n= 3: Infinitely many exist. Let P2(x)be the parabola throughthe three points. ThenS(x) =P2(x) + c(x x1)(x x2)(x x3)is a not-a-knot cubic splinefor eachc.

    Computer Problems 3.4

    1 (a) Programs 3.5 and 3.6 can be used to compute the spline coefficients and plot the spline,respectively. The command

    >> c=splinecoeff([0 1 2 3],[3 5 4 1])

    returns the spline coefficients

    S1(x) = 3 + 83

    x 23

    x3 on[0, 1]

    S2(x) = 5 + 23

    (x 1) 2(x 1)2 + 13

    (x 1)3 on[1, 2]S3(x) = 4 73(x 2) (x 2)2 + 13(x 2)3 on[2, 3]

    .

    The plot from

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    17/26

    Section 3.4 67

    >> c=splineplot([0 1 2 3],[3 5 4 1])

    is shown as (a) below.1 (b) Programs 3.5 and 3.6 can be used as in (a) to compute the spline coefficients and plot the

    spline. The result is

    S1(x) = 3 + 2.5629(x+ 1) 0.5629(x+ 1)3 on[1, 0]S2(x) = 5 + 0.8742x 1.6887x2 + 0.3176x3 on[0, 3]S3(x) = 1 0.6824(x 3) + 1.1698(x 3)2 0.4874(x 3)3 on[3, 4]S4(x) = 1 + 0.1950(x 4) 0.2925(x 4)2 + 0.0975(x 4)3 on[4, 5]

    .

    The plot of the natural cubic spline is shown in (b) below.

    1 1 2 3 4 5

    1

    2

    3

    4

    5

    (a)

    1 1 2 3 4 5

    1

    2

    3

    4

    5

    (b)

    2 (a) The not-a-knot condition can be implemented by including the appropriate two lines in

    Program 3.5. The spline is

    S1(x) = 3 + 236x 2x2 + 1

    6x3 on[0, 1]

    S2(x) = 5 + 13

    (x 1) 32

    (x 1)2 + 16

    (x 1)3 on[1, 2]S3(x) = 4 136(x 2) (x 2)2 + 16(x 2)3 on[2, 3]

    .

    and is plotted below by Program 3.6.2 (b) Use Program 3.5 with the not-a-knot condition as in (a). The spline is

    S1(x) = 3 + 3.8867(x+ 1) 2.1500(x+ 1)2 + 0.2633(x+ 1)3 on[1, 0]S2(x) = 5 + 0.3767x 1.3600x2 + 0.2633x3 on[0, 3]S3(x) = 1 0.6733(x 3) + 1.0100(x 3)2 0.3367(x 3)3 on[3, 4]S4(x) = 1 + 0.3367(x 4) 0.3367(x 4)3 on[4, 5]

    .

    and is plotted below as (b).

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    18/26

    68 CHAPTER 3 INTERPOLATION

    1 1 2 3 4 5

    1

    2

    3

    4

    5

    (a)

    1 1 2 3 4 5

    1

    2

    3

    4

    5

    (b)

    3 The spline is natural, and Program 3.5 calculates

    S1(x) = 1 + 2.6607x 0.6607x3 on[0, 1]S2(x) = 3 + 0.6786(x 1) 1.9821(x 1)2 + 1.3036(x 1)3 on[1, 2]S3(x) = 3 + 0.6250(x 2) + 1.9286(x 2)2 1.5536(x 2)3 on[2, 3]S4(x) = 4 0.1786(x 3) 2.7321(x 3)2 + 0.9107(x 3)3 on[3, 4]

    .

    1 1 2 3 4 5

    1

    2

    3

    4

    5

    4 This is a curvature-adjusted cubic spline, computed by Program 3.5 after enabling the curvature

    adjusted condition, and setting the second derivatives at the endpoints through the variables

    v1=3andvn=2. The spline is

    S1(x) = 1 + 1.8006x+ 1.5000x2 1.3006x3 on[0, 1]

    S2(x) = 3 + 0.8988(x 1) 2.4018(x 1)2 + 1.5030(x 1)3 on[1, 2]S3(x) = 3 + 0.6042(x 2) + 2.1071(x 2)2 1.7113(x 2)3 on[2, 3]S4(x) = 4 0.3155(x 3) 3.0268(x 3)2 + 1.3423(x 3)3 on[3, 4]

    .

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    19/26

    Section 3.4 69

    1 1 2 3 4 5

    1

    2

    3

    4

    5

    5 The cubic spline is clamped, and can be found by Program 3.5 with the clamped conditionsenabled and variablesv1 = 0andvn = 1.

    S1(x) = 1 + 4.6786x2 2.6786x3 on[0, 1]

    S2(x) = 3 + 1.3214(x 1) 3.3571(x 1)2 + 2.0357(x 1)3 on[1, 2]S3(x) = 3 + 0.7143(x 2) + 2.7500(x 2)2 2.4643(x 2)3 on[2, 3]S4(x) = 4 1.1786(x 3) 4.6429(x 3)2 + 3.8214(x 3)3 on[3, 4]

    .

    1 1 2 3 4 5

    1

    2

    3

    4

    5

    6 The cubic spline is clamped as in Computer Problem 5, and can be found by Program 3.5 with

    the clamped conditions enabled and variables v1 = -2andvn = 1.

    S1(x) = 1 2x+ 577x2 297x3 on[0, 1]S2(x) = 3 +

    137(x 1) 30

    7(x 1)2 + 17

    7(x 1)3 on[1, 2]

    S3(x) = 3 + 47

    (x 2) + 3(x 2)2 187(x 2)3 on[2, 3]

    S4(x) = 4 87(x 3) 337(x 3)2 + 277(x 3)3 on[3, 4]

    .

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    20/26

    70 CHAPTER 3 INTERPOLATION

    1 1 2 3 4 5

    1

    2

    3

    4

    5

    7 Program 3.5 can be used to find the cubic spline, using input vectors

    >> x=pi*(0:4)/8;>> y=cos(x);

    The clamps v1 and vn should be chosen to match the derivatives at the endpoints, namely

    S(0) = sin0 = 0andS(/2) = sin /2 = 1, respectively. The cubic spline is plottedbelow along with the cosine curve, although they are indistinguishable at this resolution.

    S1(x) = 1 0.5065x2 + 0.0327x3 on[0, 8 ]S2(x) = 0.9239 0.3826(x 8 ) 0.4679(x 8 )2 + 0.0931(x 8 )3 on[ 8 , 4 ]S3(x) = 0.7071 0.7070(x 4 ) 0.3582(x 4 )2 + 0.1396(x 4 )3 on[ 4 , 38]S4(x) = 0.3827

    0.9237(x

    34

    )

    0.1937(x

    34

    )2 + 0.1639(x

    34

    )3 on[ 38

    , 2

    ]

    .

    1

    1

    8 As in Computer Problem 7, Program 3.5 can be used to compute the clamped cubic spline

    matching first derivativesS(0) = 1andS(/2) = 0. The result is

    S1(x) = 0 +x 0.0006x2 0.1639x3 on[0, 8 ]S2(x) = 0.3827 + 0.9237(x 8 ) 0.1937(x 8 )2 0.1396(x 8 )3 on[ 8 , 4 ]S3(x) = 0.7071 + 0.7070(x 4 ) 0.3582(x 4 )2 0.0931(x 4 )3 on[ 4 , 38]S4(x) = 0.9237 + 0.3826(x 38) 0.4679(x 38)2 0.0327(x 38 )3 on[ 38, 2 ]

    .

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    21/26

    Section 3.4 71

    1

    1

    9 The clamped cubic spline can be calculated from Program 3.5 after setting the clampsS(1) =f(1) = 1andS(3) =f(3) = 1/3. The spline is

    S1(x) = (x 1) 0.4638(x 1)2 + 0.1713(x 1)3 on[1, 32 ]S2(x) = 0.4055 + 0.6647(x 32) 0.2068(x 32)2 + 0.0563(x 32)3 on[ 32 , 2]S3(x) = 0.6931 + 0.5001(x 2) 0.1224(x 2)2 + 0.0295(x 2)3 on[2, 52 ]S4(x) = 0.9163 + 0.3998(x 52) 0.0782(x 52)2 + 0.0155(x 52)3 on[ 52 , 3]

    .

    The maximum difference between the spline and the function f(x) = ln xcan be determinedby a slight modification of Program 3.5. The maximum interpolation error on[1, 3]is approx-imately0.0005464.

    10 Using ann= 48point spline reduces the maximum interpolation error to0.496

    107.

    11 (a) The natural cubic spline through the four data points is

    S1(x) = 3039585530 + 64621942(x 1960) + 21671(x 1960)3S2(x) = 3707475887 + 71123224(x 1970) + 650128(x 1970)2 13542(x 1970)3S3(x) = 5281653820 + 80877678(x 1990) 162405(x 1990)2 + 5414(x 1990)3

    on[1960, 1970], [1970, 1990] and [1990, 2000]respectively. Substitutingx = 1980 gives theestimate4470178717.

    11 (b) Using the data points, we can estimate the derivatives at the left and right endpoints

    as (3707475887

    3039585530)/10 = 66789036 and (6079603571

    5281653820)/10 =

    79794975, respectively. The clamped cubic spline through the four points is

    S1(x) = 3039585530 + 66789036(x 1960) 362212(x 1960)2 + 36221(x 1960)3S2(x) = 3707475887 + 70411154(x 1970) + 724424(x 1970)2 15477(x 1970)3S3(x) = 5281653820 + 80815906(x 1990) 204186(x 1990)2 + 10209(x 1990)3

    on[1960, 1970], [1970, 1990] and [1990, 2000]respectively. Substitutingx = 1980 gives theestimate4468552974. The natural cubic spline estimate misses the actual 1980 population by17.6 million, while the clamped spline misses by 16 million, and is slightly closer.

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    22/26

    72 CHAPTER 3 INTERPOLATION

    12 (a) The natural cubic spline through the data is

    S1(x) = 280 + 0.0613(x

    1800)

    5.2174

    107(x

    1800)3

    S2(x) = 283 + 0.0574(x 1850) 7.826 105(x 1850)2 + 4.2607 105(x 1850)3S3(x) = 291 + 0.3691(x 1900) + 0.006313(x 1900)2 2.1043 105(x 1900)3

    on[1800, 1850], [1850, 1900] and [1900, 2000] respectively, which evaluates to 322.6 ppm atx= 1950.

    12 (b) The parabolically-terminated cubic spline through the data is

    S1(x) = 280 + 0.0469(x 1800) + 2.6154 104(x 1800)2S2(x) = 283 + 0.0731(x 1850) + 2.6154 104(x 1850)2 + 2.9538 105(x 1850)3S3(x) = 291 + 0.3208(x 1900) + 0.004692(x 1900)2

    on[1800, 1850], [1850, 1900] and [1900, 2000] respectively, which evaluates to 318.8 ppm atx= 1950. The nearly-identical splines from (a) and (b) are shown below.

    12 (c) For four data points, there is no difference between the not-a-knot cubic spline and the

    degree three interpolating polynomial.

    1800 1850 1900 1950 2000

    200

    300

    400

    (a)

    1800 1850 1900 1950 2000

    200

    300

    400

    (b)

    13 Program 3.6 can be adapted to plot the three different cubic splines. They are barely distin-

    guishable in the following plot; the solid curve is natural, the dashed curve is not-a-knot, and

    the dotted curve is parabolically-terminated.

    1994 1999 2004

    65

    70

    75

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    23/26

    Section 3.5 73

    Exercises 3.5

    1 (a) Using the Bezier curve equations on page 164, one calculates bx = 3(0) = 0, cx =3(20)0 = 6, dx= 1006 = 5, by = 3(20) = 6, cy = 3(02)6 = 12, dy =0 0 6 + 12 = 6. The Bezier curve is

    x(t) =x1+bxt+cxt2 +dxt

    3 = 6t2 5t3y(t) =y1+byt+cyt

    2 +dyt3 = 6t 12t2 + 6t3 .

    1 (b) Similar to (a). One calculatesbx= 3, cx= 3, dx= 3andby = 3, cy = 3, dy = 0. TheBezier curve is

    x(t) = 1 3t 3t2 + 3t3y(t) = 1 3t+ 3t2 .

    1 (c) Similar to (a). One calculatesbx = 0, cx = 3, dx =2andby = 3, cy =3, dy = 0. TheBezier curve is

    x(t) = 1 + 3t2 2t3y(t) = 2 + 3t 3t2 .

    2 (a) (1, 1), (1, 2/3), (3, 1/3), (9, 1)2 (b) (3, 2), (13/3, 5/3), (16/3, 5/3), (8, 5)2 (c) (2, 1), (2, 2/3), (7/3, 1/3), (2, 2)

    3 We use Example 3.16 to draw three line segments as a three-piece Bezier curve. Each piece is

    characterized by four two-dimensional points:(1, 2) (1, 2) (3, 4) (3, 4)

    (3, 4) (3, 4) (5, 1) (5, 1)

    (5, 1) (5, 1) (1, 2) (1, 2)

    Translating to Bezier curves yields x(t) = 1 + 2t2(3 2t)y(t) = 2 + 2t2(3 2t)

    x(t) = 3 + 2t2(3 2t)y(t) = 4 3t2(3 2t)

    x(t) = 5 4t2(3 2t)y(t) = 1 +t2(3 2t)

    4 x(t) = 0

    y(t) = 15t

    2

    10t3

    x(t) = 15t2 10t3

    y(t) = 5 x(t) = 5

    y(t) = 5 15t2 + 10t3

    x(t) = 5 15t2 + 10t3y(t) = 0

    5 There are infinitely many Bezier curves satisfying the requirements. The data points are

    (1, 0), (1, y2), (1, y3), (1, 0)which generate the Bezier curve x(t) = 1 + 6t2 4t3y(t) = 3y2t+ (3y3 6y2)t2 + (3y2 3y3)t3

    .

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    24/26

    74 CHAPTER 3 INTERPOLATION

    Att = 12

    , x(12

    ) = 0, so we must solve1 = y(12

    ) = 38

    (y2+ y3). Any combination ofy2 andy3 =

    83

    y2satisfies the requirements. The solutions are

    x(t) = 1 + 6t2 4t3y(t) = 3y2t+ (8 9y2)t2 + (6y2 8)t3

    .

    for arbitraryy2. A particularly symmetric Bezier curve is given by settingy2 = y3 = 43

    , or

    y(t) = 4t 4t2.

    6

    x(t) = 1

    2t+ 2t2 3

    2t3

    y(t) = 1 4t2 + 3t3

    7 (a) For a space curve, the Bezier equations are applied to thex, yandzcoordinates. Therefore

    bx = 3, cx = 9, dx = 5, by = 0, cy = 6, dy = 5, andbz = 0, cz = 3, dz = 3. The Bezierspace curve is

    x(t) = 1 + 3t 9t2 + 5t3y(t) = 6t2 5t3z(t) = 3t2 3t3

    .

    7 (b) Similar to (a). Calculate bx = 0, cx =6, dx = 6, by = 3, cy =9, dy = 6, andbz = 3, cz = 12, dz = 8. The Bezier space curve is

    x(t) = 1 6t2 + 6t3y(t) = 1 + 3t

    9t2 + 6t3

    z(t) = 2 + 3t 12t2 + 8t3.

    7 (c) Similar to (a). Calculatebx = 3, cx =12, dx = 10, by = cy = dy = 0, andbz = 0, cz =6, dz = 4. The Bezier space curve is

    x(t) = 2 + 3t 12t2 + 10t3y(t) = 1

    z(t) = 1 + 6t2 4t3.

    8 (a) (1, 1, 1), (1, 2/3, 4/3), (3, 1/3, 11/3), (9, 1, 8)8 (b) (3, 2, 3), (13/3, 5/3, 10/3), (16/3, 5/3, 4), (8, 5, 4)

    8 (c) (2, 1, 0), (2, 2/3, 0), (7/3, 1/3, 0), (2, 2, 2)9 Differentiating the Bezier formulax(t) =x1 +bxt+cxt

    2+ dxt3 givesx(t) =bx +2cxt+3dxt

    2.

    Substituting yieldsx(0) =bx = 3(x2 x1)andx(1) =bx+ 2cx+ 3dx

    =bx+ 2cx+ 3(x4 x1 bx cx)= 3(x1 x1) 3(x2 x2) + 3(x4 x1)= 4(x4 x3).

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    25/26

    Section 3.5 75

    Similarly, y(0) = 3(y2 y1) and y (1) = 3(y4 y3). Therefore the direction vector of theparametric curve att = 0 is 3(x2

    x1, y2

    y1), the direction from the first endpoint to the

    first control point. The direction vector att = 1is3(x4 x3, y4 y3), the direction from thesecond control point to the second endpoint. Therefore the Bezier equations are designed to

    allow the control points to control the tangent directions at the endpoints.

    Computer Problems 3.5

    1 A Bezier spline from Exercise 5 that satisfies the requirements is x(t) = 1 + 6t2 4t3y(t) = 4t

    4t2

    .

    A parametric plot of the spline is shown below.

    1 1

    1

    2

    2 A Bezier spline from Exercise 6 that satisfies the requirements is x(t) = 1

    2t+ 2t2 3

    2t3

    y(t) = 1 4t2 + 3t3 .

    A parametric plot of the spline is shown below.

    1

    1

  • 8/10/2019 SauerNumAnalyISM 286855 04 Ch3

    26/26

    76 CHAPTER 3 INTERPOLATION

    3 Examples of Bezier splines for the four letters are shown. Program 3.7 can be adapted toaccept, instead of input data from the mouse,n 4arraysxlistand ylistholding rowsof fourx andy data points, respectively. For example, in (b) below we defined>> xlist=[1 1 1 1;1 3 3 1;1 3 3 1];

    >> ylist=[1 1 5 5;5 5 3 3;3 3 1 1];

    to represent the three splines defined by the four point groups

    (1, 1) (1, 1) (1, 5) (1, 5)

    (1, 5) (3, 5) (3, 3) (1, 3)

    (1, 3) (3, 3) (3, 1) (1, 1)

    1 2 3 4 5

    1

    2

    3

    4

    5

    (a)

    1 2 3 4 5

    1

    2

    3

    4

    5

    (b)

    1 2 3 4 5

    1

    2

    3

    4

    5

    (c)

    1 2 3 4 5

    1

    2

    3

    4

    5

    (d)