Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

EXPERIMENT # 11

SIMPSON’S RULE
AZEEM SHAN
70140626
TITLE:
Numerical Integration using Simpson's Rule in MATLAB.

OBJECTIVE:
The aim of this MATLAB experiment is to showcase the practical application of Simpson's Rule in
numerical integration. The primary objective is to estimate the definite integral of a provided
function over a defined interval. This is achieved by subdividing the interval into smaller
subintervals and employing the Simpson's Rule formula to compute the integral approximation.
THEORY:
In numerical analysis, Simpson's 1/3 rule is a method for numerical integration, the numerical
approximation of definite integrals. Specifically, it is the following approximation for n+1 values x0…….xn
bounding n equally spaced sub intervals.

FORMULA:

n must be even for applying Simpson’s 1/3 rule


CODE:
% Formula:(h/3)*[(y0+yn)+4*(y1+y3+y5..+yn-1)+ 2*(y2+y4+y6..+yn-2)]
% clc clear all f=@(x) 1/(1 + x^4);
a=input('Enter the value of lower limit=');
b=input('Enter the value of upper limit=');
n=input('Enter the number of sub-
intervals='); h=(b-a)/n; if rem(n,2)==1
fprintf('\n Enter a valid value of n!!!!!!');
n=input('\n Enter n as even number'); end for
k=1:1:n x(k)=a+k*h; y(k)=f(x(k)); end so=0;
se=0; for k=1:1:n-1 if rem(k,2)==1
so=so+y(k); else se=se+y(k); end
end answer=h/3*(f(a)+f(b)+4*so+2*se); fprintf('\n
The value of integration is %f', answer)

RESULT:

WORKSPACE:
CONCLUSION:
Simpson's Rule, characterized by its quadratic interpolation approach, emerges as a powerful
technique for estimating definite integrals. The method involves dividing the interval into
subintervals and utilizing a weighted sum of function values for accurate approximation. This
numerical integration method finds diverse applications in engineering, statistics, and
mathematical modeling, demonstrating its versatility and reliability in addressing real-world
problems.

You might also like