Talk:Natural logarithm/Archive 2

What exactly do we mean by "cubic convergence"?
For simplicity, I will assume here that x ≥ 1 and thus ln (x) ≥ 0. If we apply Halley's method to our situation (trying to calculate the natural logarithm of x), using f(y) = exp (y) - x as we do in Natural logarithm, then we get the following
 * $$\ln (x) - 2 \ \frac{x - 1}{x + 1} = \frac{3 \exp (\eta) - 2 \exp (\xi)}{12 - 6 (1 - x)} (\ln (x))^3 $$

for
 * $$ 0 \le \eta, \xi \le \ln (x) $$.

Thus
 * $$\frac{3 - 2 x}{6 (x + 1)} (\ln (x))^3 \, \le \, \ln (x) - 2 \, \frac{x - 1}{x + 1} \, \le \, \frac{3 x - 2}{6 (x + 1)} (\ln (x))^3 $$.

To extend this to 0 < x ≤ 1, replace x by 1 / x and observe that the result can be returned to the same form.

After that one can replace x by x / exp (yn), getting
 * $$\frac{3 \exp (y_n) - 2 x}{6 (x + \exp (y_n))} (\ln (x) - y_n)^3 \, \le \, \ln (x) - y_{n+1} \, \le \, \frac{3 x - 2 \exp (y_n)}{6 (x + \exp (y_n))} (\ln (x) - y_n)^3 $$.

OK? JRSpriggs (talk) 14:52, 1 May 2018 (UTC)

It is also useful to notice that for x > 0,
 * $$ 0 < \frac{d}{d x} \left(2 \, \frac{x - 1}{x + 1} \right) = \frac{4}{(x + 1)^2} < \frac{1}{x} = \frac{d \ln (x)}{d x} $$

and thus
 * $$ \ln (x) \le 2 \, \frac{x - 1}{x + 1} \le 0 \text{ or } 0 \le 2 \, \frac{x - 1}{x + 1} \le \ln (x) $$.

Consequently,
 * $$ \ln (x) \le y_{n + 1} \le y_{n} \text{ or } y_{n} \le y_{n + 1} \le \ln (x) $$,

that is, the iteration never overshoots. JRSpriggs (talk) 09:16, 2 May 2018 (UTC)

While
 * $$ x \approx \exp (y_n) \, \Rightarrow \, \ln (x) - y_{n+1} \approx \frac{1}{12} (\ln (x) - y_n)^3 $$,

it may be more useful to know how close to the "root" ln (x) one has to be before the cubic convergence becomes effective. More on this later. JRSpriggs (talk) 09:30, 2 May 2018 (UTC)

I did some calculations and got
 * $$ \vert \ln (x) - y_n \vert < 1 \, \Rightarrow \, \vert (\ln (x) - y_{n+1}) - \frac{1}{12} (\ln (x) - y_n)^3 \vert \le \frac{0.52}{24} \vert \ln (x) - y_n \vert^4 .$$

Since ln(x)-yn+1 is an odd function of ln(x)-yn, it should be possible to increase the exponent of the bound from 4 to 5. However, I doubt that the extra effort would be worthwhile since this does nothing to get rid of the cubic term. For that, we would need a better function in the iteration. JRSpriggs (talk) 21:41, 4 May 2018 (UTC)

Belatedly, I realized that the calculations I was doing were a round-about way of getting the Taylor series of a certain function
 * $$ f (z) = z - 2 \frac{\exp (z) - 1}{\exp (z) + 1} = z - 2 \tanh \left(\frac{z}{2}\right) $$.

That made it a lot simpler. However, although I have reason to think that the coefficients will remain small numbers, the expression I have for the derivatives produces large positive and large negative numbers which mostly cancel. This means that it is still not easy, and so I cannot yet determine the error bound.
 * $$ \ln (x) - y_{n+1} = \frac{1}{12} (\ln (x) - y_n)^3 + \frac{-1}{120} (\ln (x) - y_n)^5 + O ( (\ln (x) - y_n)^7 ) .$$

More terms can be determined from hyperbolic function. JRSpriggs (talk) 02:27, 6 May 2018 (UTC)

The main cost of performing an iteration is calculating the exponential of yn. We can use the formula I gave in my first comment in this section to avoid doing the last exponential before comparing it to x to see whether it is close enough. Here is pseudo-code for the algorithm:
 * input x and tolerance.
 * verify that they are positive real numbers.
 * let y := 0.
 * let expy := 1.
 * begin loop:
 * let nexty = y + 2 ( (x - expy) / (x + expy) ).
 * let min := min (x, expy).
 * if ( 3 (x + expy) - 5 min ) | x - expy |3 ≤ tolerance 6 (x + expy) min3, then:
 * let lnx := nexty.
 * output lnx.
 * stop.
 * end if.
 * let y := nexty.
 * let expy := exp ( y ) *** this is the expensive step which we are trying to avoid.
 * end loop.
 * end routine.

