%matplotlib inline import numpy as np import matplotlib.pyplot as plt from scipy import integrate def f(x): return np.exp(-x ** 2) integrate.quad(f, 0, 5) def f(x, A, B): return A * np.exp(-B * x ** 2) integrate.quad(f, 0, 5, args=(1.0, 1.0)) def f(y, t): return -y y0 = 1.0 t = np.linspace(0, 3) sol = integrate.odeint(f, y0, t) plt.plot(t, sol) def f(y, t): return np.array([y[1], -y[0]]) t = np.linspace(0, 10) y0 = np.array([1.0, 0.0]) sol = integrate.odeint(f, y0, t) plt.plot(t, sol[:, 0], label='$y$') plt.plot(t, sol[:, 1], '--k', label='$\dot{y}$') plt.legend() from scipy import optimize def F(E, e, M): return E - e * np.sin(E) - M sol = optimize.root(F, 0.1, args=(0.016, 0.1)) sol.x