Module 7
Module 7
Lesson Rationale:
Finding the exact value of a definite integral analytically is either extremely
difficult or impossible due to the complexity of the function involved. Numerical
methods provide a practical alternative for approximating these integrals. This
module introduces students to three widely used numerical integration techniques:
the Trapezoidal Rule, Simpson's Rule, and Romberg's Method. These methods form
a vital part of an engineer's computational toolkit, particularly in modeling,
simulation, and data analysis.
Lesson Outcomes:
By the end of this module, students should be able to:
1. Describe the fundamental principles behind numerical integration
techniques: Trapezoidal Rule, Simpson’s Rule, and Romberg’s Method;
2. Implement the Trapezoidal Rule and Simpson’s Rule in Excel to approximate
definite integrals;
3. Interpret the effect of step size (h) and subdivision (n) on the accuracy of
the integral approximation; and,
4. Formulate and present results clearly using Excel, reinforcing the use of
software tools for technical communication.
Lesson Contents:
91 | P a g e
Integral Calculus has countless applications in many engineering fields. A
common problem from Integral Calculus is how to find the value of the definite
integral,
b
I ( f )=∫ f ( x ) dx
a
∫ f ( x ) dx ≈∫ f 1 ( x ) dx
a a
92 | P a g e
Using Newton’s divided difference polynomial in manual computation, we have
f ( b )−f ( a )
f 1 ( x )=f ( a ) + (x −a)
b−a
Thus,
b b
∫ f ( x ) dx ≈∫ f 1 ( x ) dx
a a
[ ]
b
f ( b )−f ( a )
¿∫ f ( a) + ( x −a) dx
a b−a
[ )]
b
¿ f ( a ) x+
f ( b )−f ( a ) x2
b−a 2 (
−ax
a
b−a )( 2
¿ f ( a ) b−f ( a ) a+ ( −ab− + a )
f ( b )−f ( a ) b a
2 2
2
2
b−a )( 2
¿ f ( a ) b−f ( a ) a+ ( −ab− + a )
f ( b )−f ( a ) b a
2 2
2
2
b−a )( 2
¿ f ( a ) b−f ( a ) a+ ( −ab− )
f ( b )−f ( a ) b a
2 2
2
1 1 1 1
¿ f ( a ) b−f ( a ) a+ f ( b ) b− f ( b ) a− f ( a ) b+ f ( a ) a
2 2 2 2
1 1 1 1
¿ f ( a ) b− f ( a ) a+ f ( b ) b− f ( b ) a
2 2 2 2
¿(b−a) [ f ( a ) +f (b)
2 ]
[ {∑ } ]
n−1
h
¿ f ( a ) +2 f (a+ih) + f (b)
2n i=1
93 | P a g e
Step 2) Input the limits of the integral and the number of divisions n in the
selected cell.
Step 3) The value of h can be found using the formula,
b−a
¿
n
Step 4) input the formula of x i. This indicates that the value of a=x o.
Step 7) at the next iteration, we need to enter a condition that if x i is greater than
or equal to b, the value of x i+1 will be equal to b. Otherwise, it will be equal to the
¿ IF (E 2≥$ B $ 2 , $ B $ 2 , E 2+ $ D $ 2)
This formula will ensure that h is added to the previous value until the value of b is
reached. Later on, it will keep entering the value of b. This is done to enable the
changing value of n to make the solution more accurate.
Step 8) Enter the formula in cell for the approximate value of I (integral). This is
based on the general formula. Thus, the formula is,
E 3−E 2
¿
2∗( F 2+ F 3)
Notice that instead using h from cell D2, we used E3-E2. This is an advantage since
the formula outputs zeros when we go beyond the right end point b. Thus, the sum
of the numbers will not be affected by the repetition of b. Also, it allows the use of
this method to non-uniform divisions in the interval [ a , b ].
Step 9) In cell H3, we will input 1 so that we can monitor if how many divisions are
we going to have based on n.
Step 10) Drag down, cell H3 (fill series) until the value of a cell in column H is
equal to n.
Step 11) Drag down the values in cells E3-G3 up to the line where the value in
column H is equal to n.
Step 12) Lastly, we can use the summation function to sum up the values in
column G. This will now be the approximate value of the integral.
94 | P a g e
Types of Cell References when using dollar sign:
TAKE NOTE:
1. Relative Reference – Example: A1
o When you copy or drag the formula, both row and column
adjust relative to the new position.
o Useful when you want to apply the same formula pattern
across rows/columns.
2. Absolute Reference – Example: $A$1
o The column and row stay fixed, no matter where you copy
the formula.
o Useful when you always want to refer to a specific cell (like
a constant or value in one place).
3. Mixed Reference
o $A1: Column A is fixed, row changes when copied.
o A$1: Row 1 is fixed, column changes when copied.
Sample Problem #1
Solution:
a) Two-segmented trapezoidal rule (n=2),
b−a 10−0
h= = =5
2 2
300 (5) 300 ( 10 )
f ( 0 )=0 ; f ( 5 )= 5
=10.039; f ( 10 )= 10
=0.136
1+e 1+ e
[ {∑ } ]
n−1
h
I≈ f ( a )+ 2 f (a+ih) + f (b)
2 i=1
95 | P a g e
[ {∑ } ]
n−1
b−a
I≈ f ( a )+ 2 f (a+ih) + f (b)
2n i=1
[ {∑ } ]
2−1
10−0
I≈ f ( 0 ) +2 f (0+ 5) + f (10)
2(2) i=1
10
I≈
4
[ f ( 0 ) +2 f (5)+ f (10)]
10
I≈ [ 0+ 2(10.039)+ 0.136 ]
4
I ≈ 50.537
For the absolute relative error, we need first to solve for the exact value of
the integral (calcu tech).
10
∫
0
( 300
1+e )
x
dx=246.59
x
|Ɛt|= |246.59−50.537
246.59 |x 100=7 9.506 %
This is a bit huge error. Thus, we need more subintervals to make the
approximation more accurate.
2. Input the limits of the integral in cells A2 and B2 and the number of divisions’ n
in cell C2.
4. In cell E2, enter the formula =A2. This indicates that the value of a=x o in E2.
96 | P a g e
5. Enter the formula in cell F2, based on the function f(x). That is,
the value of x i+1 will be equal to b. Otherwise, it will be equal to the sum of x i
and h.
Thus, the formula in cell E3 will be,
8. Enter the formula in cell G3 for the approximate value of I (integral). This is
based on the general formula. Thus, for G3, the formula is,
Notice that instead using h from cell D2, we used E3-E2. This is an advantage
since the formula outputs zeros when we go beyond the right end point b. Thus,
the sum of the numbers will not be affected by the repetition of b. Also, it allows
the use of this method to non-uniform divisions in the interval [ a , b ].
9. In cell H3, we will input 1 so that we can monitor if how many divisions are we
going to have based on n.
10. Drag down, cell H3 (fill series) until the value of a cell in column H is equal to n.
11. Drag down the values in cells E3-G3 up to the line where the value in column H
is equal to n.
12. Lastly, we can use the summation function to sum up the values in column G.
This will now be the approximate value of the integral.
97 | P a g e
Figure 12.3.a. The upper part of the solution using the Trapezoidal rule in the
spreadsheet application
Figure 12.3.b. Lower part of the solution using the Trapezoidal rule in spreadsheet
application
Based on figure 12.3.b. the sum of all the terms column G is equal to I=26.4694.
This will be the approximate value of the integral.
|Ɛt|=|246.59−246.4652
246.59 |x 100=0.0101 %
Therefore, the error is less than 1%.
98 | P a g e
LABORATORY ACTIVITY #16: (25 points)
Note: Upload it on your Google Drive and send the link to your instructor for
checking. Paste your answers on A4 size bondpaper, with complete name,
year and section, and date of submission on the upper right corner of the
paper.
99 | P a g e
TOPIC 2: SIMPSONS RULE
b−a
interval into n equal subintervals, each having a width of h= . Then, the
n
formula for this method is given by,
n
h
I≈ ∑ f ( x ) +4 f ( x i ) +f ( xi +1)]
3 i=1 [ i−1
We will derive Simpson’s rule (1/3 rule) using the Newton’s divided
difference polynomial using the second order polynomial. That is,
b=
( 2 )
a+ b
f −f (a)
1
a+b
−a
2
b 2=
( f ( b )−f
b−
a+ b
2
( a+b2 )− f ( a+b2 )−f ( a)
b−a
a+b
2
−a )
We will integrate the Newton’s difference polynomial. Thus,
b b
∫ f ( x ) dx ≈∫ f 2 ( x ) dx
a a
100 | P a g e
[ )]
b
¿ ∫ b 0 +b1 ( x−a ) + b2 ( x−a ) x−
a
( a+ b
2
dx
[ )]
b
( ) (
2 3 2
x x ( 3 a+ b ) x a ( a+b ) x
¿ b 0 x +b 1 −ax + b2 − +
2 3 4 2 a
( ) (
b 3−a 3 ( 3 a+ b ) ( b −a ) a (a+ b)(b−a)
)
2 2
b2−a2
¿ b 0 ( b−a )+ b1 −a ( b−a ) +b 2 − +
2 3 4 2
[ ( a+b2 )+ f (b)]
b
∫ f ( x ) dx ≈ b−a
6
f ( a) + 4 f
a
101 | P a g e
Step 11) Drag down the values in cells E3 - F3 up to the line where the value in
column H is equal to n.
Step 12) Notice that Simpson’s rule spans two subintervals in every entry in the
summation. Thus, we need to select the range of two cells G2 and G3 and drag
down up to the line where the value in column H is equal to n.
Step 13) Lastly, we can use the summation function to sum up the values in
column G. This will now be the approximate value of the integral.
Sample Problem #1
Solution:
a) Two-segmented trapezoidal rule (n=2) in manual computation,
x=
b−a
6 [
f ( a )+ 4 f
a+b
2 ( )
+ f (b)
]
a +b 0+10
a=0 ; b=10 ; = =5
2 2
300 x
f (x)= x
1+ e
300 ( 5 )
f (0)=0 ; f ( 5 )= 5
=10.039
1+ e
300 ( 10 )
f ( 10 )= 10
=0.136
1+e
x=
b−a
6 [
f ( a )+ 4 f
a+b
2 ( )
+ f (b)
]
10−0
x=
6
[ f ( 0 )+ 4 f (5 )+ f (10) ]
102 | P a g e
10
x= [ 0+ 4 (10.039)+ 0.136 ]
6
x=67.1533
For the absolute relative error, we need first to solve for the exact value of
the integral (calcu tech).
10
∫
0
( 300
1+e )
x
x
dx=246.59
|Ɛt|=|246.59−67.1533
246.59 |x 100=7 2.767 %
This is a bit huge error. Thus, we need more subintervals to make the
approximation more accurate.
Step 2) Input the limits of the integral in cells A2 and B2 and the number of
divisions n in cell C2.
Step 3) The value of h in cell D3 can be found using the formula, = (𝐵3 – 𝐴3)/𝐶3
Step 4) In cell E3, enter the formula =A3. This indicates that the value of 𝑎 = 𝑥0 in
E3.
Step 5) Enter the formula in cell F3, based on the function f(x).
103 | P a g e
Step 6) Drag down cell the contents of cell F3 to cell F4.
Step 7) In cell E4, we need to enter a condition that if 𝑥𝑖 is greater than or equal to
b, the value of 𝑥𝑖+1 will be equal to b. Otherwise, it will be equal to the sum of 𝑥𝑖
and h. Thus, the formula in cell E4 will be, = (𝐸3 >= $𝐵$3, $𝐵$3,2 + $𝐷$3)
This formula will ensure that h is added to the previous value until the value of b is
reached. Later on, it will keep entering the value of b. This is done to enable the
changing value of n to make the solution more accurate.
Step 8) Enter the formula in cell G4 for the approximate value of I (the integral).
This is based on the general formula. Thus, for G4, the formula is,
=(E5-E3)/6*(F3+4*F4+F5)
Step 9) In cell H4, we will input 1 so that we can monitor how many divisions we
are going to have based on n.
Step 10) Drag down, cell H4 (fill series) until the value of a cell in column H is
equal to n.
104 | P a g e
Step 11) Drag down the values in cells E4 – F4 up to the line where the value in
column H is equal to n.
Step 12) Notice that Simpson’s rule spans two subintervals in every entry in the
summation. Thus, we need to select the range of two cells G3 and G4 and drag
down up to the line where the value in column H is equal to n.
Step 13) Lastly, we can use the summation function to sum up the values in
column G. This will now be the approximate value of the integral.
105 | P a g e
Based on the result of the excel application, the sum of all the terms in
column G is equal to 246.59029. This will be the approximate value of the integral
in sci-cal is 246.5903. Therefore, when compared to manual calculation, it is easier
to solve for the approximate value of the integral in excel/spreadsheet application.
106 |for
Note: Upload it on your Google Drive and send the link to your instructor Page
checking. Paste your answers on A4 size bondpaper, with complete name, year
and section, and date of submission on the upper right corner of the paper.
TOPIC 3: ROMBERG’S RULE
Is given by
1 2
E ≈− ( b−a ) h f ' '
2
If I 1 (h1) is the approximate value of the integral from trapezoidal rule, and
E1 (h1) is the truncation error with a step side h1 we can write the following
2
I ≈ I 1 ( h1 ) + E1 ( h1 ) ≈ I 1 ( h1 ) +c h1 eq.1
where,
1
c ≈− ( b−a ) f ' ' is a constant
2
Similarly if we take another step h2 we can write:
2
I ≈ I 2 ( h2 ) + E2 ( h2 ) ≈ I 2 ( h2 ) + c h2 eq.2
Substituting eq.3 into eq.2 we obtain an improved estimate of the integral as:
I 2 ( h2 )−I 1 ( h1 ) eq.4
I ≈ I 2 ( h2 ) +
{( ) }
2
h1
−1
h2
h1
For the special case where the interval is halved, h2 =
2
eq.5
108 | P a g e
I 2 ( h2 )−I 1 ( h1 ) 4 1
I ≈ I 2 ( h2 ) + = I 2 ( h 2 ) − I 1 ( h1 )
3 3 3
Romberg Integration
produce an error of order O(h 6), and so on. The general formulation of this
procedure on the trapezoidal rule is known as the Romberg Integration.
n
with n and segments.
2
Then the improved value of the integral given by Richardson’s extrapolation
is
1
4 I 0 , n−I n
0,
2
I 1 ,n=
4 1−1
If the extrapolation is applied the second time,
2
4 I 1 ,n −I n
1,
2
I 2 ,n=
4 2−1
When the extrapolation process is repeated k times, we can generalize the
formula as:
k
4 I k−1, n−I n
k−1 ,
2
I k ,n=
4 k −1
By applying a proper number of Richardson’s extrapolations, any desired
accuracy may be obtained
|I k ,n −I k−1 , n| ≤ ε
109 | P a g e
1. To approximate the integral we use the results of the Composite
Trapezoidal Rule with n=1,2,4,8,16……., and denote the resulting
approximations, respectively by I 1 ,1, I 2 ,1, I 3 ,1, etc.
1
I k ,2=I k ,1 + (I k ,1−I k−1 ,1 ), for k=2,3……
3
O(h ) approximations I 3 ,3, I 4 ,3 , I 5 ,3, etc, by
6
1
I k ,3=I k , 2+ (I −I ), for k=3,4……
15 k ,2 k−1 ,2
where, k= order of interpolation
(i.e. k=1, values of regular trapezoidal rule
k=2, values using error estimate O(h 2),
n= more/less accurate estimate integral
(i.e. value of integral with index n+1 is more accurate than that with index
n)
Sample Problem #1
( [ ] )
30
140000
x=∫ 2000 ln −9.8 t ¿ ¿ dt
8 140000−2100 t
Use Romberg’s Rule to find the distance covered. Use the 1, 2, 4, 8 segment
trapezoidal rule results.
Solution:
I 1 ,1: first trapezoidal approximation with 1 interval.
h
For I 1 ,1= ( f ( a) + f ( b) )
2
h=b−a=30−8=22
f ( a )=f ( 8 )=2000 ln
[ 140000
140000−2100(8) ]
=−9.8(8)¿=177.266743 ¿
f ( b )=f ( 30 )=2000 ln
[ 140000
140000−2100(30) ]
−9.8(30)¿=901.6740015 ¿
22
I 1 ,1= ( 177.266743+901.6740015 )=11868.34819
2
I 1 ,2: improved estimate from I 1 ,1 and I 2 ,1.
110 | P a g e
I 1 ,2 is the 1st trapezoidal estimate (with big step size).
I 2 ,1 is the trapezoidal estimate after having h once.
30+ 8
New point: h= =19
2
f ( h )=f ( 19 )=2000 ln
[ 140000
140000−2100 (19)]−9.8(19)¿=484.7454726 ¿
h
I 2 ,1= ( f ( 8 ) +2 f ( 19 ) + f ( 30 ) )
2
11
I 2 ,1= ( 177.266743+ 2 ( 484.7454726 ) +901.6740015 )=11266.37429
2
I 2 ,1−I 1 ,1 11266.37429−11868.34819
I 1 ,2=I 2 ,1 + 1
=11266.37429+ =11065.7163
4 −1 3
2000 ln
[ 140000
140000−2100 (13.5) ]
−9.8(13.5)¿=320.2468886 ¿
f ( 24.5 )=
2000 ln
[ 140000
140000−2100 (24.5) ]
−9.8(24.5)¿=676.0501168¿
h
I 3 ,1= ¿
2
5.5
I 3 ,1= ¿
2
I 3 ,1=11112.8209
For I 2 ,2:
111 | P a g e
I 3 ,1 −I 2 , 1 11112.8209−11266.37429
I 2 ,2=I 3 ,1 + 1
=11112.8209+ =11061.63644
4 −1 3
For I 1 ,3:
I 2 ,2 −I 1 , 2 11061.63644−11065.71632
I 1 ,3=I 2 ,2 + 2
=11061.63644 + =11061.36412
4 −1 15
I 1 ,4 : we need to find I 4 ,1 then find I 3 ,2, then I 2 ,3 and finally use I 2 ,3 and I 1 ,3
For I 4 ,1 : h=5.5, new h=2.75
From 8 to 30, number of subintervals:
30−8
n= =8
2.75
Thus, there are 8 subintervals and 9 points:
8, 10.75, 13.5, 16.25, 19, 21.75, 24.5, 27.25, and 30.
Already known:
f ( 8 )=177.266743
f ( 19 )=484.7454726
f ( 30 )=901.6740015
f ( 13.5 )=320.2468886
f ( 24.5 )= 676.0501168
Need to compute:
f ( 10.75 )=
2000 ln
[ 140000
140000−2100 (10.75) ]
−9.8(10.75)¿=246.3351814 ¿
f ( 16.25 )=
2000 ln
[ 140000
140000−2100 (16.25) ]
−9.8(16.25)¿=399.5165393 ¿
f ( 21.75 )=
2000 ln
[ 140000
140000−2100 (21.75) ]
−9.8(21.75)¿=576.6423135¿
f ( 27.75 )=
2000 ln
[ 140000
140000−2100 (27.75) ]
−9.8(27.75)¿=783.9826784 ¿
For I 4 ,1 :
112 | P a g e
h
I 4 ,1 = ¿
2
2.75
I 4 ,1 = (177.266743+2 ( 246.3351814 ) +2 (320.2468886 ) +2(399.5165393)+2(484.7454726)+2( 57
2
I 4 ,1 =11074.2213
Compute I 3 ,2:
I 4 , 1−I 3 , 1 11074.2213−11112.8209
I 3 ,2=I 4 , 1+ 1
=11074.2213+ =11061.35477
4 −1 3
Compute I 2 ,3:
I 3 , 2−I 2 , 2 11061.35477−11061.63644
I 2 ,3=I 3 ,2 + 2
=11061.35477+ =11061.33599
4 −1 15
Compute I 1 ,4 :
I 2 ,3−I 1 ,3 11061.33599−11061.36412
I 1 ,4 =I 2 , 3+ 3
=11061.33599+ =11061.33554
4 −1 63
Step 2)
113 | P a g e
Step 3) Compute the value of h of I 1 ,1, I 2 ,1and I 1 ,2as first trapezoidal
approximation with 1 interval.
For I 1 ,1:
For I 2 ,1:
For I 1 ,2 :
For I 1 ,3:
For I 2 ,2:
Step 5) Find the I 1 ,4 to find I 4 ,1 then find I 3 ,2, then I 2 ,3 and finally use I 2 ,3 and I 1 ,3.
114 | P a g e
Thus, there are 8 subintervals and 9
points:
For I 4 ,1 :
For I 3 ,2:
For I 2 ,3:
For I 1 ,4 :
115 | P a g e
Step 6) Make a final triangular table of the results
Initially, at large step size (h = 22), the approximation was rough: 11868.35.
As the step size was halved (h = 11, 5.5, 2.75), the first-order results moved closer
to the actual value. Higher orders of Romberg’s extrapolation (2nd, 3rd, and 4th
order) rapidly improved the estimate. Final highly accurate value at 4th order of
11061.34.
Romberg's Rule using Excel showed a very fast convergence toward the true
integral value. As the step size decreased and higher-order corrections were
applied, the error became almost negligible by the 4th order, there was no visible
change in the significant digits. Excel App allowed a clear visualization of how
Richardson extrapolation works — you could see that even if the 1st order wasn't
very accurate at the start, successive corrections made the estimate much more
precise.
116 | P a g e
The final answer is stable and reliable at around 11061.34, confirming that
the method is effective for complicated integrals involving logarithmic functions
and linear terms.
Sample Problem #2
1
Obtain ∫ e−x dx using Romberg Rule with error to 4 th
order.
0
Note: Upload it on your Google Drive and send the link to your instructor for
checking. Paste your answers on A4 size bondpaper, with complete name, year
and section, and date of submission on the upper right corner of the paper.