Sage: Ticket #8111: gcd of rationals is trouble
https://trac.sagemath.org/ticket/8111
<p>
The following was solved along the way. We add a doctest.
</p>
<p>
The GCD of rationals is still unclear (see trac 3214), and leads to definite problems with reduce().
</p>
<pre class="wiki">K.<k>= QQ[];
print(gcd(64,256))
print(gcd(K(64),K(256)))
print(gcd(64*k^2+128,64*k^3+256))
frac = (64*k^2+128)/(64*k^3+256)
frac.reduce()
print(frac)
</pre><p>
gives
</p>
<pre class="wiki">64
1
1
(64*k^2 + 128)/(64*k^3 + 256)
</pre><p>
The last line in particular is false, according to me.
</p>
en-usSagehttps://trac.sagemath.org/chrome/site/logo_sagemath_trac.png
https://trac.sagemath.org/ticket/8111
Trac 1.1.6burcinFri, 29 Jan 2010 15:07:11 GMT
https://trac.sagemath.org/ticket/8111#comment:1
https://trac.sagemath.org/ticket/8111#comment:1
<p>
I think the trouble here is our generic fraction field code, not how we define the gcd of rational numbers.
</p>
<p>
For efficiency, we should represent QQ(x) as Frac(ZZ[x]), and do the necessary normalisation of the denominator (it should be monic) when the user accesses it with <code>.denominator()</code>.
</p>
TicketkcrismanWed, 16 Feb 2011 21:21:37 GMT
https://trac.sagemath.org/ticket/8111#comment:2
https://trac.sagemath.org/ticket/8111#comment:2
<p>
<a class="closed ticket" href="https://trac.sagemath.org/ticket/10771" title="enhancement: gcd and lcm for fraction fields (closed: fixed)">#10771</a> is probably related/same thing.
</p>
TicketSimonKingThu, 17 Feb 2011 07:35:58 GMT
https://trac.sagemath.org/ticket/8111#comment:3
https://trac.sagemath.org/ticket/8111#comment:3
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/8111#comment:2" title="Comment 2">kcrisman</a>:
</p>
<blockquote class="citation">
<p>
<a class="closed ticket" href="https://trac.sagemath.org/ticket/10771" title="enhancement: gcd and lcm for fraction fields (closed: fixed)">#10771</a> is probably related/same thing.
</p>
</blockquote>
<p>
It may be related, but my patch from <a class="closed ticket" href="https://trac.sagemath.org/ticket/10771" title="enhancement: gcd and lcm for fraction fields (closed: fixed)">#10771</a> does not touch the gcd for <code>QQ['x']</code> (perhaps it should?). So far, the two tickets are about different issues.
</p>
TicketSimonKingThu, 17 Feb 2011 07:43:21 GMT
https://trac.sagemath.org/ticket/8111#comment:4
https://trac.sagemath.org/ticket/8111#comment:4
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/8111#comment:3" title="Comment 3">SimonKing</a>:
</p>
<blockquote class="citation">
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/8111#comment:2" title="Comment 2">kcrisman</a>:
</p>
<blockquote class="citation">
<p>
<a class="closed ticket" href="https://trac.sagemath.org/ticket/10771" title="enhancement: gcd and lcm for fraction fields (closed: fixed)">#10771</a> is probably related/same thing.
</p>
</blockquote>
<p>
It may be related, but my patch from <a class="closed ticket" href="https://trac.sagemath.org/ticket/10771" title="enhancement: gcd and lcm for fraction fields (closed: fixed)">#10771</a> does not touch the gcd for <code>QQ['x']</code> (perhaps it should?). So far, the two tickets are about different issues.
</p>
</blockquote>
<p>
PS: It seems to me that for changing gcd for univariate polynomials over the rationals, one has to dive into flint. I'll not do that, it'd be too far off topic for me. BTW, the doc string explicitly states that gcd in <code>QQ['x']</code> returns the <em>monic</em> gcd.
</p>
TicketjdemeyerTue, 13 Aug 2013 15:35:53 GMTmilestone changed
https://trac.sagemath.org/ticket/8111#comment:5
https://trac.sagemath.org/ticket/8111#comment:5
<ul>
<li><strong>milestone</strong>
changed from <em>sage-5.11</em> to <em>sage-5.12</em>
</li>
</ul>
Ticketvbraun_spamThu, 30 Jan 2014 21:20:52 GMTmilestone changed
https://trac.sagemath.org/ticket/8111#comment:6
https://trac.sagemath.org/ticket/8111#comment:6
<ul>
<li><strong>milestone</strong>
changed from <em>sage-6.1</em> to <em>sage-6.2</em>
</li>
</ul>
Ticketvbraun_spamTue, 06 May 2014 15:20:58 GMTmilestone changed
https://trac.sagemath.org/ticket/8111#comment:7
https://trac.sagemath.org/ticket/8111#comment:7
<ul>
<li><strong>milestone</strong>
changed from <em>sage-6.2</em> to <em>sage-6.3</em>
</li>
</ul>
Ticketvbraun_spamSun, 10 Aug 2014 16:51:03 GMTmilestone changed
https://trac.sagemath.org/ticket/8111#comment:8
https://trac.sagemath.org/ticket/8111#comment:8
<ul>
<li><strong>milestone</strong>
changed from <em>sage-6.3</em> to <em>sage-6.4</em>
</li>
</ul>
TicketkcrismanThu, 12 Feb 2015 15:06:40 GMT
https://trac.sagemath.org/ticket/8111#comment:9
https://trac.sagemath.org/ticket/8111#comment:9
<p>
Possibly related: <a class="ext-link" href="https://groups.google.com/forum/#!searchin/sage-devel/xgcd/sage-devel/JV8fCPUqTzo/FTGonGmYyCgJ"><span class="icon"></span>this discussion</a>.
</p>
TicketjakobkroekerThu, 20 Aug 2015 00:02:31 GMTstopgaps set
https://trac.sagemath.org/ticket/8111#comment:10
https://trac.sagemath.org/ticket/8111#comment:10
<ul>
<li><strong>stopgaps</strong>
set to <em>todo</em>
</li>
</ul>
Ticketgh-kliemWed, 27 May 2020 19:04:18 GMTstatus, description, milestone changed; keywords, author set
https://trac.sagemath.org/ticket/8111#comment:11
https://trac.sagemath.org/ticket/8111#comment:11
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>needs_review</em>
</li>
<li><strong>keywords</strong>
<em>sd109</em> added
</li>
<li><strong>author</strong>
set to <em>Jonathan Kliem</em>
</li>
<li><strong>description</strong>
modified (<a href="/ticket/8111?action=diff&version=11">diff</a>)
</li>
<li><strong>milestone</strong>
changed from <em>sage-6.4</em> to <em>sage-duplicate/invalid/wontfix</em>
</li>
</ul>
TicketkcrismanWed, 27 May 2020 19:15:41 GMTstatus, priority, type, milestone changed; author deleted
https://trac.sagemath.org/ticket/8111#comment:12
https://trac.sagemath.org/ticket/8111#comment:12
<ul>
<li><strong>status</strong>
changed from <em>needs_review</em> to <em>needs_info</em>
</li>
<li><strong>priority</strong>
changed from <em>major</em> to <em>minor</em>
</li>
<li><strong>author</strong>
<em>Jonathan Kliem</em> deleted
</li>
<li><strong>type</strong>
changed from <em>defect</em> to <em>task</em>
</li>
<li><strong>milestone</strong>
changed from <em>sage-duplicate/invalid/wontfix</em> to <em>sage-9.3</em>
</li>
</ul>
<p>
If this is fixed, we should probably have a doctest then. Unless it wasn't an error to begin with? Or it's possible it was fixed elsewhere and doctested, which is fine too.
</p>
Ticketgh-kliemWed, 27 May 2020 19:22:01 GMTstatus, description changed; commit, branch, author set
https://trac.sagemath.org/ticket/8111#comment:13
https://trac.sagemath.org/ticket/8111#comment:13
<ul>
<li><strong>status</strong>
changed from <em>needs_info</em> to <em>needs_review</em>
</li>
<li><strong>commit</strong>
set to <em>bed3abb1364df5a4e0588953f535b3cc9b563766</em>
</li>
<li><strong>description</strong>
modified (<a href="/ticket/8111?action=diff&version=13">diff</a>)
</li>
<li><strong>branch</strong>
set to <em>public/8111</em>
</li>
<li><strong>author</strong>
set to <em>Jonathan Kliem</em>
</li>
</ul>
<p>
New commits:
</p>
<table class="wiki">
<tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit?id=bed3abb1364df5a4e0588953f535b3cc9b563766"><span class="icon"></span>bed3abb</a></td><td><code>add doctest for 8111</code>
</td></tr></table>
Ticket