$\newcommand\Q{\mathbb Q} \newcommand\Z{\mathbb Z}$I am a bit confused on the square root of 2-adics. I am pretty sure I am mixing some steps in an algorithm. To be precise, I am trying to solve an exercise in Koblitz' book p-adic numbers, p-adic analysis and zeta functions (this is not a homework, I just want to do it). In exercise of I.7 the reader is asked to solve the square root of -7 in $\Q_2$ up to 5-digits and the hint is to use a generalization of Hensel's Lemma:
Let $f(x)$ be a polynomial with coefficients in $\Z_p$. If $a_0$ in $\Z_p$ satisfies
- $f(a_0) = 0 \bmod p^{2m+1}$
- $f'(a_0) = 0 \bmod p^m$
- $f'(a_0) \ne 0 \bmod p^{m+1}$
then there is a unique $a\in\Z_p$ such that $f(a) = 0$ and $a=a_0 \bmod p^{m+1}$
Obviously the procedure to solve comes from an algorithm to be seen in the proof of this generalized Hensel's lemma. For my particular problem $f(x)=x^2+7$ and $p=2$, I choose $a_0$ either $1$ or $0$ (so in fact an integer) and then I iterate to get, for a chosen $b_1 =1$ or $b_1=0$, $a_1 = a_0 + b_1 p^{m+1}$ for which $f(a_1)=0 \bmod p^{2m+2}$ and so on i.e. I need to get $b_i$ which gives $a_i$ such that $f(a_i) = 0 \bmod p^{2m+1+i}$.
I might be missing something, but for me the answer for square root of -7 would be of the form $a_0 + b_12+ b_22^2 + \dots $ But I have a problem getting the correct answer. So one of the square root (using Pari to check) is $(a_0,b_1,b_2,\dots)=(1,1,0,1,0,\dots)$.
Is there a cleaner way to think of this algorithm. I get easily confused and make mistakes with the iteration steps.
Maybe I have mixed something in the procedure. Could someone explain to me why for $a_0=1$, we get $(1,1,0,1,0,\dots)$?
From this I feel that manually taking roots and even doing simple arithmetic is not practical in the p-adics.
EDIT: The algorithm I have in mind is actually also written here in this online calculator: http://www.numbertheory.org/php/2adic.html
I still fail to get the correct $b_4$ using the algorithm. However, the online calculator gives me the correct $b_4$. If I follow the procedure, my $b_4$ is $(a_3^2+7)/64 \bmod 2 = 7\bmod 2$ so it is $1$, while the correct answer is $0$.
OK I was finally able to get the correct answer. The site http://www.numbertheory.org/php/2adic.html provides a code for 2-adic square roots and I just looked at it and figured out my embarassing mistake.
I will write the steps. We want to get $(11010\dots)_2$ in 2-adics. We have $f(x) = x^2+7$ , $m=1$ and most importantly that $a_0=3$ (not $1$). This will give me one (unique) solution and if we start with $a_0=1$ we get the negative of that solution. We want $a_0=3$ because, we (or I) want to obtain $(11\dots)_2$ so it must start with $a_0=3$ rather than $a_0=1$ because in the other case we would obtain $(10\dots)_2$. So what I am trying to say is: my idea was correct but I started with the wrong $a_0$.
We can use Hensel's lemma because $f'(a_0)=6$ and $2\mid\mid 6$.
To get the digit after $(11)_2$ we use this algorithm: For the i-th step we want to choose $b_i$ such that $a_i = a_{i-1}+b_i2^{m+i}$ satisfies $f(a_i)=0 \bmod 2^{2m+i+1}$.
For $i=0$ (no steps here), $a_0=3$ , and $f(a_0)=3^2+7=16$
For $i=1$ (the third digit) we want to choose $b_1$ such that $a_1 = 3 + b_12^{1+1}$ satisfies $$f(a_1) = 0 \bmod 2^{2+1+1}$$ So $b_1=0$ and $a_0=a_1=3$.
For $i=2$ (the fourth digit) we want to choose $b_2$ such that $a_2 = 3 + b_22^{1+2}$ satisfies $$f(a_2) = 0 \bmod 2^{2+2+1}$$ So $b_2=1$ and $a_2 = 3+8=11$ with $f(a_2)=128$
For $i=3$ (the fifth digit) we want to choose $b_3$ such that $a_3=11 + b_32^4$ satisfies $$f(a_3) = 0 \bmod 2^6$$ So $b_3=0$ and so I got the correct five digits $11010$.
It is much easier to program this than to iterate by hand, because it is so easy to make this stupid mistake I made (at some point I was confused modulo what powers of $2$ I should check the $a_i$ and the $f(a_i)$). Also, I do not need to "cache" the roots modulo $2^k$ after $a_0=3$ or $a_0=1$.