Numerical Methods - Numerical
Integration
N. B. Vyas
Department of Mathematics,
Atmiya Institute of Tech. and Science, Rajkot (Guj.)
niravbvyas@gmail.com
N. B. Vyas Numerical Methods - Numerical Integration
Numerical Integration
Let I =
b
a
y dx where y = f(x) takes the values y0, y1, . . . , yn for
x0, x1, . . . , xn
N. B. Vyas Numerical Methods - Numerical Integration
Numerical Integration
Let I =
b
a
y dx where y = f(x) takes the values y0, y1, . . . , yn for
x0, x1, . . . , xn
Let us divide the interval (a, b) into n sub-intervals of width h so
that x0 = a, x1 = a + h = x0 + h, x2 = x0 + 2h, . . .,
xn = x0 + nh = b then
N. B. Vyas Numerical Methods - Numerical Integration
Numerical Integration
Let I =
b
a
y dx where y = f(x) takes the values y0, y1, . . . , yn for
x0, x1, . . . , xn
Let us divide the interval (a, b) into n sub-intervals of width h so
that x0 = a, x1 = a + h = x0 + h, x2 = x0 + 2h, . . .,
xn = x0 + nh = b then
I =
b
a
y dx =
x0+nh
x0
f(x) dx
N. B. Vyas Numerical Methods - Numerical Integration
Numerical Integration
Let I =
b
a
y dx where y = f(x) takes the values y0, y1, . . . , yn for
x0, x1, . . . , xn
Let us divide the interval (a, b) into n sub-intervals of width h so
that x0 = a, x1 = a + h = x0 + h, x2 = x0 + 2h, . . .,
xn = x0 + nh = b then
I =
b
a
y dx =
x0+nh
x0
f(x) dx
Trapezoidal rule:
b=x0+nh
a=x0
f(x)dx =
h
2
[(y0 + yn) + 2 (y1 + y2 + .... + yn)]; h =
b − a
n
If the number of strips is increased; that is, h is decreased, then
the accuracy of the approximation is increased.
N. B. Vyas Numerical Methods - Numerical Integration
Numerical Integration
Simpson’s
1
3
rd rule:
N. B. Vyas Numerical Methods - Numerical Integration
Numerical Integration
Simpson’s
1
3
rd rule:
x0+nh
x0
f(x)dx = h
3 [(y0 + yn) + 4(y1 + y3 + ....)
+2(y3 + y4 + ....)]; h = b−a
n
N. B. Vyas Numerical Methods - Numerical Integration
Numerical Integration
Simpson’s
1
3
rd rule:
x0+nh
x0
f(x)dx = h
3 [(y0 + yn) + 4(y1 + y3 + ....)
+2(y3 + y4 + ....)]; h = b−a
n
while applying this rule, the given interval must be divided into
even number of equal sub-intervals. i.e. n must be even.
N. B. Vyas Numerical Methods - Numerical Integration
Numerical Integration
Simpson’s
1
3
rd rule:
x0+nh
x0
f(x)dx = h
3 [(y0 + yn) + 4(y1 + y3 + ....)
+2(y3 + y4 + ....)]; h = b−a
n
while applying this rule, the given interval must be divided into
even number of equal sub-intervals. i.e. n must be even.
Simpson’s
3
8
th rule:
N. B. Vyas Numerical Methods - Numerical Integration
Numerical Integration
Simpson’s
1
3
rd rule:
x0+nh
x0
f(x)dx = h
3 [(y0 + yn) + 4(y1 + y3 + ....)
+2(y3 + y4 + ....)]; h = b−a
n
while applying this rule, the given interval must be divided into
even number of equal sub-intervals. i.e. n must be even.
Simpson’s
3
8
th rule:
x0+nh
x0
f(x)dx = 3h
8 [(y0 + yn) + 3(y1 + y2 + y4 + y5 + ....)
+2(y3 + y6 + ....)]; h = b−a
n
N. B. Vyas Numerical Methods - Numerical Integration
Numerical Integration
Simpson’s
1
3
rd rule:
x0+nh
x0
f(x)dx = h
3 [(y0 + yn) + 4(y1 + y3 + ....)
+2(y3 + y4 + ....)]; h = b−a
n
while applying this rule, the given interval must be divided into
even number of equal sub-intervals. i.e. n must be even.
Simpson’s
3
8
th rule:
x0+nh
x0
f(x)dx = 3h
8 [(y0 + yn) + 3(y1 + y2 + y4 + y5 + ....)
+2(y3 + y6 + ....)]; h = b−a
n
while applying this rule, the number of sub-intervals should be
taken as a multiple of 3 i.e. n must be multiple of 3
N. B. Vyas Numerical Methods - Numerical Integration
Numerical Integration
Gaussian Integration Formula:
1
−1
f(t)dt =
n
i=1
wif(ti)
It should be noted here that, t = ±1 is obtained by setting
x =
1
2
[(b + a) + t (b − a)]
N. B. Vyas Numerical Methods - Numerical Integration
Numerical Integration
Gaussian Integration Formula: The following table gives the
values for n = 2, 3, 4, 5
N. B. Vyas Numerical Methods - Numerical Integration
Example
Ex. Evaluate
1
0
e−x2
dx by using Gaussion integration formula for
n = 3.
Sol. Here, we have to first convert the given integral from 0 to 1 into
an integral from −1 to 1. x = 1
2 [(b + a) + t (b − a)], a = 0 and
b = 1
∴ x =
t + 1
2
⇒ dx =
dt
2
∴
1
0
exp(−x2)dx =
1
2
1
−1
exp −
1
4
(t + 1)2 dt
N. B. Vyas Numerical Methods - Numerical Integration
Error
Error in Quadrature Formula:
If yp is a polynomial representing the function y = f(x) in the
interval [x0, xn] the error in the quadrature formula is given by
E =
xn
x0
f(x) =
xn
x0
ypdx
N. B. Vyas Numerical Methods - Numerical Integration
Error
Error in Trapezoidal rule:
|error| ≤ (b − a)
h2
12
|f (M)|
where f (M) = max |f 0(x)|, |f 1(x)|, ..., |f n−1(x)|
∴ error is of order h2
total error =
dh3
12
y 0 + y 1 + ... + y n−1
N. B. Vyas Numerical Methods - Numerical Integration
Error
Error in Simpson’s
1
3
rd rule:
|error| ≤ (b − a)
h4
180
|f4
(M)|
where f4(M) = max |y4
0|, |y4
2|, ..., |y4
n−2|
∴ error is of order h4
total error =
h5
90
y4
0 + y4
2 + ... + y4
n−2
N. B. Vyas Numerical Methods - Numerical Integration
Error
Error in Simpson’s
3
8
th rule:
|error| ≤ (b − a)
h4
80
|f4
(M)|
where f4(M) = max |y4
0|, |y4
3|, ..., |y4
n−3|
∴ error is of order h4
total error =
3h5
80
y4
0 + y4
3 + ... + y4
n−3
N. B. Vyas Numerical Methods - Numerical Integration

