# why am I not getting a staircase for the rotation number?

I'm trying to understand the staircase map. Look at this map from the circle to itself:

$$x \stackrel{F}{\mapsto} \big[\omega + x + \tfrac{\epsilon}{2\pi} \sin (2\pi x) \big] \pmod 1$$

Such a map arises when applying Euler's method to solve a differential equation. Then the rotation number as a function of $\omega$ is found by iterating $F$ many times:

$$\rho(\omega, \epsilon) = \lim_{n \to \infty} \frac{F^n(\omega, \epsilon, x_0)}{n}$$

so I tried to find the rotation number in the instance provided in the textbook (Dynamics and bifurcations, Hale & Koçak, 1991) the code is straightforward:

import numpy as np
import matplotlib.pyplot as plt

w = np.arange(0,1,0.01)
x0  = 0
x   = 0*w + x0
eps = 0.5

for n in 1+np.arange(100):
x = (w + x + (eps/2/np.pi)*np.sin(2*np.pi*x))%1

plt.plot(w,x/n)


In fact, I don't get a staircase at all. Am I coding it correctly?

The problem is your explicitly taking the result of $F$ to be modulo 1. This messes up the calculation of the winding number. Simply removing %1 will yield the correct winding number. To see why you want $F$ to be able to exceed 1, inspect the definition of the winding number $$\rho(\omega,\epsilon) = \lim_{n\to\infty} \frac{F^n(x_0;\omega, \epsilon)-x_0}{n}$$ Since $x\in[0,1]$ parameterizes the unit circle, $F(x_0)-x_0$ is the distance around the unit circle by which $F$ displaces $x_0$, and $(F^n(x_0)-x_0)/n$ is the mean displacement caused by $n$ applications of $F$. So the winding number is this mean displacement in the limit of infinitely many applications of $F$. But if the result of $F$ is always taken modulo 1, then larger and larger values of $n$ will result in ever smaller winding numbers, eventually becoming $0$, whatever the values of $\omega$ and $\epsilon$. This is obviously not capturing the intended meaning of the winding number.