Quadratic congruences assume the form $Ax^2 + Bx + C \equiv 0 \pmod m$, where $A \not\equiv 0 \pmod m$ (otherwise the congruence would be a linear congruence). We will learn methods to evaluate these quadratic congruences. However, we will first restrict our modulus m to being only an odd prime (3, 5, 7, 11, 13, …), or rather, any prime except 2.

First off, we know that there exists an inverse of A, A' (mod p) such that $AA' \equiv 1 \pmod p$, hence it thus follows that the congruence $Ax^2 + Bx + C \equiv 0 \pmod p$ has the solutions as:

(1)
\begin{align} x^2 + A'Bx + A'C \equiv 0 \pmod p \end{align}

## Example 1

Convert the coefficient of the term $x^2$ in the congruence $3x^2 + 5x + 7 \equiv 0 \pmod {11}$ into 1.

We can convert this coefficient into 1 by finding the inverse of 3 (mod 11). A modular inverse of 3 (mod 11) is 4. Hence it follows that $(4)3x^2 + (4)5x + (4)7 \equiv 4(0) \pmod {11}$, or rather that $x^2 + 20x + 28 \equiv 0 \pmod {11}$. Reducing the coefficients to least residues we obtain the following quadratic congruence:

(2)
\begin{align} x^2 + 9x +6 \equiv 0 \pmod {11} \end{align}

# Completing the Square for Quadratic Congruences.

For quadratic congruences in the form $x^2 + A'Bx + A'C \equiv 0 \pmod p$, if the term $A'B$ is even, then we can use the technique of "completing the square" to change the form of the quadratic congruence to:

(3)
\begin{align} \left ( x + \frac{A'B}{2} \right )^2 \equiv \left ( \frac{A'B}{2} \right )^2 - A'C \pmod p \end{align}

Now suppose that $A'B$ is odd. Since our prime p is restricted to being odd, then we can change the coefficient of x to be $p + A'B$, and thus transform the quadratic congruence to:

(4)
\begin{align} \left ( x + \frac{p + A'B}{2} \right )^2 \equiv \left ( \frac{p + A'B}{2} \right )^2 - A'C \pmod p \end{align}

In both cases, we have transformed the quadratic congruence into the form $y^2 \equiv d \pmod p$

## Example 2

Complete the square for the polynomial $x^2 -4x -4 = 0$.

Recognize that we can only complete the square for polynomials in the form of $ax + by + c = 0$, which is the form we have with $x^2 -4x -4 = 0$. We first take the coefficient, "b" and divide it by 2, to get -2. We then square this to get 4, and then add 4 and subtract 4 to get:

(5)
\begin{align} x^2 -4x +4 -4 -4 = 0 \\ x^2 -4x +4 -8 \\ \end{align}

Now we can complete the square to obtain:

(6)
$$(x - 2)^2 = 8$$

## Example 3

Complete the square for the quadratic congruence $3x^2 + 6x + 5 \equiv 0 \pmod 7$.

We will complete the square in the same manner as we did with example 2. First, add 7 to the constant 5 to obtain $3x^2 +6x + 12 \equiv 0 \pmod 7$. Now divide the entire lefthand side by 3 to obtain the congruence $x^2 + 2x + 4 \equiv 0 \pmod 7$. Now take the 2, divide it by 2 to get 1, square it to get 1, and add 1 and subtract 1 from the congruence to obtain:

(7)
\begin{align} x^2 + 2x + 4 \equiv 0 \pmod 7 \\ x^2 + 2x + 1 -1 +4 \equiv 0 \pmod 7 \\ x^2 + 2x + 1 +3 \equiv 0 \pmod 7 \\ (x + 1)^2 +3 \equiv 0 \pmod 7 \\ (x + 1)^2 \equiv -3 \pmod 7 \\ (x + 1)^2 \equiv 4 \pmod 7 \end{align}

We can also now find solutions. Notice that x = 1 and x = 4 are solutions to this quadratic congruence.

# Theorem 1: If p is an odd prime and p ∤ a, then the quadratic congruence x2 ≡ a (mod p) has exactly 2 solutions or 0 solutions.

• Proof: Suppose that the congruence has a solution r, that is $r^2 \equiv a \pmod p$. Then p-r must also be a solution since:
(8)
\begin{align} (p - r)^2 \equiv a \pmod p \\ p^2 - 2pr + r^2 \equiv a \pmod p \\ r^2 \equiv a \pmod p \end{align}
• Also note that p - r ≠ r. If p = r, then $r \equiv p - r \pmod p$, or rather $2r \equiv 0 \pmod p$ and then $r \equiv 0 \pmod p$. But p is an odd prime, so this cannot be true since $(2, p) = 1$.
• Now suppose that s is a solution. It thus follows that $r^2 \equiv s^2 \pmod p$, so by the definition of a congruence, $p \: \mid \: r^2 - s^2$ and $p \: \mid \: (r + s)(r - s)$, so either $p \: \mid \: (r + s)$ or $p \: \mid \: (r - s)$.
• If $p \: \mid \: (r + s)$, then $s \equiv -r \pmod p$, or rather $s \equiv p - r \pmod p$.
• If $p \: \mid \: (r - s)$, then $s \equiv r \pmod p$.
• s, r, and p - r are all least residues. Hence s = r or s = p - r, which are the only solutions to the quadratic congruence.
 Note: Theorem 1 is true when the modulus is an odd prime! If the modulus is not an odd prime, then the quadratic congruence may have more than precisely 2 solutions!