Opened 12 years ago

# gcd and lcm for fraction fields — at Initial Version

Reported by: Owned by: SimonKing AlexGhitza major sage-4.7.2 basic arithmetic gcd lcm fraction fields burcin N/A

### Description

At sage-devel, the question was raised whether it really is a good idea that the gcd in the rational field should return either `0` or `1`.

Since any non-zero element of `QQ` qualifies as gcd of two non-zero rationals, it should be possible to define gcd and lcm, so that `gcd(x,y)*lcm(x,y)==x*y` holds for any rational numbers x,y, and so that `gcd(QQ(m),QQ(n))==gcd(m,n)` and `lcm(QQ(m),QQ(n))==lcm(m,n)` for any two integers m,n.

Moreover, it should be possible to provide gcd/lcm for any fraction field of a `PID`: Note that currently gcd raises a type error for elements of `Frac(QQ['x'])`.

The aim is to implement gcd and lcm as `ElementMethods` of the category `QuotientFields()`.

It seems that defining `gcd(a/b,c/d) = gcd(a,c)/lcm(b,d)` and `lcm(a/b,c/d) = lcm(a,c)/gcd(b,d)` works, under the assumption that `a/b` and `c/d` are reduced fractions. Note: Since we need `gcd` for `a,b,c,d` anyway, it is no problem to reduce the fractions.

But I am not 100% sure whether that approach is mathematically sober.

### Change History (0)

Note: See TracTickets for help on using tickets.