Mercurial > emacs
changeset 101419:a6530c979556
(calcFunc-apart): Improve test for rational functions.
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Sat, 24 Jan 2009 02:24:41 +0000 |
parents | 197ad3185efc |
children | 69f5f041fe43 |
files | lisp/calc/calc-poly.el |
diffstat | 1 files changed, 17 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/calc/calc-poly.el Fri Jan 23 22:33:43 2009 +0000 +++ b/lisp/calc/calc-poly.el Sat Jan 24 02:24:41 2009 +0000 @@ -961,22 +961,24 @@ ((eq (car expr) '-) (math-sub (calcFunc-apart (nth 1 expr) var) (calcFunc-apart (nth 2 expr) var))) - ((not (math-ratpoly-p expr var)) - (math-reject-arg expr "Expected a rational function")) + ((and var (not (math-ratpoly-p expr var))) + (math-reject-arg expr "Expected a rational function")) (t - (let* ((calc-prefer-frac t) - (rat (math-to-ratpoly expr)) - (num (car rat)) - (den (cdr rat)) - (qr (math-poly-div num den)) - (q (car qr)) - (r (cdr qr))) - (or var - (setq var (math-polynomial-base den))) - (math-add q (or (and var - (math-expr-contains den var) - (math-partial-fractions r den var)) - (math-div r den))))))) + (let* ((calc-prefer-frac t) + (rat (math-to-ratpoly expr)) + (num (car rat)) + (den (cdr rat))) + (or var + (setq var (math-polynomial-base den))) + (if (not (math-ratpoly-p expr var)) + (math-reject-arg expr "Expected a rational function") + (let* ((qr (math-poly-div num den)) + (q (car qr)) + (r (cdr qr))) + (math-add q (or (and var + (math-expr-contains den var) + (math-partial-fractions r den var)) + (math-div r den))))))))) (defun math-padded-polynomial (expr var deg)