I had a look at algsys because of Lisp Errors for some problems. The
related bug reports are SF[609466], SF[1430379] and SF[1663399]. In all
cases the routine PUNIVARP is called with the number ZERO which causes
the Lisp Error. A simple change to prevent the Lisp Error would be to
add a check to the routine PUNIVARP:
(defun punivarp (poly)
;; Check if called with the number zero, return nil.
;; Related bugs: SF[609466], SF[1430379], SF[1663399]
(when (and (numberp poly) (= poly 0)) (return-from punivarp nil))
(do ((l (cdr poly) (cddr l)))
((null l) t)
(or (numberp (cadr l))
(and (eq (caadr l) *ivar*)
(punivarp (cadr l)))
(return nil))))
With this change to PUNIVARP the algorithm returns the message:
(%i1) solve([a*d+b*c,a+d],[a,b,c,d]);
`algsys' cannot solve - system too complicated.
-- an error. To debug this try debugmode(true);
This change does not improve algsys to get more solutions. The problem
is that the algorithm of algsys does not always do the best substitution
of the parameters.
This can be improved switching the flag $algebraic on. If we set in
addition $algebraic to TRUE in the function $algsys we get more
solutions. This are the examples already shown in the bug reports which
will give the following solutions:
(%i10) solve([a+b+c=0,a^2+b^2+c^2=1],[a,b,c]);
(%o10) [[a = %r57,b = -(sqrt(2-3*%r57^2)+%r57)/2,
c = (sqrt(2-3*%r57^2)-%r57)/2],
[a = %r58,b = (sqrt(2-3*%r58^2)-%r58)/2,
c = -(sqrt(2-3*%r58^2)+%r58)/2]]
(%i11) solve([a*d+b*c,a+d],[a,b,c,d]);
(%o11) [[a = -sqrt(%r59*%r60),b = %r59,c = %r60,
d = sqrt(%r59)*sqrt(%r60)],
[a = sqrt(%r61*%r62),b = %r61,c = %r62,
d = -sqrt(%r61)*sqrt(%r62)]]
(%i12) solve([b*c+a^2-a,b*d+a*b-b,c*d+a*c-c,d^2-d+b*c],[a,b,c,d]);
(%o12) [[a = -(sqrt(1-4*%r63*%r64)-1)/2,b = %r63,c = %r64,
d = (sqrt(1-4*%r63*%r64)+1)/2],
[a = (sqrt(1-4*%r65*%r66)+1)/2,b = %r65,c = %r66,
d = -(sqrt(1-4*%r65*%r66)-1)/2],[a = 0,b = %r67,c = 0,d = 1],
[a = 1,b = %r68,c = 0,d = 0],[a = 1,b = 0,c = 0,d = 1],
[a = 0,b = 0,c = 0,d = 0]]
The testsuite will have no problems. Two results are mathematically
equivalent, but look a bit different.
These are the two options I would like to suggest to close the bug
reports:
1. Add a test to punivarp to prevent a fatal Lisp error.
2. Setting the flag $algebraic to TRUE in the routine $algsys.
What do you think. Should we do both changes or only the first one, to
prevent the fatal Lisp error.
Dieter Kaiser