[sage-support] Re: Symbolic algebra expansion of products of sums

2009-04-24 Thread Robert Dodier

ma...@mendelu.cz wrote:

 You can use commands orderless and ordergreat in Maxima to change the
 default behavior.

For the record, I recommend against that; it's not really the right
way to resolve this problem. I'll post another message with a
different resolution.

Robert Dodier

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sage-support] Re: Symbolic algebra expansion of products of sums

2009-04-24 Thread Robert Dodier

philabuster wrote:

 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);

Well, Sage punts to Maxima (for the moment, anyway) to compute
the expansion. The terms are computed in the order you want, but
displayed in the reverse order by default. I think powerdisp:true
will give the result you expected.

 What was the rationale?

The default ordering displays polynomials in order of decreasing
powers.

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

Well, you can get the addends via the args function in Maxima;
e.g. powerdisp:true; foo:expand(whatever); args(foo); = some list.
Likewise you can get the multiplicands of each term from args.
I don't know how to get that through Sage.

FWIW

Robert Dodier
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sage-support] Re: Symbolic algebra expansion of products of sums

2009-04-23 Thread William Stein

On Thu, Apr 23, 2009 at 6:44 AM, philabuster pollock.p...@gmail.com wrote:

 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')

The ordering of these terms is determined by maxima -- Sage doesn't
control that at all, just leaving them in the default order maxima
chooses.


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

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


And in Maxima:

wst...@geom:~/db/wuthrich-twist/data$ sage -maxima
Maxima 5.16.3 http://maxima.sourceforge.net
Using Lisp CLISP 2.47 (2008-10-23)
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) expand((a0+a1)*(b0+b1));
(%o1)a1 b1 + a0 b1 + a1 b0 + a0 b0



We are currently making a push to rewrite the symbolic calculus part
of Sage using the Ginac C++ library instead of Maxima. When that
happens, the above will be:

sage: var('a0 a1 b0 b1',ns=1)  # ns=1 sets a preview mode that
enables new symbolics
(a0, a1, b0, b1)
sage: expand((a0+a1)*(b0+b1))
a0*b0 + a0*b1 + a1*b0 + a1*b1

New symbolics also tend to be easier to work with term-by-term:

sage: v = expand((a0+a1)*(b0+b1))
sage: v[0]
a0*b0
sage: v[1]
a0*b1
sage: v[2]
a1*b0
sage: v[3]
a1*b1


 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*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*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

 




-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sage-support] Re: Symbolic algebra expansion of products of sums

2009-04-23 Thread ma...@mendelu.cz



On 23 Dub, 20:38, William Stein wst...@gmail.com wrote:
 On Thu, Apr 23, 2009 at 6:44 AM, philabuster pollock.p...@gmail.com wrote:

  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')

 The ordering of these terms is determined by maxima -- Sage doesn't
 control that at all, just leaving them in the default order maxima
 chooses.



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

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

 And in Maxima:

 wst...@geom:~/db/wuthrich-twist/data$ sage -maxima
 Maxima 5.16.3http://maxima.sourceforge.net
 Using Lisp CLISP 2.47 (2008-10-23)
 Distributed under the GNU Public License. See the file COPYING.
 Dedicated to the memory of William Schelter.
 The function bug_report() provides bug reporting information.
 (%i1) expand((a0+a1)*(b0+b1));
 (%o1)                    a1 b1 + a0 b1 + a1 b0 + a0 b0


You can use commands orderless and ordergreat in Maxima to change the
default behavior.

see 
http://maxima.sourceforge.net/docs/manual/en/maxima_6.html#Item_003a-ordergreat

Works in Maxima but not in Sage :-(- even if I use unorder first.


Robert


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---