Opened 7 years ago

# Broken fraction field of rational polynomial ring — at Version 9

Reported by: Owned by: SimonKing major sage-duplicate/invalid/wontfix commutative algebra tscrim, yzh, mkoeppe, etn40ff, slelievre Marc Mezzarobba N/A

```sage: P.<t> = QQ[]
sage: p = 4/(-4*t)
sage: p   # OK, fractions are not automatically reduced
4/(-4*t)
sage: p.reduce()
sage: p   # What the heck...
4/(-4*t)
sage: p == -1/t   # At least sage gets this right
True
```

So, not only is the fraction not automatically simplified by "obvious" common factors, but also it is not simplified upon request.

Note that the fraction field of an integral polynomial ring works better.

```sage: P.<t> = ZZ[]
sage: p = 4/(-4*t)
sage: p
1/-t
```

Fixed by #16268.

### comment:1 Changed 7 years ago by emassop

I think this is fixed in u/robertwb/ticket/16268 which is part of #16268. On #16268, I felt that some of the functions introduced there could not live up to their documentation for nastier rings and should be moved around. Also the description of #16268 then goes on to hashes, which IMHO should be fixed without too much extra normalisation as this normalisation is probably not possible for nasty rings. Sadly I don't have time to work on this.

Now back to this ticket: I am not sure I would call reduce broken per se: If reduce is interpreted as divide out gcd, then the behaviour makes sense to me, since 1 is a generator of the ideal `4*QQ[t] + (-4*t)*QQ[t]` and therefore a gcd.

Normalisation in Q(ZZ[t]) isn't optimal either:

```sage: P.<t> = ZZ[]
sage: (2*t)/(2*t+1)
2*t/(2*t + 1)
sage: (-2*t)/(-2*t-1)
-2*t/(-2*t - 1)
```

I think Nemo solves this (for unnasty rings) by dividing the denominator by what it calls a canonical unit. My understanding of "canonical unit" is this: It is the result of a multiplicative map from the non-zero elements to the units, that is the identity on units. (In particular if this map is called `f`, we have `f(a/f(a)) = 1` for any non-zero element `a`.) In the case of `QQ[t]` the function "leading coefficient" works. In the case of `ZZ[t]` the function "sign after leading coefficient" works.

### comment:4 Changed 6 years ago by tscrim

My suggestion would be that if we create a fraction field of some commutative algebra over a field `k` such that `k` is constructed as the fraction field of `R` (perhaps with some extra conditions on the ring), then we create the fraction field over the algebra over `R`. This change would definitely require a discussion on sage-devel, and might be something we do only for polynomial rings or some other nice class of commutative algebras.

### comment:6 Changed 6 years ago by rws

• Component changed from basic arithmetic to commutative algebra

### comment:7 Changed 3 years ago by mkoeppe

• Milestone changed from sage-6.4 to sage-duplicate/invalid/wontfix
• Status changed from new to needs_review

With #16268, the example now works as expected:

```sage: P.<t> = QQ[]
sage: p = 4/(-4*t)
sage: p
-1/t
sage: p.reduce()
sage: p
-1/t
```

I would suggest to close this ticket as a duplicate of #16268.

### comment:8 Changed 3 years ago by mmezzarobba

• Reviewers set to Marc Mezzarobba
• Status changed from needs_review to positive_review