PROGRAM NULFIT
C FITS A STRAIGHT LINE OF TYPE Y = A.X TO (X,Y) DATA PAIRS
REAL A,B,SUMX,SUMXY,SUMXX,SLOPE,SUM,DIFF,ERROR2,ERROR
INTEGER I,J
DIMENSION X(200),Y(200)
DATA I,SUMX,SUMXY,SUMXX,SUM / 0,0.0,0.0,0.0,0.0 /
OPEN (UNIT=7, FILE='iris.dat', STATUS='OLD')
10 READ (7,*,END=12) A, B
I = I + 1
X(I) = A
Y(I) = B
GOTO 10
12 DO 13 J=1,I
SUMX = SUMX + X(J)
SUMXY = SUMXY + (X(J)*Y(J))
SUMXX = SUMXX + (X(J)*X(J))
13 CONTINUE
SLOPE = SUMXY/SUMXX
DO 14 J=1,I
SUM = SUM + ((Y(J) - (SLOPE*X(J)))**2)
14 CONTINUE
DIFF = SUMXX
ERROR2 = SUM/DIFF
ERROR = SQRT(ERROR2)
WRITE (6,15) SLOPE, ERROR
15 FORMAT (1X,' A = ',F6.3,' +- ',F6.3)
STOP
END