牛顿多项式的规范系数

2024-02-20

不久前,我为我编写的游戏实现了多项式逼近。

我正在使用牛顿金字塔法。 我花了很长时间才弄清楚,但我的解决方案需要计算二项式系数,并且我还必须将所有系数相加以获得每个幂的最终系数(因为解决这个问题类似于平方,立方..项并计算二项式系数)

例如: 从 n 个生物术语中选出 k 个并将它们相加
一选一乘
a*(x+b)(x+c)(x+d) ==> a*x^3 + a*x^2*(b+c+d) + a*x(bc+bd+cd) +a*b*c*d
所以 b*c*d 也是 b*c 和 b*d 之一

我现在的问题是: 有没有一种方法可以使用牛顿方案计算多项式插值,而无需计算所有生物项系数?

我的代码:https://github.com/superphil0/Polynominterpolation/blob/master/PolynomInterpolation.java https://github.com/superphil0/Polynominterpolation/blob/master/PolynomInterpolation.java

效果很好,虽然如果给太多分的话会很慢 因为所选择的术语都已被总结

(我真的不擅长用英语解释这一点,但我希望有人能理解我想知道的东西)

cheers


Judging from this description http://homepages.gac.edu/~hvidsten/courses/MC355/Textbooks/numerical%20analysis%20course%20notes.pdf, I take it that your “pyramid scheme” generates coefficients ci such that the polynomial p(x) can be written as
p(x) = c0 + (xx0)( c1 + (xx1)( c2 + (xx2)( c3 + (xx3)( … ( cn-1 + (xxn‒1) cn ) … ))))

Now you can compute canonical coefficients recursively from the back. Start with
pn = cn

In every step, the current polynomial can be written as
pk = ck + (xxk)pk+1 = ck + (xxk)(b0 + b1x + b2x2 + …)
assuming that the next smaller polynomial has already been turned into canonical coefficients.

Now you can compute the coefficients ai of pk using those coefficients bi of pk+1. In a strict formal way, I'd have to use indices instead of a and b, but I believe that it's clearer this way. So what are the canonical coefficients of the next polynomial?

  • a0 = ckxkb0
  • a1 = b0xkb1
  • a2 = b1xkb2

您可以在循环中编写它,使用和重用单个数组a保存系数:

double[] a = new double[n + 1]; // initialized to zeros
for (int k = n; k >= 0; --k) {
    for (int i = n - k; i > 0; --i)
        a[i] = a[i - 1] - x[k]*a[i];
    a[0] = c[k] - x[k]*a[0];
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

牛顿多项式的规范系数 的相关文章

随机推荐