Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is known about the computational complexity of primality testing in $\mathcal{O}_{\mathbb{Q}(\sqrt{d})}$ where $d$ is a square-free number? For what values of $d$ is primality testing easy (i.e., can be determined in polynomial time)?

share|cite|improve this question
You mean in the ring of integers of a quadratic number field? – Qiaochu Yuan Dec 19 '11 at 17:35
Yes, sorry. I have edited my question—hopefully it is clearer now. – Zach Langley Dec 19 '11 at 17:39
$\mathbb{Z}[\sqrt{d}]$ isn't the full ring of integers if $d \equiv 1 \bmod 4$. – Qiaochu Yuan Dec 19 '11 at 17:43
up vote 6 down vote accepted

For $K = \mathbb{Q}(\sqrt{d})$, primality testing in $\mathcal{O}_K$ reduces to primality testing of integers. It's known that the prime elements $\alpha \in \mathcal{O}_K$ are either

  • elements whose norms $N(\alpha)$ are prime, or
  • elements whose norms $N(\alpha)$ are squares of a prime $p$ such that $\left( \frac{d}{p} \right) = -1$.

(A slight modification is necessary in the case that $d \equiv 1 \bmod 4$ and $N(\alpha) = 4$. In that case $\alpha$ is prime if and only if $\frac{d-1}{4}$ is odd.)

The first condition can be tested for in polynomial time by the AKS primality test. The second condition can be tested for in polynomial time by AKS and quadratic reciprocity.

share|cite|improve this answer
If you don't mind me asking, is there a result stating this? Could you perhaps point me in the right direction? Thanks in advance. – Siddharth Prasad Jan 28 '14 at 1:55
@Siddharth: probably this result can be found in most textbooks on algebraic number theory, possibly as an exercise. – Qiaochu Yuan Jan 28 '14 at 2:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.