expand() only expands the denominator when it gets the deep=True flag (because 
it is inside a Pow, namely, -1).  So I guess factor needs to know to use that 
flag when it gets frac=True.

The last item is a printing issue, and has nothing to do with factor or expand. 
 

Aaron Meurer
On May 27, 2010, at 3:49 PM, smichr wrote:

> Is the following behavior correct for factor?
> 
>>>> from sympy import *
>>>> var('x y')
>    (x, y)
>>>> eq = x*(1+2*y+y**2)+1+2*y+y**2
> 
> Here we show what happens with and without expand being set:
>>>> factor(eq,expand=0)
>    1 + 2*y + x*(1 + 2*y + y**2) + y**2
>>>> factor(eq,expand=1)
>    (1 + y)**2*(1 + x)
> 
> Now try the same when eq is in the denominator:
>>>> factor(1/eq,expand=0,frac=1)
>    1/((1 + x)*(1 + y)**2)
>>>> factor(1/eq,expand=1,frac=1)
>    1/((1 + x)*(1 + y)**2)
> 
> I would have expected that expand=0 with frac=1 would have given
>    1/(1 + 2*y + x*(1 + 2*y + y**2) + y**2)
> 
> Also why are the terms reversed in the numerator and denominator?
> 
>>>> factor(eq,expand=1)
>    (1 + y)**2*(1 + x)
>>>> factor(1/eq,expand=1,frac=1)
>    1/((1 + x)*(1 + y)**2)
> 
> (Notice that 1+x is changing positions.)
> 
> This behavior was also tested in polys9.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sympy" 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?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" 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?hl=en.

Reply via email to