I found this math puzzle blog post http://fredrikj.net/blog/2013/03/machin-like-formulas-for-logarithms/ which I'm reposting here with permission. I'm setting this to community wiki to minimize the perception that I'm leeching for internet points, but if this question is somehow inappropriate then I would take the blame and not the original author.

Machin-like formulas express $\pi$ as an integer combination of arctangents evaluated at reciprocals of integers. The most famous is

$$\pi = 16 \arctan \frac{1}{5} – 4 \arctan \frac{1}{239}$$

which historically has been used for many record computations of $\pi$, including Machin’s own accomplishment of breaking the 100-digit barrier in 1706. (Nowadays the more efficient Chudnovsky algorithm is usually used, but Machin-like formulas still hold up quite well.)

For a Machin-like formula

$$\pi = \sum_{i=1}^N A_i \arctan \frac{1}{B_i}$$

one can define its

efficiencyas$$e = \sum_{i=1}^N \frac{1}{\log B_i}.$$

A smaller $e$ roughly corresponds to a shorter computation time. Larger $B_i$ give faster convergence of each arctangent series, but formulas with larger $B_i$ usually involve more terms, so there is a tradeoff.

By considering

hyperbolicarctangents, one can obtain rapidly converging representations for logarithms of integers. For example, here is a simple Machin-like formula for $\log 2$ (it’s easy to find others):$$\log 2 = 2 \operatorname{arctanh} \frac{1}{5} + 2 \operatorname{arctanh} \frac{1}{7}.$$

Having efficient formulas of this kind for the logarithms of small integers is very useful in some applications.

I recently noticed by accident (while looking at the output from a quick brute force search for Machin-like formulas with PSLQ in mpmath) that there is a set of particularly efficient Machin-like formulas that allow computing $\log 2$, $\log 3$ and $\log 5$

simultaneouslyfrom just three hyperbolic arctangents:$$\log 2 = 14 \operatorname{arctanh}\frac{1}{31} + 10 \operatorname{arctanh}\frac{1}{49} + 6 \operatorname{arctanh}\frac{1}{161}$$

$$\log 3 = 22 \operatorname{arctanh}\frac{1}{31} + 16 \operatorname{arctanh}\frac{1}{49} + 10 \operatorname{arctanh}\frac{1}{161}$$

$$\log 5 = 32 \operatorname{arctanh}\frac{1}{31} + 24 \operatorname{arctanh}\frac{1}{49} + 14 \operatorname{arctanh}\frac{1}{161}$$

This trivially also allows one to compute the logarithm of any integer of the form $2^i 3^j 5^k$.

Here is a challenge: for a positive integer $n$, what is the most efficient set of hyperbolic arctangents that gives you the logarithms of all integers up to $n$ (or equivalently just the primes up to $n$) simultaneously? Can you find a more efficient set for $n = 5$?

Note that if $n$ gets large and we already have a basis for the integers up to $n-1$, we can just add

$$\log(n) = \log(n-1) + 2 \operatorname{arctanh} \frac{1}{2n-1},$$

so it might be enough to consider smallish $n$.

Note that for $x \gt 1, \text{ arctanh}\frac{1}{x} = \frac{1}{2} (\log (x+1) - \log (x-1)).$ So, it makes sense to consider denominators $x$ so that $x-1$ and $x+1$ are smooth, which explains the denominators of $31$, $49$, and $161$ above. Also, the following system is not as good

$$\begin{eqnarray}\log 2 &=& 2 \text{ arctanh} \frac{1}{5} + 2 \text{ arctanh} \frac{1}{7} \newline \log 3 & = & 4 \text{ arctanh} \frac{1}{5} + 2 \text{ arctanh} \frac{1}{7} \newline \log 5 &=& 4 \text{ arctanh} \frac{1}{5} + 4 \text{ arctanh} \frac{1}{7} + 2 \text{ arctanh} \frac{1}{9} \end{eqnarray}$$

since we want larger denominators instead of smaller so that we can compute $\operatorname{arctanh} \frac{1}{b}$ more rapidly. A measure of the cost of computing $\sum a_i \operatorname{arctanh} \frac{1}{b_i}$ is $\sum \frac{1}{\log b_i}$.