0% found this document useful (0 votes)
22 views37 pages

Lesson 5. Numerical Integration

1) Numerical integration is needed to evaluate integrals of functions that cannot be solved analytically or that come from discrete experimental data. 2) The trapezoidal rule and mid-ordinate rule approximate integrals by dividing the region into intervals and using the ordinates or mid-ordinates over each interval. 3) Simpson's rule is another numerical integration technique that is more accurate than the trapezoidal or mid-ordinate rules.

Uploaded by

Lei Lopez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views37 pages

Lesson 5. Numerical Integration

1) Numerical integration is needed to evaluate integrals of functions that cannot be solved analytically or that come from discrete experimental data. 2) The trapezoidal rule and mid-ordinate rule approximate integrals by dividing the region into intervals and using the ordinates or mid-ordinates over each interval. 3) Simpson's rule is another numerical integration technique that is more accurate than the trapezoidal or mid-ordinate rules.

Uploaded by

Lei Lopez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

Numerical Integration

Lesson 5
Rationale
• Two main reasons for why there is a need to do numerical integration:
1. Analytical integration may be impossible/infeasible
2. It may be necessary to integrate tabulated data rather than known functions
• Applications for integration:
• Ex. Maxwell’s equations – numerical solutions of Maxwell’s equations can be directly used for
many engineering applications
• Integration is involved in practically every physical theory:
• Vibration, distortion under weight, or one of many types of fluid flow − e.g. heat flow, air flow
(over a wing), or water flow (over a ship’s hull, through a pipe, groundwater flow regarding a
contaminant), etc.;
• All these things can be either directly solved by integration (for simple systems), or some type of
numerical integration (for complex systems).
• Numerical integration is essential for evaluation of integrals of functions available only at
discrete points;
• Such functions often arise in the numerical solution of differential equations or from experimental
data taken at discrete intervals
• Engineers therefore often require numerical integration.
Lesson Objectives
• appreciate the need for numerical integration
• evaluate integrals using the trapezoidal rule
• evaluate integrals using the mid-ordinate rule
• evaluate integrals using Simpson’s rule
• apply numerical integration to practical situations
Contents
1. Introduction
2. The Trapezoidal Rule
3. The Mid-ordinate Rule
4. Simpson’s Rule
1. Introduction
• Even with advanced methods of integration there are many mathematical
functions which cannot be integrated by analytical methods and thus
approximate methods have then to be used.
• Approximate methods of definite integrals may be determined by what is
termed numerical integration.
• It may be shown that determining the value of a definite integral is, in fact,
finding the area between a curve, the horizontal axis and the specified
ordinates.
• Three methods of finding approximate areas under curves:
• The trapezoidal rule
• The mid-ordinate rule
• Simpson’s rule
• These rules are used as a basis for numerical integration.
Contents
1. Introduction
2. The Trapezoidal Rule
3. The Mid-ordinate Rule
4. Simpson’s Rule
2. The Trapezoidal Rule
• Let a required definite integral be
𝑏
denoted by 𝑎 𝑦𝑑𝑥 and be
represented by the area under the
graph of 𝑦 = 𝑓(𝑥) between the limits
𝑥 = 𝑎 and 𝑥 = 𝑏 (see Fig. 48.1)
• Let the range of integration be
divided into 𝑛 equal intervals, each of
width 𝑑, such that 𝑛𝑑 = 𝑏 − 𝑎 or
𝑏−𝑎
𝑑=
𝑛
• The ordinates are labelled 𝑦1 , 𝑦2 ,
𝑦3 ,… 𝑦𝑛+1
2. The Trapezoidal Rule
• An approximation to the area under
the curve may be determined by
joining the tops of the ordinates by
straight lines.
• Each interval is thus a trapezium, the
area of which is given by:
1 sum of parallel sides ×
𝐴=
2 perpendicular distance between them
𝑏
𝑦𝑑𝑥
𝑎
1 1
≈ 𝑦1 + 𝑦2 𝑑 + 𝑦2 + 𝑦3 𝑑
2 2
1 1
+ 𝑦3 + 𝑦4 𝑑 + ⋯ + 𝑦𝑛 + 𝑦𝑛+1 𝑑
2 2
1
≈ 𝑑 𝑦1 + 𝑦2 + 𝑦3 + 𝑦4 + ⋯ + 𝑦𝑛 +
2
The Trapezoidal Rule:

