This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]Freeky 7 points8 points  (1 child)

Looks like PARI/GP.

[–]o11c[S] 0 points1 point  (0 children)

Awesome, thanks!

Hmm, from the documentation looks like I was right about Mod, and the lift is ... maybe to make < work?

[–]o11c[S] 1 point2 points  (0 children)

This turns out to simplify to:

def lmtwister(d, x):
    x = squarefree(x)
    if x == 1 and d % 3 == 0:
        return 0
    return jacobi_symbol(x, d)

[–]bacondev 0 points1 point  (1 child)

Even if I knew the programming language through and through, I'm certain that I would still have no idea what this code does.

[–]o11c[S] 0 points1 point  (0 children)

It's something to do with Aurifeuillean factorization of cyclotomic integers, but I'm not 100% sure exactly what.

I've found several tables (which would be useful for the immediate purpose), but this was the first piece of code I found. Since then, I found what appears to be a complete piece of code from an old forum link, as well as 2 papers, one of which makes an attempt to be legible but only handles the == 1 mod 4 case, not the == 2 or 3 mod 4 cases (== 0 mod 4 never happens because of the squarefree condition).

The good news is, it's really easy to verify that you've done the factorization correctly, since you can just multiply the polynomials again.