Function: math-ratpoly-p

math-ratpoly-p is an autoloaded and byte-compiled function defined in calc-poly.el.gz.

Signature

(math-ratpoly-p EXPR &optional VAR)

Source Code

;; Defined in /usr/src/emacs/lisp/calc/calc-poly.el.gz
(defun math-ratpoly-p (expr &optional var)
  (cond ((equal expr var) 1)
	((Math-primp expr) 0)
	((memq (car expr) '(+ -))
	 (let ((p1 (math-ratpoly-p (nth 1 expr) var))
	       p2)
	   (and p1 (setq p2 (math-ratpoly-p (nth 2 expr) var))
		(max p1 p2))))
	((eq (car expr) '*)
	 (let ((p1 (math-ratpoly-p (nth 1 expr) var))
	       p2)
	   (and p1 (setq p2 (math-ratpoly-p (nth 2 expr) var))
		(+ p1 p2))))
	((eq (car expr) 'neg)
	 (math-ratpoly-p (nth 1 expr) var))
	((eq (car expr) '/)
	 (let ((p1 (math-ratpoly-p (nth 1 expr) var))
	       p2)
	   (and p1 (setq p2 (math-ratpoly-p (nth 2 expr) var))
		(- p1 p2))))
	((and (eq (car expr) '^)
	      (integerp (nth 2 expr)))
	 (let ((p1 (math-ratpoly-p (nth 1 expr) var)))
	   (and p1 (* p1 (nth 2 expr)))))
	((not var) 1)
	((math-poly-depends expr var) nil)
	(t 0)))