Mada za sehemu hiiNumerical MethodMada 4
- Errors
- Roots By Iterative Methods
- Numerical Integration
- Simpson's Rule
Numerical integration approximates the numerical value of a definite integral. This is necessary when an integral cannot be evaluated analytically or when the analytical solution is too complex. The trapezoidal and Simpson's rules are common methods for this.
The trapezoidal rule approximates the area under a curve by dividing it into trapezoids.
Divide the region under y=f(x) from a to b into n strips of equal width h:
a=x0<x1<x2<...<xn−1<xn=b
h=nb−a
Area of each trapezium:
Trapezium 1: A1=2h[f(x0)+f(x1)]
Trapezium 2: A2=2h[f(x1)+f(x2)]
...
Trapezium n: An=2h[f(xn−1)+f(xn)]
The total area under the curve is approximately the sum of the trapezium areas:
∫abf(x)dx≈2h[f(x0)+f(x1)]+2h[f(x1)+f(x2)]+...+2h[f(xn−1)+f(xn)]
Simplifying:
∫abf(x)dx≈2h[f(a)+2f(x1)+2f(x2)+...+2f(xn−1)+f(b)]
Or:
A=2h[(first ordinate+last ordinate)+2(sum of remaining ordinates)]
Or:
A=2h[y0+2(y1+y2+y3+...+yn−1)+yn]
Note: n=number of ordinates−1
Use the trapezoidal rule with five strips to evaluate ∫01(e−x−x3+3x2)dx, correct to four decimal places.
Solution:
f(x)=e−x−x3+3x2, a=0, b=1, n=5
h=51−0=0.2
Table of values:
| n | x | y = f(x) |
|---|---|---|
| 0 | 0 | 1 |
| 1 | 0.2 | 1.5187 |
| 2 | 0.4 | 1.9051 |
| 3 | 0.6 | 2.1161 |
| 4 | 0.8 | 2.1064 |
| 5 | 1 | 2.3679 |
∫01f(x)dx≈20.2[1+2(1.5187+1.9051+2.1161+2.1064)+2.3679]
≈0.1[1+2(7.6463)+2.3679]
≈0.1[1+15.2926+2.3679]
≈0.1[18.6605]
≈1.8661
Estimate the value of ∫12x1dx using the trapezoidal rule with six ordinates (5 strips).
Solution:
f(x)=x1, a=1, b=2, n=5
h=52−1=0.2
| n | x | f(x) |
|---|---|---|
| 0 | 1 | 1 |
| 1 | 1.2 | 0.8333 |
| 2 | 1.4 | 0.7143 |
| 3 | 1.6 | 0.6250 |
| 4 | 1.8 | 0.5556 |
| 5 | 2 | 0.5 |
∫12x1dx≈20.2[1+2(0.8333+0.7143+0.6250+0.5556)+0.5]
≈0.1[1+2(2.7282)+0.5]
≈0.1[1+5.4564+0.5]
≈0.6956
Approximate the value of ∫01(1+cos(3x2))dx with n=10 subintervals using the trapezoidal rule.
Solution:
Given ∫01(1+cos(3x2))dx, then f(x)=1+cos(3x). Note: the original text had a typo in the function under the cosine. It should be 3x not 3x2 if we are to get the values presented in the table. If it is indeed supposed to be 3x2 then the y values in the table will be different.
Using the trapezoidal rule:
∫abf(x)dx≈2h[y0+2(y1+y2+...+yn−1)+yn]
Here, a=0, b=1, n=10, so h=101−0=0.1.
Table of values (assuming f(x)=1+cos(3x)):
| n | xn | yn=f(xn) | 2yn (for n=1 to 9) |
|---|---|---|---|
| 0 | 0 | 2 | |
| 1 | 0.1 | 1.173 | 2.346 |
| 2 | 0.2 | 1.691 | 3.382 |
| 3 | 0.3 | 1.955 | 3.910 |
| 4 | 0.4 | 1.995 | 3.990 |
| 5 | 0.5 | 1.802 | 3.604 |
| 6 | 0.6 | 1.401 | 2.802 |
| 7 | 0.7 | 0.838 | 1.676 |
| 8 | 0.8 | 0.165 | 0.330 |
| 9 | 0.9 | -0.536 | -1.072 |
| 10 | 1 | -0.190 | |
| Sum of y0 and y10 | 1.81 | ||
| Sum of 2y1 to 2y9 | 20.978 |
∫01(1+cos(3x))dx≈20.1[2+2(1.173+1.691+1.955+1.995+1.802+1.401+0.838+0.165+−0.536)+−0.190]
≈0.05[2+2(10.484)−0.190]
≈0.05[2+20.968−0.190]
≈0.05[22.778]
≈1.139
If however the function is f(x)=1+cos(3x2) or f(x)=1+cos(x3)
| n | xn | yn=f(xn) | 2yn (for n=1 to 9) |
|---|---|---|---|
| 0 | 0 | 2 | |
| 1 | 0.1 | 1.995 | 3.99 |
| 2 | 0.2 | 1.98 | 3.96 |
| 3 | 0.3 | 1.955 | 3.91 |
| 4 | 0.4 | 1.92 | 3.84 |
| 5 | 0.5 | 1.875 | 3.75 |
| 6 | 0.6 | 1.82 | 3.64 |
| 7 | 0.7 | 1.755 | 3.51 |
| 8 | 0.8 | 1.68 | 3.36 |
| 9 | 0.9 | 1.595 | 3.19 |
| 10 | 1 | 1.5 | |
| Sum of y0 and y10 | 3.5 | ||
| Sum of 2y1 to 2y9 | 33.15 |
∫01(1+cos(3x2))dx≈20.1[2+2(1.995+1.98+1.955+1.92+1.875+1.82+1.755+1.68+1.595)+1.5]
≈0.05[2+33.15+1.5]
≈0.05[36.65]
≈1.8325 or 1.833
Mwalimu
Unasoma somo hili? Niulize nikuelezee chochote kilichomo.
Ingia ili kumuuliza Mwalimu wa AI wa Sonza kuhusu mada hii.
Ingia ili kuulizaMajadiliano
Hakuna maswali bado