Numerical Methods 3

  • 1.
    Numerical Methods -Numerical Integration N. B. Vyas Department of Mathematics, Atmiya Institute of Tech. and Science, Rajkot (Guj.) niravbvyas@gmail.com N. B. Vyas Numerical Methods - Numerical Integration
  • 2.
    Numerical Integration Let I= b a y dx where y = f(x) takes the values y0, y1, . . . , yn for x0, x1, . . . , xn N. B. Vyas Numerical Methods - Numerical Integration
  • 3.
    Numerical Integration Let I= b a y dx where y = f(x) takes the values y0, y1, . . . , yn for x0, x1, . . . , xn Let us divide the interval (a, b) into n sub-intervals of width h so that x0 = a, x1 = a + h = x0 + h, x2 = x0 + 2h, . . ., xn = x0 + nh = b then N. B. Vyas Numerical Methods - Numerical Integration
  • 4.
    Numerical Integration Let I= b a y dx where y = f(x) takes the values y0, y1, . . . , yn for x0, x1, . . . , xn Let us divide the interval (a, b) into n sub-intervals of width h so that x0 = a, x1 = a + h = x0 + h, x2 = x0 + 2h, . . ., xn = x0 + nh = b then I = b a y dx = x0+nh x0 f(x) dx N. B. Vyas Numerical Methods - Numerical Integration
  • 5.
    Numerical Integration Let I= b a y dx where y = f(x) takes the values y0, y1, . . . , yn for x0, x1, . . . , xn Let us divide the interval (a, b) into n sub-intervals of width h so that x0 = a, x1 = a + h = x0 + h, x2 = x0 + 2h, . . ., xn = x0 + nh = b then I = b a y dx = x0+nh x0 f(x) dx Trapezoidal rule: b=x0+nh a=x0 f(x)dx = h 2 [(y0 + yn) + 2 (y1 + y2 + .... + yn)]; h = b − a n If the number of strips is increased; that is, h is decreased, then the accuracy of the approximation is increased. N. B. Vyas Numerical Methods - Numerical Integration
  • 6.
    Numerical Integration Simpson’s 1 3 rd rule: N.B. Vyas Numerical Methods - Numerical Integration
  • 7.
    Numerical Integration Simpson’s 1 3 rd rule: x0+nh x0 f(x)dx= h 3 [(y0 + yn) + 4(y1 + y3 + ....) +2(y3 + y4 + ....)]; h = b−a n N. B. Vyas Numerical Methods - Numerical Integration
  • 8.
    Numerical Integration Simpson’s 1 3 rd rule: x0+nh x0 f(x)dx= h 3 [(y0 + yn) + 4(y1 + y3 + ....) +2(y3 + y4 + ....)]; h = b−a n while applying this rule, the given interval must be divided into even number of equal sub-intervals. i.e. n must be even. N. B. Vyas Numerical Methods - Numerical Integration
  • 9.
    Numerical Integration Simpson’s 1 3 rd rule: x0+nh x0 f(x)dx= h 3 [(y0 + yn) + 4(y1 + y3 + ....) +2(y3 + y4 + ....)]; h = b−a n while applying this rule, the given interval must be divided into even number of equal sub-intervals. i.e. n must be even. Simpson’s 3 8 th rule: N. B. Vyas Numerical Methods - Numerical Integration
  • 10.
    Numerical Integration Simpson’s 1 3 rd rule: x0+nh x0 f(x)dx= h 3 [(y0 + yn) + 4(y1 + y3 + ....) +2(y3 + y4 + ....)]; h = b−a n while applying this rule, the given interval must be divided into even number of equal sub-intervals. i.e. n must be even. Simpson’s 3 8 th rule: x0+nh x0 f(x)dx = 3h 8 [(y0 + yn) + 3(y1 + y2 + y4 + y5 + ....) +2(y3 + y6 + ....)]; h = b−a n N. B. Vyas Numerical Methods - Numerical Integration
  • 11.
    Numerical Integration Simpson’s 1 3 rd rule: x0+nh x0 f(x)dx= h 3 [(y0 + yn) + 4(y1 + y3 + ....) +2(y3 + y4 + ....)]; h = b−a n while applying this rule, the given interval must be divided into even number of equal sub-intervals. i.e. n must be even. Simpson’s 3 8 th rule: x0+nh x0 f(x)dx = 3h 8 [(y0 + yn) + 3(y1 + y2 + y4 + y5 + ....) +2(y3 + y6 + ....)]; h = b−a n while applying this rule, the number of sub-intervals should be taken as a multiple of 3 i.e. n must be multiple of 3 N. B. Vyas Numerical Methods - Numerical Integration
  • 12.
    Numerical Integration Gaussian IntegrationFormula: 1 −1 f(t)dt = n i=1 wif(ti) It should be noted here that, t = ±1 is obtained by setting x = 1 2 [(b + a) + t (b − a)] N. B. Vyas Numerical Methods - Numerical Integration
  • 13.
    Numerical Integration Gaussian IntegrationFormula: The following table gives the values for n = 2, 3, 4, 5 N. B. Vyas Numerical Methods - Numerical Integration
  • 14.
    Example Ex. Evaluate 1 0 e−x2 dx byusing Gaussion integration formula for n = 3. Sol. Here, we have to first convert the given integral from 0 to 1 into an integral from −1 to 1. x = 1 2 [(b + a) + t (b − a)], a = 0 and b = 1 ∴ x = t + 1 2 ⇒ dx = dt 2 ∴ 1 0 exp(−x2)dx = 1 2 1 −1 exp − 1 4 (t + 1)2 dt N. B. Vyas Numerical Methods - Numerical Integration
  • 15.
    Error Error in QuadratureFormula: If yp is a polynomial representing the function y = f(x) in the interval [x0, xn] the error in the quadrature formula is given by E = xn x0 f(x) = xn x0 ypdx N. B. Vyas Numerical Methods - Numerical Integration
  • 16.
    Error Error in Trapezoidalrule: |error| ≤ (b − a) h2 12 |f (M)| where f (M) = max |f 0(x)|, |f 1(x)|, ..., |f n−1(x)| ∴ error is of order h2 total error = dh3 12 y 0 + y 1 + ... + y n−1 N. B. Vyas Numerical Methods - Numerical Integration
  • 17.
    Error Error in Simpson’s 1 3 rdrule: |error| ≤ (b − a) h4 180 |f4 (M)| where f4(M) = max |y4 0|, |y4 2|, ..., |y4 n−2| ∴ error is of order h4 total error = h5 90 y4 0 + y4 2 + ... + y4 n−2 N. B. Vyas Numerical Methods - Numerical Integration
  • 18.
    Error Error in Simpson’s 3 8 thrule: |error| ≤ (b − a) h4 80 |f4 (M)| where f4(M) = max |y4 0|, |y4 3|, ..., |y4 n−3| ∴ error is of order h4 total error = 3h5 80 y4 0 + y4 3 + ... + y4 n−3 N. B. Vyas Numerical Methods - Numerical Integration