I would like to understand how can I plot Arnold tongues (see figure below) with help of Wolfram Mathematica.
From this question, I have borrowed the function that computes the winding number of the circle map. My own version (in order to be consistent with the figure presented above) is
WindingNumber =
Compile[{n, η, ϵ, ϕ0}, (Nest[# + η + ϵ*Sin[#] &, ϕ0, n] - ϕ0)/(2*Pi*n)];
Here, η is the parameter, ϕ0 is the initial value and ϵ is the parameter, too. I know that each Arnold tongue corresponds to the rational value of WindingNumber. So, my idea is to check that for a given values of ϵ and η is rational or not. To do it, I need the Wolfram Mathematica analog of RationalQ function (see discussion here). As I understand, there is no analog of RationalQ function, but in this question, I see the naive realization:
TrueQ@Element[x, Rationals]
where (as I understand) one checks that x belongs to Rationals (or not). So, I have tried to create a grid of parameters η and ϵ with help of Table. For each point of the grid, I check is WindingNumber rational or not with the help of the function written above. If true, I mark this point by 1, if false, I mark by 0, so I write
ArnoldTongues = Table[{ϵ, 2*Pi*i,
If[TrueQ@Element[WindingNumber [100, 2*Pi*i, 1.0, 0], Rationals], 1,
0]}, {i, 0, 1, 0.01}, {ϵ, 0, 1, 0.01}];
As a result, I have the array that is suitable for ListDensityPlot.
However, I obtain that the winding number is always irrational for every point on my grid, which is impossible. What am I doing wrong?



WindingNumberonly returns real numbers. Mathematica does not consider any real number to be rational. Only explicit ratios of integers are considered rational. CompareTrueQ@Element[0.25, Rationals]withTrueQ@Element[1/4, Rationals]– Bob Hanlon Aug 23 '23 at 19:53Rationalize. But it seems useless. Does any other approach to visualize Arnold tongues in Wolfram Mathematica exist? – Artem Alexandrov Aug 23 '23 at 20:51Cases[wnums, wnum_ ;/ Abs[wnum - ratonal] < tol]for each rational you want and some tol, e.g. 1E-4 – I.M. Aug 24 '23 at 02:56wnumsand compare each element with a givenrationalwith the predefined tolereancetol? Does it mean that I have to generate list of rationals, too? – Artem Alexandrov Aug 24 '23 at 07:17