Beruflich Dokumente
Kultur Dokumente
Trapezoid method
Z b
f (x) dx
in the interval [a, b], we use the area under the curve method.
Divide the area under the curve into n tapezoids (Fig. (a))
Calculate the area of each trapezoid
Sum all areas
Total area is denoted by T (f ; P ), where P (a = x0 < x1 < x2 < ...................... < xn = b).
Z xi+1
xi
f (x) dx = {xi+1 xi }
o
1n
f (xi) + f (xi+1 )
2
Total area
T (f ; P ) =
Z b
f (x) dx =
n1
X
n
o
X
1 n1
{xi+1 xi } f (xi) + f (xi+1 )
2 i=0
Ai =
i=0
Here we have not specied the nature of division into n trapezoids. Without loss of generality,
we can divide uniform spacing between xi and xi+1 . This implies that the spacing between the
two iintervals
h=
ba
n
Z b
f (x) dx =
o
X n
h n1
f (xi) + f (xi+1 )
2 i=0
h
{[f (x0 ) + f (x1 )] + [f (x1 ) + f (x2 )] + [f (x2 ) + f (x3 )] + ....................... + [f (xn1 ) + f (xn )]}
2
Since each xi term gets added twice other than x0 and xn , we can write
T (f ; P ) =
Z b
f (x) dx =
n1
X
h
{f (a) + f (b)} + h
f (a + ih)
2
i=1
(1)
Problem:
4
dx
1 + x2
We see that the accuracy of the calculation depends on the number of intervals n. Thus we can
use the recursive method to improve the accuracy. In this case, we divide the interval [a, b] into
2n equal intervals rather than n intervals and replace the notation T (f ; P ) by R(n, 0). Then
R(n, 0) =
Z b
f (x) dx = hC + h
n 1
2X
(2)
f (a + ih)
i=1
We see that while calculating R(n, 0), we also evaluate the function at points which is already
evauated by R(n 1, 0). This repeatation of the calculation can be avoided by the following
simplication. Take for example,
R(2, 0) = h00 C + h00 {f (a + h00 ) + f (a + 2h00 ) + f (a + 3h00 )}
R(3, 0) = h000 C + h000 {f (a + h000 ) + f (a + 2h000 ) + f (a + 3h000 ) + f (a + 4h000 )
+ f (a + 5h000 ) + f (a + 6h000 ) + f (a + 7h000 )}
7
5
+ f (a + h00 ) + f (a + 3h00 ) + f (a + h00 )
2
2
1
While calculating R(3, 0), we can use 2 R(2, 0) and then the remaining terms in R(3, 0).
1
h00
h00
3
5
7
R(3, 0) R(2, 0) =
f (a + ) + f (a + h00 ) + f (a + h00 ) + f (a + h00 )
2
2
2
2
2
2
(
1
R(3, 0) = R(2, 0) +
2
1
R(3, 0) R(2, 0)
2
1
R(n, 0) R(n 1, 0)
2
(3)
n 1
2X
f (a + ih)
i=1
0
R(n 1, 0) = h C + h
n 1
2X
f (a + jh0 )
j=1
R(n 1, 0) = 2hC + 2h
n 1
2X
f (a + 2jh)
j=1
n
n1
2X
1
2X
1
2X
1
f (a + ih) h
f (a + 2jh) = h
f (a + [2k 1]h)
R(n, 0) R(n 1, 0) = h
2
i=1
j=1
k=1
2X
1
f (a + [2k 1]h)
R(n, 0) = R(n 1, 0) + h
2
k=1
(4)
For example
1
R(3, 0) = R(2, 0) + h {f (a + h) + f (a + 3h) + f (a + 5h) + f 9(a + 7h)}
2
which is same as the one calcuated earlier. All the even terms get calculaed in the R(2, 0) term,
and the odd terms are added to the new term.
Problem:
4
dx
1 + x2
The recursive trapezoid can be further extrapolated using Romberg Algorithm to improve the
accuracy. Instead of calculating R(n, 0), one can calculate R(n, m), extraplated from R(n, 0)
using the equation
R(n, m) = R(n, m 1) +
1
{R(n, m 1) R(n 1, m 1)}
4m 1
....
R(n, 0)
R(1, 1)
R(2, 1) R(2, 2)
.......
......
.....
........
..........
........ R(n, n)
For exampe:
R(2, 1) = R(2, 0) +
h=ba
h1 = h/2
h2 = h1 /2
hn = hn1 /2
1
{R(2, 0) R(1, 0)}
3
1
R(0, 0) = (b a) {f (a) + f (b)}
2
(5)
Problem:
4
dx
1 + x2
h
{f (a) + 4f (a + h) + f (a + 2h)}
3
f (x) dx
(6)
Problem:
4
dx
1 + x2
h2 00 h3 000 h4 0000
f + f + f + ...............
2
6
24
2
3
4h 00 8h 000 16h4 0000
f (a + 2h) = f (a) + 2hf 0 +
f +
f +
f + ...............
2!
3!
4!
4h3 000 2h4 0000
= f (a) + 2hf 0 + 2h2 f 00 +
f +
f + ...............
3
3
2h3 000 h4 0000
0
2 00
f + f + ...............
4f (a + h) = 4f (a) + 4hf + 2h f +
3
6
5h4 0000
f (a) + 4f (a + h) + f (a + 2h) = 6f (a) + 6hf 0 + 4h2 f 00 + 2h3 f 000 +
f + ...............
6
h
4
2
5h5 0000
{f (a) + 4f (a + h) + f (a + 2h)} = 2hf (a) + 2h2 f 0 + h3 f 00 + h4 f 000 +
f + ............... (7)
3
3
3
18
f (a + h) = f (a) + hf 0 +
If we take
F (x) =
00
Z x
f (t) dt
(8)
then F (a) = 0, F 0 = f , F 00 = f 0 , F 000 = f 00 , ......., etc. Then eqn. (8) can be written as
Z a+2h
a
h
{f (a) + 4f (a + h) + f (a + 2h)} + O(h5 )
3
a
That is, basic Simpson is accuracte upto the order of h5 .
f (x) dx =
(9)
(10)
Z b
(11)
h
{f (a) + 4f (a + h) + f (a + 2h)}
3
1 5 0000
hf
90
In 2-Simpson, the inerval [a,b] is divided into two equal subintervals [a,c] and [c,b], where c is
the midpoint of [a,b]. 1-Simpson is calculated in each interval and added together to obtain I .
That is
I = S 2 [a, b] + E 2 [a, b]
(12)
where
(13)
1
90
h
2
!5
f 0000
1
90
h
2
!5
f 0000 =
1 1
E [a, b]
16
(14)
o
1 n 2
S [a, b] S 1 [a, b]
15
(16)
Thus we can use the second term as an accuracy check for guiding the adaptive process. i.e.,
check whether
1 2
S [a, b] S 1 [a, b] <
15
for exiting the loop. Otherwise, the intervals are further divided and the Simpsons are calculated
for each interval and summed.
Method:
Since a + 2h = b, h = (b a)/2 and c = (a + b)/2, calculate S 1 [a, b] and S 2 [a, b] using the
following equations
h
S [a, b] =
f (a) + 4f
6
1
a+b
+ f (b)
2
h
a+c
S 2 [a, b] =
f (a) + 4f
+ 2f (c) + 4f
12
2
c+b
+ f (b)
2
If |S 2 S 1 | < 15, where is the required accuracy, then exit and the integral value will
be
I[a, b] =
o
1 n
16S 2 S 1
15
(17)
If |S 2 S 1 | > 15, then divide the interval [a,b] into two subintervals [a,c] and [c,b] and
calculate S 1 and S 2 for each interval.
Check whether the condition, |S 2 S 1 | < 15 2 , is satised for each interval. If it satises
both the intervals, then I[a, b] = I[a, c] + I[c, b] where I[a, c] and I[c, b] are given by the
The process can be continued until the required condition is satised for each subinterval.