. , , . , , () , () () . , Numpy , .
[a, b, c] = [5, 10, -1.5]
def func(x):
return -(x+a) + b / (1 + np.exp(-(x + c)))
polyfit poly1d func (-10<x<10) f_poly 10.
x_range = np.linspace(-10,10,100)
y_range = func(x_range)
pfit = np.polyfit(x_range,y_range,10)
f_poly = np.poly1d(pfit)
, f_poly func. , . , , fsolve

roots = np.roots(pfit)
roots
([- 10.4551 + 1.4893j, -10.4551-1.4893j, 11.0027 + 0.j, 8.6679 + 2.482j, 8.6679-2.482j, -5.7568 + 3.2928j, -5.7568-3.2928j, -4.9269 + 0.j, 4.7486 + 0.j, 2.9158 + 0.j])
, Numpy 10 . [-10,10]. :
x0 = roots[np.where(np.logical_and(np.logical_and(roots.imag==0, roots.real>-10), roots.real<10))].real
x0
([- 4.9269, 4.7486, 2.9158])
x0 fsolve:
fsolve(func, x0)
([- 4.9848, 4.5462, 2.7192])
. pychebfun , . , ( ) . ( ), ( fsolve).
, fsolve
import pychebfun
f_cheb = pychebfun.Chebfun.from_function(func, domain = (-10,10))
f_cheb.roots()