如何解决错误:multiply from ipykernel import kernelapp as app
我正在尝试编写一个代码,在给定一组点 (a_i,b_i) 的情况下,计算拉格朗日多项式展开并绘制它。当我尝试运行该程序时,它不起作用。有人能帮我吗? LPE 的公式为:enter image description here
我的代码是:
import numpy as np
from matplotlib import pyplot as plt
puntosx=([1,2]) #set of x points
puntosy=([4,5]) #set of y points
def legendre(x,n):
i=0
j=0
L=1
y=0
while j<=n-1:
if i<=n-1:
if j!=i:
L=L*(x-puntosx[i])/(puntosx[i]-puntosx[j])
else:
i=i+1
else:
y=y+puntosy[j]*L
i=0
L=1
j=j+1
return y
x=np.arange(0,5,1)
plt.plot(x,legendre(x,len(puntosx)))
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com(将#修改为@)