Ask Your Question

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

asked 2019-10-30 07:15:15 +0200

Rahul gravatar image

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 flag offensive close merge delete


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

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2019-10-31 09:41:46 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-10-31 09:40:23 +0200

Emmanuel Charpentier gravatar image

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.


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


Asked: 2019-10-30 07:15:15 +0200

Seen: 226 times

Last updated: Oct 31 '19