You are on page 1of 24

Sample

Student Solutions Manual


to accompany
NUMERICAL METHODS, Third Edition
J. Douglas Faires and Richard L. Burden
Youngstown State University
September 22, 2002

ii

Contents
1 Mathematical Preliminaries
EXERCISE SET 1.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
EXERCISE SET 1.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
EXERCISE SET 1.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

iii

1
1
6
9

iv

CONTENTS

This is a Sample of the Student Solutions Manual for Numerical Methods, Third
Edition, by Faires and Burden. It contains worked out exercises for all the techniques
discussed in the rst Chapter of the book. The full Student Solutions Manual contains
worked out exercises for all the techniques discussed in the entire book. The answers
to the odd exercises are in the back of the text, but the results listed in this Study
Guide 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 into
the methods presented in the text.
In addition to the solutions to numerous exercises, the Student Solutions Manual
contains a listing of the instructions for the program disk that accompanies Numerical
Methods, together with a copy of the CD that contains the programs in the programming languages C, Pascal, and FORTRAN and for the Computer Algebra Systems
Maple, Mathematica, and Matlab. These programs can be extremely valuable in your
study of approximation techniques since they permit you to see the calculations that
need 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 likely
be obtained at your local bookstore. If not, you can obtain a copy from the publisher
at
http://www.brookscole.com/math d/

J. Douglas Faires
faires@math.ysu.edu
Richard L. Burden
burden@math.ysu.edu

Youngstown State University


September 22, 2002

Chapter 1

Mathematical Preliminaries and


Error Analysis
EXERCISE SET 1.2 (Page 13 )
1.

d. Show that the equation

x (ln x)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 not
required in the problem, we must only show that a solution exists. Let
f (x) = x (ln x)x = x exp(x(ln(ln x))).
Since f is continuous on [4, 5] with f (4) 0.3066 and f (5) 5.799, the Intermediate Value Theorem implies that a number x must exist in (4, 5) with
0 = f (x) = x (ln x)x .

2.

c.

Find intervals that contain a solution to


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

CHAPTER 1. MATHEMATICAL PRELIMINARIES

Solution: Let
f (x) = x 3 2x 2 4x + 3.
The critical points of f occur when
0 = f  (x) = 3x 2 4x 4 = (3x + 2)(x 2),
that is, when x = 23 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, since
f (x) is a polynomial of degree three. Since f (2) = 5 and f (1) = 4; f (0) = 3
and 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


2 e x + 2x
.
f (x) =
3
Solution: First note that

f  (x) = (e x + 2)/3

so the only critical point of f occurs at x = ln 2, which lies in the interval [0, 1]. The
maximum for | f (x)| must consequently be
max{| f (0)|, | f (ln 2)|, | f (1)|} = max{1/3, (2 ln 2)/3, (4 e)/3}
=(2 ln 2)/3 0.4620981.

7.

Find the second Taylor polynomial for


f (x) = e x cos x
about x0 = 0.
Solution: Since
f  (x) = e x (cos x sin x),
and

f  (x) = 2e x (sin x),

f  (x) = 2e x (sin x + cos x),

we have f (0) = 1, f  (0) = 1, and f  (0) = 0. So


P2 (x) = 1 + x

and

R2 (x) =

2e (sin + cos ) 3
x .
3!

EXERCISE SET 1.2

a.

Use P2 (0.5) to approximate f (0.5), nd 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


 2e (sin + cos )

2

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

1
(0.5)2 max |e (sin + cos )|.
[0,0.5]
3

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


Dx e x (sin x + cos x) = 2e x cos x > 0
for all x in [0, 0.5]. This implies that the maximum and minimum values of e x (sin x +
cos x) on [0, 0.5] occur at the endpoints of the interval, and
e0 (sin 0 + cos 0) = 1 < e0.5 (sin 0.5 + cos 0.5) 2.2373.
Hence

1
(0.5)3 (2.273) 0.093222.
3
Since P2 (0.5) = 1.5 and f (0.5) = 1.446889, the actual error is 0.053111.
| f (0.5) P2 (0.5)|

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

c.

Approximate


0

1
(1.0)3 e1 (sin 1 + cos 1) 1.252.
3


f (x) d x

using
0

P2 (x) d x.

CHAPTER 1. MATHEMATICAL PRELIMINARIES

Solution:

f (x) d x

x2
1 + x dx = x +
2

1
= 1.5.
0

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

Solution: From part (b),





|R2 (x)| d x

Since


1 1
e (cos 1 + sin 1)x 3 d x =
3

1.252x 3 d x = 0.313.

1
1
ex
e
(cos x + sin x) = (cos 1 + sin 1) (1 + 0) 1.378,
e cos x d x =
2
2
2
0


the actual error is |1.378 1.5| 0.12.

Use the error term of a Taylor polynomial to estimate the error involved
in using
sin x x

to approximate sin 1 .

9.

Solution: First we need to convert the degree measure for the sine function to radians.
We have 180 = radians, so 1 =
f (x) = sin x,

180

f  (x) = cos x,

radians. Since,

f  (x) = sin x,

and

f  (x) = cos x,

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


f (x) P2 (x),

and

R2 (x) =

cos 3
x .
3!

If we use the bound | cos | 1, then






     cos  3 

8.86 107 .

=
sin
 = R2
180 180
180
3!
180 

11.

a.

Let

x
f (x) = e x/2 sin .
3
Use Maple to determine the third Maclaurin polynomial P3 (x).

EXERCISE SET 1.2

Solution: Dene f (x) with


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

1
x
3

Find the rst three terms of the Taylor series with


>g:=taylor(f,x=0,4);
1
1
23 3
x + x2 +
x + O(x 4 )
3
6
648
Extract the third Maclaurin polynomial with
g :=

>p3:=convert(g,polynom);
p3 :=

1
1
23 3
x + x2 +
x
3
6
648

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);
 
 
5 (x/2)
1
1
119 (x/2)
e
x + e
x
sin
cos
f 4 :=
1296
3
54
3
Next we nd the fth derivative.
>f5:=diff(f4,x);
f 5 :=

 
 
1
1
199 (x/2)
61 (x/2)
sin
cos
e
x +
e
x
2592
3
3888
3

Then we see if the fourth derivative has any critical points in [0, 1].
>p:=fsolve(f5=0,x,0..1);
p := .6047389076
The extreme values of the fourth derivative will occur at x = 0, 1, or p.
>c1:=evalf(subs(x=p,f4));
c1 := .09787176213

CHAPTER 1. MATHEMATICAL PRELIMINARIES

>c2:=evalf(subs(x=0,f4));
c2 := .09259259259
>c3:=evalf(subs(x=1,f4));
c3 := .09472344463
The 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


67
2e 5.4
13
14

and determine the absolute and relative errors.


Solution: Using three-digit rounding arithmetic gives
e = 2.72. So
13 6
= 0.0720
14 7

and

13
14

= 0.929,

6
7

= 0.857, and

2e 5.4 = 5.44 5.40 = 0.0400.

Hence,
67
0.0720
=
= 1.80.
2e 5.4
0.0400
The correct value is approximately 1.954, so the absolute and relative errors to three
digits are
|1.80 1.954|
= 0.0788,
|1.80 1.954| = 0.154 and
1.954
respectively.
13
14

EXERCISE SET 1.3

7.

a.

Use the rst three terms of the Maclaurin series for the arctangent function
to approximate


1
1
= 4 arctan + arctan
2
3
and determine the absolute and relative errors.
 

= 0.464583 and P


1
1
= 4 arctan + arctan
3.145576.
2
3

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


so

1
2

 
1
3

= 0.3218107,

The absolute and relative errors are, respectively,


| 3.145576| 3.983 103

and

| 3.145576|
1.268 103 .
| |

The Taylor polynomial of degree n for

10.

f (x) = e x

is

n

xi
i=0

i!

Use the Taylor polynomial of degree nine and three-digit chopping


arithmetic to nd an approximation to e5 by each of the following
methods. Which formula, (a) or (b), gives the most accuracy, and
why?
a.

9

(5)i
i=0

i!

9

(1)i 5i
i=0

i!

Solution: The Taylor polynomial of degree nine gives


e5

9

(1)i 5i
i=0

i!

25 125 625 3120 15600

+
2
6
24
120
720
78000 390000 1950000
+

5040
40300
362000

=15+

CHAPTER 1. MATHEMATICAL PRELIMINARIES


= 1 5 + 12.5 20.8 + 26.0 26.0 + 21.6 15.4 + 9.67 5.38
= 1.81

b. e5 =

1
1

9
e5
i=0

5i
i!

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


e5
9

5i
i=0 i!

1
1 + 5 + 12.5 + 20.8 + 26.0 + 26.0 + 21.6 + 15.4 + 9.67 + 5.38
1
= 7.09 103
=
141
=

An approximate value of e5 correct to three digits is 6.74 103 . Part (b) is more
accurate since subtraction is not involved.

A rectangular parallelepiped has sides 3 cm, 4 cm, and 5 cm, measured


to the nearest centimeter.

11.

Solution: Let the sides be x, y, and z, and suppose that the measurements give

x = 3 cm, y = 4 cm, and z = 5 cm. Since the measurements are accurate to the
nearest centimeter, it follows that the actual values satisfy the inequalities
2.5 x 3.5, 3.5 y 4.5,
a.

and

4.5 z 5.5

What are the best upper and lower bounds for the volume of this parallelepiped?
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.375 V 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 have


