September 2014
Intermediate to advanced
512 pages
12h 39m
English
In this short recipe, we will see how to use SciPy to find the root of a simple mathematical function of a single real variable.
scipy.optimize, and matplotlib:In [1]: import numpy as np
import scipy as sp
import scipy.optimize as opt
import matplotlib.pyplot as plt
%matplotlib inlineIn [2]: f = lambda x: np.cos(x) - x
In [3]: x = np.linspace(-5, 5, 1000) y = f(x) plt.plot(x, y) plt.axhline(0, color='k') plt.xlim(-5,5) ...
Read now
Unlock full access