














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!















File faclib/dattab/LECTURE-NOTES/NUMERICAL-INTER03.tex /by EC, 2/26/2009 at 10:14, version 9
File faclib/dattab/LECTURE-NOTES/NUMERICAL-INTER03.tex /by EC, 2/26/2009 at 10:14, version 9
In this lecture we consider the process of numerically finding the value of the definite integral:
I =
∫ (^) b a^ f^ (x)dx.
The need for doing so arises in practical applications, because, in many instances f (x) is either not known explicitly or the value of I is difficult to determine. The process is called Numerical Integration. We will assume that even though f (x) is not explicitly known, the values of f (x) at certain points in [a, b] are known.
Given f (x 0 ), f (x 1 ),... , f (xn), where x 0 = a < x 1 < x 2... < xn = b, compute an approximate value of I =
∫ (^) b a^ f^ (x)dx
Numerical integration is very often referred to as numerical quadrature meaning that it is a process of finding an area of a square whose area is equal to the area under a curve.
We would like to obtain a quadrature formula of the following form:
I =
∫ (^) b a^ f^ (x)dx^ ≈^ a^0 f^0 +^ a^1 f^1 +^...^ +^ anfn, where fi = f (xi), i = 0, 1 ,... , n, are given, and the coefficients a 0 , a 1 ,... , an are to be determined.
Since f (x) is not explicitly known, the simplest thing to do will be to construct an interpo- lating polynomial for f (x) with x 0 , x 1 ,... xn as nodes and integrate with the interpolating
File faclib/dattab/LECTURE-NOTES/NUMERICAL-INTER03.tex /by EC, 2/26/2009 at 10:14, version 9
Since the above formula only gives a crude approximation to the actual value of the integral, we need to asses the error.
To obtain an error formula for this integral approximation, recall that the error formula for interpolation of degree n is given by
En(x) = f^ (n+1)(ξ(x))Ψn(x) (n + 1)! ,
where Ψn(x) = (x − x 0 )(x − x 1 )... (x − xn), and a ≤ ξ ≤ b(a ≡ xo, b ≡ xn).
Since in case of the Trapezoidal rule, n = 1, we have
E 1 (x) = f^
(2)(ξ(x))Ψ 1 (x) 2! ,
where Ψ 1 (x) = (x − x 0 )(x − x 1 ).
Integrating this formula we have the following error formula for the Trapezoidal rule:
ET (x) =
∫ (^) x 1 x 0
f (2)(ξ(x)) 2! (x^ −^ x^0 )(x^ −^ x^1 )dx^ =
∫ (^) x 1 x 0
f (2)(ξ(x)) 2! Ψ^1 (x).^ (2.2)
We can now simplify the above formula by applying the Weighted Mean Value Theorem (WMT).
Weighted Mean Value Theorem (WMT Theorem) Let g(x) does not change sign in (a, b), then there exists a constant c between a and b such that (^) ∫ (^) b a^ f^ (x)g(x)dx^ =^ f^ (c)
∫ (^) b a^ g(x)dx.
File faclib/dattab/LECTURE-NOTES/NUMERICAL-INTER03.tex /by EC, 2/26/2009 at 10:14, version 9
To apply the WMT to (2.2), we have note that the function Ψ 1 (x) = (x − x 0 )(x − x 1 ) does not change sign over [x 0 , x 1 ], because, for x ∈ [x 0 , x 1 ], (x − x 0 ) > 0 and (x − x 1 ) < 0. Thus, Ψ 1 (x) is always negative.
So, applying the above theorem to ET , with g(x) = Ψ(x) and noting that h = x 1 − x 0 , we obtain
ET = f^ (2)(η) 2!
∫ (^) x 1 x 0 (x^ −^ x^0 )(x^ −^ x^1 )dx^ =^
−h^3 12 f^
′′(η), (2.3)
where x 0 < η < x 1.
Trapezoidal Rule with Error Formula ∫ (^) x 1 =b x 0 =a^ f^ (x)dx^ =
(b − a) 2 [f^0 +^ f^1 ]^ −^
(b − a)^3 12 f^
′′(η) = h 2 [f^ (a) +^ f^ (b)]^ −^
h^3 12 f^
′′(η), where a < η < b.
Exactness of Trapezoidal Rule
From the above error formula it follows that the Trapezoidal rule is exact only for straight lines. This is because, f ′′(x) = 0, when f (x) is a straight line, and is non zero, whenever f (x) is of degree 2 and higher.
Trapezoidal rule approximates the area under the curve y = f (x) from x 0 = a to x 1 = b by the area of the trapezoid as shown below:
File faclib/dattab/LECTURE-NOTES/NUMERICAL-INTER03.tex /by EC, 2/26/2009 at 10:14, version 9
Note: The area of the trapezoid ABCD = Length of the base × average height = h · 12 (f 0 + f 1 ) = h 2 (f 0 + f 1 ).
If f (x) is approximated by Lagrange interpolating polynomial of degree 2 and then integra- tion is taken over [a, b] with the interpolating polynomial as integrand, the result is Simpson’s rule.
f (x) ≈ Lagrange Interpolating polynomial of degree 2 =⇒ Simpson’s Rule
The three points of interpolation in this case are: x 0 , x 1 , and x 2.
placements
x 0 = a x 1 x 2 = b The Lagrangian interpolating polynomial P 2 (x) = L 0 (x)f 0 + L 1 (x)f 1 + L 2 (x)f 2. So, I =
∫ (^) b=x 2 a=x 0 f^ (x)dx^ ≈
∫ (^) x 2 x 0 [L^0 (x)f^0 +^ L^1 (x)f^1 +^ L^2 (x)f^2 ]dx Now, L 0 (x) = (^) ((xx 0 −−^ xx^11 )()(xx^0 − −^ x x^2 ) 2 ), L 1 (x) = (^) (x(x 1 −−^ xx^00 )()(xx^1 − −^ x x^2 ) 2 ),
and L 2 (x) = (^) ((xx 2 −−^ xx^00 )()(xx^2 − −^ x x^1 ) 1 ). Let h be the distance between two consecutive points of interpolation, assumed to be equally spaced. That is, x 1 − x 0 = h and x 2 − x 1 = h. Substituting these expressions for L 0 (x), L 1 (x) and L 2 (x) and taking integration, we obtain Simpson’s Rule:
IS = h 3 (f 0 + 4f 1 + f 2 ) = h 3 (f (a) + 4f 1 + f (b))
File faclib/dattab/LECTURE-NOTES/NUMERICAL-INTER03.tex /by EC, 2/26/2009 at 10:14, version 9
Simpson’s Rule IS = h 3 (f (a) + 4f 1 + f (b))
We have used n = 2 to derive Simpson’s rule. So, the error formula for Simpson’s Rule is given by ES = 3!^1
∫ (^) b a^ f^
(3)(ξ(x))Ψ 2 (x)dx.
Since Ψ 2 (x) = (x − x 0 )(x − x 1 )(x − x 2 ) does change sign in (x 0 , x 2 ), we can not apply WMT directly. In this case, we will use a slightly different technique. The following result will be used.
Suppose that f (x) changes sign over (a, b), however Ψn(x) = (x − x 0 )(x − x 1 ) · · · (x − xn) is such that ∫ (^) b a^ Ψn(x) = 0. Let xn+1 be another point such that Ψn+1(x) = (x − xn+1)Ψn(x) is of one sign in (a, b). Then
∫ (^) b a^ f^ (x)Ψn(x)dx^ =^
(n + 2)!f^
(n+2)(η)^ ∫^ b a^ Ψn+1(x)dx where, a < η < b.
In our case n = 2 and we note that ∫ (^) x 2
x 0 Ψ^2 (x) =
∫ (^) x 2 x 0 (x^ −^ x^0 )(x^ −^ x^1 )(x^ −^ x^2 )dx^ = 0. (Since x 1 = x^0 + 2 x^2 ).
File faclib/dattab/LECTURE-NOTES/NUMERICAL-INTER03.tex /by EC, 2/26/2009 at 10:14, version 9
Example 3.1 Consider approximating
0 cos^ xdx^ using both Trapezoidal Rule (TRAP) and Simpson’s Rule (SYMS).
IΓ = Trap:
0 cos^ xdx^ ≈^0 .5(1 + 0.5403) = 0.^7702 IS =SYMS:
0 cos^ dx^ ≈^
6 (1 + 4 cos(
2 ) + cos(1)) = 0.^8418. Exact value ≡ 0. 8415 (in 4-digit arithmetic).
IS = b^ − 6 a
f (a) + 4f
(a + b 2
These two rules are special cases of the Closed Newton-Cotes (CNC) rule.
An n−point closed Newton-Cotes rule has the (n + 1) nodes:
xi = a + i (b^ − n a), i = 0, 1 , · · · , n.
File faclib/dattab/LECTURE-NOTES/NUMERICAL-INTER03.tex /by EC, 2/26/2009 at 10:14, version 9
n = 1 ⇒ Trapezoidal Rule
n = 2 ⇒ Simpson’s Rule
(Note that CNC Rule includes the end points of the nodes)
The open Newton-Cotes has the (n + 1) nodes which do not include the end points.
xi = a + i ( nb^ −+ 2^ a) , i = 1, 2 , · · · , n.
A well-known example of the n-point open Newton-Cotes rule is the midpoint rule (with n = 0). Thus, the midpoint rule is based on interpolation of f (x) with a constant function. The only node in this case is: x 1 = a^ + 2 b.
Thus IM = Midpoint Approximation to the Integral
∫ (^) b a^ f^ (x)dx^ = (b^ −^ a)f
(a + b 2
Error Formula for the Midpoint Rule:
In this case Ψ 0 (x) = x − x 1 = x − a^ + 2 bchanges sign in (a, b).
However, note that if we x 0 = x 1 , then Ψ 1 (x) = (x − x 1 )^2 = (x − a^ + 2 b)^2 is always of the same sign. Thus, we can show as in the case of Simpson’s rule that
EM = f ′′(η) (b^ −^ a)
3 24
, where a < η < b
Thus
Midpoint Rule with Error Formula
∫ (^) b a^ f^ (x)dx^ = (b^ −^ a)f^ (^
a + b 2 ) +^ f^
′′(η) (b^ −^ a)^3
File faclib/dattab/LECTURE-NOTES/NUMERICAL-INTER03.tex /by EC, 2/26/2009 at 10:14, version 9
∫ (^) x 1 x 0 =a^ f^ (x)dx^ +
∫ (^) x 2 x 1 f^ (x)dx^ +^...^ +
∫ (^) xn=b xn− 1 f^ (x)dx = h 2 (f 0 + f 1 ) + h 2 (f 1 + f 2 ) +... + h 2 (fn− 1 + fn)
= h
(f 0 2 +^ f^1 +^ f^2 +^...^ +^ fn−^1 +^
fn 2
The Composite Trapezoidal Rule
ICT = h
[f 0 2 +^ f^1 +^ f^2 +^...^ +^ fn−^1 +^
fn 2
= h 2 [f (a) + 2f 1 + 2f 2 + · · · + 2fn− 1 + f (b)].
The error formula for CTR is obtained by adding the individual error terms of the trapezoidal rule in each of the subintervals. Thus, the error formula for the composites trapezoidal rule, denoted by ETC in given by:
ETC = −h 3 12 [f^
′′(η 1 ) + f ′′(η 2 ) +... + f ′′(ηn)]
Simplification of the Error Formula.
To simplify the expression within the parenthesis, we need the following well-known result.
File faclib/dattab/LECTURE-NOTES/NUMERICAL-INTER03.tex /by EC, 2/26/2009 at 10:14, version 9
The Intermediate Value Theorem (IVT) If f (x) is continuous on [a, b] and k is a number such that f (a) < k < f (b), then there exists a number c, a < c < b with the property: f (c) = k.
Applying the IVT and remembering that h = b^ − n^ a, we get
ECT = − nh
3 12 f^
′′(η), where η 1 < η < ηn.
= −n (b^ − n^ a)· h 2 12 f^ ′′(η) = − (b^ −^ a) 12 h (^2) f ′′(η),
where a < η < b.
The Composite Trapezoidal Rule With Error Formula ∫ (^) b=xn a=x 0 f^ (x)dx^ =^ h
[f 0 2 +^ f^1 +^ f^2 +^...^ +^
fn 2
Composite Trapezoidal Rule
Since Simpson’s rule was obtained with two subintervals, in order to derive the CSR, we divide the interval [a, b] into even number of subintervals, say n = 2m, where m is a positive integer and then apply Simpson’s rule in each of those subintervals and finally, add up the results.
Obtaining Composite Simpson’s Rule
File faclib/dattab/LECTURE-NOTES/NUMERICAL-INTER03.tex /by EC, 2/26/2009 at 10:14, version 9
By using IMT, it can be shown that there exists a number η in (a, b) such that
ECS = −h 5 90 ×^
n 2 f^
(4)(η)
= −h
5 180
(b − a) h f^
(4)(η) = −h^4 180 (b^ −^ a)f^
(4)(η).
(Note that n = b^ − h a).
The Composite Simpson’s Rule with Error Term
∫ (^) b a^ f^ (x)dx^ =^
h 3 [(f^0 +^ fn) + 4(f^1 +^...^ +^ fn−^1 ) + 2(f^2 +^...^ +^ fn−^2 )]^ −^
h^4 180 (b^ −^ a)f^
(4)(η)
= h 3 [f (a) + f (b) + 4(f 1 + · · · + fn− 1 ) + 2(f 2 + · · · + f (n − 2)] ︸ ︷︷ ︸ Composite Simpson’s Rule
− h 4 180 (b^ −^ a)f^
(4)(η) ︸ ︷︷ ︸ Error
Example 5.1 Let f (x) =
x if 0 ≤ x ≤ (^12) 1 − x if 12 ≤ x ≤ 1 (a) Trapezoidal Rule over [0, 1] IT =^12 (f (0) + f (1)) =^12 (0 + 0) = 0
(b) Trapezoidal Rule over
and
ICT = 14 (f (0) + f (1/2)) +^14
f (^12 ) + f (1)
(c) Simpon’s Rule over [0, 1] IS = (^13)
f (0) + 4f
File faclib/dattab/LECTURE-NOTES/NUMERICAL-INTER03.tex /by EC, 2/26/2009 at 10:14, version 9
Determine h to approximate (^) ∫ (^10)
· 1
t et^ dt with an accuracy of = 10−^3 using the Composite Trapezoidal rule.
Recall that the error formula in this case is:
ECT = − b^ − 12 ah^2 f ′′(η).
Let’s now find the maximum value (in magnitude) of ECT in the interval [0.1, 10].
We then need to find f ′′(η). Now, f (t) = (^) t e^1 t (given)
and f ′′(t) = (^) t e^1 t
t^2 +
t + 1
Thus, f ′′^ is maximum when t = 0. 1
and max |f ′′(t)| = (^0). 1 ×^1 e 0. 1 (100 + 20 + 1) = 1094. 9
So, maximum value of ECT =
h^2 × 1094. 9.
Thus, to approximate h with an accuracy of = 10−^3 , h has to be such that ( 9. 9 12
h^2 × 1094. 9 ≤ 10 −^3.
That is, h^2 ≤ 12 · 10 −^3 × (^9). 9 × 11094. 9
or h ≤ 0. 01052 × 10 −^7.
File faclib/dattab/LECTURE-NOTES/NUMERICAL-INTER03.tex /by EC, 2/26/2009 at 10:14, version 9
Verify: k = 2.
R 21 = 12 [R 11 + h 1 f (a + h 2 )]
= (^12)
R 11 + (b − a)f
a + b^ − 2 a
Furthermore, one can show that R 11 and R 21 can be combined to compute another number R 22 ; R 31 and R 21 can be combined to compute R 32 ; and so on. The formula to do so is:
Rkj = Rk,j− 1 + Rk,j− 41 j^ −− 1 R−k 1 − 1 ,j−^1 , k = 2, 3 ,... , n; j = 2,... , k (6.4)
Thus, R 22 = R 21 + R^214 −−^ R 1 11 = R 21 + R^21 − 3 R^11. and so on.
These numbers are called Romberg numbers and can be arranged in a table, similar to the divided difference table, and is known as The Romberg Table.
Rn 1 Rn 2 Rn 3 Rnn
File faclib/dattab/LECTURE-NOTES/NUMERICAL-INTER03.tex /by EC, 2/26/2009 at 10:14, version 9
Suppose that we would like to compute
∫ (^) b a^ f^ (x) with an accuracy of^ ,^ then the iteration can be stopped as soon as
∣∣R nn −^ Rn− 1 ,n− 1
Since our ultimate interest is to obtain the diagonal entries and these entries can be computed just out of two entries from the previous column, we can compute the entries Romberg Table in the following order of computations.
Example 6.1 I =
1 x
(^2) lnx with n = 3
R 11 =^12 (1. 5 − 1)[f (1) + f (1.5)] =. 2280741
R 21 =^12 (R 11 + (1. 5 − 1)(f (1 +^1.^5 − 2 1))) =. 201225