Canonical coefficients from Newton polynomial

℡╲_俬逩灬. 提交于 2019-12-14 01:40:34

问题


A while ago I implemented a Polynom approximation for a game I programmed.

I am using Newton's pyramide method. It took me quite a while to figure it out, but my solution requires to calculate the binomial coefficients and I also have to sum up all the coefficients for the final coefficient of each power (since solving this problem is similar to squaring, cubing.. terms and calculating the binomial coefficients)

For example: pick k out of n of the bionomeal terms and add them
one pick is multiplied
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
so b*c*d would be one pick b*c and b*d too

My question now is: Is there a way calculating the Polynominterpolation with the newton scheme without having to calculate all the bionomial coefficients?

My code: https://github.com/superphil0/Polynominterpolation/blob/master/PolynomInterpolation.java

It works pretty good, although if one gives too many points it will be rather slow because of the selection of terms which have all be summed up

(I am really bad at explaining this in english, I hope someone can understand what I want to know though)

cheers


回答1:


Judging from this description, 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

You can write this in a loop, using and reusing a single array a to hold the coefficients:

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];
}


来源:https://stackoverflow.com/questions/13435257/canonical-coefficients-from-newton-polynomial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!