Loading [MathJax]/jax/output/HTML-CSS/jax.js

First time here? Check out the FAQ!

Ask Your Question
0

Define function in GF(q)

asked 13 years ago

Arczi84 gravatar image

Hi,

First of all I say that these are my first steps in SAGE. I want to define a function f(x,y), where x,y in GF(q), q=2^3 and next check all possible values of this function (for all x,y in GF(q)). If it will be necessary I'll write more details about function f.

Could you give me some advices how can I do it in SAGE? Any help will be highly appreciated.

I wish you a very happy Easter!

Best regards,

Artur

Preview: (hide)

3 Answers

Sort by » oldest newest most voted
2

answered 13 years ago

fidbc gravatar image

Hi,

First we can try defining the function, say we want to calculate xy+x2+y3 for all x,yGF(23). This can be done as follows

def f(x,y):
   return x*y+x^2+y^3

Now, to check all possible values we can try the following

FFq.<a> = GF( 2^3, 'a' ) # Note: a is the name of the generator
for x in FFq:
    for y in FFq:
        print f(x,y)

As a final comment, now that a has been defined to be the generator we can use it to evaluate f at particular points, say

f(a^3+1,a^2+1)

Hope it helped.

Preview: (hide)
link
1

answered 13 years ago

DSM gravatar image

Another approach would be to build a 2-dimensional vector space.

First build the base field:

sage: FFq.<a> = GF(2^3) 
sage: FFq
Finite Field in a of size 2^3

We could make a list from this:

sage: list(FFq)
[0, a, a^2, a + 1, a^2 + a, a^2 + a + 1, a^2 + 1, 1]

And we can square the field to get a vector space:

sage: FFq^2    
Vector space of dimension 2 over Finite Field in a of size 2^3

This can be listed too:

sage: list(FFq^2)
[(0, 0), (a, 0), (a^2, 0), (a + 1, 0), (a^2 + a, 0), (a^2 + a + 1, 0), (a^2 + 1, 0), (1, 0), (0, a), (a, a), (a^2, a), (a + 1, a), (a^2 + a, a), (a^2 + a + 1, a), (a^2 + 1, a), (1, a), (0, a^2), (a, a^2), (a^2, a^2), (a + 1, a^2), (a^2 + a, a^2), (a^2 + a + 1, a^2), (a^2 + 1, a^2), (1, a^2), (0, a + 1), (a, a + 1), (a^2, a + 1), (a + 1, a + 1), (a^2 + a, a + 1), (a^2 + a + 1, a + 1), (a^2 + 1, a + 1), (1, a + 1), (0, a^2 + a), (a, a^2 + a), (a^2, a^2 + a), (a + 1, a^2 + a), (a^2 + a, a^2 + a), (a^2 + a + 1, a^2 + a), (a^2 + 1, a^2 + a), (1, a^2 + a), (0, a^2 + a + 1), (a, a^2 + a + 1), (a^2, a^2 + a + 1), (a + 1, a^2 + a + 1), (a^2 + a, a^2 + a + 1), (a^2 + a + 1, a^2 + a + 1), (a^2 + 1, a^2 + a + 1), (1, a^2 + a + 1), (0, a^2 + 1), (a, a^2 + 1), (a^2, a^2 + 1), (a + 1, a^2 + 1), (a^2 + a, a^2 + 1), (a^2 + a + 1, a^2 + 1), (a^2 + 1, a^2 + 1), (1, a^2 + 1), (0, 1), (a, 1), (a^2, 1), (a + 1, 1), (a^2 + a, 1), (a^2 + a + 1, 1), (a^2 + 1, 1), (1, 1)]

So now we can define the function:

sage: def f(x,y):        
....:     return x*y+x^2+y^3
....:

And then apply it to each coordinate pair:

sage: [f(*coords) for coords in FFq^2]
[0, a^2, a^2 + a, a^2 + 1, a, a + 1, a^2 + a + 1, 1, a + 1, a + 1, a^2 + a, 0, a^2 + a, a^2 + 1, a^2 + 1, 0, a^2 + 1, a, a^2 + 1, a^2 + a + 1, a, a^2 + a + 1, 0, 0, a^2, a^2 + a, a^2 + 1, a^2, a^2 + a + 1, a^2 + 1, a^2 + a + 1, a^2 + a, a^2 + a + 1, a^2, a^2, a + 1, a^2 + a + 1, 0, a + 1, 0, a, a + 1 ...
(more)
Preview: (hide)
link
0

answered 13 years ago

Arczi84 gravatar image

Hi,

Thanks for the answer. Yes, it helps:)

Regards

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

Stats

Asked: 13 years ago

Seen: 1,921 times

Last updated: Apr 10 '12