Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

NUMERICAL INTEGRATION: Trapezoidal rule

Numerical integration simply means the numerical evaluation of


𝒃
integrals 𝑰 = ∫𝒂 𝒇(𝒙)𝒅𝒙
Where a and b are given and f(x) is a function given analytically
by a formula or empirically by a table of values. We can represent
geometrically, I as the area under the curve of f(x) between a and
b as shown

Fig 1. Graphical depiction of the trapezoidal rule.

Geometrically, the trapezoidal rule is equivalent to approximating


the area of the trapezoid under the straight line connecting f (a)
and f (b) in fig 1. Recall from geometry that the formula for
computing the area of a trapezoid is the height times the average
of the bases (Fig2a). In our case, the concept is the same but the
trapezoid is on its side (Fig.2b). Therefore, the integral estimate can
be represented as
I ∼= width × average height
(a) The formula for computing the area of a trapezoid: height times
the average of the bases.
(b) For the trapezoidal rule, the concept is the same but the
trapezoid is on its side

or
I ∼= (b − a) × average height
where, for the trapezoidal rule, the average height is the average
of the function values at
the end points, or [ f (a) + f (b)]/2.
Generally;
Trapezoidal rule is given as
𝒙𝟎 +𝒏𝒉
𝒉
𝑰=∫ 𝒇(𝒙)𝒅𝒙 = [(𝒚𝟎 + 𝒚𝒏 ) + 𝟐(𝒚𝟏 + 𝒚𝟐 + ⋯ + 𝒚𝒏−𝟏 )]
𝒙𝟎 𝟐

𝒃
RULES FOR EVALUATING ∫𝒂 𝒇(𝒙)𝒅𝒙 USING
TRAPEZOIDAL RULE OR SIMPSON’S RULE
𝒃
1. Compare the given definite integral, say I, with ∫𝒂 𝒇(𝒙)𝒅𝒙 to
get the values of f(x) and limits a, b,
𝒃−𝒂
2. Compute h= , where n denotes the number of sub-intervals
𝒏
for the problem.
3. Find the values of y=f(x), corresponding to 𝒙𝟎 = 𝒂, 𝒙𝟏 = 𝒂 +
𝒉, 𝒙𝟐 = 𝒙𝟎 + 𝟐𝒉, … . , 𝒙𝒏 = 𝒙𝟎 + 𝒏𝒉 =
𝒃 𝒂𝒏𝒅 𝒅𝒆𝒏𝒐𝒕𝒆 𝒕𝒉𝒆𝒔𝒆 𝒗𝒂𝒍𝒖𝒆𝒔 𝒂𝒔 𝒚𝟎 , 𝒚𝟏 , 𝒚𝟐 , … . . , 𝒚𝒏. .
4. Apply the specified rule to calculate I (either Trapezoidal rule
or Simpson’s rule).
By trapezoidal rule, we have

𝒙𝟎 +𝒏𝒉
𝒉
𝑰=∫ 𝒇(𝒙)𝒅𝒙 = [(𝒚𝟎 + 𝒚𝒏 ) + 𝟐(𝒚𝟏 + 𝒚𝟐 + ⋯ + 𝒚𝒏−𝟏 )]
𝒙𝟎 𝟐

𝟏
Example: Use Trapezoidal Rule to evaluate ∫𝟎 𝒙𝟑 𝒅𝒙 considering 5
subintervals.

𝟏
Sol. Let 𝑰 = ∫𝟎 𝒙𝟑 𝒅𝒙.

h=0.2, f(x) = 𝒙𝟑

Trapezoidal rule is given by


𝒉
𝑰 = [(𝒚𝟎 + 𝒚𝒏 ) + 𝟐(𝒚𝟏 + 𝒚𝟐 + ⋯ + 𝒚𝒏−𝟏 )]
𝟐

Putting the values in the above equation, we have

𝟏
𝑰 = ∫ 𝒙𝟑 𝒅𝒙
𝟎
𝟎. 𝟐
= [(𝟎 + 𝟏) + 𝟐(𝟎. 𝟎𝟎𝟖 + 𝟎. 𝟎𝟔𝟒 + 𝟎. 𝟐𝟏𝟔
𝟐
+ 𝟎. 𝟓𝟏𝟐)]

x 0 0.2 0.4 0.6 0.8 1.0


