如何强迫fsolve猜测保持积极?

2024-09-29 09:25:33 发布

您现在位置:Python中文网/ 问答频道 /正文

背景

我正在使用fsolve。以下是与fsolve相关的代码片段。函数func(H)有300行长,所以我不会在这里发布

def tosolve(H, T):
    return T - func(H[0])

x0 = fsolve(tosolve, 200., args=(35))
print(x0)

问题:

我如何确保fsolve甚至不尝试低于0

苏多

if guess < 0 then this is not the root you are looking for


Tags: 函数代码returnifdefargsfunc背景