# Lagrange Interpolation Formula

Given $n$ distinct real values $x_1, x_2, \ldots x_n$ and $n$ real values $y_1, y_2, \ldots y_n$ (not necessarily distinct), the Lagrange Interperloation Formula gives a polynomial $P$ with real coefficients satisfying $P(x_i)=y_i$ for $i \in \{ 1,2, \ldots n \}$.

To describe polynomial $P$, we first solve the following problem: Given $n$ distinct real values $x_1, x_2, \ldots x_n$, does there exist a polynomial $f$ with real coefficients satisfying $f(x_1)=1$ and $f(x_i)=0$ for all values of $i \neq 1$?

By the Remainder-Factor Theorem, if such a polynomial exists, then for all $i\neq 1$, $(x-x_i)$ must be a factor of the polynomial. Consider the polynomial $g(x) = \prod \limits_{i=2}^n (x-x_i)$. This satisfies the conditions $g(x_i)=0$. Now let $F = g(x_1)$. Then since $F \neq 0$ (using the condition that the $x_i$ are distinct), we may divide by $F$ to obtain polynomial $f(x) = \frac{g(x)}{F}$. We have $f(x_i) = \frac {g(x_i)}{F} = 0$ and $f(x_1) = \frac {g(x_1)} {F} = 1$, giving the polynomial desired.

Let $P_j(x_j)$ be the polynomial with real coefficients satisfying $P_j (x_j)=1$ and $P_j (x_i)=0$ for all $i \neq j$. Then, $P(x) = \sum y_i P_i(x)$ is a polynomial with real coefficients satisfying $P(x_i)=y_i$ for all $i \in \{ 1,2, \ldots n \}$.

## Worked Examples

### 1. If we want to find a polynomial that satisfies

$P(1)=1, P(2)=4, P(3)=1, P(4)=5,$ what are the polynomials $P_1(x), P_2(x), P_3(x), P_4(x), P(x)$?

Let $f(x) = (x-2)(x-3)(x-4)$. Then

$f(1) = (-1)(-2)(-3)=-6 \text{, so } P_1(x) = -\frac {1}{6}(x-2)(x-3)(x-4).$

Let $f(x) = (x-1)(x-3)(x-4)$. Then

$f(2) = (1)(-1)(-2) = 2 \text{, so } P_2 (x) = \frac {1}{2} (x-1)(x-3)(x-4).$

Let $f(x) = (x-1)(x-2)(x-4)$. Then

$f(3) = (2)(1)(-1) = -2 \text{, so } P_3 (x) = -\frac {1}{2} (x-1)(x-2)(x-4).$

Let $f(x) = (x-1)(x-2)(x-3)$. Then

$f(4) = (3)(2)(1) = 6 \text{, so } P_4 (x) = \frac {1}{6} (x-1)(x-2)(x-3).$

Hence,

$P(x) = 1\times (-\frac {1}{6})(x-2)(x-3)(x-4) + 4\times \frac {1}{2} (x-1)(x-3)(x-4)$ $+ 1\times (-\frac {1}{2}) (x-1)(x-2)(x-4)+ 5 \times \frac {1}{6} (x-1)(x-2)(x-3).$

### 2. Show that if we require the polynomial in Lagrange's Interpolation Formula to have degree at most $n-1$, then there is a unique polynomial satisfying the conditions. Show further that this polynomial is $P(x)$ itself.

Suppose two polynomials $R(x)$ and $S(x)$ satisfy the conditions of Lagrange's Interpolation Formula and have degree at most $n-1$. Consider the polynomial $T(x) = R(x)-S(x)$. By the conditions, we have $T(x_i) = R(x_i)-S(x_i) = y_i-y_i=0$. Hence, by the Remainder-Factor Theorem,, for all values of $i$, $(x-x_i)$ must be a factor of $T(x)$. Since the $x_i$ are distinct, we have $T(x) = U(x) \prod \limits_{i=1}^n(x-x_i)$. If $U(x)$ is not the zero polynomial, then the degree on the right hand side is at least $n$, while the degree on the left hand side is at most $n-1$, which is a contradiction. Thus, $U(x)=0$, and so $T(x)=0$, which gives $R(x)=S(x)$. Hence, there is a unique polynomial which satisfies the conditions in the question. It is clear that each of the $P_i(x)$ has degree at most $n-1$ (it can have degree 0 if $y_i=0$). Hence, since $P(x)$ is the linear combination of these polynomials, it also has degree at most $n-1$.

