Ask Your Question
1

character table of a finite field

asked 2016-09-22 23:32:34 +0200

xhimi gravatar image

updated 2019-08-29 18:24:57 +0200

FrédéricC gravatar image

I am trying to calculate the character table of a finite field. The following is my code:

def character_table(q,n):
    k=GF(q^n)
    tr(x)=sum(x^(q^i) for i in [0..n-1])
    ksi = e^(2*pi*I/n)
    chi(x)=ksi^(tr(x))
    for a in k:
        L_a = [chi(a*x) for x in k]
        print L_a

And the TypeError is "free variable 'x' referenced before assignment in enclosing scope". Can somebody help me how to fix the code?

Thanks

Blockquote

edit retag flag offensive close merge delete

Comments

Beyond the error that you are getting, here are some comments.

  1. The function definition's body (everything below the first line) should be indented four spaces.

  2. You define L but never use it.

  3. Are k and K supposed to be the same?

slelievre gravatar imageslelievre ( 2016-09-23 09:12:11 +0200 )edit

You are aware that Sage has finite group character tables via GAP as well, correct?

kcrisman gravatar imagekcrisman ( 2016-09-23 14:11:36 +0200 )edit

@slelievre I fixed all your suggestions. Now I get "free variable 'x' referenced before assignment in enclosing scope". @kcrisman I tried that but I couldn't get the right syntax. Could you please help? It seems that character_table() does not have an attribute for abelian groups. Also, since I am new in sage, I thought it was worth it to try and define a function from scratch. I also having difficulties on using only the additive group of a finite field.

xhimi gravatar imagexhimi ( 2016-09-23 17:39:15 +0200 )edit

Ah, then see my answer (which is just a link).

kcrisman gravatar imagekcrisman ( 2016-09-24 22:53:02 +0200 )edit

@slelievre Please see the edited question.

xhimi gravatar imagexhimi ( 2016-09-26 18:17:01 +0200 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2016-09-23 09:05:08 +0200

slelievre gravatar image

updated 2016-09-26 19:12:33 +0200

Some tips:

  • Instead of sum[...] you want sum(...).
  • Instead of tr(x) = ..., use def tr(x): return ...

This might be what you were trying to write:

def character_table(q, n):
    k = GF(q^n)
    def tr(x):
        return sum(x^(q^i) for i in [0..n-1])
    ksi = e^(2*pi*I/n)
    def chi(x):
        return ksi^(tr(x))
    for a in k:
        L_a = [chi(a*x) for x in k]
        print L_a

Calling this function prints something:

sage: character_table(3, 2)
[1, 1, 1, 1, 1, 1, 1, 1, 1]
[1, 1, -1, -1, 1, 1, 1, 1, -1]
[1, -1, -1, 1, 1, 1, 1, -1, 1]
[1, -1, 1, 1, 1, 1, -1, 1, -1]
[1, 1, 1, 1, 1, -1, 1, -1, -1]
[1, 1, 1, 1, -1, 1, -1, -1, 1]
[1, 1, 1, -1, 1, -1, -1, 1, 1]
[1, 1, -1, 1, -1, -1, 1, 1, 1]
[1, -1, 1, -1, -1, 1, 1, 1, 1]
edit flag offensive delete link more
0

answered 2016-09-24 22:53:38 +0200

kcrisman gravatar image

Alternately, see the solution at this question.

edit flag offensive delete link more

Comments

@kcrisman Could you explain why the very same code does not work is I change the group $g$, say with, AdditiveAbelianGroup([2,2,2])? Thanks

xhimi gravatar imagexhimi ( 2016-09-26 18:59:12 +0200 )edit

Hmm, not sure.

kcrisman gravatar imagekcrisman ( 2016-09-27 04:26:58 +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

Stats

Asked: 2016-09-22 23:32:34 +0200

Seen: 475 times

Last updated: Sep 26 '16