TITLE: Method of finding a p-adic expansion to a rational number
QUESTION [14 upvotes]: Could someone go though the method of finding a p-adic expansion of say $-\frac{1}{6}$ in $\mathbb{Z}_7?$

REPLY [2 votes]: The long division approach works, but I find that I prefer a more general version of the power series approach. In the given example, not all steps of the algorithm are apparent, but we can look at a more "full featured" case, free of simplifying coincidences.
Suppose we want a $7$-adic expansion of $\frac{128}{9}$. We first have to find some (preferably minimal) power of $7$ that is congruent to $1$, modulo $9$.
If we know a bit of elementary number theory, we realize that we are asking for the multiplicative order of $7$ in the units group, modulo $9$. Since the order of that group is $6$, the order of any element is a divisor of $6$: either $1$, $2$, $3$, or $6$. We check $7^2=49$ and $7^3=343$, and indeed the latter satisfies $7^3=38\cdot 9+1$. (If neither of them had worked, then $7^6$ definitely would have, by Lagrange's theorem on orders of subgroups.)
Now, we write our rational $\frac{128}9$ as a difference from the closest integer above it, and make $1$ minus a power of $7$ appear in the denominator. The reason we want to do that is because powers of $7$ are "small" in the $7$-adic metric. We'll also pull any factors of $7$ that we can out of the numerator:
$$\frac{128}{9} = 15-\frac{7}{9} = 15-7\left(\frac19\right) = 15-7\left(\frac{38}{342}\right) = 15+7\left(\frac{38}{1-7^3}\right)$$
$$=15+7\cdot 38\left(1+7^3+\left(7^3\right)^2+\cdots\right)$$
Now we can pretty much write down the 7-adic expansion completely. The power series is in the third power of $7$, so the repeating part of the expansion has period $3$. What's repeated in each occurrence of those three digits is $38$ in base $7$, i.e., "$053$". The repeating pattern "$\ldots 053053053.$" is then shifted one digit to the left (that's the multiplication by $7^1$, in front of the $38$), and then we add $15$, written in base $7$, which is "$21$".
$$\ldots 0530530530.\\ \ldots0000000000021. +\\ \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\\ \ldots0530530551.$$
Written more compactly, it's $\overline{305}51.$
We can verify this last expression. The base-$7$ numbers, "$305$" and "$51$", are the base-$10$ numbers $152$ and $36$. The $7$-adic number we're looking at, with periodic part written this way, is $\frac{152}{1-7^3}\cdot7^2+36$. Simplifying, that's $$36 - \frac{49\cdot 152}{342} = 36 - \frac{2^3\cdot 7^2\cdot 19}{2\cdot 3^2\cdot 19} = 36 - \frac{196}{9} = \frac{324 - 196}{9}=\frac{128}{9}$$
In the OP example, using $-\frac16$, the same process works, but is much simpler because we have $0$ instead of $15$, no power of $7$ to factor out of the numerator, and no need to multiply by $\frac{38}{38}$ to make the denominator expressible as $1-7^p.$