summaryrefslogtreecommitdiff
path: root/lisp/calc
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2019-09-22 15:03:02 +0200
committerMattias EngdegÄrd <mattiase@acm.org>2019-09-29 13:41:21 +0200
commit19405291aa5b1f7de7e44cc2efe384840b144236 (patch)
treede07f6ca665f86881ffa7628a165c719fc3b7a11 /lisp/calc
parentab2a8f70775ff1c51e3b3b5f7b337c3fe5132db2 (diff)
downloademacs-19405291aa5b1f7de7e44cc2efe384840b144236.tar.gz
Fix linear equation system solving in Calc (bug#35374)
* lisp/calc/calcalg2.el (math-try-solve-for): To solve Ax^n=0 where A is a nonzero constant and x the variable to solve for, solve x^n=0 instead of solving A=0 (which obviously fails) or something equally stupid. * test/lisp/calc/calc-tests.el (calc-test-solve-linear-system): New.
Diffstat (limited to 'lisp/calc')
-rw-r--r--lisp/calc/calcalg2.el6
1 files changed, 6 insertions, 0 deletions
diff --git a/lisp/calc/calcalg2.el b/lisp/calc/calcalg2.el
index 18243bfc749..2a716633ae6 100644
--- a/lisp/calc/calcalg2.el
+++ b/lisp/calc/calcalg2.el
@@ -2417,6 +2417,12 @@
((= (length math-t1) 2)
(apply 'math-solve-linear
(car math-t2) math-try-solve-sign math-t1))
+ ((= (length math-t1) 1)
+ ;; Constant polynomial.
+ (if (eql (nth 2 math-t2) 1)
+ nil ; No possible solution.
+ ;; Root of the factor, if any.
+ (math-try-solve-for (nth 2 math-t2) 0 nil t)))
(math-solve-full
(math-poly-all-roots (car math-t2) math-t1))
(calc-symbolic-mode nil)