Output in characteristic 2

21 views
Skip to first unread message

Samanta

unread,
Feb 3, 2020, 2:31:49 AM2/3/20
to sage-support
I have defined the input variables in characteristic 2. But when I assign a particular value to the input, output gives the result in simple algebra not in characteristic 2. Here is my code:
sage: P.<x0,x1,x2,x3> = GF(2)[]
....: x3=0
....: x2=1
....: x1=0
....: x0=1
....: s1= x0*x2*x3 + x0*x2 + x0 + x1*x2 + x2
....: s0= x0*x1*x3 + x0*x2 + x0*x3 + x1 + 1
....: print s1,s0
....:
3 2

Here I want s1, s0 as 1,0. If I don't assign any value to the input, the output will gives value in charateristic 2 like
sage: P.<x0,x1,x2,x3> = GF(2)[]
....: print x0+x1+x0
....:
x1
Can anyone guide me how to get the output values in characteristic 2 if I assign a value to the input?
Thanks in advance

Vincent Delecroix

unread,
Feb 3, 2020, 3:16:23 AM2/3/20
to sage-s...@googlegroups.com
The command

sage: P.<x0,x1,x2,x3> = GF(2)[]

is *not* declaring variables x0, x1, etc to be elements in GF(2)
but rather *assigns* x0, x1, etc to be generators of a poynomial
algebra.

sage: P.<x0,x1,x2,x3> = GF(2)[]
sage: (x0 * x1 + x3 + 1)^2
x0^2*x1^2 + x3^2 + 1

If you want to use elements of GF(2) simply do

sage: K = GF(2)
sage: x3 = K(0)
sage: x2 = K(1)
sage: x1 = K(0)
sage: x0 = K(1)

Then

sage: s1= x0*x2*x3 + x0*x2 + x0 + x1*x2 + x2
sage: s0= x0*x1*x3 + x0*x2 + x0*x3 + x1 + 1
sage: print(s1,s0)
1 0

Vincent

PS: the command

sage: x3 = 0

assigns x3 the number 0 (which is an integer). There is no such thing as
"typing a variable" in Python. You can do

sage: x3 = 0 # defines x3 as an integer
sage: x3 = [0, 1, 3] # redefines x3 as a list
sage: x3 = "hello" # redefines x3 as a string

Simon King

unread,
Feb 3, 2020, 3:24:07 AM2/3/20
to sage-s...@googlegroups.com
Hi Samanta,

On 2020-02-03, Samanta <susantas...@gmail.com> wrote:
> I have defined the input variables in characteristic 2.

No, you haven't, see below.

> But when I assign a
> particular value to the input, output gives the result in simple algebra
> not in characteristic 2. Here is my code:
> sage: P.<x0,x1,x2,x3> = GF(2)[]

Here, you define P as multivariate polynomial ring over the field
GF(2), the four generators being x0, x1, x2, x3.

> ....: x3=0
> ....: x2=1
> ....: x1=0
> ....: x0=1

Here, you override the previous definition and assign to x0,...,x3 some
integers. The ring P still knows how its variables are called, but after
the re-definition x0 does not belong to P any more.

> Can anyone guide me how to get the output values in characteristic 2 if I
> assign a value to the input?

It is not totally clear to me what you want to do, so, I'm giving two
different answers.

1. If you want four variables x0, x1, x2, x3 with values in GF(2),
then you should simply define them as such:
sage: x0 = GF(2)(1)
sage: x1 = GF(2)(0)
sage: x2 = GF(2)(1)
sage: x3 = GF(2)(0)
There is no need at all to define P in the first place.

2. If you want to symbolically work with polynomial expressions over
GF(2) in indeterminates x0,...,x3, and want to eventually insert
special values into the expressions, you could do the following:
sage: P.<x0,x1,x2,x3> = GF(2)[]
sage: f = ((x0+x1)^2+(x2+x3)^2)^2
sage: f
x0^4 + x1^4 + x2^4 + x3^4
sage: f(x0=1, x1=0, x2=1, x3=0)
0

Best regards,
Simon

SUSANTA SAMANTA

unread,
Feb 3, 2020, 4:05:37 AM2/3/20
to sage-s...@googlegroups.com
Thanks a lot Simon. All solved now.

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/r18las%243nai%241%40ciao.gmane.io.

SUSANTA SAMANTA

unread,
Feb 3, 2020, 5:12:01 AM2/3/20
to sage-s...@googlegroups.com
Thanks a lot Vincent. It also works.

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages