Hi,

I was wondering why Sage expands products of sums in an unexpected
order:

var('a0,a1,b0,b1,b2,c0,c1,c2,c3,d0,d1,d2,d3,d4')

expand((a0+a1)*(b0+b1))

a1*b1 + a0*b1 + a1*b0 + a0*b0

expand((a0+a1)*(b0+b1+b2)*(c0+c1+c2+c3)*(d0+d1+d2+d3+d4))

a1*b2*c3*d4 + a0*b2*c3*d4 + a1*b1*c3*d4 + a0*b1*c3*d4 + a1*b0*c3*d4 +
a0*b0*c3*d4 + a1*b2*c2*d4 + a0*b2*c2*d4 + a1*b1*c2*d4 + a0*b1*c2*d4 +
a1*b0*c2*d4 + a0*b0*c2*d4 + a1*b2*c1*d4 + a0*b2*c1*d4 + a1*b1*c1*d4 +
a0*b1*c1*d4 + a1*b0*c1*d4 + a0*b0*c1*d4 + a1*b2*c0*d4 + a0*b2*c0*d4 +
a1*b1*c0*d4 + a0*b1*c0*d4 + a1*b0*c0*d4 + a0*b0*c0*d4 + a1*b2*c3*d3 +
a0*b2*c3*d3 + a1*b1*c3*d3 + a0*b1*c3*d3 + a1*b0*c3*d3 + a0*b0*c3*d3 +
a1*b2*c2*d3 + a0*b2*c2*d3 + a1*b1*c2*d3 + a0*b1*c2*d3 + a1*b0*c2*d3 +
a0*b0*c2*d3 + a1*b2*c1*d3 + a0*b2*c1*d3 + a1*b1*c1*d3 + a0*b1*c1*d3 +
a1*b0*c1*d3 + a0*b0*c1*d3 + a1*b2*c0*d3 + a0*b2*c0*d3 + a1*b1*c0*d3 +
a0*b1*c0*d3 + a1*b0*c0*d3 + a0*b0*c0*d3 + a1*b2*c3*d2 + a0*b2*c3*d2 +
a1*b1*c3*d2 + a0*b1*c3*d2 + a1*b0*c3*d2 + a0*b0*c3*d2 + a1*b2*c2*d2 +
a0*b2*c2*d2 + a1*b1*c2*d2 + a0*b1*c2*d2 + a1*b0*c2*d2 + a0*b0*c2*d2 +
a1*b2*c1*d2 + a0*b2*c1*d2 + a1*b1*c1*d2 + a0*b1*c1*d2 + a1*b0*c1*d2 +
a0*b0*c1*d2 + a1*b2*c0*d2 + a0*b2*c0*d2 + a1*b1*c0*d2 + a0*b1*c0*d2 +
a1*b0*c0*d2 + a0*b0*c0*d2 + a1*b2*c3*d1 + a0*b2*c3*d1 + a1*b1*c3*d1 +
a0*b1*c3*d1 + a1*b0*c3*d1 + a0*b0*c3*d1 + a1*b2*c2*d1 + a0*b2*c2*d1 +
a1*b1*c2*d1 + a0*b1*c2*d1 + a1*b0*c2*d1 + a0*b0*c2*d1 + a1*b2*c1*d1 +
a0*b2*c1*d1 + a1*b1*c1*d1 + a0*b1*c1*d1 + a1*b0*c1*d1 + a0*b0*c1*d1 +
a1*b2*c0*d1 + a0*b2*c0*d1 + a1*b1*c0*d1 + a0*b1*c0*d1 + a1*b0*c0*d1 +
a0*b0*c0*d1 + a1*b2*c3*d0 + a0*b2*c3*d0 + a1*b1*c3*d0 + a0*b1*c3*d0 +
a1*b0*c3*d0 + a0*b0*c3*d0 + a1*b2*c2*d0 + a0*b2*c2*d0 + a1*b1*c2*d0 +
a0*b1*c2*d0 + a1*b0*c2*d0 + a0*b0*c2*d0 + a1*b2*c1*d0 + a0*b2*c1*d0 +
a1*b1*c1*d0 + a0*b1*c1*d0 + a1*b0*c1*d0 + a0*b0*c1*d0 + a1*b2*c0*d0 +
a0*b2*c0*d0 + a1*b1*c0*d0 + a0*b1*c0*d0 + a1*b0*c0*d0 + a0*b0*c0*d0

This ordering makes it extremely difficult to do index association
from the j-th term of the expansion back into constituent indices of
each sum (i0,i1,i2,i3);   for example, (0,1,2,3) corresponds to
a0*b1*c2*d3 and is associated with j=33.  A more intuitive left to
right product expansion would have been simpler and more useful when
working with these expansions.  Also, other math packages expand these
products in a different order than what's seen in Sage.  In the
simpler case (a0+a1)*(b0+b1) I would expect the accepted FOIL ordering
of terms.  What was the rationale?

Given j, how would you calculate (i0,i1,i2,i3,...,ik) considering
Sage's expansion order?

Your help is appreciated,

philabuster

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to