Chapter:

simpson-3-8-method

1. TO APPROXIMATE DEFINITE INTEGRAL OF A CONTINUOUS FUNCTION USING SIMPSONS METHOD

TITLE: 

TO APPROXIMATE DEFINITE INTEGRAL OF A CONTINUOUS FUNCTION USING SIMPSONS METHOD

 OBJECTIVES:

  • To be able to follow the algorithm of Simpson's  method of approximating definite integral of a continuous function

  • To build some programming concepts by solving practical problems.

 TOOLS REQUIRED:

  • Computer workstation

  • Program software (as necessary)

 THEORY:

Simpson's 3/8 rule (method) is a technique for approximating definite integral of a continuous function.

This method is based on Newton's Cote Quadrature Formula and Simpson 3/8 rule is obtained when we put value of n = 3 in this formula.

 ALGORITHM:

  1. Start

  2.  Define function f(x)

  3. Read lower limit of integration, upper limit of  integration and number of sub interval

  4.  Calculate: step size = (upper limit - lower limit)/number of sub interval

  5.  Set: integration value = f(lower limit) + f(upper limit)

  6.  Set: i = 1

  7.  If i > number of sub interval then goto 

  8.  Calculate: k = lower limit + i * h

  9.  If i mod 3 =0 then 

    1.  Integration value = Integration Value + 2* f(k)

    2.   Otherwise  Integration Value = Integration Value + 3 * f(k)

  10.  Increment i by 1 i.e. i = i+1 and go to step 7

  11.  Calculate: Integration value = Integration value * step size*3/8 

  12.  Display Integration value as required answer

  13.  Stop

 C-PROGRAM:   



//Simpson 3/8 Method
#include
#include
#include
#define f(x) 1/(1+x*x)
void main()
{
 float lower, upper, integration=0.0, stepSize, k;
 int i, subInterval;
 clrscr();
 printf("Enter lower limit of integration: ");
 scanf("%f", &lower);
 printf("Enter upper limit of integration: ");
 scanf("%f", &upper);
 printf("Enter number of sub intervals: ");
 scanf("%d", &subInterval);
 stepSize = (upper - lower)/subInterval;
 integration = f(lower) + f(upper);
 for(i=1; i<= subInterval-1; i++)
 {
  k = lower + i*stepSize;
  if(i%3 == 0)
  {
   integration = integration + 2 * f(k);
  }
  else
  {
   integration = integration + 3 * f(k);
  }
 }
 integration = integration * stepSize*3/8;
 printf("\nRequired value of integration is: %.3f", integration);
 getch();
 }

CONCLUSION:

Thus the definite integral of a continuous function was approximated using Simpson's 3/8 Rule (Method).

Show More