Regarding output for $p$-adic expansion on PARI/GP

157 Views Asked by At

The input sqrt$(2+O(7^{10}))$ on PARI/GP yields the output:

$ 3 + 7 + 2*7^2 + 6*7^3 + 7^4 + 2*7^5 + 7^6 + 2*7^7 + 4*7^8 + 6*7^9 + O(7^{10}).$

Which is essentially the solution of the congruence $X^2 \equiv 2 \pmod 7^k $ for $k = 1, 2, 3, \cdots .$

My question is why don't we get the other solution of the congruence as output which is $4+5*7+6*7^2+ \cdots + O(7^{10})$?

1

There are 1 best solutions below

0
On

The pari/gp documentation for "transcendental functions" is here. (Alternatively, use ??sqrt to get it from the interpreter.)

There is a sqrt function for a complex argument documented first, this does not apply here. What applies is the next doc paragraph:

Intmod a prime $p$, t_PADIC and t_FFELT are allowed as arguments. In the first 2 cases (t_INTMOD, t_PADIC), the square root (if it exists) which is returned is the one whose first $p$-adic digit is in the interval [0,p/2]. For other arguments, the result is undefined.

So we obtain a result of the shape $3+O(7^1)$ since among the "digits modulo seven" the $3$ is the one $\le 7/2$. Not the $4$.

? sqrt(2 + O(7^10))
%1 = 3 + 7 + 2*7^2 + 6*7^3 + 7^4 + 2*7^5 + 7^6 + 2*7^7 + 4*7^8 + 6*7^9 + O(7^10)

It is easy to request also the other solution:

? -sqrt(2 + O(7^10))
%2 = 4 + 5*7 + 4*7^2 + 5*7^4 + 4*7^5 + 5*7^6 + 4*7^7 + 2*7^8 + O(7^10)

The answer is thus just a matter of implementation, and the decision taken this way.