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.


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))

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

sage: QQbar(gauss_sum).radical_expression()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.