0% found this document useful (0 votes)
8 views

Computational Chapter 4

The document discusses interpolation and approximation methods. It covers linear interpolation using two data points, polynomial interpolation using multiple data points, and the least squares method for fitting data to polynomials. Equations for determining interpolation coefficients are presented.

Uploaded by

alsenlegesse
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Computational Chapter 4

The document discusses interpolation and approximation methods. It covers linear interpolation using two data points, polynomial interpolation using multiple data points, and the least squares method for fitting data to polynomials. Equations for determining interpolation coefficients are presented.

Uploaded by

alsenlegesse
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Chapter 4| Interpolation and Approximation 1

Chapter 4| Interpolation and Approximation 2





Chapter 4| Interpolation and Approximation 3


◼ 𝑃𝑛 𝑥

Chapter 4| Interpolation and Approximation 4


𝑃𝑛 𝑥
𝑓 𝑥 − 𝑝𝑛 (𝑥) < 𝑒

Chapter 4| Interpolation and Approximation 5


◼ It is applicable when two data points are given
◼ Consider:

◼ The slope of the straight line passing through the two


points is
f ( x0 ) − f ( x1 )
m=
x0 − x1

◼ Thus, the function that relates the two points can be


written as
f ( x0 ) − f ( x1 )
f 1 ( x) = ( x − x0 ) + f ( x0 )
x0 − x1

Chapter 4| Interpolation and Approximation 6


◼ 𝑓 𝑥0 &𝑓 𝑥1
𝑓 𝑥0 = 𝑒 𝑥0 = 𝑒 0 = 1
𝑓 𝑥1 = 𝑒 𝑥1 = 𝑒 1 = 𝑒

f ( x0 ) − f ( x1 )
f 1 ( x) = ( x − x0 ) + f ( x0 )
x0 − x1

1− e
f1 ( x) = ( x − 0) + 1 = (e − 1) x + 1
0 −1

Chapter 4| Interpolation and Approximation 7


Pn ( x) = a0 + a1 x + a2 x +  + an x
2 n

a 0 + a1 x1 + a 2 x1 2 +  + a n x1 n = y1

 0 + + + + n 2 = y2
2 n
a a x a x  a x

1 2 2 2

    
a + a x + a x 2 +  + a x n = y
 0 1 n 2 n n n n

Chapter 4|
Interpolation and Approximation 8

1 x1 x12 x13 x1n   a0   y1 


 2 3 n 
  y 
 2 2 2
1 x x x x2   1   2 
a
   =  
    
1 xn xn2 xn3 xnn   an   yn 

◼ Find an approximate quadratic function for


X 0 1 2
Y 2 3 6

Chapter 4| Interpolation and Approximation 9


1 0 0  a 0  2
1 1 1  a  = 3 
  1   
1 2 4 a 2  6 

▪ 𝑎0 = 2, 𝑎1 =
0 & 𝑎2 = 1

P2 ( x ) = x + 22

Chapter 4| Interpolation and Approximation 10


n
p n ( x ) =  y i Li ( x )
i =0


n x − xj
Li ( x ) = 
j =0 xi − x j
j i

Chapter 4| Interpolation and Approximation 11


𝑝2 𝑥 = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2
◼ 𝑎0 𝑎1 𝑎2
2
p2 ( x) =  yi Li ( x) = y0 L0 + y1 L1 + y2 L2
i =0


Chapter 4| Interpolation and Approximation 12

2 x − xj x − x1 x − x2 x −4 x −5 x 2 − 9 x + 20
L0 ( x) =  =( )( )=( )( )=
j =1 x0 − x j x0 − x1 x0 − x2 3 − 4 3 − 5 2
j 0

2 x − xj x − x0 x − x2 x −3 x −5
L1 ( x) =  =( )( )=( )( ) = − x 2 + 8 x − 15
j =0 x1 − x j x1 − x0 x1 − x2 4−3 4−5
j 1

2 x − xj x − x0 x − x1 x −3 x −4 − x 2 + 7 x − 12
L2 ( x) =  =( )( )=( )( )=
x
j =0 2 − x j x2 − x0 x2 − x1 5 − 3 5 − 4 2
j2

𝑥 2 − 9𝑥 + 20 2
−𝑥 2 + 7𝑥 − 12
𝑝2 𝑥 = 1 + 2 −𝑥 + 8𝑥 − 15 + 4( )
2 2

Chapter 4| Interpolation and Approximation 13


𝑝2 𝑥 = −29 + 25.5𝑥 − 3.5𝑥 2

𝑎0 = −29, 𝑎1 = 25.5 𝑎2 = −3.5


X 0 1 2
Y 2 3 6

Chapter 4| Interpolation and Approximation 14


Pn ( x) = a0 + ( x − x0 )a1 + ( x − x0 )( x − x1 )a2 + + ( x − x0 )( x − x1 ) ( x − xn −1 )an

Chapter 4| Interpolation and Approximation 15



a 0 = f ( x0 )

a = f ( x1 ) − f ( x0 )
f [ x1 , x0 ] =
 1 x1 − x0

 f [ x 2 , x1 ] − f [ x1 , x0 ]
a 2 = f [ x 2 , x1 , x0 ] =
 x 2 − x0


