Substituting into symbolic expression
I have a symbolic (polynomial) expression in A1 and A3. I want to substitute for A1 and A3 values from a ring, possibly other values from the Symbolic Ring, say a1 and a3.
R = SR
a1, a3 = R('a1'), R('a3')
A1, A3 = SR.var('A1, A3')
s = A1 + 2*A3 + 7*A1*A3
PR = PolynomialRing(R, 'A1,A3')
A1, A3 = PR.gens()
print( PR(s).subs({A1:a1, A3:a3}) )
The result of the code above is 7*A1*A3 + A1 + 2*A3
. The expected result is 7*a1*a3 + a1 + 2*a3
. The code above works fine when R
is some other ring like theGF
. How would I make this work?