# Code to reconstruct a step function from sin() functions
# demonstrating Gibbs' phenomenon.
n = 1000
ts = np.linspace(-0.5,0.5,n)
dt = 1/n
xs = 0.5*np.ones(n)
for k in range(100):
if k % 2 == 1:
xs += 2/(np.pi*k)*np.sin(k*2*np.pi*ts)
plt.plot(ts,xs)
plt.show()