Comment #15 on issue 2308 by smi...@gmail.com: Should we rename primitive()? (and Expr.primitive() should call primitive())
http://code.google.com/p/sympy/issues/detail?id=2308

Also is this the lack of unity between the function and method that is the source of the ending lines of comment 9?

    h[11] >>> primitive(3/S(2)+3*x/4)
    (1, 3/2 + 3*x/4)
    h[12] >>> (2*x/3 + 4*y/9).primitive()
    (2/9, 2*y + 3*x)

Why don't we just stick with the terms_gcd idea. That pulls out all gcds...the primitive just pulls out Rational so how about rat_gcd:

    >>> eq = 3*x*y+3*x
    >>> terms_gcd(eq)
    3*x*(1 + y)
    >> rat_gcd(eq)
    3*(x + x*y)
    >> rat_gcd(S(3)/2 + 3*x)
    3*(1 + 2*x)/2
    >> rat_gcd(S(3)/2 + 15*x/4)
    3*(2 + 5*x)/4
    >> rat_gcd(3 + (3 + 6*x)*y)
    3*(1 + (1 + 2*x)*y)

I prefer the last expression to either of these:

    h[15] >>> primitive(3 + (3 + 6*x)*y)
    (3, 1 + y + 2*x*y)
    h[16] >>> (3 + (3 + 6*x)*y).primitive()
    (1, 3 + y*(3 + 6*x))

And don't expose primitive.

Finally, if we do this, rat_gcd could take the place of as_coeff_Mul. I wonder if there is a case where you wouldn't want the additional work of rat_gcd where you would be using as_coeff_Mul. e.g. in _pi_coeff if the coeff of pi were (2*x + 4*y)*pi then I would want the (2, (x + 2*y)) not the (1, 2*x + 4*y) that as_coeff_Mul gives.

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