-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add utilities to compute Jacobi symbols
This is a core need for the Baillie-PSW implementation: we will use Jacobi symbols to set the parameters for the Strong Lucas test. The [Jacobi symbol] `(a/n)` is a multiplicative function of two numbers: `a` being any integer, and `n` any positive odd integer. It only takes values in `{-1, 0, 1}`. It's defined in terms of another function, Legendre symbols, which makes it very intimidating to compute... but actually, computation is straightforward, because the Jacobi symbol has symmetries and reduction rules that let us skip computing the Legendre symbols. I wrote this implementation by reading the linked wikipedia page, and following the rules. To test it, I wrote a few manual tests for cases where the right answer was obvious. I also tested against an implementation which I found on Wikipedia. I decided not to check the latter test into version control, because I was unsure about the licensing implications. However, the Jacobi symbol code will still get robust testing _indirectly_ in the future, because our Baillie-PSW implementation will depend on it. Helps #217. [Jacobi symbol]: https://en.wikipedia.org/wiki/Jacobi_symbol
- Loading branch information
Showing
2 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters