#176 horner([...],x)/FIX

closed
nobody
5
2014-09-04
2002-10-30
No

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))))

Discussion

  • Robert Dodier

    Robert Dodier - 2006-07-01
    • labels: --> 460522
     
  • Robert Dodier

    Robert Dodier - 2006-09-09

    Logged In: YES
    user_id=501686

    Observed in Maxima 5.9.3cvs.

     
  • Robert Dodier

    Robert Dodier - 2006-09-09
    • labels: 460522 --> Lisp Core - Polynomials
     
  • Robert Dodier

    Robert Dodier - 2006-09-09
    • milestone: --> Includes_proposed_fix
     
  • Dieter Kaiser

    Dieter Kaiser - 2009-07-01

    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

     
  • Dieter Kaiser

    Dieter Kaiser - 2009-07-01
    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks