Sunteți pe pagina 1din 25

Chapter

 4  
INTERPOLATION  
CHAPTER  CONTENT  
•  Polynomial  Interpola6on    
•  Lagrange  Interpola6on  
•  Newton-­‐Divided  Difference  Method  
•  Likewise  Polynomial  Approxima6on  
•  Natural  Cubic  Splines  
Polynomial  Interpolation  
Approxima6ng  process  of  a  func6on  to  
es6mate  the  missing  func6on  value  over  the  
interval.  

When  the  difference  of  data  is  not  evenly  


distributed  among  –x.  

Example data set x0   x1   x2   x3   x4  


x   2   3   6   7   9  
y  @  f(x)   15   39   243   375   771  

Where; x1-x0 ≠ x2-x1 ≠ x3-x2 ≠ x4-x3;


and we need to find the function of x that is in between two intervals
–x, such as “f(5)”; therefore interpolation need to be used.
Polynomial  Interpolation  
Lagrange   Newton’s  
Interpola6on   Divided  
Polynomial   Difference  

Polynomial  
Interpola6on  
Method  
How it works?
f(x)
f(x)
What is the value of
f(xk)?

xn
x1
(xn, f(xn))
f(xk)
(x1, f(x1))
x0 x2
(x0, f(x0)) (x2, f(x2))
(x)

(x) extrapolation Value within interval extrapolation


“ x0<xk<xn” use
interpolation
Lagrange  Interpolation  Polynomial  
•  When  the  set  of  data  is  only  two  points  (x0,  f(x0))  and  (x1,f(x1)),  
Joseph  Louis  Lagrange  method  @  Lagrange  method  can  be  use.    
•  This  method  is  used  when  the  polynomial  passes  two  straight  
lines  and  more  points  

Linear interpolation (1st degree interpolation) Polynomial interpolation (2st degree interpolation & more)
f(x)
f(x)

(x0,f(x0)) (x2,f(x2))
(x1,f(x1))

(x1,f(x1))
(x0,f(x0))
x
x
L0 ( x ) f ( x0 )
L0 ( x ) f ( x0 ) L1 ( x ) f ( x1 ) L1 ( x ) f ( x1 ) L2 ( x ) f ( x2 )

P1 ( x ) =
x − x1
f ( x0 ) +
x − x0
f ( x1 ) P2 ( x ) =
( x − x1 ) ( x − x2 ) f x + (x − x0 )(x − x2 ) f x + (x − x0 )(x − x1 ) f x
( 0) ( 1) ( 2)
x0 − x1 x1 − x0 ( x0 − x1 ) ( x0 − x2 ) (x1 − x0 ) ( x1 − x2 ) (x2 − x0 )(x2 − x1 )

st nd rd
st nd Interpolation at 1 point Interpolation at 2 point Interpolation at 3 point
Interpolation at 1 point Interpolation at 2 point
Lagrange  Interpolation  
Polynomial  
•  In  general,  Lagrange  Interpola6on  polynomial  is  given  by;  

n
f ( x ) ≈ Pn ( x ) = ∑ Li ( x ) fi , Li ( x ) = ∏
n
(x − x ) j

i=0 j=0
j≠i
(x − x )
i j

LINEAR QUBIC
1st Order
3rd Order
P1 ( x ) = L0 (x) f0 + L1 (x) f1 P3 ( x ) = L0 (x) f0 + L1 (x) f1 + L2 (x) f2 + L3 (x) f3
QUARTIC
QUADRATIC
2nd Order 4rd Order
P2 ( x ) = L0 (x) f0 + L1 (x) f1 + L2 (x) f2 P4 ( x ) = L0 (x) f0 + L1 (x) f1 + L2 (x) f2 + L3 (x) f3 + L4 (x) f4
Lagrange  Interpolation  
Polynomial  
Example  4.1  
1
•  Given  the  following  data  which  is  generated  by  the  func6on   y =
x

x   1   2   3   4   5  
y=f(x)   1   0.5   0.3333   0.25   0.2  

•  Approximate      f    (    4.5
           )      by  using  linear,  quadra6c,  cubic  and  quar6c  Lagrange  
