fork download
  1. import numpy as np
  2. def g(x):
  3. return np.cos(1.89*x)
  4. t= np.arange(-1,1.5,0.1)
  5. x=np.zeros((20,1))
  6. plt.plot(t,t)
  7. plt.plot(t,g(t))
  8. for k in [1,2 ,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]:
  9. x[k+1] = g(x[k])
  10. a = [x[k],x[k],x[k],x[k+1]]
  11. b = [x[k],x[k+1],x[k+1],x[k+1]]
  12. plt.plot(a,b, ' -o')
Success #stdin #stdout 0.03s 25668KB
stdin
Standard input is empty
stdout
import numpy as np
def g(x):
return np.cos(1.89*x)
t= np.arange(-1,1.5,0.1)
x=np.zeros((20,1))
plt.plot(t,t)
plt.plot(t,g(t))
for k in [1,2 ,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]:
x[k+1] = g(x[k])
a = [x[k],x[k],x[k],x[k+1]]
b = [x[k],x[k+1],x[k+1],x[k+1]]
plt.plot(a,b, ' -o')