Computational physics
Interpolation
Interpolation
If you have a set of data points x and y where y=f(x)
Can you find f(38)?
Interpolation is the process of using known data values to estimate
unknown data values.
This is usually done by deriving a simple function from a set of
discrete data points so that the function passes through all the given
data points (i.e. reproduces the data points exactly) and can be used
to estimate data points in-between the given ones.
Graphical
Interpolation
Interpolation
methods Lagrange’s method
Polynomial
Interpolation
Newton’s method
Interpolation: Graphical method
If you have a set of data points x and y where y=f(x)
! 38 =? ?
From the graph,
! 38 = 35
There is one drawback in the graphic
method which states that the value
of y obtained is the estimated value
of y not the actual one.
Polynomial Interpolation: Lagrange method
Lagrange method
Lagrange polynomial is used for polynomial interpolation.
Lagrange formula !
'! ()) = + ! )% ℓ" ())
where "#$
Where - is the order of the polynomial.
Polynomial Interpolation: Lagrange method
Lagrange method
For linear interpolation, n=1
! !
) − )'
'! ) = + ! )% ℓ" ) , ℓ" ()) = 2
)" − )'
"#$ '#$
'("
'& ()) = ℓ$ ! )$ + ℓ& ! )&
where
) − )& ) − )$
ℓ$ = , ℓ& =
)$ − )& )& − )$
) − )& ) − )$
'& ()) = ! )$ + ! )&
)$ − )& )& − )$
Polynomial Interpolation: Lagrange method
Lagrange method
For quadratic interpolation, n=2
! !
) − )'
'! ) = + ! )% ℓ" ) , ℓ" ()) = 2
)" − )'
"#$ '#$
'("
') ) = ℓ$ ! )$ + ℓ& ! )& + ℓ) ! ))
where
($ − $!)($ − $#) ($ − $")($ − $#) ($ − $")($ − $!)
ℓ"= , ℓ!= , ℓ#=
($"−$!)($"−$#) ($! − $")($! − $#) ($# − $")($# − $!)
(+,+!)(+,+") (+,+#)(+,+") (+,+#)(+,+!)
') ()) = (+ ! )$ + (+ ! )& + (+ ! ))
# ,+! )(+# ,+" ) ! ,+# )(+! ,+" ) " ,+# )(+" ,+! )
Polynomial Interpolation: Lagrange method
Lagrange method
• To generalize, (th order polynomial is the summation of (( + 1)(th order
polynomials.
• Each of these (th order polynomials have a value of 1 at one of the data
points and have values of 0 at all other data points.
• This is due to the following property of Lagrange functions
1 at + = +%
• ℓ$ (+) = ,
0 at all other data points
Polynomial Interpolation: Lagrange method
Example 1
Use the Lagrange interpolation to find the unique polynomial P3(x),
of degree 3 or less, that agrees with the following data:
Find P3(x) for x=0.5,1.5
x y
-1 3
0 -4
1 5
2 -6
Polynomial Interpolation: Lagrange method
Example 2
Find Solution of f(1) using Lagrange's Interpolation formula,
Keep four decimal places in your computations.
x y
-1 3
0 -6
3 39
6 822
7 1611
Polynomial Interpolation: Newton method
Newton’s method
In the Newton’s method, the interpolating polynomial is written in
the form:
"! ($) = %" + $ − $" %# + $ − $" $ − $# %$ + ⋯ + $ − $" ⋯ $ − $!%# %!
where the constants are:
% " = * $" ,
%# = * $# , $" ,
%$ = * $$ , $# , $" ,
…
%! = * $! , $!%# , … , $# , $"
Polynomial Interpolation: Newton method
The divided differences
- The first-order divided difference
. /& − . /'
. /&, /' =
/& − /'
- The second-order divided difference
. /&, /' − . /', /(
. /&, /', /( =
/& − /(
- The nth-order divided difference
* $! , $!%# , … , $# − * $!%# , … , $# , $"
* $! , $!%# , … , $# , $" =
$! − $"
Polynomial Interpolation: Newton method
It is convenient to work with the format in the following table:
) !()% ) ![, ], ![, , ], ![, , , ],
)$ ! )$
)& ! )& ! )& , )$
)) ! )) ! )) , )& ! )) , )& , )$
). ! ). ! ). , )) ! ). , )) , )& ! ). , )) , )& , )$
Polynomial Interpolation: Newton method
It is convenient to work with the format in the following table:
) !()% ) ![, ], ![, , ], ![, , , ],
)$ ! )$
)& ! )& ! )& , )$
)) ! )) ! )) , )& ! )) , )& , )$
). ! ). ! ). , )) ! ). , )) , )& ! ). , )) , )& , )$
The diagonal terms in the table are the coefficients of the polynomial.
Polynomial Interpolation: Newton method
Example 3
The upward velocity of a rocket is given as a function of time in the
following table. Find the velocity at 6 = 16 seconds using the Newton
Divided Difference method for:
/, ( 2) 3(/), (4/2)
a) Linear interpolation.
0 0
b) Quadratic interpolation 10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
Polynomial Interpolation: Newton method
Example 4
Use Newton’s divided difference method to compute f(2) from the
experimental data shown:
A B
-1 3
0 −2
0.5 −0.375
1 3
2.5 16.125
3 19
H.W 3
1- The velocity as a function of time is given in the table below:
Find the v(15) using Lagrange Interpolating Polynomials of order 1.
t(s) 0 8 13 18 23 26
v(m/s) 0 225 370 520 630 890
2- Fit a quadratic polynomial to the following data points by Lagrange
interpolation. (-2, 9), (5,-12), (10,33) for x=8
3- The observed values of a function are respectively 168, 120, 72, and 63
at the four position 3, 7, 9 and 10 of the independent variable. Using
Newton method find the best estimated value of the function at the position
6 of the independent variable?
4- Use both the Lagrange and Newton method to find an interpolation of
degree 2 for the following data:
(0, 1), (2,2), (3,4)