Laplace interpolation,

Source: Internet
Author: User

Laplace interpolation,

The proof of existence and uniqueness will be supplemented later ....

Laplace Interpolation

Laplace interpolation, emmmm, with a very high name: joy:

What applications does it have?

We have talked about it in FFT.

Set $ n-1 $ subpolynomial

$ Y = \ sum _ {I = 0} ^ {n-1} a_ I x ^ I $

There is an obvious conclusion: If $ n $ is given with different vertices $ (x, y) $, the $ n-1 $ subpolynomial is uniquely identified.

If the $ n $ points are given,

With the use of Laplace interpolation, you can calculate the value of a certain item in the time of $ O (n) $, or at $ O (n ^ 2) $ calculate the corresponding $ y for the given $ x $ in time complexity.

So how to calculate it?

Formula

Don't worry about it. Just give the formula directly. How can this formula be provided later?

For $ n-1 $ subpolynomials, $ n $ (x, y) $ is given.

For the given $ x $, the value of item $ I $ is

$ L (I) = y_ I \ prod _ {j = 1, j \ neq I} ^ {n} \ dfrac {x-x_j} {x_i-x_j} $

The corresponding $ y $ is

$ Y = \ sum _ {I = 1} ^ {n} l (I) $

$ = \ Sum _ {I = 1} ^ {n} y_ I \ prod _ {j = 1, j \ neq I} ^ {n} \ dfrac {x-x_j} {x_i-x_j} $

This formula can be used for calculation.

Code

 

# Include <cstdio> int x [1001], y [1001]; int N, ans = 0; int main () {scanf ("% d", & N ); for (int I = 1; I <= N; I ++) scanf ("% d", & x [I], & y [I]); int X; // The x scanf ("% d", & X) to be obtained; for (int I = 1; I <= N; I ++) {int tmp = y [I]; for (int j = 1; j <= N; j ++) {if (I = j) continue; tmp = tmp * (X-x [j])/(x [I]-x [j]);} ans + = tmp;} printf ("% d ", ans); return 0 ;}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.