Ask Your Question
0

Function in GF(16)

asked 2012-05-08 15:29:07 +0100

Arczi84 gravatar image

Hi,

I've one problem in the following task. My calculations:

I'm defining following function:

def custom_divide(x,y):
if x==0:
    return 0
return y/x

Next, I'm calculating all possible values in GF(16) for the function T:

F.<a>=GF(16)
for a,b in F^2:
    print "x=",a,"y=",b, "T:",a*custom_divide((c+1)*((custom_divide(a,b))^3+1)+(c^3+c)*((custom_divide(a,b))^2+custom_divide(a,b)),(custom_divide(a,b))^4+(c+1)*(custom_divide(a,b))^2+1)+(a*b).nth_root(2)

I know that c is not defined in that code but I wrote it there because it helps me with describing my problem. c+1 and c^3+c are constants and I don't know how can I write them in my code. If I'll write:

F.<a>=GF(16)
    for a,b in F^2:
        print "x=",a,"y=",b, "T:",a*custom_divide((a+1)*((custom_divide(a,b))^3+1)+(a^3+a)*((custom_divide(a,b))^2+custom_divide(a,b)),(custom_divide(a,b))^4+(a+1)*(custom_divide(a,b))^2+1)+(a*b).nth_root(2)

then this constants will be equal to the variable a and will be change in every steps, but they should be the same in all cases.

How can I correct my code?

I'll be grateful for any help in this task.

edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted
1

answered 2012-05-08 16:24:36 +0100

Volker Braun gravatar image

I have no idea of what you are asking or what you are trying to compute. But if you define a to be the generator of your field then it is very confusing to use a as the loop variable. For example:

sage: F.<a>=GF(16)
sage: 1+3*a
a + 1
sage: 16*a
0

Using a as a loop variable overwrites it:

sage: for a in range(3): print a
0
1
2
sage: a
2
edit flag offensive delete link more
1

answered 2012-05-08 17:25:01 +0100

Volker Braun gravatar image

How about this. I'll leave it as an exercise to handle the divide by zero:

sage: F.<a>=GF(16)
sage: def T(x,y,c):
...      return ((y/x + y^3/x^3)*(c^2 + c + 1)*c^2 + (y/x + y^4/x^4)*c^2)*x/(c*y^2/x^2 + y^4/x^4 + 1) + sqrt(x*y)
sage: for x,y in CartesianProduct(list(F),list(F)):
...   try:
...       print x, '\t', y, '\t', T(x, y, c=1)
...   except Exception, e:
...       print e
0   0   division by zero in finite field.
0   a   division by zero in finite field.
0   a^2     division by zero in finite field.
0   a^3     division by zero in finite field.
0   a + 1   division by zero in finite field.
0   a^2 + a     division by zero in finite field.
0   a^3 + a^2   division by zero in finite field.
0   a^3 + a + 1     division by zero in finite field.
0   a^2 + 1     division by zero in finite field.
0   a^3 + a     division by zero in finite field.
0   a^2 + a + 1     division by zero in finite field.
0   a^3 + a^2 + a   division by zero in finite field.
0   a^3 + a^2 + a + 1   division by zero in finite field.
0   a^3 + a^2 + 1   division by zero in finite field.
0   a^3 + 1     division by zero in finite field.
0   1   division by zero in finite field.
a   0   0
a   a   a
a   a^2     a
a   a^3     a
a   a + 1   a
a   a^2 + a     a
a   a^3 + a^2   division by zero in finite field.
a   a^3 + a + 1     a
a   a^2 + 1     a^3 + a
a   a^3 + a     a
a   a^2 + a + 1     a
a   a^3 + a^2 + a   division by zero in finite field.
a   a^3 + a^2 + a + 1   a^2 + a
a   a^3 + a^2 + 1   a
a   a^3 + 1     a^3
a   1   a^2
a^2     0   0
a^2     a   a^3
a^2     a^2     a^2
a^2     a^3     a^2
a^2     a + 1   a^2
a^2     a^2 + a     a^2
a^2     a^3 + a^2   a^2
a^2     a^3 + a + 1     division by zero in finite field.
a^2     a^2 + 1     a^2
a^2     a^3 + a     a^2 + a + 1
a^2     a^2 + a + 1     a^2
a^2     a^3 + a^2 + a   a^2
a^2     a^3 + a^2 + a + 1   division by zero in finite field.
a^2     a^3 + a^2 + 1   a^3 + a^2
a^2     a^3 + 1     a^2
a^2     1   a + 1
a^3     0   0
a^3     a   a^2 + a
a^3     a^2     a + 1
a^3     a^3     a^3
a^3     a + 1   a^3
a^3 ...
(more)
edit flag offensive delete link more
0

answered 2012-05-08 16:55:48 +0100

Arczi84 gravatar image

Maybe You are right, so I'll write it more clearly (I hope).

Let GF(2^4)={0, 1, a, a+1, a^2, a^2+1, a^2+a, a^2+a+1, a^3, a^3+1, a^3+a, a^3+a+1, a^3+a^2, a^3+a^2+1, a^3+a^2+a, a^3+a^2+a+1} and a^4+a+1=0.

Let T:= x*([c^2((y/x)^4+(y/x))+c^2(1+c+c^2)((y/x)^3+(y/x))]/[(y/x)^4+c(y/x)^2+1])+(xy)^(1/2),

where c is constant in GF(16) (for example c=a^2+a). Convention: if x=0 then y/x=0 (custom_divide).

Now I want to calculate all values of the function T:

x=0            y=0            T=...
x=0            y=1            T=...
x=0            y=a            T=...
...
x=a^3+a^2+a+1  y=a^3+a^2+1    T=...
x=a^3+a^2+a+1  y=a^3+a^2+a    T=...
x=a^3+a^2+a+1  y=a^3+a^2+a+1  T=...

I've to define this function T with this constant c.

edit flag offensive delete link more
0

answered 2012-05-08 17:28:49 +0100

Arczi84 gravatar image

Thank You for help:) I'll do this exercise.

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

Stats

Asked: 2012-05-08 15:29:07 +0100

Seen: 610 times

Last updated: May 08 '12