BEGIN:
CLS : SCREEN 0: WIDTH 80
LOCATE 10, 30: PRINT "CARLYLE CIRCLES"
LOCATE 11, 30: PRINT " STEVE DUTCH"
LOCATE 12, 22: PRINT "UNIVERSITY OF WISCONSIN-GREEN BAY"
LOCATE 13, 30: PRINT "6 JANUARY 1997"
LOCATE 18, 25: PRINT "PRESS ANY KEY TO CONTINUE";
X$ = "": WHILE X$ = "": X$ = INKEY$: WEND
CONST PI = 3.141593
REM SCREEN PARAMETERS
PXW = 320: PXH = 200: PAR = PXW / PXH: REM PIXEL DIMENSIONS
SW = 26: SH = 17: SAR = SW / SH: REM PHYSICAL DIMENSIONS OF SCREEN
REM DEFINE A SQUARE VIEWPORT
PTH = (21 / 24) * PXH: REM PORT HEIGHT IN PIXELS
PTW = PTH * PAR / SAR
CLS
PRINT "CARLYLE CIRCLES": PRINT
PRINT "CARLYLE CIRCLES ARE A GRAPHICAL WAY OF SOLVING QUADRATIC EQUATIONS"
PRINT : PRINT "GIVEN THE QUADRATIC EQUATION:"
PRINT " 2"
PRINT " X - PX + Q,": PRINT
PRINT "LOCATE POINTS (0,1) AND (P,Q). DRAW A CIRCLE USING THOSE TWO POINTS"
PRINT "AS ENDPOINTS OF A DIAMETER.": PRINT
PRINT "THE INTERSECTIONS OF THE CIRCLE WITH THE X-AXIS ARE THE"
PRINT "SOLUTIONS TO THE EQUATION"
PRINT : PRINT "TYPE P TO SEE THE PROOF";
PRINT : PRINT "OR ANY OTHER KEY TO DISPLAY THE CONSTRUCTION";
X$ = "": WHILE X$ = "": X$ = INKEY$: WEND
IF X$ <> "P" AND X$ <> "p" THEN GOTO DISPLAY
CLS : PRINT : PRINT "PROOF: The center of the circle is at (P/2, (1+Q)/2)."
PRINT : PRINT " 2 2"
PRINT "Its radius is "; CHR$(251); "(P + (Q-1) )/2. The equation of the circle"
PRINT : PRINT " 2 2 2 2"
PRINT "is therefore: (X-P/2) + (Y-(1+Q)/2) = (P + (Q-1) )/4."
PRINT "When the circle crosses the X-Axis, Y=0."
PRINT "We set Y=0, expand the equation and get"
PRINT : PRINT " 2 2 2 2 2 "
PRINT "X - PX + P /4 + (1 + 2Q + Q )/4 = P /4 + (1 - 2Q + Q )/4 OR,"
PRINT : PRINT " 2"
PRINT "X - PX + Q = 0. Thus the points where the circle crosses the X-Axis"
PRINT "are also the solutions to the quadratic equation."
PRINT : PRINT "PRESS ANY KEY TO DISPLAY THE CONSTRUCTION";
X$ = "": WHILE X$ = "": X$ = INKEY$: WEND
DISPLAY:
SCREEN 1
VIEW (0, 0)-(PTW, PTH): REM CREATE VIEWPORT
WINDOW (0, 0)-(100, 100): REM TEMPORARY WINDOW
LINE (0, 0)-(100, 100), , B: REM BORDER
REM INPUT PARABOLA PARAMETERS
LOCATE 1, 25: PRINT "EQUATION:"
LOCATE 3, 25: PRINT " 2"
LOCATE 4, 25: PRINT "X - PX + Q"
LOCATE 6, 25: INPUT "INPUT P "; P$
P = VAL(P$)
LOCATE 7, 25: INPUT "INPUT Q "; Q$
Q = VAL(Q$)
LOCATE 4, 25: PRINT "X -"; P; "X +"; Q
LOCATE 6, 25: PRINT SPC(16);
LOCATE 7, 25: PRINT SPC(16);
REM NOW DEFINE PLOT WINDOW
R = SQR(P * P + (Q - 1) * (Q - 1)) / 2
XC = P / 2: YC = (1 + Q) / 2
MAXSIZE = 2 * R
IF MAXSIZE = 0 THEN MAXSIZE = 1
MAXSIZE = 3 * MAXSIZE / 2
LFT = XC - MAXSIZE / 2
RGT = XC + MAXSIZE / 2
TOP = YC + MAXSIZE / 2
BOT = YC - MAXSIZE / 2
WINDOW (LFT, TOP)-(RGT, BOT)
MAIN:
REM PLOT AXES
LINE (0, TOP)-(0, BOT), 3
LINE (LFT, 0)-(RGT, 0), 3
REM PLOT TICKS
TKS = MAXSIZE / 100: REM TICK SIZE
FOR X = INT(LFT) TO INT(RGT)
LINE (X, TKS)-(X, -TKS)
NEXT X
FOR Y = INT(BOT) TO INT(TOP)
LINE (TKS, Y)-(-TKS, Y)
NEXT Y
LOCATE 6, 25: PRINT "PRESS ANY KEY TO"
LOCATE 7, 25: PRINT "PLOT (0,1),(P,Q)"
X$ = "": WHILE X$ = "": X$ = INKEY$: WEND
LINE (TKS, 1 + TKS)-(-TKS, 1 - TKS), 2, B
LINE (P + TKS, Q + TKS)-(P - TKS, Q - TKS), 2, B
PSET (0, 1), 2
PSET (P, Q), 2
REM DRAW CARLYLE CIRCLE
LOCATE 6, 25: PRINT "PRESS ANY KEY TO"
LOCATE 7, 25: PRINT "DRAW CIRCLE "
X$ = "": WHILE X$ = "": X$ = INKEY$: WEND
R = SQR(P * P + (Q - 1) * (Q - 1)) / 2
X0 = XC + R: Y0 = YC
FOR T = 0 TO 2.01 * PI STEP .01
X1 = XC + R * COS(T): Y1 = YC + R * SIN(T)
LINE (X0, Y0)-(X1, Y1), 2
X0 = X1: Y0 = Y1
NEXT T
LOCATE 6, 25: PRINT "PRESS ANY KEY TO"
LOCATE 7, 25: PRINT "DISPLAY PARABOLA"
X$ = "": WHILE X$ = "": X$ = INKEY$: WEND
REM NOW DRAW PARABOLA
X0 = LFT: Y0 = X0 * X0 - P * X0 + Q
FOR X1 = LFT TO RGT STEP MAXSIZE / 100
Y1 = X1 * X1 - P * X1 + Q
LINE (X0, Y0)-(X1, Y1), 1
X0 = X1: Y0 = Y1
NEXT X1
REM SHOW SOLUTIONS
SR = P * P - 4 * Q
IF SR > 0 THEN
R1 = (P - SQR(SR)) / 2
R2 = (P + SQR(SR)) / 2
LOCATE 10, 25: PRINT "TWO REAL "
LOCATE 11, 25: PRINT "SOLUTIONS:"
LOCATE 12, 25: PRINT R1
LOCATE 13, 25: PRINT R2
END IF
IF SR = 0 THEN
R1 = P / 2: R2 = R1
LOCATE 10, 25: PRINT "ONE REAL"
LOCATE 11, 25: PRINT "SOLUTION:"
LOCATE 12, 25: PRINT R1
END IF
IF SR < 0 THEN
S = SQR(-SR)
LOCATE 10, 25: PRINT "TWO COMPLEX"
LOCATE 11, 25: PRINT "SOLUTIONS:"
LOCATE 12, 25: PRINT P / 2; "+"
LOCATE 13, 27: PRINT S; "i"
LOCATE 15, 25: PRINT P / 2; "-"
LOCATE 16, 27: PRINT S; "i"
END IF
FINAL.MENU:
LOCATE 18, 25: PRINT "OPTIONS"
LOCATE 19, 25: PRINT "1 - REPEAT"
LOCATE 20, 25: PRINT "2 - RESCALE"
LOCATE 21, 25: PRINT "3 - NEW EXAMPLE"
LOCATE 22, 25: PRINT "4 - QUIT"
X$ = "": WHILE X$ = "": X$ = INKEY$: WEND
IF X$ = "1" THEN
CLS
LINE (LFT, TOP)-(RGT, BOT), 3, B
FOR I = 6 TO 23: LOCATE I, 25: PRINT SPC(16); : NEXT I
GOTO MAIN
END IF
IF X$ = "2" THEN
CLS : SCREEN 0: WIDTH 80
PRINT "LEFT EDGE COORDINATE IS "; LFT
INPUT " INPUT NEW VALUE OR PRESS RETURN TO ACCEPT "; X$
IF X$ <> "" THEN LFT = VAL(X$)
PRINT "RIGHT EDGE COORDINATE IS "; RGT
INPUT " INPUT NEW VALUE OR PRESS RETURN TO ACCEPT "; X$
IF X$ <> "" THEN RGT = VAL(X$)
PRINT "TOP EDGE COORDINATE IS "; TOP
INPUT " INPUT NEW VALUE OR PRESS RETURN TO ACCEPT "; X$
IF X$ <> "" THEN TOP = VAL(X$)
PRINT "BOTTOM EDGE COORDINATE IS "; BOT
INPUT " INPUT NEW VALUE OR PRESS RETURN TO ACCEPT "; X$
IF X$ <> "" THEN BOT = VAL(X$)
SCREEN 1: CLS
VIEW (0, 0)-(PTW, PTH): REM CREATE VIEWPORT
WINDOW (LFT, TOP)-(RGT, BOT)
LINE (LFT, TOP)-(RGT, BOT), 3, B
LOCATE 1, 25: PRINT "EQUATION:"
LOCATE 3, 25: PRINT " 2"
LOCATE 4, 25: PRINT "X -"; P; "X +"; Q
GOTO MAIN
END IF
IF X$ = "3" THEN
CLS
SCREEN 0: WIDTH 80
GOTO BEGIN
END IF
IF X$ <> "4" THEN GOTO FINAL.MENU
END