* Calc; Div by 0 in solving system
@ 2019-04-21 15:37 Christopher Howard
2019-04-22 6:23 ` Eli Zaretskii
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Christopher Howard @ 2019-04-21 15:37 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 664 bytes --]
Place this on stack with algebriac mode:
[2 * x - 3 * y + z = 5, x + y - 2 * z = 0, -x + 2 * y + 3 * z = -3]
run command 'a S x,y,z'
Receive error 'Division by zero: 1'
I enabled Debug on Error but could not find the backtrace
Emacs : GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
of 2017-09-14, modified by Debian
Package: Calc
--
Christopher Howard
p: +1 (907) 374-0257
w: https://librehacker.com
xmpp: creationist@member.fsf.org
otr: E9685B53 01F038DD D29281C9 30FDA71E BD0095D4
gnupg: 23FD5CC5 (keys.gnupg.net)
radio: KL1TL
featured: https://emailselfdefense.fsf.org/en/ id="-x-evo-selection-start-marker">
[-- Attachment #2: Type: text/html, Size: 866 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Calc; Div by 0 in solving system
2019-04-21 15:37 Calc; Div by 0 in solving system Christopher Howard
@ 2019-04-22 6:23 ` Eli Zaretskii
2019-04-22 6:56 ` Mattias Engdegård
2019-04-23 14:34 ` bug#35374: " Mattias Engdegård
2 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2019-04-22 6:23 UTC (permalink / raw)
To: Christopher Howard; +Cc: emacs-devel
> From: Christopher Howard <christopher.howard@qlfiles.net>
> Date: Sun, 21 Apr 2019 07:37:47 -0800
>
> Place this on stack with algebriac mode:
>
> [2 * x - 3 * y + z = 5, x + y - 2 * z = 0, -x + 2 * y + 3 * z = -3]
>
> run command 'a S x,y,z'
>
> Receive error 'Division by zero: 1'
>
> I enabled Debug on Error but could not find the backtrace
Here's the backtrace, obtained by setting debug-on-message to
"Division by zero":
Debugger entered--Lisp error: "Division by zero: 1."
message("%s%s" "Division by zero: 1." "")
calc-explain-why((* "Division by zero" (float 1 0)) nil)
calc-do-handle-whys()
calc-handle-whys()
calc-enter-result(1 "solv" (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 0x2000000001d6b378>)()
calc-do(#f(compiled-function () #<bytecode 0x2000000001d6b378>) 102)
calc-solve-for("x,y,z")
funcall-interactively(calc-solve-for "x,y,z")
call-interactively(calc-solve-for nil nil)
command-execute(calc-solve-for)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Calc; Div by 0 in solving system
2019-04-21 15:37 Calc; Div by 0 in solving system Christopher Howard
2019-04-22 6:23 ` Eli Zaretskii
@ 2019-04-22 6:56 ` Mattias Engdegård
2019-04-23 14:34 ` bug#35374: " Mattias Engdegård
2 siblings, 0 replies; 4+ messages in thread
From: Mattias Engdegård @ 2019-04-22 6:56 UTC (permalink / raw)
To: Christopher Howard; +Cc: Emacs developers
21 apr. 2019 kl. 17.37 skrev Christopher Howard <christopher.howard@qlfiles.net>:
>
> Place this on stack with algebriac mode:
>
> [2 * x - 3 * y + z = 5, x + y - 2 * z = 0, -x + 2 * y + 3 * z = -3]
>
> run command 'a S x,y,z'
>
> Receive error 'Division by zero: 1'
>
> I enabled Debug on Error but could not find the backtrace
This is the backtrace I get in Emacs 26.1:
* 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)
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#35374: Calc; Div by 0 in solving system
2019-04-21 15:37 Calc; Div by 0 in solving system Christopher Howard
2019-04-22 6:23 ` Eli Zaretskii
2019-04-22 6:56 ` Mattias Engdegård
@ 2019-04-23 14:34 ` Mattias Engdegård
2 siblings, 0 replies; 4+ messages in thread
From: Mattias Engdegård @ 2019-04-23 14:34 UTC (permalink / raw)
To: Christopher Howard; +Cc: 35374
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)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-04-23 14:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-21 15:37 Calc; Div by 0 in solving system Christopher Howard
2019-04-22 6:23 ` Eli Zaretskii
2019-04-22 6:56 ` Mattias Engdegård
2019-04-23 14:34 ` bug#35374: " Mattias Engdegård
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.