# Another Mathematica bug

July 12, 2009

Mathematica is great for cross-checking numerical values, but it’s not unusual to run into bugs, so triple checking is a good habit.

Here is mpmath’s evaluation for two Struve function values:

>>> struvel(1+j, 100j)(0.1745249349140313153158106 + 0.08029354364282519308755724j)>>> struvel(1+j, 700j)(-0.1721150049480079451246076 + 0.1240770953126831093464055j)

The same values in Mathematica:

In[52]:= N[StruveL[1+I, 100I], 25]Out[52]= 0.1745249349140313153158107 + 0.0802935436428251930875572 IIn[53]:= N[StruveL[1+I, 700I], 25]Out[53]= -0.2056171312291138282112197 + 0.0509264284065420772723951 I

I’m almost certain that the second value returned by Mathematica is wrong. The value from mpmath agrees with a high-precision direct summation of the series defining the Struve L function, and even Mathematica gives the expected value if one rewrites the L function in terms of the H function:

In[59]:= n=1+I; z=700IOut[59]= 700 IIn[60]:= N[-I Exp[-n Pi I/2] StruveH[n, I z], 25]Out[60]= -0.1721150049480079451246076 + 0.1240770953126831093464055 I

Maple also agrees with mpmath:

> evalf(StruveL(1+I, 700*I), 25);        -0.1721150049480079451246076 + 0.1240770953126831093464055 I

So unless Mathematica uses some nonstandard definition of Struve functions, unannounced, this very much looks like a bug in their implementation.

Wolfram Alpha reproduces the faulty value, so this still appears to be broken in Mathematica 7.