interpola6on  method.  Find  the  absolute  error  for  each  approxima6on.  
Lagrange  Interpolation  
Polynomial  
i   0   1  
•  Solu6ons;  
f(4.5)=?
xi   4   5  

Yi=fi   0.25   0.2  

x
1 2 3 4 x = 4.5
5

linear
1
Exact value of f (4.5) = = 0.2222
4.5

Linear Interpolation (1st order) P1 ( x ) = L0 (x) f0 + L1 (x) f1 x − x1 x − x0


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

4.5 − 5 4.5 − 4
P1 ( 4.5) = 0.25 + 0.2
4−5 5− 4
P1 ( 4.5) = 0.125 + 0.1 = 0.225

ε a = Exact − Approximate
ε a = 0.2222 − 0.2250 = 0.0028
Lagrange  Interpolation  
Polynomial   i   0   1   2  
•  Solu6ons;   xi   3   4   5  
f(4.5)=?
Yi=fi   0.3333   0.25   0.2  
Exact value of
1
f (4.5) =
4.5
= 0.2222 x
1 2 3 4 x = 4.5
5

Quadratic

Quadratic Interpolation (2nd order) P2 ( x ) = L0 (x) f0 + L1 (x) f1 + L2 (x) f2

P2 ( x ) =
( x − x1 ) ( x − x2 ) f x + ( x − x0 ) ( x − x2 ) f x + ( x − x0 ) ( x − x1 ) f x
( 0) ( 1) ( 2)
( x0 − x1 ) ( x0 − x2 ) ( x1 − x0 ) ( x1 − x2 ) ( x2 − x0 ) ( x2 − x1 )
P2 ( 4.5) =
( 4.5 − 4) ( 4.5 − 5) 0.3333+ ( 4.5 − 3) ( 4.5 − 5) 0.25 + ( 4.5 − 3) ( 4.5 − 4) 0.2
(3− 4) (3− 5) ( 4 − 3) ( 4 − 5) (5 − 3) (5 − 4)
P2 ( 4.5) = −0.0417 + 0.1875 + 0.0750 = 0.2208

ε a = Exact − Approximate
ε a = 0.2222 − 0.2208 = 0.0014
Lagrange  Interpolation  
Polynomial   i   0   1   2   3  
•  Solu6ons;   xi   2   3   4   5  
f(4.5)=?
Yi=fi   0.5   0.3333   0.25   0.2  

Exact value of

f (4.5) =
1
= 0.2222 x
4.5 1 2 3 4 x = 4.5
5

Cubic

Cubic Interpolation (3rd order) P3 ( x ) = L0 (x) f0 + L1 (x) f1 + L2 (x) f2 + L3 (x) f3

P3 ( x ) =
( x − x1 ) ( x − x2 ) ( x − x3 ) f x + ( x − x0 ) ( x − x2 ) ( x − x3 ) f x + ( x − x0 ) ( x − x1 ) ( x − x3 ) f x + ( x − x0 ) ( x − x1 ) ( x − x2 ) f x
( 0) ( 1) ( 2) ( 3)
( x0 − x1 ) ( x0 − x2 ) ( x0 − x3 ) ( x1 − x0 ) ( x1 − x2 ) ( x1 − x3 ) ( x2 − x0 ) ( x2 − x1 ) ( x2 − x3 ) ( x3 − x0 ) ( x3 − x1 ) ( x3 − x2 )

P2 ( 4.5) =
( 4.5 − 3) ( 4.5 − 4) ( 4.5 − 5) 0.5 + ( 4.5 − 2) ( 4.5 − 4) ( 4.5 − 5) 0.3333+ ( 4.5 − 2) ( 4.5 − 3) ( 4.5 − 5) 0.25 + ( 4.5 − 2) ( 4.5 − 3) ( 4.5 − 4) 0.2
(2 − 3) (2 − 4) (2 − 5) (3− 2) (3− 4) (3− 5) ( 4 − 2) ( 4 − 3) ( 4 − 5) (5 − 2) (5 − 3) (5 − 4)
P2 ( 4.5) = 0.0313− 0.1042 + 0.2344 + 0.0625 = 0.2240

