|Re: Scientific calculators, usage of exp|
Message #4 Posted by Ex-PPC member on 4 June 2002, 7:05 a.m.,
in response to message #3 by Renato
Yes, the article is in:
Hewlett-Packard Journal, November 1976
"The New Accuracy: Making 2**3 = 8"
The HP-25C (for instance) had the innacurate algorithm
while the HP-67 used the new one, if I'm not wrong. I also
remember that the first calculator to feature the improved
algorithm was the Topcat series HP-91.
As for implementing x^2 by direct multiplication
instead of using the much slower y^x algorithm (which
does it as log, multiplication, antilog as stated), one
of the worst cases I've ever seen was the computation of
sqr(x) [square root of x] in the Sinclair Spectrum
micro-computer of the 80's [sold in USA under the namebrand
Usually the square root is computed using a very fast
algorithm, so fast that computing a square root takes
almost the same time as a single division operation. But
in the Spectrum, it was computed so:
sqr(x) = x^0.5 = exp(0.5*log(x))
so it took a log, a multiplication, and an antilog as well.
Both the log and the antilog used Chebyshev series
expansions, i.e.: many, many multiplications and divisions.
The final result was that on the Sinclair the square root,
far from being comparable in speed to a single division, was in fact one of the slowest math functions available.
It wasn't the slowest, either, because there were
others that did use sqr itself ! Some trigonometric
functions were calculated as functions of others, so
they ended using square roots, and they were incredibly slow !!
Why did the people who wrote the BASIC interpreter use
such an inefficient way of computing the square root ?
Simple: because of lack of space in the ROM. They had just
16 Kbytes (!!) to implement a complex dialect of BASIC, with
many, many commands plus an underlying 'operating system'.
So they had to economize and optimize as much as possible.
And computing sqr(x) as e^(0.5)*log(x)) saved a *lot* of
bytes, badly needed for other features.
Has this anything to do with HP calcs ? Yes. If you
get a copy of the *wonderful* HP-15C "Advanced Functions"
manual, you'll read the experts at HP discussing the
necessary tradeoffs between accuracy and speed/space needed.
In the case of the HP-15C, this has to do with the
guaranteed accuracy for the complex functions, which
cannot be computed to the same accuracy as their real-only
equivalents unless you make them *four* times slower and
use a lot of valuable ROM for very unfrequent, boundary cases.
In HP-15C AF you'll learn why this is so, and specific
worst cases are given, as well as sample programs to
demonstrate how it could be done if necessary. Although
the examples are given for the HP-15C, all the discussion
applies equally well to the next generations of HP calcs
which followed the HP-15C, all of them using the same
algorithms, for instance:
- - the 41C Advantage ROM advanced functions for SOLVE
and INTEGRATE were taken from the HP-15C.
- - the HP-71B equivalent advanced functions present in the Math ROM, FNROOT and INTEGRAL, as well as
complex functions, were also taken from the HP-15C, while
the matrix functions were taken partly from the HP-15C
and partly from the HP-75C Math ROM and the HP-85 Matrix ROM.
- - all subsequent Saturn-based calculators, such
as the HP-42S up to the latest HP48/49, did inherit
those basic algorithms as well.
So, you, see, the HP-15C AF manual is essential
reading if you are interested in this particular topic.