Mathics
Mathics copied to clipboard
Normal canonical output of arithmetic expressions, e.g. -Number + expression -> expression - number
When we show expressions that aren't in FullForm
, e.g. StandardForm
, we are not doing a good job in converting from to a more normal output.
x - 1
comes out -1 + x
which is weird unless FullForm
is indicated.
And more generally: x ^ 2 + 2 x + 1
comes out 1 + 2 x + x ^2
.
What is going on in the above is that parsing canonicalized the parsed expression in the opposite order. And in WL it happens that way too. But WL also canonicalizes in the more normal standard form of expression on formatting for output.
So we should too.
Related to https://trac.sagemath.org/ticket/31778
https://github.com/mathics/Mathics/tree/negate-constant-at-end starts to address this.
It occurs to me that a better fix may be just to _reverse) the order in System Plus
because when going to FullForm, expressions are canonicallized exactly in the opposite order in whiuch it normally appears. That is:
x^2 - 2x - 3
appears in FullForm as -3-2 x+x^2
.