;;; Algebra commands.
+(defvar math-simplify-only)
+
(defun calc-alg-evaluate (arg)
(interactive "p")
(calc-slow-wrapper
(calc-modify-simplify-mode arg)
(calc-enter-result 1 "dsmp" (calc-top 1))))))
+(defvar calc-simplify-mode)
+
(defun calc-modify-simplify-mode (arg)
(if (= (math-abs arg) 2)
(setq calc-simplify-mode 'alg)
(calc-with-default-simplification
(calc-enter-result 1 "esmp" (math-simplify-extended (calc-top-n 1))))))
+(defvar math-expand-formulas)
+
(defun calc-expand-formula (arg)
(interactive "p")
(calc-slow-wrapper
(calc-binary-op "pgcd" 'calcFunc-pgcd arg)))
+(defvar calc-poly-div-remainder)
+
(defun calc-poly-div (arg)
(interactive "P")
(calc-slow-wrapper
(math-beforep (car a) (car b)))))
(t (string-lessp (car a) (car b)))))
+(defvar math-living-dangerously)
(defsubst math-simplify-extended (a)
(let ((math-living-dangerously t))
;; math-normalize-error is declared in calc.el.
(defvar math-normalize-error)
+(defvar math-simplifying)
+(defvar calc-angle-mode)
+
(defun math-simplify (top-expr)
(let ((math-simplifying t)
(calc-angle-mode (if (calc-input-angle-units top-expr)
(math-make-frac (math-gcd (nth 1 a) (nth 1 b))
(math-gcd (nth 2 a) (nth 2 b)))))))
+(defvar calc-prefer-frac)
+
(math-defsimplify %
(and (Math-realp (nth 2 expr))
(Math-posp (nth 2 expr))
(defvar math-is-poly-degree)
(defvar math-is-poly-loose)
(defvar math-var)
+(defvar math-poly-base-variable)
(defun math-is-polynomial (expr var &optional degree loose)
(let* ((math-poly-base-variable (if loose
'(vec (calcFunc-eq (var x var-x) 3)
(calcFunc-eq (var y var-y) 0)))))
+(ert-deftest calc-poly-div ()
+ "Test polynomial division, and that the remainder is recorded in the trail."
+ (with-current-buffer (calc-trail-buffer)
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+
+ (calc-eval "2x**3+1" 'push)
+ (calc-eval "x**2+2x" 'push)
+ (calc-poly-div nil)
+ (let ((tos (calc-top-n 1))
+ (trail (buffer-string)))
+ (calc-pop 0)
+ (should (equal tos '(- (* 2 (var x var-x)) 4)))
+ (should (equal trail "pdiv 2 * x - 4\nprem 8 * x + 1\n"))))))
+
(provide 'calc-tests)
;;; calc-tests.el ends here