Trailing-Edge
-
PDP-10 Archives
-
decus_20tap1_198111
-
decus/20-0020/fnzero.clc
There are 2 other files named fnzero.clc in the archive. Click here to see a list.
100' NAME--FNZERO
110'
120' DESCRIPTION--FINDS A ZERO OF A SPECIFIED FUNCTION IN THE
130' INTERVAL (A,B). SIX SIGNIFICANT FIGURES ARE FOUND FOR ZERO.
140'
150' SOURCE--UNKNOWN
160'
170' INSTRUCTIONS--USER SUPPLIES:
180' 270 DEF FNF(Z) = ......
190' 380 DATA A,B
200' USER IS RESPONSIBLE TO CHECK THAT FNF IS WELL DEFINED
210' IN THE INTERVAL, WITHOUT EXCEEDING THE SIZE OF THE NUMBERS
220' ALLOWED IN THE COMPUTER.
230'
240'
250' * * * * * * MAIN PROGRAM * * * * * * * * * * *
260'
270 DEF FNF(Z) = EXP(Z*Z) - 1.001
280 READ A,B
290 LET L = B-A
300 LET X = A
310 IF FNF(X) = 0 THEN 510
320 LET X = B
330 IF FNF(X) = 0 THEN 510
340 LET S = SGN(FNF(A))
350 FOR I = 1 TO 1000
360 LET X = A + RND*L
370 IF S + SGN(FNF(X)) = 0 THEN 420
380 DATA -1,1
390 NEXT I
400 PRINT "NO ZERO FOUND."
410 STOP
420 LET X(1+S) = A
430 LET X(1-S) = X
440 LET F(1+S) = FNF(A)
450 LET F(1-S) = FNF(X)
460 LET D = ABS(X(0)-X(2))
470 IF D/(ABS(X(0))+ABS(X(2))) < 5E-7 THEN 510
480 LET X = (X(0)+X(2))/2
490 LET F = FNF(X)
500 IF F <> 0 THEN 530
510 PRINT "ONE ZERO AT " X
520 STOP
530 LET X(1+SGN(F)) = X
540 LET F(1+SGN(F)) = F
550 GOTO 460
560END