208
Appendix:
Accuracy
of
Numerical
Calculations
The
last
three cases show
how
severe
are the
results
of
perturbing
the
10th significant digit
of any
coefficient
of any
quadratic whose
roots
are
nearly coincident.
The
correct roots
for
these
cases
are
Case
4: 1 and
0.9999969434
Case
5:
62.77179203
±
J8.5375
X
10~5
Case
6:
12.21711755
±i'0.001374514
Despite
errors
in the fifth
significant digit
of
the
results, subroutine
"A"
suffices
for
almost
all
engineering
and
scientific applications
of
quadratic equations.
Its
results
are
correct
to
nine significant
digits
for
most data, including
c,
b,
and a
representable exactly
using only
five
significant digits;
and the
computed roots
are
correct
to at
least
five
significant digits
in any
case because they
cannot
be
appreciably worse
than
if the
data
had
been entered with
errors
in the
10th significant
digit.
Nonetheless, some
readers
will
feel
uneasy about results calculated
to 10
significant digits
but
correct
to
only
5. If
only
to
simplify
their understanding
of the
relationship between input
data
and
output results, they might
still
prefer
roots correct
to
nine significant digits
in all
cases.
Programs
do
exist which, while carrying only
10
significant digits
during arithmetic, will calculate
the
roots
of any
quadratic
correctly
to at
least nine significant
digits
regardless
of how
nearly coincident those roots
may be. All
such programs calculate
d
=
b2
— ac by
some trick tantamount
to
carrying
20
significant
digits whenever
b2
and ac
nearly cancel,
so
those programs
are a
lot
longer
and
slower
than
the
simple subroutine
"A"
provided
above.
Subroutine
"B"
below,
which uses such
a
trick,*
is a
very
short program
that
guarantees nine correct significant
digits
on a
10-digit
calculator.
It
uses labels "B",
".7",
and
".8"
and
registers
R0
through
R9
and the
Index register.
To use it, key in c |
ENTER
| b
I
ENTER
|a,
run
subroutine "B",
and
wait
for
results
as
before.
Keystrokes
Display
000-
001-42,21,12
002-
44 25
003-
33
*Program
"B"
exploits
a
tricky property
of the
|_£-|
and |
S
+
|
keys whereby certain
calculations
can be
carried
out to 13
significant digits
before
being rounded back
to 10.
'~-