On computation of Jacobi sum [closed]

asked 2023-11-02 11:07:15 +0100

Ys1123 gravatar image

updated 2024-02-12 21:35:11 +0100

FrédéricC gravatar image

I’m computing Jacobi sum of cubic residue symbol as follows:

N=3
x=polygen(ZZ,'x')
K.<z>=CyclotomicField(N)
p=-4-3*z
P = K.ideal(p)
sum([K(a).residue_symbol(P,N)*K(1-a).residue_symbol(P,N) for a in [2..P.norm()-1] if a not in P and 1-a not in P])

The output is -3*z - 4. This is correct.

But I wrote another equivalent code:

def Jacobi(P,l,j):
    x=sum([K(a).residue_symbol(P,l)^j*K(1-a).residue_symbol(P,l)^j for a in range(2, P.norm()-1) if a not in P and 1-a not in P])
    return x

N=3
x=polygen(ZZ,'x')
K.<z>=CyclotomicField(N)
p=-4-3*z
P = K.ideal(p)
Jacobi(P,N,1)

Then the output is -4*z - 4, this is odd. Where is wrong?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Max Alekseyev
close date 2023-11-02 14:52:33.195164

Comments

You have different summation ranges.

Max Alekseyev gravatar imageMax Alekseyev ( 2023-11-02 12:19:12 +0100 )edit

range stops just before its upper bound

FrédéricC gravatar imageFrédéricC ( 2023-11-02 13:25:38 +0100 )edit

Oh my goodness.Thank you.

Ys1123 gravatar imageYs1123 ( 2023-11-02 14:46:07 +0100 )edit

On a different note - there is no need to create a list to sum up its elements, that is, instead of sum([...]) you can do simply sum(...), which may save some memory when the number of terms is large.

Max Alekseyev gravatar imageMax Alekseyev ( 2023-11-02 14:47:37 +0100 )edit

And same for [2..P.norm()-1] - there is no need to create a list here, generator (2..P.norm()-1) (or range()) is well sufficient for summation purposes.

Max Alekseyev gravatar imageMax Alekseyev ( 2023-11-02 14:50:31 +0100 )edit