ε a = Exact − Approximate
ε a = 0.2222 − 0.2240 = 0.0018
Lagrange  Interpolation  
Polynomial   i   0   1   2   3   4  
•  Solu6ons;   xi   1   2   3   4   5  
f(4.5)=?
Yi=fi   1   0.5   0.3333   0.25   0.2  

Exact value of

f (4.5) =
1
= 0.2222 x
4.5 1 2 3 4 x = 4.5
5

Quartic

Quartic Interpolation (4th order) P3 ( x ) = L0 (x) f0 + L1 (x) f1 + L2 (x) f2 + L3 (x) f3 + L4 (x) f4

P4 ( x ) =
( x − x1 ) ( x − x2 ) ( x − x3 ) ( x − x4 ) f x + ( x − x0 ) ( x − x2 ) ( x − x3 ) ( x − x4 ) f x + ( x − x0 ) ( x − x1 ) ( x − x3 ) ( x − x4 ) f x + ( x − x0 ) ( x − x1 ) ( x − x2 ) ( x − x4 ) f x + ( x − x0 ) ( x − x1 ) ( x − x2 ) ( x − x3 ) f x
( 0) ( 1) ( 2) ( 3) ( 4)
( x0 − x1 ) ( x0 − x2 ) ( x0 − x3 ) ( x0 − x4 ) ( x1 − x0 ) ( x1 − x2 ) ( x1 − x3 ) ( x1 − x4 ) ( x2 − x0 ) ( x2 − x1 ) ( x2 − x3 ) ( x2 − x4 ) ( x3 − x0 ) ( x3 − x1 ) ( x3 − x2 ) ( x3 − x4 ) ( x4 − x0 ) ( x4 − x1 ) ( x4 − x2 ) ( x4 − x3 )

P4 ( 4.5) =
( 4.5− 2) ( 4.5− 3) ( 4.5− 4) ( 4.5− 5) 1+ ( 4.5−1) ( 4.5− 3) ( 4.5− 4) ( 4.5− 5) 0.5+ ( 4.5−1) ( 4.5− 2) ( 4.5− 4) ( 4.5− 5) 0.3333+ ( 4.5−1) ( 4.5− 2) ( 4.5− 3) ( 4.5− 5) 0.25+ ( 4.5−1) ( 4.5− 2) ( 4.5− 3) ( 4.5− 4) 0.2
(1− 2) (1− 3) (1− 4) (1− 5) (2 −1) (2 − 3) (2 − 4) (2 − 5) (3−1) (3− 2) (3− 4) (3− 5) ( 4 −1) ( 4 − 2) ( 4 − 3) ( 4 − 5) (5−1) (5− 2) (5− 3) (5− 4)

P4 ( 4.5) = −0.0391+ 0.1094 − 0.1823+ 0.2734 + 0.0547 = 02161

ε a = Exact − Approximate
ε a = 0.2222 − 0.2161 = 0.0061
Exercise  
•  Try  This!  
Exercise  4  (Ques6on  7)  
 
The  following  table  gives  certain  corresponding  values  of  x  and  
log10  x.  Using  Lagrange  interpola6on,  compute  the  following  
term,  if  possible.  
(a)  log10(323.5)  
(b)  Log10(353.5)  

x   321.0   322.8   324.2   325.0  


 
Log10  x   2.507   2.509   2.511   2.512  
Newton  Divided  Difference  (NDD)  
Polynomial  
•  NDD  Polynomial  equa6on  was  introduced  by  Newton  to  find  the  f(x)  value  in  a  
polynomial  regression.  
•  This  equa6on  was  formed  from  the  equa6on  passing  a  straight  line  through  two  
data  points  (x0,f(x0))  and  (x1,f(x1))  as;  
  P1 ( x ) = a0 + a1 ( x − x0 ) →1st order
 
