|
From: tomasriker <tom...@us...> - 2026-06-04 14:02:00
|
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 258d3ea3119dc8e8905b36a55e5e43875dae112c (commit)
via bf68bd4f0202ef62779e85cfc250caa807414a4e (commit)
via 0e821f6dc137b0b8dfb535535a2f449a7443d03b (commit)
via e9b7facad93187e27f9bb47fbcd012f3a46db8c4 (commit)
via cdc692133acd87c1a7a7326e8cac2f3e4fe8a437 (commit)
via dfa0b6421abd41e5ae881a25b6e791d0fd53e758 (commit)
via 0fbcb131dac743749f4efa55ee018afad7a60e31 (commit)
via 6e1bf83117dd65e8bda4868286acbb5ffb89dfaf (commit)
from 1eed9421451526999df0e72682ba30d3add12ac4 (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 258d3ea3119dc8e8905b36a55e5e43875dae112c
Author: David Scherfgen <d.s...@go...>
Date: Thu Jun 4 15:56:57 2026 +0200
SIMPCHECK: first simplify (if necessary), then disrep special representations
SIMPCHECK's task is to return a simplified expression in general form.
However, it had a flaw in its logic: It first checked if the original, possibly
unsimplified expression was in special representation. If yes, it would convert
it to general form and return it.
For expressions in top-level general form, it would call SIMPLIFYA if required.
But it would not check if the result of that simplification was in general form.
When the simplification resulted in a special form, this could trigger an error:
:lisp (simplifya '((%sin) ((mplus) ((mrat simp) 1 . 1) ((mrat simp) 1 . 1))) nil)
Maxima encountered a Lisp error:
GREAT: internal error: unexpected MRAT argument
The %SIN simplifier uses SIMPCHECK on its argument. SIMPCHECK sees an MPLUS
expression, which is a general form. It simplifies it, but since its terms are
CRE forms (MRAT), the result is also a CRE. SIMPCHECK doesn't notice this,
and so the %SIN simplifier tries to work with a CRE. Since it rightfully
expected a general form, it causes an error while manipulating its argument.
diff --git a/src/simp.lisp b/src/simp.lisp
index 42726f8f8..78bc48e1b 100644
--- a/src/simp.lisp
+++ b/src/simp.lisp
@@ -105,12 +105,14 @@
(defun sratsimp (e) (simplifya ($ratsimp e) nil))
(defun simpcheck (e flag)
- (cond ((specrepp e) (specdisrep e))
- (flag e)
- (t (let (($%enumer $numer))
- ;; Switch $%enumer on, when $numer is TRUE to allow
- ;; simplification of $%e to its numerical value.
- (simplifya e nil)))))
+ (let ((e (if flag
+ e
+ ;; Switch $%enumer on, when $numer is TRUE to allow
+ ;; simplification of $%e to its numerical value.
+ (let (($%enumer $numer)) (simplifya e nil)))))
+ (if (specrepp e)
+ (specdisrep e)
+ e)))
(defun mratcheck (e) (if ($ratp e) (ratdisrep e) e))
commit bf68bd4f0202ef62779e85cfc250caa807414a4e
Author: David Scherfgen <d.s...@go...>
Date: Thu Jun 4 15:22:50 2026 +0200
SIMPMATRIX: simplify arguments (if necessary) before inspecting them
Bug demo:
scalarmatrixp : all$
:lisp (simplifya '((%matrix) ((mplus) ((mlist) 1) ((mlist) 1))) nil)
((%MATRIX SIMP) ((MLIST SIMP) 2))
... but it should be simply 2.
This is caused by SIMPMATRIX checking for the $SCALARMATRIXP case before making
sure that the arguments are simplified.
diff --git a/src/simp.lisp b/src/simp.lisp
index 8e8f5e88b..42726f8f8 100644
--- a/src/simp.lisp
+++ b/src/simp.lisp
@@ -2712,15 +2712,15 @@
(defun simpmatrix (x vestigial z)
(declare (ignore vestigial))
+ (let ((x (cons (car x) (simpmap (cdr x) z))))
(if (and (null (cddr x))
$scalarmatrixp
(or (eq $scalarmatrixp '$all) (member 'mult (cdar x)))
($listp (cadr x)) (cdadr x) (null (cddadr x)))
- (if z (cadadr x) (simplifya (cadadr x) nil))
- (let ((badp (dolist (row (cdr x)) (if (not ($listp row)) (return t))))
- (args (simpmap (cdr x) z)))
- (if (and args (not badp)) (matcheck args))
- (cons (if badp '(%matrix simp) '($matrix simp)) args))))
+ (cadadr x)
+ (let ((badp (dolist (row (cdr x)) (if (not ($listp row)) (return t)))))
+ (if (and (cdr x) (not badp)) (matcheck (cdr x)))
+ (cons (if badp '(%matrix simp) '($matrix simp)) (cdr x))))))
(defun %itopot (pot)
(if (fixnump pot)
commit 0e821f6dc137b0b8dfb535535a2f449a7443d03b
Author: David Scherfgen <d.s...@go...>
Date: Thu Jun 4 14:29:16 2026 +0200
Fix argument simplification in SIMP-EXP
Previously, SIMP-EXP would just return $E^ARG without calling the simplifier
on that expression, when the Z argument indicated that the argument is already
simplified.
(Sorry for probably introducing this bug and the one in SIMP-SQRT a couple of
years ago while hunting for simplifiers that ignore the Z argument.)
diff --git a/src/simp.lisp b/src/simp.lisp
index fef647bab..8e8f5e88b 100644
--- a/src/simp.lisp
+++ b/src/simp.lisp
@@ -1689,9 +1689,10 @@
(defprop %exp simp-exp operators)
(defun simp-exp (x y z)
+ (declare (ignore y))
(oneargcheck x)
- (setq y (list '(mexpt) '$%e (cadr x)))
- (if z y (simplifya y nil)))
+ (let ((arg (if z (cadr x) (simplifya (cadr x) nil))))
+ (simplifya (list '(mexpt) '$%e arg) t)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
commit e9b7facad93187e27f9bb47fbcd012f3a46db8c4
Author: David Scherfgen <d.s...@go...>
Date: Thu Jun 4 14:23:08 2026 +0200
In SIMPQUOT, don't compare bigfloat denominator to *BIGFLOATZERO*
If the denominator has a different precision than the current one,
it can be zero, but not equal to *BIGFLOATZERO*.
diff --git a/src/simp.lisp b/src/simp.lisp
index aa1e2e883..fef647bab 100644
--- a/src/simp.lisp
+++ b/src/simp.lisp
@@ -1295,7 +1295,7 @@
(/ num den))
((and (floatp num) (floatp den) #-ieee-floating-point (not (zerop den)))
(/ num den))
- ((and ($bfloatp num) ($bfloatp den) (not (equal *bigfloatzero* den)))
+ ((and ($bfloatp num) ($bfloatp den) (not (zerop (cadr den))))
;; Call BIGFLOATP to ensure that arguments have same precision.
;; Otherwise FPQUOTIENT could return a spurious value.
(bcons (fpquotient (cdr (bigfloatp num)) (cdr (bigfloatp den)))))
commit cdc692133acd87c1a7a7326e8cac2f3e4fe8a437
Author: David Scherfgen <d.s...@go...>
Date: Thu Jun 4 13:24:42 2026 +0200
Minor change: in SIMP-SQRT, let ARG be the simplified argument
diff --git a/src/simp.lisp b/src/simp.lisp
index 47fe3ebb7..aa1e2e883 100644
--- a/src/simp.lisp
+++ b/src/simp.lisp
@@ -1277,8 +1277,8 @@
(defun simp-sqrt (x y z)
(declare (ignore y))
(oneargcheck x)
- (let ((arg (cadr x)))
- (simplifya (list '(mexpt) (if z arg (simplifya arg nil)) '((rat simp) 1 2)) t)))
+ (let ((arg (if z (cadr x) (simplifya (cadr x) nil))))
+ (simplifya (list '(mexpt) arg '((rat simp) 1 2)) t)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
commit dfa0b6421abd41e5ae881a25b6e791d0fd53e758
Author: David Scherfgen <d.s...@go...>
Date: Thu Jun 4 13:23:19 2026 +0200
Optimize SIMPQUOT (simplifier of /) by pre-simplifying arguments
Previously, SIMPQUOT applied its numeric fast-paths (INTEGERP, NUMBERP, etc.)
to the raw, unsimplified arguments. As a result, expressions that dynamically
evaluated to numbers (e.g., (1+1)/2) bypassed native Lisp division and were
routed through the heavy algebraic simplifier via MTIMES and MEXPT.
Furthermore, the fallback branch redundantly simplified the -1 exponent.
This commit refactors the logic to pre-simplify the numerator and denominator
up front and using local variables, yielding the following benefits:
1. More expressions successfully hit the O(1) native Lisp numeric division
fast-paths.
2. The algebraic fallback branch now correctly passes the T flag to SIMPLIFYA
when constructing DEN^(-1) and NUM * DEN^(-1), avoiding redundant traversal
of the already-simplified arguments.
3. More readable code and size reduction of the compiled function.
Note: Because many floating-point divisions now correctly execute via native
hardware division (A / B) rather than reciprocal multiplication (A * B^(-1)),
this introduces a small IEEE 754 precision shift. This required an update to the
expected output in a test involving heavy float math.
diff --git a/share/stats/rtest_stats.mac b/share/stats/rtest_stats.mac
index 335c1f110..3a1de7cb1 100644
--- a/share/stats/rtest_stats.mac
+++ b/share/stats/rtest_stats.mac
@@ -113,42 +113,34 @@ inference_result("SHAPIRO - WILK TEST",
z:simple_linear_regression(matrix([125,140.7],[130,155.1],[135,160.3],[140,167.2],[145,169.8]),
'conflevel=0.99);
inference_result("SIMPLE LINEAR REGRESSION",
- [[model,1.405999999999985*x-31.18999999999804],
- [means,[135.0,158.62]],
- [variances,[50.0,106.9896000000008]],
- [correlation,.9611685255255155],
- [adc,.8984599126145604],
- [a_estimation,-31.18999999999804],
- [a_conf_int,[-215.2179151598772,152.8379151598812]],
- [b_estimation,1.405999999999985],
- [b_conf_int,[.04469633662525307,2.767303663374718]],
- [hypotheses,"H0: b = 0 ,H1: b # 0"],
- [statistic,6.032686683658114],
- [distribution,[student_t,3]],
- [p_value,.009131954735741799],
- [v_estimation,13.57966666666665],
- [v_conf_int,[3.173274925102496,568.0143894218797]],
- [cond_mean_conf_int,
- [1.405999999999985*x
- -21.52410081697646*(0.004*(135.0-x)^2+0.2)^0.5
- -31.18999999999804,
- 1.405999999999985*x
- +21.52410081697646*(0.004*(135.0-x)^2+0.2)^0.5
- -31.18999999999804]],
- [new_pred_conf_int,
- [1.405999999999985*x
- -21.52410081697646*(0.004*(135.0-x)^2+1.2)^0.5
- -31.18999999999804,
- 1.405999999999985*x
- +21.52410081697646*(0.004*(135.0-x)^2+1.2)^0.5
- -31.18999999999804]],
- [residuals,
- [[144.5600000000001,-3.860000000000156],
- [151.5900000000001,3.509999999999906],
- [158.62,1.680000000000007],
- [165.6499999999999,1.550000000000068],
- [172.6799999999999,-2.879999999999853]]]],
- [1,4,14,9,10,11,12,13]);
+ [[model,1.4059999999999855*x-31.189999999998037],
+ [means,[135.0,158.62]],
+ [variances,[50.0,106.98960000000079]],
+ [correlation,0.9611685255255155],
+ [adc,0.8984599126145604],
+ [a_estimation,-31.189999999998037],
+ [a_conf_int,[-215.21791515987724,152.83791515988116]],
+ [b_estimation,1.4059999999999855],
+ [b_conf_int,[0.044696336625253075,2.767303663374718]],
+ [hypotheses,"H0: b = 0 ,H1: b # 0"],
+ [statistic,6.032686683658114],
+ [distribution,[student_t,3]],
+ [p_value,0.009131954735741799],
+ [v_estimation,13.579666666666645],
+ [v_conf_int,[3.173274925102496,568.0143894218797]],
+ [cond_mean_conf_int,
+ [1.4059999999999855*x-21.524100816976457*sqrt(0.004*(135.0-x)^2+0.2)-31.189999999998037,
+ 1.4059999999999855*x+21.524100816976457*sqrt(0.004*(135.0-x)^2+0.2)-31.189999999998037]],
+ [new_pred_conf_int,
+ [1.4059999999999855*x-21.524100816976457*sqrt(0.004*(135.0-x)^2+1.2)-31.189999999998037,
+ 1.4059999999999855*x+21.524100816976457*sqrt(0.004*(135.0-x)^2+1.2)-31.189999999998037]],
+ [residuals,
+ [[144.56000000000014,-3.8600000000001558],
+ [151.5900000000001,3.5099999999999056],
+ [158.62,1.6800000000000068],
+ [165.64999999999992,1.5500000000000682],
+ [172.67999999999986,-2.8799999999998533]]]],
+ [1,4,14,9,10,11,12,13]);
diff --git a/src/simp.lisp b/src/simp.lisp
index 27536f5f4..47fe3ebb7 100644
--- a/src/simp.lisp
+++ b/src/simp.lisp
@@ -1285,20 +1285,25 @@
;;; Simplification of the "/" operator.
(defun simpquot (x y z)
+ (declare (ignore y))
(twoargcheck x)
- (cond ((and (integerp (cadr x)) (integerp (caddr x)) (not (zerop (caddr x))))
- (*red (cadr x) (caddr x)))
- ((and (numberp (cadr x)) (numberp (caddr x)) (not (zerop (caddr x))))
- (/ (cadr x) (caddr x)))
- ((and (floatp (cadr x)) (floatp (caddr x)) #-ieee-floating-point (not (zerop (caddr x))))
- (/ (cadr x) (caddr x)))
- ((and ($bfloatp (cadr x)) ($bfloatp (caddr x)) (not (equal *bigfloatzero* (caddr x))))
+ (let ((num (if z (cadr x) (simplifya (cadr x) nil)))
+ (den (if z (caddr x) (simplifya (caddr x) nil))))
+ (cond ((and (integerp num) (integerp den) (not (zerop den)))
+ (*red num den))
+ ((and (numberp num) (numberp den) (not (zerop den)))
+ (/ num den))
+ ((and (floatp num) (floatp den) #-ieee-floating-point (not (zerop den)))
+ (/ num den))
+ ((and ($bfloatp num) ($bfloatp den) (not (equal *bigfloatzero* den)))
;; Call BIGFLOATP to ensure that arguments have same precision.
;; Otherwise FPQUOTIENT could return a spurious value.
- (bcons (fpquotient (cdr (bigfloatp (cadr x))) (cdr (bigfloatp (caddr x))))))
- (t (setq y (if z (cadr x) (simplifya (cadr x) nil)))
- (setq x (simplifya (list '(mexpt) (caddr x) -1) z))
- (if (equal y 1) x (simplifya (list '(mtimes) y x) t)))))
+ (bcons (fpquotient (cdr (bigfloatp num)) (cdr (bigfloatp den)))))
+ (t
+ (let ((inv-den (simplifya (list '(mexpt) den -1) t)))
+ (if (equal num 1)
+ inv-den
+ (simplifya (list '(mtimes) num inv-den) t)))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
commit 0fbcb131dac743749f4efa55ee018afad7a60e31
Author: David Scherfgen <d.s...@go...>
Date: Thu Jun 4 12:35:19 2026 +0200
In new SIMP-SQRT, add (DECLARE (IGNORE Y)) to prevent warning
diff --git a/src/simp.lisp b/src/simp.lisp
index 468e7b2ed..27536f5f4 100644
--- a/src/simp.lisp
+++ b/src/simp.lisp
@@ -1275,6 +1275,7 @@
(defprop %sqrt simp-sqrt operators)
(defun simp-sqrt (x y z)
+ (declare (ignore y))
(oneargcheck x)
(let ((arg (cadr x)))
(simplifya (list '(mexpt) (if z arg (simplifya arg nil)) '((rat simp) 1 2)) t)))
commit 6e1bf83117dd65e8bda4868286acbb5ffb89dfaf
Author: David Scherfgen <d.s...@go...>
Date: Thu Jun 4 12:19:22 2026 +0200
Fix argument simplification in SIMP-SQRT
Previously, SIMP-SQRT would just return ARG^(1/2) without calling the simplifier
on that expression, when the Z argument indicated that the arguments are already
simplified:
(SIMPLIFYA '((%SQRT) ((MEXPT SIMP) $X 3)) T)
-> ((MEXPT) ((MEXPT SIMP) $X 3) ((RAT SIMP) 1 2)),
which is (x^3)^(1/2), not the correct result of x^(3/2)
diff --git a/src/simp.lisp b/src/simp.lisp
index 08355c9bf..468e7b2ed 100644
--- a/src/simp.lisp
+++ b/src/simp.lisp
@@ -1276,8 +1276,8 @@
(defun simp-sqrt (x y z)
(oneargcheck x)
- (setq y (list '(mexpt) (cadr x) '((rat simp) 1 2)))
- (if z y (simplifya y nil)))
+ (let ((arg (cadr x)))
+ (simplifya (list '(mexpt) (if z arg (simplifya arg nil)) '((rat simp) 1 2)) t)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-----------------------------------------------------------------------
Summary of changes:
share/stats/rtest_stats.mac | 64 ++++++++++++++++++++-------------------------
src/simp.lisp | 61 ++++++++++++++++++++++++------------------
2 files changed, 63 insertions(+), 62 deletions(-)
hooks/post-receive
--
Maxima CAS
|