我是靠谱客的博主 耍酷火龙果,这篇文章主要介绍python fsolve说明_Python曲线与fsolve()相交,函数参数使用numpy,现在分享给大家,希望可以做个参考。

找到两条曲线的交集。两条曲线基本上都是两个浮动数组。

第一个是一维数组Pmech ( Pmech(x) ),第二个是二维数组Pair ( Pair(x,y) )

x轴对于两个阵列都是通用的,所以我要做的是让每一个y轴都能看到Pair和Pmech相交的地方。

我知道fsolve()采用参数函数,而不是数组,因此我编写了两个基本函数来实现此功能:def Pmix(x):

return Pmech[x]

def Paera(x,y):

return Pair[x,y]

如上面的链接所示,我实现了findIntersection函数:def findIntersection(fun1,fun2,x0):

return fsolve(lambda x: (fun1(x) - fun2(x,y) for y in range(1,100)),x0)

但我得到了以下错误:TypeError: float() argument must be a string or a number

Traceback (most recent call last):

File "batteries.py", line 261, in

findIntersection(Pmix,Paera,0)

File "batteries.py", line 238, in findIntersection

fsolve(lambda x: (fun1(x) - fun2(x,y) for y in range(1,100) ),x0)

File "/usr/lib/python2.7/dist-packages/scipy/optimize/minpack.py", line 125, in fsolve

maxfev, ml, mu, epsfcn, factor, diag)

minpack.error: Result from function call is not a proper array of floats.

最后

以上就是耍酷火龙果最近收集整理的关于python fsolve说明_Python曲线与fsolve()相交,函数参数使用numpy的全部内容,更多相关python内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(46)

评论列表共有 0 条评论

立即
投稿
返回
顶部