•  For  a  parabolic  passing  through  three  data  points  of  (x0,f(x0)),  (x1,f(x1))    and  
(x2,f(x2)),  the  equa6on  is  shown  as;  
P2 ( x ) = a0 + a1 ( x − x0 ) + a2 ( x − x0 ) ( x − x1 ) → 2nd order
•  Thus,  the  general  equa6on  of  a  polynomial  passing  through  n+1  data  points…  
x0,f(x0)),  (x1,f(x1))…..(xn,f(xn))  is  given  by;  
Pn ( x ) = a0 + a1 ( x − x0 ) +.......... + an+1 ( x − x0 ) ( x − x1 ) ( x − xn+1 )
where a0 , a1, a2 ,........an arethecoefficient of divided difference
•  NDD  Polynomial  introduced  2  methods  to  obtain  the  coefficients  i.e.  “forward  
divided-­‐difference”  or  “backward  divided-­‐difference”  
Newton  Divided  Difference  (NDD)  
Polynomial  
•  How  to  interpolate  the  data  for  forward  divided-­‐difference  in  finding  the  coefficients  of  a0,a1,a2…an?  

i   xi   fi  [0]   fi  [1]   fi  [2]   fi  [3]   fi  [4]  


0   X0   f0  [0]=a0   f0  [1]=a1   f0  [2]  =a2   f0  [3]  =a3   f0  [4]  =a4  
1   X1   f1  [0]   f1  [1]   f1  [2]   f1  [3]  
2   X2   f2  [0]   f2  [1]   f2  [2]  
3   X3   f3  [0]   f3  [1]  
4   X4   f4  [0]  

•  Where  the  divided-­‐difference  interpola6on  is  calculated  as  follows;  

i   xi   fi  [0]   fi  [1]   fi  [2]   fi  [3]   fi  [4]  


0   X0   f0  [0]   f0  [1]=(  f1  [0]-­‐f0  [0])/(X1-­‐X0)   f0  [2]  =(  f1  [1]-­‐f0  [1])/(X2-­‐X0)   f0  [3]  =f1  [2]-­‐f0  [2]  /(X3-­‐X0)   f0  [4]  =f1  [3]-­‐f0  [3]  /(X4-­‐X0)  

1   X1   f1  [0]   f1  [1]=(  f2  [0]-­‐f1  [0])/(X2-­‐X1)   f1  [2]=(  f2  [1]-­‐f1  [1])/(X3-­‐X1)   f1  [3]  =f2  [2]-­‐f1  [2]  /(X4-­‐X1)  

2   X2   f2  [0]   f2  [1]=(  f3  [0]-­‐f2  [0])/(X3-­‐X2)   f2  [2]=(  f3  [1]-­‐f2  [1])/(X4-­‐X2)  

3   X3   f3  [0]   f3  [1]=(  f4  [0]-­‐f3  [0])/(X4-­‐X3)  

4   X4   f4  [0]  

•  and  hence;  
f (x) ≈ P4 (x) = f0[ ] + f0[ ] ( x − x0 ) + f0[
2]
0 1
( x − x0 ) ( x − x1 ) + f0[3] ( x − x0 ) ( x − x1 ) ( x − x2 ) + f0[4] ( x − x0 ) ( x − x1 ) ( x − x2 ) ( x − x3 )
Newton  Divided  Difference  (NDD)  
Polynomial  
•  Example  
Given  ;  
x   2.1   2.4   2.6  
 
f(x)   0.521   0.510   0.381  
 
1)  Find  the  NDDP  interpola6on  and  approxima6on  value  for  f(2.5).  

Solu6ons;  
i   xi   fi  [0]   fi  [1]   fi  [2]  
0   2.1   f0  [0]=a0=0.521   f0  [1]=(  f1  [0]-­‐f0  [0])/(X1-­‐X0)   f0  [2]  =(  f1  [1]-­‐f0  [1])/(X2-­‐X0)  
=  (0.510-­‐0.521)/(2.4-­‐2.1)   =((-­‐0.037)-­‐(-­‐0.645))/(2.6-­‐2.1)  
=-­‐0.037   =-­‐1.216  
1   2.4   0.510   f1  [1]=(  f2  [0]-­‐f1  [0])/(X2-­‐X1)  
=(0.381-­‐0.510)/(2.6-­‐2.4)  
=-­‐0.645  
2   2.6   0.381  

