ArticleslgStudy

science

AKS primality test

AKS primality test is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand AKS primality test rather than just read about it. In short: The Agrawal–Kayal–Saxena primality test (also known as the AKS primality test and the cyclotomic AKS test) is a deterministic primality-proving algorithm created and published by Manindra Agrawal, Neeraj Kayal, and Nitin Saxena, computer scientists at the Indian Institute of Technology Kanpur, on August 6, 2002, in an article titled "PRIMES is in P". The algorithm was the first one which is able to determine in poly…

Key takeaways

  • AKS primality test belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect AKS primality test to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of AKS primality test from memory before moving on to harder problems.

Reference excerpt

The Agrawal–Kayal–Saxena primality test (also known as the AKS primality test and the cyclotomic AKS test) is a deterministic primality-proving algorithm created and published by Manindra Agrawal, Neeraj Kayal, and Nitin Saxena, computer scientists at the Indian Institute of Technology Kanpur, on August 6, 2002, in an article titled "PRIMES is in P". The algorithm was the first one which is able to determine in polynomial time, whether a given number is prime or composite without relying on mathematical conjectures such as the generalized Riemann hypothesis. The proof is also notable for not relying on the field of analysis. In 2006 the authors received both the Gödel Prize and Fulkerson Prize for their work.

Importance AKS is the first primality-proving algorithm to be simultaneously general, polynomial-time, deterministic, and unconditionally correct. Previous algorithms had been developed for centuries and achieved three of these properties at most, but not all four.

The AKS algorithm can be used to verify the primality of any general number given. Many fast primality tests are known that work only for numbers with certain properties. For example, the Lucas–Lehmer test works only for Mersenne numbers, while Pépin's test can be applied to Fermat numbers only. The maximum running time of the algorithm can be bounded by a polynomial over the number of digits in the target number. ECPP and APR conclusively prove or disprove that a given number is prime, but are not known to have polynomial time bounds for all inputs. The algorithm is guaranteed to distinguish deterministically whether the target number is prime or composite. Randomized tests, such as Miller–Rabin and Baillie–PSW, can test any given number for primality in polynomial time, but are known to produce only a probabilistic result. The correctness of AKS is not conditional on any subsidiary unproved hypothesis. In contrast, Miller's version of the Miller–Rabin test is fully deterministic and runs in polynomial time over all inputs, but its correctness depends on the truth of the generalized Riemann hypothesis, which had not been proved at that time. While the algorithm is of immense theoretical importance, it is not used in practice, rendering it a galactic algorithm. For 64-bit inputs, the Baillie–PSW test is deterministic and runs many orders of magnitude faster. For larger inputs, the performance of the (also unconditionally correct) ECPP and APR tests is far superior to AKS. Additionally, ECPP can output a primality certificate that allows independent and rapid verification of the results, which is not possible with the AKS algorithm.

Concepts The AKS primality test is based upon the following theorem: Given an integer n≥2 and integer a coprime to n, n is prime if and only if the polynomial congruence relation

holds within the polynomial ring (ℤ/nℤ)[X]. Note that X denotes the indeterminate which generates this polynomial ring. This theorem is a generalization to polynomials of Fermat's little theorem. In one direction it can easily be proved using the binomial theorem together with the following property of the binomial coefficient:

(nk)≡0(modn) for all 0<k<n if n is prime. While the relation (1) constitutes a primality test in itself, verifying it takes exponential time: the brute force approach would require the expansion of the (X+a)n polynomial and a reduction mod⁡n of the resulting n+1 coefficients. The congruence is an equality in the polynomial ring (ℤ/nℤ)[X]. Evaluating in a quotient ring of (ℤ/nℤ)[X] creates an upper bound for the degree of the polynomials involved. The AKS evaluates the equality in (ℤ/nℤ)[X]/(Xr−1), making the computational complexity dependent on the size of r. For clarity, this is expressed as the congruence

which is the same as:

for some polynomials f and g. Note that all primes satisfy this relation (choosing g=0 in (3) gives (1), which holds for n prime). This congruence can be checked in polynomial time when r is polynomial to the digits of n. The AKS algorithm evaluates this congruence for a large set of a values, whose size is polynomial to the digits of n. The proof of validity of the AKS algorithm shows that one can find an r and a set of a values with the above properties such that if the congruences hold then n is a power of a prime.

History and running time In the first version of the above-cited paper, the authors proved the asymptotic time complexity of the algorithm to be O~(log⁡(n)12) (using Õ from big O notation)—the twelfth power of the number of digits in n times a factor that is polylogarithmic in the number of digits. However, this upper bound was rather loose; a widely-held conjecture about the distribution of the Sophie Germain primes would, if true, immediately cut the worst case down to O~(log⁡(n)6). In the months following the discovery, new variants appeared (Lenstra 2002, Pomerance 2002, Berrizbeitia 2002, Cheng 2003, Bernstein 2003a/b, Lenstra and Pomerance 2003), which improved the speed of computation greatly. Owing to the existence of the many variants, Crandall and Papadopoulos refer to the "AKS-class" of algorithms in their scientific paper "On the implementation of AKS-class primality tests", published in March 2003. In response to some of these variants, and to other feedback, the paper "PRIMES is in P" was updated with a new formulation of the AKS algorithm and of its proof of correctness. (This version was eventually published in Annals of Mathematics.) While the basic idea remained the same, r was chosen in a new manner, and the proof of correctness was more coherently organized. The new proof relied almost exclusively on the behavior of cyclotomic polynomials over finite fields. The new upper bound on time complexity was O~(log⁡(n)10.5), later reduced using additional results from sieve theory to O~(log⁡(n)7.5). In 2005, Pomerance and Lenstra demonstrated a variant of AKS that runs in O~(log⁡(n)6) operations, leading to another updated version of the paper. Agrawal, Kayal and Saxena proposed a variant which would run in O~(log⁡(n)3) if Agrawal's conjecture were true; however, a heuristic argument by Pomerance and Lenstra suggested that it is probably false.

The algorithm The algorithm is as follows:

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with AKS primality test

Start with the simplest possible case. Write down what AKS primality test claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to AKS primality test before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about AKS primality test ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of AKS primality test

In research
AKS primality test appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses AKS primality test in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
AKS primality test is common in secondary-school and first-year university syllabi. It links to neighbouring topics Finite fields, Indian inventions, Primality tests, so understanding it makes those chapters shorter.
In everyday life
Look for AKS primality test outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “AKS primality test” →

How to study AKS primality test in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what AKS primality test means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain AKS primality test out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is AKS primality test in simple terms?

The Agrawal–Kayal–Saxena primality test (also known as the AKS primality test and the cyclotomic AKS test) is a deterministic primality-proving algorithm created and published by Manindra Agrawal, Neeraj Kayal, and Nitin Saxena, computer scientists at the Indian Institute of Technology Kanpur, on A…

Why does AKS primality test matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study AKS primality test?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on AKS primality test.

Tags

  • Finite fields
  • Indian inventions
  • Primality tests

Keep exploring