python - scipy.optimize.newton gives TypeError: 'float' object is not callable -
im new python , writing code finding roots of function:
from scipy import optimize x = eval(raw_input()) #initial guess f = eval(raw_input()) # function evaluated f = eval(raw_input()) #derivative of function f round(optimize.newton(f, x, f, tol = 1.0e-9), 4) but interpreter returns: typeerror: 'float' object not callable
i'm not sure im missing out code. can me out..thank in advance
optimize.newton expects reference callable object (for example function). not mean give function string 'x*x' have define 1 first, like:
def my_func (x): return x*x then can plug my_func optimize.newton (besides other required parameters).
Comments
Post a Comment