f (2.5) ≈ P2 (2.5) = f0[ ] + f0[ ] ( x − x0 ) + f0[


0 1 2]
( x − x0 ) ( x − x1 )
f (2.5) ≈ P2 (2.5) = 0.521+ (−0.037) ( 2.5 − 2.1) + (−1.216) ( 2.5 − 2.1) ( 2.5 − 2.4) = 0.458
Newton  Divided  Difference  (NDD)  
Polynomial  
•  Try  This!  (exercise  4,  Q11,  page  106)  

Given  f(x)=e-­‐x.  
(a)  Complete  the  following  table  
x   0   0.25   0.75   1.0  
  f(x)=e-­‐x  
(b)  Hence,  find  P3(0.4)  by  using  NDD  Polynomial  method.  
(c)  If  (0.5,  0.6065)  is  added  into  the  above  data  set,  find  f(0.4)  
by  using  NDDP  method.  
To  be  con6nued  

END  OF  PART  1  


PIECEWISE  POLYNOMIAL  APPROXIMATION  
(NATURAL  CUBIC  SPLINES)  
•  WHAT  IS  SPLINE?   A function that lays between two intervals
•  HOW?   f(x)
Every spline (s0, s1…sn) will acted as individual
regression in the interpolation. Your aim is to construct
each spline equation within the data set.

S0(x) S1(x) Sn(x) (x)


  x0 x1 x2 xn
•  4  General  Steps  in  Natural  Cubic  Splines  Polynomial   hk = xk+1 − xk "
$
•  Step  1:  Construct  the  NDD  table  using  the  following  formula;     fk+1 − fk # k = 0,1, 2,, 3...., n −1
dk =
hk $%
bk = 6 ( dk+1 − dk ), k = 0,1, 2, 3,..., n − 2
•  Step  2:  for  natural  cubic  spline,  m0=0  and  mn=0.  Derive  the  system  of  linear  equa6on  with  unknowns,  mk.  For  
k=0,1,2,3,…n-­‐2,  
hk mk + 2 ( hk + hk+1 ) mk+1 + hk+1mk+2 = bk
•  Step  3:  Find  unknowns  m1….mn-­‐1  (use  any  suitable  method  in  Chapter  3  or  by  MODE  EQ  in  a  calculator  (for  system  
consists  of  2-­‐3  linear  equa6ons).  
•  Step  4:  Find  the  cubic  spline  S(x)  in  which  the  piecewise  cubic  polynomial  is  given  by  
mk 3 m 3 " f m % "f m %
sk (x) = ( xk+1 − x ) + k+1 ( x − xk ) + $ k − k hk ' ( xk+1 − x ) + $ k+1 − k+1 hk ' ( x − xk )
6hk 6hk # hk 6 & # hk 6 &
where k = 0,1, 2, 3,...n −1.
PIECEWISE  POLYNOMIAL  APPROXIMATION  
(NATURAL  CUBIC  SPLINES)  
•  or,  alterna6ve  for  step  4  
3 2
Si ( x ) = ai ( x − xi ) + bi ( x − xi ) + ci ( x − xi ) + di, i = 0,1,.....n −1
where ai , bi , ci , di are named as spline qubic polynomial coefficients

ai   bi   ci   di  
mi+1  − mi mi f ( xi+1 ) − f ( xi ) " 2hi mi + hi mi+1 % f (xi )
−$ '
6hi
  2 hi # 6 &

THE MORE I THINK,


THE MORE
CONFUSED I GET
PIECEWISE  POLYNOMIAL  APPROXIMATION  
(NATURAL  CUBIC  SPLINES)  
•  Example  
Construct  natural  cubic  splines  ,  if  S(x)  interpolates  the  data  
f(-­‐1)=-­‐1,  f(0)=0,  f(1)=1  and  f(2)=0.   k = 1, 2, 3…,n-1 k = 1, 2, 3…,n-2
y fk+1 − fk
STEP 1 hk = xk+1 − xk dk =
hk
bk = 6 ( dk+1 − dk )
k = 1, 2, 3…,n-1

k   xk   fk   hk   dk   bk  
S2
1
S1 0   -­‐1   -­‐1   h0=0-­‐(-­‐1)   d0=(0-­‐(-­‐1))/1   b0=6(1-­‐1)  
x =1   =1   =0  
-1 S0 1 2
-1 1   0   0   h1=1-­‐0   d1=(1-­‐0))/1   b1=6(-­‐1-­‐1)  
=1   =1   =6(-­‐2)  
=-­‐12  
2   1   1   h2=2-­‐1   d2=(0-­‐1))/1  
=1   =-­‐1  
x0 x1 x2 x3 3   2   0  

