Simpson 1/3 Method
Simpson 1/3 Method
THEORY:
Simpson’s rule is one of the numerical methods which is used to evaluate the definite integral.
Usually, to find the definite integral
Xi=X0+ih
X1=X0+h
X2=X0+2h
Xn
……. Xn = X0 + n ∫ F ( x ) dx=∫ Pn ( x ) dx
X0
∫ [ Pn ( x ) dx+¿ En ( x ) ] dx ¿
X0
Take In=∫ Pn ( x ) dx
X0
Xn n
Now we will solve this ∫ Pn ( x ) dx=∫∑ (F ( xi ) ¿ Li ( x ))dx ¿
X0 i=1
∑ ¿¿
i=1
n
Take ¥=∫ Li (x )¿ dx ¿ ∑∫¿¿¿
i=1
X=X0+sh
Li(x)=sh
X-X1=X-X0-h
=h(s-1)
X-X2=h(s-2)
Similarly, X-Xn=h(s-n)
Now,
1) TRAPEZOIDAL RULE
1
I =∑ f ( Xi)¥ i
0
I = F(X0)¥0+F(X1)¥1
I = h/2[F(x0)+F(x1)]
We will use same above equation and repeat the process as in trapezoidal method,
In , for n =2
I2 = F(x0)¥0+F(X1)¥1+F(X2)¥2
=4h/3
2 s ( s−1 )
¥2 =∫ hds ¿
2
0
¿
=h/3
h
Is1/3 = [f(X0)+4F(X1)+F(X2)]
3
PROGRAM:
#include<iostream>
#include<math.h>
int main()
int i, subInterval;
/* Input */
cin>>lower;
cin>>upper;
/* Calculation */
k = lower + i*stepSize;
if(i%2==0)
else {
return 0;
Output: