summaryrefslogtreecommitdiff
path: root/lisp
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-23 11:49:55 +0200
commit73e1727c405214086bb3a0647c91855e1b0853c2 (patch)
tree8160877760c649327909662937eb0f1064375c17 /lisp
parentbba9757a1fd7b05f7b18b0666735711d231972fa (diff)
downloademacs-73e1727c405214086bb3a0647c91855e1b0853c2.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')
-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)