"QUANTIZE" for Commodore-64
NOTE: N,O,P,Q are substituted for b,e,d,a, in this program.
10 LET Y=0.001: Rem This is the allowable error factor for 1 part per million.(0.01 for error of 1/10,000)
20 INPUT "ENTER PERIGEE"; KO
30 INPUT "ENTER APOGEE"; JO
40 LET DO= (JO+KO)/2: Rem this obtains the semi-major diameter,D
50 FOR P= 1 TO 200000: Rem This starts a loop for trial root P= root d'
60 LET M=DO/P^2: Rem A square into semi-major diameter, for a multiplier.
70 LET N=M*JO/P: Rem Find trial root b' for trial root d'.
SEPARATE OUT POSSIBLE QUALIFYING SOLUTIONS.
80 If N>P THEN NEXT: Rem--short cuts the loop (b' must be less than d').
90 IF INT(N)=INT(N+1-Y) THEN GOTO 140: Rem Error factor is used to round down when N=x.000 to x.001
100 IF INT(N)=INT(N-1+Y) THEN GOTO 120: Rem, error factor is used to rounds up when n=x.999 to x+1.00
110 NEXT P: Rem next trial value
120 LET N = INT(N+1)
130 GOTO 150
140 LET N= INT(N): Cancels out error
150 Gosub 1000: Rem Check for co- primeness according to Euclid VII-28
OUTPUT PRINTED & CHECKED
160 LET O= P-N: LET Q=P+O: REM Find roots e & a.
170 PRINT "N,O,P,Q=";N;",";O;","; P;",";Q: Rem Print out roots.
180 PRINT "PERIGEE=";P*N*M; "APOGEE =";P*Q*M: Rem Quantized values multiplied by the "coefficient" M to show quantum values in conventional math terms for corrected ellipse.
190 PRINT "ENTERED";JO;KO: Rem The empirical values entered.
SUB-ROUTINE FOR CHECKING PRIMENESS
1000 LET A=P: LET B=N: Rem Substitution to preserve calculations.
1010 IF A>B THEN LET A=A-B
1020 IF B>A THEN LET B=B-A
1030 IF A<>B THEN GOTO 1010
1040 IF A=B AND B<>1 THEN GOTO 1010
1050 RETURN: Rem continue to output stage, — line 160-190.