Hi Doug!

On 10 Feb., 09:40, "D. S. McNeil" <dsm...@gmail.com> wrote:
> @Simon King: as you note, there are multiple ways to extend the
> concept of gcds and lcms to the rationals. In such a situation, it
> would seem that two minimal things you would like would be (1) to
> reduce to the integer case for integer values, and (2) to maintain
> some nice properties so that the names "gcd" and "lcm" still fit.
> Given some definition satisfying (1), coercing down to integers from
> rationals isn't much of a problem, ...

There is no "coercing down to integers from rationals". One important
property of a coercion map is that it is a map, in contrast to a
partial map. Actually, it even is a morphism.

So, a coercion from QQ to ZZ would presumably be a morphism from QQ to
ZZ in the category of unital rings - which doesn't exist.

When I wrote "lcm(2/1,4) should not raise an error but use coercion",
I meant of course that the integer 4 should be coerced into the common
parent of 2/1 and 4, which is the rational field.

> Choosing any definition
> which doesn't reduce to the integer one, as is currently done, seems
> problematic to me as a design decision, given that it's far more
> likely to be used that way in error than it is that someone decided to
> obfuscate "1" by writing it as gcd(some rational, some integer).

No, I think you are mistaken. If you work with a,b rational or, worse,
real numbers, then it is very highly unlikely that a and b *are*
integers if they happen to seem like integers. Just think of rounding
errors. This is another reason why "coercing down to the integers"
won't make sense: It is highly unlikely that 1.0 really is the integer
number 1.

So, I think it is by far better to have a consistent notion than to
have to *guess* whether a user really means the integer 2 if s/he
write 4/2 (which in the first place is a rational, not an integer).
Bugs that are result of guesswork are the most ugly, IMHO.

Cheers,
Simon

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to