# October 2023

You are currently browsing the monthly archive for October 2023.

## Why is 1/log(1+1/k) ≈ k + 1/2 ?

This is just a minor extension of my last post.
Why is $$1/\log(1+1/k) \approx k + 1/2\ ?$$
At first, I was surprised that $$1/\log(1+1/237) \approx 237,$$ but then I realize that $$\log(1+x) \approx x$$ if $|x|$ is small, so
$$1/\log(1+x) \approx 1/x,\mathrm{\ thus}$$
$$1/\log(1+1/k) \approx k.$$
Where does the 1/2 come from? Well, you’ve got to get a better approximation of $\log(1 +x)$ to find the 1/2. You can do this with calculus.  If $|x| <$1 and $|y| < 1$, then $$(1-x)\cdot( 1+ x + x^2 + x^3 + \ldots) = 1$$
$$1/(1-x) = 1+ x + x^2 + x^3 + \ldots$$
$$\int_0^y 1/(1-x) \;dy = y + y^2/2 + y^3/3 + \ldots$$
$$-\log(1-y) = y + y^2/2 + y^3/3 + \ldots,\mathrm{\, so}$$
$$\log(1+x) = x – x^2/2 + O(x^3)$$ using big O notation.  (Aside: $-\log( 1 – .001) = 0.0010005003335835335…$)
Now,
\begin{aligned} 1/\log(1+x) &= 1/(x – x^2/2 + O(x^3)) \\ &= 1/x \cdot 1/(1 – x/2 + O(x^2)) \\ &= 1/x \cdot [ 1 + ( x/2 + O(x^2)) + O( ( x/2 + O(x^2))^2) ] \\ &= 1/x \cdot ( 1 + x/2 + O(x^2) + O( x^2) ) \\ &= 1/x \cdot ( 1 + x/2 + O( x^2) ) \\ &= 1/x + 1/2 + O(x). \end{aligned}Replacing $x$ with $1/k$ gives$$1/\log(1+1/k) = k + 1/2 + O(1/k).$$

It is more work to prove sharper bounds.

## 1/log(1+1/237) = 237.49964912… ??

I was rather surprised one day when I typed $$1/\log(1+1/237)$$ into a calculator and got 237.4996491…. I just thought it was strange that it was so very close to 237.5 but very slightly less.

I had been trying to find the maximum number of tanks that you can produce in the tank-factory game. You start the game with any number of factories. On each turn, you can either invest in more factories thereby increasing the number of factories by 10% or you can use the turn to produce one tank per turn per factory. The game lasts for $T$ turns with $T>10$. If you build factories for $k$ turns and build tanks for $T-k$ turns, then the total number of tanks produced is $$f(k) = f_0 \; 1.1^k (T-k)$$ where $f_0$ is the starting number of factories.

Perhaps surprisingly, the maximum value of $f(k)$ is attained both at $k=T-10$ and $k=T-11$. Mathematically[1],
$$\max\{ f(k) | k = 1,2, …, T\} = f(T-10) = f(T-11) \approx 3.9\cdot 1.1^T f_0.$$

But, $f(x)$ can also be thought of as a real valued function, so the maximum value of $f(x)$ over positive real numbers $x$ should be about half way between $x=T-10$ and $x=T-11$.
$$\max_{x>0} f(x) \approx f(T-10.5).$$
To find the precise maximum of $f$ over positive real numbers, we find the point on the curve $y=f(x)$ where the tangent line is horizontal (i.e. where the derivative is zero) as follows: (TFAE)
\begin{aligned} f'(x) &= 0 \\f_0 1.1^x \log(1.1) (T-x) – f_0 1.1^x &= 0 \\ \log(1.1) (T-x) -1 &= 0 \\ \log(1.1) (T-x) &= 1 \\ T-x &= 1/\log(1.1) \\ T- 1/\log(1.1) &=x.\end{aligned}
The max of $f(x)$ occurs at $x = T- 1/\log(1.1)$, but before we estimated that the max would occur at $x\approx T – 10.5$, so we can conlude that
$$1/ \log(1+1/10) = 1/\log(1.1) \approx 10.5.$$
Indeed,
$$1/\log(1.1) = 10.492058687….$$

You can use simillar reasoning to conclude that
$$1/\log( 1 + 1/k) \approx k + 1/2$$
for all positive integers $k$.

A more precise bound can be found with Taylor series. If you go through the math you can prove that for all positive real numbers $x$,
$$f(x) = 1/\log(1+1/x) = x + 1/2 – 1/(12 x) + e(x)$$
where $0< e(x) < 1/(24 x^2).$

Footnote:
[1] More generally, if $k$ and $T$ are postive integers, $k<T$, and $$g(k, n, T) = (1+1/k)^n (T-n),$$ then
\begin{aligned} \max\,\{ g(k,n, T)\; |\; n &= 0, 1,2, \ldots, T \} \\ &= g(k, T-k, T) \\&= g(k, T-k-1, T).\end{aligned}