Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ischurov/6a06666a59306dfff334 to your computer and use it in GitHub Desktop.
Save ischurov/6a06666a59306dfff334 to your computer and use it in GitHub Desktop.
solve-ode.py
%matplotlib inline
# to use in Jupyter
from scipy.integrate import odeint
import numpy as np
def f(Z, t):
# x = Z[0], y = Z[1]
return [Z[1], -Z[0]]
t = np.linspace(0, 10)
trajectory = odeint(f, [0, 1], t)
import matplotlib.pyplot as plt
plt.plot(t, trajectory[:,0])
plt.plot(trajectory[:,0], trajectory[:,1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment