week08&09_numerical integration & differentiation
TRANSCRIPT
![Page 1: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/1.jpg)
![Page 2: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/2.jpg)
WEEK 8 & 9
Numerical Integration and Differentiation Newton-Cotes integration formulas:
Trapezoidal rule
Simpson’s Rule
Integration with unequal segments
Numerical differentiation: High accuracy differentiation formula
Richardson extrapolation 2
![Page 3: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/3.jpg)
At the end of this topic, the students will be able:
To identify and apply the methods outlines
to integrate formulae and data set
To identify and apply the methods outlines to
differentiate formulae and data set
LESSON OUTCOMES
![Page 4: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/4.jpg)
4
Derivative – represents the rate of change of a dependent variable with respect to an independent variable given by mathematical definition begin with a difference approximation: If Δx is allowed to approach zero, the differences becomes a derivative
x
xfxxf
x
y ii
)()(
x
xfxxf
dx
dy ii
x
)()(lim
0
y and f(x) dependent variable
x is dependent variable
dy/dx : first derivative of y with
respect to x evaluated at xi.
derivative slope of the
tangent to the curve at xi
DIFFERENTIATION
![Page 5: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/5.jpg)
5
INTEGRATION
Integrate – to bring together, as parts, into a whole; to unite; to indicate the total amount…. – Mathematical definition represented by which stands for the integral of the function f(x) with respect to the independent variable x, evaluated between the limits x=a to x=b.
b
adxxfI )(
The integral is
equivalent to the
area under the curve
![Page 6: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/6.jpg)
6
• The function to be differentiated or integrated will typically be in one of the following three forms:
– A simple continuous function such as polynomial, an exponential, or a trigonometric function.
– A complicated continuous function that is difficult or impossible to differentiate or integrate directly.
– A tabulated function where values of x and f(x) are given at a number of discrete points, as is often the case with experimental or field data.
NONCOMPUTER METHODS FOR
DIFFERENTIATION AND INTEGRATION
![Page 7: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/7.jpg)
7
A noncomputer method for determining derivatives from data : equal-area graphical differentiation
Centered finite divided differences are used to estimates the derivative for each interval between the data points
Then, these values are plotted as a stepped curve versus x. That is, it is drawn so that visually, the positive and negative area are balance.
Then, values of dy/dx can be read off the smooth curve at given valus of x.
![Page 8: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/8.jpg)
8
A noncomputer method for determining integration from data :
The use of grid to approximate an integral
The use of rectangles or strips to approximate an integral
Application of a numerical integration or quadrature
method
(a) A complicated, continous function
(b) Table of discrete values of f(x) generated
from the function
(c) Use of numerical method to estimate the integral on the basis of
the discrete points.
![Page 9: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/9.jpg)
9
Newton-Cotes Integration Formulas
• The Newton-Cotes formulas are the most common numerical integration schemes.
• They are based on the strategy of replacing a complicated function or tabulated data with an approximating function that is easy to integrate:
n
n
n
nn
n
b
a
n
b
a
xaxaxaaxf
xf
dxxfdxxfI
1
110)(
polynomial of form )( where
)()(
![Page 10: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/10.jpg)
10
(a) First-order polynomial (straight
line) is used as an approximation
(b) A parabola is employed as an approximation
The integral can also be approximated using a series of polynomials applied piecewise to the function or data over segments of constant length.
The approximation of an integral by the area under three straight-
line segments
![Page 11: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/11.jpg)
11
• Closed and open forms of the Newton-Cotes formulas are available.
Closed forms where the data points at the beginning and end of the limits of integration are known.
Open forms where have integration limits that extend beyond the range of the data. This formulas not generally used for difinite integration. However, they are utilized for evaluating improper integrals and for solution of ODE.
![Page 12: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/12.jpg)
12
THE TRAPEZOIDAL RULE
• The Trapezoidal rule is the first of the Newton-Cotes closed integration formulas, corresponding to the case where the polynomial is first order:
• The area under this first order polynomial is an estimate of
the integral of f(x) between the limits of a and b:
b
a
b
a
dxxfdxxfI )()( 1
2
)()()(
bfafabI
Trapezoidal Rule
![Page 13: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/13.jpg)
13
)()()(
)()(
)()()(
)()(
)()()()(
1
0
01
0101
01
01
0
01
axab
afbfafxf
xxxx
xfxfxfxf
xx
xfxf
xx
xfxf
b
a
b
a
dxxfdxxfI )()( 1
b
a
dxaxab
afbfafI )(
)()()(
2
)()()(
bfafabI
Derivation:
Refer Box 21.1
(page 603) text book
![Page 14: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/14.jpg)
14
• Geometrically, the trapezoidal rule is equivalent to approximating the area of the trapezoid under the straight line connecting f(a) and f(b).
(a) Area of trapezoid ≈ height x average bases
(b) I ≈ width x average height
I ≈ (b – a) x average height
Average height = f(a) + f(b)
2
2
)()()(
bfafabI
![Page 15: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/15.jpg)
15
Error of the Trapezoidal Rule
• When we employ the integral under a straight line segment to approximate the integral under a curve, error may be substantial:
where x lies somewhere in the interval from a to b.
• If the function being integrated is linear, the trapezoidal rule will be exact.
• Otherwise, for functions with second and higher order derivatives (curvature), some error can occur.
33 )(''12
1))((''
12
1abfabfEt x
Derivation and Error Estimate:
Refer Box 21.2
(page 606) text book
![Page 16: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/16.jpg)
16
The Multiple-Application Trapezoidal Rule
• One way to improve the accuracy of the trapezoidal rule is to divide the integration interval from a to b into a number of segments and apply the method to each segment.
• The areas of individual segments can then be added to yield the integral for the entire interval.
• The resulting equations are called multiple-application or composite integration formulas.
![Page 17: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/17.jpg)
17
n
n
x
x
x
x
x
x
n
dxxfdxxfdxxfI
n
xbxan
abh
1
2
1
1
0
)()()(
equally segments
0
2
)()(
2
)()(
2
)()( 12110 nn xfxfh
xfxfh
xfxfhI
1
1
0 )()(2)(2
n
i
ni xfxfxfh
I
n
xfxfxf
abI
n
i
ni
2
)()(2)(
)(
1
1
0
General format for multiple
application integrals
![Page 18: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/18.jpg)
18
Error of the multiple-application Trapezoidal Rule
• An error for multiple-application trapezoidal rule can be obtained by summing the individual errors for each segment:
fn
abE
fnf
fn
abE
a
i
n
i
it
2
3
13
3
12
)(
)(
)(12
)(
x
x
![Page 19: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/19.jpg)
19
Example
Given f(x)=0.2+25x–200x2+675x3–900x4+400x5
Use following method to estimate the integral of given equation from a = 0 to b = 0.8. a) Single application of the Trapezoidal Rule b) Multiple application of the Trapezoidal Rule (2 segments)
Given that the exact value of the integral that determined analytically is 1.640533. Find true percent relative error and estimated error of the Trapezoidal Rule.
![Page 20: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/20.jpg)
20
THE SIMPSON’S RULES
• More accurate estimate of an integral is obtained if a high-order polynomial is used to connect the points. The formulas that result from taking the integrals under such polynomials are called Simpson’s rules.
(a) Graphical depiction of Simpson’s 1/3 rule: It consists of taking the area under a parabola connecting three points.
(b) Graphical depiction of Simpson’s 3/8 rule: It consists of taking the area under a cubic equation connecting four points.
![Page 21: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/21.jpg)
21
Simpson’s 1/3 Rule
• Results when a second-order interpolating polynomial is used.
2
a)(b xb; and abetween midway point the xand xb ,xa where
6
)()(4)()(
or
2)()(4)(
3
)())((
))(()(
))((
))(()(
))((
))((
,polynomial Lagrangeorder -second using drepresente is )(
)()(
1120
210
210
2
1202
101
2101
200
2010
21
2
202
2
0
xfxfxfabI
ab
n
abhxfxfxf
hI
dxxfxxxx
xxxxxf
xxxx
xxxxxf
xxxx
xxxxI
xf
xbxadxxfdxxfI
x
x
b
a
b
a
• Single segment application of Simpson’s 1/3 rule has a truncation error of:
• Simpson’s 1/3 rule is more accurate than trapezoidal rule.
bafab
Et
xx )(2880
)( )4(5
![Page 22: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/22.jpg)
22
• Just as the trapezoidal rule, Simpson’s rule can be improved by dividing the integration interval into a number of segments of equal width.
• Yields accurate results and considered superior to trapezoidal rule for most applications.
• However, it is limited to cases where values are equispaced. • Further, it is limited to situations where there are an even
number of segments and odd number of points.
The Multiple-Application Simpson’s 1/3 Rule
)4(
4
5
1
5,3,1
2
6,4,2
0
180
)(
3
)()(2)(4)(
)(
fn
abE
n
xfxfxfxf
abI
a
n
i
n
n
j
ji
![Page 23: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/23.jpg)
23
Example
Given f(x)=0.2+25x–200x2+675x3–900x4+400x5
Use following method to estimate the integral of given equation from a = 0 to b = 0.8. a) Single application of the Simpson’s 1/3 Rule b) Multiple application of the Simpson’s 1/3 Rule with n=4.
Given that the exact value of the integral that determined analytically is 1.640533. Find true percent relative error and estimated error of the Simpson’s Rule.
![Page 24: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/24.jpg)
24
Simpson’s 3/8 Rule
• An odd-segment-even-point formula used in conjunction with the 1/3 rule to permit evaluation of both even and odd numbers of segments.
• The equation called Simpson’s 3/8 rule because h is multiplied by 3/8.
)(6480
)(
8
)()(3)(3)(
)( )()(3)(3)(
8
3
)()(
)4(5
3210
3210
3
xfab
E
xfxfxfxfabI
n
abhxfxfxfxf
hI
dxxfdxxfI
t
b
a
b
a
More accurate
![Page 25: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/25.jpg)
25
Illustration of how Simpson’s 1/3 and 3/8 rules can be applied in tandem to handle multiple applications with odd numbers of intervals.
![Page 26: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/26.jpg)
26
Example
Given f(x)=0.2+25x–200x2+675x3–900x4+400x5
Use following method to estimate the integral of given equation from a = 0 to b = 0.8. a) Simpson’s 3/8 Rule b) Use Simpson’s 3/8 Rule in conjuction with Simpson’s 1/3 Rule
to integrate the same function for five segments.
Given that the exact value of the integral that determined analytically is 1.640533. Find true percent relative error.
![Page 27: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/27.jpg)
27
INTEGRATION WITH UNEQUAL SEGMENTS
• In practice, many situations deal with unequal-sized segments.
• In that case, one method is apply the trapezoidal rule to each segment and sum the results.
• In other method, inclusion of trapezoidal rule and Simpson's Rule for unequal segments.
2
)()(
2
)()(
2
)()( 12110 nn xfxfh
xfxfh
xfxfhI
![Page 28: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/28.jpg)
28
Example Given data for f(x)=0.2+25x–200x2+675x3–900x4+400x5.
Given that the exact value of the integral that determined
analytically is 1.640533. Find true percent relative error.
Use following method to determine the integral for this data. a) Trapezoidal rule with unequal segments b) Inclusion of Trapezoidal and Simpson’s rules
x f(x) x f(x)
0.0 0.200000 0.44 2.842985
0.12 1.309729 0.54 3.507297
0.22 1.305241 0.64 3.181929
0.32 1.743393 0.70 2.363000
0.36 2.074903 0.80 0.232000
0.40 2.456000
![Page 29: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/29.jpg)
Forward finite divided difference
Backward finite divided difference
Centered finite divided difference
29
Numerical Differentiation
![Page 30: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/30.jpg)
30
• High-accuracy divided difference formulas can be generated by including additional terms from the Taylor series expansion. • For example, the forward Taylor series expansion can be written as
)()()(
)('
: terms)derivativehigher and second (excluding
difference forwardfirst So,
)(2
)(")()()('
for solved becan which
...2
)(")(')()(
1
21
2
1
hOh
xfxfxf
hOhxf
h
xfxfxf
hxf
hxfxfxf
iii
iiii
iiii
HIGH-ACCURACY DIFFERENTIATION FORMULAS
![Page 31: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/31.jpg)
31
)(2
)(3)(4)()('
terms,collectingby or,
)(2
)()(2)()()()('
yield todifference forwardfirst into
)()()(2)(
)("
,derivative second theof
ion approximat thengsubstitutiby termderivative secondFor
212
2
2
121
2
12
hOh
xfxfxfxf
hOhh
xfxfxf
h
xfxfxf
hOh
xfxfxfxf
iiii
iiiiii
iiii
* This equation incorporates more terms of Taylor series expansion and more accurate.
Refer Text book
Page 92 & 93
![Page 32: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/32.jpg)
32
Forward finite-divided difference formulas: two versions are presented for each derivative. The latter version incorporates more terms of Taylor Series expansion and consequently more accurate.
h4
![Page 33: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/33.jpg)
33
Backward finite-divided difference formulas: two versions are presented for each derivative. The latter version incorporates more terms of Taylor Series expansion and consequently more accurate.
![Page 34: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/34.jpg)
34
Centered finite-divided difference formulas: two versions are presented for each derivative. The latter version incorporates more terms of Taylor Series expansion and consequently more accurate.
![Page 35: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/35.jpg)
35
Example
Estimated the first derivative of f(x) = – 0.1x4 – 0.15x3 – 0.5x2 – 0.25x + 1.2 at x = 0.5 using finite divided differences and a step size of h = 0.25.
a) Use forward and backward differences approximations
of O(h) and centered difference approximation of O(h2).
b) Use high-accuracy formulas of finite divided differences.
![Page 36: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/36.jpg)
36
2.0 1
6363.0 75.0
925.0 5.0
1035.1 25.0
2.1 0
n,calculatio From
22
11
11
22
ii
ii
ii
ii
ii
xfx
xfx
xfx
xfx
xfx
Forward
O(h)
Backward
O(h)
Centered
O(h2)
Estimate -1.155 -0.714 -0.934
ε t (%) -26.5 21.7 -2.4
Forward
O(h2)
Backward
O(h2)
Centered
O(h4)
Estimate -0.8594 -0.8781 -0.9125
ε t (%) 5.82 3.77 0
Solution
![Page 37: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/37.jpg)
37
RICHARDSON EXTRAPOLATION
• Richardson extrapolation is a method uses two estimates of an integral to compute a third, more accurate approximation.
• Two ways to improve derivative estimates when employing finite divided difference:
1) decrease the step size 2) use a higher-order formula that employs
more point.
![Page 38: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/38.jpg)
)](3
1)(
3
4
s,derivativefor itten fashion wrSimilar
)](3
1)(
3
4
)]()([1)2(
1)(
)]()([1))/2((
1)(
,2/ wherecase for the written formula This
.h and h sizes step twousing estimates integral are )( and )( where
)]()([1)/(
1)(
estimate, integral oft improvemen Formula
12
12
1222
122
11
2
12
2121
122
21
2
hDhDD
hIhII
hIhIhII
hIhIhh
hII
hh
hIhI
hIhIhh
hII
I
For centered difference
approximations with O(h2),
the application of this
formula will yield a new
derivative estimate of O(h4).
![Page 39: Week08&09_Numerical Integration & Differentiation](https://reader031.vdocuments.mx/reader031/viewer/2022020211/577cc77d1a28aba711a1198d/html5/thumbnails/39.jpg)
39
Example
Estimated the first derivative of f(x) = – 0.1x4 – 0.15x3 – 0.5x2 – 0.25x + 1.2 at x = 0.5 employing step sizes of h1 = 0.5 and h2 = 0.25. Compute an improved estimate with Richardson extrapolation. The true value is -0.9125.
Solution The first derivative estimates can be computed with centered differences
%0 9125.0)0.1(3
1)9344.0(
3
4)(
3
1)(
3
4
%4.2 9344.0)25.0(2
1035.16363.0
2
)()()(')25.0(
%6.9 0.1)5.0(2
2.12.0
2
)()()(')5.0(
t12
t11
2
t11
1
hDhDD
h
xfxfxfhD
h
xfxfxfhD
iii
iii