# What's $-\frac{1}{27}$ in the p-adic ring $\Bbb Z_2$? [duplicate]

What's $$-\frac{1}{27}$$ in $$\Bbb Z_2$$?

I was naively thinking take the repeating string of the standard binary representation of $$3^{-n}$$, put it to the left of the point and you get $$-3^{-n}$$ in $$\Bbb Z_2$$. Hey presto, it works for $$-\frac13$$ and $$-\frac19$$ so why not?

But if I take $$x=\overline{000010010111101101}_2$$ I can see that $$x+512x=-1$$, so I get $$-\frac1{513}$$ in $$\Bbb Z_2$$. It is at least a multiple of $$\frac13$$, but not the one I was expecting.

In general it would seem we get $$\dfrac{-1}{2^{3^{n-1}}+1}$$ by my naive method, which coincides for the two first cases - because $$3$$ and $$9$$ are one away from $$2$$ and $$8$$.

I should mention $$3^{-n}$$ have the peculiar property that one half of the repeating binary string is the inverse of the other. This problem arose while I was trying to prove that fact - feel free to prove that if you're minded to do so!

How do I correctly calculate an arbitrary rational number such as $$-3^{-n}$$?

• This is a good question, at the very least because it illustrates the limitations or misguidedness of insisting on "p-adic" expansions that resemble power series. Yes, I realize that that objection does not necessarily invalidate the question, but it does (to my mind) render it less essential. E.g., $-1/3^n=1/(1-(3^n-1))=\sum_{k\ge 0}(3^n-1)^k$, a $2$-adically convergent series. Commented Oct 11, 2019 at 22:48
• @paulgarrett FWIW, $3^{-n}$ (in $\Bbb Q$) have the peculiar property that one half of the repeating binary string is the inverse of the other. In other words $x \text{ XOR } x\cdot2^{3^{n-1}}\in\Bbb N$. This question arose while I was trying to prove that fact - so it was the binary strings I was interested in more than the p-adics per se. (but then I wanted to clear this up). Commented Oct 11, 2019 at 22:51
• Third iteration of Newton's Method for inverses with start value 1 gives $13992666605$, which multiplied with $27$ is $\equiv -1$ mod $2^{16}$. Look at the binary expansion of that number, maybe one sees something. Or use higher iterations. Commented Oct 11, 2019 at 22:54
• I’m sorry, I don’t understand. We’re talking about infinite expansions, whether $2$-adic or real binary. What is “one half of the binary string”? Commented Oct 11, 2019 at 23:00
• @TorstenSchoeneberg yes, that's right. I made a schoolboy error in my calc. However Prof Lubin then provided a fabulous proof of the conjecture in the 2nd part of the question which is very much worthy of attention in its own right to anyone interested in such things. Commented Oct 23, 2019 at 22:01

This probably doesn’t help a bit, but:

The period of $$2$$ in $$\Bbb Z/(3)^\times$$ is two. And $$-\frac13$$ has $$2$$-adic period two.
The period of $$2$$ in $$\Bbb Z/(9)^\times$$ is six. And $$-\frac19$$ has $$2$$-adic period six.
In general, the period of $$2$$ in $$\Bbb Z/(3^n)^\times$$ is $$2\cdot3^{n-1}$$. And we expect that the $$2$$-adic expansion of $$-3^n$$ should be purely periodic, period $$2\cdot3^{n-1}$$.

Indeed, since $$3^n|(2^{2\cdot3^{n-1}}-1)$$, say with quotient $$q_n$$, we get the results \begin{align} q_n &= \frac{2^{2\cdot3^{n-1}}-1}{3^n}\\ -\frac1{3^n}&=\frac{q_n}{1-2^{2\cdot3^{n-1}}}\,, \end{align} in which the second line says that the number of binary digits in the repeating block of the $$2$$-adic expansion of $$3^{-n}$$ is $$2\cdot3^{n-1}$$, and what’s in the block is the number $$q_n$$.

In the case of $$n=3$$, we get $$-\frac1{27}=9709+9709\cdot2^{18}+9709\cdot2^{36}+\cdots$$, and surenough, the binary expansion of $$9709$$ is $$\quad000\>010\>010\quad111\>101\>101$$. I can’t imagine how one would prove your claim.

I think I have it. But you must check this over carefully, because to me it’s looking like magic, or at least like very devious sleight-of-hand.

To avoid multiple braces in my typing, I”m going to renumber, calling $$N=n-1$$, so that in my favorite example of the expansion of $$-1/27$$, we’ll have $$N=2$$.And I’ll call $$Q_N=\frac{2^{2\cdot3^N}-1}{3^{N+1}}\,,$$ pretty much as I did above before the renumbering.

