- labels: --> 460522
Horner of a list/matrix/equation returns the argument.
Looking at the code shows that it is intended to map
across these aggregates (or bags as they're called).
The problem is that it is putting the argument in rational
form *before* checking whether it is a bag.
There are two possible ways to fix it. First is to modify
Horner.
(defmfun $horner (expr &rest vars)
(if (mbagp expr)
(cons (car expr)
(mapcar #'(lambda (u) (apply '$horner u
vars))
(cdr expr)))
(let* (($ratfac nil)
(varlist (cdr $ratvars))
(genvar nil)
(x (apply '$rat (taychk2rat expr) vars)))
(mapc #'(lambda (y z) (putprop y z 'disrep))
(cadddr (car x))
(caddar x))
(div* (hornrep (cadr x))
(hornrep (cddr x))))))
The cleaner way is to modify taychk2rat to use $rat
instead of ratf. In that case, ratnumer and ratdenom
also need to be modified to explicity check mbagp. The
only other use of taychk2rat is in partfrac, and this
change doesn't bother it. The only risk to doing this is if
there is user code that depends on (e.g) ratnumer([x/y])
returning [x/y] rather than [x], which seems highly
unlikely.
(DEFMFUN $RATNUMER (X)
(IF (MBAGP X)
(CONS (CAR X) (MAPCAR '$RATNUMER (CDR X)))
(SETQ X (TAYCHK2RAT X))
(CONS (CAR X) (CONS (CADR X) 1))))
(DEFMFUN $RATDENOM (X)
(IF (MBAGP X)
(CONS (CAR X) (MAPCAR '$RATDENOM (CDR X)))
(SETQ X (TAYCHK2RAT X))
(CONS (CAR X) (CONS (CDDR X) 1))))
(DEFUN TAYCHK2RAT (X)
(COND ((AND ($RATP X)
(MEMQ 'TRUNC (CDAR X)))
($TAYTORAT X))
(T ($RAT X))))
Logged In: YES
user_id=501686
Observed in Maxima 5.9.3cvs.
The suggested tix to the functions $ratnumer, $ratdenom, and taychk2rat have been applied with revision 1.24 of rat3e.lisp.
Closing this bug report as fixed.
Dieter Kaiser
Log in to post a comment.