𝑏
width of 1 first + last remaining
𝑦𝑑𝑥 = +
𝑎 interval 2 ordinate ordinates
3 2
Problem 1. (a) Use integration to evaluate 1 𝑥
𝑑𝑥,
correct to 3 decimal places.
• Solution:
Problem 1. (b) Use the Trapezoidal Rule with four
intervals to evaluate the integral in 1(a), correct to 3
decimal places.
• The range of integration is the difference
between the upper and lower limits, 3 − 1 = 2.
• Using the trapezoidal rule with four intervals
3−1
gives an interval width 𝑑 = = 0.5 and
4
ordinates situated at 1.0, 1.5, 2.0, 2.5, and 3.0.
2
• Corresponding values of are shown in the
𝑥
table, each correct to 4 decimal places (one more
decimal place than required in the problem).
Problem 1. (b) Use the Trapezoidal Rule with four
intervals to evaluate the integral in 1(a), correct to 3
decimal places.
• Solution:
Problem 2. Use the trapezoidal rule with eight intervals
3 2
to evaluate 1 𝑑𝑥 correct to 3 decimal places.
𝑥
3−1
• With eight intervals, width of each is 𝑑 = = 0.25
8
• Ordinates: 1.00, 1.25, 1.50, 1.75, 2.00, 2.25, 2.50, 2.75
and 3.00.
2
• Corresponding values of are shown in the table:
𝑥
Problem 2. Use the trapezoidal rule with eight intervals
3 2
to evaluate 1 𝑑𝑥 correct to 3 decimal places.
𝑥
Problem 2. Use the trapezoidal rule with eight intervals
3 2
to evaluate 1 𝑑𝑥 correct to 3 decimal places.
𝑥
• This problem demonstrates that the greater the number of intervals
chosen (i.e. the smaller the interval width) the more accurate will be
the value of the definite integral.
• The exact value is found when the number of intervals is infinite,
which is the basis for the process of integration.
𝜋/2 1
Problem 3. Use the trapezoidal rule to evaluate 0
𝑑𝑥
1+sin 𝑥
using six intervals. Give the answer correct to 4 significant
figures.
𝜋
−0 𝜋
• With six intervals, width of each is 𝑑 = 2
=
6 12
rad (15°)
1
• Ordinates occur at corresponding values of
1+sin 𝑥
(see table)
𝜋/2 1
Problem 3. Use the trapezoidal rule to evaluate 0
𝑑𝑥
1+sin 𝑥
using six intervals. Give the answer correct to 4 significant
figures.
Contents
1. Introduction
2. The Trapezoidal Rule
3. The Mid-ordinate Rule
4. Simpson’s Rule
3. The Mid-ordinate Rule
• Let a required definite integral be
𝑏
denoted by 𝑎 𝑦 𝑑𝑥 and represented
by the area under the graph of 𝑦 =
𝑓(𝑥) between the limits 𝑥 = 𝑎 and
𝑥 = 𝑏 (see Fig. 48.2)
• Each interval of width 𝑑 is assumed to
be replaced by a rectangle of height
equal to the ordinate at the middle
point of each interval, shown as 𝑦1 ,
𝑦2 , 𝑦3 ,..., 𝑦𝑛 (see Fig. 48.2)
3. The Mid-ordinate Rule
• Thus
𝑏
𝑦 𝑑𝑥
𝑎
≈ 𝑑𝑦1 + 𝑑𝑦2 + 𝑑𝑦3 + ⋯ + 𝑑𝑦𝑛
≈ 𝑑(𝑦1 + 𝑦2 + 𝑦3 + ⋯ + 𝑦𝑛 )

• The Mid-ordinate Rule states:


𝑏
𝑦 𝑑𝑥 ≈ (width of interval)(sum of mid − ordinates)
𝑎
Problem 4. Use the mid-ordinate rule with (a) four intervals, (b) eight
3 2
intervals, to evaluate 1 𝑑𝑥, correct to 3 decimal places.
𝑥

Solution (a):
3−1
• With four intervals, each will have a width of 𝑑 = = 0.5
4
• The ordinates will occur at 1.0, 1.5, 2.0, 2.5 and 3.0
• The mid-ordinates 𝑦1 , 𝑦2 , 𝑦3 , and 𝑦4 occur at 1.25, 1.75, 2.25
and 2.75
2
• Corresponding values of are shown in the table
𝑥

• From equation (2):


3
2
𝑑𝑥 ≈ 0.5 1.7889 + 1.5119 + 1.3333 + 1.2060 = 𝟐. 𝟗𝟐𝟎
1 𝑥
Correct to 3
decimal places
Problem 4. Use the mid-ordinate rule with (a) four intervals, (b) eight
3 2
intervals, to evaluate 1 𝑑𝑥, correct to 3 decimal places.
𝑥

