import matplotlib.pyplot as plt import numpy as np ############################## # non-ideal pendulum plt.clf() n = 10000 dt = 0.001 theta=[] omega=[] theta.append(3.) omega.append(0.) for i in range(1,n): theta.append(theta[i-1] + omega[i-1]*dt) omega.append(omega[i-1] - np.sin(theta[i-1])*dt) plt.plot(theta) # second run theta2=[] omega=[] theta2.append(1.) omega.append(0.) for i in range(1,n): theta2.append(theta2[i-1] + omega[i-1]*dt) omega.append(omega[i-1] - np.sin(theta2[i-1])*dt) plt.plot(theta2) plt.show()