Function: math-decompose-poly

math-decompose-poly is a byte-compiled function defined in calcalg2.el.gz.

Signature

(math-decompose-poly SOLVE-LHS SOLVE-VAR DEGREE SUB-RHS)

Source Code

;; Defined in /usr/src/emacs/lisp/calc/calcalg2.el.gz
(defun math-decompose-poly (solve-lhs solve-var degree sub-rhs)
  (let ((math-solve-lhs solve-lhs)
	(math-solve-var solve-var)
	(math-solve-rhs (or sub-rhs 1))
	math-t1 math-t2 math-t3)
    (setq math-t2 (math-polynomial-base
	      math-solve-lhs
              (lambda (solve-b)
                (let ((math-solve-b solve-b)
                      (math-poly-neg-powers '(1))
                      (math-poly-mult-powers nil)
                      (math-poly-frac-powers 1)
                      (math-poly-exp-base t))
                  (and (not (equal math-solve-b math-solve-lhs))
                       (or (not (memq (car-safe math-solve-b) '(+ -))) sub-rhs)
                       (setq math-t3 '(1 0) math-t2 1
                             math-t1 (math-is-polynomial math-solve-lhs
                                                         math-solve-b 50))
                       (if (and (equal math-poly-neg-powers '(1))
                                (memq math-poly-mult-powers '(nil 1))
                                (eq math-poly-frac-powers 1)
                                sub-rhs)
                           (setq math-t1 (cons (math-sub (car math-t1) math-solve-rhs)
                                               (cdr math-t1)))
                         (math-solve-poly-funny-powers sub-rhs))
                       (math-solve-crunch-poly degree)
                       (or (math-expr-contains math-solve-b math-solve-var)
                           (math-expr-contains (car math-t3) math-solve-var)))))))
    (if math-t2
	(list (math-pow math-t2 (car math-t3))
	      (cons 'vec math-t1)
	      (if sub-rhs
		  (math-pow math-t2 (nth 1 math-t3))
		(math-div (math-pow math-t2 (nth 1 math-t3)) math-solve-rhs))))))