# Finding periodic cycles of a function

Given a function f[{x,y}] it is rather simple to use, for example, NSolve to find periodic points of period $$n$$. We simply take something like

NSolve[f[f[f[{x, y}]]] == {x, y}, {x, y}]

to search for period three points. Is it possible to separate these solutions into periodic cycles? That is can I get as an output a list whose sublists are the fixed points, say $$p1$$ and $$p2$$ and the period 3 cycle, say $$q1 \to q2 \to q3$$?

So the required output would be {{p1}, {p2}, {q1, q2, q3}}

Edit:

Take for example g[{x_, y_}, -1, 0.2] := {x^2 + -1 - 0.2*y, x} (written this way in case we would like to find periodic points for other parameters.)

The $$n$$-th iterate is given by gcomp[n_Integer, -1, 0.2] := Composition @@ ConstantArray[g[#, -1, 0.2] &, n];

and period $$n$$ points are given by

pernpts[n_, -1, 0.2] := Table[{x, y} /. Flatten[NSolve[gcomp[n, -1, 0.2][{x, y}] == {x, y}, {x, y}], {1}][[i]], {i, 1, Length[Flatten[NSolve[gcomp[n, -1, 0.2][{x, y}] == {x, y}, {x, y}], {1}]]}]

Here I have again fixed some parameter values but the hope is to be able to easily vary these. I have also adapted the code so it gives outputs as a pair of complex numbers rather than the usual display by NSolve.

The period three points are

{{1.76619, 1.76619}, {-1.35603 + 0.124032 I, -0.0842516 - 0.441668 I}, {-1.35603 - 0.124032 I, -0.0842516 + 0.441668 I}, {-0.0842516 - 0.441668 I,0.84028 - 0.248049 I}, {-0.0842516 + 0.441668 I,0.84028 + 0.248049 I}, {-0.56619, -0.56619}, {0.84028 - 0.248049 I, -1.35603 + 0.124032 I}, {0.84028 + 0.248049 I, -1.35603 - 0.124032 I}}

and the fixed points are

{{1.76619, 1.76619}, {-0.56619, -0.56619}}

In this case it it easy to take out the fixed points and by hand we could assemble these period three points in cycles. The difficulty is that as the period increases this becomes more difficult. Also when our period $$n$$ is divisible by some number, say $$d$$, we get that periodic cycles of length $$d$$ are also periodic cycles of period $$n$$. An easy example of this is that a fixed point of $$f$$ is also a fixed point of any iterate of $$f$$ so a fixed point is a point of period $$n$$ for all $$n$$.

Update: In experiments with different parameter values for period 3 cycles there does seem to be some structure to the set of solutions which could possibly be used to provide this grouping. This could just be because I picked parameter values not too far away from each other though, so it's unclear how this generalises. Also, we'd have to limit this to low periods, since, as a comment points out, we would require a lot of processing power to solve, e.g. period 6 and higher. Perhaps one could achieve the required grouping through list manipulation by taking an element, and iterating it up to the period required. Then removing these points from the solution set and carrying on until this is exhausted. This is perhaps easier than trying to get Mathematica to group them together automatically as an output. I have experimented with this but one problem is that Mathematica does not seem to handle Complement well when applied to a list obtained by NSolve (for example the complement of period 3 points and period 1 points).

• Interesting question. Can you add a concrete example of f for people to work with? – Chris K Nov 17 '20 at 19:21
• @ChrisK I have edited the question to add an example of f and the code with which I've been working. I have also added some mathematical details. – math Nov 17 '20 at 20:14
• Nest[g, {x, y}, 6] == {x, y} // NSolve has my CPU usage topping 1400%, even though it has only four cores and the max I've ever seen is 390+%. It seems suspect. In any case, it's not finishing, so I can't even generate period-six cycles. – Michael E2 Nov 17 '20 at 21:39
• This parameter n is insufficient for many cases. 2D has many types of periodicity beyond the one of this question. The keyword periodicity may be considered already misleading. This is more searching for fixed points. Mathematica offers built-ins open to other types of periodicity beyond universitary peridodicity. Reals and even Complexes are too limited to find all of the solution with simple methods in NSolve. One problem limit truely recursion. – Steffen Jaeschke Nov 27 '20 at 10:00
• @SteffenJaeschke I don't know what other types of periodicity you mean. I am thinking in terms of a dynamical system. Can you expand on what you mean? – math Nov 27 '20 at 17:02