April 2019
Intermediate to advanced
426 pages
11h 13m
English
Some root-finding functions that can be found in the scipy.optimize modules include bisect, newton, brentq, and ridder. Let's set up the examples that we have discussed in the Incremental search section using the implementations by SciPy:
In [ ]: """ Documentation at http://docs.scipy.org/doc/scipy/reference/optimize.html """ import scipy.optimize as optimize y = lambda x: x**3 + 2.*x**2 - 5. dy = lambda x: 3.*x**2 + 4.*x # Call method: bisect(f, a, b[, args, xtol, rtol, maxiter, ...]) print("Bisection method:", optimize.bisect(y, -5., 5., xtol=0.00001)) # Call method: newton(func, x0[, fprime, args, tol, ...]) print("Newton's method:", optimize.newton(y, 5., fprime=dy)) # When fprime=None, then the secant method ...Read now
Unlock full access