PRINT PRINT "Finds two company-stocked 1% resistors that best satisfy the" PRINT "given equation." REM ****** REM 1% resistors stocked by [your company] (be sure to set MaxRes) REM ****** DATA 2.74, 10, 47.5, 100, 316, 432, 475, 562, 825 DATA 1000, 1100, 1150, 1430, 1500, 2000, 2490, 2740, 3010 DATA 3320, 3920, 4320, 4640, 4710, 4750, 5110, 5360, 6200 DATA 6810, 6980, 7870, 8250, 10000, 16200, 20000, 24900, 25500 DATA 30900, 47000, 100000, 130000, 150000, 200000, 243000, 24900, 310000 REM ****** REM load resistor value list into array REM ****** MaxRes = 44 DIM ResVals!(MaxRes + 1): FOR Res = 0 TO MaxRes: READ ResVals!(Res): NEXT Res REM ****** REM the formula to be satisfied REM ****** DEF FNError (A, B) = 1! / B - 1.4 / A + 1! / 15000 REM ****** REM compute ideal resistor pair by exhaustive search REM ****** BestOuter = 0: BestInner = 0: MinErr! = 1000 FOR Outer = 0 TO MaxRes - 1: FOR Inner = 0 TO MaxRes - 1 IF ABS(FNError(ResVals(Outer), ResVals(Inner))) < MinErr THEN MinErr = ABS(FNError(ResVals(Outer), ResVals(Inner))) BestOuter = Outer BestInner = Inner END IF NEXT Inner, Outer REM ****** REM print results & bail to OS REM ****** PRINT USING "Use ######.# and ######.# resistors"; ResVals(BestOuter); ResVals(BestInner) SYSTEM