a = f [ x n , x n −1 ,  , x1 ] − f [ x n −1 , x n − 2 , , x0 ]
 n f [ x n , x n −1 , , x0 ] =
 xn − x0

f ( xi ) − f ( x j )
f [ xi , x j ] =
xi − x j

Chapter 4| Interpolation and Approximation 16


Chapter 4| Interpolation and Approximation 17


X 0 1 2
Y 2 3 6

P2 ( x) = a0 + ( x − x0 )a1 + ( x − x0 )( x − x1 )a 2

Chapter 4| Interpolation and Approximation 18




a 0 = f ( x 0 ) = 2
 f ( x1 ) − f ( x0 )
a1 = f [ x1 , x0 ] = =1
 x1 − x0
 f [ x 2 , x1 ] − f [ x1 , x0 ] 3 − 1
a 2 = f [ x 2 , x1 , x0 ] = = =1
 x 2 − x0 2

P2 ( x) = 2 + ( x − 0) + ( x − 0)( x − 1) = x 2 + 2

Chapter 4| Interpolation and Approximation 19


Chapter 4| Interpolation and Approximation 20


Chapter 4| Interpolation and Approximation 21


Chapter 4| Interpolation and Approximation 22


◼ 𝑥1 , 𝑦1
𝑥2 , 𝑦2

𝑖 𝑡ℎ (𝑥𝑖 , 𝑦𝑖 ) (𝑥𝑖+1 , 𝑦𝑖+1 )

Chapter 4| Interpolation and Approximation 23


X 8 11 15 18

Y 5 9 10 8

𝑓1 𝑥 𝑖𝑠 𝑏𝑒𝑡𝑤𝑒𝑒𝑛 6, 5 & (11, 9)


𝑓2 𝑥 𝑖𝑠 𝑏𝑒𝑡𝑤𝑒𝑒𝑛 11, 9 & (15, 10)
𝑓2 𝑥 𝑖𝑠 𝑏𝑒𝑡𝑤𝑒𝑒𝑛 15, 10 & (18, 8)
Chapter 4| Interpolation and Approximation 24

◼ 𝑦 𝑥 = 12.7 𝑓2 (𝑥)

Chapter 4| Interpolation and Approximation 25


Chapter 4| Interpolation and Approximation 26


Chapter 4| Interpolation and Approximation 27


(𝑥1 , 𝑦1 ), (𝑥2 , 𝑦2 ), . . . , (𝑥𝑛 , 𝑦𝑛 )


𝑦 = 𝑎0 + 𝑎1 𝑥 + 𝑒
𝑎0 𝑎1 𝑒

𝑎0 + 𝑎1 𝑥
𝑒 = 𝑦 − 𝑎0 − 𝑎1 𝑥

Chapter 4| Interpolation and Approximation 28


Chapter 4| Interpolation and Approximation 29


𝑠𝑟
Chapter 4| Interpolation and Approximation 30

◼ σ 𝑎0 = 𝑛𝑎𝑜

◼ 𝑎0 𝑎1

Chapter 4| Interpolation and Approximation 31


𝒙𝒊 1 2 3 4 5 6 7
𝑦𝑖 0.5 2.5 2 4 3.5 6 5.5

Chapter 4| Interpolation and Approximation 32



n
S r =  ( yi − a0 − a1 xi − a2 xi2 − − an xin ) 2
i =0


𝑆𝑟
 S n

 a =  − 2( y i − a 0 − a1 xi − a 2 xi2 −  − a n xin ) = 0
 0 i =0

 S n

 =  − 2( y − a 0 − a1 xi − a 2 xi2 −  − a n xin )xi = 0


 a1
i
i =0


 S n

 =  − 2( y − a 0 − a1 x i − a 2 xi2 −  − a n xin )xi2 = 0


 a 2
i
i =0
 

 S
n

 a =  − 2( y
i =0
i − a 0 − a1 xi − a 2 xi2 −  − a n xin )xin = 0
 n

Chapter 4| Interpolation and Approximation 33


 n n n
  n 
n + 1 x x i
2
i  n
i x   a   i  y
 i =0 i =0 i =0
  0   i =1 
 n n n n
  a1   n 
  xi x x    a  =  i i 
2 3 n +1
i i x i x y
 i =0 i =0 i =0 i =0   2   i =1 
    
 n n n n    n 
 xn   an   x n y 
  x x  
n +1 n+2 2n
x
i =0
i
i =0
i
i =0
i
i =0
i

 
 i =1
i i


Chapter 4| Interpolation and Approximation 34


◼ 𝑆𝑟

Chapter 4| Interpolation and Approximation 35


◼ 𝑎0 𝑎1 𝑎2

Chapter 4| Interpolation and Approximation 36


𝒙𝒊 0 1 2 3 4 5
𝑦𝑖 2.1 7.7 13.6 27.2 40.9 61.1

Chapter 4| Interpolation and Approximation 37


𝑎0 = 2.47857 𝑎1 = 2.35929 𝑎2 = 1.86071


𝑦 = 2.47857 + 2.35929𝑥 + 1.86071𝑥 2

Chapter 4| Interpolation and Approximation 38


x 0 2 3
y 7 11 28

Chapter 4| Interpolation and Approximation 39


Chapter 4|
Interpolation and Approximation 40

You might also like