Post Reply 
Natural logarithm of 2 [HP-15C/HP-42S/Free42 & others]
10-12-2019, 12:47 PM (This post was last modified: 10-12-2019 12:49 PM by Paul Dale.)
Post: #4
RE: Natural logarithm of 2 [HP-15C/HP-42S/Free42 & others]
The WP 34S algorithm for logarithms might be appropriate here:

Code:
/* Natural logarithm.
 *
 * Take advantage of the fact that we store our numbers in the form: m * 10^e
 * so log(m * 10^e) = log(m) + e * log(10)
 * do this so that m is always in the range 0.1 <= m < 2.  However if the number
 * is already in the range 0.5 .. 1.5, this step is skipped.
 *
 * Then use the fact that ln(x^2) = 2 * ln(x) to range reduce the mantissa
 * into 1/sqrt(2) <= m < 2.
 *
 * Finally, apply the series expansion:
 *   ln(x) = 2(a+a^3/3+a^5/5+...) where a=(x-1)/(x+1)
 * which converges quickly for an argument near unity.
 */

Either use an argument of 2 directly or take advantage of \( \frac{\sqrt{2} - 1}{\sqrt{2} + 1} = 3 - 2 \sqrt{2} \).


Pauli
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Natural logarithm of 2 [HP-15C/HP-42S/Free42 & others] - Paul Dale - 10-12-2019 12:47 PM



User(s) browsing this thread: 1 Guest(s)