[Math] Lagrange 2nd dregree interpolating polynomial

calculusnumerical methodspolynomials

Given these set of points:
enter image description here

I must find the interpolating polinomial and find the value $0.32$

Using the Lagrange formula, I did:

$$P(x) = a\frac{(x-0,3)(x-0,4)}{(a-0,3)(a-0,4)}+b\frac{(x-0,3)(x-0,4)}{(b-0,3)(b-0,4)}$$
*where $a$ and $b$ are the respective values of $y$ for $x=0,3$ and $x=0,4$

Since he asks for a $2$ degree polynomial, then I think he's asking me to pick the 2 closest points to $x=0,32$ and interpolate it. I did it and arrived at a $2nd$ degree polynomial. But when I try online interpolation generators I always end up with a line equation. So, here's what I did:

$$P(x) = 0,067\frac{x^2 -0,7x + 0,12}{(0,067-0,3)(0,067-0,4)}-0,376\frac{x^2 -0,7x + 0,12}{(-0,376-0,3)(-0,376-0,4)}$$

$$P(x) = 0.067\frac{x^2 -0,7x + 0.12}{(-0.233)(-0.333)}-0.376\frac{x^2 -0,7x + 0.12}{(-0.676)(-0.776)}$$

$$P(x) = 0.86352(x^2 -0,7x + 0.12)-0.71676(x^2 -0,7x + 0.12) = $$
$$0.14676(x^2 -0,7x + 0.12)$$

Is my idea right? I didn't check the numbers, but am I doing it right?

In the other exercise, he asks me to find $P_3(0,32)$ (which I think is the third degree polynomial evaluated at $0,32$). So I shluld pick another close point, in this case $x=0,1$ and to the process?

UPDATE: Just figured out I did the ring thing: this polynomial is $0$ for $0.3$ and $0.4$, I'm dumb. How do I make it to be $1$ for these values?

Best Answer

The $n^{th}$ degree Lagrange interpolating polynomial $P_n(x)$ for the points $x_0,x_1,\dots,x_n$ is given by $$P_n(x)= \sum_{i=0}^n f(x_i)\prod\limits_{\substack{k=0 \\ k\neq i}}^n\frac{(x-x_k)}{(x_i-x_k)}$$ Notice thus, that in order to get an $n^{th}$ degree Lagrange interpolating polynomial, we need $(n+1)$ distinct points.

Thus, for the second degree polynomial to we require three points (the ones closest to $0.32$). Thus we choose the points $$0.1 ~~~ 0.3~~~ 0.4$$

So we get \begin{align}P_2(x) &= f(0.1)\frac{(x-0.3)(x-0.4)}{(0.1-0.3)(0.1-0.4)}+f(0.3)\frac{(x-0.1)(x-0.4)}{(0.3-0.1)(0.3-0.4)}+f(0.4)\frac{(x-0.1)(x-0.3)}{(0.4-0.1)(0.4-0.3)}\end{align}

Now, to answer your last question for $P_3(x)$ we need four points. We will must thus use all of them and get \begin{align}P_3(x) &= f(x_0)\frac{(x-x_1)(x-x_2)(x-x_3)}{(x_0-x_1)(x_0-x_2)(x_0-x_3)} +f(x_1)\frac{(x-x_0)(x-x_2)(x-x_3)}{(x_1-x_0)(x_1-x_2)(x_1-x_3)}+ f(x_2)\frac{(x-x_0)(x-x_1)(x-x_3)}{(x_2-x_0)(x_2-x_1)(x_2-x_3)} + f(x_3)\frac{(x-x_0)(x-x_1)(x-x_2)}{(x_3-x_0)(x_3-x_1)(x_3-x_2)}\end{align}

I will leave it to you to substitute in the appropriate values.