Keystrokes display – HP 15c User Manual

Page 152

Advertising
background image

152

Appendix: Accuracy of Numerical Calculations

152

She calculated $376,877.67 on her HP-15C, but the bank's total was $333,783.35, and this
latter total agrees with the results calculated on good, modern financial calculators like the
HP-12C, HP-37E, HP-38E/38C, and HP-92. Where did Susan's calculation go awry? No
severe cancellation, no vast accumulation of errors; just one rounding error that grew
insidiously caused the damage:

i/n

= 0.000000003567351598

1 + i/n = 1.000000004

when rounded to 10 significant digits. There is the rounding error that hurts. Subsequently
attempting to calculate (1+i/n)

n

, Susan must get instead (1.000000004)

31,536,000

=

1.134445516, which is wrong in its second decimal place.

How can the correct value be calculated? Only by not throwing away so many digits of i/n.
Observe that

n

i

n

e

n

n

i

1

ln

1

,

so we might try to calculate the logarithm in some way that does not discard those precious
digits. An easy way to do so on the HP-15C does exist.

To calculate λ(x) = ln(1+x) accurately for all x>−1, even if |x| is very small:

1. Calculate u = 1 + x rounded.

2. Then

.

1

1

)

ln(

1

)

(

u

if

u

x

u

u

if

x

x

The following program calculates λ(x) = ln(1+x)

Keystrokes

Display

´CLEARM

000-

´bA

001-42,21,11

Assumes x is in X-register.

v

002- 36

v

003- 36

004- 26

Places 1 in X-register.

+

005- 40

Calculates u = 1 + x rounded.

|N

006- 43 12

Calculates ln(u) (zero for u = 1).

®

007- 34

Restores x to X-register.

|K

008- 43 36

Recalls u.

009- 26

Places 1 in X-register.

|T6

010-43,30, 6

Tests u≠1.

Advertising