id summary reporter owner description type status priority milestone component resolution keywords cc merged author reviewer upstream work_issues branch commit dependencies stopgaps
13360 Should not allow coercion from polynomials to symbolic ring tkluck AlexGhitza "I've been struggling with some unexpected results in my computations with polynomials over the symbolic ring. Eventually, I came to the conclusion that it should not be possible to ''coerce'' polynomials to the symbolic ring. (Note: I'm not saying that you can't ''convert'' to the symbolic ring!) Here's some reasons for disallowing it.
I've also attached an initial patch implementing this. It needs more work though, because the same thing holds for `LaurentSeries` and `PowerSeries`.
Reasons for not allowing PolynomialRing -> SR coercion:
1) This inconsistency:
{{{
sage: R. = QQ[]
sage: SR(t^2)
t^2
sage: R. = SR[]
sage: SR(t^2)
Traceback (most recent call last):
...
TypeError: not a constant polynomial
}}}
I think the first one should raise a TypeError, too.
2) This one:
{{{
sage: R. = ZZ[]
sage: (t + 1/2).parent() # automatic base extension
Univariate Polynomial Ring in t over Rational Field
sage: R. = ZZ[]
sage: (t + pi).parent() # expect base extension SR[t]
Symbolic Ring
}}}
It is not hard to imagine that this gives all kinds of unexpected results when trying to manipulate these kind of rings programmatically. This must have cost me days and days.
3) There is also a better way to convert a polynomial to the symbolic ring,
namely just substituting a symbolic variable:
{{{
sage: R. = PolynomialRing(ZZ,'t')
sage: f = t^2 - t
sage: t = var('t')
sage: f(t)
(t - 1)*t
sage: f(t).parent()
Symbolic Ring
}}}
This has the advantage that the conversion is explicit.
4) Philosophically, I would say that the name of the variable is just a display label, but as it is, it has the side effect of determining what variable to coerce to. Then if you want to return a polynomial from a library routine, you can't be sure that it won't collide with a user-defined variable upon coercion." defect needs_work major sage-6.4 algebra N/A address review