当前位置:   article > 正文

python做方程_如何在python中建立方程

python根据数据变化 生成方程

>>> import numpy as np

>>> a = [1,20,300,4000]

>>> b = np.arr[a[n:]+a[:n] for n in range(4)]

>>> sol = np.linalg.solve(b[1:,1:],-b[1:,0])

>>> print "Using last N equations the solution is:", [1.0]+list(sol)

Using last N equations the solution is: [1.0, -0.11111111111111105, -0.11111111111111113, -1.2222222222222223]

>>> print "Substituting in first equation gives:", a[0]+sol.dot(a[1:]), "= 0"

Substituting in first equation gives: -4.44444444444 = 0

>>>

在这一点上,您的程序可以决定残差是太多还是解决方案足够好。在

如果解决方案足够好,也许你想用

^{pr2}$

对另一个元素的解的性质给出了一个重要的注记>>> print np.linspace.lstsq.__doc__

了解整个故事。在

关于效率,当你要解一个大的方程组(NxN,几乎…)时,你不介意你可以用一个简单的数值解来构建系数矩阵。在

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/683762
推荐阅读
相关标签
  

闽ICP备14008679号