### 3. Given $n$ distinct complex values $x_1, x_2, \ldots x_n$ and $n$ (not necessarily distinct) complex values $y_1, y_2, \ldots y_n$, does there exist a polynomial with complex coefficients satisfying $P(x_i)=y_i$ for all values of $i$?

Solution: Repeat the above discussion by replacing "real" with "complex". Then $P(x)= \sum y_i P_i(x)$ is a polynomial with complex coefficients.

Note by Calvin Lin
7 years, 1 month ago

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

• Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
• Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
• Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold
- bulleted- list
• bulleted
• list
1. numbered2. list
1. numbered
2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in $$ ... $$ or $ ... $ to ensure proper formatting.
2 \times 3 $2 \times 3$
2^{34} $2^{34}$
a_{i-1} $a_{i-1}$
\frac{2}{3} $\frac{2}{3}$
\sqrt{2} $\sqrt{2}$
\sum_{i=1}^3 $\sum_{i=1}^3$
\sin \theta $\sin \theta$
\boxed{123} $\boxed{123}$

Sort by:

@Calvin Lin Many a time I have seen people using Lagrange Multipliers where I generally use AM-GM. How is that done? And how do we find the next term of 1,2,3,4,5,? be Lagrange Interpolation? Trevor said me that it's something weird which I don't remember. Thanks!

- 6 years, 3 months ago

Lagrange interpolation is about finding a polynomial. AM-GM is Arithemtic Mean - Geometric Mean inequality. I do not see how they are related.

Are you asking about Method of Differences? If so, MOD only works when the values that you are given are consecutive (constant width apart), whereas LI is much more general and works for any set of $x$ values. E.g. find a quadratic polynomial such that $f(1) = 1, f(2) = 2, f(10) = 11$ would be easy with LI, but hard with MOD.

Staff - 6 years, 3 months ago

Oops! Sorry, it was Lagrange Multipliers not Lagrange Interpolation.

And Trevor once told me that by Lagrange Interpolation, the next term in the sequence 1,2,3,4,5,6, __ is something like $\sqrt{\pi}^{100i\cos{2.9}}$. I don't get how. @Calvin Lin

- 6 years, 3 months ago

i only understood a bit of it, can you please elaborate it.....

- 7 years, 1 month ago

Basically, if we want a polynomial running through points a,b,c,d, we need a degree 3 function.

We make a polynomial with 4 "parts"

$[p(x-a)(x-b)]+[q(x-a)(x-c)]+[r(x-b)(x-c)]$

Note how each part (I've separated them by []) have different 0's. The first part has 0's at x=a,b. Now, we plug in d into the function for x. Notice also how everyother part of the function becomes 0 when plugging in 0.

Let's say we want a function going through (1,2), (2,3), and (3,5)

In this case, a=1, b=2, c=3

$y=(x-a)(x-b)+q(x-a)(x-c)+r(x-b)(x-c)$

$y=p(x-1)(x-2)+q(x-1)(x-3)+r(x-2)(x-3)$

Plugging in x=a=1

$y=p(1-1)(1-2)+q(1-1)(1-3)+r(1-2)(1-3)$

$y=p(\color{#3D99F6}{0})(-1)+q(\color{#3D99F6}{0})(-2)+r(-1)(-2)$

$y=2r$

Remember, we want our function to go through (1,2), so y=2

$2=2r\Rightarrow r=1$

Now we have

$y=p(x-1)(x-2)+q(x-1)(x-3)+\color{#20A900}{1}(x-2)(x-3)$

Repeating this process for x=2

$y=p(2-1)(2-2)+q(2-1)(2-3)+r(2-2)(2-3)$

$y=p(1)(\color{#3D99F6}{0})+q(1)(-1)+r(\color{#3D99F6}{0})(-1)$

$y=-q$

In this case y=3

$3=-q\Rightarrow q=-3$

Now we have

$y=p(x-1)(x-2)+(\color{#20A900}{-3})(x-1)(x-3)+1(x-2)(x-3)$

Finally, repeating this for x=3, we know that the second and third parts of our eq will be 0 so I won't show those parts.

$y=p(2)(1)$

We want our function to go through (3,5), so y=5.

$5=2p\Rightarrow p=\frac{5}{2}$

Thus our function is

$y=\frac{5}{2}(x-1)(x-2)-3(x-1)(x-3)+(x-2)(x-3)$

- 6 years, 4 months ago