Ln(x) using repeated square root extraction
03-03-2022, 11:20 PM
Post: #4
 Thomas Klemm Senior Member Posts: 1,616 Joined: Dec 2013
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)$$
 « 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 RE: Ln(x) using repeated square root extraction - Thomas Klemm - 03-03-2022 11:20 PM RE: Ln(x) using repeated square root extraction - Albert Chan - 03-06-2022, 12:04 AM RE: Ln(x) using repeated square root extraction - Dan C - 03-05-2022, 05:32 PM RE: Ln(x) using repeated square root extraction - Dan C - 03-05-2022, 05:53 PM RE: Ln(x) using repeated square root extraction - Dan C - 03-05-2022, 08:02 PM RE: Ln(x) using repeated square root extraction - Namir - 03-05-2022, 08:29 PM RE: Ln(x) using repeated square root extraction - Thomas Klemm - 03-05-2022, 08:39 PM RE: Ln(x) using repeated square root extraction - Albert Chan - 03-06-2022, 12:50 AM RE: Ln(x) using repeated square root extraction - Thomas Klemm - 03-06-2022, 09:33 AM RE: Ln(x) using repeated square root extraction - Albert Chan - 03-09-2022, 07:47 PM RE: Ln(x) using repeated square root extraction - Thomas Klemm - 03-10-2022, 05:18 AM RE: Ln(x) using repeated square root extraction - Albert Chan - 03-10-2022, 03:17 PM

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