- labels: 460522 --> Lisp Core - Simplification
Dunno what's going on here. I'm guessing that letsimp
tries to assign something to %pi as a trial value while
trying to match x/(%pi*sin(y)) to a/(%pi*sin(b)). I
haven't looked at the code.
(%i1) matchdeclare ([a,b],true);
(%o1) done
(%i2) letrat: true;
(%o2) true
(%i3) let (a/(%pi*sin(b)),foo(a,b));
a
(%o3) ---------- --> foo(a, b)
%pi sin(b)
(%i4) x/(%pi*sin(y));
x
(%o4) ----------
%pi sin(y)
(%i5) letsimp(%);
%pi improper value assignment to a numerical quantity
-- an error. Quitting. To debug this try
debugmode(true);
Maxima version: 5.9.1.1cvs
Maxima build date: 23:52 1/25/2005
host type: i686-redhat-linux-gnu
lisp-implementation-type: CLISP
lisp-implementation-version: 2.31 (released 2003-09-01)
also observed in
Maxima version: 5.9.1
Maxima build date: 21:24 9/23/2004
host type: i686-pc-linux-gnu
lisp-implementation-type: CMU Common Lisp
lisp-implementation-version: 19a
The reported problem is a general problem when we have a numeric constant in a let-rule.
Again an example with the symbol %e which is more simple:
(%i1) matchdeclare(a,true)$
(%i2) let(%e*a,foo(a))$
(%i3) letsimp(%e*x);
assignment: cannot assign to %e; it is a declared numeric quantity.
-- an error. To debug this try: debugmode(true);
The error is in the routine nisnumberpicker in the file nisimp.lisp. This routine skips over numbers but not over numeric constants. When can extend the routine:
(defun nisnumberpicker (x)
(cond ((null x) nil)
((or (not (symbolp (caar x)))
(kindp (caar x) '$constant))
(nisnumberpicker (cdr x)))
(t (nisswcdr x (nisnumberpicker (cdr x))))))
This would be the new and correct result:
(%i5) letsimp(%e*x);
(%o5) foo(x)
This is the result for the reported example:
(%i1) matchdeclare([a,b],true)$
(%i2) let(a/(%pi*sin(b)),foo(a,b))$
(%i3) letrat:true$
(%i4) letsimp(x/(%pi*sin(y)));
(%o4) foo(x,y)
Dieter Kaiser
Fixed in nisimp.lisp revision 1.10. We skip over constants in nisnumberpicker too.
Closing this bug report as fixed.
Dieter Kaiser