Solution (b):
3−1
• With eight intervals, each will have a width of 𝑑 = = 0.25
8
• The ordinates will occur at 1.00, 1.25, 1.50, 1.75,…
• The mid-ordinates 𝑦1 , 𝑦2 , 𝑦3 , 𝑦4 ,… occur at 1.125, 1.375,
1.625 and 1.875…
2
• Corresponding values of are shown in the table
𝑥
• From equation (2):
3
2
𝑑𝑥
1 𝑥
≈ 0.25 1.8856 + 1.7056 + 1.5689 + 1.4606 + 1.3720 + 1.2978 + 1.2344
Correct to 3 The greater the number of intervals the
decimal places nearer the result is to the true value.
−𝑥2
2.4
Problem 5. Evaluate 0
𝑒
𝑑𝑥, correct to 4 significant
3

figures, using the mid-ordinate rule with six intervals.


2.4−0
• With six intervals, each will have a width of 𝑑 = = 0.40
6
• The ordinates will occur at 0, 0.40, 0.80, 1.20, 1.60, 2.00, and
2.40
• The mid-ordinates are at 0.20, 0.60, 1.00, 1.40, 1.80, and 2.20
−𝑥2
• Corresponding values of 𝑒 3 are shown in the table

• From equation (2):


2.4 −𝑥 2
𝑒 3 𝑑𝑥 ≈ 0.40 0.98676 + 0.88692 + 0.71653 + 0.52031 + 0.33960 + 0.19922
0
= 𝟏. 𝟒𝟔𝟎 Correct to 3
decimal places
Contents
1. Introduction
2. The Trapezoidal Rule
3. The Mid-ordinate Rule
4. Simpson’s Rule
4. Simpson’s Rule
• The approximation made with the trapezoidal rule is to join the top of
two successive ordinates by a straight line, i.e. by using a linear
approximation of the form 𝑎 + 𝑏𝑥.

• With Simpson’s Rule, the approximation made is to join the tops of


three successive ordinates by a parabola, i.e. by using a quadratic
approximation of the form 𝑎 + 𝑏𝑥 + 𝑐𝑥 2 .
4. Simpson’s Rule
• Fig. 48.3 shows a parabola 𝑦 = 𝑎 + 𝑏𝑥 + 𝑐𝑥 2 with ordinates 𝑦1 , 𝑦2 and 𝑦3
at 𝑥 = −𝑑, 𝑥 = 0, and 𝑥 = 𝑑, respectively.
• Thus the width of each of the two intervals is 𝑑.
• The area enclosed by the parabola, the 𝑥-axis and ordinates 𝑥 = −𝑑 and
𝑥 = 𝑑 is given by:
𝑑 2 3 𝑑
2
𝑏𝑥 𝑐𝑥
𝑎 + 𝑏𝑥 + 𝑐𝑥 𝑑𝑥 = 𝑎𝑥 + +
−𝑑 2 3 −𝑑
𝑏𝑑 2 𝑐𝑑 3 𝑏𝑑 2 𝑐𝑑 3
= 𝑎𝑑 + + − −𝑎𝑑 + −
2 2 2 2
2 3 1
= 2𝑎𝑑 + 𝑐𝑑 or 𝑑(6𝑎 + 2𝑐𝑑 2 )
3 3
4. Simpson’s Rule
• Since 𝑦 = 𝑎 + 𝑏𝑥 + 𝑐𝑥 2
• at 𝑥 = −𝑑, 𝑦1 = 𝑎 − 𝑏𝑑 + 𝑐𝑑2
• at 𝑥 = 0, 𝑦2 = 𝑎
• at 𝑥 = 𝑑, 𝑦3 = 𝑎 + 𝑏𝑑 + 𝑐𝑑2
• Hence: 𝑦1 + 𝑦3 = 2𝑎 + 2𝑐𝑑2
• and: 𝑦1 + 4𝑦2 + 𝑦3 = 6𝑎 + 2𝑐𝑑2
• Thus the area under the parabola between 𝑥 = −𝑑 and 𝑥 = 𝑑 in Fig.
1
48.3 may be expressed as 𝑑(𝑦1 + 4𝑦2 + 𝑦3 ), from equations (3)
3
and (4)
• The result is seen to be independent of the position of the origin.
• Let
𝑏
a definite integral be denoted by
𝑦 𝑑𝑥 and represented by the area
4. Simpson’s Rule 𝑎
under the graph of 𝑦 = 𝑓(𝑥) between the
limits 𝑥 = 𝑎 and 𝑥 = 𝑏 (Fig. 48.4)
• The range of integration, 𝑏 − 𝑎, is divided
into an even number of intervals, say 2𝑛,
each of width 𝑑.
• Since an even number of intervals is
specified, an odd number of ordinates,
2𝑛 + 1, exists.
• Let an approximation to the curve over
the first two intervals be2
a parabola of the
form 𝑦 = 𝑎 + 𝑏𝑥 + 𝑐𝑥 , which passes
through the tops of the three ordinates
𝑦1 , 𝑦2 and 𝑦3 .
• Similarly, let an approximation to the
curve over the next two intervals be the
parabola which passes through the tops of
the ordinates 𝑦3 , 𝑦4 and 𝑦5 , and so on.
4. Simpson’s Rule
• Then…
𝑏
𝑦 𝑑𝑥
𝑎
1 1
≈ 𝑑 𝑦1 + 4𝑦2 + 𝑦3 + 𝑑 𝑦3 + 4𝑦4 + 𝑦5
3 3
1
+ 𝑑 𝑦2𝑛−1 + 4𝑦2𝑛 + 𝑦2𝑛+1
3
1
≈ 𝑑 𝑦1 + 𝑦2𝑛+1 + 4 𝑦2 + 4𝑦4 + ⋯ + 𝑦2𝑚
3
+ 2 𝑦3 + 𝑦5 + ⋯ + 𝑦2𝑛−1
4. Simpson’s Rule
• Simpson’s Rule states:
𝑏
𝑦 𝑑𝑥
𝑎
1 width of first + last sum of even sum of odd
≈ +4 +2
3 interval ordinates ordinates ordinates

