On 14 May 2017 at 17:34, Ralf Hemmecke <[email protected]> wrote:
> Look at the docstrings in GcdDomain. I think, we can do better.
>
>       gcd : (%, %) -> %
>             ++ gcd(x, y) returns the greatest common divisor of x and y.
>
>       lcm : (%, %) -> %
>             ++ lcm(x, y) returns the least common multiple of x and y.
>
> In particular, it is not clearly specified what gcd(0,0) will return.
> Currently gcd(0,0) in Fraction(Integer) gives 1. Why?
>
> Because there is a default definition in Field
>
>       gcd(x, y) == 1
>

This is another point against the current implementation of 'gcd' in Fraction.

> In Integer, we have gcd(0,0)=0.
>
> Mathematica, Maple, and Sage all yield 0 as a result of gcd(0,0).
>
> I'm not saying that is the best, but 1 is also not really nice, since then
>
> \exists a,b : gcd(x,y) = a*x + b*y
>
> would not hold for x=y=0.
>

Certainly gcd(0,0) cannot be 1.

> It all depends on what the definition of "greatest common divisor" in
> the docstring of gcd (see above) actually is.
>
> Opinions?


The definition of "greatest" in "greatest common divisor" should be
interpreted in the sense of the partial order defined by divisibility,
i.e. when one thing divides another "evenly". 0 is the greatest number
since every other number divides 0 evenly.  'gcd' and 'lcm' are
related to meet and join in the associated lattice.

BTW, this definition extends Euclid's algorithm naturally into the
rationals in a way that is consistent with my proposal for the
implementation of 'gcd' and 'lcm' in Fraction fields that we are
discussing in another thread.

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to