如何在python中编写重心权重

时间:2018-07-07 06:31:34

标签: python python-3.x numerical-methods numerical-analysis

问题是在数值分析中实现重心权重: enter image description here

这是我的代码:

def barycentric_weights(j,n):
weight=1
for k in range(0,n+1):
    if k != j:
        weight=weight*(1/(xj-xk))
    else:
        weight=weight*1

我遇到的问题是我不知道如何正确调用xj和xk。我应该称它们为元组吗?

0 个答案:

没有答案