From: "Mattias Engdegård" <mattiase@acm.org>
To: Christopher Howard <christopher.howard@qlfiles.net>
Cc: 35374@debbugs.gnu.org
Subject: bug#35374: Calc; Div by 0 in solving system
Date: Tue, 23 Apr 2019 16:34:58 +0200 [thread overview]
Message-ID: <285679AC-2D65-41BD-B672-9D159E4B70FA@acm.org> (raw)
In-Reply-To: <1555861067.5469.3.camel@qlfiles.net>
21 apr. 2019 kl. 17.37 skrev Christopher Howard <christopher.howard@qlfiles.net>:
> I enabled Debug on Error but could not find the backtrace
Reproduced in 26.1. Backtrace below.
I quickly got lost in calcalg2.el, but it looks like the equation
2(z - 1.0) - (5 + 3(z - 1.0) - z) / 2 + 3z + 3 = 0,
isn't solved properly by math-try-solve-for: math-decompose-poly returns the correct decomposition of the LHS, (4) * z, but then the code decides to find a root of the polynomial (4) which of course doesn't exist and nothing good comes out of it. I'm not sure why the floating-point numbers (float 1 0) are there in the first place.
Maybe someone more knowledgeable about Calc can help further.
* math-reject-arg((float 1 0) "*Division by zero")
math-div-by-zero((float 1 0) 0)
math-div((float 1 0) 0)
math-float((frac 1 0))
math-mul((frac 1 0) (float 138629436111989 -14))
math-mul-objects-fancy((frac 1 0) (cplx (float 138629436111989 -14) (float 314159265358979 -14)))
math-mul((frac 1 0) (cplx (float 138629436111989 -14) (float 314159265358979 -14)))
math-pow-fancy(-4 (frac 1 0))
math-pow(-4 (frac 1 0))
math-poly-laguerre-root((4) 0 t)
math-poly-any-root((4) 0 t)
math-try-solve-for((+ (+ (- (* 2 (- (var z var-z) (float 1 0))) (/ (- (+ 5 (* 3 (- (var z var-z) (float 1 0)))) (var z var-z)) 2)) (* 3 (var z var-z))) 3) 0 nil nil)
math-try-solve-for((calcFunc-eq (+ (- (* 2 (- (var z var-z) (float 1 0))) (/ (- (+ 5 (* 3 (- (var z var-z) (float 1 0)))) (var z var-z)) 2)) (* 3 (var z var-z))) -3) 0 nil)
math-solve-for((calcFunc-eq (+ (- (* 2 (- (var z var-z) (float 1 0))) (/ (- (+ 5 (* 3 (- (var z var-z) (float 1 0)))) (var z var-z)) 2)) (* 3 (var z var-z))) -3) 0 (var z var-z) nil)
math-solve-system-rec((((calcFunc-eq (+ (- (* 2 (- (var z var-z) (float 1 0))) (/ (- (+ 5 (* 3 (- (var z var-z) (float 1 0)))) (var z var-z)) 2)) (* 3 (var z var-z))) -3))) ((var z var-z)) (((var y var-y) (- (var z var-z) (float 1 0))) ((var x var-x) (/ (- (+ 5 (* 3 (- (var z var-z) (float 1 0)))) (var z var-z)) 2))))
math-solve-system-rec((((calcFunc-eq (- (+ (/ (- (+ 5 (* 3 (var y var-y))) (var z var-z)) 2) (var y var-y)) (* 2 (var z var-z))) 0)) ((calcFunc-eq (+ (- (* 2 (var y var-y)) (/ (- (+ 5 (* 3 (var y var-y))) (var z var-z)) 2)) (* 3 (var z var-z))) -3))) ((var y var-y) (var z var-z)) (((var x var-x) (/ (- (+ 5 (* 3 (var y var-y))) (var z var-z)) 2))))
math-solve-system-rec((((calcFunc-eq (+ (- (* 2 (var x var-x)) (* 3 (var y var-y))) (var z var-z)) 5)) ((calcFunc-eq (- (+ (var x var-x) (var y var-y)) (* 2 (var z var-z))) 0)) ((calcFunc-eq (+ (- (* 2 (var y var-y)) (var x var-x)) (* 3 (var z var-z))) -3))) ((var x var-x) (var y var-y) (var z var-z)) nil)
math-solve-system((vec (calcFunc-eq (+ (- (* 2 (var x var-x)) (* 3 (var y var-y))) (var z var-z)) 5) (calcFunc-eq (- (+ (var x var-x) (var y var-y)) (* 2 (var z var-z))) 0) (calcFunc-eq (+ (- (* 2 (var y var-y)) (var x var-x)) (* 3 (var z var-z))) -3)) (vec (var x var-x) (var y var-y) (var z var-z)) nil)
calcFunc-solve((vec (calcFunc-eq (+ (- (* 2 (var x var-x)) (* 3 (var y var-y))) (var z var-z)) 5) (calcFunc-eq (- (+ (var x var-x) (var y var-y)) (* 2 (var z var-z))) 0) (calcFunc-eq (+ (- (* 2 (var y var-y)) (var x var-x)) (* 3 (var z var-z))) -3)) (vec (var x var-x) (var y var-y) (var z var-z)))
apply(calcFunc-solve ((vec (calcFunc-eq (+ (- (* 2 (var x var-x)) (* 3 (var y var-y))) (var z var-z)) 5) (calcFunc-eq (- (+ (var x var-x) (var y var-y)) (* 2 (var z var-z))) 0) (calcFunc-eq (+ (- (* 2 (var y var-y)) (var x var-x)) (* 3 (var z var-z))) -3)) (vec (var x var-x) (var y var-y) (var z var-z))))
math-normalize((calcFunc-solve (vec (calcFunc-eq (+ (- (* 2 (var x var-x)) (* 3 (var y var-y))) (var z var-z)) 5) (calcFunc-eq (- (+ (var x var-x) (var y var-y)) (* 2 (var z var-z))) 0) (calcFunc-eq (+ (- (* 2 (var y var-y)) (var x var-x)) (* 3 (var z var-z))) -3)) (vec (var x var-x) (var y var-y) (var z var-z))))
math-simplify((calcFunc-solve (vec (calcFunc-eq (+ (- (* 2 (var x var-x)) (* 3 (var y var-y))) (var z var-z)) 5) (calcFunc-eq (- (+ (var x var-x) (var y var-y)) (* 2 (var z var-z))) 0) (calcFunc-eq (+ (- (* 2 (var y var-y)) (var x var-x)) (* 3 (var z var-z))) -3)) (vec (var x var-x) (var y var-y) (var z var-z))))
calc-normalize-fancy((calcFunc-solve (vec (calcFunc-eq (+ (- (* 2 (var x var-x)) (* 3 (var y var-y))) (var z var-z)) 5) (calcFunc-eq (- (+ (var x var-x) (var y var-y)) (* 2 (var z var-z))) 0) (calcFunc-eq (+ (- (* 2 (var y var-y)) (var x var-x)) (* 3 (var z var-z))) -3)) (vec (var x var-x) (var y var-y) (var z var-z))))
calc-normalize((calcFunc-solve (vec (calcFunc-eq (+ (- (* 2 (var x var-x)) (* 3 (var y var-y))) (var z var-z)) 5) (calcFunc-eq (- (+ (var x var-x) (var y var-y)) (* 2 (var z var-z))) 0) (calcFunc-eq (+ (- (* 2 (var y var-y)) (var x var-x)) (* 3 (var z var-z))) -3)) (vec (var x var-x) (var y var-y) (var z var-z))))
math-evaluate-expr((calcFunc-solve (vec (calcFunc-eq (+ (- (* 2 (var x var-x)) (* 3 (var y var-y))) (var z var-z)) 5) (calcFunc-eq (- (+ (var x var-x) (var y var-y)) (* 2 (var z var-z))) 0) (calcFunc-eq (+ (- (* 2 (var y var-y)) (var x var-x)) (* 3 (var z var-z))) -3)) (vec (var x var-x) (var y var-y) (var z var-z))))
mapcar(math-evaluate-expr ((calcFunc-solve (vec (calcFunc-eq (+ (- (* 2 (var x var-x)) (* 3 (var y var-y))) (var z var-z)) 5) (calcFunc-eq (- (+ (var x var-x) (var y var-y)) (* 2 (var z var-z))) 0) (calcFunc-eq (+ (- (* 2 (var y var-y)) (var x var-x)) (* 3 (var z var-z))) -3)) (vec (var x var-x) (var y var-y) (var z var-z)))))
#f(compiled-function () #<bytecode 0x4a71afd9>)()
calc-do(#f(compiled-function () #<bytecode 0x4a71afd9>) 126)
calc-evaluate(1)
funcall-interactively(calc-evaluate 1)
call-interactively(calc-evaluate nil nil)
command-execute(calc-evaluate)
next parent reply other threads:[~2019-04-23 14:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1555861067.5469.3.camel@qlfiles.net>
2019-04-23 14:34 ` Mattias Engdegård [this message]
2019-04-22 5:20 bug#35374: Calc; Div by 0 in solving system Christopher Howard
2019-09-22 17:34 ` Mattias Engdegård
2019-09-23 5:28 ` Christopher Howard
2019-09-23 10:11 ` Mattias Engdegård
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=285679AC-2D65-41BD-B672-9D159E4B70FA@acm.org \
--to=mattiase@acm.org \
--cc=35374@debbugs.gnu.org \
--cc=christopher.howard@qlfiles.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).