149
$\begingroup$

In the course of doing mathematics, I make extensive use of computer-based calculations. There's one CAS that I use mostly, even though I occasionally come across out-and-out wrong answers.

After googling around a bit, I am unable to find a list of such bugs. Having such a list would help us remain skeptical and help our students become skeptical. So here's the question:

What are some mathematical bugs in computer algebra systems?

Please include a specific version of the software that has the bug. Please note that I'm not asking for bad design decisions, and I'm not asking for a discussion of the relative merits of different CAS's.

$\endgroup$
7
  • 8
    $\begingroup$ Judging by the answers below, maybe a better question would be not "What are some bugs?" but "Which websites have the most useful/comprehensive lists of bugs?". $\endgroup$ Jan 12, 2010 at 15:36
  • 28
    $\begingroup$ This is possibly some sort of record: Richard Parker told me that he once typed "isprime(2)" as his first ever query to a certain computer algebra system, and got the reply "2 is not prime". He also claimed, probably correctly, that he could find a bug in any computer algebra system within 5 minutes. $\endgroup$ Aug 9, 2010 at 14:27
  • 4
    $\begingroup$ Richard's story is really surprising, because all systems I know will look up small primes in a table, so someone left off 2 from that table. It's possible, I guess, but really a silly goof. $\endgroup$ Apr 27, 2011 at 16:51
  • $\begingroup$ Kevin thanks. pari has unconditional thue solver too (the second thue() in the example) and it agrees with your solutions. pari's GRH conditional solver is faster than the unconditional (in some cases the unconditional might be undoable). Do you happen to know other GRH conditional thue solver implementation? $\endgroup$
    – joro
    Jul 13, 2012 at 5:19
  • $\begingroup$ RE: GRH thue solver. Pari developers are investigating the problem. The thread is here: pari.math.u-bordeaux.fr/archives/pari-dev-1207/msg00008.html. Developer wrote "I do not understand where the problem (missing solution) comes from yet. It looks like a mathematical bug so far...". The pari thue code is relatively small. $\endgroup$
    – joro
    Jul 16, 2012 at 5:46

38 Answers 38

1
2
4
$\begingroup$

Over the summer I came across an elementary bug in Magma when working with congruence subgroups of SL_2(Z). The isEquivalent function, which is supposed to tell whether two points are identified by a congruence subgroup, would miss a lot of identifications. For example:

G := CongruenceSubgroup(2); % \Gamma(2)

H := UpperHalfPlaneWithCusps();

(G! [-11,4,8,-3]) in G; % Cast this matrix into \Gamma(2)

true % It's really in \Gamma(2)!

(G! [-11,4,8,-3]) * (H! 3/8); % Have the matrix act on the point 3/8

oo % Magma correctly computes that it gets sent to infinity

IsEquivalent(G, H! 3/8, H! Infinity()); % Are 3/8 and infinity equivalent under the action of \Gamma(2), and specifically, can you given me a matrix representing an element of \Gamma(2) sending the former to the latter?

false [1 0] [0 1] % Doh!

It's a pretty simple computation, and it was pretty clear what loop it was leaving out. We may have been running an old version of Magma, but anyway we reported the error to them, and they fixed it quickly, but I've never trusted computer algebra systems since!

$\endgroup$
2
  • $\begingroup$ Which version of Magma? $\endgroup$ Mar 3, 2010 at 13:12
  • 9
    $\begingroup$ My favorite Magma bug was when NthPrime(4) was 6. Supposedly, with NthPrime they implemented a system involving checkpoints and $x/log(x)$ estimations for $x\ge 10$, and then hard-coded the first few primes as: 2, 3, 5, 6. Oops... $\endgroup$
    – Junkie
    May 25, 2010 at 6:20
4
$\begingroup$

As was noted for Sage, for any open source CAS you can just look up the issue tracker. For example, here's the list if all the issues in SymPy tracker with the WrongResult label: http://code.google.com/p/sympy/issues/list?q=label:WrongResult. Most of them are pretty rare. You're much more likely to hit a bug that just gives an error when it shouldn't, or that gives an unexpected, but not technically wrong (mathematically), result.

My advice is to double check your answer in some other way. The chances of the same bug manifesting itself in two different ways are almost zero. For example, you can check a result numerically, which will use a completely different algorithm from the symbolic version. Many CASs even have built in functions that do this for you.

$\endgroup$
1
4
$\begingroup$

According to Wolfram Alpha

$$ (\log{(5+i)}+\log{(5-i)})^4= 10\,000$$

When one clicks on "10 000" WA spells it as integer.

