You are on page 1of 24

Lagrangian Interpolation

1
Lagrange Method of
Interpolation

http://numericalmethods.eng.usf.edu
What is Interpolation ?
Given (x0,y0), (x1,y1), …… (xn,yn), find the value
of ‘y=f(x)’ at a value of ‘x’ that is not given.

3
Interpolants
Polynomials are the most common
choice of interpolants because they
are easy to:

Evaluate
Differentiate, and
Integrate.

4 http://numericalmethods.eng.usf.edu
Lagrange Interpolating Polynomials
The Lagrange interpolating polynomial is simply a
reformulation of the Newton’s polynomial that avoids the
computation of divided differences:
Lagrangian interpolating polynomial is given by

Lagrangian interpolating polynomial is given by


n

Where )
f n ( x´n´ inLfi n( (x)
x) f ( stands
xi ) for the nth order polynomial that
i 0
approximates the function y = f(x), given at (n+1) data points
where ‘ n ’ in f n (x) stands for the n order polynomial that approximates the function y  f (x)
th

(x0,y0), (xi,y1),…,(xn,yn) and


given at (n  1) data points as  x 0 , y 0  ,  x1 , y1  ,......,  x n 1 , y n 1  ,  x n , y n  , and
n x  xj
Li ( x)  
j 0 xi  x j
j i

Li (x) is a weighting function that includes a product of (n  1) terms with terms of j  i


omitted. Chapter 18 5
5 http://numericalmethods.eng.usf.edu
to Linear Interpolation we use the following structure

For Quadratic Interpolation is used the following structure

• As with Newton’s method, the Lagrange version has


an estimated error of:
n
Rn  f [ x, xn , xn 1 ,  , x0 ] ( x  xi )
by Lale Yurttas,
6 i A&M
Texas 0 University Chapter 18
Example
The upward velocity of a rocket is given as a function of
time in Table 1. Find the velocity at t=16 seconds using
the Lagrangian method for linear interpolation.

Table Velocity as a
function of time
t (s) v(t ) (m/s)
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67

Figure. Velocity vs. time data


7 for the rocket example http://numericalmethods.eng.usf.edu
Linear Interpolation
550
517.35

1
v(t )   Li (t )v(ti ) 500
i 0
ys
 L0 (t )v (t 0 )  L1 (t )v (t1 ) f ( range)
450

f x desired 

t 0  15,  t 0   362.78 400

t1  20,  t1   517.35 362.78 350


10 12 14 16 18 20 22 24
x s 10 x s  range x desired x s  10
0 1

8 http://numericalmethods.eng.usf.edu
Linear Interpolation (contd)

1 t tj t  t1
L0 (t )   
j 0 t0  t j t 0  t1
j 0

1 t tj t  t0
L1 (t )   
j 0 t1  t j t1  t 0
j 1

t  t1 t  t0 t  20 t  15
v (t )  v(t 0 )  v(t1 )  (362.78)  (517.35)
t 0  t1 t1  t 0 15  20 20  15
16  20 16  15
v(16)  (362.78)  (517.35)
15  20 20  15
 0.8(362.78)  0.2(517.35)

 393.7 m/s.

9 http://numericalmethods.eng.usf.edu
Quadratic Interpolation
For the second order polynomial interpolation (also called quadratic interpolation), we
choose the velocity given by
2
v (t )   Li ( t ) v(t i )
i 0

 L0 (t )v (t 0 )  L1 (t ) v( t1 )  L2 (t) v( t 2 )

10 http://numericalmethods.eng.usf.edu
Example 2
The upward velocity of a rocket is given as a function of
time in Table 1. Find the velocity at t=16 seconds using the
Lagrangian method for quadratic & cubic interpolation.

Table Velocity as a
function of time
t (s) v(t ) (m/s)
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67

Figure. Velocity vs. time data


11 for the rocket example http://numericalmethods.eng.usf.edu
Quadratic Interpolation (contd)
t 0  10, v(t 0 )  227.04
t1  15, v(t1 )  362.78
t 2  20, v(t 2 )  517.35 f(x) = 9.42 x² + 107.5 x + 110.13
R² = 1 Vt contra t
12

2 t tj  t  t1  t  t2  10
L0 (t )      
j 0 t0  t j t  t
 0 1  0 2 t  t 8
j 0
vt
6

vt
Polynomial (vt)
2 t t j  t  t0  t  t 2 
L1 (t )       4
j 0 t1  t j  t1  t 0  t1  t 2  2
j 1

0
2 t tj  t  t 0  t  t1  5 5.5 6 6.5 7 7.5 8 8.5 9 9.5 10
L2 (t )      
j 0 t2  t j t  t
 2 0  2 1  t  t f
j 2

12 http://numericalmethods.eng.usf.edu
To calculate the quadratic equation  the structure is as follows

V(t)=)+ )+)

V(t)=) ++ (517.35)  

V(t)=+  + (t-15)

V(t)= 4.54080(t2 -35t+300)-14.5112(t2 -30t+200)+10.347(t2 -25t+150)

V(t)=4.5408000t2 - 158.92800t + 1362.2400


-14.511200t2 + 435.33600t - 2902.2400
y = 0.3766x2 +
10.347000t2 - 258.67500t + 1552.0500 17.733x + 12.05
v(t) = 0.376600t2 +17.73300t + 12.050000

V(t)=0.37660000*(16)+17.7330000(16)+12.050000 = 392.18 m/s


13 http://numericalmethods.eng.usf.edu
Quadratic Interpolation (contd)

The absolute relative approximate error


  obtained between the results
from the first and second order polynomial is

39219 − 39270
  ∗100=0.38410 %
|∈𝑎|= | 39219 |

