Ask Your Question

Revision history [back]

Instead of sum[(x^(q^i) for i in [0..n-1])] you want sum(x^(q^i) for i in [0..n-1]).

Some tips:

  • Instead of sum[(x^(q^i) for i in [0..n-1])]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]).[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

Using this function returns 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]

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

Using Calling this function returns 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]

Some tips:

  • Instead of sum[...] you want sum(...).
  • Instead of tr(x) = ..., use `def 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]