我有一个1次多项式的系数列表,其中a[i][0]*x^1 + a[i][1]
a = np.array([[ 1. , 77.48514702],
[ 1. , 0. ],
[ 1. , 2.4239275 ],
[ 1. , 1.21848739],
[ 1. , 0. ],
[ 1. , 1.18181818],
[ 1. , 1.375 ],
[ 1. , 2. ],
[ 1. , 2. ],
[ 1. , 2. ]])
在接下来的操作中遇到了问题,
np.polydiv(reduce(np.polymul, a), a[0])[0] != reduce(np.polymul, a[1:])
何处
In [185]: reduce(np.polymul, a[1:])
Out[185]:
array([ 1. , 12.19923307, 63.08691612, 179.21045388,
301.91486027, 301.5756213 , 165.35814595, 38.39582615,
0. , 0. ])
和
In [186]: np.polydiv(reduce(np.polymul, a), a[0])[0]
Out[186]:
array([ 1.00000000e+00, 1.21992331e+01, 6.30869161e+01, 1.79210454e+02,
3.01914860e+02, 3.01575621e+02, 1.65358169e+02, 3.83940472e+01,
1.37845155e-01, -1.06809521e+01])
首先,np.polydiv(reduce(np.polymul, a), a[0])
的余数比0大得多,确切地说是827.61514239
,其次,商的最后两项应该是0,但比0大得多。
我想知道我有什么选择来提高准确性?
1条答案
按热度按时间webghufk1#
有一个稍微复杂的方法,先保留产品,然后再划分结构。
首先使用
n
点并在a
上求值。然后对
ys
而不是系数进行除法。最后使用具有
xs
和ys
的多项式插值来恢复系数找到第二个解决方案