Kosta,
In general, it is hard to force Maxima to organize things in a certain
way, but if you're willing to program in simp:false mode, you can
organize them in arbitrary ways, e.g.:
reorder_product(ex):= block([simp:false],
make_simplified(reorder_product1(ex)))$
reorder_product1(ex):=
if mapatom(ex) then ex
elseif op(ex)="*"
then apply("*",
sort(args(ex),
lambda([a,b],
if subvarp(a) and subvarp(b) then orderlessp(a,b)
elseif subvarp(a) then false
elseif subvarp(b) then true
else orderlessp(a,b))))
else map(reorder_product,ex)$
make_simplified(ex):=
if atom(ex) then ex
else ?cons(?list(?caar(ex),?simp),?cdr(ex))$
The results of reorder_product will display the way you specify, but
should be resimplified before you perform any algebraic calculations
on them using expand(expr,0,0).
That said, I find it weird that Maxima orders
r[1]*r[2]*(a[2]+a[1])
as
r[1]*(a[2]+a[1])*r[2]
This should be fixable internally, but I haven't looked into it.
-s
On Jan 17, 2008 10:44 AM, Kostas Oikonomou <ko at research.att.com> wrote:
> (a1+a2+a3)r1r2r3 + (a1+a2+a4)r1r2r4 + ...
> Maybe this is not possible?