TITLE: $a_{n+1}=|a_n|-a_{n-1} \implies a_n \; \text{is periodic}$
QUESTION [16 upvotes]: Prove that any sequence of real numbers satisfying $a_{n+1}=|a_n|-a_{n-1}$ is periodic.

Although it looks simple, I can't prove this statement...
I tried rewriting the first few terms of the sequence, but nothing interesting showed up...
I'd be mostly interested in hints for this one.

REPLY [7 votes]: You can handle the problem this way. Assume $a_0=a$ and $a_1=b$. 
The behaviour of the sequence always depends on the belonging of $(a,b)$ to one of the nine cones depicted below. By assuming, for example, that we starts with $(a,b)$ in the first cone ($a\geq 0,a\leq b\leq 2a$), the sequence is:
$$ a,b,b-a,-a,2a-b,3a-b,a,b-2a,a-b,a,b,b-a,\ldots\tag{2}$$
and the period is $9$. By hand, we just have to check that this happens for any possible starting cone. Or be more clever. This is how the regions of the $(a,b)$-plane are mapped one into another:

Starting in any point, we come back to that point in $9$ steps. To put in elegant terms, the map
$$\phi:(a,b)\to(b,|b|-a)$$
sends the $n$-th cone depicted in the $n+1$-th (the $9$th in the first one) with a bijection. Since the orbit of a point in the first cone is closed, the orbit of any point is closed, and its cardinality is nine.

REPLY [3 votes]: Once you guess that if $2a \ge b \ge a$, the sequence is $a,b,b-a,-a,2a-b,3a-b,a,b-2a,a-b,\ldots$ and that this sequence should cover all the possible cases,
you can translate the condition $2a \ge b \ge a $ to the other eight pairs of numbers and you should obtain a covering of the plane
For example if you do one step and let $a' = b, b' = b-a$, the condition becomes $2a'-2b' \ge a' \ge a'-b'$, so that $a' \ge 2b' \ge 0$. So this gives you a new region of the plane where you know that the sequence will be $9$-periodic because it is a shift of the original example.
For completeness' sake, here are the $9$ regions, in order :
$2a \ge b \ge a \\
a \ge 2b \ge 0 \\
a \ge 0 \ge a+b\\
b \ge 0 \ge a+b \\
b \ge 2a \ge 0 \\
2b \ge a \ge b \\
a+b \ge 0 \ge b \\
0 \ge a,b \\
a+b \ge 0 \ge a
$
Those do form a covering of the plane so the template we used at the beginning covers all possible sequences.