Ln(x) using repeated square root extraction
|
03-21-2016, 12:03 AM
(This post was last modified: 04-11-2020 12:00 AM by Gerson W. Barbosa.)
Post: #1
|
|||
|
|||
Ln(x) using repeated square root extraction
Algorithm:
1. Enter x; 2. Take the square root 6 times; 3. Multiply by 2; 4. Subtract 1; 5. Take the square root; 6. Subtract 1; 7. Multiply by 64. For x = 2, on an 8-digit calculator like the Canon LC-37, you should get ln(2) ~ 0.693152. For 10-digit calculators, in step 2 take the square root 9 times and multiply by 512 in the last step. Thus, on the HP-12C, which has two guard digits, we get ln(2) ~ 0.693147648. Ordinary 10-digit calculator might give less approximate results. A 4-step less accurate algorithm is available in this old thread: http://www.hpmuseum.org/cgi-sys/cgiwrap/...ead=145192 The accuracy range should be tested for your particular calculator. Use these at your own risk. Gerson. Method: \[\ln (x)=\int_{1}^{x}\frac{du}{u}=\int_{1}^{x}u^{-1}du=\lim_{v\rightarrow 0}\left | \frac{u^{v}}{v} \right |_{1}^{x}=\lim_{v\rightarrow 0} \left ( \frac{x^{v}}{v}-\frac{1^{v}}{v} \right )=\lim_{v\rightarrow 0} \left ( \frac{x^{v}-1}{v} \right )\] By testing the limit with a few values for v close to zero, an empirical second term has been able to be added to the expression: \[\ln (x)=\lim_{v\rightarrow 0} \left ( \frac{x^{v}-1}{v}-\frac{v\cdot \ln^{2}(x)}{2} \right )\] After turning the limit into an equality and solving the resulting quadratic equation for ln(x), we get \[\ln (x)=\lim_{v\rightarrow 0} \left ( \frac{\sqrt{2\cdot x^{v}-1}-1}{v} \right )\] Example: Let x = 2 and v = 0.001 Then \[\ln (2)\approx \frac{\sqrt{2\cdot 2^{0.001}-1}-1}{0.001}\approx 0.69314723\] which is good to 6 decimal places ( ln(2) = 0.69314718 ). P.S.: Perhaps 8 square root extractions and final multiplication by 256 (2^8) is a better compromise for the range 2..100 on the Canon LC-37. Contrary to what I thought its SILVA-CELL 189 battery is still working after all these years, so I was able to make some more tests. :-) ----------------------------------- Good Friday 2020 Update The following expression allows us to go further: \[\ln (x)=\lim_{v\rightarrow 0} \left ( \frac{x^{v}-1}{v}-\frac{v\cdot \ln^{2}(x)}{2!} -\frac{v^{2}\cdot \ln^{3}(x)}{3!} -\frac{v^{3}\cdot \ln^{4}(x)}{4!} - \cdots \right )\] By going up to the third power of ln(x) and solving the corrisponding cubic equation, we get \[\ln (x)=\lim_{v\rightarrow 0}\frac{1}{v}\left ( \sqrt[3]{\sqrt{9x^{2v}-6x^{v}+2}+3x^{v}-1} - \frac{1}{\sqrt[3]{\sqrt{9x^{2v}-6x^{v}+2}+3x^{v}-1}} - 1 \right )\] For example, if x = 2 and v = 0.01 then ln(2) ~ 0.69314719 This approximation is rather complicated for manual calculations. Also, it requires one cubic root extraction. It can be used, however, as an alternative method for implementing the ln(x) function to 7 significant digits on calculators that lack it, like the HP-16C. The e^x function has also been implemented. Since it's based on the first formula, obtained by solving a quadratic equation, and uses a constant number of loops, it gives less significant digits. The cubic root algorithm is optimized for the narrow range required by the approximation formula and was based one provided by Albert Chan here. Code:
Examples: 2 GSB A -> 0.6931471(360) GSB B -> 2.0000(13165) 12345 GSB A -> 9.421006(848) GSB B -> 12345.0(1957) 6.789 EEX 79 GSB A -> 183.8195(343) GSB B -> 6.(686887E79) 0.12345 GSB A -> -2.091919(104) GSB B -> 0.123450(119) 230 GSB B -> 7.496895E99 GSB A -> 229.97041(15) 1 GSB A -> 0.000000000 GSB B -> 1.000000000 GSB B -> 2.7182(92170) GSB B -> 15.1544(4181) GSB A -> 2.71829(4016) GSB A -> 1.000004(736) GSB A -> 0.000004736 0.693147181 CHS GSB B -> 0.500000(16) 10 GSB A -> 2.302585(344) STO 2 2 GSB A RCL 2 / -> 0.3010299(435) 0 GSB A -> Error 0 2 CHS GSB A -> Error 0 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)