Opened 11 years ago

Closed 9 years ago

#11368 closed defect (fixed)

can't coerce pari to rational function field

Reported by: katestange Owned by: robertwb
Priority: minor Milestone: sage-6.1
Component: coercion Keywords: coercion pari rational fraction_field string
Cc: katestange Merged in:
Authors: Peter Bruin Reviewers: Marco Streng
Report Upstream: N/A Work issues:
Branch: u/pbruin/11368-coerce_rational_function_field (Commits, GitHub, GitLab) Commit: a9fcc831dca865c0adf7feceb8413d7dc7b5cf8c
Dependencies: Stopgaps:

Status badges

Description (last modified by pbruin)

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).

Change History (8)

comment:1 Changed 11 years ago by katestange

  • Description modified (diff)
  • Keywords string added

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


with the same error. Again, polynomial coercion like


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()

Note that the following does work:

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

Note also that the PARI types are different:

sage: a.type()
sage: b.type()

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

  • Commit set to a9fcc831dca865c0adf7feceb8413d7dc7b5cf8c
  • Reviewers set to Marco Streng

I'll review this as my first git review.

New commits:

a9fcc83fix 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.