Trapezoidal Rule in Numerical Integration
Trapezoidal Rule in Numerical Integration
=∫ ( ) ≅ ∫ 1 ( )
( )− ( )
=∫[ ( )+ ( − )]
−
The result of the integration is
( )+ ( )
=( − )
2
What is known as the trapezoidal rule
Geometrically, the trapezoid rule is equivalent to approximating the area of the trapezoid below the
a straight line that connects f(a) and f(b). Remember that the formula to calculate the area of a trapezoid is
the height multiplied by the average of the bases. In our case, the concept is the same, but the
the trapezoid is on its side (figure 21.5b). Therefore, the approximate integral is represented
how
≅ ℎ ×
≅( − )×
( )− ( ) ( ) − ( )
1( ) = +
− −
Which can be integrated between x=a and x=b to obtain:
( )− ( ) 2 ( ) − ( )
= + |
− 2 −
This result is evaluated to give:
2
( ) − ( )( − )2 (− ) ( )
= + ( − )
− 2 −
Now, like 2− 2= ( − )( + ),
+
=[ ( ) − ( )] + ( ) − ( )
2
Multiplying and grouping terms gives:
( )+ ( )
=( − )
2
What is the formula for the trapezoidal rule?
´´( )
=∫ [ ( )+ ∆ ( ) + ( ) 2]
− 1ℎ
2
( − )
To simplify the analysis, consider that if = , then =ℎ
ℎ
Because h = b-a (for a segment of the trapezoidal rule), the limits of integration a and
b correspond to 0 and 1, respectively. Therefore, the equation will be expressed as
1
´´( )
=ℎ∫[ ( )+ ∆ ( ) + ( ) 2]
− 1ℎ
0 2
And evaluated as
Δ ( ) 1
=ℎ [ ( ) + ]− ´´( ) 3ℎ
2 12
from a = 0 to b = 0.8. Remember that the exact value of the integral can be determined at
analytical form and is 1.640533.
Solution.
When evaluating the function
(0) = 0.2 + 25x- 200(0)2+ 675(0)3- 900(0)4+ 400(0)5
The average value of the second derivative is calculated using the equation:
The multiple application trapezoidal rule One way to improve the accuracy of the rule of
trapezoid consists of dividing the integration interval from a to b into several segments, and applying the
method to each of them (figure 21.7). The areas
One way to improve the accuracy of the trapezoidal rule is to divide the interval of
integration of a or b in several segments, and apply the
method to each of them. The areas of the segments
they are added later to obtain the integral over the entire
interval. The resulting equations are called formulas
of integration, of multiple or composite application.
( )0 + ( 1) ( )1+ ( 2) ( −1)+ ( )
=ℎ +ℎ +⋯+ℎ
2 2 2
Oh, we group terms,
−1
ℎ
=[ ( 0+) 2 ∑ +( ) ]( )
2
=1
Oh, using the following equation to express the equation in general form of the equation
−1
( )0 + 2 ∑ =1 ( ) + ( )
=( − )
2n
Since the sum of the coefficients of f(x) in the numerator divided by 2n equals 1, the
Average height represents a weighted average of the values of the function. According to
with the equation, the interior points are given double the weight of the two extreme points
( 0) ( )There is an error with the multiple application trapezoidal rule when summing the
individual errors of each segment, like this
( − )3
=− ∑ ´´( )
12n3
=1
∑ =1 ´´( )
´´ ≅
Therefore, ´´
∑ ( ≅) ´´ and the equation is written as
( − )3
= − ´´
12n2
Thus, if the number of segments is doubled, the truncation error is divided by four.
Use the trapezoidal rule with two segments to estimate the integral of
Solution:
n = 2ℎ( = 0,4 : )
( 0=
) 0,2 ; 0,4 ( = 2,456
) ( )
0,8 = 0,232
(
02 + 2 2,456 +) 0,232
= 0,8 = 1,0688
4
= 34.9%
0.83
= − ( -60=)0,64
12(2)2
The results of the previous example, along with applications of the trapezoidal rule with three to
ten segments, are summarized in table 21.1. Note how the error decreases as
it increases the number of segments. However, also note that the reason for the decrease
it is gradual, because the error is inversely related to the square of n. Therefore
Thus, by doubling the number of segments, the error is divided by four. In the following
we will develop higher degree formulas that are more accurate and that converge
faster towards the true integral as the segments increase. However, before
to investigate such formulas, we will analyze computational algorithms to implement the
trapezoidal rule.
For individual applications of functions with good behavior, the trapezoidal rule
of multiple segments is almost exact for the type of precision required in various
applications of engineering.
If high accuracy is required, the multiple segment trapezoidal rule demands a large
computational work. Although this work seems insignificant for a single application,
it can be very important when: a) numerous integrals are evaluated, or b) where the function
it is time-consuming in its evaluation. For such cases, perhaps methods may be required
more efficient (they will be analyzed in the remaining part of this chapter and in the next one).
SIMPSON'S RULE 1 / 3
where a = x0, b = x2 and x1 = the point halfway between a and b, which is given by (b + a)/2. Observe
that, according to the equation, the midpoint is weighted by two thirds; and the two
extreme points, by a sixth. It can be shown that the application to a single segment of the
Simpson's 1/3 rule has a truncation error of
1 5 ( 4)
=− ℎ ( )
90
Or how h = (b-a) /2,
( − )5 (4 )(
=− )
2880
where ξ is somewhere in the interval from a to b. Thus, the 1/3 Simpson's rule is more accurate
that the trapezoidal rule. Consequently, the Simpson 1/3 rule achieves an accuracy of
third order even when based on only three points. In other words, it gives exact results
for cubic polynomials even when obtained from a parabola
Solution
( )= . ( . )= . ( . )= .
(
0.2 + 4 2.456 )+ 0.232
= 0.8 = 1.367467
6
What represents an exact error of
=∫ ( ) + ∫ ( ) +⋯+∫ ( ) +
−
( ∑ −1
)0+ 4 =1,3,5 ( + )2 ∑
=2,4,6
-2
( )+ ( )
=( − )
3
An estimated error in the multiple application Simpson's rule is obtained in the same way.
that in the trapezoidal rule: by summing the individual errors of the segments and taking out the
average of the derivative to reach
( − ) 5 ̅̅̅̅̅
= − (4)
180 4
where (4) It is the average of the fourth derivative in the interval.
( )= . ; ( .) = . ;( ). = . (; ) . = . ; ( . )= .
(
0.2 + 4 1.288 + 3.464 +) 2 2.456+
( )
0.232
= 0.8 = 1,623467
12
What represents an exact error of
=∫ ( ) =∫ ( )
To obtain ≅ [( ) + ( )+ ( +) ( ])
where h = (b–a)/3. This equation is called the Simpson's 3/8 rule because h is multiplied
for 3/8. This is the third closed integration formula of Newton-Cotes. The 3/8 rule is
express also in the form of the equation
( )0+ 3 ( 1+) 3 ( 2+ ) 3( )
=( − )
8
WIDTH AVERAGE WEIGHT
Thus the two interior points have weights of three eighths, while the extreme points
they have a weight of one eighth. The Simpson 3/8 rule has an error of
3 5 4(
= −ℎ )
80
Oh, how h = (b-a) / 3,
( − )5 4(
= − )
6480 4
Typically, the Simpson's rule is preferred.
1/3, since it reaches a third accuracy
order with three points instead of four
points required in version 3/8. No
however, the 3/8 rule is useful when the
the number of segments is odd.
EXAMPLE Simpson's Rule 3/8
Use it together with Simpson's 1/3 rule in order to integrate the same function in five.
segments.
Solution.
( 0=
) 0.2 ; (0.2667) = 1.432724
( 0.5333=) 3.487177 ; ( 0.8 ) = 0.232
0.2 + 3 (1.432724 +3.487177 + )00.232
= 0.8 = 1,519170
8
= 1.640533− 1.519170 = 0.1213630 7.4%
(0.8) 5
The estimated error is =− ( -2400= )0.01213630
6480
b) the necessary data for an application with five segments (h=0.16) are
Numerical integration formulas have been based on equally spaced data. In the
in practice, there are many situations where this assumption is not satisfied and there are
segments of unequal sizes. Numerical integration formulas have been based on
equally spaced data. In practice, there are many situations where this
the assumption is not satisfied and segments of unequal sizes are present. One method consists of
apply the trapezoidal rule to each segment and sum the results:
Hasta aquí, todas las fórmulas de integración numérica se han basado en datos igualmente
spaced. In practice, there are many situations where this assumption is not satisfied.
and segments of unequal sizes are obtained. For example, the data obtained
experimentally are often of this type. In such cases, one method consists of applying the
trapezoidal rule for each segment and sum the results:
( )0+ ( 1) ( )1+ ( 2) ( −1)+ ( )
= ℎ1 + ℎ2 +⋯+ℎ
2 2 2
Where h1, h2, h3, hn = the width of segments 1, 2, 3, n respectively. Note that this was the
same procedure that was used in the multiple application trapezoidal rule. The only
The difference between these equations is that the h in the first one are constants. In some
Adjacent segments are of the same width and, consequently, could be evaluated.
through Simpson's rules. This usually leads to more accurate results.
When the length of the subintervals is not equal, a combination of the rule is used.
Trapezoidal and Simpson's rules, aiming to follow the following hierarchical order: When the
the length of the subintervals is not equal, a combination of the Trapezoidal rule and the
Simpson's rules, trying to follow the following hierarchical order:
Problem statement. Recalculate the integral for the data in table 21.3, but
Now use Simpson's rules in those segments where appropriate.
MULTIPLE INTEGRALS
∫ (∫ ( ,) )
̅ =
( − )( − )
The numerator is called double integral.
∫(∫ (, ) ) = ∫( ∫ ,( ) )
First, the integral is evaluated in one of the dimensions and the result of this first
integration is incorporated in the second dimension. The equation states that it does not matter the
order of integration. A double numerical integral will be based on the same idea. First, it
they apply methods, such as Simpson's rule or the trapezoidal rule for multiple segments, to the
first dimension keeping the values of the second dimension constant. Then, it
apply the method to integrate the second dimension. The procedure is illustrated in the example
next
Use of the double integral to determine an average temperature.
( , ) = 2xy + 2x – 2-2y2+ 72
If the plate is 8 m long (dimension x) and 6 m wide (dimension y), calculate the
average temperature.
Solution.
First, the trapezoidal rule will be used with two segments in each dimension. The temperatures
in the necessary x and y values.
Note that a simple average of these values is 47.33. The function is also evaluated
analytically, whose result would be 58.66667.
To numerically perform the same evaluation, the trapezoidal rule is first used to
length of dimension x with each of the values of y.
These values are integrated throughout the dimension to result in a final total of 2,688.
We can also use Simpson's 1/3 rule in the same way with a single segment.
This integral results in 2,816 and an average of 58.66667, which is exact.
Why does this happen? Remember that Simpson's 1/3 rule gave perfect results with
cubic polynomials. Since the term of the highest degree in the function is of second degree, in the
In this case, the exact same result is obtained. For algebraic functions of degree
superior, as well as with transcendent functions, it will be necessary to employ multiple segments
to obtain exact estimates of the integral.