STEP 2 For natural cubic splines, slope of graph at 1st point (m0) and
final point must (mn) = 0.
Derive the system of linear equations using unknowns mk for
k=0,1,2,…,n-2 points. (continued in next page)
PIECEWISE  POLYNOMIAL  APPROXIMATION  
(NATURAL  CUBIC  SPLINES)  
STEP 2-cont’d General formula;
hk mk + 2 ( hk + hk+1 ) mk+1 + hk+1mk+2 = bk substitute k=0, 1, 2,…, n-2

k m   System  of  linear  equa<on  


0 m0=0(start  point)     h0 m0 + 2 ( h0 + h0+1 ) m0+1 + h0+1m0+2 = b0
m1=?   1(0) + 2 (1+1) m1 +1m2 = 0
m2=?  
  4m1 + m2 = 0…(i)

1 m1=?     h1m1 + 2 ( h1 + h2 ) m2 + h2 m3 = b1
m2=?  
m3=0  (end  point,  n-­‐2)  
  1m1 + 2 (1+1) m2 +1(0) = −12
Stop k at n-2= (3-2)=1   m1 + 4m2 = −12…(ii)

STEP 3 Solve the system of linear equations using one of previously learned methods
! 4 1 $! m1 $ ! 0 $ )1, " 4 1 0 &
# &# &=# & → − + . R1 + R2 → R2 ⇒$ ( Using backward substitution,
" 1 4 %#" m2 &% " −12 % *4- $# 0 15
4 −12 ' calculate the value of m2 and m1

Hence, m2 = -16/5
m1= 4/5
PIECEWISE  POLYNOMIAL  APPROXIMATION  
(NATURAL  CUBIC  SPLINES)  
STEP 4 General spline formula: sk (x) = mk ( xk+1 − x )3 + mk+1 ( x − xk )3 + "$ fk − mk hk %' ( xk+1 − x ) + "$ fk+1 − mk+1 hk %' ( x − xk )
6hk 6hk # hk 6 & # hk 6 &
wherek = 0,1, 2, 3,...n −1.
at k = 0
k = 1, 2, 3…,n-1 m0 3 m 3 "f m % "f m %
s0 (x) = ( x1 − x ) + 1 ( x − x0 ) + $ 0 − 0 h0 ' ( x1 − x ) + $ 1 − 1 h0 ' ( x − x0 )
6h0 6h0 # h0 6 & # h0 6 &
S2 0 4 " −1 0 % "0 4 %
1 s0 (x) =
3 3
( 0 − x ) + 5 ( x − (−1)) + $# − (1)'& ( 0 − x ) + $# − 5 (1)'& ( x − (−1))
S1 6(1) 6(1) 1 6 1 6
x
-1 S0 1 2 2 2
s0 (x) = (x +1)3 + x − (x +1) ⇒ x ∈ [−1, 0 ]
-1 15 15
at k = 1
m 3 m 3 "f m % "f m %
s1 (x) = 1 ( x2 − x ) + 2 ( x − x1 ) + $ 1 − 1 h1 ' ( x2 − x ) + $ 2 − 2 h1 ' ( x − x1 )
6h1 6h1 # h1 6 & # h1 6 &
4 − 1653 3 "0 4 % " 1 − 16 %
s1 (x) = 5
(1− x ) ( x − 0) + $# − 5 (1)'& (1− x ) + $# − 5 (1)'& ( x − 0)
+
6(1) 6(1) 1 6 1 6
2 8 2 23
s1 (x) = (1+ x)3 − x 3 − (1− x) + x ⇒ x ∈ [ 0,1]
15 15 15 15
at k = 2
m2 3 m 3 "f m % "f m %
s2 (x) = ( x3 − x ) + 3 ( x − x2 ) + $ 2 − 2 h2 ' ( x3 − x ) + $ 3 − 3 h2 ' ( x − x2 )
6h2 6h2 # h2 6 & # h2 6 &
− 165 3 0 3 " 1 − 16 % "0 0 %
s2 (x) = (2 − x ) + ( x −1) + $# − 5 (1)'& ( 2 − x ) + $# − (1)'& ( x −1)
6(1) 6(1) 1 6 1 6
8 23
s2 (x) = − (2 − x)3 + (2 − x) ⇒ x ∈ [1, 2 ]
15 15
PIECEWISE  POLYNOMIAL  APPROXIMATION  
(NATURAL  CUBIC  SPLINES)  
ALTERNATIVE FOR STEP 4