Now, what we know is that $$2^{2\cdot3^N}-1\equiv0\pmod{3^{N+1}}$$, so we can factor $$\left(2^{3^N}-1\right)\left(2^{3^N}+1\right)\equiv0\pmod{3^{N+1}}\,,$$ but please note that since $$3^{N+1}$$ is odd, we see that the left-hand factor above is $$\equiv1\pmod3$$, in particular relatively prime to $$3$$, and thus to $$3^{N+1}$$ as well. Thus $$3^{N+1}$$ divides the right-hand factor, i.e. $$3^{N+1}\mid(2^{3^N}+1)$$, and once again to make typing easier for myself, I’ll call the quotient $$\Omega$$. Thus we have: \begin{align} \Omega&=\frac{2^{3^N}+1}{3^{N+1}}\\ 0&<\Omega<2^{3^N}\\ Q_N&=\Omega\left(2^{3^N}-1\right)\\ &=2^{3^N}(\Omega-1)+\left(2^{3^N}-\Omega\right)\\ \text{where we note }0&<2^{3^N}-\Omega<2^{3^N}\,. \end{align}

And that gives us our expression for $$Q_N=2^{3^N}a+b$$ with both $$a$$ and $$b$$ in the interval $$\langle0,2^{3^N}\rangle$$, namely $$a=\Omega-1$$ and $$b=2^{3^N}-\Omega$$. And surenough, $$a+b=2^{3^N}-1$$, as we desired.

• Thanks. Much of this I have already but much less well organised - it's really helpful to see it set out so clearly. If $w=2\cdot3^{n-1}$ is the length of the periodic string then I guess $3^{-n}=(2^{(w/2)+1}+1)-2^{w/2}q+q$ is the identity we seek to prove in order to prove my claim.... Actually that's not right. I've forgotten the residue again (exactly what I did in my original question!) Commented Oct 12, 2019 at 9:46
• Yes, I woke up in the middle of the night, with much the same idea. I’ll try to work it out. Commented Oct 12, 2019 at 13:44
• Funny to hear others do the same thing! I'm always dreaming and then the answer comes to me in my sleep! Anyway, more fun stuff about these numbers. The number of times the string changes from one to zero, appears to be the binary transform of the nth Jacobsthal gap oeis.org/A080925 Commented Oct 12, 2019 at 19:27
• ...which I can't distinguish from this: oeis.org/A046717 Commented Oct 12, 2019 at 19:32
• I think I’m understanding it. But I’m at a local restaurant, tanking up. When sobriety comes, after I get home, I’ll try to write up what I know. Commented Oct 13, 2019 at 22:00

You are not correct to assume that $$x+512x=-1$$. You have a couple zero bits in the actual sum:

$$x+512x=513x=...1111111111111\color{blue}{0}11\color{blue}{0}1$$

and this is $$-19$$ in $$2$$-adics. Thereby $$x=-19/513$$ and when you reduce this to lowest terms you end with ... $$-1/27$$.

• Aha, thanks. Of course, this should have been obvious. So I can continue with my naive method (but take more care!) Commented Oct 11, 2019 at 23:27

I am not sure what the actual question is. What should be clear is that $$-\frac1{27}=\frac1{1-28}=\sum_{k=0}^\infty28^k=\sum_{k=0}^\infty2^{2k}(1+2+2^2)^k.$$ It is not obvious (to me, at least) what would be the last expression in the form $$\sum\epsilon_k2^k$$ with $$\epsilon_k\in\{0,1\}$$.

Note: Suppose that the sequence is definitely periodic, i.e. suppose that there exists $$r\geq0$$ and $$\ell\geq1$$ such that $$z=\sum_{k=0}^\infty\epsilon_k2^k=\underbrace{(\epsilon_0+\cdots\epsilon_{r-1}2^{r-1})}_{:=M}+2^{r}\sum_{j=0}^\infty2^{j\ell}\underbrace{(\epsilon_r+\cdots+\epsilon_{r+\ell-1}2^{\ell-1})}_{:=N}.$$ Then $$z=M+2^r\frac{N}{1-2^{\ell}}.$$ Thus the only rational numbers that have a definitely periodic expansion are those of the above form with $$M$$ and $$N\in\Bbb{Z}^{>0}$$.

• should that be $2^{2k}$? Commented Oct 11, 2019 at 23:15
• @samerivertwice, of course! Edited, thanks. Commented Oct 11, 2019 at 23:16
• Thanks for this. Another useful perspective. Turns out I made a schoolboy error (as usual)! Commented Oct 11, 2019 at 23:29
• @samerivertwice, please note that I added a note explaining what are the rational numbers that have a definitely periodic 2-adic expansion. Commented Oct 11, 2019 at 23:49
• @samerivertwice The point of Andrea's answer is that $\sum_k a_k 2^k, a_k\in \{0,1\}$ is just a particular kind of $2$-adic series, asking to put $-1/27=\sum_{k\ge 0} 28^k$ in that form is as pointless as asking the decimal expansion of $\sum_{k\ge 0} \frac1{k!}$. We have a sequence of integers converging to $-1/27$ : we are happy with it. Commented Oct 12, 2019 at 2:39