8行代码求解非线性方程

来源:互联网 发布:遗传算法的matlab实现 编辑:程序博客网 时间:2024/05/19 22:26

Talk is cheap show me the code

from scipy.optimize import fsolvefrom math import exp ,sindef f(x,*arg):     f1=exp(x)+sin(x)     f2=0.2    return(f1-f2)result=fsolve(f,x0=0)print(result)
[-0.45173218]

什么牛顿法,拟牛顿法,二分法,都在库里。。。。。

原创粉丝点击