Sei sulla pagina 1di 21

Lagrangian Interpolation

Major: All Engineering Majors


Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates
http://numericalmethods.eng.usf.edu

Lagrange Method of
Interpolation

http://numericalmethods.eng.usf.edu

What is Interpolation ?
Given (x0,y0), (x1,y1), (xn,yn), find the
value of y at a value of x that is not given.

http://numericalmethods.eng.usf.edu

Interpolants
Polynomials are the most common
choice of interpolants because they
are easy to:
Evaluate
Differentiate, and
Integrate.
4

http://numericalmethods.eng.usf.edu

Lagrangian Interpolation
Lagrangian interpolating polynomial is given by
n

f n ( x) Li ( x) f ( xi )
i 0

where n in f n (x) stands for the n th order polynomial that approximates the function y f (x)
given at (n 1) data points as x0 , y 0 , x1 , y1 ,......, x n 1 , y n 1 , x n , y n , and
n

Li ( x)
j 0
j i

x xj
xi x j

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


omitted.

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 linear interpolation.
Table Velocity as a
function of time
t (s) v(t ) (m/s)

0
10
15
20
22.5
30

0
227.04
362.78
517.35
602.97
901.67
Figure. Velocity vs. time data
for the rocket example http://numericalmethods.eng.usf.edu

Linear Interpolation
517.35

550

v(t ) Li (t )v(ti )

500

i 0

L0 (t )v(t 0 ) L1 (t )v(t1 )

ys
f ( range)

450

f x desired

t 0 15, t 0 362.78
t1 20, t1 517.35

400

362.78

350

10

12

x s 10
0

14

16

18

x s range x desired

20

22

24
x s 10

http://numericalmethods.eng.usf.edu

Linear Interpolation (contd)


1

L0 (t )
j 0
j 0
1

L1 (t )
j 0
j 1

v(t )
v(16)

t tj
t0 t j
t tj
t1 t j

t t1
t 0 t1

t t0
t1 t 0

t t0
t t1
t 20
t 15
v(t 0 )
v(t1 )
(362.78)
(517.35)
t 0 t1
t1 t 0
15 20
20 15
16 20
16 15
(362.78)
(517.35)
15 20
20 15

0.8(362.78) 0.2(517.35)

393.7
8

m/s.

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 )

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 quadratic interpolation.
Table Velocity as a
function of time
t (s) v(t ) (m/s)

0
10
15
20
22.5
30

10

0
227.04
362.78
517.35
602.97
901.67
Figure. Velocity vs. time data
for the rocket example http://numericalmethods.eng.usf.edu

Quadratic Interpolation (contd)


t 0 10 , v(t 0 ) 227 .04

517.35

t1 15 , v(t1 ) 362 .78

550

500

t 2 20, v(t 2 ) 517 .35

450
ys
400

L0 (t )
j 0
j 0
2

L1 (t )
j 0
j 1
2

L2 (t )
j 0
j 2

11

t tj
t0 t j
t t j
t1 t j
t tj
t2 t j

t t1 t t 2

t
t

t
0 1 0 2
t t0

t1 t 0

t t 2

t1 t 2

f ( range)

f x desired

300

t t 0 t t1

t
t

t
2 0 2 1

350

250

227.04

200

10
10

12

14

16

18

x s range x desired

http://numericalmethods.eng.usf.edu

20
20

Quadratic Interpolation (contd)


t t1 t t 2
t t0 t t 2
t t0 t t1

vt0

vt1
vt 2
vt
t0 t1 t0 t 2
t1 t0 t1 t 2
t2 t0 t 2 t1
16 15 16 20
16 10 16 20
16 10 16 15

v16
227
.
04

362
.
78

517.35
10 15 10 20
15 10 15 20
20 10 20 15
0.08227.04 0.96362.78 0.12527.35
392.19 m/s

The absolute relative approximate error a obtained between the


results from the first and second order polynomial is

392 .19 393 .70


a
100
392 .19
0.38410 %
12

http://numericalmethods.eng.usf.edu

Cubic Interpolation
For 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( t 0 ) L1 ( t ) v(t 1 ) L2 ( t ) v(t 2 ) L3 ( t ) v(t 3 )


602.97

700

600

ys

500

f ( range)

f x desired

400

300

227.04

13

200

10
10

12

14

16

18

x s range x desired

20

22

24
22.5

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
10
15
20
22.5
30

14

0
227.04
362.78
517.35
602.97
901.67
Figure. Velocity vs. time data
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

L0 (t )
j 0
j 0
3

L1 (t )
j 0
j 1

t tj
t0 t j
t t j
t1 t j

t t 1 t t 2 t t 3

;

t 0 t 1 t 0 t 2 t 0 t 3
t t0

t1 t 0

t t 2 t t 3

t1 t 2 t1 t 3

602.97

700

600

ys

500

f ( range)

f x desired

400

L2 (t )
j 0
j 2
3

L3 ( t )
j 0
j 3

15

t tj
t2 t j
t tj
t3 t j

t t 0 t t1 t t 3

t
t

t
2 0 2 1 t 2 t 3
t t 0 t t1 t t 2

t
t

t
t

t
3 0 3 1 3 2

300

227.04

200

10
10

12

14

16

18

x s range x desired

20

22

24
22.5

http://numericalmethods.eng.usf.edu

Cubic Interpolation (contd)


t t1 t t 2 t t3
t t0 t t 2 t t3

vt1

vt 2

vt
t

t
t

t
t

t
t

t
t

t
t

t
0 1 0 2 0 3
1 0 1 2 1 3
t t0 t t1 t t3
t t1 t t1 t t 2

vt 2

vt3

t
t

t
t

t
t

t
t

t
t

t
2 0 2 1 2 3
3 1 3 1 3 2
16 15 16 20 16 22.5
16 10 16 20 16 22.5
v16

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.0416227.04 0.832362.78 0.312517.35 0.1024602.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 %
16

http://numericalmethods.eng.usf.edu

Comparison Table

17

Order of
Polynomial

v(t=16) m/s

393.69

392.19

392.06

Absolute Relative
Approximate Error

--------

0.38410%

0.033269%

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
18

1605 m

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

,
d
d
2
a t v t 4.245 21.265t 0.13195t 0.00544t 3
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

19

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

THE END
http://numericalmethods.eng.usf.edu

Potrebbero piacerti anche