Another Mathematica bug

Comments
Bookmark and Share

Math is hard.

Not for Barbie, but for Mathematica.

I ran into a weird Mathematica bug while trying to evaluate the sum

$$\sum_{k=1}^{\infty} \biggl[-\frac{\pi^2}{6} + \psi'(k + 1) + H_k^2\biggr]\frac{z^k}{k!}$$

Split this into three parts. The first one is the well-known expansion of the exponential function

$$-\frac{\pi^2}{6}\sum_{k=1}^{\infty} \frac{z^k}{k!} = -\frac{\pi^2}{6}(e^z - 1)$$

The second is not the well-known expansion of the exponential function.

$$\sum_{k=1}^{\infty} \psi'(k + 1)\frac{z^k}{k!} \neq \frac{\pi^2}{6}(e^z - 1)$$

Obviously not, in fact, since if two power series are equal, \(\sum_i a_n z^n = \sum_i b_n z^n\), for an infinite number of points, each of their coefficients have to be equal: \(\forall n,\ a_n = b_n\). (You can show this by taking the difference of the two sides and plugging in a bunch of different values of \(z\).)

I guess Mathematica doesn’t know that.

In[1] = Sum[PolyGamma[1, k + 1] z^k/k!, {k, 1, Infinity}]
Out[1] = 1/6(-1 + E^z)Pi^2

I had my hopes up for about two days that these two terms would cancel out, but I should have gone with my instinct that something was fishy about that result.

Apparently we have to go all the way back to version 7 to get a correct answer.

I’m still working on the rest of it.

Can you trust your calculator?

This is actually emblematic of a big problem that is on many people’s minds right now because of a recent article in the Notices of the American Mathematical Society, (PDF) “The Misfortunes of a Trio of Mathematicians Using Computer Algebra Systems. Can We Trust in Them?” In this paper, the authors construct some fairly simple mathematical expressions for which Mathematica gives egregiously wrong results. (The expressions may not look simple to us, but they’re polynomials with integer coefficients, pretty much the easiest mathematical objects for computers to handle.)

Forget math, it’s programming that’s hard!

What all this shows is that relying on the results of a computer program is dangerous without some kind of independent verification that it does what you think it does. Anyone who’s ever written a program should understand that. But it’s all too easy to forget; we get lulled into a false sense of security by the 90% of the time that programs do work, plus the 9% of the time that they seem to work because whatever errors they produce are buried in a giant pile of output.

I think sometimes we could all do with a reminder like this not to get too trusting.