2
$\begingroup$

Given integers $n$ and $k$, find the number of quadratic congruences of the form $$ ax^2 + bx + c \equiv 0 \pmod{n} $$ having exactly $k$ solutions in $\mathbb{Z}_n$, where $a, b, c \in \mathbb{Z}_n$.

I could only find a formula for the case $n$ is a prime number but failed to derive one for the composite case.

Here is my attempt for the case $n = p$, where $p$ is a prime number.

The case $p = 2$ is pretty trivial. For $k = 0$, there are 2 congruences, 4 congruences when $k = 1$ and 2 congruences having 2 solutions. The following will consider the case $p$ is an odd prime.

For $a \equiv 0 \pmod{p}$, the congruence becomes $bx + c \equiv 0 \pmod{p}$. If $b \equiv 0 \pmod{p}$ then the congruence will have 0 solutions if $c \not \equiv 0 \pmod{p}$ and $p$ solutions otherwise. If $b \not \equiv 0 \pmod{p}$ then $\gcd(b, p) = 1$, which implies a unique solution $x \equiv -b^{-1}c \pmod{p}$.

This case contributes one congruence for $k = p$ and $p(p - 1)$ congruences for $k = 1$.

Now, for $a \not \equiv 0 \pmod{p}$, the congruence becomes $(2ax + b)^2 \equiv b^2 - 4ac \pmod{p}$. Let $\Delta \equiv b^2 - 4ac \pmod{p}$, then there will be no solution if $\Delta$ is a quadratic non-residue of $p$. Otherwise, if $\Delta \equiv 0 \pmod{p}$ then $2ax + b \equiv 0 \pmod{p}$, which has an unique solution $x \equiv -(2a)^{-1}b \pmod{p}$ since $\gcd(a, p) = 1$. As $b^2 \equiv 4ac \pmod{p}$, we can determine an unique $c$ for every $a$ and $b$ because $c \equiv (4a)^{-1}b^2 \pmod{p}$, thus, this case contributes $p(p - 1)$ congruences for $k = 1$. The final case is $\Delta \not \equiv 0 \pmod{p}$, i.e. non-zero quadratic residue of $p$, which yields 2 solutions $x \equiv (2a)^{-1}\left(b \pm \sqrt{\Delta}\right) \pmod{p}$. Now, $c \equiv (4a)^{-1}\left(b^2 - \Delta\right) \pmod{p}$, there are $\dfrac{p - 1}{2}$ choices for $\Delta$, $p - 1$ choices for $a$ and $p$ choices for $b$, which implies a total of $\dfrac{p(p - 1)^2}{2}$ congruences.

Combining the above cases, we obtain \begin{array}{cl} \text{1 solution}: & 2p(p - 1)\\ \text{2 solutions}: & \dfrac{p(p - 1)^2}{2}\\ \text{p solutions}: & 1\\ \text{0 solution}: & p^3 - 1 - 2p(p - 1) - \dfrac{p(p - 1)^2}{2}\\ \text{Others}: & 0 \end{array}

Then, I attempted to solve for composite $n$ using a similar approach but failed to proceed since $b$ and $a$ are not always coprime to $n$. I also tried CRT but it was wrong.

I also tried brute-forcing the problem to see if there are any notable patterns but failed to detect anything besides those $k$'s that have at least one congruence divides $n$ (aside from $k = 2$).

Brute-force approach

How can I proceed and obtain similar results for composite $n$?

Thank you in advance.

$\endgroup$
4
  • 2
    $\begingroup$ Hensel's lemma gives you a way to go from solutions mod p to solutions mod $p^k$, then you can count solutions with the CRT by seeing every possible way of combining the solutions each power of prime. $\endgroup$
    – Merosity
    Commented Dec 4, 2021 at 0:30
  • $\begingroup$ @Merosity: I actually want to count the number of congruences, not solutions but I will try Hensel’s lemma, thanks for suggesting. $\endgroup$
    – KM02
    Commented Dec 4, 2021 at 5:44
  • 1
    $\begingroup$ Why is $ a^2 + bx + c \equiv 0 \pmod{n}$ quadratic? Do you mean $a\color{red}{x^2}+bx+c\equiv 0\pmod n$ ? $\endgroup$
    – mathlove
    Commented Dec 6, 2021 at 16:33
  • $\begingroup$ @mathlove: ah yes, I mistyped that, thank you for pointing it out. $\endgroup$
    – KM02
    Commented Dec 6, 2021 at 17:06

0

You must log in to answer this question.