Ticket #10771 (closed enhancement: fixed)
gcd and lcm for fraction fields
|Reported by:||SimonKing||Owned by:||AlexGhitza|
|Component:||basic arithmetic||Keywords:||gcd lcm fraction fields|
|Report Upstream:||N/A||Reviewers:||Marco Streng, Mariah Lenox|
|Authors:||Simon King||Merged in:||sage-4.7.2.alpha0|
Description (last modified by SimonKing) (diff)
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().
Let R be an integral domain, assume that it provides gcd and lcm, and let F be its fraction field. Since R has gcd, we can assume that x.numerator() and x.denominator() are relatively prime for any element x of F.
gcd(x,y) = gcd(x.numerator(),y.numerator())/lcm(x.denominator(),y.denominator()) lcm(x,y) = lcm(x.numerator(),y.numerator())/gcd(x.denominator(),y.denominator())
If that approach is mathematically sober, we obtain the following equalities up to units in R:
- gcd(x,y)*lcm(x,y)==x*y, for any x,y in F, provided that the equality holds for any x,y in R.
- gcd(F(x),F(y))==gcd(x,y) and lcm(F(x),F(y))==lcm(x,y) for any x,y in R.
- Status changed from new to needs_review
- Type changed from PLEASE CHANGE to defect
- Authors set to Simon King
comment:10 follow-up: ↓ 22 Changed 2 years ago by mstreng
- Status changed from needs_review to needs_work
comment:21 follow-up: ↓ 23 Changed 2 years ago by SimonKing
- Cc burcin added
- Status changed from needs_work to needs_review
comment:33 Changed 2 years ago by mariah
- Status changed from needs_review to positive_review
- Reviewers changed from Marco Streng to Marco Streng, Mariah Lenox
comment:35 Changed 2 years ago by jdemeyer
- Type changed from defect to enhancement
- Milestone changed from sage-4.7.1 to sage-4.7.2
comment:36 follow-up: ↓ 37 Changed 2 years ago by jdemeyer
- Status changed from positive_review to needs_work
comment:37 in reply to: ↑ 36 Changed 2 years ago by SimonKing
- Status changed from needs_work to positive_review