繁体   English   中英

用Python进行Lagrange插值做奇怪的事情

[英]Lagrange interpolation with Python doing something weird

有谁知道为什么它会返回如此疯狂的数字?

from scipy.interpolate import lagrange

x = [2458723, 2458724, 2458725, 2458727, 2458728, 2458729]
y = [-2000, -900, 1000, 400, -4700, -1900]

poly = lagrange(x, y)

x0 = list(np.linspace(min(x), max(x), num=10))
y0 = poly(x0)
print(y0)

输出: [-2.88230376e+18 -6.91752903e+18 -3.45876451e+18 -8.07045053e+18 -2.30584301e+18 -2.88230376e+18 -5.76460752e+18 -4.03522527e+18 -2.88230376e+18 -4.03522527e+18]

该实现可能正在对域进行假设。 尝试将您的域移近x = 0

from scipy.interpolate import lagrange
import numpy as np

x = np.array([2458723, 2458724, 2458725, 2458727, 2458728, 2458729])
y = np.array([-2000, -900, 1000, 400, -4700, -1900])

poly = lagrange(x - x.min(), y)

x0 = np.linspace(x.min(), x.max(), num=10)
y0 = poly(x0 - x0.min())
print(y0)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM