Ln(x) using repeated square root extraction
03-21-2016, 07:11 AM
Post: #3 Paul Dale Senior Member Posts: 1,733 Joined: Dec 2013
RE: Ln(x) using repeated square root extraction
I've got a feeling I tried something along these lines for the LN function of the 34S. The LN function has always been very slow on the 34S and I've tried several implementations to try to get both performance and accuracy. The current implementation is much faster than the original but still far slower than I'd like. I ended up with:

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.
*/

- Pauli
 « Next Oldest | Next Newest »

 Messages In This Thread Ln(x) using repeated square root extraction - Gerson W. Barbosa - 03-21-2016, 12:03 AM RE: Ln(x) using repeated square root extraction - Gerson W. Barbosa - 03-21-2016, 05:09 AM RE: Ln(x) using repeated square root extraction - Paul Dale - 03-21-2016 07:11 AM

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