Homework Solutions Math2130

Embed Size (px)

Citation preview

  • 8/13/2019 Homework Solutions Math2130

    1/67

    1.1 Basic Tools for Calculus

    Page 12

    #1 What is the third-order Taylor polynomial for f(x) =

    x+ 1, aboutx0 = 0?

    Solution:

    P3(x) =f(0) +xf(0) +

    x2

    2!f(0) +

    x3

    3!f(0) (1)

    f(0) = 1

    f(x) = 12

    (x+ 1)12 so f(0) =1

    2

    f(x) = 14

    (x+ 1)3

    2 so f(0) = 14

    f(x) = 3

    8(x+ 1)

    5

    2 so f(0) =3

    8

    Substituting in (1) yields

    P3(x) = 1 +1

    2x 1

    8x2 +

    1

    16x3.

    #4 Given that

    R(x) =|x|6

    6! e

    for x [1, 1], where is between x and 0, find and upper bound for|R|,valid for all x [1, 1], that is independent ofx and .

    Solution: Note first that x [1, 1] |x| 1.|x|66!

    e 1 e1

    6! =

    e

    6! 0.00378.

    #6 Given that

    R(x) =|x|4

    4!

    11 +

    1

  • 8/13/2019 Homework Solutions Math2130

    2/67

    forx

    1

    2

    ,1

    2, whereis betweenxand 0, find and upper bound for |R|,value for all x

    1

    2,1

    2

    , that is independent ofxand .

    Solution: We use the following facts

    (i) x

    12

    ,1

    2

    |x| 1

    2

    (ii) for 0 < z < 1

    2, y = z4 is increasing, thus for z1 < z2, we have that

    z41 < z42 , e.g., z

    4 < 1

    24

    (iii) 1

    |1 +| for 1

    2,1

    2

    is maximized for that minimizes|1 +|, i.e.

    when= 12

    .

    |x|44!

    11 +

    |x|

    4

    4!|1 +|12

    44!|1 +|

    12

    44!1 + 12 =

    12

    44!12

    =

    12

    34

    = 1

    192.

    #7 What is the fourth-order Taylor polynomial for 1

    x+ 1about x0= 0?

    Solution:

    P4(x) =f(0) +xf(0) +

    x2

    2!f(0) +

    x3

    3!f(0) +

    x4

    4!f(iv)(0) (2)

    f(0) = 1

    f(x) = (x+ 1)2 so f(0) = 1f(x) = 2(x+ 1)3 so f(0) = 2

    f(x) =

    6(x+ 1)4 so f(0) =

    6

    f(iv)(x) = 24(x+ 1)5 so f(iv)(0) = 24

    Substituting in (2) yields

    P4(x) = 1 x+x2 x3 +x4.

    2

  • 8/13/2019 Homework Solutions Math2130

    3/67

    #10(c) Find the Taylor polynomial of third-order for sin(x), using: x0 =

    2.

    Solution:

    P3(x) =f

    2

    +

    x 2

    f

    2

    +

    x

    2

    22!

    f

    2

    +

    x

    2

    33!

    f

    2

    (3)

    f(0) = 1

    f(x) = cos(x) so f(0) = 0

    f(x) = sin(x) so f(0) = 1f(x) = cos(x) so f(0) = 0

    Substituting into (3) yields

    P3(x) = 1

    x 2

    22

    .

    #11(d) For each function below construct the third-order Taylor polynomialapproximation, using x0 = 0, and then estimate the error by computing anupper bound on the remainder, over the given interval: (d) f(x) = ln(1+ x),

    x 1

    2,1

    2

    .

    Solution:

    P4(x) =f(0) +xf(0) +

    x2

    2!f(0) +

    x3

    3!f(0) +

    x4

    4!f(iv)() (4)

    for between 0 and x.

    f(x) = ln(1 +x) so f(0) = ln(1) = 0

    f(x) = 1

    1 +x so f(0) = 1

    f(x) = (x+ 1)2 so f(0) = 1f(x) = 2(x+ 1)3 so f(0) = 2

    f(iv)

    (x

    ) = 6(x

    + 1)4

    = 6

    (1 +x)4 sof(iv)

    (

    ) = 6

    (1 +)4

    Substituting into (4) yields

    ln(1 +x) =x x2

    2 +

    x3

    3 x

    4

    4(1 +)4.

    3

  • 8/13/2019 Homework Solutions Math2130

    4/67

    SoP3(x) =x

    x2

    2

    +x3

    3

    . For the error bound, first note that x

    1

    2

    ,1

    2 |x| 12

    .

    |R3(x)| |x|4

    4(1 +)4

    12

    44(1 +)4

    12

    44

    1 +1

    2

    412

    4412

    4 =14#12(b) Construct a Taylor polynomial approximation that is accurate towithin 103, over the indicated interval, for each of the following functions,using x0 = 0: (b) f(x) =e

    x, x [0, 1].

    Solution: As in example 2 of the notes, we need n such that

    |Rn(x)| 103

    for all x [0, 1]. xn+1(n+ 1)!e = |x|n+1(n+ 1)! e 1 e

    0

    (n+ 1)!=

    1

    (n+ 1)!

    Solving 1

    (n+ 1)! 103 for n, we find that n= 7, thus we must find P7(x).

    Since f(n)

    (x) = (1)n

    ex

    for all n we have that f(n)

    (0) = (1)n

    for all n.Thus

    P7(x) = 1 x+ x2

    2 x

    3

    3! +

    x4

    4! x

    5

    5! +

    x6

    6! x

    7

    7!.

    #23 Use the Integral Mean Value Theorem to show that the pointwiseform (1.3) of the Taylor remainder (usually called the Lagrange form) fol-lows from the integral form (1.2) (usually called the Cauchy form).

    4

  • 8/13/2019 Homework Solutions Math2130

    5/67

    Solution: Note: (x t)n doesnt change sign for t [x0, x].

    Rn(x) = 1

    n!

    xx0

    (x t)nf(n+1)(t) dt (Integral Form)

    = f(n+1)()

    n!

    xx0

    (x t)n dt (Using Mean Value Theorem)

    = f(n+1)()

    n! (x t)

    n+1

    n+ 1

    xx0

    = f(n+1)()

    n! 0 (x x0)

    n+1

    n+ 1

    = (x

    x0)

    n+1

    (n+ 1)! f(n+1)(). (pointwise form)

    #24 For each function in Problem 11, use the Mean Value Theorem to finda value M such that

    |f(x1) f(x2)| M|x1 x2|that is valid for all x1, x2 in the interval used in Problem 11: 11(b)f(x) =ln(1 +x) on the interval [1, 1], 11(c) f(x) = sin(x) on the interval [0, ].

    Solution: From the notes,

    |f(x2) f(x1)| |f()| |x2 x1|.For 11(b): [x1, x2] = [1, 1] and [1, 1].

    f(x) = ln(1 +x) = f(x) = 11 +x

    = |f()| = 11 +

    11 1

    = So Mdoes not exist.

    For 11(c): [x1, x2] = [0, ] and [0, ].

    f(x) = sin(x) = f(x) = cos(x)= |f()| = | cos(x)| 1 =M

    5

  • 8/13/2019 Homework Solutions Math2130

    6/67

    #25 A function is called monotoneon an interval if its derivative is strictly

    positive or strictly negative on the interval. Suppose f is continuous andmonotone on the interval [a, b], andf(a)f(b)< 0; prove that there is exactlyone value [a, b] such that f() = 0.

    Solution: Iff is monotone on [a, b] and f(a)f(b)< 0 then either

    f(a)< 0 and f(b)> 0 or f(a)> 0 and f(b)< 0.

    Thus, as f C([a, b]), by the Intermediate Value Theorem[a, b] suchthat f() = 0.

    1.2 Error, etc.

    Page 19

    #1 Use Taylors Theorem to show that

    1 +x = 1 +

    1

    2x+ O(x2),

    for x sufficiently small.

    Solution: x0= 0 and

    f(x) = f(0) +xf(0) +x2

    2f(0) +...

    = f(0) +xf(0) +O

    (x2) (5)

    Calculating coefficients:

    f(x) = (1 +x)1

    2 = f(0) = 1f(x) =

    1

    2(1 +x)

    1

    2 = f(0) =12

    6

  • 8/13/2019 Homework Solutions Math2130

    7/67

    Substituting into (5) yields

    1 +x = 1 +

    12

    x+ O(x2).

    #2 Use Taylors Theorem to show that

    ex = 1 +x+ O(x2),for x sufficiently small.

    Solution: x0= 0 and

    f(x) = f(x) =ex

    = f(0) = f(0) = 1Thus, as in #1, ex = 1 +x+ O(x2).

    #3 Use Taylors Theorem to show that

    1 cos(x)x

    =1

    2x+ O(x3),

    for x sufficiently small.

    Solution: x0= 0 and

    cos(x) = 1 12!

    x2 + 1

    4!x4 ...

    = 1 cos(x) = 12!

    x2 14!

    x4 +...

    = 1 cos(x)x

    = 1

    2!x 1

    4!x3 +...

    = 1

    2x+ O(x3).

    #4 Show thatsin(x) =x + O(x3).

    Solution: x0= 0 and

    sin(x) =x 13!

    x3 +...= x+ O(x3).

    7

  • 8/13/2019 Homework Solutions Math2130

    8/67

    #6 Recall the summation formula

    1 +r+r2 +r3 +...+rn =n

    k=0

    fk =1 rn+1

    1 r .

    Use this to prove that

    nk=0

    rk = 1

    1 r + O(rn+1).

    Hint: What is the definition ofO notation?

    Solution: nk=0

    rk =1 rn+1

    1 r = 1

    1 r rn+1

    1 r , for|r|

  • 8/13/2019 Homework Solutions Math2130

    9/67

    for r=1

    e and n= 9.

    rn+1

    1 r = e10

    1 e1 = 7.2 105

  • 8/13/2019 Homework Solutions Math2130

    10/67

    1.3 Computer Arithmetic

    Page 27

    #2 Perform the indicated computations in each of three ways: (i) Exactly; (ii)Using 3 digit decimal arithmetic, with chopping; (iii) Using 3 digit decimalarithmetic, with rounding. For both approximations, compute the absoluteerror and the relative error.

    (a)1

    6+

    1

    10 (c)

    1

    7+

    1

    10

    +

    1

    9

    Solution:

    (a) (i) 16

    + 110

    = 0.26

    (ii)

    f l

    f l

    1

    6

    +f l

    1

    10

    = f l(f l(0.16) +f l(0.1))

    = f l(0.166 + 0.100)

    = f l(0.266)

    = 0.266 (chopping)

    absolute error = |0.26 0.266| = 0.0006relative error =

    0.0006

    0.26= 2.5 103 (2 significant figures)

    (iii)

    f l

    f l

    1

    6

    +f l

    1

    10

    = f l(f l(0.16) +f l(0.1))

    = f l(0.167 + 0.100)

    = f l(0.267)

    = 0.267 (rounding)

    absolute error = |0.26 0.267| = 3.3 104

    relative error = 0.0003

    0.26= 1.25 103 (2 significant figures)

    10

  • 8/13/2019 Homework Solutions Math2130

    11/67

    (c) (i) 1

    7

    + 1

    10 +1

    9

    = 0.3539682

    (ii)

    f l

    f l

    1

    7

    +f l

    1

    10

    = f l(f l(0.142) + 0.100)

    = f l(0.242)

    = 0.242

    so

    f l0.142 +f l1

    9 = f l(0.142 + 0.111)

    = f l(0.353)

    = 0.353 (chopping)

    absolute error = |0.3539682 0.353| = 9.683 104

    relative error = 9.683... 104

    0.3539682 = 2.735 103 (4 significant figures)

    (iii) Rounding obtained via the same method, but as f l

    1

    7

    = 0.143,

    this leads to the answer 0.354. Thus,

    absolute error = |0.3539682 0.354| = 3.175 105

    relative error = 3.175... 105

    0.3539682 = 8.969 105 (4 significant figures)

    #4 For f(x) = ex 1

    x , how many terms in the Taylor expansion are needed

    to get single precision accuracy (7 decimal digits) for all x

    0,1

    2

    ? How

    many terms are needed for double precision accuracy (14 decimal digits) overthis same range?

    Solution: Recall

    ex = 1 +x+x2

    2! +...+

    xn

    n! +

    xn+1

    (n+ 1)!e,

    11

  • 8/13/2019 Homework Solutions Math2130

    12/67

    for between 0 and x, and x

    0,1

    2. Rearranging:ex 1

    x = 1 +

    x

    2!+

    x2

    3! +...+

    xn1

    n! +

    xn

    (n+ 1)!e

    Rn(x)

    .

    For single precision (i.e., rounding to t= 7 decimal places) find n such that

    |Rn(x)| 5 108 ifn= 7). So we need 9 terms or n= 8.

    For double precision we need n such that

    |Rn(x)|

  • 8/13/2019 Homework Solutions Math2130

    13/67

    with 3digit decimal arithmetic yields 1 1020.

    #8 Assume we are using 3digit decimal arithmetic. For = 0.0001 anda1= 5, compute

    a2= a0+

    1

    a1

    for a0 equal to each of 1, 2, and 3. Comment.

    Solution:

    a0= 1

    f l12 = 1 105

    f l(5 105) = 50000f l(1 + 5 105) = f l(50001) = 50000.

    a0= 2

    ...fl(2 + 5 105) =f l(50002) = 50000

    a0= 3

    ...fl(3 + 5 105) =f l(50003) = 50000

    a2 is the same in all three cases.

    #12 What is the machine epsilon for a computer that usees binary arith-metic, 24 bits for the fraction, and rounds? What if it chops?

    Solution: = 2 and t= 24: From the lecture notes

    =1

    21t =

    1

    22124 = 0.596

    107 (rounding)

    = 1t = 2124 = 0.119 107 (chopping)

    13

  • 8/13/2019 Homework Solutions Math2130

    14/67

    2.1 Horners Rule

    Page 42

    #1(d) Write each of the following polynomials in nested form: (d) x3+3x+2.

    Solution: 2 + 3x+x3 = 2 +x(3 +x2).

    #2(a) Write each of the following polynomials in nested form, but this timetake advantage of the fact that they involve only even powers ofx to mini-

    mize the computations: (a) 1 12

    x2 + 1

    24x4.

    Solution:

    1 12

    x2 + 1

    24x4 = 1 +x2

    1

    2

    +

    1

    24x2

    .

    #3(a) Write each of the following polynomials in nested form: (a) 1 x2 +1

    2x4 1

    6x6.

    Solution:

    1 x2

    +

    1

    2 x4

    1

    6 x6

    = 1 +x2(1) +12x2 16 x4

    = 1 +x2

    (1) +x2

    1

    2

    1

    6

    x2

    Note: it takes longer to work out

    1 +x

    x

    1 +x

    x

    1

    21

    6x2

    .

    #7(b) Consider the polynomial

    p(x) = 1(x

    1) +

    1

    6

    (x

    1)(x

    2) +

    1

    7

    (x

    1)(x

    2)(x

    4).

    This can be written in nested-like form by factoring out each binomialterm as far as it will go, thus:

    p(x) = 1 + (x 1)

    1 + (x 2)

    1

    6+

    1

    7(x 4)

    .

    14

  • 8/13/2019 Homework Solutions Math2130

    15/67

    Write each of the following polynomials in this kind of nested form: (b)

    p(x) = 1 +67x 12 521 x 12 (x 4) +17 x 12 (x 4)(x 2).

    Solution:

    p(x) = 1 +67

    x 1

    2

    5

    21

    x 1

    2

    (x 4) +1

    7

    x 1

    2

    (x 4)(x 2)

    = 1 +

    x 12

    6

    7 5

    21(x 4) +1

    7(x 4)(x 2)

    = 1 +

    x 12

    6

    7+ (x 4)

    5

    21

    +

    1

    7(x 2)

    2.2 Difference Approximations

    Page 49

    #2(a), (d) Compute, by hand, approximations to f(1) for each of the fol-

    lowing functions, using h = 1

    16and each of the derivative approximations

    contained in (2.1) and (2.5): (a) f(x) = arctan(x), (d) f(x) =ex.

    Solution:

    For (a) f(x) = arctan(x)

    Forward Difference Approximation

    f(x+h) f(x)h

    = arctan

    1 + 116

    arctan(1)116

    = 0.8157

    4116

    = 0.485 f(1) (3 decimal places)

    Central Difference Approximation

    f(x+h) f(x h)2h

    = arctan

    1 + 1

    16

    arctan(1 116

    )216

    = 0.500 (3 decimal places)...which is better.

    15

  • 8/13/2019 Homework Solutions Math2130

    16/67

    Note that the answer in the book is wrong. Also, observe that f(x) =1

    x2 + 1 so f(1) = 0.5.

    For (d) f(x) =ex

    Forward Difference Approximation

    f(x+h) f(x)h

    = e(1+

    1

    16) e1116

    = 0.356 (3 decimal places)

    Central Difference Approximation

    f(x+h) f(x h)2h

    = e(1+

    1

    16) +e(1 1

    16)

    216

    = 0.368 (3 decimal places)...which is better.

    Observe that f(x) = ex so f(1) = e1 0.367 to 3 decimal places.

    #4 Use the approximations from this section to fill in approximations to themissing values in Table 2.4 (for x= 1 and x= 1.5).

    x f(x) f(x)

    1.00 1.00000000001.5 0.8862269255

    Solution: Using h= 0.1Forward Difference Approximation

    x= 1

    f(x+ 0.1) f(x)0.1

    =0.9513... 1.00

    0.1

    =

    0.486

    f(1) (3 decimal places)

    x= 1.5

    f(x+ 0.1) f(x)0.1

    =0.8935... 0.88622...

    0.1 = 0.0729 f(1.5) (3 decimal places)

    16

  • 8/13/2019 Homework Solutions Math2130

    17/67

    Centered Difference Approximation

    x= 1.5f(x+ 0.1) f(x)

    0.1 =

    0.8935... 0.8872...0.2

    = 0.0313 f(1.5) (3 decimal places)

    #5 Use the error estimate (2.5) for the centered approximation to the firstderivative to prove that this approximation will be exactfor any quadraticpolynomial.

    Solution: Let p(x) = a+ bx + cx2 so p(x) = b+ 2cx. Using the centereddifference approximation

    p(x+h)

    p(x

    h)

    2h = [a+b(x+h) +c(x+h)2]

    [a+b(x

    h) +c(x

    h)2]

    2h

    = 2bh+c(x+h)2 c(x h)2

    2h

    = b+ c

    2h[(x+h)2 (x h)2]

    = b+ c

    2h[(x2 + 2xh+h2) (x2 2xh+h2)]

    = b+4cxh

    2h= b+ 2cx

    = p

    (x

    ).

    #6(a) Find coefficientsA, B, andCso that (a)f(x) =Af(x) + Bf(x + h) +Cf(x+ 2h) + O(h2). Hint: Use Taylors theorem.

    Solution:

    f(x+h) =f(x) +hf(x) +h2

    2!f(x) +

    h3

    3!f(c1), (6)

    for c1 between x and x+h.

    f(x+ 2h) =f(x) + 2hf(x) +(2h)2

    2! f(x) +

    (2h)3

    3! f(c2), (7)

    for c2 between x and x+ 2h. Now computing 4(6)-(7) gives4f(x+h) f(x+ 2h) = 3f(x) + 2hf(x) + h

    3

    6[4f(c1) 8f(c2)]

    = 3f(x) + 2hf(x) +2h3

    3 [f(c1) 2f(c2)].

    17

  • 8/13/2019 Homework Solutions Math2130

    18/67

    So dividing by 2h yields:

    2h

    f(x+h) 12h

    f(x+ 2h) = 32h

    f(x) +f(x) + O(h2)or

    f(x) = 32h

    f(x) +2

    hf(x+h) 1

    2hf(x+ 2h) + O(h2).

    Thus A= 32h

    , B = 2

    h, and C= 1

    2h.

    #8 Use Taylors Theorem to show that the approximation

    f(x)

    8f(x+h) 8f(x h) f(x+ 2h) +f(x 2h)

    12h

    isO(h4).

    Solution: Expand to powers of h4 (with remainder termO(h5) as we thendivide by 12h:

    f(x+h) =f(x) +hf(x) +h2

    2!f(x) +

    h3

    3!f(x) +

    h4

    4!f(iv)(x) +

    h5

    5!f(v)(c1)

    f(x h) =f(x) hf(x) + h2

    2!f(x) h

    3

    3!f(x) +

    h4

    4!f(iv)(x) h

    5

    5!f(v)(c2)

    f(x+ 2h) = f(x) + 2hf(x) +(2h)2

    2! f(x) +

    (2h)3

    3! f(x) +

    (2h)4

    4! f(iv)(x) +

    (2h)5

    5! f(v)(c3)

    = f(x) + 2hf(x) + 2h2f(x) +4h3

    3 f(x) +

    2h4

    3 f(iv)(x) +

    4h5

    15f(v)(c3)

    f(x2h) =f(x)2hf(x)+2h2f(x) 4h3

    3 f(x)+

    2h4

    3 f(iv)(x) 4h

    5

    15f(v)(c4)

    Thus,

    8f(x+h) 8f(x h) f(x+ 2h) +f(x 2h) = 16hf(x) 4hf(x) + ch5

    = 12hf(x) + ch5,

    where cdepends on f(v)(ci) for i= 1, 2, 3, 4. So dividing by 12h yields

    8f(x+h) 8f(x h) f(x+ 2h) +f(x 2h)12h

    =f(x) +ch4,

    18

  • 8/13/2019 Homework Solutions Math2130

    19/67

    wherec= c

    12

    . Rearranging

    f(x) =8f(x+h) 8f(x h) f(x+ 2h) +f(x 2h)

    12h + O(h4).

    #10 Use the derivative approximation from Problem 8 to fill in as much aspossible of the table in Problem 4. (just do x= 1.2)

    Solution: With x= 1.2 and h= 0.1

    f(1.2) = 8f(1.2 + 0.1) 8f(1.2 0.1) f(1.2 + 0.2) +f(1.2 0.2)

    12(0.1)

    = 8f(1.3) 8f(1.1) f(1.4) +f(1.0)1.2

    = 8(0.89747...) 8(0.95135...) (0.88726...) + 1.0

    1.2= 0.265 (3 decimal places)

    #12 Use Taylor expansions for f(x h) to derive an O(h2) accurate approx-imation tof(x) usingf(x) andf(x h). Provide all the details of the errorestimate. Hint: Go out as far as the fourth derivative term, and then addthe two expansions.

    Solution: See class notes.

    2.3 Eulers Method

    Page 56

    #1 Use Eulers method with h = 0.25 to compute approximate solutionvalues for the initial value problem

    y = sin(t+y), y(0) = 1.

    You should get y4 = 1.851566895 (be sure that your calculator is set to radi-ans).

    19

  • 8/13/2019 Homework Solutions Math2130

    20/67

    Solution:

    yn+1 = yn+h sin(tn+yn)tn = nh= 0.25n

    So yn+1= yn= 0.25sin(0.25n+yn)y0 = y(0) = 1

    n= 0

    y1 = y0+ 0.25 sin(0 +y0)

    = 1 + 0.25 sin(1)

    = 1.2103677462...(

    y(0.25))

    n= 1

    y2 = y1+ 0.25 sin(0.25 +y1)

    = 1.45884498566...( y(0.5))n= 2

    y3 = y2+ 0.25 sin(0.5 +y2)

    = 1.6902572796...( y(0.75))n= 3

    y4 = y3+ 0.25 sin(0.75 +y3)

    = 1.85156689533...( y(1))#4 Use Eulers method with h = 0.25 to compute approximate solutionvalues for

    y= ety, y(0) = 1.What approximate value do you get for y(1) = 0.7353256638?

    Solution:

    yn+1 = yn+hf(tn, yn)= yn+ 0.25e

    tn+yn

    = yn+ 0.25e0.25nyn,

    withy0= y(0) = 1.

    20

  • 8/13/2019 Homework Solutions Math2130

    21/67

    n= 0

    y1 = y0+ 0.25e0y0

    = 1 + 0.25e1= 0.320429542885...( y(0.25))

    n= 1

    y2 = y1+ 0.25e0.25y1

    = 0.121827147394...( y(0.5))

    n= 2

    y3 = y2+ 0.25e0.5y2

    = 0.486730952236...( y(0.75))

    n= 3

    y4 = y3+ 0.25e0.75y3

    = 0.812025139875...( y(1))

    #6 Repeat the above with h = 0.125. What value do you now get fory8 y(1)?

    Solution:

    yn+1 = yn+hf(tn, yn)

    = yn+ 0.125etn+yn

    = yn+ 0.125e0.125nyn,

    withy0= y(0) = 1.

    n= 0

    y1 = y0+ 0.125e0y0

    = 0.660214771443...( y(0.125))

    21

  • 8/13/2019 Homework Solutions Math2130

    22/67

    n= 1

    y2 = y1+ 0.125e0.125y1

    = 0.38610503923...( y(0.25))

    n= 2

    y3 = y2+ 0.125e0.25y2

    = 0.149966473291...( y(0.375))

    n= 3

    y4 = y3+ 0.125e0.375y3

    = 0.061333798435...( y(0.5))

    n= 4

    y5 = y4+ 0.125e0.5y4

    = 0.255163498508...( y(0.625))

    n= 5

    y6 = y5+ 0.125e0.625y5

    = 0.436100739954...( y(0.75))

    n= 6

    y7 = y6+ 0.125e0.75y6

    = 0.607194720154...( y(0.875))

    n= 7

    y8 = y7+ 0.125e0.875y7

    = 0.770581294899...( y(1))

    22

  • 8/13/2019 Homework Solutions Math2130

    23/67

    2.4 Linear Interpolation

    Page 62

    #1(a) Use linear interpolation to find approximations to the following valuesof the error function, using the table in the text. For each case, give an upperbound on the error in the approximation: (a) erf(0.34).

    Solution: Set f(x) = erf(x) and choose x0 = 0.3, and x1 = 0.4 so that[a, b] = [0.3, 0.4].

    P1(x) = x x1x0 x1 f(x0) + x x0x1 x0 f(x1).

    With x= 0.34,

    P1(0.34) = 0.6(0.3286...)+0.4(0.4283...) = 0.3685 (2 significant figures).

    For the error in the approximation we need the 2nd derivative off(x) = erf(x).From the argument on p.61 of the text

    f(x) = 4x

    ex2

    .

    Without resorting to a graphical approach this is difficult to bound. A crudeupper bound is

    |f(x)| 4(0.4)

    e(0.3)2

    = 0.8250087277,

    where we have bounded using max (numerator)

    min (denominator) and the fact that y1 = x

    is increasing on [0.3, 0.4] andy2= ex2 is decreasing on [0.3, 0.4]. Thus from

    the error bound formula

    |f(x) P1(x)| M

    8(x1 x0)2

    = 0.250087277

    8 (0.4 0.3)2

    = 0.001031 (4 significant figures),

    23

  • 8/13/2019 Homework Solutions Math2130

    24/67

    whereM= max |f(x)| for all x [x0, x1].

    Check: using erf(x) = 2

    x0

    et2

    dt on my TI-89 graphing calculator I

    get

    |f(x) P1(x)| = 2

    0.340

    et2

    dt 0.3685329977

    = |0.369364529345... 0.3685329...|= 0.000831...,

    consistent with our result above.

    #2 The gamma function, denoted by (x), occurs in a number of applica-tions, most notably probability theory and the solution of certain differentialequations. It is basically the generalization of the factorial function to non-integer values, in that (n+ 1) = n!. Table 2.8 gives values of (x) for xbetween 1 and 2. Use linear interpolation to approximate values of (x) asgiven below. (a) (1.005) = 0.9971385354

    x (x)

    1.00 1.00000000001.10 0.9513507699

    1.20 0.91816874241.30 0.89747069631.40 0.88726381751.50 0.88622692551.60 0.89351534931.70 0.90863873291.80 0.93138377101.90 0.96176583192.00 1.000000000

    Solution: Choosex0= 1.00 and x1 = 1.10. Set f(x) = (x).

    P1(x) = x x1

    x0 x1

    f(x0) +x x0

    x1 x0

    f(x1).

    With x= 1.005

    P1(1.005) = 0.95(1.00)+0.05(0.9513507699) = 0.9976 (4 significant figures).

    24

  • 8/13/2019 Homework Solutions Math2130

    25/67

    #4 Construct a linear interpolating polynomial to the function f(x) = x1

    using x0 = 1

    2 and x1 = 1 as nodes. What is the upper bound on the error

    over the interval

    1

    2, 1

    , according to the error estimate?

    Solution:

    P1(x) =

    x x1x0 x1

    f(x0) +

    x x0x1 x0

    f(x1)

    =

    x 112 1

    1

    2

    1+

    x 1

    2

    1 12

    11

    = 3

    2x.

    For the error bound we need f(x):

    f(x) = x2 and f(x) = 2x3 = 2x3

    .

    We need an upper bound for f(x) on

    1

    2, 1

    . Noting thatx3 is increasing

    on

    1

    2, 1

    = 2

    x3 is decreasing on

    1

    2, 1

    and positive throughout, thus

    |f(x)

    |= 2

    |x3

    | 2

    1

    23

    = 2 (21)3= 2(8) = 16 = M .So using the error bound formula

    |f(x) P1(x)| M8

    (x1 x0)2 =168

    1 1

    2

    2= 2

    1

    4

    =

    1

    2.

    #6 Repeat the above for f(x) =x1

    3 , using the interval

    1

    8, 1

    .

    Solution:

    P1(x) = x x1x0 x1 f(x0) +

    x x0x1 x0 f(x1)

    =

    x 118 1

    1

    8

    13

    +

    x 1

    8

    1 18

    11

    3

    = 4

    7x+

    3

    7 or

    1

    7(4x+ 3).

    25

  • 8/13/2019 Homework Solutions Math2130

    26/67

    Now

    f(x) =1

    3 x2

    3 and f(x) = 2

    9 x5

    3 = 2

    9x5

    3 .

    Where is |f(x)| a maximum on

    1

    8, 1

    ? f(x) is monotonic (doesnt change

    sign) on

    1

    8, 1

    , so check value at endpoints:

    f

    1

    8

    = 7.1 and f(1) = 0.2

    =

    |f(x)

    | 7.1 =M. Thus from the error bound formula

    |f(x) P1(x)| M8

    (x1 x0)2 =7.18

    1 1

    8

    2= 0.6806 (4 significant figures)

    2.5 Trapezoid Rule

    Page 70

    #1 Apply the trapezoid rule with h=1

    8, to approximate the integral

    I= 10

    11 +x4

    dx= 0.92703733865069.

    How small does h have to be to get that the error is less that 103? 106?

    Solution:

    f(x) = 11 +x4

    , h=1

    8, [a, b] = [0, 1], n=

    b ah

    =1 0

    18

    = 8.

    26

  • 8/13/2019 Homework Solutions Math2130

    27/67

    i xi f(xi)

    0 0 11 18

    0.99987...2 14 0.99805...3 3

    8 0.99025...

    4 12 0.97014...5 5

    8 0.93145...

    6 34 0.87157...7 7

    8 0.79400...

    8 1 0.70710...

    T8(f) = 12h(f(x0) + 2f(x1) +...+ 2f(x7) +f(x8))

    =

    1

    2

    1

    8

    (1 + 2(0.99987...) + 2(0.99805...) +...+ 2(0.79400...) + 0.70710...)

    = 0.926115180158...

    In order to estimate the error we need the 2nd derivative off(x) = (1+x4)1

    2 .

    f(x) = 12

    (1 +x4)3

    2 4x3 = 2x3(1 +x4) 32 .

    Using the product rule we can show that

    f(x) =6x2(x4 1)

    (x4 + 1)5

    2

    .

    This is a complicated function to get an upper bound on. We would use acombination of calculus and curve sketching techniques to deduce the follow-ing diagram:

    27

  • 8/13/2019 Homework Solutions Math2130

    28/67

    Alternatively, you could get an upper bound by maximizing and minimizingthe numerator and denominator in f respectively. (Note: I wouldnt giveyou one as complicated as this in our tests!) Now recall from lecture notes

    that to get an error 103 we require

    |I(f) Tn(f)| b a12

    h2M= h2

    12(1.39275) 103, (8)

    where M = max |f(x)| for all x [a, b] (as indicated in the diagram).Rearranging, we require

    h2 0.08616047... or h 0.0928227...

    But h must divide b a= 1, so as

    n= b ah

    or h= b an

    = 1n 0.0928227...

    = n 10.77The book would stop here.

    28

  • 8/13/2019 Homework Solutions Math2130

    29/67

    so choose n= 11 =

    h=

    1

    n= 0.09. As in (8) we seek h such that

    h2

    12(1.39275) 106 or h2 8.616047 106 so h 0.0029353104.

    As before

    h= 1

    n 0.0029353104...= n 340.679...

    so with n= 341, = h= 1n

    = 0.00293255132...

    #2 Use the trapezoid rule with h=

    4, to approximate the integral

    I= 20

    sin(x) dx= 1.

    How small does h have to be to get that the error is less that 103? 106?

    Solution:

    f(x) = sin(x), h=

    4, [a, b] =

    0,

    2

    , n=

    b ah

    =2 04

    = 2.

    i xi f(xi)

    0 0 0

    1 4

    12

    2 2 1

    T2(f) = 1

    2h(f(x0) + 2f(x1) +f(x2))

    =

    1

    2

    4

    0 +

    22

    + 1

    =

    2 + 1

    8

    0.948059...

    (Note: exact answer is 1.)In order to estimate the error we need the 2nd derivative off(x) = sin(x).

    f(x) = cos(x) and f(x) = sin(x)

    29

  • 8/13/2019 Homework Solutions Math2130

    30/67

    Thus|f(x)| = | sin(x)| 1 =M on 0,

    2 .From the error bound formula we need|I(f) Tn(f)| b a

    12 h2M=

    2

    12h2 1 =

    24h2 103 (9)

    = h2 0.007639437... so h 0.08740387...

    But h must divide b a= 2

    , so noting that h= b a

    n =

    2

    n 0.08740387...

    = n 17.97.

    So choosen

    = 18 =h

    =

    2

    n = 0.087266

    ....

    From (9) we also seek h such that

    24h2 106

    = h2 7.639... 106= h 0.002763953...

    As before

    h=2

    n 0.002763953... = n 568.315...

    Choosing n= 569 = h=2

    569= 0.0027606...

    #4 Apply the trapezoid rule with h=1

    8, to approximate the integral

    I=

    10

    x(1 x2) dx= 14

    .

    Feel free to use a computer program or a calculator, as you wish. How smalldoesh have to be to get that the error is less than 103? 106?

    Solution:

    f(x) =x(1x2), h= 18

    , [a, b] = [0, 1], n= b a

    h =

    1 018

    = 8.

    30

  • 8/13/2019 Homework Solutions Math2130

    31/67

    i xi f(xi)

    0 0 01 18

    63512

    2 141564

    3 38

    165512

    4 1238

    5 58

    195512

    6 342164

    7 78

    105512

    8 1 0

    T8(f) = 1

    2 h(f(x0) + 2f(x1) +...+ 2f(x7) +f(x8))

    =

    1

    2

    1

    8

    (0 + 2

    63

    512

    + 2

    15

    64

    +...+ 2

    105

    512

    + 0)

    = 63

    256= 0.2461 (4 significant figures)

    Note: exact answer is 1

    4

    . In order to estimate the error we need the 2nd

    derivative off(x) =x(1 x2).f(x) = 1 3x2 = f(x) = 6x.

    So|f(x)| = 6|x| 6 =Mon [0, 1]. From the error bound formula we needh such that

    |I(f) Tn(f)| b a12

    h2M= h2

    12(6) 103, (10)

    Rearranging, we require

    h2 0.002 or h 0.0447213595...

    But h must divide b a= 1, so ash=

    b an

    = 1

    n 0.0447213595...

    = n 22.36...

    31

  • 8/13/2019 Homework Solutions Math2130

    32/67

    so choose n= 23 =

    h=

    1

    23 = 0.04347826. For an error less than 106 we

    needh such that

    |I(f) Tn(f)| b a12

    h2M= h2

    12(6) 106

    Rearranging, we require

    h2 2 106 or h 0.00141421356...

    As before

    h= 1

    n 0.00141421356...= n 707.106...

    so with n= 708, = h= 1708

    = 0.00141242937...

    #6 Apply the trapezoid rule with h=1

    8, to approximate the integral

    I=

    10

    ln(1 +x) dx= 2 ln(2) 1.

    How small does h have to be to get that the error is less than 103? 106?

    Solution:

    f(x) = ln(1+x), h=1

    8, [a, b] = [0, 1], n=

    b ah

    =2 1

    18

    = 8.

    i xi f(xi)

    0 0 01 18 ln

    98

    2 1

    4 ln

    54

    3 3

    8 ln

    118

    4 12 ln

    325 58 ln 138 6 34 ln 74

    7 78

    ln158

    8 1 ln(2)

    32

  • 8/13/2019 Homework Solutions Math2130

    33/67

    T8(f) = 1

    2h(f(x0) + 2f(x1) +...+ 2f(x7) +f(x8))

    =

    1

    2

    1

    8

    0 + 2 ln

    9

    8

    + 2ln

    5

    4

    +...+ 2 ln

    15

    8

    + ln(2)

    = 0.3856 (4 significant figures)

    (Note: exact answer is 0.3863 to 4 significant figures). In order to estimatethe error we need the 2nd derivative off(x) = ln(1 +x).

    f(x) = 1

    1 +x= f(x) = 1

    (1 +x)2.

    So|

    f(x)|=

    1

    (1 +x)2 1

    (1 + 0)2 = 1 = M on [0, 1]. From the error bound

    formula we need h such that

    |I(f) Tn(f)| b a12

    h2M= h2

    12(1) 103, (11)

    Rearranging, we require

    h2 0.012 or h 0.10954451150...But h must divide b a= 1, so as

    h= b a

    n =

    1

    n0.10954451150...

    = n 9.12...so choose n= 10 = h = 1

    10 = 0.1. For an error less than 106 we need h

    such that

    |I(f) Tn(f)| b a12

    h2M= h2

    12(1) 106

    Rearranging, we require

    h2 1.2 105 or h 0.003464101615...

    As beforeh=

    1

    n 0.003464101615...= n 288.67...

    so with n= 289, = h= 1289

    = 0.0034602076...

    33

  • 8/13/2019 Homework Solutions Math2130

    34/67

  • 8/13/2019 Homework Solutions Math2130

    35/67

    Back substitution yields:

    x1 = 0.008495 x2= 0.1575 x3 = 0.2274 x4= 0.2009(each to 4 significant figures).

    #6 Use the tridiagonal algorithm in this section to solve the following systemof equations:

    1 12 0 012

    13

    14

    00 14

    15

    16

    0 0 16

    17

    x1x2x3x4

    =

    2253301514

    Note that this is a very small change from the previous problem, since theonly difference is that f2 has changed by only

    1

    12. How much has the answer

    changed?

    Solution:

    1 12 0 012

    13

    14

    00 14

    15

    16

    0 0 16

    17

    2253301514

    r2 12r1 r2

    1 12 0 00 1

    1214

    00 14

    15

    16

    0 0 16

    17

    2153301514

    r3 3r2 r3

    1 12 0 00 112

    14 0

    0 0 1120

    16

    0 0 1617

    21

    3730

    1514

    r4+ 1033

    r3 r4

    1 12

    0 00 112

    14 0

    0 0 1120

    16

    0 0 0 134693

    21

    3730

    9671386

    The associated linear system is:x1 +

    12

    x2 = 2112

    x2 + 1

    4x3 = 1

    1120x3 +

    16x4 = 3730

    134693

    x4 = 9671386

    35

  • 8/13/2019 Homework Solutions Math2130

    36/67

    Back substitution yields:

    x1= 1.004 x2 = 1.993 x3= 3.336 x4= 3.608

    (each to 4 significant figures).

    #8 Verify that the following system is diagonally dominant and use thealgorithm of this section to find the solution.

    12

    1021 0 0

    14

    13

    113

    00 15

    14

    121

    0 0 15

    16

    x1x2x3x4

    =

    61421791565634201310

    Solution: Checking for diagonal dominance:

    0.5 = 1

    2 >

    10

    21= 0.4761...

    0.3 = 1

    3 >

    1

    4+

    1

    13=

    17

    52= 0.3269...

    0.25 = 1

    4 >

    1

    5+

    1

    21=

    26

    105= 0.247...

    0.16 = 1

    6 h2 1

    ?Recall the triangle inequality, namely

    |a+b

    | |a

    |+

    |b

    |,

    so h2 1 =

    h2+ (1) h2+ 1 < 2 < 2 + h2 = |2 +h2|

    1Note: this problem is harder than I would give you in an exam!

    40

  • 8/13/2019 Homework Solutions Math2130

    41/67

    Middle equations: Is|2 +h2| h2

    + 1+ h2 1? First observe thath

    2 1< 0 as h

  • 8/13/2019 Homework Solutions Math2130

    42/67

    so by the IMVT a root offexists in [1, 1.5]. Set x3=1 + 1.5

    2 = 1.25.

    #2(a) For each of the functions listed below, do a calculation by hand (i.e.with a calculator) to find the root to an accuracy of 0 .1. This process willtake at most five iterations for all of these, and fewer for several of them: (a)f(x) =x ex2, for [a, b] = [0, 1].

    Solution: Need k such that

    | xk| b a2k

  • 8/13/2019 Homework Solutions Math2130

    43/67

    3.2 Newtons Method

    Page 99

    #1 Write down Newtons method as applied to the function f(x) = x3 2.Simplify the computation as much as possible. What has been accomplishedif we find the root of this function?

    Solution:f(x) =x3 2 = f(x) = 3x2.

    Thus

    xn+1 = xn f(xn)f(xn)

    = xn (x3n 2)3x2n

    = 2(x3n+ 1)

    3x2n,

    wherex0 is given. If we find a root offwe have found the cube root of 2.

    #4 Write down Newtons method as applied to the function f(x) =a x1.Simplify the resulting computation as much as possible. What has been ac-

    complished if we find the root of this function?

    Solution:

    f(x) =a x1 =a 1x

    = f(x) =x2 = 1x2

    .

    Thus

    xn+1 = xn f(xn)f(xn)

    = xn

    (a 1xn

    )1

    x2n

    = xn(2 axn),

    wherex0 is given. A root off corresponds to a= 1

    x, or x=

    1

    a, a = 0.

    43

  • 8/13/2019 Homework Solutions Math2130

    44/67

    #6 Do three iterations of Newtons method for f(x) = 3 ex, using x0= 1.Repeat, using x0= 2, 4, 8, 16. Comment on your results.

    Solution:f(x) = 3 ex = f(x) = ex.

    Thus

    xn+1 = xn f(xn)f(xn)

    = xn

    3 exnexn

    = [(xn 1)exn

    + 3]exn

    ,

    x0= 1

    x1 = [(1 1)e1 + 3]e1= 3e1

    = 1.103...

    x2 = 1.098...

    x3 = 1.0986122...

    x0= 2

    x1 = [(2 1)e2 + 3]e2= 1.406...

    x2 = 1.141...

    x3 = 1.0995133...

    x0= 4

    x1 = [(4 1)e4 + 3]e4

    = 3.054...x2 = 2.196...

    x3 = 1.529...

    44

  • 8/13/2019 Homework Solutions Math2130

    45/67

  • 8/13/2019 Homework Solutions Math2130

    46/67

    3.3 How to Stop Newtons Method

    Page 102

    #1 Under the assumption that f() = 0 and xn , prove (3.10); be sureto provide all the details. Hint: Expand f and f in Taylor series aboutx= .

    Solution: From the lecture notes we have

    xnxn+1 xn = en

    f(xn)f(xn)

    = en f(+en)f(+en)

    = en

    f() +enf() +e2n

    f()2!

    +...

    f() +enf() +e2n

    f()2! +...

    =

    f() +enf() +e2nf()2!

    +...

    f() +enf()2!

    +e2nf()3!

    +...

    Thus

    limn

    xnxn+1 xn

    =

    limn

    f() +enf() +e2n f()2! +...limn

    f() +en

    f()2!

    +e2nf()

    3! +...

    =f() + lim

    nenf

    () + limn

    e2nf()

    2! +...

    f() + limn

    enf()

    2! + lim

    ne2n

    f()3!

    +...

    =f() +f() lim

    nen+

    f()2!

    limn

    e2n+...

    f() + f()2!

    limn en+ f

    ()3!

    limn e

    2n+...

    = f() + 0 + 0 +...

    f() + 0 + 0 +...= 1,

    46

  • 8/13/2019 Homework Solutions Math2130

    47/67

    where we used the fact that

    limn

    en = limn

    (xn ) = 0.

    #4 Figure 3.5 shows the geometry of a planetary orbit around the sun. Theposition of the sun is given by S, the position of the planet is given by P. Letxdenote the angle defined by P0OA, measured in radians. The dotted line isa circle concentric to the ellipse and having a radius equal to the major axisof the ellipse. Let Tbe the total orbital period of the planet, and let t bethe time required for the planet to go from A to P. Then Keplers equationfrom orbital mechanics, relating xand t, is

    x

    sin(

    x) =

    2t

    T .

    Hereis the eccentricity of the elliptical orbit (the extent to which it deviatesfrom a circle). For an orbit of eccentricity = 0.01 (roughly equivalent to

    that of the Earth), what is the value ofx corresponding to t= T

    4? What is

    the value ofx corresponding to t = T

    8? Use Newtons method to solve the

    required equation.

    Figure 3.5 Orbital geometry for Problems 4 and 5

    47

  • 8/13/2019 Homework Solutions Math2130

    48/67

    Solution: = 0.01 and t=T

    4

    leads to

    x 0.01 sin(x) =2T4

    T =

    2.

    Set f(x) =x 0.01 sin(x) 2 , then

    f(0) = 2 0

    so by the IMVT a root [0, ]. Set x0= 2

    . Newtons method is:

    xn+1 = xn f(xn)f(xn)

    = xn

    xn 0.01 sin(xn) 2

    (1 0.01 cos(xn))=

    xncos(xn) sin(xn) 50cos(xn) 100

    Iterating with x0=

    2:

    n = 0 x1

    = 1.5807963267...

    n = 1 x2= 1.5807958268...

    n = 2 x3= 1.5807958268...

    The method for t=T

    8is done in the same way.

    3.8 Secant Method

    Page 123

    #1 Do three steps of the secant method for f(x) = x3 2, using x0 = 0,x1 = 1.

    48

  • 8/13/2019 Homework Solutions Math2130

    49/67

    Solution: The question allows us to approximate the cube root of 2 since

    f(x) = 0 = x= 3

    2. The secant method is:xn+1 = xn f(xn)

    xn xn1

    f(xn) f(xn1)

    = xn (x3n 2)

    xn xn1(x3n 2) (x3n1 2)

    = xn (x3n 2)

    xn xn1x3n x3n1

    (22)

    Nowb3 a3

    b

    a

    =b2 +ab+a2,

    so with b= xn and a= xn1 we havex3n x3n1xn xn1 =x

    2n+xnxn1+x

    2n1

    soxn xn1x3n x3n1

    = 1

    x2n+xnxn1+x2n1

    .

    Substituting this into (22) yields:

    xn+1= xn (x3n 2)

    x2n+xnxn1+x2n1

    (23)

    Doing 3 steps of (23) (withx

    0 = 0 andx

    1= 1)n= 1

    x2 = x1 (x31 2)

    (x21+x0x1+x20)

    = 1 (13 2)

    (12 + (0)(1) + 02)= 2

    n= 2

    x3 = x2

    (x32 2)

    (x22+

    x1

    x2+

    x21)

    = 2 (23 2)

    (22 + (1)(2) + 12)

    = 8

    7 or 1.14286 (6 significant figures)

    49

  • 8/13/2019 Homework Solutions Math2130

    50/67

  • 8/13/2019 Homework Solutions Math2130

    51/67

    n= 1

    x2 = ln(1 + 0.405465108108...)

    = 0.340368285804...

    n= 2

    x3 = ln(1 + 0.340368285804...)

    = 0.292944416354...

    #2 Let Y = 1

    2 be fixed, and take h =

    1

    8. Do three steps of the following

    fixed point iteration

    yn+1= Y +1

    2h(Y ln(Y) ynln(yn))

    using y0 = Y.

    Solution: With Y =1

    2 and h=

    1

    8we have

    yn+1=1

    2+

    1

    16

    1

    2ln

    1

    2

    ynln(yn)

    .

    Using y0= Y =1

    2we have

    n= 0

    y1 = 1

    2+

    1

    16

    1

    2ln

    1

    2

    y0ln(y0)

    = 1

    2+

    1

    16

    1

    2ln

    1

    2

    1

    2ln

    1

    2

    = 1

    2+

    1

    16ln

    1

    2

    = 0.543321698785...

    n= 1

    y2 = 1

    2+

    1

    16

    1

    2ln

    1

    2

    y1ln(y1)

    = 0.542376812253...

    51

  • 8/13/2019 Homework Solutions Math2130

    52/67

    n= 2

    y3 = 1

    2+

    116

    1

    2ln1

    2

    y2ln(y2)

    = 0.54239978931...

    #4 Consider the fixed point iteration xn+1 = 1 +exn. Show that this it-

    eration converges for any x0 [1, 2]. How many iterations does the theorypredict it will take to achieve 105 accuracy?

    Solution: Observe that with g(x) = 1 +ex

    g(1) = 1.367... [1, 2]g(2) = 1.135... [1, 2]

    and as g(x) is monotonically decreasing on [1, 2] we know that 1 g(x) 2for all x [1, 2], i.e. g : [1, 2] [1, 2]. To show the second condition ofTheorem 3.5 consider

    |g(x)| = |ex| |e1| = 0.367< 1,

    for all x (1, 2), as ex is decreasing. Thus by Theorem 3.5 the iterationconverges for all x0 [1, 2]. We apply the error bound formula

    |xn |

    Ln

    1 L

    (x1 x0),

    whereL=1

    e = 0.367...and

    x0 = 1.5

    x1 = 1 +ex0

    = 1 +e1.5

    = 1.22313016015...,

    so we seek n such that 1e

    n1 1

    e

    (1.2231... 1.5)< 105

    52

  • 8/13/2019 Homework Solutions Math2130

    53/67

    or en < 2.2830965... 105so n < ln(2.2830965... 105)

    or n > 10.687..

    so take n= 11.

    #5(a)(c) For each function listed below, find an interval [a, b] such thatg([a, b]) [a, b]. Draw a graph of y = g(x) and y = x over this interval,and confirm that a fixed point exists there. Estimate (by eye) the valueof the fixed point, and use this as a starting value for a fixed point iter-

    ation. Does the iteration converge? Explain: (a) g(x) = 12

    x+2

    x

    , (c)

    g(x) = 1 +ex.

    Solution:(a) Not straightforward. Need to do some curve sketching. Notice first thatwe can work the fixed points out exactly, as for

    g(x) =1

    2x+

    1

    x=x = 1

    x=

    1

    2x or 2 =x2 or x=

    2.

    Focus on the fixed point at x = 2. Noticeg(2) = 2 gives that (2, 2)is on the graph ofg. Now

    g(x) =1

    2 1

    x2 = 0 = x=

    2

    are critical points. Maxima, minima, or inflection points? Look at the secondderivative.

    g(x) = 2

    x3 = g(

    2) =

    2

    23

    2

    >0

    so ((2),

    2) is a local minimum. Notice also that

    limx+

    g(x) = + and limx

    g(x) = .

    This information leads to the following graph:

    53

  • 8/13/2019 Homework Solutions Math2130

    54/67

    Since g(1) = 1.5 =g(2), thus

    2 g(x) 1.5 for all x [1, 2]1 g(x) 1.5 for all x [1, 2]

    Thus, condition (i) in Theorem 3.5 is satisfied with [a, b] = [1, 2]. To satisfythe second condition we need to show that |g(x)|

  • 8/13/2019 Homework Solutions Math2130

    55/67

    Nowg(1) = 1 +e1 1.136...g(2) = 1 +e

    2

    1.135... and as g(x) is decreasing,

    1 g(x) 2 for all x [1, 2]

    i.e. g: [1, 2] [1, 2] and so condition (i) in Theorem 3.5 is satisfied. To satisfy(ii), consider g(x) =ex so|g(x)| = ex, which again is a decreasingfunction. And so as

    |g(1)| =e1 0.367...|g(2)| =e2 0.135...

    = |g(x)|

  • 8/13/2019 Homework Solutions Math2130

    56/67

  • 8/13/2019 Homework Solutions Math2130

    57/67

    Solution: To find P2(x) first find the Lagrange basis functions:

    L0(x) = (x x1)(x x2)(x0 x1)(x0 x2)=

    (x 1)(x 2)(0 1)(0 2) =

    1

    2(x 1)(x 2)

    L1(x) = (x x0)(x x2)(x1 x0)(x1 x2)=

    (x 0)(x 2)(1 0)(1 2) = x(x 2)

    L2(x) = (x x0)(x x1)(x2 x0)(x2 x1)=

    (x 0)(x 1)(2 0)(2 1) =

    1

    2x(x 1)

    Thus,

    P2(x) = f(x0)L0(x) +f(x1)L1(x) +f(x2)L2(x)

    = x(x 2) + (8)12 x(x 1)

    = x(3x 2)The sketch is difficult to draw as both graphs match well over the specifiedinterval:

    57

  • 8/13/2019 Homework Solutions Math2130

    58/67

    #4 Construct the quadratic polynomial that interpolates y =

    x at the

    nodesx0=1

    4, x1 =

    9

    16 and x2= 1.

    Solution: To find P2(x) first find the Lagrange basis functions:

    L0(x) = (x x1)(x x2)(x0 x1)(x0 x2) =

    x 9

    16

    (x 1)

    14 9

    16

    14 1 =6515

    x 9

    16

    (x 1)

    L1(x) = (x x0)(x x2)(x1 x0)(x1 x2) =

    x 1

    4

    (x 1)

    916

    14

    916

    1 = 25635

    x 14

    (x 1)

    L2(x) = (x x0)(x x1)(x2

    x0)(x2

    x1)

    = x 1

    4

    x 9

    16

    1 14 1 916 =

    64

    21 x 1

    4x 9

    16Thus,

    P2(x) = f(x0)L0(x) +f(x1)L1(x) +f(x2)L2(x)

    =

    1

    2

    64

    15

    x 9

    16

    (x 1) +

    3

    4

    256

    35

    x 1

    4

    (x 1)

    +(1)

    64

    21

    x 1

    4

    x 9

    16

    = after much tedious simplification

    = 32105 x2 + 2221x+ 935#6 Find the polynomial of degree 3 that interpolates y = x3 at the nodesx0 = 0, x1 = 1, x2 = 2 and x3 = 3. (Simplify your interpolating polynomialas much as possible.) Hint: This is easy if you think about the implicationsof the uniqueness of the interpolating polynomial.

    Solution: From our lecture notes we know that for distinct nodes, the inter-polating polynomial is unique. Thus the cubic polynomial that interpolatesthe cubic x3 at x0 = 0, x1 = 1, x2 = 2 and x3 = 3 must be x

    3! We will do

    58

  • 8/13/2019 Homework Solutions Math2130

    59/67

    the calculation nonetheless.

    L0(x) = (x x1)(x x2)(x x3)(x0 x1)(x0 x2)(x0 x3)=

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

    16

    (x 1)(x 2)(x 3

    L1(x) = (x x0)(x x2)(x x3)(x1 x0)(x1 x2)(x1 x3)=

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

    1

    2x(x 2)(x 3)

    L2(x) = (x x0)(x x1)(x x3)(x2 x0)(x2 x1)(x2 x3)=

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

    1

    2x(x 1)(x 3)

    L3(x) = (x x0)(x x1)(x x2)(x3 x0)(x3 x1)(x3 x2)=

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

    1

    6x(x 1)(x 2)

    Thus, after setting f(x) =x3

    P3(x) = f(x0)L0(x) +f(x1)L1(x) +f(x2)L2(x) +f(x3)L3(x)

    = 0 +1

    2x(x 2)(x 3) + (8)

    1

    2

    x(x 1)(x 3) + (27)

    1

    6

    x(x 1)(x 2)

    = x3 (after much simplification)

    4.3 Interpolation Error

    Page 180

    #1 What is the error in quadratic interpolation to f(x) = x, using equallyspaced nodes on the interval

    1

    4, 1

    ?

    Solution: From lecture notes we have

    |f(x) P2(x)| h3

    9

    3M,

    whereM= maxx(x0,x2)

    |f(x)|. Here f(x) = xand h= 1 14

    2 =

    3

    4 1

    2=

    3

    8, so

    x0 =1

    4 x1=

    1

    4+

    3

    8=

    5

    8 x2 =

    5

    8+

    3

    8= 1.

    59

  • 8/13/2019 Homework Solutions Math2130

    60/67

    Also

    f(x) =x 12 = f(x) =12

    x 12

    = f(x) = 14

    x3

    2

    = f(x) =38

    x5

    2 ,

    which is a decreasing function on

    1

    4, 1

    . Thus

    |f(x)| 38

    1

    4 5

    2

    = 3

    8 45

    2 = 3

    8 (32) = 12 =M ,for all x

    1

    4, 1

    . Thus

    |f(x) P2(x)| 38

    39

    3(12) =

    3

    3

    128 = 0.0406 (3 significant figures).

    #2 Repeat the above for f(x) =x1 on

    1

    2, 1

    .

    Solution: Proceed as in #1.

    f(x) =x1 and h=1 12

    2 =

    1

    4, so

    x0=1

    2 x1=

    3

    4 x2 = 1.

    Also

    f(x) =x1 = f(x) = x2= f(x) = 2x3= f(x) = 6x4.

    So

    |f(x)

    |=

    6

    |x|4= 96 = M , for all x

    1

    2, 1 .

    Thus using the error estimate given at the start of #1 we have

    |f(x) P2(x)| 14

    39

    3(96) =

    3

    18 = 0.0962 (3 significant figures).

    60

  • 8/13/2019 Homework Solutions Math2130

    61/67

    4.6 Hermite Interpolation

    Page 192

    #1 Construct the cubic Hermite interpolate to f(x) =

    1 +x using thenodes a = 0 and b = 1. Plot the error between the interpolate and thefunction.

    Solution: f(x) = (1 +x)1

    2 = f(x) =12

    (1 +x)1

    2 . Then

    L1(x) = x x2

    x1

    x2

    = x 10

    1

    = 1 x

    L2(x) = x x1

    x2 x1 = x 01 0 =x

    withL1(x) = 1 and L2(x) = 1. Now

    h1(x) = [1 2(x x1)L1(x1)]L21(x)= [1 2(x 0)(1)](1 x)2= (1 + 2x)(1 x)2 (24)

    h2(x) = [1 2(x x2)L2(x2)]L22(x)= [1

    2(x

    1)(1)]x2

    = (3 2x)x2 (25)h1(x) = (x x1)L21

    = (x 0)(1 x)2= x(1 x)2 (26)

    h2(x) = (x x2)L22(x)= (x 1)x2 (27)

    Using (24)-(27) we have

    H(x) = f(x1)h1(x) +f(x1)h1(x) +f(x2)h2(x) +f

    (x2)h2(x)

    = 11

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

    x(1 x)2 + 2 12 (3 2x)x2 +12

    21

    2 (x 1)x2

    = (after simplifying)

    = 0.0251x3 0.111x2 + 0.5x+ 1 (coefficients to 3 significant figures)

    61

  • 8/13/2019 Homework Solutions Math2130

    62/67

    #2 Construct the cubic Hermite interpolate to f(x) = sin(x) using the nodesa= 0 and b= . Plot the error between the interpolate and the function.

    Solution: f(x) = sin(x) = f(x) = cos(x). Then

    L1(x) = x x2

    x1 x2=

    x 0

    = x

    L2(x) = x x1

    x2 x1 = x 0 0=

    x

    62

  • 8/13/2019 Homework Solutions Math2130

    63/67

    withL1(x) =

    1

    and L2(x) =

    1

    . Now

    h1(x) = [1 2(x x1)L1(x1)]L21(x)=

    1 2(x 0)

    1

    ( x)2

    2

    =

    1 +

    2

    x

    ( x)2

    2 (28)

    h2(x) = [1 2(x x2)L2(x2)]L22(x)=

    1 2(x )

    1

    x2

    2

    = 3 2

    xx22

    (29)

    h1(x) = (x x1)L21= (x 0)( x)

    2

    2

    = x( x)2

    2 (30)

    h2(x) = (x x2)L22(x)= (x ) x

    2

    2 (31)

    Using (28)-(31) we have

    H(x) = f(x1)h1(x) +f(x1)h1(x) +f(x2)h2(x) +f

    (x2)h2(x)

    = 0 + 1x( x)2

    2 + 0

    3 2

    x

    x2

    2+ (1)(x ) x

    2

    2

    = (after simplifying)

    = 0x3

    1

    x2 +x+ 0

    63

  • 8/13/2019 Homework Solutions Math2130

    64/67

    #5 Construct the cubic Hermite interpolate to f(x) = x1

    3 on the interval1

    8, 1

    . What is the maximum error as predicted by theory? What is the

    actual (observed) maximum error?

    Solution: f(x) =x1

    3 =

    f(x) =

    1

    3

    x2

    3 . Then

    L1(x) = x x2

    x1 x2 = x 118 1=

    x 17

    8

    =8

    7(1 x)

    L2(x) = x x1

    x2 x1 = x 1

    8

    1 18=

    8

    7

    x 1

    8

    64

  • 8/13/2019 Homework Solutions Math2130

    65/67

    withL1(x) =

    8

    7 and L2(x) =

    8

    7. Now

    h1(x) = [1 2(x x1)L1(x1)]L21(x)

    =

    1 2

    x 1

    8

    8

    7

    8

    7

    2(1 x)2

    =

    16

    7x+

    5

    7

    64

    49

    (1 x)2 (32)

    h2(x) = [1 2(x x2)L2(x2)]L22(x)

    =

    1 2(x 1)

    8

    7

    8

    7

    2x 1

    8

    2

    = 23716

    7x64

    49x 1

    82 (33)

    h1(x) = (x x1)L21=

    x 1

    8

    8

    7

    (1 x)2 (34)

    h2(x) = (x x2)L22(x)

    = (x 1)

    64

    49

    x 1

    8

    2(35)

    Using (32)-(35) we have

    H(x) = f(x1)h1(x) +f(x1)h1(x) +f(x2)h2(x) +f(x2)h2(x)

    =

    1

    8

    13

    16x

    7 +

    5

    7

    64

    49

    (1 x)2 +

    1

    3

    1

    8

    23

    x 18

    8

    7

    (1 x)2

    +(11

    3 )

    23

    716

    7x

    64

    49

    x 1

    8

    2+

    1

    3

    (1

    2

    3 )(x 1)

    64

    49

    x 1

    8

    2= (after simplifying)

    = 0.466x3 1.26x2 + 1.46x+ 0.336 (coefficients to 3 significant figures)From the lecture notes, the interpolation error is

    f(x) H(x) = (x x1)2(x x2)2 f(4)

    (x)4!

    so

    |f(x) H(x)|

    x 18

    2(x 1)2

    M24 , (36)65

  • 8/13/2019 Homework Solutions Math2130

    66/67

    whereMis an upper bound for

    |f(4)(x)

    |on

    1

    8

    , 1.f(x) =x

    1

    3 = f(x) =13

    x2

    3

    = f(x) = 29

    x5

    3

    = f(x) =1027

    x8

    3

    = f(4)(x) = 8081

    x11

    3

    so

    |f(4)(x)

    |= 8081

    |x

    | 11

    3, which is a decreasing function on 1

    8

    , 1, thus|f(4)(x)| 80

    81

    1

    8

    113

    =

    80

    81

    (2048) =

    20736

    10 =M .

    We also need to maximize

    x 1

    8

    2(x1)2 on

    1

    8, 1

    . Basic shape of

    h(x) =

    x 1

    8

    2(x 1)2 is:

    so use Calculus to find the local maximum point.

    h(x) = 1

    32(x 1)(8x 1)(16x 9)

    66

  • 8/13/2019 Homework Solutions Math2130

    67/67

    Thus local extrema occur atx = 1,x =1

    8andx =

    9

    16. Thush(x)

    h

    916=2401

    65536 . Thus from (36)

    |x13 H(x)| 240165536

    2073610

    124

    = 3.165 (predicted).