0
$\begingroup$

Let's say we have 1000 points, \begin{align*} (a_1 &, b_1) \\ (a_2 &, b_2) \\ & \vdots \\ (a_{1000} &, b_{1000}) \\ \end{align*} and we want to find a 999 degree polynomial that fits these points. The method I have in mind is to have a polynomial $$c_{999}x^{999}+c_{998}x^{99}+\ldots+c_1x+c_0=y$$ We would then plug in each of the 1000 points to get a huge matrix: $$\begin{bmatrix} a_{1000}^{999} & a_{1000}^{998} & \dots & a_{1000}^{0}\\ a_{999}^{999} & a_{999}^{998}\\ \vdots & \vdots& \ddots\\ a_1^{999} & \ldots & \ldots &a_1^0 \end{bmatrix} \begin{bmatrix} c_{999} \\ c_{998} \\ \vdots \\ c_0 \end{bmatrix} = \begin{bmatrix} b_{1000} \\ b_{999} \\ \vdots \\ b_1 \end{bmatrix} $$ However, this matrix is probably really hard to solve, because of the size of the numbers ($a_{1000}^{999}$ is huge), and the size of the matrix. I am doing this in Java, and I don't even know how to store numbers that big.

Is there a better way of doing this than using matrices that is more efficient?

$\endgroup$
1
  • 1
    $\begingroup$ are you interested in that from a theorical point of view ?(then the answers below are fairly good) or do you have a practical problem at hand ? and if so, why do you need such a high degree polynomial ? $\endgroup$
    – G Cab
    Nov 1, 2017 at 18:43

2 Answers 2

3
$\begingroup$

The standard way of thinking about this is the Lagrange interpolation:

$$f(x)=\sum_{i=1}^{1000}b_i\prod_{\substack{j=0\\j \ne i}}^{1000} \frac{x-a_j}{a_i-a_j} .$$

I think if you're sufficiently clever you can write code for this that will be slightly more efficient than a standard matrix division but at $n=1000$ it might not even be worth it.

Of course, if you're using scipy to calculate these, there's already a function for that and if you're using a different system like MATLAB you can likely use a ready-made function like that as well, which deals with edge cases.

$\endgroup$
2
$\begingroup$

Yes! This is a standard problem in numerical analysis, and two possible solutions include using Lagrange interpolating polynomials, and Newton's method for interpolation.

$\endgroup$
3
  • $\begingroup$ Correct answer, but link only answers are discouraged on this site. $\endgroup$ Nov 1, 2017 at 17:32
  • $\begingroup$ This is a fair response, but I felt it would be more useful for OP to have an introduction to the ideas to read more about this very broad topic than a short m.se reply. $\endgroup$
    – B. Mehta
    Nov 1, 2017 at 17:33
  • 1
    $\begingroup$ Fair enough, and those are reliable links. $\endgroup$ Nov 1, 2017 at 17:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .