symbolic substitution is done only partially
I'm trying to use symbolic ring as a media for conversion between complex algebraic entities. However, I've encountered an issue when the substitution does not quite work. The following code illustrates the issue, where only part of the variables are substituted. Namely, symbolic variables x
and t
remain intact despite of the request to substitute them with xx
and tt
:
R = PolynomialRing(QQ,2,'s')
s = R.gens()
K.<x,t> = R[[]]
f = (s[0]+s[1])*x + (s[0]^2+s[1]^2)*x^2 + t*x^3
fs = SR( f.polynomial() )
print(f'fs: {fs.parent()} {fs.variables()}')
var('ss0','ss1','xx','tt')
fn = fs.subs({SR(s[0]):ss0, SR(s[1]):ss1, SR(t):tt, SR(x):xx})
print(f'fn: {fn.parent()} {fn.variables()}')
The output is
fs: Symbolic Ring (s0, s1, t, x)
fn: Symbolic Ring (ss0, ss1, t, x)
What's wrong?
UPDATE. Apparently, the substitution
fn = fs.subs({SR(s[0]):ss0, SR(s[1]):ss1, SR(t.polynomial()):tt, SR(x.polynomial()):xx})
works as expected. So, it seems that Sage does not recognize SR(t)
and SR(t.polynomial())
as the same variable. Is this expected?