Chapter 5
Chapter 5
Chapter 5
Numerical integration
In this chapter, we study some methods; used to find the approximate value for the
definite following integral
w
methods), such as:
The general idea of the integration methods is to divide the interval , into of
subintervals :
From the last form, we note that, the formula of numerical integration depends on
the way of choosing the polynomial .
50
Dr. Maan A. Rasheed Numerical Analysis
where,
i.e.
Thus
which means
51
Dr. Maan A. Rasheed Numerical Analysis
Trapezoidal method
From the general form of integration, with choosing Lagrange polynomial, and
n=1, we get
, ,
Set ,
Remark:- We note that, if is polynomial of order less than or equal one, then the
truncation error equal zero, which means:
52
Dr. Maan A. Rasheed Numerical Analysis
Example:- Use the Trapezoidal method to find the approximate value of the following
integral
Solution
, , ,
In order to get more accurate value to the integration, we use the composite
Trapezoidal methods.
53
Dr. Maan A. Rasheed Numerical Analysis
Since the summation of all the integrals on the subintervals is equal the integral on
the whole interval , we can apply the Trapezoidal formula, on each of the
integrals as follows:
where
1-Input
4-Find
54
Dr. Maan A. Rasheed Numerical Analysis
Example: For the last example, find the approximate value of the integral, using
composite Trapezoidal methods with taking
=1/4(1+1/8+1+1/8+1+2)= 1/4[21/4]=[21/16]=1.3125
E=| - |=|1.31-1.25|=0.06
Remark
In last example, it is clear that, from the absolute errors, the result of the composite
Trapezoidal method is more accurate than the result that we get by using normal
Trapezoidal method.
Next, we write dawn the Matlab Code for last example with
a=0; b=1; n=40;
h=(b-a)/n; g=0;
x=sym('x');
f=x^3+1;
m=subs(f,x,a)+subs(f,x,b);
for i=1:n-1
55
Dr. Maan A. Rasheed Numerical Analysis
d=a+i*h;
g=g+2*subs(f,x,d);
end
T=(h/2)*(m+g);
fprintf('I=%f',T);
I=1.250156
Simpson method
Here, we set , which means
Thus, we get
56
Dr. Maan A. Rasheed Numerical Analysis
Remark:- We note that, if is polynomial of order less than or equal 3, then the
truncation error equal zero, which means:
Example: find the approximate value of the following integral , using Simpson
method
Solution:
answer 1.25,
57
Dr. Maan A. Rasheed Numerical Analysis
where
1-Input a,b
4-
58
Dr. Maan A. Rasheed Numerical Analysis
Example:- Use Composite Simpson integral formula to find the value of the
following integral, consider n=4
solution
= 15.0375
H.W. Compare between the two absolute errors, those can arise from using
Simpson method with n=2 and 4, respectively, to find the approximate value
for the following integral:
59
Dr. Maan A. Rasheed Numerical Analysis
Next, we write dawn the Matlab Code for which can be used to find the following
integer using composite Simpson method, with .
I=1.25
60
Dr. Maan A. Rasheed Numerical Analysis
Note that
and that because is a polynomial of order three.
Exercises
Q2: Use Trapezoidal method, with n=1, and n=3 to find the approximate value of
the following integral, and find the absolute error in each case.
61