|
From: <ap...@us...> - 2026-05-17 00:34:33
|
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 d1b9106c0a4748ea3e4c7c5eb2b1544b0726a315 (commit)
via 6da388d4f866e438807da88f8e418edaa19d043d (commit)
from e730032acd0538fbec341619a9c43c188ba0cc3c (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 d1b9106c0a4748ea3e4c7c5eb2b1544b0726a315
Author: Robert Dodier <rob...@so...>
Date: Sat May 16 17:33:41 2026 -0700
Package ezunits: test script rtest_ezunits_mroz_examples.mac based on examples posted to mailing list,
thanks to Mateusz Mroz for posting the original examples.
diff --git a/share/ezunits/rtest_ezunits_mroz_examples.mac b/share/ezunits/rtest_ezunits_mroz_examples.mac
new file mode 100644
index 000000000..894958284
--- /dev/null
+++ b/share/ezunits/rtest_ezunits_mroz_examples.mac
@@ -0,0 +1,52 @@
+/* derived from maxima-discuss circa 2026-05-07, subject: "Simplifying Units in Ezunits Package" */
+
+(C_2: 10 `nF,
+ C_1: 100 `pF,
+ R_1: 10 `kOhm,
+ e1a: 1/(R_1 * (C_1 + C_2)),
+ e1b: all_units_fundamental (e1a),
+ e1c: e1b `` Hz,
+ approximately_equal (x, y, d) := units(x) = units(y) and is (abs (qty(x) - qty(y)) <= d),
+ approximately_equal (e1c, 9900.9901 ` Hz, 0.00005));
+true;
+
+(H(s, C, R_1, R_2) := (1/(s * C)) / (R_1 + R_2 + 1/(s * C)),
+ e2a: H(s, 18`nF, 1`kOhm, 1`kOhm),
+ e2b: subst (s = 2*%pi*%i*50 ` Hz, e2a),
+ f_1: all_units_fundamental (e2b),
+ u: fundamental_units (f_1),
+ [ u, e2c: f_1 `` u ]);
+[ 1, -((5000000*%i)/(9*(2000-(5000000*%i)/(9*%pi))*%pi)) ];
+
+(e3a: diff(H(s, x, R, R), x, 1),
+ e3b: subst(x = C, %%),
+ e3c: subst(%i*ω, s, %%),
+ e3d: f_2: subst([R = 1`kOhm, C = 1`nF, ω = 2*%pi*10`Hz], %%),
+ e3e: all_units_fundamental (%%),
+ e3f: ratsimp (e3e),
+ e3g: dimensionally (rectform (e3f)), /* FWIW dimensionally(...) can't contain %% since it's a macro that expands into block(...) */
+ e3h: float (%%),
+ e3i: %% `` 1/F);
+(-(125663.70019038678*%i)-31.582733086016873) ` 1/F;
+
+(e4a: func: hstep(1000 ` Hz * 1 ` ms - 1),
+ e4b: all_units_fundamental (func));
+1/2;
+
+(e5a: subst (s = 2*%pi*%i*50 ` Hz, (1/(s*C_2))/(R_1 + 1/(s*C_2))),
+ e5b: all_units_fundamental (e5a),
+ e5c: dimensionally (cabs (e5b)),
+ e5d: float (e5c),
+ e5e: approximately_equal (e5d, 0.9995, 0.00005));
+true;
+
+(e6a: (1/(s*x))/(R_1 + 1/(s*x)),
+ e6b: diff (e6a, x),
+ e6c: subst ([s = 2*%pi*%i*50 ` Hz, x = C_2], e6b),
+ e6d: all_units_fundamental (e6c),
+ e6e: dimensionally (cabs (e6d)),
+ e6f: float (e6e),
+ e6g: e6f `` 1/nF,
+ e6h: approximately_equal (e6g, 0.0031 ` (1/nF), 0.00005));
+true;
+
commit 6da388d4f866e438807da88f8e418edaa19d043d
Author: Robert Dodier <rob...@so...>
Date: Sat May 16 17:30:59 2026 -0700
Package ezunits: (1) treat dimensions applied to "+" and "-" expressions differently than "*" and "/".
(2) New function all_units_fundamental to convert all units in an expression to fundamental units.
diff --git a/share/ezunits/ezunits_functions.mac b/share/ezunits/ezunits_functions.mac
index 34c9abd01..bf99a637a 100644
--- a/share/ezunits/ezunits_functions.mac
+++ b/share/ezunits/ezunits_functions.mac
@@ -464,7 +464,9 @@ matchdeclare
ff%, lambda ([e%], symbolp (e%)),
gg%, lambda ([e%], not atom (e%) and op (e%) = "`"),
hh%, lambda ([e%], not atom (e%) and op (e%) = "^"),
- ii%, lambda ([e%], not mapatom (e%) and member (op (e%), ["+", "-", "*", "/"])));
+ ii%, lambda ([e%], not mapatom (e%) and member (op (e%), ["*", "/"])),
+ jj%, lambda ([e%], not mapatom (e%) and op (e%) = "+"),
+ kk%, lambda ([e%], not mapatom (e%) and op (e%) = "-"));
simp : false;
defrule (raa, 'dimensions (aa%), 1);
@@ -483,7 +485,9 @@ defrule (rgg, 'dimensions (gg%), (constvalue (first (gg%)), if unitp (%%) then d
matchdeclare (aa%, all, bb%, constantp_not1);
defrule (rhh, 'dimensions (aa%^bb%), dimensions (aa%) ^ bb%);
defrule (rii, 'dimensions (ii%), map (dimensions, ii%));
-/* ??? defrule (rjj, 'dimensions (sqrt (aa%)), sqrt (dimensions (aa%))); */
+defrule (rjj, 'dimensions (jj%), apply ("+", unique (map (dimensions, args (jj%)))));
+defrule (rkk, 'dimensions (kk%), apply ("+", unique (map (dimensions, args (kk%)))));
+/* ??? defrule (rfoo, 'dimensions (sqrt (aa%)), sqrt (dimensions (aa%))); */
simp : true;
dimensions (expr) :=
@@ -497,7 +501,7 @@ dimensions (expr) :=
dimensions1 (expr) :=
if not atom (expr) and (setp (expr) or listp (expr) or matrixp (expr) or op (expr) = "=")
then map (dimensions, expr)
- else apply (apply1, ['dimensions (expr), raa, rbb, rcc, rdd, ree, ree1, rff, rgg, rhh, rii]);
+ else apply (apply1, ['dimensions (expr), raa, rbb, rcc, rdd, ree, ree1, rff, rgg, rhh, rii, rjj, rkk]);
/* Adapted from dimensions_as_list in share/physics/dimension.mac.
* Thanks to Barton Willis.
@@ -529,6 +533,10 @@ fundamental_units ([L]) :=
then apply ("*", map ("^", fundamental_units (), d))
else 'fundamental_units (L [1]));
+all_units_fundamental (e) := applyb1 (e, fundamental_units_rule);
+
+defrule (fundamental_units_rule, uu%, uu% `` fundamental_units (uu%));
+
/* Adapted from dimensionless in share/physics/dimension.mac.
* Thanks to Barton Willis.
*/
-----------------------------------------------------------------------
Summary of changes:
share/ezunits/ezunits_functions.mac | 14 ++++++--
share/ezunits/rtest_ezunits_mroz_examples.mac | 52 +++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 3 deletions(-)
create mode 100644 share/ezunits/rtest_ezunits_mroz_examples.mac
hooks/post-receive
--
Maxima CAS
|