Function: math-poly-div-coefs
math-poly-div-coefs is a byte-compiled function defined in
calc-poly.el.gz.
Signature
(math-poly-div-coefs U V)
Documentation
Divide two polynomials in coefficient-list form. Return (quot . rem).
Source Code
;; Defined in /usr/src/emacs/lisp/calc/calc-poly.el.gz
(defun math-poly-div-coefs (u v)
"Divide two polynomials in coefficient-list form. Return (quot . rem)."
(cond ((null v) (math-reject-arg nil "Division by zero"))
((< (length u) (length v)) (cons nil u))
((cdr u)
(let ((q nil)
(urev (reverse u))
(vrev (reverse v)))
(while
(let ((qk (math-poly-div-rec (math-simplify (car urev))
(car vrev)))
(up urev)
(vp vrev))
(if (or q (not (math-zerop qk)))
(setq q (cons qk q)))
(while (setq up (cdr up) vp (cdr vp))
(setcar up (math-sub (car up) (math-mul-thru qk (car vp)))))
(setq urev (cdr urev))
up))
(while (and urev (Math-zerop (car urev)))
(setq urev (cdr urev)))
(cons q (nreverse (mapcar 'math-simplify urev)))))
(t
(cons (list (math-poly-div-rec (car u) (car v)))
nil))))