NUMERICAL DIFFERENTIATIONNUMERICAL DIFFERENTIATIONThe derivative of f (x) at x0 is:
h
xfhxfxf Limith
)( 0000
An approximation to this is:
h
xfhxfxf )( 000
for small
values of h.
Forward Difference Formula
810 . and ln)(Let xxxfFind an approximate value for
81.f
0.1 0.5877867
0.6418539
0.5406720
0.01 0.5877867
0.5933268
0.5540100
0.0010.5877867
0.5883421
0.5554000
).( 81f ).( hf 81 hfhf ).().( 8181
h
The exact value of
555081 .. f
Assume that a function goes through three points:
., and ,,, 221100 xfxxfxxfx
)()( xPxf
221100 xfxLxfxLxfxLxP
Lagrange Interpolating Polynomial
21202
10
12101
20
02010
21
))(())((
))(())((
))(())((
xfxxxx
xxxx
xfxxxx
xxxx
xfxxxx
xxxxxP
221100 xfxLxfxLxfxLxP
20000
000
10000
000
00000
0000
)()2()2()(2
)2()()()2(2
)2()()2()(2
xfhxhxxhx
hxxx
xfhxhxxhx
hxxx
xfhxxhxx
hxhxxxP
If the points are equally spaced, i.e.,
hxxhxx 20201 and
hxxhxx 0201 and If the points are equally spaced with x0 in the middle:
20000
000
10000
000
00000
0000
)()()()(2
)()()()(2
)(()()()(2
xfhxhxxhx
hxxx
xfhxhxxhx
hxxx
xfhxxhxx
hxhxxxP
Alternate approach (Error estimate)Take Taylor series expansion of f(x+h) about x: xfhxfhxfhxfhxf 3
32
2
!32
xfhxfhxfhxfhxf 33
22
!32
xfhxfhxf
hxfhxf 3
22
!32.............. (1)
xfhxfhxfhxfhxf 33
22
!38
2422
xfhxfhxfhxfhxf 33
22
!38
2422
xfhxfhxf
hxfhxf 3
22
!34
22
22
..........
....... (2)
xfhxfhxf
hxfhxf 3
22
!32.............. (1)
xfhxfhxf
hxfhxf 3
22
!34
22
22
..........
....... (2)
2 X Eqn. (1) – Eqn. (2)
22342 hOxf
hxfhxfhxf
22342 hO
hxfhxfhxfxf
h
xfhxfhxfxf 2342
Three-point Formula xfhxfhhO 4
33
22
!46
!32
Take Taylor series expansion of f(x+h) about x: xfhxfhxfhxfhxf 3
32
2
!32Take Taylor series expansion of f(x-h) about x: xfhxfhxfhxfhxf 3
32
2
!32
The Second Three-point Formula
Subtract one expression from another
xfhxfhxfhhxfhxf 66
33
!62
!322
h
xfhxfhxfxf 2342
First Three-point Formula
Summary of Errors continued
xfhxfhhO 43
32
2
!46
!32Error
term
Example: xxexf
Find the approximate value of
2f
1.9 12.703199
2.0 14.778112
2.1 17.148957
2.2 19.855030
x xf
with 10.h
Using the Forward Difference formula:
0 0 01f x f x h f xh
12 21 2011 17148957 1477811201
23708450
ff . f.
. ...
Using the 1st Three-point formula:
032310.22 855030.19
148957.174778112.1432.01
)2.2()1.2(4)2(31.0212
ffff
hxfhxfxfh
xf 24321
0000
Using the 2nd Three-point formula:
228790.22
703199.12148957.172.01
)9.1()1.2(1.0212
fff
The exact value of
22.167168 :is 2f
hxfhxfh
xf 000 21
Comparison of the results with h = 0.1
Formula ErrorForward Difference
23.708450
1.541282
1st Three-point
22.032310
0.134858
2nd Three-point
22.228790
0.061622
2f
The exact value of
2f is 22.167168
Second-order Derivative
xfhxfhxfhxfhxf 33
22
!32
xfhxfhxfhxfhxf 33
22
!32Add these two equations.
xfhxfhxfhxfhxf 44
22
!42
222
2 4
2 42 22 2 4!h hf x h f x f x h f x f x
NUMERICAL INTEGRATIONNUMERICAL INTEGRATION
b
a
dxxf )( area under the curve f(x) between . to bxax
In many cases a mathematical expression for f(x) is unknown and in some cases even if f(x) is known its complex form makes it difficult to perform the integration.
Area of the trapezoidThe length of the two parallel sides of the trapezoid are: f(a) and f(b)
The height is b-a
)()(
)()()(
bfafh
bfafabdxxfb
a
2
2
2 2
0 0
2
0
2
0
1 20
0 1 0 2
0 21
1 0 1 2
0 12
2 0 2 1
x x
x x
x
x
x
x
( x x )( x x )P x dx f x dx( x x )( x x )
( x x )( x x ) f x dx( x x )( x x )( x x )( x x ) f x dx( x x )( x x )
Riemann Sum
The area under the curve is subdivided into n subintervals. Each subinterval is treated as a rectangle. The area of all subintervals are added to determine the area under the curve.There are several variations of Riemann sum as applied to composite integration.
In Left Riemann sum, the left-side sample of the function is used as the height of the individual rectangle.
a b
Left Riem ann Sumy
xx
1
2
3 2
1i
x b a / nx ax a xx a x
x a i x
1
nbia i
f x dx f x x
In Right Riemann sum, the right-side sample of the function is used as the height of the individual rectangle.a b
Right Riem ann Sumy
xx
1
2
3
23
i
x b a / nx a xx a xx a x
x a i x
1
nbia i
f x dx f x x
In the Midpoint Rule, the sample at the middle of the subinterval is used as the height of the individual rectangle.
a b
M idpoint Ruley
xx
1
2
3
2 1 1 22 2 1 22 3 1 2
2 1 2i
x b a / nx a x /x a x /x a x /
x a i x /
1
nbia i
f x dx f x x
Composite Trapezoidal Rule:Divide the interval into n subintervals and apply Trapezoidal Rule in each subinterval.
)()()( bfxfafhdxxfn
kk
b
a
1
122
where
nkkhaxn
abh k , ... , , ,for and 210
by dividing the interval into 20 subintervals.
Find πsin
0(x)dx
2021020
20
20
....., , , , ,π
π
kkkhax
nabh
n
k
Composite Simpson’s Rule:Divide the interval into n subintervals and apply Simpson’s Rule on each consecutive pair of subinterval. Note that n must be even.
)()(
)()(
/
)/(
bfxf
xfafhdxxf
n
kk
n
kk
b
a2
112
12
12
4
23
nkkhaxn
abh k , ... , , ,for and 210
where
by dividing the interval into 20 subintervals.
Find πsin
0(x)dx
2021020
2020
....., , , , ,π
π
kkkhax
nabhn
k
Top Related