User:Joserbala/sandbox

Newton's polynomial Example
Another example:

The sequence $$f_0$$ such that $$f_0(1) = 6, f_0(2) = 9, f_0(3) = 2$$ and $$f_0(4) = 5$$, i.e., they are $$6, 9, 2, 5$$ from $$x_0 = 1$$ to $$x_3 = 4$$.

You obtain the slope of order $$1$$ in the following way:
 * $$f_1(x_0, x_1) = \frac{f_0(x_1) - f_0(x_0)}{x_1 - x_0} = \frac{9 - 6}{2 - 1} = 3$$
 * $$f_1(x_1, x_2) = \frac{f_0(x_2) - f_0(x_1)}{x_2 - x_1} = \frac{2 - 9}{3 - 2} = -7$$
 * $$f_1(x_2, x_3) = \frac{f_0(x_3) - f_0(x_2)}{x_3 - x_2} = \frac{5 - 2}{4 - 3} = 3$$

As we have the slopes of order $$1$$, it's possible to obtain the next order:
 * $$f_2(x_0, x_1, x_2) = \frac{f_1(x_1, x_2) - f_1(x_0, x_1)}{x_2 - x_0} = \frac{-7 - 3}{3 - 1} = -5$$
 * $$f_2(x_1, x_2, x_3) = \frac{f_1(x_2, x_3) - f_1(x_1, x_2)}{x_3 - x_1} = \frac{3 - (-7)}{4 - 2} = 5$$

Finally, we define the slope of order $$3$$:
 * $$f_3(x_0, x_1, x_2, x_3) = \frac{f_2(x_1, x_2, x_3) - f_2(x_0, x_1, x_2)}{x_3 - x_0} = \frac{5 - (-5)}{4 - 1} = \frac{10}{3}$$

Once we have the slope, we can define the consequent polynomials:
 * $$p_0(x) = 6$$.
 * $$p_1(x) = 6 + 3(x - 1)$$
 * $$p_2(x) = 6 + 3(x - 1) - 5(x - 1)(x - 2)$$.
 * $$p_3(x) = 6 + 3(x - 1) - 5(x - 1)(x - 2) + \frac{10}{3} (x - 1)(x - 2)(x - 3)$$