# PCjs Machines

Home of the original IBM PC emulator for browsers.

## PC-SIG Diskette Library (Disk #180)

[PCjs Machine "ibm5150"]

Waiting for machine "ibm5150" to load....

## Information about “MATH AND STATISTICS”

``````This collection of math and financial analytical tools, intended
for the professional or student, or anyone interested in math
or statistics, represents an outstanding ``living laboratory'' for
studying applied BASIC source code in those areas of endeavor. A great
opportunity to take it apart and see what makes it tick.
File Descriptions:

M1       BAS  Greatest common denominator.
DATANET       DATANET network sampler.
M2       BAS  Prime factors of integers.
M4       BAS  Analysis of two vectors.
M3       BAS  Area of polygon.
M5       BAS  Parts of a triangle.
M6       BAS  Operations on two vectors.
M7       BAS  Coordinate conversion.
M8       BAS  Coordinate plot.
M10      BAS  Plot of polar equation.
M9       BAS  Angle conversion.
M12      BAS  Linear interpolation.
M11      BAS  Plot of function.
M14      BAS  Integration: Simpson's rule.
M13      BAS  Curvilinear interpolation.
M18      BAS  Roots of quadratic equation.
M16      BAS  Integration: Trapezoidal rule.
M17      BAS  Derivative.
M26      BAS  Matrix inversion.
M25      BAS  Matrix multiplication.
M24      BAS  Matrix add, subtract and scalar multiplication.
M23      BAS  Linear programming.
M22      BAS  Simultaneous equations.
M21      BAS  Trig polynomial.
M20      BAS  Roots of polynomials: half interval sear.
M19      BAS  Real roots of polynomials: Newton.
MATH     BAS  Menu for above math programs.
NCCLSPRE BAS  Calculates a sample's precision.
MATRIX   BAS  Solves simultaneous equations.
S2       BAS  Mann-Whitney U test.
S1       BAS  Permutations and combinations.
REGRESS  BAS  Regression analysis.
NORMAL-Z BAS  Normal distribution routines.
S6       BAS  Normal distribution.
S5       BAS  Poisson distribution.
S4       BAS  Binomial distribution.
S3       BAS  Geometric mean and deviation.
S8       BAS  Chi-square test.
S7       BAS  Chi-square distribution.
S10      BAS  Student's T test.
S9       BAS  Student's T distribution.
S12      BAS  Linear correlation coefficient.
S11      BAS  F-distribution.
S16      BAS  Geometric regression.
S15      BAS  Nth order regression.
S14      BAS  Linear regression.
S13      BAS  Multiple linear regression.
S17      BAS  Exponential regression.
S18      BAS  Mean, variance, standard deviation.
STAT     BAS  Menu for above S**.BAS statistics programs.
``````

## CRC.TXT

``````PC-SIG Disk No. #180, version v1

The following is a list of the file checksums which should be produced by
the CRCK4 program on disk #9 (and others).  If the CRC numbers do not match
you may have a bad file.  To use type:  CRCK4 <filespec>

CRCK4 output for this disk:

CRCK ver 4.2B (MS DOS VERSION )
CTL-S pauses, CTL-C aborts

--> FILE:  DATANET .            CRC = 56 19

--> FILE:  M1      .BAS         CRC = 52 E4

--> FILE:  M10     .BAS         CRC = 48 15

--> FILE:  M11     .BAS         CRC = 4A FA

--> FILE:  M12     .BAS         CRC = 93 36

--> FILE:  M13     .BAS         CRC = 40 E9

--> FILE:  M14     .BAS         CRC = 77 85

--> FILE:  M15     .BAS         CRC = 3D 2D

--> FILE:  M16     .BAS         CRC = 9E 3E

--> FILE:  M17     .BAS         CRC = 7C B6

--> FILE:  M18     .BAS         CRC = 9E A3

--> FILE:  M19     .BAS         CRC = CD 53

--> FILE:  M2      .BAS         CRC = CD 22

--> FILE:  M20     .BAS         CRC = 57 0A

--> FILE:  M21     .BAS         CRC = 0F 8D

--> FILE:  M22     .BAS         CRC = EB B9

--> FILE:  M23     .BAS         CRC = C0 9E

--> FILE:  M24     .BAS         CRC = 3D B4

--> FILE:  M25     .BAS         CRC = 0D A5

--> FILE:  M26     .BAS         CRC = 05 8C

--> FILE:  M3      .BAS         CRC = 1A 35

--> FILE:  M4      .BAS         CRC = A6 F3

--> FILE:  M5      .BAS         CRC = E5 B8

--> FILE:  M6      .BAS         CRC = 3F 3A

--> FILE:  M7      .BAS         CRC = AD F7

--> FILE:  M8      .BAS         CRC = 5A 3D

--> FILE:  M9      .BAS         CRC = 12 BF

--> FILE:  MATH    .BAS         CRC = A0 C1

--> FILE:  MATRIX  .BAS         CRC = B6 CC

--> FILE:  NCCLSPRE.BAS         CRC = 48 BC

--> FILE:  NORMAL-Z.BAS         CRC = 45 A8

--> FILE:  REGRESS .BAS         CRC = 94 D5

--> FILE:  S1      .BAS         CRC = 5B 79

--> FILE:  S10     .BAS         CRC = 85 62

--> FILE:  S11     .BAS         CRC = A1 EE

--> FILE:  S12     .BAS         CRC = 9C BF

--> FILE:  S13     .BAS         CRC = ED 30

--> FILE:  S14     .BAS         CRC = 46 91

--> FILE:  S15     .BAS         CRC = CC 61

--> FILE:  S16     .BAS         CRC = 37 EC

--> FILE:  S17     .BAS         CRC = 2D 6A

--> FILE:  S18     .BAS         CRC = 03 73

--> FILE:  S2      .BAS         CRC = C6 B5

--> FILE:  S3      .BAS         CRC = 8C A7

--> FILE:  S4      .BAS         CRC = 18 52

--> FILE:  S5      .BAS         CRC = 98 5E

--> FILE:  S6      .BAS         CRC = F7 2E

--> FILE:  S7      .BAS         CRC = FC 87

--> FILE:  S8      .BAS         CRC = F6 22

--> FILE:  S9      .BAS         CRC = E2 95

--> FILE:  STAT    .BAS         CRC = 4B 17

--> FILE:  TRADENET.            CRC = C1 85

--> FILE:  XXX     .            CRC = 5D C0

---------------------> SUM OF CRCS = BB D6

DONE

These and other Public Domain and user-supported programs from:

PC Software Interest Group
1125 Stewart Ct  Suite G
Sunnyvale, CA 94086
(408) 730-9291
``````

## M1.BAS

``````10 PRINT "GREATEST COMMON DENOMINATOR"
20 PRINT
30 PRINT "(ENTER 0,0 TO END PROGRAM)"
40 PRINT "ENTER TWO NUMBERS";
50 INPUT A,B
60 IF A <> 0  THEN  90
70 IF B <> 0   THEN 90
80 GOTO 190
90 A = ABS (A)
100 B = ABS (B)
110 R = A - B * INT (A/B)
120 IF R = 0  THEN 160
130 A = B
140 B = R
150 GOTO 110
160 PRINT "G.C.D: ";B
170 PRINT
180 GOTO  40
190 RUN "MATH"
``````

## M10.BAS

``````0 CLS:PRINT
10  PRINT "PLOT OF POLAR EQUATION"
20  PRINT
30  DIM X(91),Y(90)
40 N = 90
50  PRINT "ABSOLUTE VALUE OF ENDPOINTS";
60  INPUT Z
70  PRINT
80  PRINT "INCREMENT OF X-AXIS = ";Z / 30
90  PRINT "INCREMENT OF Y-AXIS = ";Z / 18
100  PRINT
110  FOR I = 1 TO N
120 D = 0.06981317 * I
130  REM  - ENTER FUNCTION HERE (F AS A FUNCTION OF D)
140 X(I) =  INT (((F *  COS (D) / Z + 1) * 30) + 0.5)
150 Y(I) =  INT ((( - F *  SIN (D) / Z + 1) * 18) + 0.5)
160  NEXT I
170  FOR J = 1 TO N
180  FOR I = 1 TO N - J
190 A = X(I)
200 B = Y(I)
210  IF B <  = Y(I + 1) THEN 260
220 X(I) = X(I + 1)
230 Y(I) = Y(I + 1)
240 X(I + 1) = A
250 Y(I + 1) = B
260  NEXT I
270  NEXT J
280 T = 1
290  FOR P = 0 TO N - 1
300  IF Y(P + 1) >  = 0 THEN 320
310  NEXT P
320  FOR I = 0 TO 36
330 T = T + P
340 P = 0
350  IF T > N THEN 370
360  IF Y(T) = I THEN 420
370  IF I = 18 THEN 400
380  PRINT  TAB( 30);"*";
390  GOTO 860
400 S = N + 1
410  GOTO 740
420  FOR L = T TO N
430  IF Y(L) > Y(T) THEN 460
440 P = P + 1
450  NEXT L
460  IF P = 1 THEN 560
470  FOR J = 1 TO P
480  FOR L = 1 TO P - J
490 C = X(T + L - 1)
500 A = X(T + L)
510  IF C <  = A + 0 THEN 540
520 X(T + L - 1) = A
530 X(T + L) = C
540  NEXT L
550  NEXT J
560  IF I = 18 THEN 730
570 L =  - 1
580 S = 0
590  FOR K = 0 TO P - 1
600  IF X(T + K) = L THEN 690
610 L = X(T + K)
620  IF L = 30 THEN 660
630  IF L < 30 THEN 670
640  IF S = 1 THEN 670
650  PRINT  TAB( 30);"*";
660 S = 1
670  IF L > 60 THEN 860
680  PRINT  TAB( L);"+";
690  NEXT K
700  IF S = 1 THEN 860
710  PRINT  TAB( 30);"*";
720  GOTO 860
730 S = T
740  FOR J = 0 TO 60
750  IF X(S) <  > J THEN 830
760  PRINT "+";
770  FOR K = S TO T + P - 1
780  IF X(K) = X(S) THEN 810
790 S = K
800  GOTO 840
810  NEXT K
820  GOTO 840
830  PRINT "*";
840  NEXT J
850  PRINT "X";
860  PRINT
870  NEXT I
880  PRINT  TAB( 30);"Y"
890  RUN "MATH"
``````

## M11.BAS

``````0 CLS:PRINT
10  PRINT "PLOT OF FUNCTIONS"
20  PRINT
30  DIM Y(9),A\$(11)
40  FOR I = 1 TO 11
60  NEXT I
70  PRINT "NUMBER OF FUNCTIONS TO BE PLOTTED";
80  INPUT N
90  PRINT "X-AXIS: LEFT ENDPOINT, RIGHT ENDPOINT, INCREMENT";
100  INPUT X1,X2,X3
110  PRINT "Y-AXIS: LOWER ENDPOINT, UPPER ENDPOINT, INCREMENT";
120  INPUT Y1,Y2,Y3
130 Y2 = (Y2 - Y1) / Y3
140  IF Y2 <  = 70 THEN 170
150  PRINT "Y-RANGE TOO LARGE"
160  GOTO 110
170  PRINT
180  PRINT
190  LPRINT "X-AXIS CROSSES Y-AXIS AT Y=";Y1
200  LPRINT "Y-AXIS CROSSES X-AXIS AT X=";X1
210  LPRINT
220  FOR X = X1 TO X2 STEP X3
221  REM  - FUNCTIONS Y(1) TO Y(9) SHOULD BE ENTERED AT INES 221 TO 229
230  FOR I = 1 TO N
240 Y(I) =  INT ((Y(I) - Y1) / Y3 + 0.5)
250  NEXT I
260  FOR I = 0 TO Y2
270 S = 0
280  FOR J = 1 TO N
290  IF Y(J) <  > I THEN 320
300 S = S + 1
310 T = J
320  NEXT J
330  IF S > 0 THEN 360
340  LPRINT A\$( SGN (I) + 10);
350  GOTO 400
360  IF S > 1 THEN 390
370  LPRINT A\$(T);
380  GOTO 400
390  LPRINT "*";
400  NEXT I
410  IF X > X1 THEN 430
420  LPRINT "Y";
430  LPRINT
440 A\$(11) = " "
450  NEXT X
460  LPRINT "X"
470  DATA  "1","2","3","4","5","6","7","8","9","+","+"
480  RUN "MATH"
``````

## M12.BAS

``````0 CLS:PRINT
10  PRINT "LINEAR INTERPOLATION"
20  PRINT
30  PRINT "X,Y OF FIRST POINT";
40  INPUT X1,Y1
50  PRINT "X,Y OF SECOND POINT";
60  INPUT X2,Y2
70  PRINT "INTERPOLATE: X= ";
80  INPUT X
90 Y = Y1 + (Y2 - Y1) / (X2 - X1) * (X - X1)
100  PRINT "             Y= "; INT (Y * 1000 + 0.5) / 1000
110  PRINT
120  PRINT "MORE POINTS ON THIS LINE (1=YES, 0=NO)";
130  INPUT Z
140  PRINT
150  IF Z = 1 THEN 70
160  PRINT "NEW LINE (1=YES,0=NO)";
170  INPUT Z
180  IF Z = 1 THEN 20
190  RUN "MATH"
``````

## M13.BAS

``````0 CLS:PRINT
10  PRINT "CURVILINEAR INTERPOLATION"
15  DIM X(50),Y(50)
20  PRINT
40  PRINT "NUMBER OF KNOWN POINTS";
50  INPUT P
60  FOR I = 1 TO P
70  PRINT "X,Y OF POINT";I;
80  INPUT X(I),Y(I)
90  NEXT I
100  PRINT
110  PRINT "INTERPOLATE: X = ";
120  INPUT A
130 B = 0
140  FOR J = 1 TO P
150 T = 1
160  FOR I = 1 TO P
170  IF I = J THEN 190
180 T = T * (A - X(I)) / (X(J) - X(I))
190  NEXT I
200 B = B + T * Y(J)
210  NEXT J
220  PRINT "             Y = ";B
230  PRINT
240  PRINT "MORE X ON THIS CURVE (1=YES, 0=NO)";
250  INPUT C
260  IF C = 1 THEN 100
270  PRINT "MORE X ON ANOTHER CURVE (1=YES, 0=NO)";
280  INPUT C
290  IF C = 1 THEN 20
300  RUN "MATH"
``````

