3
$\begingroup$

Using the quadratic formula, we have either 0, 1, or 2 solutions. I wonder if we could use it this formula for congruence? Or is there a formula to solve quadratic equation for congruence?

Edit Assume that $ax^2 + bx + c \equiv 0 \pmod{p}$, where $p$ is prime with $(a, p) = 1$, then is there a formula for this equation?

Thanks,

$\endgroup$
3
  • 3
    $\begingroup$ Yes: if $p\gt 2$, then you can just use the quadratic formula, suitably interpreted: "dividing" by $2a$ means multiplying by the modular inverse of $2a$ modulo $p$; and $\sqrt{b^2-4ac}$ means any modular class whose square is congruent to $b^2-4ac$ modulo $p$, if such exists. If there is no such modular class, then the quadratic is irreducible modulo $p$. If $p=2$, then you get no solutions if all of $a$, $b$, and $c$ are odd; you get a single double solution $x=1$ if $a$ and $c$ are odd, $b$ even; both $x=0,1$ if $b$ odd, $c$ even; and a single double $x=0$ solution if $b,c$ even. $\endgroup$ Apr 4, 2011 at 2:44
  • $\begingroup$ @Arturo Magidin: Thank you. I got it. $\endgroup$
    – roxrook
    Apr 4, 2011 at 2:55
  • $\begingroup$ Regarding the modulus $\rm\:p=2\:$ see the Parity Root Test. $\endgroup$ Apr 4, 2011 at 3:42

3 Answers 3

4
$\begingroup$

If $n = p$ is prime, the situation is straightforward. When $p = 2$ there are a small number of cases, and when $p > 2$ the quadratic formula holds. (Note that the quadratic formula fails when $p = 2$ because you can't divide by $2$. This is because you can't complete the square $\bmod 2$.)

If $n$ is composite, the situation is more complicated. $x$ is a solution if and only if $x$ is a solution $\bmod p^k$ for every prime power factor of $n$ by the Chinese Remainder Theorem, so in particular if, say, $n$ is a product of $k$ distinct primes there can be as many as $2^k$ solutions obtained by combining roots modulo the prime factors of $n$.

After the above step the problem reduces to the prime power case $n = p^k$. In this case the question of what solutions look like is completely answered by Hensel's lemma. Again the case $p = 2$ is special.

$\endgroup$
5
  • $\begingroup$ @Quiaochu Yuan: Thank you. How about if $(a, p) = 1$, is it a special case? $\endgroup$
    – roxrook
    Apr 4, 2011 at 2:35
  • 1
    $\begingroup$ @Chan: if $p > 2$ and $n = p^k$ then each solution $\bmod p$ can be uniquely extended to a solution $\bmod n$ by Hensel's lemma. If $p = 2$ then I think one needs to look at solutions $\bmod 8$. $\endgroup$ Apr 4, 2011 at 2:38
  • $\begingroup$ @Chan: Did you mean $(a,p)=p$? When $(a,p)=1$, you are in the "easy" case, because $a$ is invertible modulo $p$ so you can divide by $2a$. $\endgroup$ Apr 4, 2011 at 2:38
  • $\begingroup$ @Quiaochu Yuan: Thank you. $\endgroup$
    – roxrook
    Apr 4, 2011 at 2:53
  • $\begingroup$ @Arturo Magidin: I meant $(a, p) = 1$. I remember now, the "invertible part". Many thanks ;) $\endgroup$
    – roxrook
    Apr 4, 2011 at 2:54
1
$\begingroup$

The quadratic formula works just as well modulo n as long as $(2a,n) = 1$ and $b^2-4ac$ is a quadratic residue mod n. If either of those conditions do not hold, then there are no solutions.

Edit: as pointed out in the comments, this is not a complete answer; see Qiaochu Yuan's for a much better one.

$\endgroup$
9
  • 1
    $\begingroup$ @Harry Stern: Thank you. That was exactly what I thought initially. $\endgroup$
    – roxrook
    Apr 4, 2011 at 1:54
  • $\begingroup$ @Chan I'm glad I could be helpful! $\endgroup$ Apr 4, 2011 at 2:00
  • $\begingroup$ @Harry: That's false, e.g. $\rm\ m\ n\ x^2 + x\ $ has root $\rm x = 0\ (mod\ n)\ $ and $\rm\ (2a,n) = (2\ m\ n,\ n) = n > 1\:$ for $\rm\:n>1\:.$ Also there can be arbitrarily many roots for composite $\rm\:n\:.$ $\endgroup$ Apr 4, 2011 at 2:02
  • $\begingroup$ @Harry Stern: It is absolutely helpful. Great thanks ;) $\endgroup$
    – roxrook
    Apr 4, 2011 at 2:02
  • 1
    $\begingroup$ This answer is incomplete when $n$ is composite. As Bill Dubuque says, there can be arbitrarily many roots for composite $n$ because we can combine pairs of roots modulo the prime factors of $n$ by CRT. $\endgroup$ Apr 4, 2011 at 2:12
1
$\begingroup$

Here (link) is a thorough discussion of the steps in reducing general moduli quadratic equation problems to those of prime moduli, including the case $p=2$.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .