Ask Your Question

Revision history [back]

Looking at the source of sage.rings.multi_power_series_ring_element.MPowerSeries.__call__ we find that Sage is parsing the arguments to X incorrectly. Namely it first tries to cast each argument to an element of X.parent() which is R. When doing this with t we would expect it to fail. There is no natural way in which t is an element of R, right? But according to Sage, there is:

sage: R(t)

I can only guess that it somehow finds a power series parent object (underlying R) which has a single generator, and maps to it. Furthermore:

sage: R(t).valuation()

This explains the error, and why the replacements succeed in removing the error: in those cases there is no power series parent object with a single generator underlying R which we can map t to:

sage: R(t)
TypeError: Cannot coerce input to polynomial ring.

In this case, X(t,t^2) evaluates correctly to X._subs_formal(t,t^2) which gives the result you want.

So a workaround is to call X._subs_formal(t,t^2) directly to avoid the faulty argument parsing.

This could also be reported as a bug. Maybe _subs_formal should be made public (with documentation).