lab_07
lab_07
Objective:
To get familiarized with the different types of numerical integration technique.
Theory:
The Newton-Cotes formulas are the most common numerical integration schemes. They
are based on the strategy of replacing a complicated function or tabulated data with an
approximating function that is easy to integrate:
b b
I = ∫ f (x) dx ≅ ∫ f
a a
n (x) dx
Closed and open forms of the Newton-Cotes formulas are available. The closed forms are those where
the data points at the beginning and end of the limits of integration are known (Fig. 11.1(a)). The open
forms have integration limits that extend beyond the range of the data (Fig. 11.1(b)).
Fig. 11.1
The trapezoidal rule is the first of the Newton-Cotes closed integration formulas.
First of the Newton-Coates formulas; corresponds to 1st order polynomial
b b
I = ∫
a
f (x) dx ≅ ∫ f (x) dx
a
1
Recall from “INTERPOLATION” that a straight line can be represented:
f (b) − (a)
f1=
(x) f (a) + x
b−a
Area under line is an estimate of the integral b/w the limits ' a ' and 'b'
f (b) − f (a)
b
=I ∫ f (a) +
a
b−a
x dx
One way to improve the accuracy of the trapezoidal rule is to divide the integration
interval from a to b into a number of segments and apply the method to each segment.
The areas of individual segments can then be added to yield the integral for the entire
interval. There are n + 1 equally spaced base points (x0, x1, x2, . . . , xn).
Consequently, there are n segments of equal width:
b−a
h=
n
If a and b are designated as x 0 and x n , respectively, the total integral can be represented
as
x1 x2 x3 xn
Demonstration
Example 21.1 from the book.
Problem statement
Using 10 iterations numerically integrate
f(x) = 0.2 + 25x - 200x 2 + 675 x 3 − 900 x 4 + 400 x 5 from x = 0 to 0.8. The exact value is
1.640533
clear all
clc
n = 20; % number iterations
intervalBegin = 0; % lower limit
intervalEnd = 0.8; % upper limit
exact_val = 1.640533; % Exact value
integral = 0.0;
dx = (intervalEnd-intervalBegin)/n; % step size
for i = 1:(n-1)
Verification
n h I E t (%)
∫ f (x) dx
a
≈
3
(y 0 + 4 y1 + 2 y 2 + 4 y3 + 2 y 4 + ........ + 4 y n −1 + y n )