Spaces:
Sleeping
Sleeping
File size: 507 Bytes
81e15fe | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 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)
|