Lab Report 8
Lab Report 8
Name of the Experiment:MATLAB program for trapezoidal rule, Simpsons 1/3 rule and Simpsons 3/8 rule.
Objectives:Objectives if this experiment are1. To perform numerical integration using different methods .
2. To compare the accuracy of those methods.
Theory:Numerical integration is one of the most useful mathematical tools used in different
sectors of our work field. The general problem of numerical integration may be stated as
follows- Given a set of data points (x 0, y0), (x1, y1), .(xn, yn) of a function y = f(x), where
f(x) is not known explicitly, it is required to compute the value of the definite integralb
I = y dx
a
Which can be treated as the area under the curve y=f(x) enclosed between the limits
x=ax=b . This is the basic theme of integration. There are various techniques of
numerical integration among which 3 techniques are described briefly belowTrapezoidal rule:Trapezoidal rule is the simplest forms of numerical integration which works with
two data points taken at a time. Those points are joined as a straight line which forms
trapezoidal and area under those points are measured. Then next two data points are taken
and same procedures are applied. The general integral form i.e. the area under all the data
points can be difined by the following eqationS= ( f1/2 + f2 + f3 + ..+ fn+1)*h
where h is the distance between two data points.
Using this equation we will get the value of the integral.
Simpsons 1/3 rule:Simpsons 1/3 rule is a popular numerical integration technique. It is based on
approximating the function f(x) by fitting the quadratics through sets of three points. A
parabolla is formed due to joining three points. All the points are joined in this way and the
area under the data points are measured by the following equation-
clc
clear all
n=input('total data - 1 = ');
for i= 1:(n+1)
x(i)=input('x= ');
y(i)=input('y= ');
end
h= x(2)-x(1);
s=(y(1)+y(n+1))/2;
for j= 2:n
s=s+y(j);
end
integral= s*h
Output:total data - 1 = 4
x= .25
y= .2474
x= .26
y= .2571
x= .27
y= .2667
x= .28
y= .2764
x= .29
y= .2860
integral =
0.0107
Output:total data - 1 = 4
x= .25
y= .2474
x= .26
y= .2571
x= .27
y= .2667
x= .28
y= .2764
x= .29
y= .2860
integral =
0.0107
integral= s*(3*h/8)
Output:-
total data-1 = 8
x= 0
y= 1
x= .125
y= .8889
x= .25
y= .8
x= .375
y= .7273
x= .5
y= .6667
x= .625
y= .6154
x= .75
y= .5714
x= .875
y= .533
x= 1
y= .5
integral =
0.6848
Conclusion:From the above discussion and program we can say that without knowing the
functions we can find out the integral of a set of data points. Above three numerical technique
Simpsons 1/3 rule gives more accurate result than the others. Though here the result using
trapezoidal and Simpsons 1/3 rule is same but the previous statement will be easily visible if
the number of data points is more.