## M14.BAS

``````0 CLS:PRINT
10  PRINT "INTEGRATION: SIMPSON'S RULE"
30  PRINT "SELECTION: 1=KNOWN FORMULA, 0=UNKNOWN FORMULA";
40  INPUT S
49 REM IF FUNCTION IS KNOW ENTER AT LINE 50 DEF FNC(X)='YOUR FUNCTION'
50  DEF FNC(X)=X
60  PRINT "LOWER, UPPER LIMIT OF INTEGRAION";
70  INPUT A,B
80  PRINT "INCREMENT OF X";
90  INPUT X1
95 VR = (B - A) / X1
100  IF VR <  >  INT (VR) THEN 80
110  IF S = 1 THEN 150
120  PRINT "FIRST, LAST VALUE OF F(X)";
130  INPUT Y1,Y2
140  GOTO 170
150 Y1 =  FNC(A)
160 Y2 =  FNC(B)
170 C = 0
180 D = 0
190  FOR I = 1 TO (B - A) / X1 - 0.5
200  IF S = 1 THEN 240
210  PRINT "VALUE OF F(X) AT INTERVAL ";I;" (X=";A + I * X1;")";
220  INPUT Y
230  GOTO 250
240 Y =  FNC(A + I * X1)
250  IF I / 2 =  INT (I / 2) THEN 280
260 C = C + Y
270  GOTO 290
280 D = D + Y
290  NEXT I
300  PRINT "INTEGRAL IS ";X1 / 3 * (Y1 + 4 * C + 2 * D + Y2)
305 INPUT "Run again (Y/N) ";A\$
307 IF A\$="Y" OR A\$="y" THEN 10
310  RUN "MATH"
``````

## M15.BAS

``````0 CLS:PRINT
20  PRINT
30 DEF FNC(X)=X^3:REM DEFINE FUNCTION HERE (DEFFNC(X)="FUNCTION")
40  DATA  .076526521,.15275339,.22778585,.14917299,.37370609
50  DATA  .14209611,.510867,.13168864,.6305368,.11819453
60  DATA  .74633191,.10193012,.83911697,.083276742,.91223443
70  DATA  .062672048,.96397183,.04060143,.9931286,.017614007
80  PRINT "INTEGRATION LIMITS (LOWER,UPPER)";
90  INPUT X,Y
100  PRINT "NUMBER OF INTERVALS";
110  INPUT N
120 S = (Y - X) / N / 2
130 T = X + S
140 R = 0
150  FOR I = 1 TO N
160 P = 0
170  FOR J = 1 TO 10
190 P = P + B * ( FNC(S * A + T) +  FNC(T - S * A))
200  NEXT J
210  RESTORE
220 R = R + P * S
230 T = T + 2 * S
240  NEXT I
250  PRINT "INTEGRAL = ";R
260  PRINT
270  PRINT "CHANGE DATA AND RECOMPUTE?"
280  PRINT "(0=NO,1=NEW INTEGRATION LIMITS, 2=NEW NO. OF INTERVALS)";
290  INPUT S
300  IF S = 1 THEN 80
310  IF S = 2 THEN 100
315 INPUT "Run again (Y/N) ";A\$
317 IF A\$="Y" OR A\$="y" THEN 10
320  RUN "MATH"
``````

## M16.BAS

``````0 CLS:PRINT
10  PRINT "INTEGRATION: TRAPEZOIDAL RULE"
20  PRINT
30  DEF  FNC(X) = X ^ 3
40  PRINT "(ENTER 0,0 TO END PROGRAM)"
50  PRINT "INTEGRATION LIMITS (LOWER, UPPER)";
60  INPUT A,B
70  IF A = B THEN 190
80  PRINT "NUMBER OF INTERVALS";
90  INPUT N
100 I = 0
110 D = (B - A) / N
120  FOR J = A TO B STEP D
130 I = I +  FNC(J)
140  NEXT J
150 I = (I - ( FNC (A) +  FNC(B)) / 2) * D
160  PRINT "INTEGRAL = ";I
170  PRINT
180  GOTO 50
190  RUN "MATH"
``````

## M17.BAS

``````0 CLS:PRINT
10  PRINT "DERIVATIVE"
20  PRINT
30 DEF FNC(X)=X^2+COS(X): REM  - ENTER DEFFNC(X) HERE
40  PRINT "(ENTER X=99999 TO END PROGRAM)"
50  INPUT "DERIVATIVE AT X=";X1
70  IF X1 = 99999! THEN 160
80 D = 0.0001
140  PRINT "                IS ";( FN C(X1 + D) -  FN C(X1)) / D
150  GOTO 50
160  RUN "MATH"
``````

## M18.BAS

``````0 CLS:PRINT
10  PRINT "ROOTS OF QUADRATIC EQUATIONS"
20  PRINT
30  PRINT "COEFFICIENTS A,B,C";
40  INPUT A,B,C
50 S = B ^ 2 - 4 * A * C
60 R =  SQR ( ABS (S))
70  IF S < 0 THEN 100
80  PRINT "ROOTS (REAL):  ";( - B - R) / (2 * A);",  ";( - B + R) / (2 * A)
90  GOTO 110
100  PRINT "ROOTS (COMPLEX):  "; - B / (2 * A);" + OR - ";R / (2 * A);" I"
110  PRINT
120  PRINT "MORE DATA (1=YES,0=NO)";
130  INPUT X
140  IF X = 1 THEN 20
150  RUN "MATH"
``````

## M19.BAS

``````0 CLS:PRINT
10  PRINT "REAL ROOTS OF POLYNOMIALS: NEWTON"
20  PRINT
30  DIM A(11),B(11)
40  FOR I = 1 TO 11
50 A(I) = 0
60 B(I) = 0
70  NEXT I
80  PRINT "DEGREE OF EQUATION";
90  INPUT N
100  FOR I = 1 TO N + 1
110  PRINT "COEFFICIENT A(";I - 1;")";
120  INPUT A(I)
130  NEXT I
140  FOR I = 1 TO 10
150 B(I) = A(I + 1) * I
160  NEXT I
170  PRINT
180  PRINT "GUESS";
190  INPUT X
200 Q = 0
210 S = 1
220 F1 = 0
230 F0 = 0
240 Q = Q + 1
250  FOR I = 1 TO N + 1
260 F0 = F0 + A(I) * S
270 F1 = F1 + B(I) * S
280 S = S * X
290  NEXT I
300  IF F1 = 0 THEN 360
310 S = X - F0 / F1
320  IF X = S THEN 380
330 X = S
340  IF Q > 100 THEN 490
350  GOTO 210
360  PRINT "DERIVATIVE = 0 AT X = ";X
370  GOTO 180
380  PRINT
390  PRINT " ROOT"," ERROR","DERIV."
400  PRINT X,F0,F1
410  PRINT
420  PRINT "ANOTHER VALUE (1=YES,0=NO)";
430  INPUT A
440  IF A = 1 THEN 170
450  PRINT "ANOTHER FUNCTION (1=YES,0=NO)";
460  INPUT A
470  IF A = 1 THEN 30
480  GOTO 550
490  PRINT "100 ITERATIONS COMPLETED:"
500  PRINT " X = ";X;" F(X) = ";F0
510  PRINT "  CONTINUE (1=YES,0=NO)";
520  INPUT A
530  IF A = 1 THEN 200
550  RUN "MATH"
``````

## M2.BAS

``````0 CLS:PRINT
10  PRINT "PRIME FACTORS OF INTEGERS"
20  PRINT
30  PRINT "(ENTER 0 TO END PROGRAM)"
40  PRINT "NUMBER";
50  INPUT Z
60  IF Z = 0 THEN 200
70  PRINT  SGN (Z)
80 Z =  ABS (Z)
90  FOR I = 2 TO SQR (Z)
100 S = 0
110  IF Z / I <  >  INT (Z / I) THEN 150
120 Z = Z / I
130 S = S + 1
140  GOTO 110
150  IF S = 0 THEN 170
160  PRINT I;"^";S
170  NEXT I
180  PRINT
190  GOTO 40
200  RUN "MATH"
``````

## M20.BAS

``````0 CLS:PRINT
10  PRINT "ROOTS OF POLYNOMIALS: HALF-INTERVAL SEARCH"
20  PRINT
30 DEF FNR(X)=4*X^4-2.5*X^2-X+0.5: REM  - ENTER FUNCTION (DEFFNR(X)="FUNCTION") HERE
40  DIM D(3)
50  PRINT "(TO END SEARCH ENTER 0,0)"
60  PRINT "INTERVAL (LOWER,UPPER LIMIT)";
70  INPUT A,B
80  IF A <  > B THEN 120
90  IF A = 0 THEN 430
100  PRINT "--INTERVAL LIMITS CAN'T BE EQUAL!--"
110  GOTO 60
120  IF A < B THEN 150
130  PRINT "--LOWER LIMIT MUST BE ENTERED FIRST!--"
140  GOTO 60
150 A1 =  SGN ( FNR(A))
160 B1 =  SGN ( FNR(B))
170  IF A1 * B1 = 0 THEN 360
180  IF A1 * B1 < 0 THEN 280
190  FOR I = 1 TO 1000
200 X = A +  RND (2) * (B - A)
210 X1 =  SGN ( FNR (X))
220  IF X1 = 0 THEN 400
230  IF A1 * X1 < 0 THEN 270
240  NEXT I
250  PRINT "NO CHANGE OF SIGN FOUND"
260  GOTO 60
270 B = X
280 D(2 + A1) = A
290 D(2 - A1) = B
300 Y = (D(1) + D(3)) / 2
310 Y1 =  SGN ( FNR (Y))
320  IF Y1 = 0 THEN 400
330 D(2 + Y1) = Y
340  IF  ABS (D(1) - D(3)) /  ABS (D(1) +  ABS (D(3))) < 0.000005 THEN 400
350  GOTO 300
360  IF A1 = 0 THEN 390
370 Y = B
380  GOTO 400
390 Y = A
400  PRINT "ROOT = ";Y
410  PRINT
420  GOTO 60
430  RUN "MATH"
``````

## M21.BAS

``````0 CLS:PRINT
10  PRINT "TRIG POLYNOMIAL"
20  PRINT
30  REM  - ENTER NUMBER OF PAIRS OF TERMS AND COEFFICIENTS HERE
35 DATA 3,1,2,-2,1,5,-3
40  PRINT "(ENTER ANGLE=99999 TO END PROGRAM)"
50  PRINT "ANGLE";
60  INPUT R
70  IF R = 99999! THEN 180
90  FOR I = 1 TO N
110 Z = Z + A *  SIN (I * R) + B *  COS (I * R)
120  NEXT I
130  PRINT "F(";R;")=";Z
140  RESTORE
150  PRINT
160 Z = 0
170  GOTO 50
180  RUN "MATH"
``````

## M22.BAS

``````0 CLS:PRINT
10  CLS:PRINT "SIMULTANEOUS EQUATIONS"
20  PRINT
30  DIM A(9,10)
40  PRINT "NUMBER OF EQUATIONS";
50  INPUT R
60  PRINT "COEFFICIENT MATRIX:"
70  FOR J = 1 TO R
80  PRINT "EQUATION ";J
90  FOR I = 1 TO R + 1
100  IF I = R + 1 THEN 130
110  PRINT " COEFFICIENT ";I;
120  GOTO 140
130  PRINT " CONSTANT ";
140  INPUT A(J,I)
150  NEXT I
160  NEXT J
170  FOR J = 1 TO R
180  FOR I = J TO R
190  IF A(I,J) <  > 0 THEN 230
200  NEXT I
210  PRINT "NO UNIQUE SOLUTION "
220  GOTO 440
230  FOR K = 1 TO R + 1
240 X = A(J,K)
250 A(J,K) = A(I,K)
260 A(I,K) = X
270  NEXT K
280 Y = 1 / A(J,J)
290  FOR K = 1 TO R + 1
300 A(J,K) = Y * A(J,K)
310  NEXT K
320  FOR I = 1 TO R
330  IF I = J THEN 380
340 Y =  - A(I,J)
350  FOR K = 1 TO R + 1
360 A(I,K) = A(I,K) + Y * A(J,K)
370  NEXT K
380  NEXT I
390  NEXT J
400  PRINT
410  FOR I = 1 TO R
420  PRINT "X";I;" = "; INT (A(I,R + 1) * 1000 + 0.5) / 1000
430  NEXT I
435 PRINT "Run Again (Y/N) ;A\$
436 IF A\$="y" OR A\$ = "Y" THEN 10
440  RUN "MATH"
``````

## M23.BAS

