Google
 

Trailing-Edge - PDP-10 Archives - decus_20tap1_198111 - decus/20-0020/greint.clc
There are 2 other files named greint.clc in the archive. Click here to see a list.
100'  NAME--GREGRY
110'
120'  DESCRIPTION--APPLIES GREGORY'S METHOD OF INTEGRATION.
130'
140'  SOURCE--UNKNOWN
150'
160'  INSTRUCTIONS--THE FUNCTION IS DEFINED IN LINE 240.
170'  THE LOWER LIMIT, THE UPPER LIMIT, THE INITIAL NUMBER OF
180'  SUBINTERVALS, THE MAXIMUM ORDER OF CORRECTION, AND
190'  REL. TOLERANCE REQUIRED ARE ENTERED AS DATA IN LINE 980.
200'
210'
220'  *  *  *  *  *  *  MAIN PROGRAM  *  *  *  *  *  *   *  *  *
230'
240 DEF FNF(Z) = 2/(1+Z*Z)
250 READ A, B, N, K, E
260 IF K <= 5 THEN 290
270 PRINT "K CANNOT EXCEED 5, SO IT IS BEING SET TO 5."
280 LET K = 5
290 IF N >= 10 THEN 320
300 PRINT "N MUST BE AT LEAST 10, SO IS BEING SET TO 10."
310 LET N = 10
320 LET H = (B - A)/N
330 LET T1 = FNF(A)
340 LET T2 = FNF(B)
350 LET F(0,0) = T1
360 LET B(0,0) = T2
370 LET S = 0
380 FOR I = 1 TO 5
390 LET T3 = FNF(A + I*H)
400 LET F(0,I) = T3
410 LET S = S + T3
420 NEXT I
430 LET S = S - FNF(A + 5*H)
440 FOR I = 5 TO N-6
450 LET S = S + FNF(A + I*H)
460 NEXT I
470 FOR I = N-5 TO N-1
480 LET T3 = FNF(A + I*H)
490 LET S = S + T3
500 LET B(0, N-I) = T3
510 NEXT I
520 LET T = ((T1 + T2)/2 + S)/N
530 GOTO 740
540 LET F(0,4) = F(0,2)
550 LET F(0,2) = F(0,1)
560 LET B(0,4) = B(0,2)
570 LET B(0,2) = B(0,1)
580 LET S1 = 0
590 FOR I = 1 TO 5 STEP 2
600 LET T1 = FNF(A + I*H)
610 LET F(0,I) = T1
620 LET S1 = S1 + T1
630 NEXT I
640 FOR I = 7 TO N-7 STEP 2
650 LET S1 = S1 + FNF(A + I*H)
660 NEXT I
670 FOR I = N-5 TON-1 STEP 2
680 LET T1 = FNF(A + I*H)
690 LET S1 = S1 + T1
700 LET B(0,N-I) = T1
710 NEXT I
720 LET T = T/2 + S1/N
730 GOTO 740
740 FOR I = 1 TO K
750 FOR J = 0 TO K-I
760 LET F (I,J) = F(I-1,J+1) - F(I-1,J)
770 LET B (I,J) = B(I-1,J) - B(I-1,J+1)
780 NEXT J
790 NEXT I
800 LET W = T*(B - A)
810 IF K < 1 THEN 970
820 FOR I = 1 TO K
830 LET S7 = -1
840 IF I <> INT(I/2)*2 THEN 860
850 LET S7 = 1
860 LET C = A(I) * H * ( B(I,0) + S7 * F(I,0) )
870 IF ABS(C/W) < E THEN 930
880 LET W = W + C
890 NEXT I
900 LET N = 2*N
910 LET H = H/2
920 GOTO 540
930 LET W = W + C
940 PRINT "TO WITHIN A RELATIVE ERROR OF" ; E
950 PRINT "THE ANSWER IS" ; W
960 STOP
970 PRINT "ANSWER WITH NO CORRECTION IS"; W
980 DATA -1, 1, 10, 5, 1E-8
990 END