#813: forced coercion vs. automatic coercion
------------------------+---------------------------------------------------
Reporter: nbruin | Owner: roed
Type: defect | Status: new
Priority: major | Milestone: sage-4.7.1
Component: coercion | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author:
Merged: | Dependencies:
------------------------+---------------------------------------------------
Comment(by SimonKing):
Here is my plan for implementing a coercion of `P = QQ['x','y']` into `Q =
Frac(QQ['x'])['y']`.
Since conversion of P into Q works, we only need to make
`Q._coerce_map_from_(P)` return True.
Let p be an element of P. When converting p into Q, the multivariate
polynomial p is transformed into a univeriate polynomial via p. This is
done using `p._polynomial_(Q)`, which ultimately boils down to
`Q(p.polynomial(P('y')))`:
{{{
sage: P = QQ['x','y']
sage: p = P.gen(0)
sage: Q = Frac(QQ['x'])['y']
sage: Q(p.polynomial(P('y')))
x
}}}
`p.polynomial(P('y')).parent()` lives in a stacked polynomial ring:
{{{
sage: p.polynomial(P('y')).parent()
Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over
Rational Field
}}}
That stacked ring coerces into Q:
{{{
sage: Q.has_coerce_map_from(p.polynomial(P('y')).parent())
True
}}}
Conclusion: If we want to test whether a multivariate polynomial ring P
coerces into a univariate polynomial ring Q in variable y, then we need to
try and transform P into a ''univariate'' polynomial ring P' in variable
y; here, we have `P'=QQ['x']['y']`. There is a coercion from P into Q if
and only if there is a coercion from P' into Q.
I already have a patch, but "surprisingly" the additional coercion yields
some doctest errors in other places.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/813#comment:10>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.