Created
January 16, 2016 12:07
-
-
Save ischurov/6a06666a59306dfff334 to your computer and use it in GitHub Desktop.
solve-ode.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%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