I stumbled upon the following problem in trigreduce():
Maxima 5.45.1 https://maxima.sourceforge.io
using Lisp SBCL 1.4.9
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) trigreduce(cos(1/2*acos(q))^2*sin(1/2*acos(q))^2);
Maxima encountered a Lisp error:
The value
1
is not of type
LIST
Automatically continuing.
To enable the Lisp debugger set *debugger-hook* to nil.
(%i2) build_info();
(%o2)
Maxima version: "5.45.1"
Maxima build date: "2021-11-01 10:49:25"
Host type: "x86_64-pc-linux-gnu"
Lisp implementation type: "SBCL"
Lisp implementation version: "1.4.9"
User dir: "/home/rifleman/.maxima"
Temp dir: "/tmp"
Object dir: "/home/rifleman/.maxima/binary/5_45_1/sbcl/1_4_9"
Frontend: false
The correct answer should be something like (1-q^2)/4 .
Confirmed in Maxima post-5.45. I was digging around in src/trgred.lisp a little bit, and I tried a few changes to SP1TLIN to avoid the error, but I wasn't able to get a correct result.
The code in src/trgred.lisp is pretty convoluted; from reading the comments, it looks like a fairly narrow range of expressions is handled. If so, then just starting over and rewriting in Maxima, making use of the pattern matching machinery (matchdeclare / defrule, etc.) could be a win.
For the record, I find I can get to the expected result by working in steps.
I found a lot of examples by now, where the same problem appears.
Here are two of them:
The second one of course must involve complex numbers. But if i switch to complex
domain here, i get
and this is just wrong. A correct answer would be something like
-1/16 x^2 sqrt(-x^2) (1+sqrt(1+x^2))
or maybe
-i/16 x^3 (1+sqrt(1+x^2))
Is that the same problem? Or should this have its own ticket?
Dominik, thanks for the additional example. I've copied it to a separate ticket: https://sourceforge.net/p/maxima/bugs/4620/
trigreduce(cos(k*acos(q))^2*sin(k*acos(q))^2)also works fine.Substituting k=1/2, applying
trigexpand, thenratsimp, gets a nice simple (and correct) answer,-(q^2-1)/4.Another workaround is
but of course that doesn't fix the bug.