Lagrange Polynomial Interpolation Presentation-V3
Lagrange Polynomial Interpolation Presentation-V3
n x xj
Li ( x)
n
f n ( x) Li ( x) f ( xi )
i 0 j 0 xi x j
j i
For example:
linear n=1
n 1
1
f1 ( x) Li ( x) f ( xi ) Lo ( x) f ( x0 ) L1 ( x) f ( x1 )
i 0
1 x xj x x1
L0 ( x) note: j starts in 1 as j i
j 1 xi x j x0 x1
j i
Lagrange Polynomial Interpolation
For example:
n 1 linear n=1
1
f1 ( x) Li ( x) f ( xi ) Lo ( x) f ( x0 ) L1 ( x) f ( x1 )
i 0
1 x xj x x1
L0 ( x) note: j starts in 1 as j i
j 1 xi x j x0 x1
j i
1 x xj x x0
L1 ( x) note: j starts in 0 and doesn’t
j 0 xi x j x1 x0 run up to 1 as j must be j i
j i
x x1 x x0
f1 ( x) f ( x0 ) f ( x1 )
x0 x1 x1 x0
Lagrange Polynomial Interpolation
n x xj
Li ( x)
n
f n ( x) Li ( x) f ( xi )
i 0 j 0 xi x j
j i
For example:
n2 cuadratic n=2
( x x1 )( x x2 ) ( x x0 )( x x2 )
f1 ( x) f ( x0 ) f ( x1 )
( x0 x1 )( x0 x2 ) ( x1 x0 )( x1 x2 )
( x x0 )( x x1 )
f ( x2 )
( x2 x0 )( x2 x1 )
Lagrange Polynomial Interpolation
For example: n x xj
n2 Li ( x) cuadratic n=2
j 0 xi x j
j i
2 x xj x x1 x x2
L0 ( x)
j 1
xi x j x0 x1 x0 x2
j (i 0 )
2 x xj x x0 x x2
L1 ( x)
j 0 xi x j
x1 x0 x1 x2
j ( i 1)
2 x xj x x0 x x1
L2 ( x)
j 0 xi x j
x2 x0 x2 x1
j (i 2)
( x x1 )( x x2 ) ( x x0 )( x x2 ) ( x x0 )( x x1 )
f 2 ( x) f ( x0 ) f ( x1 ) f ( x2 )
( x0 x1 )( x0 x2 ) ( x1 x0 )( x1 x2 ) ( x2 x0 )( x2 x1 )
Quiz
• Develop a Lagrange interpolating polynomial of order n=3
In the formula, each term Li (x) will be equal to 1 for x=xi , and
zero for all other data points.
Thus, each product Li (x) fi(x) takes on the value of f(xi) at the
data point xi.
For example, consider:
( x x1 )( x x2 ) ( x x0 )( x x2 ) ( x x0 )( x x1 )
f 2 ( x) f ( x0 ) f ( x1 ) f ( x2 )
( x0 x1 )( x0 x2 ) ( x1 x0 )( x1 x2 ) ( x2 x0 )( x2 x1 )
For x=xo:
1 0 0
( x0 x1 )( x0 x2 ) ( x x )( x x ) ( x x )( x x )
f 2 ( x) f ( x0 ) 0 0 0 2 f ( x1 ) 0 0 0 1 f ( x2 )
( x0 x1 )( x0 x2 ) ( x1 x0 )( x1 x2 ) ( x2 x0 )( x2 x1 )
f 2 ( x) f ( x0 )
which is an expected results at x=xo, the
value of the function must be f(x0)
In the formula, as x approaches xo the weight term Lo(x)
approaches 1 and L1(x) and L2(x) approach zero, i.e., more weight
is put to the pair [xo, f(x0)] and less to the other pairs in the
formula
For xxo:
1 0 0
( x0 x1 )( x0 x2 ) ( x x )( x x ) ( x x )( x x )
f 2 ( x) f ( x0 ) 0 0 0 2 f ( x1 ) 0 0 0 1 f ( x2 )
( x0 x1 )( x0 x2 ) ( x1 x0 )( x1 x2 ) ( x2 x0 )( x2 x1 )
In the formula, each term Li (x) will be equal to 1 for x=xi , and
zero for all other data points.
Thus, each product Li (x) fi(x) takes on the value of f(xi) at the
data point xi.
In summary:
f1(x)
• The linear Lagrange
interpolating polynomial
that passes through the
points (2, 4) and (5, 1).
f1(x)
Example: Develop a 2nd degree Polynomial
• Use the numbers (called nodes) • We first determine the coefficient polynomials
x0 = 2, x1 = 2.75 and x2 = 4 to L0(x), L1(x), and L2(x):
find the second Lagrange
interpolating polynomial for
1
𝑓 𝑥 =
𝑥
f2(x)
f2(x)
Note the good
fitting of
Lagrange
polynomial in
the range of
the nodes
x=[2,2.75,4]
f2(x)