HP 15c User Manual

Page 172

Advertising
background image

172

Appendix: Accuracy of Numerical Calculations

172

Example 6 Continued. The program listed below solves the real quadratic equation c − 2 bz
+ az

2

= 0 for real or complex roots.

To use the program, key the real constants into the stack (c v b v a) and run
program "A".

The roots x and y will appear in the X- and Y-registers. If the roots are complex, the C
annunciator turns on, indicating that Complex mode has been activated. The program uses
labels "A" and ".9" and the Index register (but none of the other registers 0 to .9); therefore,
the program may readily be called as a subroutine by other programs. The calling programs
(after clearing flag 8 if necessary) can discover whether roots are real or complex by testing
flag 8, which gets set only if roots are complex.

The roots x and y are so ordered that |x| ≥ |y| except possibly when |x| and |y| agree to more
than nine significant digits. The roots are as accurate as if the coefficient c had first been
perturbed in its 10th significant digit, the perturbed equation had been solved exactly, and its
roots rounded to 10 significant digits. Consequently, the computed roots match the given
quadratic's roots to at least five significant digits. More generally, if the roots x and y agree to
n significant digits for some positive n ≤ 5, then they are correct to at least 10 − n significant
digits unless overflow or underflow occurs.

Keystrokes

Display

´CLEARM

000-

´bA

001-42,21,11

v

002- 36

|(

003- 43 33

*

004- 20

|K

005- 43 36

®

006- 34

|(

007- 43 33

OV

008- 44 25

|x

009- 43 11

-

010- 30

|T1

011-43,30, 1

t.9

012- 22 .9

013- 16

¤

014- 11

´XV

015-42, 4,25

|T2

016-43,30, 2

l-V

017-45,30,25

|T3

018-43,30, 3

l+V

019-45,40,25

|T0

020-43,30, 0

Advertising