Skip to content

Commit 8f2609b

Browse files
authored
Update lagrange_polynomial_interpolation.md
1 parent fd3a1f9 commit 8f2609b

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

notes/6_regression/lagrange_polynomial_interpolation.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Lagrange Polynomial Interpolation is a widely used technique for determining a polynomial that passes exactly through a given set of data points. Suppose we have a set of $(n+1)$ data points $(x_0, y_0), (x_1, y_1), \ldots, (x_n, y_n)$ where all $x_i$ are distinct. The aim is to find a polynomial $L(x)$ of degree at most $n$ such that:
44

5-
$$L(x_i) = y_i, \quad \text{for} \; i=0,1,\ldots,n.$$
5+
$$L(x_i) = y_i, \quad \text{for} \; i=0,1,\ldots,n$$
66

77
Instead of solving a system of linear equations (as would be required if we used a general polynomial form), Lagrange interpolation provides a direct formula for the interpolating polynomial in terms of **Lagrange basis polynomials**. This approach is conceptually straightforward and does not require forming and solving large linear systems.
88

@@ -22,7 +22,7 @@ I. **Lagrange Basis Polynomials:**
2222

2323
For each $i$ in $\{0,1,\ldots,n\}$, define the $i$-th Lagrange basis polynomial $P_i(x)$ by:
2424

25-
$$P_i(x) = \prod_{\substack{j=0 \\ j \neq i}}^{n} \frac{x - x_j}{x_i - x_j}.$$
25+
$$P_i(x) = \prod_{\substack{j=0 \\ j \neq i}}^{n} \frac{x - x_j}{x_i - x_j}$$
2626

2727
Notice that $P_i(x_k) = \delta_{ik}$, where $\delta_{ik}$ is the Kronecker delta. In other words:
2828

@@ -36,19 +36,19 @@ II. **Lagrange Interpolating Polynomial:**
3636

3737
Once we have the $P_i(x)$, the interpolating polynomial $L(x)$ is given by:
3838

39-
$$L(x) = \sum_{i=0}^{n} y_i P_i(x).$$
39+
$$L(x) = \sum_{i=0}^{n} y_i P_i(x)$$
4040

4141
By construction, $L(x_j) = y_j$ for all $j$. The degree of $L(x)$ is at most $n$.
4242

4343
### Derivation
4444

4545
Starting from the requirement that $L(x)$ matches all data points:
4646

47-
$$L(x_i) = y_i \quad \text{for } i=0,1,\ldots,n.$$
47+
$$L(x_i) = y_i \quad \text{for } i=0,1,\ldots,n$$
4848

4949
Consider polynomials $P_i(x)$ defined as:
5050

51-
$$P_i(x) = \prod_{\substack{j=0 \\ j \neq i}}^{n} \frac{x - x_j}{x_i - x_j}.$$
51+
$$P_i(x) = \prod_{\substack{j=0 \\ j \neq i}}^{n} \frac{x - x_j}{x_i - x_j}$$
5252

5353
This construction ensures that for each fixed $i$:
5454

@@ -59,7 +59,7 @@ Hence $P_i(x)$ acts like a "selector" polynomial that equals 1 at $x_i$ and 0 at
5959

6060
To construct $L(x)$ that passes through all points, we form:
6161

62-
$$L(x) = \sum_{i=0}^{n} y_i P_i(x).$$
62+
$$L(x) = \sum_{i=0}^{n} y_i P_i(x)$$
6363

6464
Evaluating at $x = x_k$:
6565

@@ -84,13 +84,13 @@ For each $i=0,1,\ldots,n$:
8484
- Initialize $P_i(x)=1$.
8585
- For each $j=0,1,\ldots,n$ with $j \neq i$:
8686

87-
$$P_i(x) = P_i(x) \cdot \frac{x - x_j}{x_i - x_j}.$$
87+
$$P_i(x) = P_i(x) \cdot \frac{x - x_j}{x_i - x_j}$$
8888