y=f(x) 𝒚𝟎 𝒚𝟏 =0.008 𝒚𝟐 =0.064 𝒚𝟑 =0.216 𝒚𝟒 =0.512 𝒚𝟓 =1
=𝟎
=0.26

NUMERICAL INTEGRATION: Simpson’s rule


Another way to obtain a more accurate estimate of an integral is to
use higher-order polynomials to connect the points. For example,
if there is an extra point midway between f (a) and f (b), the three
points can be connected with a parabola (Fig. 3a). If there are two
points equally spaced between f (a) and f (b), the four points can be
connected with a third-order polynomial (Fig.3b). The formulas
that result from taking the integrals under these 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.
𝟏
For Simpson’s rule, the following formula applies;
𝟑
𝒙𝟎 +𝒏𝒉
∫ 𝒇(𝒙)𝒅𝒙
𝒙𝟎
𝒉
= [(𝒚𝟎 + 𝒚𝒏 ) + 𝟒(𝒚𝟏 + 𝒚𝟑 + ⋯ + 𝒚𝒏−𝟏 ) + 𝟐(𝒚𝟐 + 𝒚𝟒
𝟑
+ ⋯ + 𝒚𝒏−𝟐 )]

𝟏 𝒅𝒙 𝟏
Example: Evaluate ∫𝟎
𝟏+𝒙 𝟐 dx using Simpson’s
𝟑
rule taking h=0.25
𝟏
𝒅𝒙 𝒉
𝑰=∫ = [(𝒚𝟎 + 𝒚𝟒 ) + 𝟒(𝒚𝟏 + 𝒚𝟐 ) + 𝟐𝒚𝟐 ]
𝟎 𝟏 + 𝒙𝟐 𝟑
𝟏
f(x) = , h=0.25
𝟏+𝒙𝟐

x 0 0.25 0.50 0.75 1.00


y =f(x) 𝒚𝒐 =1 𝒚𝟏 =0.9412 𝒚𝟐 =0.8 𝒚𝟑 =0.64 𝒚𝟒 =0.5

𝟏 𝒅𝒙 𝟎.𝟐𝟓
𝑰 = ∫𝟎 = [(𝟏 + 𝟎. 𝟓) + 𝟒(𝟎. 𝟗𝟒𝟏𝟐 + 𝟎. 𝟔𝟒) + 𝟐 × 𝟎. 𝟖]
𝟏+𝒙𝟐 𝟑

= 0.7854

CLASSWORK
1. Given that
x 4.0 4.2 4.4 4.6 4.8 5.0 5.2
lo 1.3863 1.4351 1.4816 1.5261 1.5686 1.6094 1.6487
gx

𝟓.𝟐
Evaluate ∫𝟒 𝒍𝒐𝒈 𝒙 𝒅𝒙 by (i) Trapezoidal Rule (ii) Simpson’s
𝟏
Rule ANSWERS: (i) 1.82766 (ii)1.82785
𝟑

𝟒
2. Evaluate ∫𝟎 𝒆𝒙 𝒃𝒚 𝑺𝒊𝒎𝒑𝒔𝒐𝒏′ 𝒔𝑹𝒖𝒍𝒆 𝒈𝒊𝒗𝒆𝒏 𝒕𝒉𝒂𝒕 𝒆 =
𝟐. 𝟕𝟐, 𝒆𝟐 = 𝟕. 𝟑𝟗, 𝒆𝟑 = 𝟐𝟎. 𝟎𝟗, 𝒆𝟒 = 𝟓𝟒. 𝟔
ANSWER:53.87
3. A curve is drawn to pass through the points given by the
following table:
x 1 1.5 2 2.5 3.0 3.5 4.0
y 2 2.4 2.7 2.8 3 2.6 2.1
Estimate the area bounded by the curve, x-axis and the line x=1
and x=4.

ANSWER : Area= 7.78 square units

4. The following table gives the velocity v of a particle at time t:


t(seconds) 0 2 4 6 8 10 12
v(m/sec) 4 6 16 34 60 94 136
Find the distance moved by the particle in 12 secs.
ANSWER: S= 552 m.
𝝅⁄
5. calculate ∫𝟎 𝟐 𝒆𝒔𝒊𝒏𝒙 𝒅𝒙 correct to four decimal places by
Trapezoidal rule

You might also like