Topic: The "famous" HP35 exp(ln2.02) bug

Hello All,

Firstly I must say, I have really enjoyed reading Jacques excellent description of the HP35 - especially the Cordic functions and the famous Ln(2.02) bug in the first batch of calculators.

In the errata sheet for the HP35, they say that the error is not above the 1% level (for the bug).

Has anyone found a value of x in the buggy version calculator, where exp(ln(x)) would lead to an answer "greater" than a 1% error?

Regards Kiwi Geoff.
http://www.geocities.com/kiwi_36_nz

Topic: The "famous" HP35 exp(ln2.02) bug

Hello Geof,

Thank your for the kind words and encouraging feedback.

Regarding the famous bug, I spent a lot of time last year on that historical point.

The « errata sheet » and the letter from Ron Stevenson are pure marketing communication. The so called “idiosyncrasy” is clearly a bug and we know from Dijkstra (1968) that « Program testing can be used to show the presence of bugs, but never to show their absence! »

There are 2 malfunctions in this "exp(ln (2.02))=2" bug:
1-    the floating point leak of precision in chaining Cordic for ln(x) and for exp(x),
2-    the “crash” of the exp(x) cordic algorithm called with an unexpected pattern.


ln(2.02) = ln( 2 x 1.01) = ln(2) + ln(1.01)
by definition.

The Cordic implemented by Cochran performs the pseudo division process by successive subtractions (q1q2q3 … the number of possible subtractions) (clock wise rotations) and next it will execute the rotations (counter clock wise) on the remainder.

The case of the bug is quite trivial:
q1= 2, q2=1.1, q3=1.01

Theoretically (no precision problem) to the number ln(2.02)= 0.7030975114
the algorithm first tries to subtract ln(2) stored as 0.693147180553 =OK, the result is 0.009950330847 and next, tries to subtract ln(1.1) = KO.
The next try is ln(1.01)  stored as 0.00995033085090.
previous remainder = 0.009950330847 - 0.00995033085093

Which does not give zero –as expected –  due to difference of precision: r < 0.00995033085093.

The constants in ROM are stored left aligned with a maximum of precision whereas ln(2.02) =  0.7030975114 has been computed previously hence normalized as C=07030975114999.
(the constants are stored in ROM with 12 digit precision while the intermediate normalized result is just 10 digits).

The rest of the story is sad the algorithm subtracts 9 times ln(1.001), 9 times ln(1.0001) and 5 times ln(1.00001).

The pseudo quotients are “599001” where they should be “000101” and this unexpected pattern causes a register overflowing in part 2 (cordic rotations) because the algorithm was not tailored accordingly.

Look at the correction, embarked in the HP-65, HP-21 & HP-25 (I will check in the 67) : it is just quick fix : the precision of the remainder (input of the second part) is reduced to avoid overflow.

Now, your question:

Is it possible with another couple of numbers?

The overflow can occur only with combinations of big “pseudo quotients”: number ln(2)  ln(1.1) and ln(1.01) possibly multiplied by an integer value ; the rest of the pseudo quotients are too small to cause the overflow (AFAIK).

On my buggy HP35 exp(ln(2) * ln(1.1)) is Ok, only exp(ln(2)*ln(1.01)) is faulty.
It depends on the  pseudo quotient decomposition pattern. 

Best regards,
Jacques.

Topic: The "famous" HP35 exp(ln2.02) bug

Dear Jacques,

Thankyou so much for your detailed reply - slowly my mind is coming around to the "magic" in the Cordic algorithms.

I thought I should explain why I raised my question Jacques.

I wanted to use the simulator code to play with some numbers (I don't have a buggy HP35).

I tried exp(ln(2.02)) and got the answer 2 (which shows it is the buggy ROM code).

I then played with various number sequences and I found the following:

exp(ln(0.1)) = 3.2E-12
exp(ln(0.01)) = 3.2E-13
exp(ln(0.001)) = 3.2E-14
exp(ln(0.0001)) = 3.2E-15

Clearly the above numbers are greater than a 1% error as per the exp(ln(2.02)) case.

So it seemed as if I had detected a number sequence that was "new" to this issue in the buggy ROM.

Spending a little more time on your wonderful informative website, I then found the reason for the above numbers.

There are indeed three (3) HP35 simulators on your website, and the one I found the above numbers on is:

../sim35test.htm

Some more careful reading showed that the above simulator uses the ROM code from the "fixed" version, however you have changed address 2122 and 2123 to nop's to prove some of your findings.

So the four extreme cases I found above, would not actually be found on a real HP35 calculator (of any version).

So I understand now what I did wrong Jacques - and what caused me to raise the initial question.

There is still a lot for me to learn from your web site and wonderful work.

Over the next few months I hope to slowly work my way through your site (as spare time permits).

Many thanks Jacques.

Kind Regards, Geoff (New Zealand).
http://www.geocities.com/kiwi_36_nz

Topic: The "famous" HP35 exp(ln2.02) bug

Hello Geoff,

Kiwi Geoff wrote:

So it seemed as if I had detected a number sequence that was "new" to this issue in the buggy ROM.

Spending a little more time on your wonderful informative website, I then found the reason for the above numbers.

There are indeed three (3) HP35 simulators on your website, and the one I found the above numbers on is:

http://www.jacques-laporte.org/sim35test.htm

Some more careful reading showed that the above simulator uses the ROM code from the "fixed" version, however you have changed address 2122 and 2123 to nop's to prove some of your findings.

What I named « version X » in my article is a pure fiction, a trick I used to isolate the « famous bug ».
I remember well that night of March 2006, I replace two instructions by 2 NOP  in the new ROM and bingo! the bug appears wink.

In reality, Cochran, did a lot of changes in the buggy ROM, much more than 2 simple instructions, that explains the side effet you discovered.
But it does not appear on a real buggy ROM or on the simulator running the buggy rom image.

You can find the simulator running the real old buggy ROM here :

http://www.jacques-laporte.org/sim35bugs.htm

Peter Monta dumped it in his genial optical way ; later I did it myself using a rather raw electronic “kludge”, capturing the serial flow “key by key” and confirming Peter’s work (my way was a non invasive one ; I own just one buggy HP-35).
I will clarify the relevant page.
If you need more details on this issue, I’ll be glad to help you.
All the best,
Jacques