Re: beginner’s question with Maxi ma
Robert Dodier <[email protected]>
| Newsgroups | gmane.comp.mathematics.maxima.general |
|---|---|
| Message-ID | <CAAsY_sRWueaWggKsn7CATU7QK8Ns6ATZs1v5LoJqoKDgpayMMw@mail.gmail.com> |
This is an interesting problem, and a good test of various things --
in particular, I was a little worried that the nested sum/product
expressions wouldn't turn out right, but I was at least able to get to
a result -- you can say whether it's correct.
I made the following changes, as shown by this diff:
diff -U 0 logophage-ellipsoid.mac-original logophage-ellipsoid.mac
--- logophage-ellipsoid.mac-original 2026-08-24 21:03:53.867928151 -0700
+++ logophage-ellipsoid.mac 2026-08-24 23:43:23.986661930 -0700
@@ -49 +49 @@
-∏(i, i_min, i_max, expr) ::= product(expr, i, i_min, i_max)$
+∏(i, i_min, i_max, expr) ::= buildq ([i, i_min, i_max, expr],
product(expr, i, i_min, i_max))$
@@ -51 +51 @@
-∑(i, i_min, i_max, expr) ::= sum(expr, i, i_min, i_max)$
+∑(i, i_min, i_max, expr) ::= buildq ([i, i_min, i_max, expr],
sum(expr, i, i_min, i_max))$
@@ -61,3 +61,2 @@
-declare("-", alphabetic)$
-semi-major_axis: 6378137 ` m;
-first_flattening: 1/bfloat(298.257223563)$
+semi_major_axis: 6378137 ` m;
+first_flattening: 1/(298.257223563b0)$
@@ -67 +66 @@
- The meridian arc length should be a bit less than semi-major_axis/2
+ The meridian arc length should be a bit less than semi_major_axis/2
@@ -84,7 +83,12 @@
-S[a, n, φ, j_maximum] := \
- a * (1 - n)² * (1 + n) \
- * ∑(j, 0, j_maximum, ∏(k, 1, j, (-n/(2*k) - n)²)) \
- * (φ + ∑(l, 1, 2*j, (sin(2*l*φ)/l)) \
- * ∏(m, 1, l, \
- (-n/(2*j + 2*(-1)^m*⌊m/2⌋) - n)^((-1)^m)));
-for j_max: 0 thru 5 do S[semi-major_axis, third_flattening, latitude, j_max];
+S[a, n, φ, j_maximum] :=
+ a * (1 - n)² * (1 + n)
+ * ∑(j, 0, j_maximum, ∏(k, 1, j, (-n/(2*k) - n))²
+ * (φ + ∑(l, 1, 2*j, (sin(2*l*φ)/l) * ∏(m, 1, l,
(-n/(2*j + 2*(-1)^m*⌊m/2⌋) - n)^((-1)^m)))));
+
+for j_max: 0 thru 5 do print (S[semi_major_axis, third_flattening,
latitude, j_max]);
+
+grind (S[a, n, φ, N]);
+
+texput (φ, "\\phi");
+
+tex (S[a, n, φ, N]);
At lines 49 and 51, use buildq to construct the sum/product expressions.
At line 61, cut out declare("-", alphabetic) -- I think that causes
confusion. I replaced the hyphen with an underscore. Also, write the
bigfloat constant with the exponent marker "b".
At lines 84ff, I cut out the backslash characters -- they're unneeded
here because the Maxima parser will collect input until it gets to a
dollar sign or semicolon.
Most importantly, I changed the placement of parentheses to conform to
what's intended in the linked-to paper. They have stuff that looks
like Sigma foo(k) bar(k) which, I assume, means Sigma(foo(k) bar(k)),
but in the code you posted, it is written as Sigma(foo(k)) bar(k).
I put in a print(...) in the for loop to display the result.
To inspect the expression S[a, n, phi, N], I put in grind(...) and
tex(...), and pasted the result of the latter into a TeX document and
inspected the equation, and from what I can tell it matches Eqn. 15 in
the paper.
Here's the output I get from the for loop:
5.00095113594463555b6 ` m
4.98494444065052407b6 ` m
4.98494437797803309b6 ` m
4.98494437797774351b6 ` m
4.98494437797774351b6 ` m
4.98494437797774351b6 ` m
Let me know if that does or does not look correct.
Hope this helps,
Robert
_______________________________________________
Maxima-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maxima-discuss