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