Why does $\text{arctanh}(2^{-k})$ approach powers of $2$?

258 Views Asked by At

This is from a piece of verilog code I generated for $\text{arctanh}(2^{-k})$:

localparam bit [31:0][47:0] arctanhTable = {
        48'b100011001001111101010011110101010110100000011000,
        48'b010000010110001010111011111010100000010001010001,
        48'b001000000010101100010010001110010011110101011101,
        48'b000100000000010101011000100010101101001101110101,
        48'b000010000000000010101010110001000100100011010111,
        48'b000001000000000000010101010101100010001000101011,
        48'b000000100000000000000010101010101011000100010001,
        48'b000000010000000000000000010101010101010110001000,
        48'b000000001000000000000000000010101010101010101100,
        48'b000000000100000000000000000000010101010101010101,
        48'b000000000010000000000000000000000010101010101010,
        48'b000000000001000000000000000000000000010101010101,
        48'b000000000000100000000000000000000000000010101010,
        48'b000000000000010000000000000000000000000000010101,
        48'b000000000000001000000000000000000000000000000010,
        48'b000000000000000100000000000000000000000000000000,
        48'b000000000000000010000000000000000000000000000000,
        48'b000000000000000001000000000000000000000000000000,
        48'b000000000000000000100000000000000000000000000000,
        48'b000000000000000000010000000000000000000000000000,
        48'b000000000000000000001000000000000000000000000000,
        48'b000000000000000000000100000000000000000000000000,
        48'b000000000000000000000010000000000000000000000000,
        48'b000000000000000000000001000000000000000000000000,
        48'b000000000000000000000000100000000000000000000000,
        48'b000000000000000000000000010000000000000000000000,
        48'b000000000000000000000000001000000000000000000000,
        48'b000000000000000000000000000100000000000000000000,
        48'b000000000000000000000000000010000000000000000000,
        48'b000000000000000000000000000001000000000000000000,
        48'b000000000000000000000000000000100000000000000000
    };

The $\text{arctanh}(2^{-k})$ values start converging to successive powers of $2$. It's apparent that the number of zeroes between the first $1$ and the second $1$ keeps increasing, so the form $\text{arctanh}(2^{-k}) = 2^{-1} + q(k)$ for values of $q(k)$ decreasing much more quickly than values of $2^{-k}$. Wolfram Alpha tells me $q(k) = -2^{-k} - \dfrac{\ln(1-2^{-k}) + \ln(1+2^{-k})}{2}$

Why does this divergence happen? I don't think I can leverage this to cheaply calculate $\text{arctanh}$, although it does give me an interesting way to compress the table by storing a floating-point $q(k)$, not that that's actually useful either.

2

There are 2 best solutions below

9
On BEST ANSWER

We know that

$$ \DeclareMathOperator{\arctanh}{artanh} \arctanh(x) = \frac12\left(\log(1 + x) - \log(1 - x)\right). \tag1$$

The Taylor series for $\log(1+x)$ centered at $x=0$ is $$ \log(1 + x) = x - \frac12 x^2 + r_1(x) $$ where $r_1(x)$ is $\mathcal O(x^3)$ as $x \to 0$. Similarly, the Taylor series for $\log(1 - x)$ centered at $x=0$ is $$ \log(1 - x) = -x - \frac12 x^2 - r_2(x) $$ where $r_2(x)$ is $\mathcal O(x^3)$ as $x \to 0$.

Substituting these two Taylor series into Equation $(1)$ gives

\begin{align} \arctanh(x) &= \frac12\left(\left(x - \frac12 x^2 + r_1(x)\right) - \left(-x - \frac12 x^2 + r_2(x)\right)\right) \\ &= x + r_1(x) + r_2(x) \\ &\subseteq x + \mathcal O(x^3), \quad x \to 0. \\ \end{align}

Let $x = 2^{-k}$ for a positive integer $k$ and you have $$ \arctanh(2^{-k}) \subseteq 2^{-k} + \mathcal O(2^{-3k}), \quad k \to \infty. $$

In other words, $q(k)$ is a function of order $2^{-3k}.$ So its first non-zero digit is about three times as many places to the right as the $1$ digit of $2^{-k}$, leaving about $2k$ zeros between the digits.

For example, consider the following two rows of your table.

        48'b000000000100000000000000000000010101010101010101,
        48'b000000000010000000000000000000000010101010101010,

The first of these two rows has nine zeros followed by a $1$, which is the $2^{-k}$ digit of $\arctanh(2^{-k})$, then we have $21$ zeros followed by some non-zero digits; if this is the row for $k = 10$ then indeed we have about $2k$ zeros ($2k+1$ to be exact) between the non-zero digits. In the next row the $2^{-k}$ digit has moved one place to the right, but the rest of the digits have moved three places, adding two zeros to the gap between non-zero digits. And we will just keep on adding two more zeros on every row, which is a simple consequence of the fact that $q(k)$ is of order $2^{-3k},$ or in other words, when $k$ is large, $q(k)$ is approximately $\lambda 2^{-3k}$ for some constant $\lambda$.

1
On

The reason that $\lim_{i\to\infty}\frac{\operatorname{arctanh}(2^{-i})}{2^{-i}}=1$ is that $\lim_{h\to 0}\frac{\operatorname{arctanh}(h)}{h}=1$. This is in turn true because $\operatorname{arctanh}(0)=0$ so this is really the expression $\lim_{h\to 0}\frac{\operatorname{arctanh}(h)-\operatorname{arctanh}(0)}{h-0}=\frac{d(\operatorname{arctanh})}{dx}(0)=1$.

You will get the same behaviour with any other function which, like $\operatorname{arctanh}$, at $x=0$ has the value equal to $0$, and the value of the first derivative equal to $1$.

The reason we see a big "gap" of zeros after the first "one" (i.e. the values are very close to $2^{-i}$) is that the second derivative has the value $0$, i.e. $\frac{d^2(\operatorname{arctanh})}{dx^2}(0)=0$ This then in turn means that the function is well approximated by its Taylor polynomial of $2$nd degree, which ends up being $\frac{1}{1!}\cdot x+\frac{0}{2!}\cdot x^2=x$, i.e. $\operatorname{arctanh}(x)=x+O(x^3)$ and so the order of magnitude of the error term is therefore close to $2^{-3i}$. Cf. Wolfram Alpha McLaurin expansion for $\operatorname{arctanh}$.