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}$:
To get the radical expression that you want automatically, you can do: