DEFDBL a-z CONST eps = .01 CLS PRINT " " PRINT " " PRINT "Astrophysics with a PC : DYNAMICAL PARALLAX" PRINT "-------------------------------------------" PRINT " " PRINT "---------- Minimal solution program -------" PRINT " " PRINT "Input of the observed data :" INPUT "Orbital period (years) : ", p INPUT "Apparent distance (arc seconds) : ", a INPUT "Apparent magnitude of first component : ", mv1 INPUT "Apparent magnitude of second component : ", mv2 INPUT "Bolometric correction of first component : ", bc1 INPUT "Bolometric correction of second component : ", bc2 PRINT " " PRINT _ " i m1 m2 dist par Mb1 Mb2" ' select starting values for the two masses m1 = 1! m2 = 1! stopcrit% = 0 i% = 1 DO 'Main cycle that stops when the two masses have converged par = a / p ^ (2 / 3) / (m1 + m2) ^ (1 / 3) mabs1 = mv1 + 5 + 5 * LOG(par) / LOG(10!) mabs2 = mv2 + 5 + 5 * LOG(par) / LOG(10!) mb1 = mabs1 - bc1 mb2 = mabs2 - bc2 m11 = 10 ^ (.58 - .112 * mb1) ' new approximation ' of first mass m22 = 10 ^ (.58 - .112 * mb2) ' new approximation ' of second mass dis = 1 / par * 3.26 ' new approximation ' of the distance ' show iterations on screen PRINT USING "### ######.## ######.## #####.### ######.##" &_ " ######.# ######.#"; i%; m1; m2; par; dis; mb1; mb2 ' check convergence (if yes, stopcrit% becomes 1) IF (ABS(m1 - m11) < eps) AND (ABS(m2 - m22) < eps) THEN stopcrit% = 1 ELSE m1 = m11 m2 = m22 i% = i% + 1 END IF LOOP UNTIL (stopcrit% = 1) OR (i% > 15) ' show final results on screen IF i% > 15 THEN PRINT "Method does not converge for your input" ELSE PRINT USING "Final results : mass of 1st component : " &_ "###.##"; m11 PRINT USING " mass of 2nd component : " &_ "###.##"; m22 PRINT USING " distance in light yrs : " &_ "###.##"; dis END IF PRINT "Press any key to stop the program" DO LOOP WHILE INKEY$ = "" END