SME
Numerical Methods for Engineers
Numerical integration
Use this for “Estimate the integral of x³ from 0 to 2 with n = 4 by the trapezoid and Simpson’s rules, and find the trapezoid error.”
Chart
Trapezoid rule, n = 4, h = 0.5 from x = 0 to 2: T = 4.25
This is an example. Type your own values to start a new problem.
∫
k
x
dx
≈
T
n
Panels
example
h
Panel width
worked out (not typed)
S
Simpson estimate
worked out (not typed)
I
Exact integral
worked out (not typed)
εT
Trapezoid error
worked out (not typed) · %
Formulas
h
=
b
−
a
n
0.5
=
2 − 0
4
T
=
(
h
2
)
×
(f₀
+
2f₁
+
…
+
2fₙ₋₁
+
fₙ),
fᵢ
=
k
(
a
+ hi)
p
,
i
=
0
to
n
4.25
=
(
0.5
2
)
×
(f₀
+
2f₁
+
…
+
2fₙ₋₁
+
fₙ),
fᵢ
=
1
(0 + 0.5i)
3
,
i
=
0
to
4
S
=
(
h
3
)
×
(f₀
+
4f₁
+
2f₂
+
…
+
4fₙ₋₁
+
fₙ),
fᵢ
=
k
(
a
+ hi)
p
,
i
=
0
to
n
4
=
(
0.5
3
)
×
(f₀
+
4f₁
+
2f₂
+
…
+
4fₙ₋₁
+
fₙ),
fᵢ
=
1
(0 + 0.5i)
3
,
i
=
0
to
4
I
=
k
×
b
p
+ 1
−
a
p
+ 1
p
+ 1
4
=
1
×
2
3 + 1
−
0
3 + 1
3 + 1
εT
=
|
T
−
I
|
÷
|
I
|
×
100
6.25 = |4.25 − 4| ÷ |4| × 100
Assumptions
•
f(x) = kxᵖ on [a, b], cut into n equal panels of width h; Simpson’s rule needs n even.
•
The trapezoid rule joins the nodes with straight lines: too big where the curve bends up.
•
Simpson’s rule fits a parabola over each pair of panels, so it is exact for cubics.
•
The error compares T with the exact integral, as a percent of it.
Step-by-step
WE KNOW
k = 1, p = 3, a = 0, b = 2, n = 4
FIND
panel width (h), trapezoid estimate (T), Simpson estimate (S), exact integral (I), trapezoid error (εT)
Step 1 · Find panel width (h)
Use h = (b − a) ÷ n
Cut
the
interval
from
a
to
b
into
n
panels
of
equal
width.
h
=
2 − 0
4
h
=
0.5
Step 2 · Find trapezoid estimate (T)
Use T = (h ÷ 2) × (f₀ + 2f₁ + … + 2fₙ₋₁ + fₙ), fᵢ = k(a + hi)ᵖ, i = 0 to n
Work
out
f
=
kxᵖ
at
the
5
nodes;
the
ends
count
once,
the
inner
nodes
twice,
all
times
h
2
.
T
=
(
h
2
)
×
(0
+
2
×
0.125
+
2
×
1
+
2
×
3.375
+
8)
T
=
(
0.5
2
)
×
(0
+
2
×
0.125
+
2
×
1
+
2
×
3.375
+
8)
Nodes x = 0, 0.5, 1, 1.5, 2: f = 0, 0.125, 1, 3.375, 8
T
=
0.5
2
×
17
T
=
4.25
Step 3 · Find Simpson estimate (S)
Use S = (h ÷ 3) × (f₀ + 4f₁ + 2f₂ + … + 4fₙ₋₁ + fₙ), fᵢ = k(a + hi)ᵖ, i = 0 to n
The
same
heights:
the
ends
once,
odd
nodes
times
4,
even
inner
nodes
times
2,
all
times
h
3
.
S
=
(
h
3
)
×
(0
+
4
×
0.125
+
2
×
1
+
4
×
3.375
+
8)
S
=
(
0.5
3
)
×
(0
+
4
×
0.125
+
2
×
1
+
4
×
3.375
+
8)
S
=
0.5
3
×
24
S
=
4
Step 4 · Find exact integral (I)
Use I = k × (bᵖ⁺¹ − aᵖ⁺¹) ÷ (p + 1)
The power rule for integrals gives the exact value to compare with.
I
=
1
×
2
3 + 1
−
0
3 + 1
3 + 1
I
=
2
4
−
0
4
3 + 1
I
=
16
4
I
=
4
Step 5 · Find trapezoid error (εT)
Use εT = |T − I| ÷ |I| × 100
The gap between the trapezoid estimate and the exact value, as a percent of the exact value.
εT = |4.25 − 4| ÷ |4| × 100
εT = |0.25| ÷ |4| × 100
εT
=
0.25
4
×
100
εT = 0.0625 × 100
εT = 6.25%
Check
Put the numbers back in. Both sides should match.
0.5
=
2 − 0
4
✓
4.25
=
(
0.5
2
)
×
(f₀
+
2f₁
+
…
+
2fₙ₋₁
+
fₙ),
fᵢ
=
1
(0 + 0.5i)
3
,
i
=
0
to
4
✓
4
=
(
0.5
3
)
×
(f₀
+
4f₁
+
2f₂
+
…
+
4fₙ₋₁
+
fₙ),
fᵢ
=
1
(0 + 0.5i)
3
,
i
=
0
to
4
✓
4
=
1
×
2
3 + 1
−
0
3 + 1
3 + 1
✓
6.25 = |4.25 − 4| ÷ |4| × 100 ✓
Topic check
See what you know: 5 questions on this topic
New questions each time. Pass to mark it complete.
More problem types
Integrating tabulated data
Use this for “A car’s speed, read every 10 s, is 4, 12, 20 and 24 m/s. Estimate the distance it covers with the trapezoid rule.”
Error of the trapezoid rule
Use this for “Estimate the trapezoid rule’s error for x³ from 0 to 2 with 4 panels, taking the average f″ as 6.”
Two-point Gauss quadrature
Use this for “Estimate the integral of x³ from 0 to 2 with two-point Gauss quadrature and compare it with the exact value.”