Spaces:
Sleeping
Sleeping
| import numpy as np | |
| import scipy as sp | |
| import scipy.optimize | |
| from fast_bisect import cbisect | |
| myargs = {'alpha': 1.0} | |
| def f(x,args): | |
| return np.tan(x)-args['alpha']*x | |
| %timeit sp.optimize.bisect(f, a=0.5, b=2.0, args=myargs, xtol=1e-8, rtol=1e-15, maxiter=100) | |
| # 10.2 μs ± 124 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each) | |
| %timeit cbisect(a=0.5, b=2.0, args=myargs, xtol=1e-8, rtol=1e-15, maxiter=100) | |
| # 241 ns ± 0.411 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each) | |