8/3/2019 C04-Defferentiation and Integration
1/20
5/5/2012 by Adam Pamudji R 1
Numerical Differentiation
8/3/2019 C04-Defferentiation and Integration
2/20
5/5/2012 by Adam Pamudji R 2
First Order Derivative
First Order Taylor Series for x closed to x0
001
0
0001
)()('
)(')(
xx
xfxPxf
xxxfxfxP
8/3/2019 C04-Defferentiation and Integration
3/20
5/5/2012 by Adam Pamudji R 3
graphical explanation
0
010
0001
)()('
)(')(
xx
xfxPxf
xxxfxfxP
x0 x>x0x
8/3/2019 C04-Defferentiation and Integration
4/20
5/5/2012 by Adam Pamudji R 4
h
xfhxfxf
)()(' 000
Ifx = x0+ h, then for forward difference we have
Ifx = x0- h, then for backward difference we have
h
hxfxfh
xfhxfxf
00000)()()('
8/3/2019 C04-Defferentiation and Integration
5/20
5/5/2012 by Adam Pamudji R 5
First Order Derivative
Second Order Taylor Series for x closed to x0
h
hxfhxfxf
xfhhxfhxf
hxf
hxfxfhxf
hxfhxfxfhxf
xxxf
xxxfxfxP
2)('
0)('20
2
)(''
)(')(
2
)('')(')(
!2
)(''
)(')(
00
0
000
2
0
000
2
0
000
2
00
0002
8/3/2019 C04-Defferentiation and Integration
6/20
5/5/2012 by Adam Pamudji R 6
graphical explanation
h
hxfhxfxf
2
)()(' 000
x0
x0-h
central difference
)(' 0xf
)(0
xf
)(0
hxf )( 0 hxf
x0+h
8/3/2019 C04-Defferentiation and Integration
7/20
5/5/2012 by Adam Pamudji R 7
Reading Assignment
Please read page 146 to 150 section 4.1for another approach
Find about:
The three point formulas
The five point formulas
8/3/2019 C04-Defferentiation and Integration
8/20
5/5/2012 by Adam Pamudji R 8
Second Order Derivative
Second Order Taylor Series for x closed to x0
2
000
0
2
0000
2
0000
2
0000
)(2)(''
)(''0)(2
2
)('')(')(
2
)('')(')(
h
hxfxfhxfxf
hxfxfhxfhxf
hxfhxfxfhxf
hxfhxfxfhxf
8/3/2019 C04-Defferentiation and Integration
9/20
5/5/2012 by Adam Pamudji R 9
Differentiation from interpolation
function The use of polynomials in approximation
problems allow us to find the derivative
and integral from that functions. Read page 145 and 146
8/3/2019 C04-Defferentiation and Integration
10/20
5/5/2012 by Adam Pamudji R 10
Differentiation and Integration
dxxfdxxP
xfxP
xfxP
n
n
n
''
8/3/2019 C04-Defferentiation and Integration
11/20
5/5/2012 by Adam Pamudji R 11
Differentiation
xLdxdxf
xLxfdx
d
xP
in
n
i
i
n
iinin
,
0
0,'
8/3/2019 C04-Defferentiation and Integration
12/20
5/5/2012 by Adam Pamudji R 12
Differentiation
n
ijj
n
iljl
l
ln
ijj
ji
in
n
ijj ji
j
in
xx
xx
xL
dx
d
xx
xxxL
0 0
0
,
0
,
1
8/3/2019 C04-Defferentiation and Integration
13/20
5/5/2012 by Adam Pamudji R 13
Numerical Integration
We can use theinterpolation function
to approximate anintegral
dxxPdxxf
xPxf
n
n
dxxLxf
dxxLxfdxxP
b
a
in
n
i
i
b
a
n
i
ini
bx
ax
n
,
0
0
,
8/3/2019 C04-Defferentiation and Integration
14/20
5/5/2012 by Adam Pamudji R 14
Numerical Integration
For the first and second Lagrangepolynomials with equally spaced nodes
Trapezoidal rule
Simpsons rule
Read page 163 to 165
Learn about closed and open Newton-Cotes formulas (p 168 to p 173)
8/3/2019 C04-Defferentiation and Integration
15/20
5/5/2012 by Adam Pamudji R 15
Trapezoidal rule
For function f(x)between x0=aandx1=b
h = x1x0
)(''12
)()(2
)(3
10f
hxfxf
hdxxf
b
a
a=x0 b=x1
f
P1
x
y
8/3/2019 C04-Defferentiation and Integration
16/20
5/5/2012 by Adam Pamudji R 16
Simpson rule
)(
90
)()(4)(3
)(
)4(5
210
fh
xfxfxfh
dxxfb
a
For function f(x)between x0=aand
x2=b
a=x0 b=x2
f
P1
x
y
x1
8/3/2019 C04-Defferentiation and Integration
17/20
5/5/2012 by Adam Pamudji R 17
Closed and Open Newton-Cotes
Closed N-C Trapezoidal rule
Simpsons rule Simpsons three-eight rule
Open N-C
Midpoint rules: n=0 n=1
n=2
a=x-1 b=x1
f
P1
x
y
x0
8/3/2019 C04-Defferentiation and Integration
18/20
5/5/2012 by Adam Pamudji R 18
Examples
See the excel file
http://../computation/INTEG00.XLShttp://../computation/INTEG00.XLS8/3/2019 C04-Defferentiation and Integration
19/20
5/5/2012 by Adam Pamudji R 19
Numerical Integration
Gaussian Quadrature
For a given known function
Optimizing accuracy by selecting best positionof nodes.
By using a standard tabulated coeff and node
positions, it is necessary to transform linearlythe function to an interval [-1,1]
8/3/2019 C04-Defferentiation and Integration
20/20
5/5/2012 by Adam Pamudji R 20
Gauss Quadrature
Read page 198 to 204
Example file
http://../computation/integrasi01.xlshttp://../computation/integrasi01.xls