Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Sage subs() function include product condition

from brial import * katan=declare_ring([Block('x',32),Block('k',80)],globals())

r1=x(3)x(8) + x(7) + x(10)x(12) + x(18) + x(23) + k(1) + k(16)

r2 = r1.subs({x(3)x(8)+x(7)+ x(10)x(12)+ x(18) + x(23) + k(1) + k(16) : 0}) print(r2) this is a sage code, make r1 equals a polynomial include some variables, then use the subs() function to fix some variable, in this case, let the polynomial equals 0, so the expected result of r2 is 0, but the sage gives the result is

x(7) + x(10)*x(12) + x(18) + x(23) + k(1) + k(16)

i know , some thing wrong with the x(3)*x(8), but i don't know how to make it right.

click to hide/show revision 2
None

Sage subs() function include product condition

Code:

from brial import *
katan=declare_ring([Block('x',32),Block('k',80)],globals())

katan=declare_ring([Block('x',32),Block('k',80)],globals())

r1=x(3)x(8) r1=x(3)*x(8) + x(7) + x(10)x(12) x(10)*x(12) + x(18) + x(23) + k(1) + k(16)

k(16)

r2 = r1.subs({x(3)x(8)+x(7)+ x(10)x(12)+ r1.subs({x(3)*x(8)+x(7)+ x(10)*x(12)+ x(18) + x(23) + k(1) + k(16) : 0}) print(r2)

this is a sage code, make r1 equals a polynomial include some variables, then use the subs() function to fix some variable, in this case, let the polynomial equals 0, so the expected result of r2 is 0, but the sage gives the result is

x(7) + x(10)*x(12) + x(18) + x(23) + k(1) + k(16)

i know , some thing wrong with the x(3)*x(8), but i don't know how to make it right.