The Quadratic Frobenius Test (QFT) is a probabilistic primality test to test whether a number is a probable prime. It is named after Ferdinand Georg Frobenius. The test uses the concepts of quadratic polynomials and the Frobenius automorphism. It should not be confused with the more general Frobenius test using a quadratic polynomial -- the QFT restricts the polynomials allowed based on the input, and also has other conditions that must be met. A composite passing this test is a Frobenius pseudoprime, but the converse is not necessarily true.

Concept

Grantham's stated goal when developing the algorithm was to provide a test that primes would always pass and composites would pass with a probability of less than 1/7710.[1]:33

The test was later extended by Damgård and Frandsen to a test called Extended Quadratic Frobenius Test (EQFT).[2]

Algorithm

Let n be a positive integer such that n is odd, (b2 + 4c | n) = −1 and (−c | n) = 1, where (x | n) denotes the Jacobi symbol. Set B = 50000. Then a QFT on n with parameters (b, c) works as follows:

(1) Test whether one of the primes less than or equal to the lower of the two values ${\displaystyle B}$ and ${\displaystyle {\sqrt {n}}}$ divides n. If yes, then stop as n is composite.
(2) Test whether ${\displaystyle {\sqrt {n}}\in \mathbb {Z} }$. If yes, then stop as n is composite.
(3) Compute ${\displaystyle x^{n+1 \over 2}\,{\bmod {\,}}{\big (}n,x^{2}-bx-c)}$. If ${\displaystyle x^{n+1 \over 2}\notin \mathbb {Z} {\big /}n\mathbb {Z} }$ then stop as n is composite.
(4) Compute ${\displaystyle x^{n+1}\,{\bmod {\,}}{\big (}n,x^{2}-bx-c)}$. If ${\displaystyle x^{n+1}\not \equiv -c}$ then stop as n is composite.
(5) Let ${\displaystyle n^{2}-1=2^{r}s}$ with s odd. If ${\displaystyle x^{s}\not \equiv 1{\bmod {\,}}{\big (}n,x^{2}-bx-c)}$, and ${\displaystyle x^{2^{j}s}\not \equiv -1{\bmod {\,}}{\big (}n,x^{2}-bx-c)}$ for all ${\displaystyle 0\leq j\leq r-2}$, then stop as n is composite.

If the QFT doesn't stop in steps (1)–(5), then n is a probable prime.