For any odd prime $p$, a quadratic is solvable mod $p^2$ if it is solvable mod $p$, and $p$ does not divide the discriminant and leading coefficient.

Let $p$ be an odd prime number and $a$, $b$ and $c$ integers such that $p$ does not divide $a$, and does not divide $D=b^2-4ac$, and such that $$ax^2+bx+c\equiv0\pmod{p},$$ is solvable. Prove that in this case $ay^2 + by + c \equiv 0 \mod p^2$ is solvable too.

Well, the only thing that I was able to do is get $D$ from quadratic equation:

\begin{eqnarray*} ax^2 + bx + c &=& a(x^2 + bx/a) + c\\ & =& a(x^2 + 2\cdot b/2a + (b/2a)^2) - a(b/2a)^2 + c\\ &=&a(x + b/2a)^2 - \left(\frac{b^2 - 4ac}{4a}\right)\\ &=& a(x + b/2a)^2 - \left(\frac{D}{4a}\right) \end{eqnarray*} Since $D$ is not divisible by $p$, $D/4a$ is not divisible by $p$ too. So in order to make this equation true remainders of both $\frac{D}{4a}$ and $a(x + b/2a)^2$ should be equal to each other. Let us say that it is $r_1$.

Okay, then let $a(x + b/2a)^2$ be $p\cdot k + r_1$ and $D/4a = p \cdot m + r_1$. But can't move on with this proof. I tried several paths but all of them didn't lead me anywhere.

Your help will be much appreciated!


Let $p$ be an odd prime number and $a$, $b$ and $c$ integers such that $p\nmid a$ and $p\nmid D$, where $D=b^2-4ac$. Let $x$ be an integer such that $$ax^2+bx+c\equiv0\pmod{p},\tag{1}$$ so $ax^2+bx+c=mp$ for some integer $m$.

Exercise: Show that $p$ does not divide $2ax+b$, because $p\nmid a$ and $p\nmid D$ and $p$ is odd.

If $2ax+b\equiv0\pmod{b}$ then because $p$ is odd and $p\nmid a$ we have $$x\equiv-b(2a)^{-1}\pmod{p}.$$ Plugging this into $(1)$ yields \begin{eqnarray*} 0&\equiv&a(-b(2a)^{-1})^2+b(-b(2a)^{-1})+c\\ &\equiv&(2a)^{-2}(ab^2-2ab^2+4a^2c)\\ &\equiv&(2a)^{-2}(-aD), \end{eqnarray*} contradicting the fact that $p\nmid a$ and $p\nmid D$ and $p$ is odd.

Now if $y$ is an integer such that $$ay^2+by+c\equiv0\pmod{p}^2,\tag{2}$$ then reducing mod $p$ shows that $y$ is a solution to $(1)$. So it makes sense to suppose that $y=x+kp$ for some integer $k$. Then \begin{eqnarray*} ay^2+by+c&=&a(x+kp)^2+b(x+kp)+c\\ &=&(ax^2+bx+c)+(2ax+b)kp+ak^2p^2\\ &=&((2ax+b)k+m)p+ak^2p^2 \end{eqnarray*} We see that $y$ satisfies $(2)$ if and only if $$(2ax+b)k+m\equiv0\pmod{p}.$$ Now because $2ax+b\not\equiv0\pmod{p}$ we are be done by taking $$k\equiv-m(2ax+b)^{-1}\pmod{p}.$$


Conceptually: $\bmod p\!:\, $ the discriminant $\,D\not\equiv 0\Rightarrow\, r\,$ is not a double root, so $\,\color{#c00}{f'(r)\not\equiv 0},\,$ so Newton's method (Hensel's Lemma) improves (lifts) a root approximation $\!\bmod p\,$ to $\!\bmod p^2,\,$ i..e

completing the square: $\,4af(x) = (2ax+b)^2 -\, D,\ \ \,D = b^2-4ac$

Therefore, $\bmod p\!:\ f(r)\equiv 0\,\Rightarrow\, (2ar\!+b)^2\equiv D\not\equiv 0\,\Rightarrow\,2ar+b\not\equiv 0$

i.e. $\,\color{#c00}{f'(r)\not\equiv 0}\,$ so Newton's method applies - lifting $\,r\,$ to a root $\bmod p^2$ as below (for $\,k,n\!=\!1)$.

Hensel's Lemma $ $ Suppose that $\,1\le n\le k\,$ are both integers and the polynomial $ \:f(x) \in \mathbb Z[x].\,$ If $\, f(r)\equiv 0\pmod{p^k}\,$ and $\,\color{#c00}{p\nmid f'(r)},\, $ then the root $\,r\,$ uniquely lifts to a root $\,\hat r \pmod{p^{k+n}},\,$ i.e. there exists $\,\hat r \equiv r\pmod{p^k}\,$ with $\,f(\hat r)\equiv 0\pmod{p^{k+n}}$ and $\,\hat r\,$ is unique $\bmod {p^{k+n}},\,$ viz.

$\qquad \begin{align}\bmod p^{k+n}\!:\ \ f(\hat r)\equiv 0\iff\hat r\,&\equiv\ r-p^k\left(\dfrac{f(r)/p^k}{\color{#c00}{f'(r)}}\bmod p^n \right)\\[.2em] & \equiv\ r \ -\ f(r) \left( \dfrac{1}{\color{#c00}{f'(r)}}\bmod p^n\right)\end{align}$

Proof $\ $ By Taylor, $ \ 0\equiv f(\hat r)\equiv f(r\!+qp^k) \equiv f(r) + f'(r)\, qp^k \,\pmod{\!p^{k+n}}\,$

$ \qquad \iff p^{k+n}\mid p^k\,(f(r)/p^k + f'(r)q)\iff p^n\mid f(r)/p^k + f'(r)\, q$

By $ \: \color{#c00}{p\nmid f'(r)}\:$ this has a unique solution $\ q \equiv -(f(r)/p^k)/ \color{#c00}{f'(r)}\,\pmod {p^n}$