74

I was playing with logarithms under an arbitrary-precision calculator, and got some odd results. I happened to have the precision set to 20 places, and these are the initial results I got:

ln 0.6666666 = -0.40546520810816938198
ln 2/3       = -0.40546510810816438198

"That's strange", I thought. "I would have expected the logarithms to be more different than that."

But then I looked more closely: they are different, in two places, with the first difference coming at the seventh digit, about as you would expect. But I would have expected all the digits after that to be different — it was quite a surprise that most of them were the same!

To be clear, my assumption is that if two numbers a and b are slightly different, and with a function f such that f(a) and f(b) are also slightly different, then unless there's something special going on, the decimal expansions of f(a) and f(b) will be identical up to a point, then diverge. Unless there's something special going on, I don't expect to see any patterns past the point of divergence — indeed for a transcendental function like ln, I don't expect to see any patterns in a decimal expansion at all. So how can it be that, in this case, there are quite a few digits in common after the point of divergence?

At first I assumed this was just a bizarre coincidence, but then I tried several other numbers, with similar results:

To 13 places:

ln 0.3333333 = -1.0986123886681
ln 1/3       = -1.0986122886681

To 20 places again:

ln 0.1111111 = -2.19722467733622438279
ln 1/9       = -2.19722457733621938279

ln 0.2222222 = -1.50407749677627907337 ln 2/9 = -1.50407739677627407337

(Similar results hold for 4/9, 5/9, 7/9, and 8/9.)

It seems there's got to be "something special" going on here, but I have no idea what! (Although, I realize that patterns in decimal expansions are not necessarily meaningful. I was going to additionally tag this question "numerology", but I guess that's not a tag. :-) )


Addendum: The answers reveal that in this case, my assumption that "for a transcendental function like ln, I don't expect to see any patterns in a decimal expansion at all" was quite wrong. The core of the answer to this question is that ln(1 - 10-7) is −0.000000100000005000000…, and I think this is going to be #3 on my list of fun numerological facts, behind 1001 = 7 · 11 · 13 and, of course, that one about e.

Also, the answers help to answer two side questions I had but didn't ask at first:

  1. Does the effect depend on having truncated 2/3 specifically to 7 digits? No, and it's even more pronounced the more digits you leave in place. For example, if you truncate 2/3 to 15 places, you get an answer that looks like it's correct out to 45 places, typically differing only in the 15th and the 31st.
  2. Is there anything special about having 3 or 9 in the denominator? No, the effect usually works for any repeating decimal, as long as (I think) the period is shorter than the truncation point. (Also if the period is greater than 1, you may have to truncate at the right spot, involving multiples of the period.)
Bill Dubuque
  • 282,220
  • 2
    Nice to see you here Steve. Your book is still an example of good writing, and about C for that matter! – A rural reader May 04 '25 at 14:24
  • 2
    @Aruralreader That was a very long time ago! (And I did not expect to be recognized for it here, on math.se!). But thanks. :-) – Steve Summit May 04 '25 at 14:37
  • 1
    I'm curious - can you find any specs on how $ln$ is calculated in the calculator you are using? My guess is that this is not so much a mathematical "something special" as it is a calculator "something special" but I could be wrong. – roundsquare May 04 '25 at 14:58
  • 1
    @roundsquare As it happens, I noticed the effect while playing with a calculator I wrote myself, but I double-checked these results against bc, and got exactly the same digits. I believe all the digits I've shown are correct and exact, out to the precisions indicated — if not, that would completely invalidate the question. (And if the digits are correct, they should obviously be independent of the algorithm used to compute them.) – Steve Summit May 04 '25 at 15:01
  • Does Wolfram Alpha exhibit the same behavior? If so it's not a calculator artifact. What about $a/99$? What about logs to other bases? – Ethan Bolker May 04 '25 at 15:02
  • 4
    These two differ by $log(1-0.0000001)$. By Taylor series, $log(1-x) \approx -x -\frac{x^2}{2}$. Your precisions might lead some clue – Srini May 04 '25 at 15:04
  • @SteveSummit right-o! I think the people who pointed out the Taylor series thing are on to something. – roundsquare May 04 '25 at 15:12
  • It's a cool observation. I'd really recommend sitting down and thinking why it would occur. – fleablood May 04 '25 at 17:01
  • @EthanBolker Per the answers I've now received, it will not work for logs wrt other bases. ln(1-10⁻⁷) is -0.000000100000005000000 (and similarly for 10⁻⁶, 10⁻⁸, etc.), but this doesn't hold for log₂, log₁₀, log₇, etc. But ln(45/99) vs. ln(0.454545) does show the effect, as predicted. – Steve Summit May 04 '25 at 17:42
  • Well, that makes sense. sort of. Then natural log is the "natural" log in that it is of the base where the derivative of $e^x$ is $e^x$ whereas the derivative of $b^x = \ln b \times b^x$ and the $\ln b$ factor can "cloud" things up. Like wise the derivative if $\ln x= \frac 1x$ whereas the derivative of $\log_b x = \frac 1{\log_b e\times x}$ and then $\frac 1{\log_b e}$ will cloud. Even if you don't know what's going on it makes sense that other bases would "cloud". – fleablood May 04 '25 at 17:42
  • @SteveSummit I suspect the argument in the (nice!) accepted answer will work with the natural log and the base $b$ "decimal" expansion for fractions $a/(b-1)$, – Ethan Bolker May 04 '25 at 17:42
  • The first decimal difference can be explained with Newtons approximation. $ \ln 0.6666666-\ln \frac 23\approx 10^{-7}\implies \ln \frac {\frac 0.6666666}{\frac 23}=\ln 0.9999999 \approx 10^{-7}$ can be explained via $\ln (1-h)\approx \ln 1 - h\cdot(\frac {d\ln (x)}{dx}){|{x=1}}= -h$. – fleablood May 04 '25 at 17:49
  • Very few coincidences in math are actually a coincidence. At least for large numbers. – qwr May 06 '25 at 01:38
  • 6
    There is a very similar observation in Borwein, Borwein, and Dilcher, Pi, Euler Numbers, and Asymptotic Expansions. The American Mathematical Monthly: Vol. 96, No. 8, pp. 681-687. Gregory's series for pi, truncated at $500000$ terms, gives five correct decimal places for pi. The sixth decimal place is wrong – but then the next ten digits are correct! Then there are two wrong digits, and then another ten correct digits. One more wrong digit, then another ten correct digits. The paper is freely available at https://nova.newcastle.edu.au/vital/access/services/Download/uon:14226/ATTACHMENT01 – Gerry Myerson May 06 '25 at 06:24
  • Fun fact: as mentioned on page 1 of the Borwein, Borwein, Dilcher paper, this was noticed by an amateur/recreational mathematician, who communicated it to the Borweins, who then proceeded to explain it. – David May 07 '25 at 00:33
  • Another similar example occurs when comparing $\frac{\pi^2}{6}$ to $\sum_{k=1}^n \frac1{k^2}$ when $n$ is a power of $10$. – Misha Lavrov May 07 '25 at 02:37
  • I emailed your post as a PDF to my friend, and he replied with his response in a PDF as well: https://green-aurelea-79.tiiny.site. I think you should check it out – Martin.s May 10 '25 at 09:00
  • @Martin.s Thanks, and I'm surely intrigued, but I'm sorry, there's no way I can chase an unknown link like that! – Steve Summit May 10 '25 at 11:08
  • @SteveSummit oh it’s okay – Martin.s May 10 '25 at 11:31

