我的任务是编写一个计算方法收敛速度的程序。我不得不用牛顿法来近似求根。这部分代码是好的,工作良好,但我会孵化它。在
x0 : start value
F: function
DF: jacobi matrix
tol : tolerance rate of the approximation. If it is reached the loop shall be stopped --> that`s why I calculate with count
maxit: maximum iterations
重要的是,我试着在任何n维上都这样做。在
^{pr2}$主要部分:
if __name__ == "__main__":
p = konv(x0, F, DF, tol, maxit)
print(p)
我得到的结果是:
[ 0.39384945 0.03214274] 6
<function konv.<locals>.<lambda> at 0x0000023312A82268>
这是什么意思?它不是应该返回一个数字吗?为什么我的返回值中有字母?在
使用lambda函数返回的是函数而不是数字。在
只需返回:
相关问题 更多 >
编程相关推荐