How to display (a-b) and not -(b-a)...



Patrick Gelin:
> > I simplified an expression and maxima show the result as -(b-a). I would
> > like to display (a-b).
Larry Prevett:
>  some examples that simplify with ratsimp. powerdisp settings may differ,
>  but ratsimp works in both cases.

>  (%i3) factor(a-b);
>  (%o3)                              - (b - a)

"Factor" is intentionally not providing a fully simplified answer.
So, for example, factor(6) => 2*3, which is obviously not simplified.

Patrick, was your original expression the result of "factor"?

Ratsimp will of course simplify cases like this, but so will %o3+0,
%o3*1, or expand(%o3,0,0) (which resimplifies all the way down).

The advantage to those other approaches is that they don't expand out
the expression.  On the other hand, I don't know any simple way to
take

       factor(x^2-y^2) =>   - (y - x) (y + x)

You can use substinpart(multthru(piece),expr,[1,2]) in this case, but....

          -s