``````0 CLS:PRINT
10  PRINT "LINEAR PROGRAMMING"
20  PRINT
30  DIM A(10,14),B(13)
40  PRINT "NUMBER OF VARIABLES";
50  INPUT V
60  PRINT "NUMBER OF CONSTRAINTS";
70  INPUT C
80  PRINT "MATRIX ELEMENTS:"
90  FOR I = 2 TO C + 1
100  PRINT "CONSTRAINT ";I - 1
110  FOR J = 1 TO V
120  PRINT " COEFFICIENT ";J;
130  INPUT A(I,J)
140  NEXT J
150  PRINT "  RELATION (1 OR -1)";
160  INPUT A(I,V + 1)
170  PRINT "  CONSTANT ";
180  INPUT A(I,V + 2)
190 A(I,C + V + 1) = A(I,V + 2)
200 A(I,V + 2) = 0
210  IF I = 2 THEN 240
220 A(I,V + I - 1) = A(I,V + 1)
230 A(I,V + 1) = 0
240  NEXT I
250  PRINT
260  PRINT "FUNCTION:"
270  FOR I = 1 TO V
280  PRINT "  COEFFICIENT ";I;
290  INPUT A(1,I)
300  NEXT I
310  PRINT
320 M = 1
330  FOR I = 1 TO V
340 B(I) = 1
350  NEXT I
360  FOR I = 2 TO C + 1
370  IF A(I,V + I - 1) <  >  - 1 THEN 430
380 B(V + I - 1) = 1
390  FOR J = 1 TO C + V
400 A(C + 2,J) = A(C + 2,J) - A(I,J)
410  NEXT J
420 M = C + 2
430  NEXT I
440 P = 1
450 R = 1
460  FOR I = 2 TO C + V
470  IF A(M,I) < A(M,P) THEN 490
480 P = I
490  IF A(M,I) >  = A(M,R) THEN 510
500 R = I
510  NEXT I
520  IF A(M,R) < 0 THEN 570
530  IF P = 1 THEN 880
540  IF A(M,P) > 0.0001 THEN 840
550 M = 1
560  GOTO 440
570 P = 1
580  FOR I = 2 TO C + 1
590  IF A(I,R) <  = 0 THEN 640
600 Z = A(I,C + V + 1) / A(I,R)
610  IF P = 1 THEN 630
620  IF Z >  = A(P,C + V + 1) / A(P,R) THEN 640
630 P = I
640  NEXT I
650  IF P = 1 THEN 860
660  FOR I = 1 TO V + C
670  IF B(I) = 1 THEN 690
680  IF A(P,I) = 1 THEN 700
690  NEXT I
700 B(I) = 1
710 B(R) = 0
720 Z = A(P,R)
730  FOR I = 1 TO V + C + 1
740 A(P,I) = A(P,I) / Z
750  NEXT I
760  FOR I = 1 TO C + 2
770  IF I = P THEN 820
780 Z = A(I,R)
790  FOR J = 1 TO V + C + 1
800 A(I,J) = A(I,J) - Z * A(P,J)
810  NEXT J
820  NEXT I
830  GOTO 440
840  PRINT "INFEASIBLE"
850  GOTO 1030
860  PRINT "UNBOUNDED"
870  GOTO 1030
880  FOR J = 1 TO V
890  IF B(J) = 0 THEN 920
900 B(J) = 0
910  GOTO 960
920  FOR I = 2 TO C + 1
930  IF A(I,J) = 1 THEN 950
940  NEXT I
950 B(J) = A(I,V + C + 1)
960  NEXT J
970 Z = A(1,V + C + 1)
980  PRINT
990  PRINT "FUNCTION = ";Z * ( - 1)
1000  FOR I = 1 TO V
1010  PRINT "X(";I;")=";B(I)
1020  NEXT I
1030  END
5530  IF M = 1 THEN 880
``````

## M24.BAS

``````10 PRINT "MATRIX ADDITION, SUBTRACTION, SCALAR MULTIPLICATION"
20 PRINT
30 DIM A (3,3) , B (3,3)
40 PRINT " 1 = ADDITION"
50 PRINT "2 = SUBTRACTION"
60 PRINT "3 = SCALAR MULTIPLICATION"
70 PRINT "WHICH OPERATION";
80 INPUT D
90 IF D <> 3 THEN 120
100 PRINT "VALUE OF SCALAR";
110 INPUT S
120 PRINT "DIMENSION OF MATRIX (R,C)";
130 INPUT R,C
140 FOR K = 1  TO 2
150 IF K = 2  THEN 180
160 PRINT "MATRIX 1: "
170 GOTO  190
180 PRINT "MATRIX 2:"
190 FOR J = 1  TO R
200 PRINT "ROW" ;J
210 FOR I = 1  TO C
220 PRINT "VALUE COLUMN" ;I;
230 IF K=2  THEN 260
240 INPUT A (J,I)
250 GOTO  270
260 INPUT B (J,I)
270 NEXT I
280 NEXT J
290 IF D=3   THEN 310
300 NEXT K
310 FOR J=1  TO R
320 FOR I=1  TO C
330 IF D<>2  THEN 350
340 B (J,I) =- B (J,I)
350 IF D=3  THEN 380
360 PRINT A (J,I) + B (J,I) ; "  ";
370 GOTO  390
380 PRINT A (J,I) *S; "  ";
390 NEXT I
400 PRINT
410 NEXT J
420 PRINT
430 PRINT "MORE DATA?  (1=YES, 0=NO) ";
440 INPUT D
450 IF D=1  THEN 70
460 RUN "MATH"
``````

## M25.BAS

``````0 CLS:PRINT
10  CLS:PRINT "MATRIX MULTPLICATION"
20  PRINT
30  DIM A(10,10),B(10,10)
40  PRINT "DIMENSION OF MATRIX 1 (R,C)";
50  INPUT R1,C1
60  PRINT "DIMENSION OF MATRIX 2 (R,C)";
70  INPUT R2,C2
80  IF C1 = R2 THEN 110
90  PRINT "CANNOT BE MULTIPLIED;  OTHER DIMENSION NECESSARY"
100  GOTO 40
110  PRINT "MATRIX 1:"
120  FOR J = 1 TO R1
130  PRINT "ROW ";J
140  FOR I = 1 TO C1
150  PRINT "VALUE COLUMN";I;
160  INPUT A(J,I)
170  NEXT I
180  NEXT J
190  PRINT
200  PRINT "MATRIX 2:"
210  FOR J = 1 TO R2
220  PRINT "ROW ";J
230  FOR I = 1 TO C2
240  PRINT "VALUE COLUMN ";I;
250  INPUT B(J,I)
260  NEXT I
270  NEXT J
280  PRINT
290  FOR I = 1 TO R1
300  FOR J = 1 TO C2
310 S = 0
320  FOR K = 1 TO C1
330 S = S + A(I,K) * B(K,J)
340  NEXT K
350  PRINT S;"  ";
360  NEXT J
370  PRINT
380  NEXT I
385 INPUT "Run Again (Y/N) ;A\$
387 IF A\$="Y" OR A\$="y" THEN 10
390  RUN "MATH"
``````

## M26.BAS

``````0 CLS:PRINT
10  CLS:PRINT "MATRIX INVERSION "
20  PRINT
30  DIM A(10,10),B(10,10)
40  PRINT "DIMENSION OF MATRIX";
50  INPUT R
60  PRINT "MATRIX ELEMENTS:"
70  FOR J = 1 TO R
80  PRINT "ROW ";J
90  FOR I = 1 TO R
100  PRINT "VALUE COLUMN ";I;
110  INPUT A(J,I)
120  NEXT I
130 B(J,J) = 1
140  NEXT J
150  FOR J = 1 TO R
160  FOR I = J TO R
170  IF A(I,J) <  > 0 THEN 210
180  NEXT I
190  PRINT "SINGULAR MATRIX"
200  GOTO 500
210  FOR K = 1 TO R
220 S = A(J,K)
230 A(J,K) = A(I,K)
240 A(I,K) = S
250 S = B(J,K)
260 B(J,K) = B(I,K)
270 B(I,K) = S
280  NEXT K
290 T = 1 / A(J,J)
300  FOR K = 1 TO R
310 A(J,K) = T * A(J,K)
320 B(J,K) = T * B(J,K)
330  NEXT K
340  FOR L = 1 TO R
350  IF L = J THEN 410
360 Y =  - A(L,J)
370  FOR K = 1 TO R
380 A(L,K) = A(L,K) + T * A(J,K)
390 B(L,K) = B(L,K) + T * B(J,K)
400  NEXT K
410  NEXT L
420  NEXT J
430  PRINT
440  FOR I = 1 TO R
450  FOR J = 1 TO R
460  PRINT  INT (B(I,J) * 1000 + 0.5) / 1000;"  ";
470  NEXT J
480  PRINT
490  NEXT I
495 INPUT "Run Again (Y/N)";A\$
497 IF A\$="Y" OR A\$="y" THEN 10
500  RUN "MATH"
``````

## M3.BAS

``````0 CLS:PRINT
10  PRINT "AREA OF A POLYGON"
20  PRINT
30  DIM X(25),Y(25)
40  PRINT "NUMBER OF VERTICES (ENTER 0 TO END PROGRAM)";
50  INPUT N
60  IF N = 0 THEN 230
70  FOR I = 1 TO N
80  IF I > 1 THEN 110
90  PRINT "COORDINATES OF VERTEX ";I;
100  GOTO 120
110  PRINT "               VERTEX ";I;
120  INPUT X(I),Y(I)
130  NEXT I
140 X(N + 1) = X(1)
150 Y(N + 1) = Y(1)
160 A = 0
170  FOR I = 1 TO N
180 A = A + (X(I) + X(I + 1)) * (Y(I) - Y(I + 1))
190  NEXT I
200  PRINT "AREA =";ABS (A) /2
210  PRINT
220  GOTO 40
230  RUN "MATH"
``````

## M4.BAS

``````0 CLS:PRINT
5 DEF FNA (X) = 1.570796 - ATN (X/ SQR (X * X-1))
10  PRINT "ANALYSIS OF TWO VECTORS"
35  PRINT
40  PRINT "VECTOR 1: X,Y,Z";
50  INPUT X(1),Y(1),Z(1)
60  PRINT "VECTOR 2: X,Y,Z";
70  INPUT X(2),Y(2),Z(2)
80  PRINT
90  FOR I = 1 TO 2
100 M(I) =  SQR (X(I) ^ 2 + Y(I) ^ 2 + Z(I) ^ 2)
110  IF M(I) = 0 THEN 220
120  PRINT "VECTOR ";I;":"
130  PRINT "MAGNITUDE: ";M(I)
140 S = 57.29578
150 J = X(I) / M(I)
160  PRINT "ANGLE WITH X-AXIS: "; FNA(J) * S
170 J = Y(I) / M(I)
180  PRINT "ANGLE WITH Y-AXIS: "; FNA(J) * S
190 J = Z(I) / M(I)
200  PRINT "ANGLE WITH Z-AXIS: "; FNA(J) * S
210  PRINT
220  NEXT I
230 J = 0
240  IF M(1) = 0 THEN 310
250  IF M(2) = 0 THEN 310
260 J = (X(1) * X(2) + Y(1) * Y(2) + Z(1) * Z(2)) / M(1) / M(2)
270  IF J <  > 0 THEN 300
280 J = 90
290  GOTO 310
300 J =  FNA (J) * S
310  PRINT "ANGLE BETWEEN VECTORS: ";J
320  PRINT
330  PRINT "MORE DATA? (1=YES, 0=NO)";
340  INPUT Z
350  IF Z = 1 THEN 20
360  RUN "MATH"
``````

## M5.BAS

``````0 CLS:PRINT
1  DEF  FNA(X) =  ATN (X /  SQR ( - X * X + 1))
2  DEF  FNB(X) =  -  FNA(X) + 1.5708
30  DIM A(3),S(3)
40 P = 3.1415927#
45 C = 0.0174532927#
59 CLS
60 PRINT:PRINT :PRINT :PRINT
61 PRINT "PARTS OF A TRIANGLE"
62 PRINT
63 PRINT "PROBLEM TYPES:": PRINT "1. ASA": PRINT "2. SAS": PRINT "3. AAS": PRINT "4. SSA": PRINT "5. SSS": PRINT "6. END PROGRAM": PRINT
64 PRINT "ENTER PROBLEM TYPE BY NUMBER";
70  INPUT X
80  IF X = 6 THEN 560
90  IF X = 5 THEN 390
100  IF X = 4 THEN 300
110  IF X = 3 THEN 260
120  IF X = 2 THEN 190
130  PRINT "ENTER ANGLE, SIDE, ANGLE";
140  INPUT A(1),S(3),A(2)
145 A(1) = A(1) * C
146 A(2) = A(2) * C
150 A(3) = P - A(1) - A(2)
160 S(1) = S(3) *  SIN (A(1)) /  SIN (A(3))
170 S(2) = S(3) *  SIN (A(2)) /  SIN (A(3))
180  GOTO 440
190  PRINT "ENTER SIDE, ANGLE, SIDE";
200  INPUT S(3),A(1),S(2)
205 A(1) = A(1) * C
210 S(1) =  SQR (S(3) ^ 2 + S(2) ^ 2 - 2 * S(3) * S(2) *  COS (A(1)))
220 A(2) =  SIN (A(1)) / S(1) * S(2)
229  REM  - ARCSIN FUNCTION
230 A(2) =  FNA(A(2))
240 A(3) = P - A(1) - A(2)
250  GOTO 440
260  PRINT "ENTER ANGLE, ANGLE, SIDE";
270  INPUT A(3),A(2),S(3)
275 A(3) = A(3) * C
276 A(2) = A(2) * C
280 A(1) = P - A(2) - A(3)
290  GOTO 160
300  PRINT "ENTER SIDE, SIDE, ANGLE";
310  INPUT S(1),S(2),A(1)
315 A(1) = A(1) * C
320 T = S(2) *  SIN (A(1))
330  IF S(1) < T THEN 520
340 S(3) = S(3) + Y
350  IF S(1) <  = T THEN 380
360 Y =  SQR (S(1) ^ 2 - T ^ 2)
370 S(3) = S(3) + Y
380  GOTO 220
390  PRINT "ENTER SIDE, SIDE, SIDE";
400  INPUT S(1),S(2),S(3)
410 A(1) = (S(2) ^ 2 + S(3) ^ 2 - S(1) ^ 2) / 2 / S(2) / S(3)
420 A(1) =  FNB(A(1))
430  GOTO 220
440  PRINT
450  FOR I = 1 TO 3
460  IF A(I) < 0 THEN 520
470  PRINT "SIDE ";I;" = "; INT (S(I) * 1000 + 0.5) / 1000
480  PRINT "OPPOSITE ANGLE = "; INT (A(I) / C * 1000 + 0.5) / 1000;" DEGREES"
490  NEXT I
500  PRINT
510  GOTO 60
520  PRINT
530  PRINT "NO SOLUTION"
540  PRINT
550  GOTO 60
560 RUN "MATH"
``````

## M6.BAS