8989
IV. **Form the Interpolating Polynomial**:
9090

9191
Compute:
9292

93-
$$L(x) = \sum_{i=0}^{n} y_i P_i(x).$$
93+
$$L(x) = \sum_{i=0}^{n} y_i P_i(x)$$
9494

9595
**Result**:
9696

@@ -102,29 +102,29 @@ The polynomial $L(x)$ is the desired Lagrange interpolating polynomial. To inter
102102

103103
Let’s consider three points:
104104

105-
$$A(-1,1), \quad B(2,3), \quad C(3,5).$$
105+
$$A(-1,1), \quad B(2,3), \quad C(3,5)$$
106106

107107
We have $n=2$ (since there are 3 points), and thus the polynomial $L(x)$ will be of degree at most 2.
108108

109109
**Compute $P_0(x)$** for the point $A(-1, 1)$:
110110

111-
$$P_0(x) = \frac{(x - x_1)(x - x_2)}{(x_0-x_1)(x_0-x_2)} = \frac{(x - 2)(x - 3)}{(-1 -2)(-1 -3)} = \frac{(x - 2)(x - 3)}{(-3)(-4)} = \frac{(x - 2)(x - 3)}{12}.$$
111+
$$P_0(x) = \frac{(x - x_1)(x - x_2)}{(x_0-x_1)(x_0-x_2)} = \frac{(x - 2)(x - 3)}{(-1 -2)(-1 -3)} = \frac{(x - 2)(x - 3)}{(-3)(-4)} = \frac{(x - 2)(x - 3)}{12}$$
112112

113113
**Compute $P_1(x)$** for the point $B(2,3)$:
114114

115-
$$P_1(x) = \frac{(x - x_0)(x - x_2)}{(x_1 - x_0)(x_1 - x_2)} = \frac{(x +1)(x - 3)}{(2 + 1)(2 - 3)} = \frac{(x+1)(x - 3)}{3 \cdot (-1)} = -\frac{(x+1)(x-3)}{3}.$$
115+
$$P_1(x) = \frac{(x - x_0)(x - x_2)}{(x_1 - x_0)(x_1 - x_2)} = \frac{(x +1)(x - 3)}{(2 + 1)(2 - 3)} = \frac{(x+1)(x - 3)}{3 \cdot (-1)} = -\frac{(x+1)(x-3)}{3}$$
116116

117117
**Compute $P_2(x)$** for the point $C(3,5)$:
118118

119-
$$P_2(x) = \frac{(x - x_0)(x - x_1)}{(x_2 - x_0)(x_2 - x_1)} = \frac{(x +1)(x - 2)}{(3 + 1)(3 - 2)} = \frac{(x+1)(x - 2)}{4}.$$
119+
$$P_2(x) = \frac{(x - x_0)(x - x_1)}{(x_2 - x_0)(x_2 - x_1)} = \frac{(x +1)(x - 2)}{(3 + 1)(3 - 2)} = \frac{(x+1)(x - 2)}{4}$$
120120

121121
Now, plug these into $L(x)$:
122122

123123
$$L(x) = y_0 P_0(x) + y_1 P_1(x) + y_2 P_2(x)$$
124124

125125
Substitute $(y_0, y_1, y_2) = (1,3,5)$:
126126

127-
$$L(x) = 1 \cdot \frac{(x - 2)(x - 3)}{12} + 3 \cdot \left(-\frac{(x+1)(x - 3)}{3}\right) + 5 \cdot \frac{(x+1)(x-2)}{4}.$$
127+
$$L(x) = 1 \cdot \frac{(x - 2)(x - 3)}{12} + 3 \cdot \left(-\frac{(x+1)(x - 3)}{3}\right) + 5 \cdot \frac{(x+1)(x-2)}{4}$$
128128

129129
This polynomial will exactly fit the three given points.
130130

0 commit comments

Comments
 (0)