|
From: tomasriker <tom...@us...> - 2026-05-27 20:50:08
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Maxima CAS".
The branch, master has been updated
via c295b89a4305bda4012e07943084f14d1d3e312a (commit)
from caa920e729bb170e62c04b7a96fa714aabe92715 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit c295b89a4305bda4012e07943084f14d1d3e312a
Author: David Scherfgen <d.s...@go...>
Date: Wed May 27 22:49:49 2026 +0200
Fix GCSQR (wrong formula for squaring complex number, called by GCFACTOR)
The function GCSQR, which computes the square of a complex number R + %i * I,
wrongly computed the real part of the result as R^2 + I^2, when it should be
R^2 - I^2. This bug broke GCFACTOR for some numbers.
This fixes bug #4623.
diff --git a/src/numth.lisp b/src/numth.lisp
index 70e351319..61fba4e22 100644
--- a/src/numth.lisp
+++ b/src/numth.lisp
@@ -277,7 +277,7 @@
(let ((r (first a))
(i (second a)))
(declare (integer r i))
- (list (+ (* r r) (* i i)) (ash (* r i) 1))))
+ (list (- (* r r) (* i i)) (ash (* r i) 1))))
(defun gctime1 (a b)
(gctimes (car a) (cadr a) (car b) (cadr b)))
diff --git a/tests/rtest_numth.mac b/tests/rtest_numth.mac
index 06c65ee0a..671a6fd6c 100644
--- a/tests/rtest_numth.mac
+++ b/tests/rtest_numth.mac
@@ -809,3 +809,16 @@ gcfactor (%i / 2);
sublist (%%, lambda ([x], x # true)));
[];
*/
+
+/* Bug #4623: "gcfactor(4), expand(%%) => -4" */
+
+create_list(is(a + %i * b = expand(gcfactor(a + %i * b))), a, makelist(i, i, -4, 4), b, makelist(i, i, -4, 4));
+[true, true, true, true, true, true, true, true, true,
+ true, true, true, true, true, true, true, true, true,
+ true, true, true, true, true, true, true, true, true,
+ true, true, true, true, true, true, true, true, true,
+ true, true, true, true, true, true, true, true, true,
+ true, true, true, true, true, true, true, true, true,
+ true, true, true, true, true, true, true, true, true,
+ true, true, true, true, true, true, true, true, true,
+ true, true, true, true, true, true, true, true, true];
-----------------------------------------------------------------------
Summary of changes:
src/numth.lisp | 2 +-
tests/rtest_numth.mac | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
hooks/post-receive
--
Maxima CAS
|