|
From: tomasriker <tom...@us...> - 2026-05-27 20:14:12
|
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 caa920e729bb170e62c04b7a96fa714aabe92715 (commit)
from 6c7372506b5eb62bf2295b27b8b9b2ec1933a1d0 (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 caa920e729bb170e62c04b7a96fa714aabe92715
Author: David Scherfgen <d.s...@go...>
Date: Wed May 27 22:12:35 2026 +0200
Make FACTOR check that minimal polynomial is irreducible
factor(a^2*g+a*g-a^2, g^3-1) -> division by zero, because g^3-1 = (g-1)*(g^2+g+1).
This fixes bug #4658.
diff --git a/src/rat3e.lisp b/src/rat3e.lisp
index bf8b5f080..827d10c48 100644
--- a/src/rat3e.lisp
+++ b/src/rat3e.lisp
@@ -266,8 +266,14 @@
(setq minpoly* (cadr (ratrep* *alpha*)))
(when (or (pcoefp minpoly*)
(not (univar (cdr minpoly*)))
- (< (cadr minpoly*) 2))
- (merror (intl:gettext "factor: second argument must be a nonlinear, univariate polynomial; found: ~M") *alpha*))
+ (< (cadr minpoly*) 2)
+ ;; Detect a reducible polynomial: factor MINPOLY* with GAUSS = NIL,
+ ;; skip over the content and see if there is more than one factor
+ ;; or the single factor has a multiplicity > 1.
+ (let* ((pfac (let (gauss) (pfactor minpoly*)))
+ (facs (if (pcoefp (car pfac)) (cddr pfac) pfac)))
+ (or (cddr facs) (> (cadr facs) 1))))
+ (merror (intl:gettext "factor: second argument must be an irreducible, nonlinear, univariate polynomial; found: ~M") *alpha*))
(setq *alpha* (pdis (list (car minpoly*) 1 1))
mm* (cadr minpoly*))
(unless (equal (caddr minpoly*) 1)
diff --git a/tests/rtest16.mac b/tests/rtest16.mac
index 3a2c49e6e..0d9c766d3 100644
--- a/tests/rtest16.mac
+++ b/tests/rtest16.mac
@@ -3282,6 +3282,14 @@ expand((1 + sqrt(2)) * 2^(15/4) + (1 - sqrt(2)) * 2^(5/4));
(3^x + 3^(x + 1/2)) + 2*3^x;
3^(x+1)+3^(x+1/2);
+/* Bug #4658: "factor should check that second argument is irreducible" */
+
+errcatch(factor(a^2*g+a*g-a^2, g^3-1));
+[];
+
+factor(a^2*g+a*g-a^2, second(factor(g^3-1)));
+(a*(-g+3*a+1)*(g-1))/3;
+
kill(x);
done$
-----------------------------------------------------------------------
Summary of changes:
src/rat3e.lisp | 10 ++++++++--
tests/rtest16.mac | 8 ++++++++
2 files changed, 16 insertions(+), 2 deletions(-)
hooks/post-receive
--
Maxima CAS
|