You are on page 1of 4

30-08-2016, r1

Subject: Fortran Code for Numerical Integration

Dear Sir/Madam,

I am appending an article Fortran Code for Numerical Integration. it is based on the Simpsons
formula. It is an open source code developed by me and has not been covered under copy right
laws.

As a sample, I am sending a PDF file for Double Integral. I have developed codes up to 8th
integration. Double integral has 9 functions and code needs two pages where as 8th integral has
6561 functions and will need about 280 pages. Codes have been successively run up to 7th order.
The execution completes in few seconds and accuracy of results has been excellent. Necessary
conditions can be inserted in the program according to function.

Interested parties may send me a request for commercial dealings for 3rd to 8th order integration.

Thanks,

N.T.Dadlani

nanak.dadlani@gmail.com
Fortran codes for Numerical Integration
Edition-1, 2016

Applied research series


Based on Simpson formula:
- double integration 9 functions
- triple integration
- 4th order integration
- 5th integration
- 6th integration
- 7th integration 2187 functions
- 8th integration . 6561 functions

Codes are in Fortran-77. Tested up to 7th integration.

N. T. Dadlani
nanak.dadlani@gmail.com

30-08-2016, r1
INTEG2A
C INTEG2.FOR (18-04-2016)
C
C Ref:- Numerical methods in Fortran
C J.M.McCormick and M.G.Salvadori
C
C DOUBLE INTEGRAL
C
DIMENSION SUMM(10)
C WRITE(*,*)'NUMX,NUMY,XA ,XB ,YA , YB '
C WRITE(*,*)' 1 , 1 ,0 , 1 , 0 , 2'
C WRITE(*,*)
C1 READ (*,*) NUMX,NUMY,XA,XB,YA,YB
C WRITE(*,*)
C
NUMX=1
NUMY=1
XA=0.
XB=1.
YA=0.
YB=1.
C
PRINT 998, NUMX,NUMY,XA,XB,YA,YB
C
DO 200 K=1,4
NUMMX=NUMX*K
NUMMY=NUMY*K
C
XSTRIP=2.*NUMMX
YSTRIP=2.*NUMMY
C
C
XH=(XB-XA)/XSTRIP
YH=(YB-YA)/YSTRIP
C
C
SUM=0.0
C
X1=XA
X2=X1+XH
X3=X2+XH
C
DO 100 I=1,NUMMX
Y1=YA
Y2=Y1+YH
Y3=Y2+YH
C
DO 90 M=1,NUMMY
C
F1=F(X1,Y1)
F2=F(X2,Y1)
F3=F(X3,Y1)
C
F4 =F(X1,Y2)
F5 =F(X2,Y2)
F6 =F(X3,Y2)
C
F7 =F(X1,Y3)
F8 =F(X2,Y3)
F9 =F(X3,Y3)
C
FF1=F1+F3+F7+F9
FF2=F2+F4+F6+F8
FF3=F5
C
SUM=SUM+(XH*YH/9.)*(FF1 +4.*FF2 +16.*FF3)
C
Y1=Y3
Y2=Y1+YH
90 Y3=Y2+YH
C
Page 1
INTEG2A
X1=X3
X2=X1+XH
100 X3=X2+XH
C
PRINT 997,K,XH,YH,SUM
C
200 SUMM(K)=SUM
C INTRODUCE STATEMENT "GO TO 1" TO SEE VARIOUS OUTPUTS BY
C CHANGING INPUT VALUES
C
C GO TO 1
C
997 FORMAT (I18,2F10.5,E17.7)
998 FORMAT (//23X,26HRESULTS FROM PROGRAM 9.9A
$ //25X,21HLIMITS OF INTEGRATION
$ / 16X,7HNUMX = ,I4,4X,7HNUMY = ,I4
$ /16X,4HXA = ,E14.7,4X,4HXB = ,E14.7 / 16X,4HYA = ,E14.7,
$ 4X,4HYB = ,E14.7/
$ //17X,1HK ,6X,2HXH ,8X,2HYH ,8X,8HINTEGRAL)
C
C
END
C EX1
C LIMITS XA=0,XB=1
C YA=0,YB=2
C NUMX=1,NUMY=1
C I=3.684 MATHCAD (PROGRAM ..I=3.6834)
C
C FUNCTION F(X,Y)
C F=EXP(X*Y)
C RETURN
C END
C
C Ex-5
C Limits: XA=0, XB=1., YA=0 ,YB=1.
C NUMX=1, NUMY=1
C I= 1.167 ..Mathcad (I= ,K=4)
FUNCTION F(X,Y)
F=(X+Y)**2
RETURN
END
C
C

Page 2