# Variables defined modulo $\pi$ and avoiding singularities; phase plotting for a map

I have the following $2$-dimensional implicitly defined map

f[x_, y_] := -x + 2 *ArcTan[(2 (5*Tan[x] + 2*Tan[y]))/(5 (2 - 5*Tan[x]*Tan[y]))]

g[x_, y_] := -y + ArcTan[2/(5*Tan[x])] - ArcTan[2/(5*Tan[f[x, y]])]

The variables $x$ and $y$ are defined modulo $\pi$, i.e. $x \mod \pi$ and $y \mod \pi$; the map is thus well-defined. I want to plot its phase portrait; to this end, I take initial points in the interval $[0, \pi) \times [0, \pi)$ partitioned with a step size of $\pi/10$ (thus I have 100 initial points), and I want to iterate each initial point 20 times.

Questions:

1. Despite that the map is analytic, Mathematica encounters singularities of the form $1/0$ - how do I circumvent this problem?.

So, for example, when I run the following code

points = NestList[{f[#[[1]], #[[2]]], g[#[[1]], #[[2]]]} &, #, 10] & /@Flatten[Table[{i, j}, {i, 0, Pi/2, 0.2}, {j, 0, Pi/2, 0.2}], 1]

Mathematica returns "Infinite expression $\frac{1}{0}$ encountered".

1. How do I define variables modulo $\pi$?

2. What is the optimal way to plot phase trajectories for the above map?

Thanks.

• It would be useful to see the code you have used. I am not really understanding what exactly is wanted here. (Those are two separate statements. But with code and maybe a picture the first issue, and possibly the second, would go away.) – Daniel Lichtblau Nov 18 '17 at 16:27
• Please see my edited post @DanielLichtblau – Alex Nov 19 '17 at 1:45
• Have you notived that g[0, 0], g[0, π], g[π, 0], and g[π, π] are all Indeterminate (i.e.: retutn Power::infy: Infinite expression 1/0 encountered.) Tan[0] == Tan[π] == 0, and g divides by Tan[x]. – aardvark2012 Nov 19 '17 at 11:41
• Starting at the origin is trouble because of tangents in denominators in g[x,y]. Either redefine at the origin to deal with that (could use fact that ArcTan[Infinity]=Pi/2) or else start slightly away from origin. – Daniel Lichtblau Nov 19 '17 at 15:35
• Yes, that's that's why I stated that the map is analytic everywhere, since $\arctan \infty = \frac{\pi}{2}$ - how do I incorporate this condition in Mathematica? In my definition of the map, it is imperative that I include the origin (that's the whole point of the difficulty I encounter) @DanielLichtblau – Alex Nov 19 '17 at 17:20