Updates:
Labels: Polynomial Simplify
Comment #2 on issue 3408 by [email protected]: problem with method
simplify()
http://code.google.com/p/sympy/issues/detail?id=3408
If anyone's curious, I bisected it to
commit e6f98b2e00906717d8f879196fffbe33432d8f5a
Author: Chris Smith <[email protected]>
Date: Tue Nov 15 12:35:55 2011 +0545
2607: more efficient implementation of Add.as_numer_denom
By collecting denominators and processing Integer denominators,
as_numer_denom is more efficient. When denominators are collected
this produces less terms to process; when Integers are handled
separately, their denominator can be computed very quickly with
integer arithmetic.
Because of collection of denominators, there will be a slight
bit of nesting that will occur:
>>> (1/x+a/x+b/y).as_numer_denom()
(b*x + y*(a + 1), x*y)
Processing Integer denominators will not result in nesting as
a result of the automatic distribution of Rationals on Adds:
>>> (a/1+b/2+c/3+d/4).as_numer_denom()
(12*a + 6*b + 4*c + 3*d, 12)
(Note, too, that the numerical gcd of numerator and denominator
has been removed so (24*a + 12*b + 8*c + 6*d, 24) is not obtained.
There are other possibilities for improvement: if one doesn't care
about producing a nested numerator, a binary approach can be
employed
where pairs of terms are processed. If a mostly cancelled expression
is desired, a symbolic lcm method (Vladimir's approach) can be used.
One of the dilemmas is to know when to use one method over another;
and testing to see which method to use can eliminate the savings
that
a technique might have over another. Testing for common denominators
and integers are a fairly easy preprocessing step that can lead to
large improvements over a more naive method.
This work was a collaborative effort of Aaron Meurer, Vladimir
Peric,
and Christopher Smith.
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.