Hi,

On Thu, May 27, 2010 at 03:55:25PM -0600, Aaron S. Meurer wrote:
> 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.
> 

Good that this went out, because I'm reworking code responsible for
processing flags|options in polys. In the new approach, there will
be a separate module for managing options which will allow for unified
configuration of different aspects of polys. I'm also working on context
managers which will save a lot of typing, e.g.:

In [1]: c = ctx.gaussian(True)

In [2]: factor(x**2 + 4)
Out[2]:
     2
4 + x

In [3]: c.factor(x**2 + 4)
Out[3]: (x + 2⋅ⅈ)⋅(x - 2⋅ⅈ)

In [4]: with ctx.gaussian(True):
   ...:     factor(x**2 + 4)
   ...:
Out[4]: (x + 2⋅ⅈ)⋅(x - 2⋅ⅈ)

The same will apply to other options (in particular to frac and expand).

So, if there are more thoughts about this issue, lets share them, so that
I have more input for the new developments.

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

-- 
Mateusz

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to