On computation of Jacobi sum [closed]

asked 1 year ago

Ys1123 gravatar image

updated 1 year ago

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?

Preview: (hide)

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 ( 1 year ago )

range stops just before its upper bound

FrédéricC gravatar imageFrédéricC ( 1 year ago )

Oh my goodness.Thank you.

Ys1123 gravatar imageYs1123 ( 1 year ago )

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 ( 1 year ago )

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 ( 1 year ago )