{
  "aliases": [
    "rabin-miller-primality-test"
  ],
  "backlinks": null,
  "body": "\n## Summary\n\nThe Miller–Rabin test is a probabilistic [[primality test|0EGJZHZ02C]] for an odd integer $n \u003e 2$.\nWrite $n - 1 = 2^s d$ with $d$ odd, and choose a base $a$ with $1 \u003c a \u003c n - 1$.\nThe number $n$ passes for base $a$ if $a^d \\equiv 1 \\pmod n$, or if $a^{2^r d} \\equiv -1 \\pmod n$ for some $r$ with $0 \\le r \u003c s$.\nEach odd prime $n$ passes for each base. If $n$ fails for some base, then $n$ is composite.\n\n## Remarks\n\nThe prime case follows from [[Fermat's little theorem|0M25PRN3WQ]] and the fact that $\\pm 1$ are the only square roots of $1$ modulo a prime.\nIf $n$ is an odd composite number, then at most $\\frac{1}{4}$ of the bases let it pass. So $k$ random bases give an error probability of at most $4^{-k}$.\nGary Miller found the test in 1976, in a deterministic form that depends on the extended Riemann hypothesis. Michael Rabin made it an unconditional probabilistic test in 1980.\n\n## Explanations\n\n### L1 human\n\nThe test checks a property that every prime has, for a few random bases.\nA composite number fails for most bases, so a few rounds expose it with high probability.\nThe powers are fast to compute by [[modular exponentiation|04DR5PM25N]].\n",
  "commit": "545acf83a9b75c8ddc375ef8b23d2ae101a4d7e4",
  "front": {
    "aliases": [
      "rabin-miller-primality-test"
    ],
    "kind": "concept",
    "msc": [
      "11Y11"
    ],
    "name": "Miller–Rabin primality test",
    "same_as": {
      "wikidata": "Q980224",
      "wikipedia": "Miller–Rabin primality test"
    },
    "sources": [
      {
        "locator": "lead section",
        "url": "https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test"
      },
      {
        "locator": "Strong probable primes",
        "url": "https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test"
      }
    ],
    "tag": "0SZCSYHW60",
    "uses": [
      "0EGJZHZ02C",
      "0M25PRN3WQ",
      "04DR5PM25N"
    ]
  },
  "kind": "concept",
  "link": "https://math2.tamnd.com/node/0SZCSYHW60/",
  "links": [
    {
      "field": "uses",
      "target": "0EGJZHZ02C"
    },
    {
      "field": "uses",
      "target": "0M25PRN3WQ"
    },
    {
      "field": "uses",
      "target": "04DR5PM25N"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/0SZCSYHW60.md",
  "msc": [
    "11Y11"
  ],
  "name": "Miller–Rabin primality test",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/0SZ/0SZCSYHW60.md",
  "status": null,
  "tag": "0SZCSYHW60",
  "uri": "m2://0SZCSYHW60",
  "url": "https://math2.tamnd.com/wiki/miller-rabin-primality-test/",
  "writing": {
    "tag": "0SZCSYHW60",
    "kind": "concept",
    "level": "W1",
    "next": [
      {
        "what": "edge defines in",
        "note": "at least one definition",
        "have": 0,
        "want": 1
      },
      {
        "what": "edge instance_of in",
        "note": "at least two examples",
        "have": 0,
        "want": 2
      },
      {
        "what": "edge not_instance_of in",
        "note": "at least one non-example",
        "have": 0,
        "want": 1
      },
      {
        "what": "edge specializes both",
        "note": "the more general notions and the special cases",
        "have": 0,
        "want": 1
      }
    ]
  }
}
