import numpy as np import matplotlib.pyplot as plt import scipy.integrate as itg def diff(y, t): return np.array([y[1], -y[0]]) t = np.linspace(0., 10., 101) y = itg.odeint(diff, [1., 0.] , t) plt.xlabel(r'$t$') plt.plot(t, y[:, 0], '-', t, y[:, 1], '--') plt.legend([r'$x$', r'$dx/dt$'], loc='best') plt.show()