6. 1st Order LAGRANGE POLYNOMIAL
INTERPOLATION
Example: Find y at x = 2.2
# Find 1st order Lagrange Polynomial Equation
# Plug in data and Simplify, and Validate
# Plug in given data to newly found function
f(x) =
𝒙−𝒙𝟐
𝒙𝟏−𝒙𝟐
y1 +
𝒙−𝒙𝟏
𝒙𝟐−𝒙𝟏
y2
*** Short Cut
X Y
2 5
3 10
7. 2nd Order LAGRANGE POLYNOMIAL
INTERPOLATION
Example: Find y at x = 2.5
n=3 thus 2nd order Lagrange
# Find General order Lagrange Polynomial Equation
# Plug in data and Simplify; then Validate
# Plug in given data to newly found function
f(x) =
(𝒙−𝒙𝟐)(𝒙−𝒙𝟑)
𝒙𝟏
−𝒙𝟐
(𝒙𝟏
−𝒙𝟑
)
y1 +
(𝒙−𝒙𝟏)(𝒙−𝒙𝟑)
𝒙𝟐
−𝒙𝟏
(𝒙𝟐
−𝒙𝟑
)
y2 +
(𝒙−𝒙𝟏)(𝒙−𝒙𝟐)
𝒙𝟑
−𝒙𝟏
(𝒙𝟑
−𝒙𝟐
)
y3
X Y
1 4
3 8
7 10
8. 2nd Order LAGRANGE POLYNOMIAL
INTERPOLATION
Example: Find y at x = 2.5
n=3 thus 2nd order Lagrange
f(x) =
(𝒙−𝒙𝟐
)(𝒙−𝒙𝟑
)
𝒙𝟏
−𝒙𝟐
(𝒙𝟏
−𝒙𝟑
)
y1 +
(𝒙−𝒙𝟏
)(𝒙−𝒙𝟑
)
𝒙𝟐
−𝒙𝟏
(𝒙𝟐
−𝒙𝟑
)
y2 +
(𝒙−𝒙𝟏
)(𝒙−𝒙𝟐
)
𝒙𝟑
−𝒙𝟏
(𝒙𝟑
−𝒙𝟐
)
y3
= - 0.25 x2 + 3x + 1.25
if x = 2.5, then y should be 7.1875.
X Y
1 4
3 8
7 10
9. 3rd Order LAGRANGE POLYNOMIAL
INTERPOLATION
Example: Find y at x = 3
n=4 thus 3rd order Lagrange
f(x) =
(𝒙−𝒙𝟐
)(𝒙−𝒙𝟑
)(𝒙−𝒙𝟒
)
𝒙𝟏
−𝒙𝟐
(𝒙𝟏
−𝒙𝟑
)(𝒙𝟏
−𝒙𝟒
)
y1 +
(𝒙−𝒙𝟏
)(𝒙−𝒙𝟑
)(𝒙−𝒙𝟒
)
𝒙𝟐
−𝒙𝟏
(𝒙𝟐
−𝒙𝟑
)(𝒙𝟐
−𝒙𝟒
)
y2 +
(𝒙−𝒙𝟏
)(𝒙−𝒙𝟐
)(𝒙−𝒙𝟒
)
𝒙𝟑
−𝒙𝟏
(𝒙𝟑
−𝒙𝟐
)(𝒙𝟑
−𝒙𝟒
)
y3 +
(𝒙−𝒙𝟏
)(𝒙−𝒙𝟐
)(𝒙−𝒙𝟑
)
𝒙𝟒
−𝒙𝟏
(𝒙𝟒
−𝒙𝟐
)(𝒙𝟒
−𝒙𝟑
)
y4
= 0.25 x3 – 1.5833x2 + 5x + 0.333
if x = 3, then y should be 7.833.
X Y
1 4
2 6
4 11
5 17
11. NEWTON’S DIVIDED DIFFERENCE &
POLYNOMIAL INTERPOLATION
DIVIDED DIFFERENCE INTERPOLATION Numerical Interpolation
method to find the coefficients of a curve fitting polynomial
Newton’s polynomial polynomials that we use to interpolate for a specified
set of data. Advantage: faster, recursive, better
18. GLOBAL VS LOCAL INTERPOLATION
Interpolation used to find continuous (& ideally smooth) functions from discrete data
points Interpolating function f(x)
Discrete data points
Interpolation Process:
Given data set
Fit interpolating function for the given data set
Use newly found function to find the output for any input (within domain)
Y
X
19. GLOBAL VS LOCAL INTERPOLATION
GLOBAL INTERPOLATION LOCAL INTERPOLATION
Uses all supplied data to create the interpolating
function; Single/Higher order polynomial
Uses only a subset of all supplied data points
Consists of lower order polynomials
E.g. Lagrange Polynomials, Divided Difference E.g. Spline Interpolation
Must use all data; Always gives the same answer Local Interpolation can use all or little of our supplied
data (must all be continuous and connecting)
Problem: Increase polynomial order = Increase error
at edges of our equal distance input points
Y
X
Global Polynomial
364th Order
Local Polynomial
1st or 2nd
Order
21. TYPES OF SPLINE INTERPOLATIONS
1ST Order – Linear Spline 2nd Order – Cubic Spline
More widely used
Y
Y1
Y0, Y2
X0 X1 X2 X
Y
Y1
Y0, Y2
X0 X1 X2 X
22. LINEAR SPLINE INTERPOLATIONS
1ST Order – Linear Spline
These often lead to knots/sharp changes in our function which
is un-ideal as we want to smooth continuous functions
P2(x)
P1(x) We assume our function to be linear
** How de we go about finding P1(x) and a point along it?
EACH SEGMENT IS SIMPLY A STRAIGHT LINE EQUATION
Gen. Equation of Line: y = mx + b
P1(x) = Y1 +
𝑌2
−𝑌1
𝑋2
−𝑋1
(X – X1)
P2(x) = Y2 + 𝑌3
−𝑌2
𝑋3
−𝑋2
(X – X2)
Y
Y1
Y0, Y2
X0 X1 X2 X
23. LINEAR SPLINE INTERPOLATIONS
Given
Find the necessary interpolating functions
Find the outputs at x = 2, 5 and 10
P2(x)
P1(x)
Gen. Equation of Line: y = mx + b
P1(x) = 2 + 8−2
6−1
(X – 1) = 1.2x + 0.8
1 ≤ 𝑥 ≤ 6
P2(x) = 10 +
14−10
12−9 (X – 9) = 4
3
𝑥 - 2 @ x=2, use P1(x) y=3.2
9 ≤ 𝑥 ≤ 12 @ x=5, use P1(x) y=6.8
@ x=10, use P2(x) y=11.3333
X Y
1 2
6 8
7 6
9 10
12 14
20 41
Y
X
24. QUADRATIC SPLINE INTERPOLATIONS
Given
Find the necessary interpolating functions
Find the outputs at x = 2, 4 and 7
P3(x)
*** 3n equations P2(x)
3 splines = 9 unknowns P1(x)
Write out General polynomials
Identify unknowns
Solve unknowns
Plug in X-inputs
X Y
1 2
3 3
5 9
8 10
Y
X
25. QUADRATIC SPLINE INTERPOLATIONS
X Y
1 2
3 3
5 9
8 10
Y
X
P2(x)
P1(x)
P3(x)
(1) Polynomials to find:
P1(x) = a1 X2 + b1 X + c1
P2(x) = a2 X2 + b2 X + c2
P3(x) = a3 X2 + b3 X + c3
(2) 9 unknowns a1, b1, c1, a2, b2, c2, a3, b3, c3