2

If you create a graph where the vertices are elements $g \in Z/pZ$ and there is an edge from a to b if $b = a^2$.

How many cycles does this graph have for each p? Is there some property of p that tells us how many cycles the graph has?

I tried to look at examples Z/17Z has only two cycles centered in 1 and 0, but Z/29Z has four cycles, one centered in 16 and another in 23.

hmmmmmmm
  • 147
  • 1
    Is it correct to assume that $p$ is prime? Also, what is meant by a cycle being "centered in" a value? – paw88789 Oct 27 '24 at 09:11
  • Yes, also, centered just means that's a part of the cycle. Sorry, I should have said "including" – hmmmmmmm Oct 27 '24 at 09:26
  • 1
    Note that cycles (except the $0$ cycle) can only occur in the subgroup of squares in $\mathbb{Z}/p\mathbb{Z}^{\ast}$. Moreover, if an element $a$ is contained in a cycle, then $x\mapsto x^2$ should be an automorphism on the subgroup generated by $a$. – schiepy Oct 27 '24 at 09:57
  • Note the edit to my answer (after it was accepted) because I originally did not consider the $1 \to 1$ cycle carefully enough. – Misha Lavrov Oct 27 '24 at 17:40
  • I am not 100 per cent sure that this is a duplicate of this old thread, but it is close. As I happened to answer that older one, I won't vote either way. My dupehammer privilege would make my vote immediately binding, but the case is not clear cut. – Jyrki Lahtonen Oct 27 '24 at 21:54
  • I mean, even though the linked question is looking at the same graph of transitions, the focus is different. – Jyrki Lahtonen Oct 27 '24 at 22:03
  • My absolute favorite variant of this graph showed up here, where both Misha and I shined to some extent :-) – Jyrki Lahtonen Oct 27 '24 at 22:04

1 Answers1

3

Let's define $G_n$ to the be the directed graph with vertices $\mathbb Z/n\mathbb Z$ and edges $k \to 2k$.

Why is this graph relevant? Because whenever $p$ is prime, there is a primitive root mod $p$: an nonzero element $r \in \mathbb Z/p\mathbb Z$ such that the elements of $\mathbb Z/p\mathbb Z$ are $0$ and $1, r, r^2, r^3, \dots, r^{p-2}$, with $r^{p-1}=1$. Excluding $0$ (which forms a cycle in the squaring graph) the rest of the squaring graph is isomorphic to $G_{p-1}$, so the question is: how many cycles does $G_{p-1}$ have?

Moving on to $G_n$: when $n$ is even, we can separate is vertices into odd vertices and even vertices. The odd vertices $1, 3, 5, \dots, n-1$ will have edges to distinct even vertices. The even vertices $0, 2, 4, \dots, n-2$ will only have edges to each other, and they form a copy of $G_{n/2}$. Therefore $G_n$ and $G_{n/2}$ have the same number of cycles. Repeating this for each factor of $2$, we reduce to the case that $n$ is odd.

When $n$ is odd, multiplication by $2$ invertible mod $n$; therefore every vertex in $G_n$ has indegree $1$ as well as outdegree $1$. It is a cycle or a disjoint union of cycles. One of these cycles is the $0 \to 0$ cycle, and we ignore it. Another one of those cycles has the form $$1 \to 2 \to 4 \to \dots \to 2^k \to 1$$ for some $k$. In fact, whatever $k$ happens to be, it is not just the length of the cycle containing $1$, but the length of every cycle except $0 \to 0$, because each nonzero $a \in \mathbb Z/n\mathbb Z$ is contained in the cycle $$a \to 2a \to 4a \to \dots \to 2^ka \to a.$$ Therefore there are $1 + (n-1)/k$ cycles of length $k$. What is $k$, in this case (where $n$ is odd)? It is exactly the multiplicative order of $2$ mod $n$. Note that $G_1$ just has one cycle.

Working backwards: when $n$ is even, let $2^t$ be the highest power of $2$ dividing $n$. Then $G_n$ has $1 + \frac{n/2^t - 1}{k}$ cycles, where $k$ is the multiplicative order of $2$ mod $n/2^t$.

Finally, to answer the original question, let $2^t$ be the highest power of $2$ dividing $p-1$. Then the squaring graph has $2 + \frac{(p-1)/2^t - 1}{k}$ cycles, where $k$ is the multiplicative order of $2$ mod $(p-1)/2^t$. (We add $1$ to include the cycle $0 \to 0$ where this is the $0$ in $\mathbb Z/p\mathbb Z$.)

For example, when $p=17$, we can write $p-1=16$ as $2^4 \cdot 1$, and $G_1$ just has one cycle, so the squaring graph has two cycles.

When $p=29$, we can write $p-1=28$ as $2^2 \cdot 7$, and $G_7$ has three cycles ($0\to 0$, $1 \to 2 \to 4 \to 1$, and $3 \to 6 \to 5 \to 3$), because the multiplicative order of $2$ mod $7$ is $3$. so the squaring graph has four cycles. The formula is $2 + \frac{(29-1)/4-1}{3}$.

Misha Lavrov
  • 159,700