Ask Your Question
1

symbolic substitution is done only partially

asked 2022-10-25 19:12:04 +0100

Max Alekseyev gravatar image

updated 2022-11-18 11:18:22 +0100

tmonteil gravatar image

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-10-26 14:59:10 +0100

Max Alekseyev gravatar image

This seems to be a bug, which I reported as https://trac.sagemath.org/ticket/34695

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2022-10-25 19:12:04 +0100

Seen: 99 times

Last updated: Oct 26 '22