Numerical Methods · Unit 6
Numerical Integration
Exam-focused notes for Numerical Integration (Numerical Methods, BIT203): what the TU syllabus asks and how it has actually been tested, with 8 solved past questions from this unit.
Numerical Integration in short
Some integrals have no simple antiderivative, and some functions are known only as tables. Numerical integration finds the area under a curve by adding the areas of simple shapes.
What this unit covers
- Trapezoidal rule and composite trapezoidal rule
- Simpson's 1/3 rule and composite Simpson's 1/3 rule
- Simpson's 3/8 rule and composite Simpson's 3/8 rule
- Double integration using Simpson's rules
- Applications of numerical integration
- Algorithm and program for numerical integration
Simpson's 1/3 rule and composite Simpson's 1/3 rule
2082 · 5 marks
Integrate $\int_{0}^{3} (2x^3 + 1) dx$ using Simpson's $\frac{1}{3}$ rule with $n=6$. [5]
Show solved answerHide answer
Simpson's 1/3 Rule: $\int_0^3 (2x^3 + 1),dx$ with $n = 6$
Given
- $f(x) = 2x^3 + 1$
- Limits: $a = 0$, $b = 3$
- Number of intervals: $n = 6$
Step 2: Step Size
$$h = \frac{b-a}{n} = \frac{3-0}{6} = 0.5$$
Step 3: Function Values
| $i$ | $x_i$ | $f(x_i) = 2x_i^3 + 1$ | Coeff | Product |
|---|---|---|---|---|
| 0 | 0.0 | $2(0)+1 = 1.000$ | 1 | 1.000 |
| 1 | 0.5 | $2(0.125)+1 = 1.250$ | 4 | 5.000 |
| 2 | 1.0 | $2(1)+1 = 3.000$ | 2 | 6.000 |
| 3 | 1.5 | $2(3.375)+1 = 7.750$ | 4 | 31.000 |
| 4 | 2.0 | $2(8)+1 = 17.000$ | 2 | 34.000 |
| 5 | 2.5 | $2(15.625)+1 = 32.250$ | 4 | 129.000 |
| 6 | 3.0 | $2(27)+1 = 55.000$ | 1 | 55.000 |
Step 4: Apply the Formula
$$\int_a^b f(x),dx \approx \frac{h}{3}\Big[f_0 + f_6 + 4(f_1+f_3+f_5) + 2(f_2+f_4)\Big]$$
Compute the grouped sums:
- End terms: $1.000 + 55.000 = 56.000$
- Odd terms: $4(1.250 + 7.750 + 32.250) = 4(41.250) = 165.000$
- Even terms: $2(3.000 + 17.000) = 2(20.000) = 40.000$
Total sum: $$S = 56.000 + 165.000 + 40.000 = 261.000$$
Step 5: Final Result
$$\int_0^3 (2x^3+1),dx \approx \frac{0.5}{3}(261) = \frac{261}{6} = 43.5$$
$$\boxed{\int_0^3 (2x^3+1),dx \approx 43.5}$$
Verification (Exact Value)
$$\int_0^3 (2x^3+1),dx = \left[\frac{x^4}{2} + x\right]_0^3 = \frac{81}{2} + 3 = 40.5 + 3 = 43.5$$
Simpson's 1/3 rule gives the exact answer because the integrand is a cubic polynomial (degree $\le 3$), for which the rule is exact.
Double integration using Simpson's rules
2080 · 5 marks
Solve the double integration using Simpson's 1/3 rule. $$\int_{2}^{2.6} \int_{4}^{4.4} \frac{dxdy}{xy}$$ [5]
Trapezoidal rule and composite trapezoidal rule
2080 · 5 marks
Why Numerical Integration is required? Compute the integral: $I=\int_{-1}^{1} e^x dx$ using composite trapezoidal rule for n = 4. [5]
2078 · 5 marks
Solve the following integral using trapezoidal rule form = 8, $l=\int_{2}^{4} (x^4 + 1)dx$. [5]
0 · 5 marks
Find following integral using composite trapezoidal rule using 2 segments (k=2) and 4 segments (k=4). $$\int_{2}^{8} (x+3)^2 dx$$ [5]
Algorithm and program for numerical integration
2079 · 10 marks
What do you mean by numerical integration? Write any one application of numerical integration. Write an algorithm and c program to implement multi-segment trapezoidal rule.[10]
Show solved answerHide answer
Numerical Integration: Multi-Segment Trapezoidal Rule
1. What is Numerical Integration? (2 marks)
Numerical Integration (also called numerical quadrature) is the process of computing the approximate value of a definite integral using numerical methods when:
- The integrand f(x) is too complex to integrate analytically, or
- The function is given only as a set of discrete data points (tabular data), or
- The antiderivative does not exist in closed form.
The general goal is to approximate:
$$I = \int_a^b f(x), dx$$
by replacing the integrand with a simpler approximating function (such as polynomials) and summing the areas of geometric shapes under the curve.
2. Application of Numerical Integration (1 mark)
Engineering Application: Computing the area under a velocity-time curve to find displacement, or calculating the work done by a variable force:
$$W = \int_{x_1}^{x_2} F(x), dx$$
where F(x) may be given only as experimental data points, making analytical integration impossible.
3. Multi-Segment Trapezoidal Rule (7 marks)
Concept
The interval [a, b] is divided into n equal sub-intervals (segments), each of width:
$$h = \frac{b - a}{n}$$
The nodes are: $x_0 = a,; x_1 = a+h,; x_2 = a+2h,; \ldots,; x_n = b$
Each sub-interval is approximated by a trapezoid. The formula is:
$$\boxed{I \approx \frac{h}{2}\left[f(x_0) + 2f(x_1) + 2f(x_2) + \cdots + 2f(x_{n-1}) + f(x_n)\right]}$$
Or equivalently:
$$I \approx \frac{h}{2}\left[f(x_0) + f(x_n) + 2\sum_{i=1}^{n-1} f(x_i)\right]$$
Algorithm
Algorithm: Multi-Segment Trapezoidal Rule
Input : a (lower limit), b (upper limit), n (number of segments)
Output: Approximate value of integral I
Step 1: START
Step 2: Read a, b, n
Step 3: Compute h = (b - a) / n
Step 4: Set sum = f(a) + f(b) [first and last terms]
Step 5: Set i = 1
Step 6: WHILE i <= n-1 DO
x = a + i * h
sum = sum + 2 * f(x) [middle terms multiplied by 2]
i = i + 1
END WHILE
Step 7: I = (h / 2) * sum
Step 8: Print I
Step 9: STOP
C Program
#include <stdio.h>
#include <math.h>
/* Define the function to be integrated */
/* Example: f(x) = x^2, change as needed */
double f(double x) {
return x * x; /* Replace with desired function */
}
int main() {
double a, b, h, sum, x, result;
int n, i;
/* Input */
printf("Enter lower limit (a): ");
scanf("%lf", &a);
printf("Enter upper limit (b): ");
scanf("%lf", &b);
printf("Enter number of segments (n): ");
scanf("%d", &n);
/* Step size */
h = (b - a) / n;
/* Apply Multi-Segment Trapezoidal Rule */
/* First and last terms */
sum = f(a) + f(b);
/* Middle terms */
for (i = 1; i <= n - 1; i++) {
x = a + i * h;
sum = sum + 2 * f(x);
}
/* Final result */
result = (h / 2) * sum;
printf("\nApproximate value of integral = %.6lf\n", result);
return 0;
}
Sample Output
For $\int_0^1 x^2, dx$ with n = 4:
| i | x_i | f(x_i) = x_i^2 |
|---|---|---|
| 0 | 0.00 | 0.0000 |
| 1 | 0.25 | 0.0625 |
| 2 | 0.50 | 0.2500 |
| 3 | 0.75 | 0.5625 |
| 4 | 1.00 | 1.0000 |
$$h = \frac{1-0}{4} = 0.25$$
$$I \approx \frac{0.25}{2}\left[0 + 1 + 2(0.0625 + 0.25 + 0.5625)\right]$$
$$I \approx 0.125 \times [1 + 2(0.875)] = 0.125 \times 2.75 = \mathbf{0.34375}$$
Exact value = 1/3 = 0.33333... (small error due to finite segments; error decreases as n increases)
Key Points
| Feature | Detail |
|---|---|
| Method type | Newton-Cotes closed formula |
| Order of accuracy | O(h^2) per segment |
| Error decreases | As n increases (h decreases) |
| Easy to implement | Yes, simple loop structure |
Simpson's 3/8 rule and composite Simpson's 3/8 rule
2078 · 10 marks
Derive the formula for integration using simpsons 3/8 rule. Use Secant Method to estimate the root of equation with initial estimate x₁ = 4 and x₂ = 2, $x^2 - 4x - 10 = 0$. [10]
Make Unit 6 stick
Practice BIT203 with flashcards & quizzes