quadratic gauss sum calculation in sage

231 Views Asked by At

I tried to calculate quadratic gauss sum in SAGE but it works just for primes 3 and 5 which are $i\sqrt{3}$ and $\sqrt{5}$ respectively.

p=3 print sum((legendre_symbol(x,p))*(e^(2*piIx/p)) for x in (1..p-1) )

For other primes it gives exponential sum expansion. For p=7 the program gives the result:

-e^(12/7*I*pi) - e^(10/7*I*pi) + e^(8/7*I*pi) - e^(6/7*I*pi) + e^(4/7*I*pi) + e^(2/7*I*pi)

What is wrong with this? Thanks for answers in advance.

1

There are 1 best solutions below

0
On BEST ANSWER

Nothing is wrong per se; the output is equal to $i\sqrt{7}$:

sage: p = 7
sage: gauss_sum = sum((legendre_symbol(x,p))*(e^(2*pi*I*x/p)) for x in (1..p-1) )
sage: bool(gauss_sum == I*sqrt(7))
True

To get the radical expression that you want automatically, you can do:

sage: QQbar(gauss_sum).radical_expression()
I*sqrt(7)