2(2.5)(3.5) + 2(2.5)(4.5) + 2(3.5)(4.5) S

EXERCISE SET 1.4

and
S 2(3.5)(4.5) + 2(3.5)(5.5) + 2(4.5)(5.5),
so 71.5 S 119.50.

EXERCISE SET 1.4 (Page 27 )


1.

c.

(i) Use four-digit rounding arithmetic and the formulas of Example 1 to


nd 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 4ac
2a

and

x2 =

2c

b b2 4ac

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

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


b + b2 4ac
=
x1 =
2a
2a

121.2 4.008(0.01265)
11.01 + 121.2 0.05070
=
2.004
2.004

11.01 + 11.00
22.01
11.01 + 121.1
=
=
= 10.98
=
2.004
2.004
2.004
=

11.01 +

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


6.87488 103 , and the relative error is
6.87488 103
= 6.25736 104 .
10.98687488
Also,
x2 =

2(0.01265)
2c

=

2
b b 4ac
11.01 (11.01)2 4(1.002)(0.01265)

10

CHAPTER 1. MATHEMATICAL PRELIMINARIES

0.02530
0.02530
=
= 0.001149.
11.01 11.00
22.01

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


|0.001149076 0.001149| = 7.566 108 ,
and the relative error is
7.566 108
= 6.5844 105 .
0.001149076

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
2a

and

x2 =

2c

b b2 4ac

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

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


b + b2 4ac
=
x1 =
2a
2a

11.01 + 121.2 0.05070


121.2 4.008(0.01265)
=
=
2.004
2.004

11.01 + 11.00
22.01
11.01 + 121.1
=
=
= 10.98
=
2.004
2.004
2.004
11.01 +

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


6.87488 103 , and the relative error is
6.87488 103
= 6.25736 104 .
10.98687488
Also,
2(0.01265)
2c

=

2
b b 4ac
11.01 (11.01)2 4(1.002)(0.01265)
0.02530
0.02530
=
= 0.001149.
=
11.01 11.00
22.01

x2 =

EXERCISE SET 1.4

11

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


|0.001149076 0.001149| = 7.566 108 ,
and the relative error is
7.566 108
= 6.5844 105 .
0.001149076

The fth Maclaurin polynomials for e2x and e2x are







4
2
4
x+
x+
x +2 x +2 x +1
P5 (x) =
15
3
3

5.

and
P5 (x) =

a.







4
2
4
x+
x
x +2 x 2 x +1
15
3
3

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.7232 2)(0.49) + 1
= (1.277)(0.49) + 1
= 0.6257 + 1
= 0.3743

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.011 103 , and the relative
error is

c.

1.011 103
= 2.694 103 .
e0.98

Approximate e0.98 using 1/P5 (0.49) and four-digit rounding arithmetic.


