Ask Your Question
1

character table of a finite field

asked 2016-09-22 16:32:34 -0500

xhimi gravatar image

updated 2016-09-26 11:16:21 -0500

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 02:12:11 -0500 )edit

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

kcrisman gravatar imagekcrisman ( 2016-09-23 07:11:36 -0500 )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 10:39:15 -0500 )edit

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

kcrisman gravatar imagekcrisman ( 2016-09-24 15:53:02 -0500 )edit

@slelievre Please see the edited question.

xhimi gravatar imagexhimi ( 2016-09-26 11:17:01 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
1

answered 2016-09-23 02:05:08 -0500

updated 2016-09-26 12:12:33 -0500

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 15:53:38 -0500

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 11:59:12 -0500 )edit

Hmm, not sure.

kcrisman gravatar imagekcrisman ( 2016-09-26 21:26:58 -0500 )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 16:32:34 -0500

Seen: 108 times

Last updated: Sep 26 '16