Taylor - McLaurin

Download Report

Transcript Taylor - McLaurin

Deret Taylor
( x  x0 ) 2
f ( x)  f ( x0 )  f ( x0 )(x  x0 )  f ( x0 )
2!
n
(
x

x
)
(n)
0
   f ( x0 )

n!
n
f ' (a)
f ' ' (a)
f
(a)
f ( x)  f (a ) 
( x  a) 
( x  a) 2  .... 
( x  a) n  ...
1!
2!
n!
n
x
x 2

x
n



f ( xi 1 )  f ( xi )  f ( xi )  f ( xi )
   f ( xi )
 Rn
1!
2!
n!
x  xi 1  xi
• Kesalahan yang dihasilkan dari penggunaan
suatu aproksimasi pengganti prosedur
matematika yang eksak
Contoh: approksimasi dengan deret Taylor
Kesalahan:
f
( ) ( n 1)
Rn 
x
(n  1)!
( n 1)
Kesalahan pemotongan
• Aproksimasi orde ke nol (zero-order appr.)
f ( xi 1 )  f ( xi )
• Aproksimasi orde ke satu (first-order appr.)
f ( xi 1 )  f ( xi )  f ( xi )
x
1!
• Aproksimasi orde ke dua (second-order appr.)
x
x 2
f ( xi 1 )  f ( xi )  f ( xi )
 f ( xi )
1!
2!
Recall the Taylor Series
f ' '  xi  2 f ' ' '  xi  3
f  x i  1   f  x i   f '  x i h 
h 
h
2!
3!
f n  xi  n
. . . . . .
h  Rn
n!
where h  step size  xi  1  xi

Finite difference method -1
The Taylor series
x 2 '' x 3 '''
f i 1  f i  xfi 
fi 
fi    
2!
3!
x 2 '' x 3 '''
'
f i 1  f i  xfi 
fi 
fi    
2!
3!
(1)
'
(2)
First-oder difference
Forward
difference
Backward
difference
Central
Difference
f i 1  f i
x '' x 2 '''
'
 fi 
fi 
fi    
x
2!
3!
f i  f i 1
x '' x 2 '''
'
 fi 
fi 
fi    
x
2!
3!
f i 1  f i 1
x 2 ''' x 4 ''''
'
 fi 
fi 
fi    
2x
6
5!
i-1
i
i-1
i-1
turunkan juga!
i+1
i
i
i+1
i+1
Finite difference method -3
High-oder finite difference
To reduce the truncation error of finite difference method, high-order finite
difference method is frequently employed
h
df i
 af i  2  bf i 1  cf i  df i 1  ef i  2
dx
Taylor series of five points are,
(1)
i-2
i-1
( 2 h ) 2 ' ' ( 2 h ) 3 ' '' ( 2 h ) 4 ''''
f i  2  f i  ( 2h) f i 
fi 
fi 
fi    
2!
3!
4!
h 2 '' h 3 '' ' h 4 ' '''
'
f i 1  f i  hfi 
fi 
fi 
fi    
2!
3!
4!
fi  fi
i
i+1 i+2
'
h 2 '' h 3 ' '' h 4 '' ''
f i 1  f i  hfi 
fi 
fi 
fi    
2!
3!
4!
( 2 h ) 2 '' ( 2 h ) 3 ''' ( 2 h ) 4 ''''
'
f i  2  f i  ( 2h) f i 
fi 
fi 
fi    
2!
3!
4!
'
By substituting (2)~(5) into Eq.(1), we have,
(2)
(3)
(4)
(5)
(5)
Finite difference method -4
dfi
 (a  b  c  d  e) f i  (2ah  bh  dh  2eh) f i '
dx
8 3
h3
h3
8h 3
2
2
2
2
''
 (2h a  0.5h b  0.5h d  2h e) f i  ( h a  b  d 
e ) f i '' '
6
6
6
6
( 2h) 4
h4 h4
( 2h) 4
(
a  d 
e ) f i ''' ' 
4!
4! 4!
4!
(7)
The coefficient for the first derivative must be 1 and the others
must be zero . By solving 5 linear equations, we get,
1
8
8
, b
, c  0, d 
,
12h
12h
12h
df  f i  2  8 f i 1  8 f i 1  f i  2
 i 
dx
12h
a
The order of precision is 4th.
e
1
12h
(8)
Finite difference method -5
Comparison of finite difference method
f(x)=x3, Δx=1,x=2 , analytical solution f’(2)=12
x
f(x)
0
0
1
1
2
8
3
27
4
64
Forward finite
difference
Backward finite
difference
f i 1  f i 27  8

 19
x
1
f i  f i 1 8  1

7
x
1
Central
difference
f i 1  f i 1 27  1

 13
2x
2
4th order finite
Central difference
 f i  2  8 f i 1  8 f i 1  f i  2
 12
12 h
Exercise: Calculate above four types of finite
differences under condition of f(x)=x, Δx=1, x=2