numerical methods - solutions manual

Upload: timur-abbiasov

Post on 02-Jun-2018

259 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 Numerical Methods - Solutions Manual

    1/24

    Sample

    Student Solutions Manual

    to accompany

    NUMERICAL METHODS, Third Edition

    J. Douglas Faires and Richard L. Burden

    Youngstown State University

    September 22, 2002

  • 8/10/2019 Numerical Methods - Solutions Manual

    2/24

    ii

  • 8/10/2019 Numerical Methods - Solutions Manual

    3/24

    Contents

    1 Mathematical Preliminaries 1EXERCISE SET 1.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1EXERCISE SET 1.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6EXERCISE SET 1.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    iii

  • 8/10/2019 Numerical Methods - Solutions Manual

    4/24

    iv CONTENTS

    This is a Sample of the Student Solutions Manual for Numerical Methods, ThirdEdition, by Faires and Burden. It contains worked out exercises for all the techniquesdiscussed in the first Chapter of the book. The full Student Solutions Manual containsworked out exercises for all the techniques discussed in the entire book. The answersto the odd exercises are in the back of the text, but the results listed in this StudyGuide go well beyond the answers listed in the text, and the exercises that are solved

    in this Student Solutions Manual were carefully chosen as those requiring insight intothe methods presented in the text.

    In addition to the solutions to numerous exercises, the Student Solutions Manualcontains a listing of the instructions for the program disk that accompanies NumericalMethods, together with a copy of the CD that contains the programs in the program-ming languages C, Pascal, and FORTRAN and for the Computer Algebra SystemsMaple, Mathematica, and Matlab. These programs can be extremely valuable in yourstudy of approximation techniques since they permit you to see the calculations thatneed to be performed without the necessity of performing the calculations by hand.

    If you are interested in obtaining the entire Student Solutions Manual, it can likelybe obtained at your local bookstore. If not, you can obtain a copy from the publisherat

    http://www.brookscole.com/math d/

    J. Douglas [email protected]

    Richard L. Burden Youngstown State [email protected] September 22, 2002

  • 8/10/2019 Numerical Methods - Solutions Manual

    5/24

    Chapter 1

    Mathematical Preliminaries and

    Error Analysis

    EXERCISE SET 1.2 (Page 13 )

    1. d. Show that the equationx(lnx)x =0

    has at least one solution in the interval[4, 5].Solution: It is not possible to algebraically solve for the solution x, but this is notrequired in the problem, we must only show that a solution exists. Let

    f(x)=x(lnx)x =xexp(x(ln(lnx))).

    Since f is continuous on[4, 5] with f(4)0.3066 and f(5) 5.799,the Interme-diate Value Theorem implies that a number x must exist in (4, 5)with

    0= f(x)=x(lnx)x .

    2. c. Find intervals that contain a solution to

    x 3 2x 2 4x+3=0.

    1

  • 8/10/2019 Numerical Methods - Solutions Manual

    6/24

    2 CHAPTER 1. MATHEMATICAL PRELIMINARIES

    Solution: Letf(x)=x 3 2x 2 4x+3.

    The critical points of foccur when

    0= f(x)=3x 2 4x4=(3x+2)(x2),that is, when x

    = 2

    3 and x

    = 2. Relative maximum and minimum values of f

    can occur only at these values. There are at most three solutions to f(x)= 0, sincef(x) is a polynomial of degree three. Since f(2)= 5 and f(1)= 4; f(0)= 3and f(1)= 2 and f(2)= 5 and f(4)=19, solutions lie in the intervals[2,1],[0, 1], and [2, 4].

    4. a. Find max0x1|f(x)| when

    f(x)= 2ex +2x3

    .

    Solution: First note that

    f(x)=(ex

    +2)/3so the only critical point of foccurs at x= ln 2, which lies in the interval [0, 1]. Themaximum for |f(x)| must consequently be

    max{|f(0)|, |f(ln 2)|, |f(1)|} =max{1/3, (2 l n 2)/3, (4e)/3}=(2 l n 2)/30.4620981.

    7. Find the second Taylor polynomial for

    f(x)=ex cosx

    about x0=0.Solution: Since

    f(x)=ex(cosxsinx), f(x)= 2ex (sinx),and

    f(x)= 2ex(sinx+cosx),we have f(0)=1, f(0)=1,and f(0)=0. So

    P2(x)=1+x and R2(x)=2e(sin +cos )

    3! x3.

  • 8/10/2019 Numerical Methods - Solutions Manual

    7/24

    EXERCISE SET 1.2 3

    a. Use P2(0.5)to approximate f(0.5), find an upper bound for

    |f(0.5) P2(0.5)|,

    and compare this to the actual error.

    Solution: P2(0.5)=1+0.5=1.5 and

    |f(0.5) P2(0.5)| max[0.0.5]

    2e(sin +cos )3! (0.5)2

    13(0.5)2 max

    [0,0.5]|e(sin +cos )|.

    To maximize this quantity on[0, 0.5], first note that

    Dx ex(sinx+cosx)=2ex cosx >0

    for all x in[0, 0.5]. This implies that the maximum and minimum values ofex

    (sinx+cosx)on[0, 0.5] occur at the endpoints of the interval, and

    e0(sin0+cos 0)=1 < e0.5(sin0.5+cos 0.5)2.2373.

    Hence

    |f(0.5) P2(0.5)| 13(0.5)3(2.273)0.093222.

    Since P2(0.5)=1.5 and f(0.5)=1.446889, the actual error is 0.053111.

    b. Find a bound for the error|f(x) P2(x)|| for x in[0, 1]Solution: A similar analysis to that in part (a) gives

    |f(x) P2(x)| 13(1.0)3e1(sin1+cos 1)1.252.

    c. Approximate 10

    f(x) d x using

    10

    P2(x) d x .

  • 8/10/2019 Numerical Methods - Solutions Manual

    8/24

    4 CHAPTER 1. MATHEMATICAL PRELIMINARIES

    Solution: 10

    f(x) d x 1

    0

    1+x d x=

    x+ x2

    2

    10

    =1.5.

    d. Find an upper bound for the error in part (c).

    Solution: From part (b), 10

    |R2(x)| d x 1

    0

    1

    3e1(cos1+sin 1)x 3 d x=

    10

    1.252x 3 d x= 0.313.

    Since 10

    ex cosx d x=

    ex

    2(cosx+sinx)

    10

    = e2(cos 1+sin 1) 1

    2(1+0)1.378,

    the actual error is|1.3781.5| 0.12.

    9. Use the error term of a Taylor polynomial to estimate the error involved

    in usingsinx x

    to approximate sin1.

    Solution: First we need to convert the degree measure for the sine function to radians.We have 180= radians, so 1= 180 radians. Since,

    f(x)=sin x, f(x)=cos x, f(x)= sinx, and f(x)= cosx,we have f(0)=0, f(0)=1,and f(0)=0. The approximation sinx x is given by

    f(x) P2(x), and R2(x)= cos

    3

    !

    x 3.

    If we use the bound| cos | 1, thensin 180

    180

    = R2 180

    = cos 3!

    180

    3 8.86107.

    11. a. Letf(x)=ex/2 sin x

    3.

    Use Maple to determine the third Maclaurin polynomial P3(x).

  • 8/10/2019 Numerical Methods - Solutions Manual

    9/24

    EXERCISE SET 1.2 5

    Solution: Define f(x)with

    >f:=exp(x/2)*sin(x/3);

    f:= e(1/2x) sin

    1

    3x

    Find the first three terms of the Taylor series with>g:=taylor(f,x=0,4);

    g:= 13

    x+16

    x 2 + 23648

    x 3 +O (x 4)Extract the third Maclaurin polynomial with

    >p3:=convert(g,polynom);

    p3:= 13

    x+16

    x 2 + 23648

    x 3

    b. Determine f(4)(x), and bound the error|

    f(x)

    P3(x)

    |on

    [0, 1

    ].

    Solution: First we determine the fourth derivative.

    >f4:=diff(f,x,x,x,x);

    f4:= 1191296

    e(x/2) sin

    1

    3x

    + 5

    54e(x/2) cos

    1

    3x

    Next we find the fifth derivative.

    >f5:=diff(f4,x);

    f5:= 1992592

    e(x/2) sin

    1

    3x

    + 61

    3888e(x/2) cos

    1

    3x

    Then we see if the fourth derivative has any critical points in[0, 1].>p:=fsolve(f5=0,x,0..1);

    p:=.6047389076The extreme values of the fourth derivative will occur at x= 0, 1, or p.

    >c1:=evalf(subs(x=p,f4));

    c1:=.09787176213

  • 8/10/2019 Numerical Methods - Solutions Manual

    10/24

    6 CHAPTER 1. MATHEMATICAL PRELIMINARIES

    >c2:=evalf(subs(x=0,f4));

    c2:=.09259259259

    >c3:=evalf(subs(x=1,f4));

    c3:=.09472344463The maximum absolute value of f(4)(x)is c1 and the error is given by

    >err:=c1/24;

    err:=.004077990089

    EXERCISE SET 1.3 (Page 20 )

    3. e. Use three-digit rounding arithmetic to compute

    1314

    67

    2e5.4and determine the absolute and relative errors.

    Solution: Using three-digit rounding arithmetic gives 1314

    = 0.929, 67= 0.857, and

    e=2.72. So13

    14 6

    7=0.0720 and 2e5.4=5.445.40=0.0400.

    Hence,1314

    67

    2e5.4 = 0.0720

    0.0400 =1.80.The correct value is approximately 1.954, so the absolute and relative errors to threedigits are

    |1.801.954| =0.154 and |1.801.954|1.954

    =0.0788,respectively.

  • 8/10/2019 Numerical Methods - Solutions Manual

    11/24

    EXERCISE SET 1.3 7

    7. a. Use the first three terms of the Maclaurin series for the arctangent functionto approximate

    = 4

    arctan1

    2+arctan 1

    3

    and determine the absolute and relative errors.

    Solution: Let P (x)=x 13x 3+ 15x 5.Then P

    12

    =0.464583 and P

    13

    =0.3218107,

    so

    = 4

    arctan1

    2+arctan 1

    3

    3.145576.

    The absolute and relative errors are, respectively,

    |3.145576| 3.983103 and |3.145576|| | 1.268103.

    10. The Taylor polynomial of degreen for

    f(x)=ex isn

    i=0

    x i

    i !.

    Use the Taylor polynomial of degree nine and three-digit choppingarithmetic to find an approximation to e5 by each of the followingmethods. Which formula, (a) or (b), gives the most accuracy, andwhy?

    a. e5 9

    i=0

    (5)ii

    ! =

    9

    i=0

    (1)i 5ii

    !Solution: The Taylor polynomial of degree nine gives

    e5 9

    i=0

    (1)i 5ii !

    =15+ 252

    1256

    + 62524

    3120120

    + 15600720

    780005040

    + 39000040300

    1950000362000

  • 8/10/2019 Numerical Methods - Solutions Manual

    12/24

    8 CHAPTER 1. MATHEMATICAL PRELIMINARIES

    =15+12.520.8+26.026.0+21.615.4+9.675.38= 1.81

    b. e5=

    1

    e5 1

    9i=0 5i

    i !.

    Solution: The reciprocal of the Taylor polynomial of degree nine gives

    e5 19i=0

    5i

    i !

    = 11+5+12.5+20.8+26.0+26.0+21.6+15.4+9.67+5.38

    = 1141

    =7.09103

    An approximate value of e5 correct to three digits is 6.74103. Part (b) is moreaccurate since subtraction is not involved.

    11. A rectangular parallelepiped has sides 3 cm, 4 cm, and 5 cm, measuredto the nearest centimeter.

    Solution: Let the sides be x, y, and z, and suppose that the measurements givex= 3 cm, y= 4 cm, and z= 5 cm. Since the measurements are accurate to thenearest centimeter, it follows that the actual values satisfy the inequalities

    2.5x3.5, 3.5 y4.5, and 4.5z5.5

    a. What are the best upper and lower bounds for the volume of this paral-lelepiped?

    Solution: Since the volume is V= x yz we have(2.5)(3.5)(4.5)V (3.5)(4.5)(5.5) and 39.375V 86.625

    b. What are the best upper and lower bounds for the surface area?

    Solution: Since the surface area is S=2x y+2x z+2yz we have2(2.5)(3.5)+2(2.5)(4.5)+2(3.5)(4.5)S

  • 8/10/2019 Numerical Methods - Solutions Manual

    13/24

    EXERCISE SET 1.4 9

    andS2(3.5)(4.5)+2(3.5)(5.5)+2(4.5)(5.5),

    so 71.5S119.50.

    EXERCISE SET 1.4 (Page 27 )

    1. c. (i) Use four-digit rounding arithmetic and the formulas of Example 1 tofind the most accurate approximations to the roots of

    1.002x 2 11.01x+0.01265=0.

    (ii) Compute the absolute error and relative error.

    Solution: Since b= 11.01 is negative, we use the formulas

    x1=

    b+

    b2 4ac2a

    and x2=

    2cb b2 4ac

    to avoid the subtraction of nearly equal numbers. Using four-digit rounding arithmeticgives

    x1=b+

    b2 4ac

    2a=(11.01)+

    (11.01)2 4(1.002)(0.01265)

    2a

    = 11.01+

    121.24.008(0.01265)2.004

    = 11.01+

    121.20.050702.004

    = 11.01+

    121.1

    2.004= 11.01+11.00

    2.004= 22.01

    2.004=10.98

    The actual root is 10.98687488, so the absolute error is |10.98687488 10.98| =6.87488103, and the relative error is

    6.8748810310.98687488

    =6.25736104.

    Also,

    x2= 2c

    b

    b2 4ac= 2(0.01265)

    11.01(11.01)2 4(1.002)(0.01265)

  • 8/10/2019 Numerical Methods - Solutions Manual

    14/24

    10 CHAPTER 1. MATHEMATICAL PRELIMINARIES

    = 0.0253011.0111.00 =0.02530

    22.01 =0.001149.

    The actual root is 0.001149076 so the absolute error of this approximation is

    |0.0011490760.001149| =7.566108,

    and the relative error is

    7.5661080.001149076

    =6.5844105.

    2. c. Repeat Exercise 1 using four-digit chopping arithmetic.

    Solution: Since b= 11.01 is negative, we use the formulas

    x1=b+

    b2 4ac

    2aand x2=

    2cb

    b2 4ac

    to avoid the subtraction of nearly equal numbers. Using four-digit chopping arithmeticgives

    x1=b+

    b2 4ac

    2a=(11.01)+

    (11.01)2 4(1.002)(0.01265)

    2a

    = 11.01+

    121.24.008(0.01265)2.004

    = 11.01+

    121.20.050702.004

    = 11.01+

    121.1

    2.004= 11.01+11.00

    2.004= 22.01

    2.004=10.98

    The actual root is 10.98687488, so the absolute error is |10.98687488 10.98| =6.8748810

    3

    , and the relative error is

    6.8748810310.98687488

    =6.25736104.

    Also,

    x2= 2c

    b

    b2 4ac= 2(0.01265)

    11.01(11.01)2 4(1.002)(0.01265)

    = 0.0253011.0111.00 =0.02530

    22.01 =0.001149.

  • 8/10/2019 Numerical Methods - Solutions Manual

    15/24

    EXERCISE SET 1.4 11

    The actual root is 0.001149076 so the absolute error of this approximation is

    |0.0011490760.001149| =7.566108,and the relative error is

    7.566108

    0.001149076 =6.5844

    105.

    5. The fifth Maclaurin polynomials fore2x and e2x are

    P5(x)=

    4

    15x+2

    3

    x+4

    3

    x+2

    x+2

    x+1

    and

    P5(x)=

    415

    x+23

    x4

    3

    x+2

    x2

    x+1

    a. Approximate e0.98 using P5(0.49)and four-digit rounding arithmetic.Solution: Using four-digit rounding arithmetic to evaluate P5(0.49) gives

    P5(0.49)=(((((0.2667)(0.49)+0.6667)(0.49)1.333)(0.49)+2)(0.49)2)(0.49)+1

    =((((0.1307+0.6667)(0.49)1.333)(0.49)+2)(0.49)2)(0.49)+1

    =((((0.5360)(0.49)1.333)(0.49)+2)(0.49)2)(0.49)+1

    =(((0.2626

    1.333)(0.49)

    +2)(0.49)

    2)(0.49)

    +1

    =(((1.070)(0.49)+2)(0.49)2)(0.49)+1=(((0.5243)+2)(0.49)2)(0.49)+1=((1.476)(0.49)2)(0.49)+1=(0.72322)(0.49)+1=(1.277)(0.49)+1= 0.6257+1=0.3743

  • 8/10/2019 Numerical Methods - Solutions Manual

    16/24

    12 CHAPTER 1. MATHEMATICAL PRELIMINARIES

    b. Compute the absolute and relative error for the approximations in part(a).

    Solution: The absolute error is|e0.98 0.3743| = 1.011103, and the relativeerror is

    1.011103e0.98 =

    2.694

    103.

    c. Approximatee0.98 using1/P5(0.49)and four-digit rounding arithmetic.

    Solution: We have

    1

    P5(0.49)= 1

    (((((0.2667)(0.49)+0.6667)(0.49)+1.333)(0.49)+2)(0.49)+2)(0.49)+1= 1

    2.663

    =0.3755.

    d. Compute the absolute and relative errors for the approximations in part(c).

    Solution: The absolute error is

    |e0.98 0.3755| =1.889104,and the relative error is

    1.889104e0.98

    =5.033104.

    6. a. Show that the polynomial nesting technique can be used to evaluate

    f(x)=1.01e4x 4.62e3x 3.11e2x +12.2ex 1.99.

    Solution: Since enx =(ex )n, we can write

    f(x)=((((1.01)ex 4.62)ex 3.11)ex +12.2)ex 1.99.

  • 8/10/2019 Numerical Methods - Solutions Manual

    17/24

    EXERCISE SET 1.4 13

    b. Use three-digit rounding arithmetic and the formula given in the state-ment of part (a) to evaluate f(1.53).

    Solution: Using e1.53

    = 4.62 and three-digit rounding gives e2(1.53)

    = (4.62)2

    =21.3, e3(1.53) =(4.62)2(4.62)=(21.3)(4.62)=98.4,and e4(1.53) =(98.4)(4.62)=455.So

    f(1.53)=1.01(455)4.62(98.4)3.11(21.3)+12.2(4.62)1.99=46045566.2+56.41.99=5.0066.2+56.41.99= 61.2+56.41.99= 4.801.99= 6.79.

    c. Redo the calculations in part (b) using the nesting form of f(x)that wasfound in part (a).

    Solution:

    f(1.53)=(((1.01)4.624.62)4.623.11)4.62+12.2)4.621.99=(((4.674.62)4.623.11)4.62+12.2)4.621.99=((0.2313.11)4.62+12.2)4.621.99=(13.3+12.2)4.621.99= 7.07.

    d. Compare the approximations in parts (b) and (c).

    Solution: The exact result is 7.61, so the absolute errors in parts (b) and (c) are,

    respectively,| 6.79+7.61| =0.82 and | 7.07+7.61| =0.54. The relative errorsare, respectively, 0.108 and 0.0710.

  • 8/10/2019 Numerical Methods - Solutions Manual

    18/24

    14 CHAPTER 1. MATHEMATICAL PRELIMINARIES

    7. Use three-digit chopping arithmetic to compute the sum

    10i=1

    1

    i 2

    first by 1

    1+ 1

    4+ + 1

    100

    and then by1

    100+ 1

    81+ + 1

    1,

    adding left to right. Which method is more accurate, and why?

    Solution: Using three-digit chopping arithmetic on10

    i=11

    i 2in the order 1 + 1

    4+ +

    1100 gives

    1.00+0.250+0.111+0.0625+0.0400+0.0277+0.0204+0.0156+0.0123+0.0100=1.25+0.111+0.0625+0.0400+0.0277+0.0204+0.0156+0.0123+0.0100=1.36+0.0625+0.0400+0.0277+0.0204+0.0156+0.0123+0.0100=1.42+0.0400+0.0277+0.0204+0.0156+0.0123+0.0100=1.46+0.0277+0.0204+0.0156+0.0123+0.0100=1.48+0.0204+0.0156+0.0123+0.0100=1.50+0.0156+0.0123+0.0100=1.51+0.0123+0.0100=1.52+0.0100

    =1.53.

    In the reverse order we sum 1100

    + 181

    + + 14+1 as

    0.0100+ .0123+ 0.0156 +0.0204+ 0.0277 +0.0400+ 0.0625 +0.111+ 0.25+ 1.00=1.54

    The actual value is 1.549. The problem of adding a very small number to an accumu-lated sum causes significant round-off errors in the first method.

  • 8/10/2019 Numerical Methods - Solutions Manual

    19/24

    EXERCISE SET 1.4 15

    8. a. Determine the number n of terms of the series

    arctanx= limn Pn(x)=

    i=1

    (1)i+1 x2i1

    (2i1)

    that are required to ensure that|4Pn(1) | < 103

    .

    Solution: Since the terms of the series

    = 4 arctan1=4

    i=1(1)i+1 1

    2i1

    alternate in sign, the error produced by truncating the series at any term is less thanthe magnitude of the next term. To ensure significant accuracy we need to choose nso that

    4

    2(n+1)1

  • 8/10/2019 Numerical Methods - Solutions Manual

    20/24

    16 CHAPTER 1. MATHEMATICAL PRELIMINARIES

    where is between 0 and 1n2

    . Since| cos | 1 we have 1n2

    1

    6cos

    1

    n6

    2n2 .Thus, sin 1n20 2 1n2 and the rate of convergence ofsin 1

    n2 is O

    1n2

    .

    12. a. How many calculations are needed to determine a sum of the form

    ni=1

    ij=1

    ai bj ?

    Solution: For each i the inner sum ij=1ai bj requires i multiplications and i1additions, for a total ofn

    i=1i= n(n+1)

    2Multiplications

    andn

    i=1i1= n(n+1)

    2n Additions.

    Once the n inner sums are computed, n1 additions are required for the final sum.The final total is:

    n(n+1)2

    Multiplications and (n+2)(n1)

    2

    Additions.

    b. Re-express the series in a way that will reduce the number of calculationsneeded to determine this sum.

    Solution: By rewriting the sum as

    ni=1

    ij=1

    ai bj=n

    i=1ai

    ij=1

    bj

  • 8/10/2019 Numerical Methods - Solutions Manual

    21/24

    EXERCISE SET 1.4 17

    we can significantly reduce the amount of calculation. For each i we now need i1additions to sum bj s for a total of

    ni=1

    i1= n(n+1)2

    n Additions.

    Once the bj s are summed we need n multiplications by the ai s, followed by n1additions of the products.

    The total additions by this method is still (n+2)(n1)2

    , but the number of multipli-

    cations has been reduced from n(n+1)2

    to n.

    13. Consider the Fibonacci sequence defined by

    F0=1, F1=1, and Fn+2= Fn+1+ Fn, ifn0,and define

    xn= Fn+1/Fn.Assuming that

    limnxn= x

    converges, show that the limit is the golden ratio:

    x= 1+

    5

    2.

    Solution: Since

    limnxn= limnxn+1=x and xn+1=1+

    1

    xn,

    we havex= 1+ 1

    xwhich implies that x 2 x1=0.

    The only positive solution to this quadratic equation is x=(1+

    5)/2.

    14. The Fibonacci sequence also satisfies the equation

    FnFn= 1

    5

    1+ 5

    2

    n

    1 52

    n.

  • 8/10/2019 Numerical Methods - Solutions Manual

    22/24

    18 CHAPTER 1. MATHEMATICAL PRELIMINARIES

    a. Write a Maple procedure to calculate F100.

    Solution: We have

    >n:=98;f:=1;s:=1;

    n:=98f:=1s:=1

    >for i from 1 to n do

    > l:=f+s;f:=s;s:=l;

    >od;

    l:=2f:=1s

    :=2

    l:=3f:=2s:=3l:=5

    ...

    l:=218922995834555169026f:=135301852344706746049s:=218922995834555169026l:=354224848179261915075

    b. Use Maple with the default value ofDigitsfollowed byevalfto calculateF100.

    Solution: We have

    > F100:=(((1+sqrt(5))/2)^100-((1-sqrt(5))/2)^100)/sqrt(5);

    F100:= 15

    1

    2+ 1

    2

    5

    100

    1

    2 1

    2

    5

    1005

  • 8/10/2019 Numerical Methods - Solutions Manual

    23/24

    EXERCISE SET 1.4 19

    >evalf(F100);

    .3542248538 1021

    c. Why is the result from part (a) more accurate than the result from part(b)?

    Solution: The result in part (a) is computed using exact integer arithmetic, and theresult in part (b) is computed using 10-digit rounding arithmetic.

    d. Why is the result from part (b) obtained more rapidly than the resultfrom part (a)?

    Solution: The result in part (a) required traversing a loop 98 times.

    e. What results when you use the command simplify instead ofevalf tocompute F100?Solution: The result is the same as the result in part (a).

    15. The harmonic series

    1+ 12

    + 13

    + 14

    + diverges, but the sequence

    n=1+1

    2+ + 1

    nln n

    converges, since{n} is a bounded, nonincreasing sequence. The limit

    0.5772156649 . . . of the sequence{

    n} is called Eulers constant.

    a. Use the default value ofDigits in Maple to determine the value ofn for to be within 102.

    b. Use the default value ofDigits in Maple to determine the value ofn for to be within 103.

  • 8/10/2019 Numerical Methods - Solutions Manual

    24/24

    20 CHAPTER 1. MATHEMATICAL PRELIMINARIES

    c. What happens if you use the default value ofDigits in Maple to deter-mine the value ofn for to be within 104?

    Solution: The following Maple procedure is used:

    >g:=proc(t);

    > dne:=1;

    > n:=1;

    > sm:=0;

    > while dne=1 do

    > sm:=sm+evalf(1/n);

    > gam:=evalf(sm-ln(n));

    > err:=abs(evalf(gamma)-gam);

    > if err else n:=n+1;

    > fi;

    > od;

    > n;

    >end;

    >g(0.01);>g(0.001);

    >g(0.0001);

    The results from the procedure area. n=50, b. n=500, and c. n=5001.If a procedure is not used, as in the following code, the program fails.

    >restart;

    >tol:=0.0001;

    >dne:=1;

    >n:=1;

    >sm:=0;

    >while dne=1 do

    > sm:=sm+evalf(1/n);> gam:=evalf(sm-ln(n));

    > err:=abs(evalf(gamma)-gam);

    > if err else n:=n+1;

    > fi;

    >od;

    >n;