# Revision history [back]

I think you're right that there are bugs here, but I don't quite know what they are either.

In any case, I think the Symbolic Ring can serve as a useful intermediary here. With your example, I did

sage: test_sr = SR(test)


You can see that it's still the right thing, but as a symbolic Sage object:

sage: test_sr
1/y*x + 1
sage: test_sr.parent()
Symbolic Ring


Unfortunately, converting straight to S still doesn't work:

sage: S(test_sr)
...
TypeError:


However, the method coeffs returns coefficients for powers of the given variable, and individual coefficients can be coerced to S:

sage: test_sr.coeffs(x)
[[1, 0], [1/y, 1]]
sage: test_sr.coeffs(y)
[[x, -1], [1, 0]]

sage: sum(S(c[0])*x^c[1] for c in test_sr.coeffs(x))
(x + y)/y
sage: sum(S(c[0])*y^c[1] for c in test_sr.coeffs(y))
(x + y)/y


Of course it's probably not helpful if S unsimplifies something that you specifically wanted simplified, but bear in mind that the rational function field will always try to give you elements which are ratios of polynomials. Even if that's not what you want, coercing the individual coefficients will of course work.