# How to find the coefficient of a boolean function with respect to some variable?

Suppose we have a boolen ring with variable x1,x2,x3,v1,v2 and v3. let f = 1+x1x2v1v2 + x3v1v2 + v1v3 +x1x2v3. now how i find coefficient of v1v2? in this case it will be (x1x2 + x3). how can i find this using sagemath. I try to use f.coefficient(v1*v2). But it not work.

edit retag close merge delete

Please take the time to format your question to allow for easier reading (and possibly cut'n paste...).

( 2019-10-31 09:41:46 +0200 )edit

Sort by » oldest newest most voted

Apparently, you want to treat the x as coefficients and the v as indeterminates. One way do do this is to create a ring of polynomials in x1, x2, x3overGF(2) :

sage: R1.<x1, x2, x3>=GF(2)[]
sage: R1
Multivariate Polynomial Ring in x1,


then a ring of polynomials in v1, v2, v3over the latter :

sage: R.<v1, v2, v3>=R1[]
sage: R
Multivariate Polynomial Ring in v1, v2, v3 over Multivariate Polynomial Ring in x1, x2, x3 over Finite Field of size 2


Define f pver this one: sage: f = 1+x1x2v1v2 + x3v1v2 + v1v3 +x1x2v3

and, lo !, it works as you intended:

sage: f.coefficient(v1*v2)
x1*x2 + x3


There are probably other ways to do this.

HTH,

more