14 http://numericalmethods.eng.usf.edu
Cubic Interpolation
For the third order polynomial (also called cubic intepolation), we
choose the velocity given by
the third order polynomial (also called cubic interpolation), we choose the velocity given by
3
v (t )   Li ( t ) v(t i )
i 0

 L0 (t ) v( t0 )  L1 ( t ) v(t 1 )  L2 ( t ) v(t 2 )  L3 ( t ) v(t 3 )

700
602.97
Grafica de los valores de t y vt
700
600
600
f(x) = 0.01 x³ + 0.13 x² + 21.27 x − 4.25
500 R² = 1
ys 500

f ( range) 400
vt
 
vt

f x desired
400
300 Polynomial (vt)

200

300 100

0
227.04 5 7 9 11 13 15 17 19 21 23 25
200
10 12 14 16 18 20 22 24
10 x s  range x desired 22.5 t

15 http://numericalmethods.eng.usf.edu
Example
The upward velocity of a rocket is given as a function of
time in Table 1. Find the velocity at t=16 seconds using
the Lagrangian method for cubic interpolation.

Table Velocity as a
function of time
t (s) v(t ) (m/s)
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67

Figure. Velocity vs. time data


16 for the rocket example http://numericalmethods.eng.usf.edu
Cubic Interpolation (contd)
t o  10, v  t o   227.04 t1  15, v  t1   362.78

t 2  20, v  t 2   517.35 t 3  22.5, v  t 3   602.97

700
3 t tj  t  t 1  t  t 2  t  t 3  602.97

L0 (t )        ;
j 0 t0  t j t  t t  t
 0 1  0 2  0 3  t  t 600
j 0

3 t t j  t  t0  t  t 2  t  t 3 
L1 (t )  
ys
     500

t1  t j  t1  t 0  t1  t 2  t1  t 3 
f ( range)
j 0
j 1 
f x desired 
400

3 t tj  t  t 0  t  t1  t  t 3 
L2 (t )        ;
t2  t j  t 2  t 0  t 2  t 1  t 2  t 3 
300
j 0
j2

227.04
3 t tj  t  t 0  t  t1  t  t 2  200

L3 ( t )  
10 12 14 16 18 20 22 24
     10 x s  range x desired 22.5

j 0 t3  t j t  t t  t
 3 0  3 1  3 2  t  t
j 3

17 http://numericalmethods.eng.usf.edu
Cubic Interpolation (contd)
 t  t1  t  t 2  t  t3   t  t0  t  t 2  t  t3 
v t      v t1      v t 2 
t  t t 
 0 1  0 2  0 3  t t  t t  t t
 1 0  1 2  1 3   t t  t
 t  t0  t  t1  t  t3   t  t1  t  t1  t  t 2 
    v t 2      v t3 
t  t t 
 2 0  2 1  2 3  t t  t t  t t
 3 1  3 1  3 2   t t  t
 16  15  16  20  16  22.5   16  10  16  20  16  22.5 
v16      227.04      362.78
 10  15  10  20  10  22.5   15  10  15  20  15  22.5 
 16  10  16  15  16  22.5   16  10  16  15  16  20 
    517.35      602.97 
 20  10  20  15  20  22 .5   22 .5  10  22.5  15  22 .5  20 
   0.0416 227.04    0.832 362.78   0.312 517.35    0.1024 602.97 
 392.06 m/s
The absolute relative approximate error a obtained between the
results from the first and second order polynomial is
392.06  392.19
a  100
392.06
 0.033269%
18 http://numericalmethods.eng.usf.edu
Comparison Table

Order of
1 2 3
Polynomial
v(t=16) m/s 393.69 392.19 392.06
Absolute Relative
-------- 0.38410% 0.033269%
Approximate Error

19 http://numericalmethods.eng.usf.edu
Distance from Velocity Profile
Find the distance covered by the rocket from t=11s to
t=16s ?
v(t )  (t 3  57.5t 2  1087.5t  6750)( 0.36326)  (t 3  52.5t 2  875t  4500)(1.9348)
 (t 3  47.5t 2  712.5t  3375)( 4.1388)  (t 3  45t 2  650t  3000)( 2.5727)
v (t )  4.245  21.265t  0.13195t 2  0.00544t 3 , 10  t  22.5
16
s(16)  s (11)   v( t ) dt
11

16
  ( 4.245  21.265t  0.13195t 2  0.00544t 3 ) dt
11

t2 t3 t 4 16
 [ 4.245t  21.265  0.13195  0.00544 ]11
2 3 4

 1605 m
20 http://numericalmethods.eng.usf.edu
Acceleration from Velocity Profile
Find the acceleration of the rocket at t=16s given that

v(t )  4.245  21.265t  0.13195t 2  0.00544t 3 , 10  t  22.5

a  t   v  t     4.245  21.265t  0.13195t  0.00544t 3 


d d 2 ,

dt dt

 21.265  0.26390t  0.01632t 2


a (16)  21. 265  0.26390(16)  0.01632(16) 2

 29.665 m / s 2

21 http://numericalmethods.eng.usf.edu
Additional Resources
For all resources on this topic such as digital audiovisual
lectures, primers, textbook chapters, multiple-choice
tests, worksheets in MATLAB, MATHEMATICA, MathCad
and MAPLE, blogs, related physical problems, please
visit

http://numericalmethods.eng.usf.edu/topics/lagrange_
method.html

Year: 1951 1961 1971


Population
2.8 3.2 4.5
(Million):
Example No 5: The population of Mississippi
during three census periods was as follows:

Year: 1951 1961 1971 1981


Populati
on 2.8 3.2 4.5 4.8
(Million):

Interpolate the population during 1966.

24 http://numericalmethods.eng.usf.edu

You might also like