1 Jun 04:08 2011

### Re: why does terms_gcd clear the denominators of an expression

Hi,

On 27 May 2011 21:08, Chris Smith <smichr-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

Aaron S. Meurer wrote:The quote I posted takes the approach that the divisor is the number that divides both and still gives an integer, so our gcd and current primitive method (soon to be changed) is consistent with that notion.

>> Shouldn't it return 1?

>>> R=Rational;gcd(R(2,3),R(4,9))

2/9

The primitive function in polys doesn't advertise (and doesn't do) a removal of the gcd...it should clearly state that, I think, or be changed to do so. I will have to defer to those that know what primitive is suppose to mean.

For long time I wasn't convinced what gcd(p/q, P/Q) should return and the safest was to return 1. Some libraries, e.g. gmpy, don't define gcd() of rationals at all. However, following other symbolic mathematics systems it seems useful to define gcd(p/q, P/Q) as gcd(p, P)/lcm(q, Q) because this way we can clear denominators when dividing by the gcd and core diverged from polys. As I recall, the implementation of gcd() in core was done upon request. To make core and polys behave the same way, I submitted a pull request:

in which I changed behavior of gcd() and lcm() in Field. As expected (by myself), no tests failed other than those testing the old behavior.

--

You received this message because you are subscribed to the Google Groups "sympy" group.

To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.

To unsubscribe from this group, send email to sympy+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.

For more options, visit this group at http://groups.google.com/group/sympy?hl=en.

Mateusz

-- You received this message because you are subscribed to the Google Groups "sympy" group.

To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org

To unsubscribe from this group, send email to sympy+unsubscribe <at> googlegroups.com.

For more options, visit this group at http://groups.google.com/group/sympy?hl=en.