Opened 11 years ago

Closed 9 years ago

# can't coerce pari to rational function field

Reported by: Owned by: katestange robertwb minor sage-6.1 coercion coercion pari rational fraction_field string katestange Peter Bruin Marco Streng N/A u/pbruin/11368-coerce_rational_function_field a9fcc831dca865c0adf7feceb8413d7dc7b5cf8c

The following fails

```sage: R.<x,y> = PolynomialRing(QQ)
sage: S = R.fraction_field()
sage: S(pari((x+y)/y))
TypeError: no canonical coercion from Fraction Field of Multivariate Polynomial Ring in x, y over Rational Field to Rational Field
```

However, if you replace (x+y)/y with x+y, it works (in other words, polynomials work but rational functions don't).

### comment:1 Changed 11 years ago by katestange

• Description modified (diff)

I think it is probably related that the following fails: (with R and S as above)

```S('(x+y)/y')
```

with the same error. Again, polynomial coercion like

```S('x+y')
```

succeeds. (If someone finds that this is a different problem, please put in a separate ticket, but I'm guessing it's related.)

### comment:2 Changed 9 years ago by jdemeyer

• Milestone changed from sage-5.11 to sage-5.12

### comment:3 Changed 9 years ago by pbruin

• Description modified (diff)

In newer Sage versions (for example 5.13.beta0), the example `S('(x+y)/y')` works correctly, but the original example (converting from PARI) still fails.

### comment:4 Changed 9 years ago by pbruin

The problem seems to be this:

```sage: R.<x,y> = PolynomialRing(QQ)
sage: a=pari((x+y)/y); a
1/y*x + 1
sage: a.numerator()
1/y*x + 1
sage: a.denominator()
1
```

Note that the following does work:

```sage: b=pari((x+y)/x); b
(x + y)/x
sage: b.numerator()
x + y
sage: b.denominator()
x
```

Note also that the PARI types are different:

```sage: a.type()
't_POL'
sage: b.type()
't_RFRAC'
```

This difference arises because PARI treats multivariate polynomials as iterated univariate polynomials. To PARI, a lives in Q(y)[x], and b in Frac(Q[y][x]).

The solution is probably to convert PARI elements of type `t_POL` coefficientwise into S.

### comment:5 Changed 9 years ago by pbruin

• Authors set to Peter Bruin
• Branch set to u/pbruin/11368-coerce_rational_function_field
• Description modified (diff)
• Modified changed from 12/20/13 14:19:13 to 12/20/13 14:19:13
• Status changed from new to needs_review

### comment:6 Changed 9 years ago by mstreng

• Reviewers set to Marco Streng

I'll review this as my first git review.

New commits:

 ​a9fcc83 `fix conversion PARI -> rational function field in several variables`

### comment:7 Changed 9 years ago by mstreng

• Modified changed from 12/23/13 14:19:35 to 12/23/13 14:19:35
• Status changed from needs_review to positive_review

### comment:8 Changed 9 years ago by vbraun

• Resolution set to fixed
• Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.