First time here? Check out the FAQ!

Ask Your Question
0

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

asked 5 years ago

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.

Preview: (hide)

Comments

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

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 5 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 5 years ago

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.

HTH,

Preview: (hide)
link

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: 5 years ago

Seen: 301 times

Last updated: Oct 31 '19