Le dimanche 09 août 2009 à 01:31 -0600, Ondrej Certik a écrit :
> On Sun, Aug 9, 2009 at 1:25 AM, Luke<hazelnu...@gmail.com> wrote:
> > Attached is a patch that allows expand to handle negative integer
> > powers.  This effectively allows expressions like:
> > expr = (x+y)**(-2)
> > to be expanded by calling
> > expr.expand()
> 
> Thanks, it's in.
> 
> Ondrej

I have a few comments:
* The call to expand() is slow and unnecessary. At this stage, all
that's needed is to call _eval_expand_multinomial(deep=False). So
instead of:
+            return 1 / Pow(base, -exp.p).expand(deep=deep, **hints)
we should have:
+            return 1 / Pow(base,
-exp.p)._eval_expand_multinomial(deep=False)

* This line suggests that it would be helpful to create an 'inverse'
property - less work is needed to create this inverse than for a generic
Pow instance.
* There should be more tests for negative exponents, basically
duplicating all existing tests with positive exponents
*I don't see the point of the third test: it's only testing that (x
+y)**2*(x+y)**-4 == (x+y)**-2 which isn't related to expand.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy-patches" group.
To post to this group, send email to sympy-patches@googlegroups.com
To unsubscribe from this group, send email to 
sympy-patches+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sympy-patches?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to