Solution: We have
1
1
=
P5 (0.49)
(((((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.889 104 ,
and the relative error is
1.889 104
= 5.033 104 .
e0.98

6.

a.

Show that the polynomial nesting technique can be used to evaluate


f (x) = 1.01e4x 4.62e3x 3.11e2x + 12.2e x 1.99.
Solution: Since enx = (e x )n , we can write
f (x) = ((((1.01)e x 4.62)e x 3.11)e x + 12.2)e x 1.99.

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,
So

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


f (1.53) = 1.01(455) 4.62(98.4) 3.11(21.3) + 12.2(4.62) 1.99
= 460 455 66.2 + 56.4 1.99
= 5.00 66.2 + 56.4 1.99
= 61.2 + 56.4 1.99 = 4.80 1.99 = 6.79.

c.

Redo the calculations in part (b) using the nesting form of f (x) that was
found in part (a).
Solution:
f (1.53) = (((1.01)4.62 4.62)4.62 3.11)4.62 + 12.2)4.62 1.99
= (((4.67 4.62)4.62 3.11)4.62 + 12.2)4.62 1.99
= ((0.231 3.11)4.62 + 12.2)4.62 1.99
= (13.3 + 12.2)4.62 1.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 errors
are, respectively, 0.108 and 0.0710.

14

7.

CHAPTER 1. MATHEMATICAL PRELIMINARIES

Use three-digit chopping arithmetic to compute the sum


10

1
i2
i=1

rst by
1
1 1
+ + +
1 4
100
and then by
1
1
1
+
+ + ,
100 81
1
adding left to right. Which method is more accurate, and why?
Solution: Using three-digit chopping arithmetic on
1
100

10

1
i=1 i 2

in the order 1 + 14 + +

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

1
100

1
81

+ +

1
4

+ 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 accumulated sum causes signicant round-o errors in the rst method.

EXERCISE SET 1.4

8.

a.

15

Determine the number n of terms of the series


arctan x = lim Pn (x) =
n

(1)i+1

i=1

x 2i1
(2i 1)

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


Solution: Since the terms of the series
= 4 arctan 1 = 4


(1)i+1
i=1

1
2i 1

alternate in sign, the error produced by truncating the series at any term is less than
the magnitude of the next term. To ensure signicant accuracy we need to choose n
so that
4
< 103 or 4000 < 2n + 1.
2(n + 1) 1
To ensure this accuracy requirement we need n 2000.
b. How many terms are required to ensure the 1010 accuracy needed for an

approximation to ?

Solution: In this case we need


4
< 1010
2(n + 1) 1

or

n > 20, 000, 000, 000.

Clearly, a more rapidly convergent method is needed for this approximation.


10.

b. Find the rate of convergence of

1
lim sin 2
n
n


=0

as n .
Solution: The second Taylor polynomial for f (x) = sin x about x0 = 0 and its
remainder term are sin x = x 16 (cos x )x 3 . We let x = n12 to obtain
sin

1
1
= 2
2
n
n

1
cos
6



1
n2

3

16

CHAPTER 1. MATHEMATICAL PRELIMINARIES

where is between 0 and

1
.
n2

Since | cos | 1 we have



 

1

 1 cos 1  2 .
 n2
6
6
n  n2

Thus,

 


 


sin 1 0 2  1 
 n2 
 n2

 
and the rate of convergence of sin n12 is O n12 .
12.

a.

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


i
n

ai b j ?

i=1 j=1

Solution: For each i the inner sum

j=1 ai b j

requires i multiplications and i 1

additions, for a total of


n

i=1

and

i=

n(n + 1)
2

i 1=

i=1

Multiplications

n(n + 1)
n
2

Additions.

Once the n inner sums are computed, n 1 additions are required for the nal sum.
The nal total is:
n(n + 1)
2

Multiplications

(n + 2)(n 1)
2

and

Additions.

b. Re-express the series in a way that will reduce the number of calculations

needed to determine this sum.


Solution: By rewriting the sum as
n
i

i=1 j=1

ai b j =

n

i=1

ai

i

j=1

bj

EXERCISE SET 1.4

17

we can signicantly reduce the amount of calculation. For each i we now need i 1
additions to sum b j s for a total of
n

i 1=

i=1

n(n + 1)
n
2

Additions.

Once the b j s are summed we need n multiplications by the ai s, followed by n 1


additions of the products.
, but the number of multipliThe total additions by this method is still (n+2)(n1)
2
cations has been reduced from n(n+1)
to
n.
2
13.

Consider the Fibonacci sequence dened by


F0 = 1,

F1 = 1,

and

Fn+2 = Fn+1 + Fn , if n 0,

and dene
xn = Fn+1 /Fn .
Assuming that
lim xn = x

converges, show that the limit is the golden ratio:

1+ 5
.
x=
2
Solution: Since
lim xn = lim xn+1 = x

we have
x =1+

1
x

and

xn+1 = 1 +

1
,
xn

x 2 x 1 = 0.

The only positive solution to this quadratic equation is x = (1 + 5)/2.


14.

which implies that

The Fibonacci sequence also satises the equation



n
n 
1
+
1
1

5
5
Fn Fn =
.

2
2
5

18

a.

CHAPTER 1. MATHEMATICAL PRELIMINARIES

Write a Maple procedure to calculate F100 .


Solution: We have
>n:=98;f:=1;s:=1;
n :=98
f :=1
s :=1
>for i from 1 to n do
> l:=f+s;f:=s;s:=l;
>od;
l :=2
f :=1
s :=2
l :=3
f :=2
s :=3
l :=5
..
.
l :=218922995834555169026
f :=135301852344706746049
s :=218922995834555169026
l :=354224848179261915075

b. Use Maple with the default value of Digits followed by evalf to calculate

F100 .

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

 


1 1 100
1 1 100
1
+

5
5
F100 :=
5
2 2
2 2

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 the
result in part (b) is computed using 10-digit rounding arithmetic.

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

from part (a)?


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

What results when you use the command simplify instead of evalf to
compute F100 ?
Solution: The result is the same as the result in part (a).
The harmonic series

15.

1+

1 1 1
+ + +
2 3 4

diverges, but the sequence


n = 1 +

1
1
+ + ln n
2
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 of Digits in Maple to determine the value of n for
to be within 102 .

b. Use the default value of Digits in Maple to determine the value of n for

to be within 103 .

20

c.

CHAPTER 1. MATHEMATICAL PRELIMINARIES

What happens if you use the default value of Digits in Maple to determine the value of n 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<t then dne:=0
> else n:=n+1;
> fi;
> od;
> n;
>end;
>g(0.01);
>g(0.001);
>g(0.0001);
The results from the procedure are
a. 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<tol then dne:=0
> else n:=n+1;
> fi;
>od;
>n;

You might also like