IDENTIFICATION DIVISION.
PROGRAM-ID. 	SIMPSON.
AUTHOR.		ALEJANDRO ALONSO.
DATE-WRITTEN. 	6-9-87.
REMARKS.
	RESOLUCION DE INTEGRALES DEFINIDAS POREL METODO DE SIMPSON.
ENVIRONMENT DIVISION.
DATA DIVISION.
	WORKING STORAGE SECTION.
	77	EXTREMO-INF	PIC	S9(4)V9(4).
	77 	EXTREMO-SUP	PIC	S9(4)V9(4).
	77 	INTERVALOS	PIC	 9(4).
	77	SUBINTERVALOS	PIC	 9(4).
	77	H		PIC	 9(4)V9(4).
	77	PASO		PIC	 9(4)V9(4).
	77	Y0		PIC	S9(4)V9(4).
	77	Y1		PIC	S9(4)V9(4).
	77	Y		PIC	S9(4)V9(4).
	77	X		PIC	S9(4)V9(4).
	01	SUMA		PIC	S9(4)V9(4) VALUE ZERO.
	01	INTEGRAL	PIC	++++9.9(4) REDEFINES SUMA.

PROCEDURE DIVISION.
CUERPO.
	DISPLAY 'Extremo inferior".
	ACCEPT EXTREMO-INF.
	DISPLAY 'Extremo superior".
	ACCEPT EXTREMO-SUP.
	DISPLAY 'Intervalos".
	ACCEPT INTERVALOS.
	COMPUTE SUBINTERVALOS = 2 * INTERVALOS.
	COMPUTE H = (EXTREMO-SUP - EXTREMO-INF) / SUBINTERVALOS.
	COMPUTE PASO = H * 2.
	PERFORM PROCESO.
		VARYING INDICE FROM EXTREMO-INF BY PASO
		UNTIL INDICE > EXTREMO-SUP - PASO.
	DISPLAY 'VALOR DE LA INTEGRAL' INTEGRAL.
	STOP RUN.

PROCESO.
	MOVE INDICE TO X.
	PERFORM FUNCION.
	MOVE Y TO Y0.
	COMPUTE X = INDICE + H.
	PERFORM FUNCION.
	MOVE Y TO Y1.
	COMPUTE X = INDICE + 2 * H.
	PERFORM FUNCION.
	COMPUTE SUMA = SUMA + H * (Y0 + 4 * y1 + y) /3.

FUNCION.
	COMPUTE Y = X * X.
