a+b vs. b+a



On 10/5/07, Stavros Macrakis <macrakis at alum.mit.edu> wrote:

> On 10/5/07, van Nek <van.nek at arcor.de> wrote:
> > Is it possible to have a+b => a+b as the default (without calling ordergreat)?

Yes. The ordering of terms for display of a literal sum is
controlled by the global variable powerdisp.

(%i2) powerdisp;
(%o2) false
(%i3) c + x + 1 + b + a + x^3 + x^2;
(%o3) x^3+x^2+x+c+b+a+1
(%i4) powerdisp : true;
(%o4) true
(%i5) c + x + 1 + b + a + x^3 + x^2;
(%o5) 1+a+b+c+x+x^2+x^3

We could consider making powerdisp = true the default.
Or just cut out the stuff in FORM-MPLUS which reverses the
order of the arguments from the order in which they're stored.

> I believe that the motivation for the current ordering (reverse
> alphabetical in sums, alphabetical in products) is that letters at the
> end of the alphabet (x,y,z) often represent variables, while letters
> at the beginning of the alphabet (a,b,c) often represent constants or
> parameters.  Users probably want to see
>
>            c*x^3 + b*x + a
>
> rather than
>
>           a + x*b + x^3*c

Better still is a + b*x + c*x^3, which is achieved by powerdisp : true
or equivalent modification of FORM-MPLUS.

> We could of course define pretty much any order we wanted.  For
> example, we could decide on the order w,x,y,z / p,q,r,s,...u,v /
> a,b,...o.

I don't think we need to invent a new ordering policy.
We just need to get the display code to behave differently.

FWIW

Robert