2 Answers2

90

For the first example,

$$ 0.6666666 = \frac23 - \frac23 \times 0.0000001 = \frac23 \left(1 - 10^{-7}\right). $$

Therefore $$ \ln(0.6666666) = \ln\left(\frac23\right) + \ln\left(1 - 10^{-7}\right). $$

The Taylor series for the natural logarithm $\ln x$ about $x = 1$ is

$$ \ln(1 + x) = x - \frac{x^2}{2} + \frac{x^3}{3} - \frac{x^4}{4} + \frac{x^5}{5} -+ \cdots . $$

Therefore \begin{align} \ln\left(1 - 10^{-7}\right) &= -10^{-7} - \frac12\times 10^{-14} - \frac13\times 10^{-21} - \frac14\times 10^{-28} - \cdots \\ &\approx -0.0000001000000050000003333333583333. \end{align}

So you really should expect the difference between the two logarithms to be a difference of $1$ in the seventh digit past the decimal point and a difference of $5$ in the $15$th digit past the decimal point. The next non-zero digits in the difference start at the $22$nd digit past the decimal point.

Depending on what digits are in the smaller logarithm, when you add these differences they may or may not carry into some adjacent digits. If the carries from the $22$nd and later digits don't go very far (and they won't go far unless you have some consecutive $9$s) this means the first $20$ digits are affected only by the $1$ in the seventh digit and the $5$ in the $15$th digit, which is exactly what you see: the seventh digit goes from $1$ to $2$ and the $15$th goes from $4$ to $9.$

The other numbers likewise are in the ratio $1 : \left(1 - 10^{-7}\right),$ so you're adding $1$ to the seventh digit and $5$ to the $15$th digit each time.

David K
  • 108,155
  • 6
    Splendid! Thank you. So there actually is a secret, backchannel path from the decimal digits of x to the decimal digits of ln x. (Those widely-separated 10⁻⁷ⁿ terms are nicely independent — I'm reminded of the way that 1000000001ⁿ gives you the rows of Pascal's triangle.) And the property will hold not just for multiples of 1/9 as I was exploring, but for many repeating decimals (as I've just confirmed by truncating the decimal expansion of 1/7 at various points). – Steve Summit May 04 '25 at 16:58
  • 1
    @SteveSummit With regards to $(1000000001)^n$ giving you the rows of Pascal’s triangle, that is actually a special case of the following. For any $x$, $(1+x)^n = {n \choose 0} + {n \choose 1} x + {n \choose 2} x^2 + \dots + {n \choose n} x^n$, where ${n \choose k}$ is the $k$th entry of the $n$th row of Pascal’s triangle (indexing for $k$ and $n$ both start at $0$). Yours is the case $x= 1000000000$, which happens to produce the rows in a readable way in the decimal digits of some numbers. – Robin May 05 '25 at 20:02
  • …for more information, see https://en.wikipedia.org/wiki/Binomial_theorem. – Robin May 05 '25 at 20:03
28

Consider the first example, comparing $\log \frac23$ and $\log 0.6666666$. The latter is $\log \left(\frac23 (1 - 10^{-7})\right) = \log \frac23 + \log (1 - 10^{-7})$, so the difference of the logarithms is $-\log (1 - 10^{-7}).$ Expanding $\log (1 - x)$ in a Maclaurin series gives $$\log (1 - x) \sim -x - \frac12 x^2 - \frac13 x^3 + \cdots ,$$ so that difference is a mere $$10^{-7} + \frac12 \cdot 10^{-14} + \cdots = 10^{-7} + 5 \cdot 10^{-15} + \cdots,$$ where $\cdots$ denotes a remainder of $< 10^{-21}$. There turns out to be no carrying, so the first $20$ digits of $\log \frac23$ and $\log 0.6666666$ differ exactly by $1$ in the $7$th place and $5$ in the $15$th place, which is just what you observed.

Travis Willse
  • 108,056