I'm a first-year Open University student studying for a Mathematics degree. We have to use Maxima but are told to use an older version because of a bug with complex numbers in recent releases. I believe that the Open University are recommending we use version 5.38.1 of Maxima. I can see the bug with Maxima 5.47.0
I'm trying to attach multiple files, but it's not clear from the Sourceforge interface if more than one is being attached. If not, I will attach other files later. The bug is demonstrated by activity 65 of the Computer Algebra Guide. I have, or at least will soon, attach a few pages from that, which show what should be done, and the answers in the back of the book.
I have verified the results in the Mathematica. ** This is a regression, as Maxima used to provide the correct results, but recent(ish) releases are not. **
These Maxima commands demonstrate the bug.
c:3*(cos(5*%pi/13)+%i*sin(5*%pi/13));
d:4*(cos(7*%pi/13)+%i*sin(7*%pi/13));
trigreduce(carg(c*d));
That gives a result of 25 Pi/13, but the correct result is 12 Pi/13. Mathematica does not show 12 Pi/13, but produces a huge expression I'm not going to bother trying to write. But converting Mathematic's symbolic expression to a numerical value, computed with 60 digits of precision, gives the same as 12 Pi/13 computed to 60 digits.
c = 3 (Cos[5 Pi/13] + I Sin[5 Pi/13])
d = 4 (Cos[7 Pi/13] + I Sin[7 Pi/13])
N[TrigReduce[Arg[c d]], 60]
2.89993168023673222011936312302723343156661790711548229628456
N[12 Pi/13, 60]
2.89993168023673222011936312302723343156661790711548229628456
This Maxima command also gives the wrong result.
trigreduce(carg(c/d));
That gives a result of 11 Pi/13, but the correct result is 24 Pi/13.
Adding a section from the Open University Computer Algebra guide for the module I'm studying.
Maxima worksheet demonstrating the bug.
Results computed with Mathematica.
I should have added, the result from the earlier version of Maxima for
trigreduce(carg(c/d))is 24 Pi/13.
Is you subtract 2 Pi it is -2 Pi/13, which is what Mathematica gives, with
I think it's a problem with how
trigreducehandlesatan(sin(x)/cos(x))in combination withtriginverses:true, which is the default.trigreducewill convertsin(7*%pi/13)/cos(7*%pi/13)totan(7*%pi/13)as expected. Thenatan(tan(7*%pi/13))is7*%pi/13withtriginverses:truebut-6*%pi/13withtriginverses:false.I didn't look, but maybe
trigreducesetstriginverses:true, becausetrigreduce(cargs(c*d))produces the wrong answer even if I settriginverses:false.Something has probably changed in
trigreducethen, as it used to work properly.I did not add any labels to this bug report - I did not see the option. But perhaps someone with more knowledge of me can add appropriate labels.
It's impressive how nice the result is from earlier versions of Maxima compare to a current version of Mathematica, which produces a huge expression, rather than a simple irrational number. But Maxima producing the wrong answer is clearly not desirable.
Thanks for the hint.
git bisectshows that the offending commit is the following. Incidentally this commit is between versions 5.41 and 5.42.Glancing at this, I don't see how that comes into play in the example you showed in the problem statement above, however,
git bisectshows that this is the commit where the result changed from12*%pi/13to25*%pi/13.I wonder if there is a simpler example which shows the same incorrect behavior.
That's a good hint. I think that means in the old version, we probably weren't calling
sp1and falling through to the default case of callingsp1atrig2.Maybe the solution here is to change the condition to also check for the value of
triginversesto betruebefore callingsp1?One of the staff tutors at the Open University contacted me with a simpler example. I'll just copy/paste what he wrote:
"If you would like to see an easier example of the carg bug then it happens for any angle larger than pi/2. For example
trigreduce(carg(cos(3*%pi/5)+%i * sin(3*%pi/5)))will give the incorrect answer."Last edit: Robert Dodier 2025-04-13
I've asked a few people at the Open University if they know of a simpler example. None do, but one of the senior academics is going to try to look into whether she can provide a simpler example. I don't have the mathematical ability to do so myself, but I knew enough of Mathematica to satisfy myself they were correct in identifying this as a bug.
Fixed by commit [ 723d702 ]. Closing this report.