# Square roots in the $p$-adics

Suppose I want to know whether $\sqrt{7}\in\mathbb{Q}_5$, or more generally, whether $\sqrt{n}\in\mathbb{Q}_p$ for $n\in\mathbb{Z}$, $p$ an odd prime. What are the techniques for determining this? Am I supposed to "lift" it from $\mathbb{Z}/p\mathbb{Z}$ using Hensel's lemma? Could I see an example?

-
First you should check if there even is a square root mod $p$. Doesn't whatever book you are reading have a worked example? –  KCd Dec 5 '11 at 7:29
The book we're using assumes I already know lots about them, which I do not. –  Nick Dec 5 '11 at 7:46
It only shows what to do for $\mathbb{Q}_2$ and then goes on to Hasse-Minkowski. –  Nick Dec 5 '11 at 7:55
Come to think of it, what is a good book for learning about the p-adics? Preferably one that assumes only 1 year of undergrad algebra. –  Nick Dec 5 '11 at 8:28
@Nick There are introductory books by Gouvêa and Koblitz which are worth a look. –  Dylan Moreland Dec 5 '11 at 8:50

Suppose $(n,p) = 1$ and $n$ is a square mod $p$, so the square root in ${\mathbb Q}_p$ should exist. One quick way to explicitly find good approximations of it is Newton's method. The iteration is $x_{k+1} = \frac{x_k + n/x_k}{2}$ where $x_0$ is an integer with $n \equiv x_0^2 \mod p$. Then $x_{k+1}^2 - n = (x_k - n)^2/4$ so $\|x_{k+1}^2 - n\|_p = \|x_k^2 - n\|_p^2$. Since $\|x_0^2 - n\|_p \le p^{-1}$ we get $\|x_k^2 - n\|_p \le p^{-2^k}$. For example, with $n=5$ and $p=11$, taking $x_0 = 4$ we have $x_1 = (4 + 5/4)/2 = 21/8 = 4 + 4 \cdot 11 + O(11^2)$, $x_2 = 761/336 = 4 + 4 \cdot 11 + 10 \cdot 11^2 + 4 \cdot 11^3 + O(11^4)$, $x_3 = 1143601/511392 = 4 + 4 \cdot 11 + 10 \cdot 11^2 + 4 \cdot 11^3 + 9 \cdot 11^5 + 5 \cdot 11^6 + 8 \cdot 11^7 + O(11^8)$, etc.

-

Yes, this is a direct application of Hensel's lemma.

By definition, ${\sqrt q} \in \mathbf{Z}_p$, if and only if the polynomial $f(x)=x^2-q$ splits in $\mathbf{Z}_p$.

In particular, $f$ must have a root $\alpha$ mod $p$, which is a quadratic residue of $p$. It cannot be a double root because $f'(x)=2x$ and $p\neq 2$, $\alpha\neq 0$. Hence by Hensel's lemma, $\alpha$ lifts to a root $\alpha'$ of $f$ in $\mathbf{Z}_p$. Thus the primes which split in $\mathbf{Z}_p$ are the quadratic residues of $p$.

I'll let you determine for general $n$... :-)

-
OK, one more thing, how might I actually write down the answer for a specific $n$ and $p$? Suppose I know that $\sqrt{2}\in\mathbb{Q}_7$ for example. How can I express $\sqrt{2}$ as $\sum_{i=-n}^{\infty}a_i 7^i$ for some $a_i\in\mathbb{Z}/7\mathbb{Z}$? –  Nick Dec 5 '11 at 7:59
@Nick As $3^2\equiv 2\pmod 7$, you can set $n=0$ (this because you never need to leave the 7-adic integers here), and $a_0=3$. From that point on you work out the next digits one at a time. Two remarks: 1) The digits $a_i$ really come from the set $\{0,1,2,3,4,5,6\}$ - not the quotient group $\mathbf{Z}/7\mathbf{Z}$. 2) Don't expect a closed formula for $a_i$. After all, the decimal expansion of $\sqrt2$ has no pattern either. –  Jyrki Lahtonen Dec 5 '11 at 8:32
You can use the Binomial Series to get a formula for $(1+7a)^{1/2}$ when $a$ is a $7$-adic integer, then apply it to $a=-1/9$ to get the square root of $2/9$. Multiply this by $3$ and there you are. –  Lubin Jan 16 '12 at 20:20