 The Museum of HP Calculators

HP Forum Archive 18

 An old logrithm algorithmMessage #1 Posted by Palmer O. Hanson, Jr. on 26 Dec 2008, 10:41 a.m. While reviewing some old slide rule manuals as a part of participation in some recent threads I also looked at some old calculator manuals. I found the following material on pages 33 and 34 of the manual for the Texas Instruments SR-10: Quote: Logarithmic and Exponential Functions The value of log a can be determined to within +/-0.04% using the square root key. If you repeatedly take the square root of any number, the value will approach unity with a remainder that is proportional to the logarithm of the original number. Because of the eight digit acuracy of the SR-10, the optimum number of times to take the square root is eleven. For 4 <= a <= 40, the manual prescribes 1. Enter the value of a. 2. Take the square root eleven times. 3. Subtract 1. 4. Multiply by 889. The manual gives an example for the common logarithm of 12: 1. Enter 12 2. Take the square root eleven times and see 1.001214 3. Subtract 1 and see 0.001214 4. Multiply by 889 and see 1.079246 which is within 0.006% 0f the correct value of 1.079181. I haven't been able to locate a reference describing this technique. I thought that I should be able to get there with the use of infinite series but I haven't been able to push that through. Can anyone help? Palmer

 Re: An old logrithm algorithmMessage #2 Posted by Thomas Klemm on 26 Dec 2008, 12:23 p.m.,in response to message #1 by Palmer O. Hanson, Jr. Use the definition of Set n = 2^11 = 2048 and solve for x to find an approximation of LN(y): x = 2048 * (y^(1/2048) - 1). Use LOG(y) = LN(y)/LN(10). Thus instead of multiplying with 2048 use 2048/LN(10) ~ 889. Best regards Thomas Klemm

 Re: An old logrithm algorithmMessage #3 Posted by Namir on 26 Dec 2008, 12:25 p.m.,in response to message #1 by Palmer O. Hanson, Jr. Palmer, You post remind me of an old algorithm I cam acroos that can be used to calculate natural log and exponential (if you reverse the operations) values. e^x = (1 + x/n)^n .. where n is large enough (2048 and higher) The reverse would be: ln(x) = n*(x^(1/n) - 1) where n is large enough (2048 and higher) The power 1/2048 is equivalent to taking the square root 11 times. In the late 70s, I used to approximate e^x and ln(x) with simple calculators that had the square root. Namir Edited: 26 Dec 2008, 12:35 p.m.

 Re: An old logrithm algorithmMessage #4 Posted by Namir on 28 Dec 2008, 10:33 a.m.,in response to message #3 by Namir As the equations in my post, and those of other folks, show, the number 2048 (2 to the power of 11) used to calculate the exponential or logarithm can be replaced by even higher powers of 2. I checked the errors and found that the error has the following form: error = A e(-B N) (for 5 <= N <= 16) Where N is the power of 2 used, and A and B are constants that depend on the argument for exp(x) or for ln(x). Edited: 28 Dec 2008, 10:34 a.m.

 Re: An old logrithm algorithmMessage #5 Posted by Gerson W. Barbosa on 26 Dec 2008, 12:57 p.m.,in response to message #1 by Palmer O. Hanson, Jr. This comes from the limit definition of ln(x): / 1/n \ ln(x) = lim n | x - 1 | n->oo \ / http://kr.cs.ait.ac.th/~radok/math/mat/chap9.htm Scroll down to section 9.216 It appears n=2048 (2^11) is close enough to infinity to grant that level of accuracy in the given range. And 2048/889 (2.30371) is close enough to ln(10) (2.30258) to be used as a natural log to common log factor conversion. I hope this might explain the algorithm. Regards, Gerson. Edited: 26 Dec 2008, 5:22 p.m.

 Re: An old logrithm algorithmMessage #6 Posted by Chuck on 26 Dec 2008, 4:35 p.m.,in response to message #1 by Palmer O. Hanson, Jr. A couple of other things of interest... Graph the equation 10^(889(x^(1/2048)-1))-x and see what happens when the 889 is changed to either 890 or 888. Also, if you write the equation as 10^(A(x^(1/2048)-1))-x, and solve for A for a particular x (ie x=40) you find that A=888.6343. Fun stuff for a snowy afternoon. CHUCK

 Re: An old logrithm algorithmMessage #7 Posted by Palmer O. Hanson, Jr. on 26 Dec 2008, 10:27 p.m.,in response to message #1 by Palmer O. Hanson, Jr. Thanks to all for the prompt responses. That's what I love about this forum. Palmer

 Re: An old logrithm algorithmMessage #8 Posted by Namir on 27 Dec 2008, 9:08 a.m.,in response to message #7 by Palmer O. Hanson, Jr. Palmer, You are so welcome. I enjoy sharing algorithms, because I can then implement them on a whole variety of machines and languages. I remember 30 years ago I can across the definition of the e^x using the limits. I used to chat with different engineers (mostly with simple calculators that had the square root) and showed them how to approximate ln(x) and exp(x). That seem to impress them. Namir

 Re: An old logrithm algorithmMessage #9 Posted by PatrickS on 26 Dec 2008, 10:47 p.m.,in response to message #1 by Palmer O. Hanson, Jr. The Texas Instruments SR-10 was my first-ever calculator. My dad purchased it for me somewhere around 1974-75 for about \$100 (Canadian). Of course, I read the manual cover-to-cover and vividly remember reading about this nifty logarithm technique. I actually put it to use on several occasions, mostly in chem lab. While knowing this trick was like a secret-decoder ring in it's novelty, I was nevertheless jealous of my more affluent friends whose dad's bought them the incredible SR-52 (\$250) with it's one key log / trig capabilities. But that SR-10 was still waaayyy better than the one-to-two digit accuracy I was getting previously with my (metal) Stirling slide rule. Of course, even then I knew of the superiority of HP calculators, but the price tags of the then-current models (HP-45, 55 and 65) were far out of reach. It was only a year or so later that I was introduced to the techniques of calculus and learned how and why this multi-square root trick worked. Go back to the main exhibit hall