``````10 PRINT "OPERATIONS ON TWO VECTORS"
20 PRINT
30 PRINT "VECTOR A: X,Y,Z COORDINATES";
40 INPUT X1, Y1, Z1
50 PRINT "VECTOR B: X, Y, Z COORDINATES";
60 INPUT X2, Y2, Z2
70 PRINT
80 PRINT "A+B="; X1+X2;", "; Y1+Y2;", "; Z1+Z2
90 PRINT "A-B="; X1-X2;","; Y1-Y2;","; Z1-Z2
100 PRINT "A.B="; X1 * X2+Y1 * Y2 + Z1 * Z2
110 PRINT "A*B="; Y1*Z2-Z1 * Y2;","; Z1 * X2-X1 * Z2;","; X1 * Y2-Y1 * X2
120 PRINT
130 PRINT "MORE DATA? (1=YES, 0=NO) ";
140 INPUT X
150 IF X = 1   THEN 20
160 RUN "MATH"
``````

## M7.BAS

``````0 CLS:PRINT
10  PRINT "COORDINATE CONVERSION"
20  PRINT
30  PRINT "     ( 1=CARTESIAN TO POLAR)"
40  PRINT "     (-1=POLAR TO CARTESIAN)"
50  PRINT "     ( 0=END PROGRAM)"
60  PRINT "WHICH DIRECTION";
70  INPUT D
80  IF D = 0 THEN 380
90  IF D =  - 1 THEN 320
100  PRINT "X,Y";
110  INPUT X,Y
120  IF X = 0 THEN 170
130  IF Y = 0 THEN 260
140  PRINT "R = "; INT ( SGN (X) *  SQR (X ^ 2 + Y ^ 2) * 100 + 0.5) / 100;",";
150  PRINT "  A = "; INT ( ATN (Y / X) * 180 / 3.1415927# * 100 + 0.5) / 100
160  GOTO 60
170  IF Y = 0 THEN 240
180  PRINT "R = "; ABS (Y);",";
190  IF Y < 0 THEN 220
200  PRINT "  A = 90"
210  GOTO 60
220  PRINT "  A = 270"
230  GOTO 60
240  PRINT "R = 0,  A = 0"
250  GOTO 60
260  PRINT "R = "; ABS (X);",";
270  IF X < 0 THEN 300
280  PRINT "  A = 0"
290  GOTO 60
300  PRINT "  A = 180"
310  GOTO 60
320  PRINT "R,A";
330  INPUT R,A
340 M = (A -  INT (A / 360) * 360) * 3.1415927# / 180
350  PRINT "X = "; INT (R *  COS (M) * 100 + 0.5) / 100;",";
360  PRINT " Y = "; INT (R *  SIN (M) * 100 + 0.5) / 100
370  GOTO 60
380  RUN "MATH"
``````

## M8.BAS

``````0 CLS:PRINT
10  PRINT "COORDINATE PLOT"
20  PRINT
30  DIM X(100),Y(100)
40  PRINT "X-AXIS: LEFT ENDPOINT, RIGHT ENDPOINT, INCREMENT";
50  INPUT A1,A2,A3
60  PRINT "Y-AXIS: LOWER ENDPOINT, UPPER ENDPOINT, INCREMENT";
70  INPUT B1,B2,B3
80 B2 = (B2 - B1) / B3
90  IF B2 <  = 70 THEN 120
100  PRINT "Y-RANGE TOO LARGE"
110  GOTO 60
120  PRINT "NUMBER OF POINTS TO BE PLOTTED";
130  INPUT N
140  IF N = 0 THEN 1070
150  IF N <  = 99 THEN 180
160  PRINT "TOO MANY POINTS"
170  GOTO 120
180  FOR I = 1 TO N
190  IF I > 1 THEN 220
200  PRINT "COORDINATES OF POINT ";I;
210  GOTO 230
220  PRINT "               POINT ";I;
230  INPUT X(I),Y(I)
240 X(I) =  INT ((X(I) - A1) / A3 + 0.5)
250 Y(I) =  INT ((Y(I) - B1) / B3 + 0.5)
260  NEXT I
270 Y(N + 1) =  INT (B2 + 0.5) + 1
280 X(N + 1) =  INT ((A2 - A1) / A3 + 0.5) + 1
290  PRINT
300  PRINT "INTERSECTION OF AXES AT (";A1;",";B1;")"
310  PRINT
320  FOR J = 1 TO N
330  FOR I = 1 TO N - J
340 A = X(I)
350 B = Y(I)
360 C = X(I + 1)
370 D = Y(I + 1)
380  IF A < C THEN 430
390 X(I) = C
400 Y(I) = D
410 X(I + 1) = A
420 Y(I + 1) = B
430  NEXT I
440  NEXT J
450 T = 1
460  FOR P = 0 TO N - 1
470  IF X(P + 1) = 0 THEN 490
480  NEXT P
490  FOR I = 0 TO  INT ((A2 - A1) / A3 + 0.5)
500 T = T + P
510 P = 0
520  IF T > N THEN 540
530  IF X(T) = I THEN 590
540  IF I = 0 THEN 570
550  PRINT "*";
560  GOTO 1040
570 S = N + 1
580  GOTO 920
590  FOR L = T TO N
600  IF X(L) > X(T) THEN 630
610 P = P + 1
620  NEXT L
630  IF P = 1 THEN 730
640  FOR J = 1 TO P
650  FOR L = 1 TO P - J
660 D = Y(T + L - 1)
670 B = Y(T + L)
680  IF D <  = B THEN 710
690 Y(T + L - 1) = B
700 Y(T + L) = D
710  NEXT L
720  NEXT J
730  FOR L = 0 TO P - 1
740 Z = Y(T + L)
750  IF Z >  = 0 THEN 770
760  NEXT L
770  IF I = 0 THEN 910
780  IF Z = 0 THEN 800
790  PRINT "*";
800  IF L = P - 1 THEN 870
810  FOR J = L TO P - 1
820  IF Z > B2 THEN 1040
830  IF Y(T + J) = Z THEN 860
840  PRINT  TAB( Z);"+";
850 Z = Y(T + J)
860  NEXT J
870  IF Z < 0 THEN 1040
880  IF Z > B2 THEN 1040
890  PRINT  TAB( Z);"+";
900  GOTO 1040
910 S = T + L
920  FOR J = 0 TO B2
930  IF Y(S) <  > J THEN 1010
940  PRINT "+";
950  FOR K = S TO T + P - 1
960  IF Y(K) = Y(S) THEN 990
970 S = K
980  GOTO 1020
990  NEXT K
1000  GOTO 1020
1010  PRINT "*";
1020  NEXT J
1030  PRINT "Y";
1040  PRINT
1050  NEXT I
1060  PRINT "X"
1069 A\$=INKEY\$: IF A\$="" THEN 1069
1070  RUN "MATH"
``````

## M9.BAS

``````5  CLS
10  PRINT "ANGLE CONVERSION:"
20  PRINT
35  PRINT "3. END PROGRAM"
40 C = 180 / 3.1415927#
50  INPUT "WHICH OPTION? (BY NUMBER):";O
60  ON O GOTO 70,150
65  GOTO 240
70  INPUT "INPUT THE ANGLE IN DEGREES, MINUTES, SECONDS?";D,M,S
80 A = D + M / 60 + S / 3600
90  PRINT "RADIANS =";A / C
100  GOTO 50
150  INPUT "INPUT THE ANGLE IN RADIANS?";A
160  PRINT
170 A = A * C
180  PRINT "DEGREES = "; INT (A)
190 A = A -  INT (A)
200  PRINT "MINUTES = "; INT (A * 60)
210 A = A * 60 -  INT (A * 60)
220  PRINT "SECONDS = "; INT (A * 60)
230  GOTO 50
240  RUN "MATH"
``````

## MATH.BAS

``````10 CLS:' EDITED BY ats  11.26.81   MATH.BAS -------------------
15 KEY OFF:WIDTH 80
17 DIM A\$(30)
20  PRINT TAB(20)"MATHEMATICS CATAGORY PROGRAMS:"
30  PRINT
40  FOR I = 1 TO 27
55 NEXT I
57 FOR I=1 TO 13
60  IF I < 10 THEN  B\$="  " ELSE B\$=" "
80  PRINT B\$;I;". ";A\$(I);TAB(38);I+13;". ";A\$(I+13)
90  NEXT I
100 PRINT TAB(39) "27 . ";A\$(27)
150 PRINT :PRINT
160  PRINT : INPUT "   WHICH PROGRAM WOULD YOU LIKE TO USE ";A\$
170 IF A\$="27" THEN RUN "MENU"
180  IF VAL(A\$) <1 OR VAL(A\$) >26 THEN 160
185 CLS:PRINT
190  RUN "M"+A\$
200  DATA  "GREATEST COMMON DENOMINATOR","PRIME FACTORS","AREA OF POLYGON","VECTOR ANALYSIS","PARTS OF TRIANGLE"
210  DATA  "VECTOR OPERATIONS","COORDINATE CONVERSION","COORDINATE PLOT","ANGLE CONVERSION","POLAR EQUATION PLOT"
220  DATA "FUNCTION PLOT","LINEAR INTERPOLATION","CURVILINEAR INTERPOLATION","SIMPSON'S RULE","GAUSSIAN QUADRATURE","TRAPEZOIDAL RULE","DERIVATIVE"
230  DATA  "QUADRATIC FORMULA","REAL ROOTS:NEWTON","REAL ROOTS:HALF-INTERVAL SEARCH","TRIG POLYNOMIAL","SIMULTANEOUS EQUATIONS"
``````

## MATRIX.BAS

``````5 CLS:KEY OFF:WIDTH 80
10 '====== SIMULTANEOUS EQUATIONS ====
12 SE\$="SIMULTANEOUS EQUATIONS"
15 PRINT TAB(29) SE\$:PRINT :PRINT
16 PRINT "THIS PROGRAM SOLVES SIMULTANEOUS EQUATIONS. THE NUMBER OF EQUATIONS IS FIRST"
17 PRINT "ENTERED, FOLLOWED BY THE COEFFICIENTS OF EACH EQUATION AND THEN THE"
18 PRINT "RESPECTIVE CONSTANT. THE USER MUST SUPPLY THE APPROPRIATE DATA WHEN REQUESTED."
19 PRINT "IF AN EQUATION DOES NOT HAVE A PARTICULAR COEFFICIENT, ENTER ZERO (0) WHEN":PRINT "PROMPTED.":PRINT :PRINT
20 INPUT "NUMBER OF EQUATIONS ",RA
25 PRINT :PRINT
30 CA=RA:RB=RA
40 '***** COEFFICIENT MATRIX *******
90 GOSUB 280
120 '***** CONSTANT MATRIX *****
140 GOSUB 1410
150 'FIND INVERSE OF MATRIX A
160 GOSUB 1060
170 'MULTIPLY INVERSE A AND VECTOR B
180 X=RB
190 PRINT
200 GOSUB 670
220 CLS:PRINT TAB(29); SE\$
241 PRINT:PRINT
244 FOR I=1 TO RA
245 FOR J=1 TO CA
246 IF SGN(KB(I,J))=-1 THEN SG\$=" -" ELSE SG\$=" +"
247 IF J=1 THEN SG\$=""
248 KB\$=STR\$(KB(I,J))
249 PRINT SG\$+KB\$+CHR\$(96+J);
250 NEXT J
252 PRINT " =";B(I)
253 NEXT I
254 PRINT :PRINT "Where: ":'OUTPUT RESULT
255 FOR I=1 TO RA
256 PRINT "   " CHR\$(96+I)" =";D(I)
257 NEXT I
259 PRINT :PRINT :PRINT
261 PRINT "PRINT OUTPUT ? ";
263 A\$=INKEY\$: IF A\$="" THEN 263
265 IF A\$="Y" OR A\$="y" THEN GOSUB 1500
273 PRINT :PRINT
274 PRINT "SOLVE ANOTHER SET OF EQUATIONS ? ";
275 A\$=INKEY\$: IF A\$="" THEN 275
276 IF A\$="Y" OR A\$="y" THEN CLEAR:GOTO 5
277 CLS:PRINT :PRINT "Have a Nice Day":END
280 DIM A(RA,CA), KB(RA,CA)
290 FOR I=1 TO RA
300 FOR J=1 TO CA
310 PRINT "Equation";I;", coefficient " CHR\$(96+J) " ";
315 INPUT A(I,J)
317 KB(I,J)=A(I,J)
320 NEXT J
325 PRINT
330 NEXT I
335 PRINT
340 RETURN
650 '============   MATRIX MULTIPLY, B IS A VECTOR =========
660 'SU IS SUM OF MULTIPLIED ELEMENTS
670 DIM D(RB)
680 SU=0
690 FOR I=1 TO RA
700 FOR J=1 TO CA
710 SU=SU+(A(I,J)*B(J))
720 NEXT J
730 D(I)=SU
740 SU=0
750 NEXT I
760 RETURN
1040 '================  MATRIX INVERSION   =====================
1050 'MAT A IS REPLACED WITH ITS INVERSE
1060 FOR K=1 TO RA
1070 FOR J=1 TO RA
1080 IF J=K GOTO 1100
1090 A(K,J)=A(K,J)/A(K,K)
1100 NEXT J
1110 A(K,K)=1/A(K,K)
1120 FOR I=1 TO RA
1130 IF I=K GOTO 1180
1140 FOR J=1 TO RA
1150 IF J=K GOTO 1170
1160 A(I,J)=A(I,J)-A(K,J)*A(I,K)
1170 NEXT J
1180 NEXT I
1190 FOR I=1 TO RA
1200 IF I=K GOTO 1220
1210 A(I,K)=-A(I,K)*A(K,K)
1220 NEXT I
1230 NEXT K
1240 RETURN
1400 '===============   READ VECTOR B   ============================
1410 DIM B(RB)
1420 FOR I=1 TO RB
1430 PRINT "Constant for equation";I;
1435 INPUT B(I)
1440 NEXT I
1450 RETURN
1490 '============ PRINT OUTPUT ===============
1500 LPRINT TAB(29); SE\$
1505 FOR BL=1 TO 5:LPRINT :NEXT BL
1510 FOR I=1 TO RA
1520 FOR J=1 TO CA
1530 IF SGN(KB(I,J))=-1 THEN SG\$=" -" ELSE SG\$=" +"
1540 IF J=1 THEN SG\$=""
1550 KB\$=STR\$(KB(I,J))
1560 LPRINT SG\$+KB\$+CHR\$(96+J);
1570 NEXT J
1580 LPRINT " =";B(I)
1590 NEXT I
1600 LPRINT :LPRINT "Where: ":'OUTPUT RESULT
1610 FOR I=1 TO RA
1620 LPRINT "   " CHR\$(96+I)" =";D(I)
1630 NEXT I
``````

## NCCLSPRE.BAS

``````5 CLS:KEY OFF
10 REM PRECISION PROGRAM v1.83 by N. ADAMS
20 REM This program will calculate within run,run to run, and day to day
30 REM precision.
32 CLEAR
34 INPUT "Title: ";TI\$
35 INPUT "Enter number of days of data collected ";N
40 OPTION BASE 1
50 DIM A(N,4),B(N,2),C(N,4),D(N),E(N,2),G(N)
60 PRINT "ENTER EACH DAYS VALUES AS FOLLOWS:"
70 PRINT "RUN 1 VALUE 1,RUN 1 VALUE 2,RUN 2 VALUE 1, RUN 2 VALUE 2"
80 FOR I =1 TO N:INPUT "DATA ";A(I,1),A(I,2),A(I,3),A(I,4)
90 NEXT I
100 FOR I =1 TO N:
110       B(I,1) = (A(I,1) + A(I,2))/2
120       B(I,2) = (A(I,3) + A(I,4))/2
130 NEXT I
140 FOR I = 1 TO N:
150       C(I,1) = (A(I,1) - B(I,1))^2
160       C(I,2) = (A(I,2) - B(I,1))^2
170       C(I,3) = (A(I,3) - B(I,2))^2
180       C(I,4) = (A(I,4) - B(I,2))^2
190 NEXT I
200 S=0
210 FOR I = 1 TO N:
220 FOR J = 1 TO 4:
230    S = S+C(I,J)
240 NEXT J
250 NEXT I
260 WR = S/(2*N)
265 WRP = SQR(WR)
270 PRINT "WITHIN RUN PRECISION = ",WRP
280 FOR I = 1 TO N: D(I) = (B(I,1) + B(I,2))/2
290 NEXT I
300 T = 0
310 FOR I = 1 TO N:
320      E(I,1) = (B(I,1) - D(I))^2
330      E(I,2) = (B(I,2) - D(I))^2
340 T = T + E(I,1) + E(I,2)
350 NEXT I
360 RR = (2*T)/N
365 RRP = (RR-WR)/2 :QW = SQR(RRP)
370 PRINT:PRINT "RUN TO RUN PRECISION = ",QW
380 L = 0
390 FOR I = 1 TO N:L = L + D(I)
400 NEXT I
410 F = L/N
420 H = 0
430 FOR I = 1 TO N:
440      G(I) = (D(I) - F)^2
450 H = H + G(I)
460 NEXT I
470 PR = (4*H)/(N-1)
475 PRP = (PR-RR)/4 :ZW =SQR(PRP)
480 PRINT :PRINT "DAY TO DAY PRECISION = ",ZW
485 LPRINT TI\$:LPRINT
490 LPRINT SPC(20) "RUN 1" SPC(25) "RUN 2"
495 LPRINT "DAY","REP 1","REP 2","REP 1","REP 2"
500 FOR I = 1 TO N:
510 LPRINT I,A(I,1),A(I,2),A(I,3),A(I,4)
520 NEXT I
530 LPRINT:LPRINT:LPRINT
600 LPRINT: LPRINT:LPRINT
610 LPRINT "THE WITHIN RUN PRECISION = ";WRP
620 LPRINT:LPRINT "THE RUN TO RUN PRECISION = ";QW
630 LPRINT:LPRINT "THE DAY TO DAY PRECISION = ";ZW
635 PRINT :PRINT
640 PRINT:INPUT "Continue (C) or End (E): ";ZX\$
650 IF ZX\$ = "C" OR ZX\$ ="c" THEN 10 ELSE 660
660 IF ZX\$ ="e" OR ZX\$ = "E" THEN 700 ELSE 640
700 CLS: KEY ON
``````

## NORMAL-Z.BAS

``````100  '**********************************************************************
110  '********                                                   ***********
120  '********           NORMAL DISTRIBUTION ROUTINES            ***********
130  '********                                                   ***********
140  '**********************************************************************
150  '            *   COPYRIGHT 1982 - CRAIG W. UTHE          *
160  '            *   WRITTEN 3/3/82 BY CRAIG W. UTHE         *
170  '            *                 * * * *                   *
180  '            *   ANY INDIVIDUAL MAY COPY THIS PROGRAM    *
190  '            *   AND MAKE MODIFICATIONS TO IT IF THAT    *
200  '            *   INDIVIDUAL ARRANGES TO CONTRIBUTE ONE   *
210  '            *   OTHER PROGRAM TO THE PHILA. AREA IBM    *
215  '            *   PC USER GROUP PUBLIC DOMAIN SOFTWARE    *
220  '            *   EXCHANGE LIBRARY.  HOWEVER, COPIES      *
230  '            *   ARE NOT ALLOWED TO BE SOLD, NOT IN      *
240  '            *   WHOLE NOR IN PART, NOT SEPARATELY       *
250  '            *   NOR JOINTLY WITH OTHER SOFTWARE.        *
260  '            *********************************************
270  '
280  '
1000 'MASTER-CONTROL ROUTINE
1010     CLS
1020     PRINT "This program computes areas under the normal distribution"
1030     PRINT "probability curve from the mean to a designated `Z' value."
1040     PRINT "This program also can compute `Z' values from a given area."
1050     PRINT
1060     PRINT "Just as in most statistical tables, only half the curve is
1070     PRINT "considered.  Z values must be between -4 and +4 (these"
1080     PRINT "limits are somewhat arbitrary) and area figures must be"
1090     PRINT "between 0 and 0.5 (actually .49997).  If out-of-range"
1100     PRINT "figures are input, the nearest range limit is assumed"
1120     PRINT
1130     PRINT "HIT ANY KEY TO START"
1140     SELECTION\$ = INKEY\$ : IF SELECTION\$ = "" THEN GOTO 1140 'SAME LINE
1150     ' Area results (given Z) are accurate to the 5 displayed digits.
1160     ' Z values are accurate to 2 digits based on an input area,
1170     ' or the 3 displayed digits based on the program's approximation
1180     ' of that area.
1190     '
1200     ' This precision can be changed by changing the precision
1210     ' constants in the program from their 0.000001 setting.
1220     ' For higher precision, you might also want to change the
1230     ' variables to double, instead of single, precision form.
1240     ' With higher precision, you may wish to change the number
1250     ' of digits displayed, too.
1260     '
1270     ' Out of respect, please do not mutilate the structured
1280     ' programming approach that makes changes so easy and
1290     ' makes the program almost readable.  Of course you can
1300     ' easily use the subroutines in more elaborate programs.
1310     ' This program is fairly insignificant by itself.
1320     '
1330     SELECTION\$ = "1" 'initialization
1340     WHILE (SELECTION\$ = "1" OR SELECTION\$ = "2")
1350         CLS : PRINT STRING\$(60,42)
1370         PRINT : PRINT "     <1> . . . . . . . . COMPUTE AREA FROM Z"
1380         PRINT : PRINT "     <2> . . . . . . . . COMPUTE Z VALUE FROM AREA"
1390         PRINT : PRINT "     <ANY OTHER KEY> . . EXIT PROGRAM"
1400         PRINT : PRINT STRING\$(60,45)
1410         PRINT : PRINT "HIT ANY KEY IN INDICATED RANGE TO MAKE SELECTION:"
1420         SELECTION\$ = INKEY\$ : IF SELECTION\$ = "" THEN GOTO 1420 'SAME LINE
1430         CLS : PRINT "THANK YOU."
1440         IF 0 = INSTR("12",SELECTION\$)                                                       THEN : PRINT "I HOPE THE PROGRAM WAS USEFUL TO YOU.  BYE."                             : GOTO 1480 'WEND
1450         ON INSTR("12",SELECTION\$) GOSUB 3000,2000
1460             'IE:  IF 1, GOSUB COMPUTE-Z-FROM-AREA ROUTINE
1470             '     IF 2, GOSUB COMPUTE-AREA-FROM-Z ROUTINE
1480         WEND
1490     END
1500 '
1510 '
2000 'COMPUTE-Z-FROM-AREA ROUTINE
2010     PRINT : PRINT STRING\$(80,42) : PRINT
2020     QUIT% = 0
2030     WHILE NOT QUIT%
2040            PRINT "INPUT AREA VALUE FROM WHICH TO COMPUTE FREQUENCY."
2060            INPUT "INPUT AREA VALUE (0 TO 0.49997): ",AREA
2070            IF AREA > 5 THEN QUIT% = -1 : GOTO 2230 'WEND
2080            HI.CALCULATED.AREA = .49997 : HI.Z = 4  '*** area < .49997
2090            LO.CALCULATED.AREA = 0      : LO.Z = 0  '*** area > 0
2100            IF AREA >= .49997 THEN CALCULATED.AREA = .49997 : Z = 4                                                 : GOTO 2170
2110            IF AREA <= 0 THEN CALCULATED.AREA = 0 : Z = 0 : GOTO 2170 'PRNT
2120            WHILE ABS(CALCULATED.AREA - AREA) > .000001
2130                    IF AREA > CALCULATED.AREA                                                          THEN LO.CALCULATED.AREA = CALCULATED.AREA : LO.Z = Z                            ELSE HI.CALCULATED.AREA = CALCULATED.AREA : HI.Z = Z
2140                    Z = (LO.Z + HI.Z) / 2
2150                    GOSUB 4000 'McLAUREN-METHOD-AREA-CALCULATION ROUTINE
2160                    WEND
2170            PRINT : PRINT "THE NORMAL-DISTRIBUTION Z-VALUE CORRESPONDING"
2180                    PRINT "TO A MEAN-TO-Z AREA OF ";
2190                    PRINT USING "#.#####"; CALCULATED.AREA;
2200                    PRINT " is:  ";
2210                    PRINT USING "#.###"; Z
2220            PRINT : PRINT STRING\$(80,42) : PRINT
2230            WEND
2240     RETURN
2250 '
3000 'COMPUTE-AREA-FROM-Z ROUTINE
3010     PRINT : PRINT STRING\$(80,42) : PRINT
3020     QUIT% = 0
3030     WHILE NOT QUIT%
3040            PRINT "INPUT Z VALUE FROM WHICH TO COMPUTE FREQUENCY."
3060            INPUT "INPUT Z VALUE (-4.0 TO +4.0):  ", Z
3070            IF Z >= 5 THEN QUIT% = -1 : GOTO 3150 'WEND
3080            IF ABS(Z) >= 4 THEN CALCULATED.AREA = .49997 : Z.SGN% = SGN(Z)                                  : Z = 4 :GOTO 3100 'PRINT OUTPUT
3090            GOSUB 4000 'McLAUREN-METHOD-AREA-CALCULATION ROUTINE
3100            PRINT :PRINT "THE AREA UNDER THE NORMAL DISTRIBUTION CURVE"
3110                    PRINT "FROM THE MEAN TO Z = " Z.SGN%*Z " IS:  ";
3120                    PRINT USING "#.#####"; CALCULATED.AREA
3130            PRINT
3140            PRINT : PRINT STRING\$(80,42) : PRINT
3150            WEND
3160     RETURN
3170 '
4000 'McLAUREN-METHOD-AREA-CALCULATION ROUTINE
4010     '
4020     Z.SGN% = SGN(Z) : Z = ABS(Z) : Z.SQR = Z*Z
4030     CALCULATED.AREA = Z * (1/SQR(2*3.141592654#))
4040     Z.CONSTANT = CALCULATED.AREA
4050     PRECISION.ERROR = 1 : INTERMEDIATE.TERM = 1 : I% = 1
4060     '
4070     WHILE ABS(PRECISION.ERROR) > .000001
4080            INTERMEDIATE.TERM = -(INTERMEDIATE.TERM * Z.SQR) / (2*I%)
4090            PRECISION.ERROR = Z.CONSTANT * (INTERMEDIATE.TERM / (2*I% + 1))
4100            CALCULATED.AREA = CALCULATED.AREA + PRECISION.ERROR
4110            I% = I% + 1
4120            WEND
4130            CALCULATED.AREA = CALCULATED.AREA - PRECISION.ERROR
4140     RETURN
``````

## REGRESS.BAS

``````10 KEY OFF:PRINT:CLS:N\$="IBM PC User Group of Greater Kansas City":N2\$="Keith D. Barber - Librarian":PRINT TAB(19) N\$:PRINT :PRINT TAB(25) N2\$:FOR T=1 TO 1000 :NEXT T:CLS:N4\$="REGRESSION ANALYSES":PRINT TAB(30) N4\$:PRINT
20 PRINT "This program fits a straight line, a geometric curve, and an exponential curve  to a given set of coordinates using the method of least squares.":X\$=CHR\$(253)
30 PRINT "The equation of each curve,the respective coefficient of determination (R ";X\$;"),";"coefficient of correlation (R), and standard error of estimate are printed.":PRINT :PRINT "The form of the three equations are:" :PRINT
40 COLOR 1:PRINT "Straight Line";:COLOR 7:PRINT TAB(23);:COLOR 1:PRINT "Geometric Curve";:COLOR 7:PRINT TAB(48);:COLOR 1:PRINT "Exponential Curve":COLOR 7:PRINT " y = mx + b" TAB(26) "y = bx^m" TAB(52)"y = bm^x":DIM X(100), Y(100)
50 PRINT :INPUT "Enter date in the form of `00/00/83' ",N3\$:PRINT :INPUT "Enter your initials: ",KB\$:PRINT :INPUT "Enter client's name: ", N5\$:PRINT :INPUT "Enter project number: ",N6\$
60 PRINT :PRINT "The `X' value will represent ";:COLOR 0,7:PRINT "                                 ";:COLOR 7,0:PRINT ".":LOCATE 21,30:INPUT " ",N7\$
70 PRINT :PRINT "The `Y' value will represent ";:COLOR 0,7:PRINT "                                 ";:COLOR 7,0:PRINT ".":LOCATE 23,30:INPUT " ",N8\$:CLS:PRINT TAB(21) N\$:PRINT TAB(26) N2\$:PRINT:PRINT TAB(30) N4\$:PRINT :PRINT N5\$; TAB(66) "By ";KB\$
80 PRINT "Project No. "; N6\$; TAB(66) "Date ";N3\$
85 ON ERROR GOTO 500
90 PRINT :PRINT "Total number of points =";:INPUT " ",N:SX=0:SGX=0:SY=0:SGY=0:SX2=0:SGX2=0:SY2=0:SGY2=0:SXY=0:SGXY=0:SEXY=0:R2=0::Z=0:FOR I=1 TO N:PRINT "  X,Y value of point";I;"=";:INPUT " ",X(I),Y(I):NEXT I
91 PRINT "List Data (y/n) ?"
92 C\$=INKEY\$:IF C\$="" THEN 92
93 IF LEFT\$(C\$,1) ="y" OR LEFT\$(C\$,1) ="Y" THEN INPUT "Data Range (Point1,Point 2) ",P1,P2:CLS:PRINT ,"   I","   X","   Y":PRINT ," -----"," -----"," -----":FOR I = P1 TO P2:PRINT ," Point ";I,X(I),Y(I):NEXT I:GOTO 91
94 PRINT "Edit Data (y/n) ?"
95 C\$=INKEY\$:IF C\$="" THEN 95
96 IF LEFT\$(C\$,1) ="y" OR LEFT\$(C\$,1) ="Y" THEN INPUT "Point Number (I) ";I:PRINT "X,Y Value of point";I;: INPUT X(I),Y(I):GOTO 91
99 FOR I=1 TO N:X=X(I):Y=Y(I):IF X>0 THEN XG=LOG(X) ELSE XG=-5
118 IF Y>0 THEN YG=LOG(Y) ELSE YG=-5
119 SX=SX+X : SGX=SGX+XG:SY=SY+Y : SGY=SGY+YG:SX2=SX2+X^2 : SGX2=SGX2+XG^2:SY2=SY2+Y^2 : SGY2=SGY2+YG^2:SXY=SXY+X*Y:SGXY=SGXY+XG*YG:SEXY=SEXY+X*YG:NEXT I:M = (N*SXY-SY*SX)/(N*SX2-SX^2):MG=(N*SGXY-SGY*SGX)/(N*SGX2-SGX^2)
120 ME=(N*SEXY-SGY*SX)/(N*SX2-SX^2):B=(SY-M*SX)/N:BG=(SGY-MG*SGX)/N:BE=(SGY-ME*SX)/N:TX=M*(SXY-SX*SY/N):TGX=MG*(SGXY-SGX*SGY/N):TEX=ME*(SEXY-SX*SGY/N):TY=SY2-SY^2/N:TGY=SGY2-SGY^2/N:K1=TY-TX : KG=TGY-TGX:KE=TGY-TEX:R2=TX/TY : RG2=TGX/TGY:RE2=TEX/TGY
124 B\$=STR\$(ABS(B))
125 IF SGN(B) = -1 THEN SG\$=" * X -" ELSE SG\$=" * X +"
130 CLS:PRINT: K=17:KB=30:PRINT TAB(KB+1) "LINEAR REGRESSION":PRINT:PRINT TAB(K+7) "Y =";M;SG\$;B\$:PRINT :PRINT TAB(K)"Coefficient of Determination (R ";X\$;") =";R2:PRINT TAB(K)"Coefficient of Correlation (R) =";SQR(R2):PRINT
140 PRINT TAB(KB) "GEOMETRIC REGRESSION":PRINT :PRINT TAB(K+7)"Y =";EXP(BG);" * X ^";MG:PRINT :PRINT TAB(K)"Coefficient of Determination (R ";X\$;") =";RG2:PRINT TAB(K)"Coefficient of Correlation (R) =";SQR(RG2):PRINT
150 PRINT TAB(KB-1) "EXPONENTIAL REGRESSION":PRINT :PRINT TAB(K+5)"Y =";EXP(BE);" *";EXP(ME);"^X":PRINT :PRINT TAB(K)"Coefficient of Determination (R ";X\$;") =";RE2:PRINT TAB(K)"Coefficient of Correlation (R) =";SQR(RE2)
160 LOCATE 25,5:PRINT "PRINT OUTPUT (Y/N): "
162 A\$=INKEY\$:IF A\$="" THEN 162
164 IF LEFT\$(A\$,1)="y" OR LEFT\$(A\$,1)="Y" THEN 250
170 LOCATE 25,5:PRINT "PRESS ANY KEY TO BEGIN INTERPOLATION. ";
180 A\$=INKEY\$: IF A\$="" THEN 180
190 CLS:PRINT "             INTERPOLATION  (Enter X = 0 to end program)":LOCATE 5,10:PRINT ,"   X ","   Y1 ","   Yg ","   Ye ":LOCATE 6,10:PRINT ," -------"," -------"," -------"," -------"
200 LOCATE 3,35 :PRINT "                ":LOCATE 3,35:INPUT "x = ",X:IF X=0 THEN 230
210 Y1=M*X+B:YG=EXP(BG)*X^MG:YE=EXP(BE)*EXP(ME)^X:PRINT:Z=Z+1:IF Z=17 THEN Z=0:GOTO 190
220 LOCATE 7+Z,10:PRINT ,X,Y1,YG,YE:GOTO 200
230 LOCATE 9+Z:PRINT "        Analyze more data (y/n)"
234 A\$=INKEY\$: IF A\$="" THEN 234
236 IF LEFT\$(A\$,1)="y" OR LEFT\$(A\$,1)="Y" THEN CLS:GOTO 90
250 WIDTH "lpt1:",132:LPRINT CHR\$(15):GOSUB 300:LPRINT :LPRINT:LPRINT TAB(35)"Point" TAB(55) "X Value (a)"TAB(75)"Y Value (b)":LPRINT TAB(34)"-------" TAB(54) "-------------"TAB(74)"-------------":FOR I=1 TO N
260 LPRINT TAB(33);I;TAB(60);X(I);TAB(80);Y(I):NEXT I:LPRINT:LPRINT TAB(35)"(a) The `X' value represents ";N7\$;".":LPRINT TAB(35)"(b) The `Y' value represents ";N8\$;".":IF N>24 THEN LPRINT CHR\$(12): GOSUB 300
270 LPRINT :LPRINT:K=43:KB=56:LPRINT TAB(KB+1) "LINEAR REGRESSION":LPRINT:LPRINT TAB(K+7) "Y =";M;SG\$;B\$:LPRINT :LPRINT TAB(K)"Coefficient of Determination (R2) =";R2:LPRINT TAB(K)"Coefficient of Correlation (R) =";SQR(R2):LPRINT
280 LPRINT TAB(KB) "GEOMETRIC REGRESSION":LPRINT :LPRINT TAB(K+7)"Y =";EXP(BG);" * X ^";MG:LPRINT :LPRINT TAB(K)"Coefficient of Determination (R2) =";RG2:LPRINT TAB(K)"Coefficient of Correlation (R) =";SQR(RG2):LPRINT
290 LPRINT TAB(KB-1) "EXPONENTIAL REGRESSION":LPRINT :LPRINT TAB(K+5)"Y =";EXP(BE);" *";EXP(ME);" ^X":LPRINT :LPRINT TAB(K)"Coefficient of Determination (R2) =";RE2:LPRINT TAB(K)"Coefficient of Correlation (R) =";SQR(RE2):LPRINT CHR\$(12):GOTO 170
300 LPRINT TAB(47) N\$:LPRINT TAB(52) N2\$:LPRINT:LPRINT TAB(56) N4\$:LPRINT :LPRINT TAB(13); N5\$; TAB(105) "By ";KB\$:LPRINT TAB(13) "Project No. "; N6\$; TAB(105) "Date ";N3\$:RETURN
500 IF ERR=27 OR ERR=25 THEN PLAY"T110L8MSD4MNO3GABO4CD4O3MSG4MNG4O4MSE4MNCDEF#G4O3MSG4MNG4MSO4C4MNDCO3BAMSB4MN04CO3BAG":PRINT "TURN PRINTER ON":RESUME 250
``````

## S1.BAS

``````10  PRINT "PERMUTATIONS AND COMBINATIONS"
20  PRINT
30  PRINT "(ENTER 0 TO END PROGRAM)"
40  PRINT "TOTAL NUMBER OF OBJECTS";
50  INPUT N
60  IF N = 0 THEN 280
70  PRINT "SIZE OF SUBGROUP";
80  INPUT D
90  IF D <  = N THEN 130
100  PRINT "SUBGROUP TOO LARGE"
110  PRINT
120  GOTO 40
130 P = 1
140 C = 1
150  FOR I = N - D + 1 TO N
160  IF 9.899999e+37 / I >  = P THEN 190
170  PRINT "MORE THAN 9.9 * 10^37 PERMUTATIONS"
180  GOTO 280
190 P = P * I
200  NEXT I
210  FOR J = 2 TO D
220 C = C * J
230 NEXT J
240 PRINT P; "PERMUTATIONS"
250 PRINT P/C; "COMBINATIONS"
260 PRINT
269 REM - RESTART PROGRAM
270 GOTO 40
280 RUN "STAT"
``````

## S10.BAS

``````10  CLS:PRINT "STUDENT'S T-DISTRIBUTION TEST"
20  PRINT
30  DIM P(10,2)
40  DIM V(2),R(2),M(2),D(2)
50  PRINT "TEST 1: MEAN=X"
60  PRINT "TEST 2: MEAN=MEAN,STANDARD DEVIATION=STANDARD DEVIATION"
70  PRINT "TEST 3: MEAN=MEAN,STANDARD DEVIATION<>STANDARD DEVIATION"
80  PRINT "WHICH HYPOTHESIS";
90  INPUT T
100  PRINT
110  FOR I = 1 TO  SGN (T - 1) + 1
120 V(I) = 0
130 D(I) = 0
140  PRINT "SAMPLE ";I;":"
150  PRINT "  NUMBER OF ELEMENTS";
160  INPUT R(I)
170  FOR J = 1 TO R(I)
180  PRINT "   ELEMENT" ;J;
190 INPUT P(J,I)
200 V (I) = V (I) + P (J,I)
210 D (I) = D (I) + P (J,I) ^ 2
220 NEXT J
230 M (I) = V (I) / R (I)
240 V (I) = (D(I) - V (I) ^ 2 /R (I)) / (R(I) - 1)
250 NEXT I
260 PRINT
270 IF T = 2   THEN 340
280 IF T = 3  THEN 380
290 PRINT "VALUE OF MEAN";
300 INPUT M
310 A = (M(1) - M) * SQR (R(1) / V (1))
320 B = R (1) - 1
330 GOTO  420
340 A = (M(1) - M (2)) / SQR (1/R (1) + 1/R (2))
350 B = R (1) + R (2) - 2
360 A = A/ SQR (((R(1) -1) * V (1) + (R(2) - 1 * V (2))/B)
370 GOTO  420
380 A = (M(1) - M (2)) / SQR (V(1) / R (1) + V (2) / R (2))
390 B = (V(1) / R (1) + V (2) / R (2)) ^ 2
400 B = B/ ((V(1) / R (1)) ^ 2/ (R(1) + 1) +(V(2) /R (2)) ^ 2 / (R(2) + 1 )) - 2
410 B = INT (B + 0.5)
420 PRINT
430 PRINT "T - VALUE ="; ABS (A)
440 PRINT "DEGREES OF FREEDOM ="; B
445 INPUT "Run again ";A\$
447 IF A\$="Y" OR A\$="y" THEN 10
450 RUN "STAT"
``````

## S11.BAS

``````10  PRINT "F-DISTRIBUTION"
20  PRINT
30  PRINT "(TO END PROGRAM ENTER AN F-VALUE OF 0)"
40  PRINT "F-VALUE";
50  INPUT F
60  IF F = 0 THEN 340
70  PRINT "DEGREES OF FREEDOM IN NUMERATOR";
80  INPUT D1
90  PRINT "DEGREES OF FREEDOM IN DENOMINATOR";
100  INPUT D2
110 X = 1
120  IF F < 1 THEN 170
130 S = D1
140 T = D2
150 Z = F
160  GOTO 200
170 S = D2
180 T = D1
190 Z = 1 / F
200 J = 2 / 9 / S
210 K = 2 / 9 / T
220 Y =  ABS ((1 - K) * Z ^ (1 / 3) - 1 + J) /  SQR (K * Z ^ (2 / 3) + J)
230 IF T < 4  THEN 270
240 X = 0.5 / (1 + Y * ( 0.196854 + Y * (0.115194 + Y * (0.000344 + Y * 0.019527)))) ^ 4
250 X = INT (X * 10000 + 0.5) / 10000
260 GOTO 290
270 Y = Y * (1 + 0.08 * Y ^ 4 / T ^ 3)
280 GOTO 240
290 IF F > = 1  THEN 310
300 X = 1 - X
310 PRINT "PERCENTILE ="; 1-X
320 PRINT
330 GOTO  40
340 RUN "STAT"
``````

## S12.BAS

``````10 CLS:PRINT "LINEAR CORRELATION COEFFICIENT"
20 PRINT
30 PRINT "NUMBER OF POINTS";
40 INPUT N
50 J = 0
60 K = 0
70 L = 0
80 M = 0
90 R = 0
100 FOR I = 1 TO N
110 PRINT "X,Y OF POINT " ;I;
120 INPUT X,Y
130 J = J + X
140 K = K + Y
150 L = L + X ^ 2
160 M = M + Y ^ 2
170 R = R + X * Y
180 NEXT I
190 R2 = (N * R - J * K) / SQR ((N * L - J ^ 2) * (N * M - K ^ 2))
200 PRINT
210 PRINT "COEFFICIENT OF CORRELATION = "; R2
215 INPUT "Run again ";A\$
217 IF A\$="Y" OR A\$="y" THEN 10
220 RUN "STAT"
``````

## S13.BAS

``````10  PRINT "MULTIPLE LINEAR REGRESSION"
20  PRINT
30  DIM X(9),S(9),T(9),A(9,10)
40  PRINT "NUMBER OF KNOWN POINTS";
50  INPUT N
60  PRINT "NUMBER OF INDEPENDENT VARIABLES";
70  INPUT V
80 X(1) = 1
90  FOR I = 1 TO N
100  PRINT "POINT ";I
110  FOR J = 1 TO V
120  PRINT "  VARIABLE ";J;
130  INPUT X(J + 1)
140  NEXT J
150  PRINT "  DEPENDENT VARIABLE";
160  INPUT X(V + 2)
170  FOR K = 1 TO V + 1
180  FOR L = 1 TO V + 2
190 A (K,L) = A (K,L) + X (K) * X (L)
200 S (K) = A (K, V+2)
210 NEXT L
220 NEXT K
230 S (V + 2) = S (V+2) + X (V+2) ^2
240 NEXT I
250 FOR I=2  TO V+1
260 T (I) = A (1,I)
270 NEXT I
280 FOR I=1  TO V+1
290 J = I
300 IF A (J,I) <> 0  THEN 340
305 J = J + 1
310 IF J < = V + 1  THEN 300
320 PRINT "NO UNIQUE SOLUTION"
330 GOTO  810
340 FOR K = 1  TO V + 2
350 B = A (I,K)
360 A (I,K) = A (J,K)
370 A (J,K) = B
380 NEXT K
390 Z = 1 / A (I,I)
400 FOR K=1  TO V+2
410 A (I,K) = Z * A (I,K)
420 NEXT K
430 FOR J=1  TO V+1
440 IF J=I  THEN 490
450 Z =-A (J,I)
460 FOR K=1 TO V+2
470 A (J,K) = A (J,K) + Z * A (I,K)
480 NEXT K
490 NEXT J
500 NEXT I
510 PRINT
520 PRINT "EQUATION COEFFICIENTS:"
525 PRINT "     CONSTANT:"; A (1,V+2)
530 FOR I=2  TO V+1
540 PRINT "VARIABLE("; I-1;"): ";A (I,V+2)
550 NEXT I
560 P = 0
570 FOR I =2  TO V+1
580 P = P +A (I,V+2) * (S(I) - T (I) * S (1)/N)
590 NEXT I
600 R=S (V+2) - S (1) ^2/N
610 Z = R-P
620 L = N - V -1
640 PRINT
650 I = P/R
660 PRINT "COEFFICIENT OF DETERMINATION (R^2) ="; I
670 PRINT "COEFFICIENT OF MULTIPLE CORRELATION =; SQR (I)
680 PRINT "STANDARD ERROR OF ESTIMATE ="; SQR (ABS(Z/L))
690 PRINT
700 PRINT "INTERPOLATION: (ENTER 0 TO END PROGRAM)"
710 P = A (1, V+2)
720 FOR J=1  TO V
730 PRINT "VARIABLE" ;J;
740 INPUT X
750 IF X=0  THEN 810
760 P = P+A (J+1, V+2) *X
770 NEXT J
780 PRINT "DEPENDENT VARIABLE="; P
790 PRINT
800 GOTO 710
810 RUN "STAT"
``````

## S14.BAS

``````10 CLS:PRINT "LINEAR REGRESSION"
20 PRINT
30 PRINT "NUMBER OF KNOWN POINTS";
40 INPUT N
50 J = 0
60 K = 0
70 L = 0
80 M = 0
90 R2 = 0
100 FOR I = 1  TO N
110 PRINT "X,Y OF POINT" ;I;
120 INPUT X,Y
130 J = J + X
140 K = K + Y
150 L = L + X ^ 2
160 M = M + Y ^ 2
170 R2 = R2 + X * Y
180 NEXT I
190 B = (N * R2 - K * J) / (N*L - J ^ 2)
200 A = (K-B * J) /N
210 PRINT
220 PRINT "F (X) = " ;A; " + (" ;B; " * X ) "
230 J = B * (R2-J * K/N)
240 M = M - K ^ 2/N
250 K = M - J
260 PRINT
270 R2 = J/M
280 PRINT "COEFFICIENT OF DETERMINATION (R^2) ="; R2
290 PRINT "COEFFICIENT OF CORRELATION ="; SQR (R2)
300 PRINT "STANDARD ERROR OF ESTIMATE ="; SQR (K/ (N-2))
310 PRINT
320 PRINT "INTERPOLATION: (ENTER X=0 TO END PROGRAM)"
330 PRINT "X =";
340 INPUT X
350 IF X = 0  THEN 390
360 PRINT "Y ="; A + B * X
370 PRINT
380 GOTO  330
385 INPUT "Run again ";A\$
387 IF A\$="Y" OR A\$="y" THEN 10
390 RUN "STAT"
``````

## S15.BAS

``````10 PRINT "NTH-ORDER REGRESSION"
20 PRINT
30 DIM A(13), R(7,8) , T(8)
40 PRINT "DEGREE OF EQUATION";
50 INPUT D
60 PRINT "NUMBER OF KNOWN POINTS";
70 INPUT N
80 A (1) = N
90 FOR I=1  TO N
100 PRINT "X,Y OF POINT" ;I;
110 INPUT X,Y
120 FOR J=2  TO 2 * D+1
130 A (J) = A (J) + X ^ (J-1)
140 NEXT J
150 FOR K=1  TO D+1
160 R (K, D+2) = T(K) +Y *X ^ (K-1)
170 T (K) =T (K) + Y * X ^ (K-1)
180 NEXT K
190 T (D+2) = T (D+2) + Y ^ 2
200 NEXT I
210 FOR J=1  TO D+1
220 FOR K=1  TO D+1
230 R (J,K) = A (J+K-1)
240 NEXT K
250 NEXT J
260 FOR J=1  TO D+1
270 K =J
280 IF R(K,J) <> 0  THEN 320
290 K = K+1
295 IF K< = D+1  THEN 280
300 PRINT "NO UNIQUE SOLUTION"
310 GOTO  790
320 FOR I =1  TO D+2
330 S = R (J,I)
340 R (J,I) = R (K,I)
350 R (K,I) =S
360 NEXT I
370 Z=1 / R (J,J)
380 FOR I=1  TO D+2
390 R (J,I) = Z * R (J,I)
400 NEXT I
410 FOR K=1  TO D+1
420 IF K=J  THEN 470
430 Z =- R (K,J)
440 FOR I=1  TO D+2
450 R (K,I) = R (K,I) + Z * R (J,I)
460 NEXT I
470 NEXT K
480 NEXT J
490 PRINT
495 PRINT "            CONSTANT ="; R(1,D+2)
500 FOR J=1  TO D
510 PRINT J; "DEGREE COEFFICIENT ="; R(J+1, D+2)
520 NEXT J
530 PRINT
540 P =0
550 FOR J=2  TO D+1
560 P = P + R (J,D+2) * (T(J) -A (J) * T(1) /N)
570 NEXT J
580 Q = T (D+2) - T(1) ^2/N
590 Z = Q-P
600 I =N -D - 1
620 PRINT
630 J = P/Q
640 PRINT "COEFFICIENT OF DETERMINATION (R^2) = ";J
650 PRINT "COEFFICIENT OF CORRLELATION ="; SQR (J)
660 PRINT "STANDARD ERROR OF ESTIMATE ="; SQR (Z/I)
670 PRINT
680 PRINT "INTERPOLATION: (ENTER 0 TO END PROGRAM)"
690 P = R (1, D+2)
700 PRINT "X =";
710 INPUT X
720 IF X =0  THEN 790
730 FOR J=1 TO D
740 P = P + R (J +1, D+2) * X ^ J
750 NEXT J
760 PRINT "Y ="; P
770 PRINT
780 GOTO  690
790 RUN "STAT"
``````

## S16.BAS

``````10 PRINT "GEOMETRIC REGRESSION"
20 PRINT
30 PRINT "NUMBER OF KNOWN POINTS";
40 INPUT N
50 J = 0
60 K = 0
70 L = 0
80 M = 0
90 R2 = 0
100 FOR I = 1  TO N
110 PRINT "X,Y OF POINT" ;I;
120 INPUT X,Y
130 Y = LOG (Y)
140 X = LOG (X)
150 J = J + X
160 K = K + Y
170 L = L + X ^ 2
180 M = M + Y ^ 2
190 R2 = R2 + X * Y
200 NEXT I
210 B = (N * R2 - K * J) / (N * L - J ^ 2)
220 A = (K - B * J) /N
230 PRINT
240 PRINT "F (X) ="; EXP (A); " * X ^";B
250 J = B * (R2 - J * K/N)
260 M = M - K ^ 2/N
270 K = M - J
280 PRINT
290 R2 = J/M
300 PRINT "COEFFICIENT OF DETERMINATION (R^2) ="; R2
310 PRINT "COEFFICIENT OF CORRELAION ="; SQR (R2)
320 PRINT "STANDARD ERROR OF ESTIMATE ="; SQR (K/ (N-2))
330 PRINT
340 PRINT "INTERPOLATION: (ENTER X=0 TO END PROGRAM)"
350 PRINT "X =";
360 INPUT X
370 IF X = 0  THEN 410
380 PRINT "Y ="; EXP (A) * X ^ B
390 PRINT
400 GOTO  350
410 RUN "STAT"
``````

## S17.BAS

``````10 PRINT "EXPONENTIAL REGRESSION"
20 PRINT
30 PRINT "NUMBER OF KNOWN POINTS";
40 INPUT N
50 J = 0
60 K = 0
70 L = 0
80 M = 0
90 R2 = 0
100 FOR I = 1  TO N
110 PRINT "X, Y OF POINT" ;I;
120 INPUT X,Y
130 Y = LOG (Y)
140 J = J + X
150 K = K + Y
160 L = L + X ^ 2
170 M = M + Y ^ 2
180 R2 = R2 + X * Y
190 NEXT I
200 B = (N * R2 - K * J) / (N *L - J ^ 2)
210 A = (K - B * J) /N
220 PRINT
230 PRINT "A ="; EXP (A)
240 PRINT "B ="; B
250 J = B * (R2 - J * K/N)
260 M = M - K ^ 2/N
270 K = M - J
280 PRINT
290 R2 = J/M
300 PRINT "COEFFICIENT OF DETERMINATION (R^2) ="; R2
310 PRINT "COEFFICIENT OF CORRELATION ="; SQR (R2)
320 PRINT "STANDARD ERROR OF ESTIMATE ="; SQR (K/ (N-2))
330 PRINT
340 PRINT "INTERPOLATION: (ENTER X=0 TO END PROGRAM)"
350 PRINT "X =";
360 INPUT X
370 IF X = 0  THEN 410
380 PRINT "Y ="; EXP (A) * EXP (B*X)
390 PRINT
400 GOTO 350
410 RUN "STAT"
``````

## S18.BAS

``````10 PRINT "MEAN, VARIANCE, STANDARD DEVIATION"
20 PRINT
30 PRINT "WHICH METHOD (0 = POPULATION, 1 = SAMPLE)";
40 INPUT S
50 PRINT "KIND OF DATA (0 = GROUPED, 1 = UNGROUPED)";
60 INPUT K
70 PRINT "NUMBER OF OBSERVATIONS";
80 INPUT N
90 R = 0
100 M = 0
110 P = 0
120 IF K = 1  THEN 230
130 FOR I = 1  TO N
140 PRINT "ITEM, FREQUENCY" ;I;
150 INPUT A,B
160 R = R + B * A
170 P = P + B
180 M = M + B * A ^ 2
190 NEXT I
200 R = R/P
210 V = (M-P * R ^ 2) / (P-S)
220 GOTO  310
230 FOR I = 1  TO N
240 PRINT "ITEM";I;
250 INPUT D
260 P = P+D
270 M = M + D ^ 2
280 NEXT I
290 R = P/N
300 V = (M-N * R ^ 2) / (N-S)
310 PRINT
320 PRINT "MEAN", "VARIANCE", "STANDARD DEVIATION"
330 PRINT R,V,SQR (V)
340 PRINT
350 PRINT "MORE DATA (1=YES, 0=NO)";
360 INPUT S
370 IF S=1  THEN 20
380 RUN "STAT"
``````

## S2.BAS

``````10  CLS:PRINT "MANN-WHITNEY U-TEST"
20  PRINT
30  DIM X(25),Y(25)
40  DIM N(2)
50  FOR I = 1 TO 2
60  PRINT "SAMPLE ";I; ":"
70  PRINT " SIZE ";
80  INPUT N(I)
90  FOR J = 1 TO N(I)
100  PRINT "   DATA ";J;
110  INPUT Y(J)
120  NEXT J
130  FOR J = 1 TO N(I)
140  FOR K = 1 TO N(I) - J
150 C = Y(K)
160 D = Y(K + 1)
170  IF Y(K) < Y(K + 1) THEN 200
180 Y(K) = Y(K + 1)
190 Y(K + 1) = C
200  NEXT K
210  NEXT J
220  PRINT
230  IF I = 2 THEN 270
240  FOR J = 1 TO N(1)
250 X(J) = Y(J)
260  NEXT J
270 NEXT I
279 REM - ADD UP RANKS
280 R = 1
290 I = 0
300 J = 0
310 I = I + 1
320 J = J + 1
330 IF I > N (1)  THEN 580
340 IF J > N (2)  THEN 620
350 IF X (I) < Y (J)   THEN 620
360 IF Y (J) < X (I)   THEN 590
369 REM - LINES 370 - 570 HANDLE EQUAL SCORES FROM BOTH SAMPLES
370 K = 2
380 M = I
390 L = J
400 R1 = 2 * R + 1
410 R = R + 2
420 I = I + 1
430 J = J + 1
440 IF I > N (1)   THEN 480
450 IF X (I) <> X (I-1)   THEN 480
460 I = I + 1
470 GOTO  510
480 IF J > N (2)   THEN 550
490 IF Y (J) <> Y (J-1)  THEN 550
500 J = J + 1
510 R1 = R1 + R
520 R = R + 1
530 K = K + 1
540 GOTO  440
550 X = X + (I - M)  * R1/K
560 Y = Y + (J-L)  * R1/K
570 GOTO  330
580 IF J > N (2)  THEN 660
590 Y = Y + R
600 J = J + 1
610 GOTO  640
620 X = X + R
630 I = I + 1
640 R = R + 1
650 GOTO  330
659 REM = U1 = NUMBER OF TIMES SAMPLE 1 SCORES PRECEDE SAMPLE 2 SCORES
660 U1 = N (1) * N (2) + N (1) * (N(1) + 1) /2 -X
669 REM - U2 = NUMBER OF TIMES SAMPLE 2 SCORES PRECEDE SAMPLES 1 SCORES
670 U2 = N (1) * N (2) + N (2) * (N(2) + 1) / 2-Y
680 PRINT
690 PRINT "FIRST SAMPLE PRECEDING , U ="; U1
700 PRINT "SECOND SAMPLE PRECEDING, U ="; U2
705 INPUT "Run again ";A\$
706 IF A\$="y" OR A\$="Y" THEN 10
710 RUN "STAT"
``````

## S3.BAS

``````10 PRINT "GEOMETRIC MEAN AND DEVIATION"
20 PRINT
30 PRINT "(TO END PROGRAM ENTER 0 OBSERVATIONS)"
40 PRINT "NUMBER OF OBSERVATIONS";
50 INPUT N
59 REM = TEST FOR END OF PROGRAM
60 IF N = 0  THEN 200
69 REM - COMPUTE WHICH ROOT TO USE
70 P = 1 / N
80 M = 1
90 FOR I = 1  TO N
100 PRINT "ITEM" ;I;
110 INPUT D
119 REM - ITERATIVELY COMPUTE MEAN
120 M = M * D ^ P
129 REM - ACCUMULATE INTERMEDIATE TERM FOR DEVIATION
130 Q = Q + LOG (D) ^ 2
140 NEXT I
150 R = EXP (SQR( Q/ (N-1) - (N/ (N-1) *  (LOG (M)) ^ 2)))
160 PRINT "GEOMETRIC MEAN = "; M
170 PRINT "GEOMETRIC DEVIATION =";R
180 PRINT
190 GOTO  40
200 RUN "STAT"
``````

## S4.BAS

``````10  PRINT "BINOMIAL DISTRIBUTION"
20  PRINT
30  DIM M(3)
40  PRINT "(TO END PROGRAM ENTER 0)"
50  PRINT "NUMBER OF TRIALS";
60  INPUT N
70  IF N = 0 THEN 270
80  PRINT "EXACT NUMBER OF SUCCESSES";
90  INPUT X
100  PRINT "PROBABILITY OF SUCCESS";
110  INPUT P
120 M(1) = N
130 M(2) = X
140 M(3) = N - X
150  FOR I = 1 TO 3
160  IF M(I) = 0 THEN 220
170 A = 1
180  FOR J = 1 TO M(I)
190 A = A * J
200  NEXT J
210 M(I) =  LOG (A)
220  NEXT I
230 R =  EXP (M(1) - M(2) - M(3) + X *  LOG (P) + (N-X) * LOG (1-P))
240 PRINT "PROBABILITY OF ";X; "SUCCESSES IN" ;N; "TRAILS =";R
250 PRINT
260 GOTO  50
270 RUN "STAT"
``````

## S5.BAS

``````10  PRINT "POISSON DISTRIBUTION"
20  PRINT
30  PRINT "(TO END PROGRAM ENTER 0)"
40  PRINT "CALCULATED FREQUENCY";
50  INPUT L
60  IF L = 0 THEN 180
70  PRINT "TEST FREQUENCY";
80  INPUT X
90 A = 1
100  FOR I = 1 TO X
110 A = A * I
120  NEXT I
130 A =  LOG (A)
140 A =  EXP ( - L + X *  LOG (L) - A)
150  PRINT "PROBABILITY OF ";X;" OCCURRENCES = ";A
160  PRINT
170  GOTO 40
180  RUN "STAT"
``````

## S6.BAS

``````10  PRINT "NORMAL DISTRIBUTION"
20  PRINT
30  PRINT "(0=STANDARD,1=NON-STANDARD)"
40  PRINT "WHICH TYPE OF VARIABLE";
50  INPUT S
60  IF S = 0 THEN 120
70  PRINT "MEAN";
80  INPUT M
90  PRINT "STANDARD DEVIATION ";
100  INPUT S
110  GOTO 130
120 S = 1
130  PRINT
140  PRINT "(TO END PROGRAM ENTER X=99999)"
150  PRINT "X = ";
160 INPUT Y
170  IF Y = 99999! THEN 290
180 Y = ABS ((Y-M) /S)
190 R =  EXP ( - (Y ^ 2) / 2) / 2.5066282746#
200  PRINT "FREQUENCY = ";R
210 Z = Y
220 Y = 1 / (1 + 0.33267 * ABS (Y))
230 T = 1 - R* (0.4361836 * Y - 0.1201676 * Y ^ 2 + 0.937298 * Y ^ 3)
240 IF Z > = 0  THEN 260
250 T = 1 - T
260 PRINT "PROBABILITY = "; T
270 PRINT
280 GOTO  150
290 RUN "STAT"
``````

## S7.BAS

``````10  PRINT "CHI-SQUARE DISTRIBUTION"
20  PRINT
30  PRINT "(TO END PROGRAM ENTER 0)"
40  PRINT "DEGREES OF FREEDOM";
50  INPUT V
60  IF V = 0 THEN 280
70  PRINT "CHI-SQUARE";
80  INPUT W
90 R = 1
100  FOR I = V TO 2 STEP  - 2
110 R = R * I
120  NEXT I
130 K = W ^ ( INT ((V + 1) / 2)) *  EXP ( - W / 2) / R
140  IF  INT (V / 2) = V / 2 THEN 170
150 J =  SQR (2 / W / 3.141592653599#)
160  GOTO 180
170 J = 1
180 L = 1
190 M = 1
200 V = V + 2
210 M = M * W / V
220  IF M < 1.000000e-7 THEN 250
230 L = L + M
240 GOTO 200
250 PRINT "TAIL END VALUE ="; 1-J * K * L
260 PRINT
270 GOTO  40
280 RUN "STAT"
``````

## S8.BAS

``````10 CLS:WIDTH 80:CLEAR:PRINT "Chi-Square Test":PRINT
28 REM Limit size of contingency tables to V1(R*C),V2(C),A(R)
29 REM Where R = number of rows, C = number of columns
30 DIM V1(4),V2(2),A(2)
39 REM Lines 50-150 input contingency table
50 INPUT "Number of rows";R
70 INPUT "Number of columns";C
80 PRINT "Contingency Table:"
90 FOR I=1 TO R
100 PRINT "Row";I
110 FOR J=1 TO C
120 PRINT "  Element";J;
130 INPUT V1((I-1)*C+J)
140 NEXT J
150 NEXT I
160 PRINT
169 REM Add up marginal frequencies for each row
170 L=0:M=1
190 FOR I=1 TO R
200 FOR J=1 TO C
210 A(I)=A(I)+V1(M)
220 M=M+1
230 NEXT J
240 L=L+A(I)
250 NEXT I
260 N=R*C
269 REM Add up marginal frequencies for each column
270 FOR I=1 TO C
280 FOR J=1 TO N STEP C
290 V2(I)=V2(I)+V1(J)
300 NEXT J
310 NEXT I
320 Z=0
330 PRINT "Observed Value","Expected Value","Chi^2 Contribution"
340 FOR I=1 TO C
350 PRINT "  Column";I
360 FOR J=1 TO R
369 REM P = Expected cell value
370 P=A(J)*V2(I)/L
375 X=I+(J-1)*C
379 REM Use Yates' correction for contiuity in 2x2 chi-square tests
380 IF R<>2 THEN 390
381 IF C<>2 THEN 390
382 Y=(ABS(V1(X)-P)-0.5)^2/P
383 GOTO 400
389 REM Y = chi-square contribution from this cell
390 Y=(V1(X)-P)^2/P
399 REM Z = Total chi-square value
400 Z=Z+Y
410 PRINT "    ";V1(X),,P,,Y
420 NEXT J
430 NEXT I
440 PRINT
450 PRINT "Chi-Square =";Z
460 PRINT "Degrees of Freedom =";(C-1)*(R-1)
470 PRINT :INPUT "Run again";A\$
480 IF A\$="Y" OR A\$="y" THEN 10
500 RUN "stat"
``````

## S9.BAS

``````10  PRINT "STUDENT'S T-DISTRIBUTION"
20  PRINT
30  PRINT "(TO END PROGRAM ENTER A T-VALUE OF 0)"
40  PRINT "T-VALUE";
50  INPUT T
60  IF T = 0 THEN 340
70  PRINT "DEGREES OF FREEDOM";
80  INPUT D
90 X = 1
100 Y = 1
110 T = T ^ 2
120  IF T < 1 THEN 170
130 S = Y
140 R = D
150 Z = T
160  GOTO 200
170 S = D
180 R = Y
190 Z = 1 / T
200 J = 2 / 9 / S
210 K = 2 / 9 / R
220 L =  ABS ((1 - K) * Z ^ (1 / 3) - 1 + J) /  SQR (K * Z ^ (2 / 3) + J)
230 IF R < 4   THEN 270
240 X = 0.25/ (1 + L * (0.196854 + L * (0.115194 + L * (0.000344 + L * 0.019527)))) ^4
250 X = INT (X * 10000 + 0.5) / 10000
260 GOTO 290
270 L = L * (1 + 0.08 * L ^ 4/R ^ 3)
280 GOTO  240
290 IF T > = 1   THEN 310
300 X = 1 - X
310 PRINT "RIGHT TAIL VALUE =" ;X
320 PRINT
330 GOTO  40
340 RUN "STAT"
``````

## STAT.BAS

``````10 ' EDITED BY ats   11.26.81    STAT.BAS -----------------------
20  CLS : PRINT "STATISTICS PROGRAMS:"
30  PRINT
40  FOR I = 1 TO 19
60  IF I < 10 THEN  PRINT "  ";: GOTO 80
70  PRINT " ";
80  PRINT I;". ";A\$
90  NEXT I
100  PRINT : PRINT : INPUT "WHICH PROGRAM WOULD YOU LIKE TO USE ";A\$
110 IF A\$="19" THEN RUN "MENU"
120  IF VAL(A\$) <1 OR VAL(A\$) >18 THEN RESTORE:GOTO 20
125 CLS:PRINT
130  RUN "S"+A\$
140  DATA "PERMUTATIONS AND COMBINATIONS","MANN-WHITNEY U TEST","GEOMETRIC MEAN","BINOMIAL DISTRIBUTION","POISSON DISTRIBUTION","NORMAL DISTRIBUTION","CHI-SQUARE DISTRIBUTION"
150  DATA  "CHI-SQUARE TEST","STUDENT'S T-DISTRIBUTION","STUDENT'S T-DISTRIBUTION TEST","F-DISTRIBUTION","LINEAR CORRELATION COEFFICIENT"
160  DATA "MULTIPLE LINEAR REGRESSION","LINEAR REGRESSION","NTH ORDER REGRESSION","GEOMETRIC REGRESSION","EXPONENTIAL REGRESSION "
``````

### Directory of PC-SIG Library Disk #0180

`````` Volume in drive A has no label
Directory of A:\

DATANET          17536   5-19-84  10:58a
M1       BAS       384   4-15-82
M10      BAS      1664   4-14-82
M11      BAS      1152   4-15-82
M12      BAS       512   4-14-82
M13      BAS       640   4-14-82
M14      BAS       896  11-13-83   6:32p
M15      BAS      1024  11-13-83   7:02p
M16      BAS       512   4-15-82
M17      BAS       384  11-14-83   9:52a
M18      BAS       512   4-14-82
M19      BAS      1024   4-14-82
M2       BAS       384   4-15-82
M20      BAS      1024  11-14-83  10:09a
M21      BAS       512  11-14-83  10:14a
M22      BAS       896  11-14-83  10:18a
M23      BAS      1920  11-14-83  11:10a
M24      BAS       896   4-15-82
M25      BAS       768  11-14-83  11:30a
M26      BAS      1024  11-14-83  11:34a
M3       BAS       512   4-15-82
M4       BAS       896   4-15-82
M5       BAS      1792   4-15-82
M6       BAS       512   4-15-82
M7       BAS      1024   4-15-82
M8       BAS      2176  11-13-83   6:08p
M9       BAS       640   4-14-82
MATH     BAS      1152  11-14-83  10:46a
MATRIX   BAS      2688   5-19-83   9:58p
NCCLSPRE BAS      1920   2-02-83   6:24p
NORMAL-Z BAS      7424   6-06-82
REGRESS  BAS      4736   3-09-84  11:14p
S1       BAS       640
S10      BAS      1280  11-14-83   9:27p
S11      BAS       768
S12      BAS       512  11-14-83   9:29p
S13      BAS      1664   4-22-82
S14      BAS       896  11-14-83   9:32p
S15      BAS      1536   4-14-82
S16      BAS       896  11-14-83   9:42p
S17      BAS       896   4-14-82
S18      BAS       768   4-14-82
S2       BAS      1664  11-14-83   9:06p
S3       BAS       640   4-14-82
S4       BAS       640   4-14-82
S5       BAS       384   4-14-82
S6       BAS       640  11-14-83   9:15p
S7       BAS       640   4-14-82
S8       BAS      1408  11-26-83   5:51p
S9       BAS       768
STAT     BAS       896   8-16-83   1:43a