# [Maxima] Bug # 535363 and using polynomialp

Richard Fateman fateman at cs.berkeley.edu
Fri Sep 21 23:01:37 CDT 2007

```polynomialp((x^2-1)/(x-1),[x])  returns false. I suggest it might be
supplemented by a program that gets this right.

Here is a definition for a program that might be useful and shows how to use
the CRE form, too

(defun \$pp1(z) (let ((varlist nil)) ;; test for polynomial. returns superset
of list of variables
(declare (special varlist))
(setf z (\$rat z))
;; if the denominator is a constant, return a macsyma list of the
variables, else false
(if (constantp (cddr z)) (cons '(mlist) (third (car z)))
nil)))

;; this one requires a little more work, but tells you exactly which
variables are in the
;; polynomial. It will not be fooled by  (y^2-1)/(y+1)-y+x.  Whereas pp1
will say [x,y], this says [x]

(defun \$pp2(z) (let ((varlist nil)) ;; test for polynomial. returns list of
exactly variables
(declare (special varlist))
(setf z(\$ratdisrep(\$rat z)))
(setf varlist nil)
(setf z (\$rat z ))
(if (constantp (cddr z)) (cons '(mlist) (third (car z)))
nil)))
```