Note that this uses the theorem
 * $$ \vert \ln (x) - y \vert \le \frac{\vert x - \exp (y) \vert}{\min (x, \exp (y))} $$

to get around the fact that we do not yet know what ln (x) is. JRSpriggs (talk) 03:40, 6 May 2018 (UTC)

The test for exiting the loop is intended to achieve the same effect as:
 * $$ \vert \ln (x) - y_{n+1} \vert \le \operatorname{tolerance} $$

but without having to calculate exp (yn+1) and without knowing ln (x). Can the test be simplified? Yes, if you are not too picky about getting it right. We could define another variable
 * let threshold := cube_root ( 12 ''tolerance )

and compare | x - expy | ≤ threshold min. Or we could use nexty as a substitute for ln (x), which would make the test | nexty - y | ≤ threshold. JRSpriggs (talk) 13:03, 7 May 2018 (UTC)

To get a general idea of how this technique (the iterative method, not the program) converges, I ran a test beginning with a distant initial guess y0. I got the following:
 * ln (x) - y0 = 4.0000000000
 * ln (x) - y1 = 2.0719448398
 * ln (x) - y2 = 5.193595899&middot;10-1
 * ln (x) - y3 = 1.13675706&middot;10-2
 * ln (x) - y4 = 1.224097816&middot;10-7

Notice that at first it moves closer by a little less than 2 which is the limit on how far it can move in one iteration. Then after it comes within 1 of the correct value, the cubic convergence begins to take hold. JRSpriggs (talk) 04:20, 8 May 2018 (UTC)

An alternative iteration to get the natural logarithm
I discussed the current version of Natural logarithm in the previous section of talk, Talk:Natural logarithm. Now, I would like to suggest an alternative. Thanks to the third order Householder's method, we could use
 * $$ y_{n+1} = y_{n} + 3 \frac{x^2 - (\exp (y_{n}))^2}{x^2 + 4 x \exp (y_{n}) + (\exp (y_{n}))^2} .$$

Advantages: It converges faster, moving upto 3 when far away (as opposed to 2 for the Halley's method) per iteration and having quintic (fifth power) convergence (usually the third Householder's method only gives quartic convergence, but this is a especially favorable situation) when close rather than the cubic convergence of the Halley's method. This may allow for fewer iterations of the method and thus fewer evaluations of the power series for the exponential.

Disadvantages: It is a change, and any change may cause confusion. It requires three more multiplications to compute the adjustment. It is slightly more complex than the previous method. Although, I have proved that the convergence is quintic, I do not have the coefficient yet. If it is too large, that might be a problem.

Do you think that we should change the section to use this new method? JRSpriggs (talk) 05:05, 9 May 2018 (UTC)
 * I don't think it's appropriate for this article. In fact, a whole lot of the stuff currently in the "Series" and "Continued fraction" sections should probably be pruned out, as well.  This is not an article on numerical methods for computing logarithms.  --Trovatore (talk) 09:46, 9 May 2018 (UTC)
 * In that case, can we create an article on numerical methods for computing logarithms and transfer that material to it? JRSpriggs (talk) 00:14, 10 May 2018 (UTC)
 * Hmm, is that a topic called out as such in the literature? Certainly numerical methods are an important area of study and can be covered in Wikipedia, but going into detail about the pluses and minuses of specific ways of computing a particular function feels a little "handbook-like" to me.
 * That said, I wouldn't object to it nearly as much in its own article. Just make sure all the methods are sourced (and specifically for computing logs).  Also convergence estimates, caveats, etc, should have sources that specifically say this is what happens when you're computing logarithms. --Trovatore (talk) 00:42, 10 May 2018 (UTC)

For the iteration suggested above,
 * $$ \ln (x) - y_{n+1} = \frac{1}{180} (\ln (x) - y_{n})^5 - \frac{1}{1512} (\ln (x) - y_{n})^7 + O ( (\ln (x) - y_{n})^9 ) $$.

JRSpriggs (talk) 06:08, 10 May 2018 (UTC)

Assuming that errors in calculating exp (yn) and yn+1 from x and yn are negligible,
 * $$ 0 \le \ln (x) - y_{n+1} \le \min \left(\frac{(\ln (x) - y_n)^5}{180}, \, \ln (x) - y_n \right) \quad \text{ or } \quad \max \left(\frac{(\ln (x) - y_n)^5}{180}, \, \ln (x) - y_n \right) \le \ln (x) - y_{n+1} \le 0 .$$

JRSpriggs (talk) 01:27, 17 May 2018 (UTC)

Section on origin of the term
I've just removed the section titled Origin of the term natural logarithm. There was a ton of WP:OR/WP:SYNTH in here. The one source listed (which I had to check an archived copy of) didn't seem to actually verify anything at all in here. At best, it was just some extra history capped off with a statement to the effect of: "and that's why it's called the natural logarithm". If anyone disagrees or thinks any of this could/should be salvaged, please feel free to comment. –Deacon Vorbis (carbon &bull; videos) 13:45, 18 July 2019 (UTC)
 * Good call. —Kusma (t·c) 17:50, 18 July 2019 (UTC)
 * Read above section "Why natural"? Also see History of logarithms and recall previous name Hyperbolic logarithm. Justification for removal is weak. — Rgdboer (talk) 21:46, 19 July 2019 (UTC)
 * I'm not sure why concerns about OR/SYNTH are weak, and reading the above section really only strengthens my concerns there. This looks like a reading of primary source material and making conjectures based on that (however plausible doesn't matter).  If someone can find a good history source that can confirm any of this, then great, but otherwise, I don't really understand the resistance here.  –Deacon Vorbis (carbon &bull; videos) 22:16, 19 July 2019 (UTC)
 * In science the term natural philosophy is associated with perceptible phenomena. In mathematics it is area which forms the perceptible quantification of natural logarithm. Would you please consider the quotation from Tom Whiteside on History of logarithms. Your challenge of this origin of the descriptor natural perpetuates ignorance of the concept and its relation to hyperbolic angle. — Rgdboer (talk) 21:48, 20 July 2019 (UTC)
 * After reading this I am actually less convinced that "naturalness" of the log is related to hyperbolic area. —Kusma (t·c) 15:25, 21 July 2019 (UTC)
 * (Whoops, forgot to reply.) I don't understand; are you claiming that the use of "natural" in "natural logarithm" is related to its use in "natural philosophy" (which itself is really just an old term for "science").  If not, then what are you getting at?  If so, do you have source(s) to back this up?  This all seems to be getting away from the main issue, which is that any claims about the term's etymology should be (secondarily) sourced – not left to editors to speculate about.  –Deacon Vorbis (carbon &bull; videos) 21:24, 21 July 2019 (UTC)
 * The essential nature of area defining this function was acknowledged by Derek Thomas Whiteside (1961) "Patterns of mathematical thought in the later seventeenth century", Archive for History of Exact Sciences 1(3):179–388, § III.1 The logarithm as a type-function pp 214–231, see especially page 231. — Rgdboer (talk) 23:11, 21 July 2019 (UTC)
 * I don't have access to this source, can you quote the relevant portion(s)? –Deacon Vorbis (carbon &bull; videos) 00:09, 22 July 2019 (UTC)
 * , a quote is in our article History of logarithms. It seems to me to be about several concepts from analysis and geometry coming together and becoming the natural logarithm, but I don't see any justification to say that the naturalness is inherited from geometry instead of from analysis. We don't call them "hyperbolic logarithms" any more, so it seems to me we are de-emphasizing the relation to geometry these days. —Kusma (t·c) 10:31, 22 July 2019 (UTC)
 * Mmm, okay, and yeah, I managed to ... "find" ... a full copy, and there's really no discussion on why the term is appropriate, or who first used it, etc. So barring any other sources, I'm not sure there's anything to do here.  –Deacon Vorbis (carbon &bull; videos) 13:33, 22 July 2019 (UTC)
 * The section has been restored with citation from V. Frederick Rickey who explicates Euler's development of the subject. — Rgdboer (talk) 22:11, 26 July 2019 (UTC)
 * The source you cited merely says that Euler called it by "natural or hyperbolic", not any of rest of that, or why he chose the term "natural" (was that term already in use? did Euler coin it?). I'm sure that a brief mention of Euler in the history section would be fine, but not any of the big pile of OR that was the main concern.  –Deacon Vorbis (carbon &bull; videos) 22:44, 26 July 2019 (UTC)
 * "Big pile of OR" should be described as 270 years have passed since Euler: anything original on this topic is unlikely. — Rgdboer (talk) 22:53, 26 July 2019 (UTC)
 * Are you talking to me? I'm guessing so, but you didn't indent your reply (I've done so for you), or give an actor for should be described, so it's hard to be sure.  Anyway, I'm not sure what else I can do here.  Nowhere in the section was there really an explanation of the origin of the term natural logarithm, and what was there wasn't sourced, so I don't understand what you're looking for here.  –Deacon Vorbis (carbon &bull; videos) 00:58, 27 July 2019 (UTC)
 * "Big pile of OR" should be described as 270 years have passed since Euler: anything original on this topic is unlikely. — Rgdboer (talk) 22:53, 26 July 2019 (UTC)
 * Are you talking to me? I'm guessing so, but you didn't indent your reply (I've done so for you), or give an actor for should be described, so it's hard to be sure.  Anyway, I'm not sure what else I can do here.  Nowhere in the section was there really an explanation of the origin of the term natural logarithm, and what was there wasn't sourced, so I don't understand what you're looking for here.  –Deacon Vorbis (carbon &bull; videos) 00:58, 27 July 2019 (UTC)

e^-lnx
Should we not include the line:

e -lnx = 1/x

? — Preceding unsigned comment added by 2603:6011:3140:7400:B4A0:B8CE:398B:B46E (talk) 03:52, 12 March 2021 (UTC)