• Note: Simpson’s rule can only be applied when an even number of


intervals is chosen, i.e. an odd number of ordinates.
Problem 6. Use Simpson’s rule with (a) four intervals, (b) eight
3 2
intervals, to evaluate 1 𝑑𝑥, correct to 3 decimal places.
𝑥

Solution (a):
3−1
• With four intervals, each will have a width of 𝑑 = = 0.5 first
4
even
• The ordinates will occur at 1.0, 1.5, 2.0, 2.5, and 3.0
odd
2
• Corresponding values of are shown in the table even
𝑥
• From equation (5): last
3
2 1
𝑑𝑥 ≈ 0.5 2.0000 + 1.1547 + 4 1.6330 + 1.2649 + 2 1.4142
1 𝑥 3
1 Correct to 3
= 0.5 3.1547 + 11.5916 + 2.8284 = 𝟐. 𝟗𝟐𝟗 decimal places
3
Problem 6. Use Simpson’s rule with (a) four intervals, (b) eight
3 2
intervals, to evaluate 1 𝑑𝑥, correct to 3 decimal places.
𝑥

Solution (b):
3−1
• With eight intervals, each will have a width of 𝑑 = = 0.25
8
• The ordinates will occur at 1.00, 1.25, 1.50, 1.75,…, and 3.0
2
• Corresponding values of are shown in the table
𝑥
• From equation (5):
3
2
𝑑𝑥
1 𝑥
1
≈ 0.25 2.0000 + 1.1547
3
+ 4 1.7889 + 1.5119 + 1.3333 + 1.2060

Correct to 3 decimal places


Problem 6 Notes:
• The latter answer is exactly the same as that obtained by integration.

• In general, Simpson’s rule is regarded as the most accurate of the


three approximate methods used in numerical integration.
𝜋/3 1
Problem 7. Evaluate 0
1− sin2 𝜃 𝑑𝜃, correct to 3
3
decimal places, using Simpson’s rule with six intervals.
𝜋
−0 𝜋
• With six intervals, each will have a width of 𝑑 = 3
= = 10°
6 18
𝜋 𝜋 𝜋 2𝜋 5𝜋 𝜋
• The ordinates will occur at 0, , , , , , and
18 9 6 9 18 3
1
• Corresponding values of 1 − sin2 𝜃 are shown in the table
3
𝜋/3 1
Problem 7. Evaluate 0
1− sin2 𝜃 𝑑𝜃, correct to 3
3
decimal places, using Simpson’s rule with six intervals.
• From equation (5):
𝜋/3
1
1 − sin2 𝜃 𝑑𝜃
0 3
1 𝜋
≈ 1.0000 + 0.8660 + 4 0.9950 + 0.9574 + 0.8969 + 2 0.9803 + 0.9286
3 18
1 𝜋
= 1.8660 + 11.3972 + 3.8178 = 𝟎. 𝟗𝟗𝟒 Correct to 3 decimal places
3 18

first even odd even odd even last


Problem 8. An alternating current 𝑖 has the
first
following values at equal intervals of 2.0 even
milliseconds (see table at the right). Charge 𝑞 in odd
12.0
millicoulombs is given by 𝑞 = 0 𝑖 𝑑𝑡. Use even
odd
Simpson’s rule to determine the approximate even
charge in the 12 millisecond period. last
• From equation (5):
12.0
1
𝑞= 𝑖 𝑑𝑡 ≈ 2.0 0 + 0 + 4 3.5 + 10 + 2.0 + 2 8.2 + 7.3
0 3
𝑞 = 𝟔𝟐 𝒎𝑪
end

You might also like