Resources » Articles/Knowledge Sharing » Computer & Technology

# understanding simpsons 1/3rd rule using Fortran for integration

 Posted Date: 12-Mar-2008 Last Updated: 12-Mar-2008 Category: Computer & Technology Author: ashish singh Member Level: Gold Points: 4

Numerical integration using simpsons 1/3rd rule

The general problem of Numerical Integration may be stated as follows. Given a set of data points (x0,y0),(x1,y1),(x2,y2)……….(xn,yn) of a function y=f(x), where f(x) is not known explicitly, it is required to compute the value of the definite integral.
Simpson`s 1/3 Rule is also used for solving Numerical Integration problem and it is also same as the Trepezoisdal Rule including some differences.
In Simpson`s 1/3 Rule the value of dependent variable i.e. y0,y1,y2….. yn which are actually the functional value of independent variablex0,x1,x2……..xn which are increases by h in every step.
After creating table of using following formula we can solve the given Numerical Integation problem.
I=(h*(y0+4(y1+y3+y5…………)+2*(y2+y4+y6……….)+yn))/3

The required condirion for this rule is n must be multiple of 3 where n is number of strips.

Fortran Program for Simpson`s 1/3-Rule :

C PROGRAM FOR SIMPSON'S 1/3 RULE
FUNTION F(X)
F=1/(1+X)
RETURN
END
WRITE(*,*)'ENTER UPPER AND LOWER LIMIT'
WRITE(*,*)'ENTER THE NUMBER OF INTERVALS'
H=(B-A)/N
SUM=F(A)+F(B)
D=4
DO 5 I=1,N-1
X=A+I*H
SUM=SUM+D*F(X)
D=6-D
5 CONTINUE
S=H/3*SUM
WRITE(*,*)'INTEGRAL=',S
END

Output

SIMPSON’S 1/3 RULE

D:\FORTRAN\BINB>FL SIMP13.FOR
Microsoft (R) FORTRAN Optimizing Compiler Version 5.10

SIMP13.FOR

Microsoft (R) Segmented-Executable Linker Version 5.15

Object Modules [.OBJ]: SIMP13.OBJ
Run File [SIMP13.exe]: SIMP13.EXE
List File [NUL.MAP]: NUL
Libraries [.LIB]:
Definitions File [NUL.DEF]: ;

D:\FORTRAN\BINB>SIMP13
ENTER UPPER AND LOWER LIMIT
0
5
ENTER THE NUMBER OF INTERVALS
10
INTEGRAL= 1.793170

D:\FORTRAN\BINB>SIMP13
ENTER UPPER AND LOWER LIMIT
0
4
ENTER THE NUMBER OF INTERVALS
9
INTEGRAL= 1.579433

Did you like this resource? Share it with your friends and show your love!

Responses to "understanding simpsons 1/3rd rule using Fortran for integration"

No responses found. Be the first to respond...

Feedbacks

## Post Comment:

• Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
• No HTML formatting and links to other web sites are allowed.
• This is a strictly moderated site. Absolutely no spam allowed.
•  Name: Sign In to fill automatically. Email: (Will not be published, but required to validate comment) Type the numbers and letters shown on the left.