Post Reply 
Ln(x) using repeated square root extraction
03-03-2022, 11:20 PM
Post: #4
RE: Ln(x) using repeated square root extraction
Formula

We can use the following identity:

\(\log(x) = n \log\left(x^{\frac{1}{n}}\right) = n \log\left(\sqrt[n]{x}\right)\)

For say \(n = 2^{10} = 1024\) and \(1 \leqslant x \leqslant 100 \) the value of \(\sqrt[n]{x}\) is close to \(1\).

Thus we can use the Taylor series to calculate the logarithm:

\(\log(1 + \varepsilon) = \varepsilon - \frac{\varepsilon^2}{2} + \frac{\varepsilon^3}{3} - \frac{\varepsilon^4}{4} + \frac{\varepsilon^5}{5} + \mathcal{O}(\varepsilon^6)\)

Program

Here's a program for the HP-42S that calculates both the logarithm and its approximation:
Code:
LN  LASTX
SQRT  SQRT  SQRT  SQRT  SQRT
SQRT  SQRT  SQRT  SQRT  SQRT
1  -
4  1/X  RCL× ST Y
3  1/X  X<>Y  -  RCL× ST Y
2  1/X  X<>Y  -  RCL× ST Y
1  X<>Y  -  ×
1024  ×

It's easy to extend if you want to use more terms.

Example

x = 2

0.69314718056
0.69314718056


Comparison

We can compare this to your solution:

\(\sqrt{2(1 + \varepsilon) - 1} - 1\)

The Taylor series agrees for the first two terms:

\(\varepsilon - \frac{\varepsilon^2}{2} + \frac{\varepsilon^3}{2} - \frac{5 \varepsilon^4}{8} + \frac{7 \varepsilon^5}{8} + \mathcal{O}(\varepsilon^6)\)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Ln(x) using repeated square root extraction - Thomas Klemm - 03-03-2022 11:20 PM



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