I’m solving the damped driven pendulum:

```
{γ, g, ω} = {0.5, 1.5, 2/3};
{X0, V0} = {0.6184, 0.};
tmax = 1000;
sol = NDSolve({x''(t) + γ x'(t) + Sin(x(t)) == g Cos(ω t), x(0) == X0, x'(0) == V0}, x, {t, 0, tmax}, MaxSteps -> Infinity)
sol1(t_) := x(t) /. sol((1))
sol2(t_) := x'(t) /. sol((1))
```

I then want to plot the solution $(x,x’)$ constraining $x$ to the interval $(-pi,pi)$. I came with modulo to make one part $(-2pi,0)$, the other $(0,2pi)$, and then restrict the range to $(-pi,pi)$. First, it is inelegant. Second, I end with a gap in the middle that even with a big number of `PlotPoints`

I cannot get rid of.

```
ParametricPlot({{Mod(sol1(t), -2 π), sol2(t)}, {Mod(sol1(t), 2 π), sol2(t)}}, {t, 0, tmax},
Frame -> True, Axes -> False, PlotStyle -> Black, PlotRange -> {{-π, π}, {-3, 3}}, PlotPoints -> 500)
```

Using an alternative formulation for modulo:

```
normalize(angle_?(NumericQ(#) && Im(#) == 0 &)) := angle - 2 Pi Floor((angle + Pi)/(2 Pi))
```

to plot

```
ParametricPlot({normalize@sol1(t), sol2(t)}, {t, 0, tmax},
Frame -> True, Axes -> False, PlotStyle -> Black, PlotRange -> {{-π, π}, {-3, 3}}, PlotPoints -> 500)
```

I get redundant horizontal lines:

How to make such plot elegantly?