ai   bi   ci   di  
mi+1  − mi mi f ( xi+1 ) − f ( xi ) " 2hi mi + hi mi+1 % f (xi )
−$ '
6hi
  2 hi # 6 &

Calculate for ai Calculate for ci


m1 − m0 45 − 0 8 f ( x0+1 ) − f ( x0 ) " 2h0 m0 + h0 m0+1 % 0 − (−1) " 2(1)(0) + (1)( 45 ) % 13
ao = = = c0 = −$ '= −$ '=
6h0 6(1) 15 h0 # 6 & 1 # 6 & 5
m2 − m1 − 165 − 45 2
a1 = = =− f ( x1+1 ) − f ( x1 ) " 2h1m1 + h1m1+1 % 1− (0) " 2(1)( 45 ) + (1)(− 165 ) % 4
6h1 6(1) 3 c1 = −$ '= −$ ' =1
h1 # 6 & 1 # 6 & 15
m3 − m2 0 − (− 165 ) 8 f ( x2+1 ) − f ( x2 ) " 2h2 m2 + h2 m2+1 % 0 − (1) " 2(1)(− 165 ) + (1)(0) % 1
a2 = = = c2 = −$ '= −$ '=
6h2 6(1) 15 h2 # 6 & 1 # 6 & 15
Calculate for bi Calculate for di
m0 0
b0 = = =0 d0 = f (x0 ) = −1
2 2

m1 45 2 d1 = f (x1 ) = 0
b1 = = =
2 2 5 d2 = f (x2 ) = 1

m2 − 165 8
b2 = = =−
2 2 5
PIECEWISE  POLYNOMIAL  APPROXIMATION  
(NATURAL  CUBIC  SPLINES)  

Spline Equations;
3 2 8 3 2 8
S0 ( x ) = a0 ( x − x0 ) + b0 ( x − x0 ) + c0 ( x − x0 ) + d0 = ( x − (−1)) + 0 ( x − (−1)) + ( x − (−1)) + (−1)
15 15
2 3 13
S0 ( x ) = ( x +1) + ( x +1) −1
15 15

3 2 2 3 2 2 4
S1 ( x ) = a1 ( x − x1 ) + b1 ( x − x1 ) + c1 ( x − x1 ) + d1 = ( x − (0)) + ( x − 0) +1 ( x − (0)) + 0
3 5 15
2 3 2 2 4
S1 ( x ) = − ( x ) + ( x ) +1 x
3 5 15

3 2 8 3 8 2 1
S2 ( x ) = a2 ( x − x2 ) + b2 ( x − x2 ) + c2 ( x − x2 ) + d2 = ( x −1) − ( x −1) + ( x −1) +1
15 5 15
PIECEWISE  POLYNOMIAL  APPROXIMATION  
(NATURAL  CUBIC  SPLINES)  

•  Try  This!  

Given  the  following  data.  


  x   4   9   16  
  f(x)   2   3   4  

Es6mate  f(7)  and  f(14)  from  


(b)  Natural  cubic  spline  func6on.  

S-ar putea să vă placă și