Why does Wolframalpha think that this sum converges?

Looking at the sum:

$$\sum_{n=1}^\infty\tan\left(\frac\pi{2^n}\right)$$

I'd say that it does not converge, because for $n=1$ the tangent $\tan\left(\frac\pi 2\right)$ should be undefined. But Wolframlpha thinks that the sum converges somewhere around $1.63312×10^{16}$.

What am I missing?


For floating point numbers stored in IEEE double precision format, the significant has $53$ bit of accuracy. The most significant bit is implied and is always one. Only $52$ bits are actually stored.

Since $1 \le \frac{\pi}{2} < 2$, among those numbers representable by IEEE, the closest number to $\frac{\pi}{2}$ is $$\left(\frac{\pi}{2}\right)_{fp} \stackrel{def}{=} 2^{-52}\left\lfloor \frac{\pi}{2} \times 2^{52}\right\rfloor$$

Numerically, we have $$\frac{\pi}{2} - \left(\frac{\pi}{2}\right)_{fp} \approx 6.1232339957\times 10^{-17}$$

Since for $\theta \approx \frac{\pi}{2}$, $\displaystyle\;\tan\theta \approx \frac{1}{\frac{\pi}{2} - \theta}$, we have

$$\tan\left(\frac{\pi}{2}\right)_{fp} \approx \frac{1}{6.1232339957\times 10^{-17}} \approx 1.6331239353 \times 10^{16}$$

This is approximately the number you observed.


Possible explication: Wolfram Alpha applies some convergence test and says "is convergent". But as does not know any closed form, does a numerical approximation.

EDIT: interesting phenomenon: https://www.wolframalpha.com/input/?i=sum_(n%3D1)%5E7000+tan(pi%2F2%5En). Try and wait a bit.


Computing

tan(pi/2)

with Python or Matlab yields $1.633123935319537\mathrm{e}{+}16$. Hence, this is just a result of rounding errors (the remaining terms in the sum are quite small).