$\endgroup$
3
  • 1
    $\begingroup$ WolframAlpha now gives the answer as "112.68232…". $\endgroup$ Jun 13, 2023 at 7:53
  • $\begingroup$ @TheAmplitwist now, it is giving $13.0323...$ $\endgroup$
    – vidyarthi
    Jul 14, 2023 at 10:54
  • $\begingroup$ @vidyarthi Oh! For me, there's no change, it still shows 112.68232…: i.stack.imgur.com/JhahW.png $\endgroup$ Jul 15, 2023 at 8:17
3
$\begingroup$

Wolfram Mathematica 7 routinely confuses sums with integrals.

Example 1:

DSolve[(-Log[Log[a]] f'[x] + f''[x])/(Log[a] f'[x]) == D[Sum[f[x], x], x], f[x], x]

g[x_] := f[x] /. s
g[x]

Checking the result by inserting it into the equation shows the result is incorrect:

(-Log[Log[a]] g'[x] + g''[x])/(Log[a] g'[x]) - D[Sum[g[x], x], x]

Example 2:

s=NDSolve[{0.9159460564995328*Derivative[1][f][x] == f[x]*Product[f[x], x], f[0] == 1}, f, {x, -1.9, 15}]

Plot[Evaluate[f[x] /. s], {x, -0.4, 1.5}, AspectRatio -> Automatic, AxesOrigin -> {0, 0}]

In Mathematica 8.0 this has been fixed (i.e. it will report inability to solve the equations.

$\endgroup$
1
  • $\begingroup$ See other examples. $\endgroup$
    – Anixx
    May 3, 2011 at 2:29
3
$\begingroup$

Mathematica 7.0.1 says that Sum[1/(k*Length[Divisors[k]]), {k, 1, n}] is the harmonic number $H_n$, which is clearly wrong. The correct answer is at An elementary number theoretic infinite series


Edit:

This is less a bug and more a misunderstanding of how to use Mathematica. The culprit is that Length[Divisors[k]] for k without a value evaluates to 1 (which is consistent with how Mathematica structurally treats expressions). The correct way to express the sum is

Sum[1/(k DivisorSigma[0, k]), {k, 1, n}]

which, as expected, now remains unevaluated.

$\endgroup$
0
2
$\begingroup$

Not a bug but a difficulty for users:

I do often not really understand how assignements work for CAS:

Given a variable $a$ with value, say, $\pi$, set $b:=a$ and set now $a$ to, say, $e$. What is the value of $b$?

As I understand the answer depends sometimes on the context (working with symbolic variables, vectors, floating numbers etc.) and the exact behaviour is sometimes difficult to guess for me.

$\endgroup$
5
  • 2
    $\begingroup$ Normally this should not be a matter of guessing. Somewhere the documentation should state whether the evaluation is call-by-value ($b=\pi$) or call-by-reference ($b=e$). $\endgroup$ Apr 27, 2011 at 9:02
  • 6
    $\begingroup$ Maple and Mathematica are both call-by-value. What Roland is probably referring to is that Maple has some variables which have an entirely 'new' calling convention,last-name-evaluation: a cross between call-by-value and call-by-name. An LNE variable (like a table) will 'evaluate' all the way to a value and then BACKTRACK one level and return the last name encountered! The reason for this is purely for display purposes, as the name is preferred over a large value. This decision was made in 1982 (or so), when it made some sense, but now Maple is stuck with this. MMA has similar oddities too $\endgroup$ Apr 27, 2011 at 12:46
  • $\begingroup$ I would be great to leave the choice to to the user! $\endgroup$ Apr 27, 2011 at 13:45
  • 2
    $\begingroup$ @Roland, the problem with leaving the choice to the user would be that the same program would give different results for different users. $\endgroup$
    – JRN
    Apr 28, 2011 at 1:04
  • $\begingroup$ Of course! Passing By Reference or Passing By Value?. One of the classes in your programming courses, though not the first one indeed..... $\endgroup$
    – Brethlosze
    May 18, 2017 at 2:14
1
$\begingroup$

Sagemath and pari/gp disagree about the degree of the zero polynomial over arbitrary rings. Since pari/gp is proper subset of sagemath, this gives us inconsistency in sagemath.

Session:

sage: K.<x>=QQ[];K(0).degree()
-1
sage: gp.poldegree(K(0))
-oo
$\endgroup$
1
-6
$\begingroup$

Here is a very simple common bug: ask your cas to solve in x the equation a x-´b = 0. Probably, the answer would bex = - b/a, that is wrong if a = 0. Most cas assume implicitly that a is not zero (Mathematica is an exception).

$\endgroup$
1
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.