Chapter:
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:
Start
Define function f(x)
Read lower limit of integration, upper limit of integration and number of sub interval
Calculate: step size = (upper limit - lower limit)/number of sub interval
Set: integration value = f(lower limit) + f(upper limit)
Set: i = 1
If i > number of sub interval then goto
Calculate: k = lower limit + i * h
If i mod 3 =0 then
Integration value = Integration Value + 2* f(k)
Otherwise Integration Value = Integration Value + 3 * f(k)
Increment i by 1 i.e. i = i+1 and go to step 7
Calculate: Integration value = Integration value * step size*3/8
Display Integration value as required answer
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).
Guest