Search code examples
equationmaxima

Terms of an equation in different order


I'm using wxMaxima 15.08.1 (win 10) and when I input this equation

/* [wxMaxima: input   start ] */a*x+b*y+c*z=0;

I get this:

/* [wxMaxima: input   end   ] */cz+by+ax=0

Why does it change the term's position of the expression? It seems like in descending order somehow.

Then, if I type another equation giving all coefficients the same unknown, maxima outputs it just right.

/* [wxMaxima: input   start ] */a*x^2+b*x+c=0;

/* [wxMaxima: input   end   ] */ax^2+bx+x=0

Solution

  • Maxima has its own idea of the canonical ordering of terms in "+" and "*" expressions. The canonical ordering is expressed by the function ordergreatp (equivalently orderlessp) which tells if one term comes after (respectively, before) another term. If you apply sort to a list of terms, they are sorted, by default, according to the canonical order.

    By default, "+" terms are displayed in reverse order (reverse of the canonical order). When the global variable powerdisp is true, "+" terms are displayed in the canonical order. You can decide whether one order or the other works better for you.

    (%i2) powerdisp;
    (%o2)                         false
    (%i3) a*x + b*y + c*z;
    (%o3)                    c z + b y + a x
    (%i4) a*x^2 + b*x + c;
                                2
    (%o4)                    a x  + b x + c
    
    (%i7) powerdisp : true $
    (%i8) a*x + b*y + c*z;
    (%o8)                    a x + b y + c z
    (%i9) a*x^2 + b*x + c;
                                          2
    (%o9)                    c + b x + a x