0% found this document useful (0 votes)
18 views7 pages

Simpson 1/3 Method

To find the root of a polynomial using Simpson 1/3 method

Uploaded by

vbiswal19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views7 pages

Simpson 1/3 Method

To find the root of a polynomial using Simpson 1/3 method

Uploaded by

vbiswal19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

AIM: To integrate a function using Simpson’s 1/3 rule.

THEORY:

Simpson’s rule is one of the numerical methods which is used to evaluate the definite integral.
Usually, to find the definite integral

Let us consider Pn(x) be a interpolating polynomial. I n be the approximate value of integration


and EIn be the error term.
n n n
( X− Xi)
¿=∑ F ( xi ) Li ( x )=∑ F ( xi) ∏ ¿ ¿ ¿)
Pn(x i=1 i=1 k=0
k≠
¿
i

Here F(x) is any function between a and b

And n is equally spaced interval


Xn

We need to find out ∫ F ( x ) dx


X0

Xi=X0+ih

X1=X0+h

X2=X0+2h
Xn

……. Xn = X0 + n ∫ F ( x ) dx=∫ Pn ( x ) dx
X0

Here we need to add a error term


Xn

∫ [ Pn ( x ) dx+¿ En ( x ) ] dx ¿
X0

Since EIn is very very small as compared to In , so I≈In


Xn

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)

Li(x)= (s)h(s-1)h(s-2)h………(s-i+1)h(s-i-1)h…….(s-n)h / (i)h(i-1)h…….(1)h(-1)h……(i-n)h

Li(x)= (s)(s-1)(s-2)h………(s-i+1)(s-i-1)…….(s-n) / (i)(i-1)…….(1)(-1)……(i-n)

Li(x)= (s)(s-1)(s-2)h………(s-i+1)(s-i-1)…….(s-n) /(-1)^n-1 i!(n-1)!

Now,

1) TRAPEZOIDAL RULE
1
I =∑ f ( Xi)¥ i
0

I = F(X0)¥0+F(X1)¥1

From the above equation of ¥ we can find ¥0 and ¥1

Hence ¥0=h/2 and ¥1=h/2

I = h/2[F(x0)+F(x1)]

2) SIMPSON 1/3 RULE

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

From above ¥ equation


2 ( s−1 )( s−2 )
¥0 =∫ hds ¿
2
0
¿
¥0=h/3
2 s ( s−2 )
¥1=∫ −1 hds ¿
0
¿

=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>

/* Define function here */

#define f(x) 1/(1+pow(x,1))

using namespace std;

int main()

float lower, upper, integration=0.0, stepSize, k;

int i, subInterval;

/* Input */

cout<<"Enter lower limit of integration: ";

cin>>lower;

cout<<"Enter upper limit of integration: ";

cin>>upper;

cout<<"Enter number of sub intervals: ";


cin>>subInterval;

/* Calculation */

/* Finding step size */

stepSize = (upper - lower)/subInterval;

/* Finding Integration Value */

integration = f(lower) + f(upper);

for(i=1; i<= subInterval-1; i++)

k = lower + i*stepSize;

if(i%2==0)

integration = integration + 2 * (f(k));

else {

integration = integration + 4 * (f(k));

integration = integration * stepSize/3;

cout<< endl <<"Required value of integration is: "<< integration;

return 0;

Output:

Enter lower limit of integration: 1

Enter upper limit of integration: 5


Enter number of sub intervals: 10

Required value of integration is: 1.09866

You might also like