Hi, On Sat, Aug 14, 2010 at 04:26:46AM -0700, smichr wrote: > Can anyone tell me how to get (1+x+y+c*x+c*x*y)/(x+x*y) to give me > > c + (1+x+y)/(x+x*y) > > >>> Poly(1 + x + y + c*x + c*x*y).div(Poly(x+x*y)) > (Poly(0, x, y, c, domain='ZZ'), Poly(x*y*c + x*c + x + y + 1, x, y, c, > domain='ZZ')) >
In [1]: var('c') Out[1]: c In [2]: (1+x+y+c*x+c*x*y)/(x+x*y) Out[2]: 1 + x + y + c⋅x + c⋅x⋅y ─────────────────────── x + x⋅y If you want things to work out of the box then use ratsimp() from polys11 branch: In [3]: ratsimp(_) Out[3]: 1 + x + y c + ───────── x + x⋅y However, if you would like to use polynomial division then: In [4]: p, q = _2.as_numer_denom() In [5]: p Out[5]: 1 + x + y + c⋅x + c⋅x⋅y In [6]: q Out[6]: x + x⋅y In [7]: div(p, q, wrt=x) Out[7]: (0, 1 + x + y + c⋅x + c⋅x⋅y) In [8]: div(p, q, wrt=y) Out[8]: (0, 1 + x + y + c⋅x + c⋅x⋅y) In [9]: div(p, q, wrt=c) Out[9]: (c, 1 + x + y) This happens because div() uses recursive division algorithm, so, depending on the order of variables, the results may differ (as showed in [7]-[9]). There exists also another, generalized division algorithm that is implemented in reduced(): In [10]: reduced(p, [q]) Out[10]: ([c], 1 + x + y) (which is, by the way, used in new ratsimp()). > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To post to this group, send email to sy...@googlegroups.com. > To unsubscribe from this group, send email to > sympy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sympy?hl=en. > -- Mateusz
signature.asc
Description: This is a digitally signed message part