ArticleslgStudy

science

Miller–Rabin primality test

Miller–Rabin 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 Miller–Rabin primality test rather than just read about it. In short: The Miller–Rabin primality test or Rabin–Miller primality test is a probabilistic primality test: an algorithm which determines whether a given number is likely to be prime, similar to the Fermat primality test and the Solovay–Strassen primality test. It is of historical significance in the search for a polynomial-time deterministic primality test.

Key takeaways

  • Miller–Rabin 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 Miller–Rabin primality test to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Miller–Rabin primality test from memory before moving on to harder problems.

Reference excerpt

The Miller–Rabin primality test or Rabin–Miller primality test is a probabilistic primality test: an algorithm which determines whether a given number is likely to be prime, similar to the Fermat primality test and the Solovay–Strassen primality test. It is of historical significance in the search for a polynomial-time deterministic primality test. Its probabilistic variant remains widely used in practice, as one of the simplest and fastest tests known. Gary L. Miller discovered the test in 1976. Miller's version of the test is deterministic, but its correctness relies on the unproven extended Riemann hypothesis. Michael O. Rabin modified it to obtain an unconditional probabilistic algorithm in 1980.

Mathematical concepts Similarly to the Fermat and Solovay–Strassen tests, the Miller–Rabin primality test checks whether a specific property, which is known to hold for prime values, holds for the number under testing.

Strong probable primes The property is the following. For a given odd integer n > 2 {\displaystyle n>2} , let’s write n − 1 {\displaystyle n-1} as 2 s d {\displaystyle 2^{s}d} where s {\displaystyle s} is a positive integer and d {\displaystyle d} is an odd positive integer. Let’s consider an integer a {\displaystyle a} , called a base, which is coprime to n {\displaystyle n} . Then, n {\displaystyle n} is said to be a strong probable prime to base a if one of these congruence relations holds:

a d ≡ 1 ( mod n ) {\displaystyle a^{d}\equiv 1\!\!\!{\pmod {n}}} , or

a 2 r d ≡ − 1 ( mod n ) {\displaystyle a^{2^{r}d}\equiv -1\!\!\!{\pmod {n}}} for some 0 ≤ r < s {\displaystyle 0\leq r<s} . This simplifies to first checking for a d ≡ 1 ( mod n ) {\displaystyle a^{d}\equiv 1{\pmod {n}}} and then a 2 r d ≡ n − 1 ( mod n ) {\displaystyle a^{2^{r}d}\equiv n-1{\pmod {n}}} for successive values of r {\displaystyle r} . For each value of r {\displaystyle r} , the value of the expression may be calculated using the value obtained for the previous value of r {\displaystyle r} by squaring under the modulus of n {\displaystyle n} . The idea beneath this test is that when n {\displaystyle n} is an odd prime, it passes the test because of two facts:

by Fermat's little theorem, a n − 1 ≡ 1 ( mod n ) {\displaystyle a^{n-1}\equiv 1{\pmod {n}}} (this property alone defines the weaker notion of probable prime to base a {\displaystyle a} , on which the Fermat test is based); the only square roots of 1 modulo n {\displaystyle n} are 1 and −1. Hence, by contraposition, if n {\displaystyle n} is not a strong probable prime to base a {\displaystyle a} , then n {\displaystyle n} is definitely composite, and a {\displaystyle a} is called a witness for the compositeness of n {\displaystyle n} . However, this property is not an exact characterization of prime numbers. If n {\displaystyle n} is composite, it may nonetheless be a strong probable prime to base a {\displaystyle a} , in which case it is called a strong pseudoprime, and a {\displaystyle a} is a strong liar.

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Miller–Rabin primality test

Start with the simplest possible case. Write down what Miller–Rabin 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 Miller–Rabin 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 Miller–Rabin 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 Miller–Rabin primality test

In research
Miller–Rabin 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 Miller–Rabin 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
Miller–Rabin primality test is common in secondary-school and first-year university syllabi. It links to neighbouring topics Finite fields, Primality tests, so understanding it makes those chapters shorter.
In everyday life
Look for Miller–Rabin 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 “Miller–Rabin primality test” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Miller–Rabin primality test in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Miller–Rabin 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 Miller–Rabin primality test out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Miller–Rabin primality test in simple terms?

The Miller–Rabin primality test or Rabin–Miller primality test is a probabilistic primality test: an algorithm which determines whether a given number is likely to be prime, similar to the Fermat primality test and the Solovay–Strassen primality test. It is of historical significance in the search…

Why does Miller–Rabin 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 Miller–Rabin 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 Miller–Rabin primality test.

Tags

  • Finite fields
  • Primality tests

Keep exploring