From: Barton W. <wi...@un...> - 2024-10-29 11:13:33
|
* But in the case of addition, mathematical convention is that variable names from the end of the alphabet (u, v, w, x, y, z) are generally considered to be "variables", which variable names from the beginning of the alphabet (a, b, c, ...) are generally considered to be "parameters", so the displayed ordering is closer to mathematical convention. Some of Maxima's ordering choices are unconventional, for example (%i11) 2^k * k! * x^k; (%o11) 2^k*k!*x^k Sandwiching the factorial between 2^k and x^k is a non-standard term ordering, I think. The function great wears too many hats: great must be antisymmetric and transitive, and it determines the way sums and products are printed. The Maxima simplifier could leverage term ordering to boost efficiency more than it does. If Maxima exploited this more, that's annother hat for great to wear. Tweaking great to make expressions print closer to convention, for example, might ruin simplifcation or efficiency. Plus a tiny change to great can result in 100s of syntatic testsuite failures that are tedious and error-prone to sort out. I've experimented a bit on fixing the bug https://sourceforge.net/p/maxima/bugs/4383/. But I might be too pusillanimous to propose my putative fix. --Barton ________________________________ From: Eduardo Ochs <edu...@gm...> Sent: Monday, October 28, 2024 11:36 To: Stavros Macrakis <mac...@gm...> Cc: <max...@li...> <max...@li...> Subject: Re: [Maxima-discuss] ((MPLUS SIMP FACTORED) 2 3) -> 3 + 2 Caution: Non-NU Email Hi Stavros, This clarified many points that I found confusing. Many thanks!!! Cheers =) Eduardo On Sun, 27 Oct 2024 at 16:45, Stavros Macrakis <mac...@gm...<mailto:mac...@gm...>> wrote: On Sun, Oct 27, 2024 at 1:17 AM Eduardo Ochs <edu...@gm...<mailto:edu...@gm...>> wrote: In this thread from mid-august - https://sourceforge.net/p/maxima/mailman/message/58807287/<https://urldefense.com/v3/__https://sourceforge.net/p/maxima/mailman/message/58807287/__;!!PvXuogZ4sRB2p-tU!E3FvDOm3Mg-3IUyfoomrCUsi9HYGhqgdAqFmMPoBjlW0ivomXdfKUmDwmmvbee7ySfO4DQwmst9Xa5THwXM$> ...I learned that the result of factor(12345678) is not simplified because is starts with (MTIMES SIMP FACTORED). No, you missed the point. There are lots of simplified expressions which start with (mtimes simp factored): ?print(factor(x^2)) => ((MEXPT SIMP FACTORED) $X 2) In fact, the simp flag indicates that the expression is simplified. The result of factor(4) has that flag because it is declaring -- falsely -- that it is simplified in order to display as 2^2 and not to simplify back to 4. Maxima simplifies everything except if it is within a function definition (named or unnamed): f() := 2+2 => f() := 2+2 lambda([],2+2) => lambda([],2+2) It also generally respects the simp flag to mean that something shouldn't be re-simplified, unless you force re-simplification. The factored flag is irrelevant. 3 + 2 instead of the "2 + 3" that I was hoping for. Maxima's internal print function prints simplified sums (but not products) in the reverse order from the internal form. Why? Because the canonical (simplified) internal form puts constants first, then orders alphabetically (in the case of symbols): :lisp (simplifya '((mlist) ((mplus) x 4 a) ((mtimes) a 4 x)) nil) => ((MLIST SIMP) ((MPLUS SIMP) 4 A X) ((MTIMES SIMP) 4 A X)) But in the case of addition, mathematical convention is that variable names from the end of the alphabet (u, v, w, x, y, z) are generally considered to be "variables", which variable names from the beginning of the alphabet (a, b, c, ...) are generally considered to be "parameters", so the displayed ordering is closer to mathematical convention. This is of course a crude heuristic, but it produces pretty good results: :lisp (displa '((mlist) ((mplus) 4 a x) ((mplus) 4 x a) ((mplus simp) a x) ((mplus simp) x a))) => [4+a+x,4+x+a,x+a,a+x] :lisp (displa '((mlist) ((mtimes) 4 a x) ((mtimes) 4 x a) ((mtimes simp) a x) ((mtimes simp) x a))) => [4*a*x,4*x*a,a*x,x*a] In particular, polynomials look right: print(x^2+a*x-b); => x^2+a*x-b even though the internal form is in a different order: ?print(x^2+a*x-b); => ((MPLUS SIMP) ((MTIMES SIMP) -1 $B) ((MTIMES SIMP) $A $X) ((MEXPT SIMP) $X 2)) Hope this helps. -s |