Ask Your Question

How to create in Sage system of equations using elements from boolean field?

asked 2019-05-30 11:09:10 +0200

Maori gravatar image

I want to create a field on 8 elements, and then, using this elements make a System of equations like:

nb = 8
varl = [c+ str(p) for c in 'xy' for p in range (nb)]
B = BooleanPolynomialRing(names = varl)

f1 = x1 + x7*x2

f2 = x4*x6*x8 + x7

and then....

But in this case Sage give me an error NameError: name 'x1' is not defined

And in this case:

f1 = x[3] + x[1]*x[2]
f2 = x[4]*x[6]*x[2] + x[7]

error: TypeError: 'sage.symbolic.expression.Expression' object does not support indexing

Is there any way to create them in Sage?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-05-30 14:31:15 +0200

tmonteil gravatar image

When you write f1 = x1 + x7*x2, you assume that the Python name x1 points to the boolean indeterminate x1, but there is nothing in your code that assign the Python name x1 to something.

You can to that with:

sage: B.inject_variables()
Defining x0, x1, x2, x3, x4, x5, x6, x7, y0, y1, y2, y3, y4, y5, y6, y7
edit flag offensive delete link more


Thank you, it helps:)

Maori gravatar imageMaori ( 2019-05-30 14:45:43 +0200 )edit

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-05-30 11:09:10 +0200

Seen: 320 times

Last updated: May 30 '19