--- title: "Algebra I" id: 50667 type: "computer_media" slug: "algebra-i" url: "http://localhost/computer_media/algebra-i/" markdown_url: "http://localhost/computer_media/algebra-i.md" published_at: "2023-06-25T13:06:19+00:00" modified_at: "2026-04-02T15:27:59+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "Solve any quadratic equation instantly — real or complex roots displayed clearly, with clean input validation to keep the math honest." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "Timex Computer Corporation" slug: "timex-computer-corporation" taxonomy: "post_tag" url: "http://localhost/tag/timex-computer-corporation/" - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" - name: "ZX81" slug: "zx81" taxonomy: "post_tag" url: "http://localhost/tag/zx81/" model: - name: "Sinclair ZX81" slug: "zx81" taxonomy: "model" url: "http://localhost/model/zx81/" - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" genre: - name: "Education" slug: "education" taxonomy: "genre" url: "http://localhost/type/education/" media_type: "Cassette" download_url: "https://archive.org/download/Sinclair_ZX81_TOSEC_2012_04_23/Sinclair_ZX81_TOSEC_2012_04_23.zip/Sinclair%20ZX81%20%5BTOSEC%5D%2FSinclair%20ZX81%20-%20Educational%20%28TOSEC-v2011-09-24_CM%29%2FAlgebra%201%20-%20Roots%20of%20Quadratic%20Equations%20%2819xx%29%28-%29.zip" mediadate: "198x" producer_company: - id: 11401 title: "Timex Computer Corporation" type: "company" url: "http://localhost/company/timex-computer-corporation/" related_products: - id: 11743 title: "Algebra I" type: "product" url: "http://localhost/product/algebra-i/" media_type_tags: "Education" --- This program solves quadratic equations of the form AX² + BX + C = 0 using the quadratic formula, handling both real and complex roots. It computes the discriminant S = B²−4AC; if negative, it calculates the real and imaginary parts separately and displays the complex conjugate pair in the form a ± bI. The program uses SLOW mode during input and output for readability, switching to FAST mode during computation. A DIM A$(1) declaration at line 16 allocates a single-character string for the yes/no prompt response. Input validation ensures coefficient A is non-zero, preventing division by zero in the root calculations. *** ## Program Analysis ### Program Structure The program is organized into a straightforward linear flow with two branch points. Lines 10–46 handle setup and coefficient input, lines 47–109 perform computation and output results, and lines 110–160 manage the repeat-or-quit loop. The overall structure is: 1. Initialize display and prompt for coefficients A, B, C (lines 10–46) 2. Compute discriminant and roots (lines 47–109) 3. Ask user to repeat or quit (lines 110–160) 4. Save line at 170–180 (never reached during normal execution) ### Mathematical Approach The discriminant is calculated at line 50 as `S = B*B - 4*A*C`. Line 60 computes `R = SQR(ABS S)`, taking the absolute value before the square root so that the same variable `R` holds the magnitude regardless of the sign of `S`. The branch at line 70 then determines whether roots are real (S ≥ 0) or complex (S < 0). For real roots, line 85 prints both values directly using the quadratic formula: `(-B-R)/(2*A)` and `(R-B)/(2*A)`. For complex roots, line 102 reassigns `S` to hold the imaginary coefficient `R/(2*A)`, and lines 103–104 print the conjugate pair in the form `a + bI` / `a - bI`. ### Key BASIC Idioms - `DIM A$(1)` at line 16 — allocates a one-character string variable for the Y/N response, required before string input can be accepted. - `SLOW` / `FAST` toggling (lines 15, 47, 115) — switches between display-synchronised and full-speed execution modes at appropriate points. - `IF A=0 THEN GOTO 33` at line 36 — simple validation loop that re-prompts until a non-zero coefficient A is entered, preventing a division-by-zero error. - `IF A$="Y" THEN RUN` at line 135 — restarts the entire program from the beginning rather than using a GOTO, which cleanly reinitializes all variables. ### Notable Techniques The reuse of variable `S` at line 102 is a minor space-saving idiom: after the discriminant has served its purpose in the branch test, the variable is repurposed to store the imaginary part of the complex roots. This avoids introducing an additional variable at the cost of some readability. Lines 30–31 simulate a superscript “2” for the equation display by printing it on the line above the formula text, achieving a rudimentary typeset appearance within the constraints of the character-based display. ### Bugs and Anomalies - The `PRINT "ENTER COEFFICIENT A";` at line 33 is paired with `INPUT A` at line 34, then `PRINT " ";A` at line 35. The echo print after INPUT is somewhat redundant since the value is already visible on-screen from the INPUT prompt, but causes no error. - Lines 150–160 form a fallthrough handler for invalid yes/no input, printing a message and looping back to line 120. However, line 150 says “ENTER YES OR NO” while the program only accepts single characters “Y” or “N” — a minor mismatch between the prompt text and actual validation logic. - Lines 170–180 (SAVE and GOTO 10) are only reachable if execution somehow falls through line 160’s `GOTO 120`, which cannot happen under normal conditions. They serve as a save-and-restart block intended to be run manually or jumped to directly. ### Variable Summary | Variable | Purpose | | --- | --- | | `A` | Coefficient of x² term; also reused as yes/no string variable name prefix | | `B` | Coefficient of x term | | `C` | Constant term | | `S` | Discriminant (B²−4AC); later repurposed as imaginary coefficient | | `R` | Square root of \|S\| | | `A$` | Single-character user response (“Y” or “N”) | ## Source Code ``` 10 CLS 15 SLOW 16 DIM A$(1) 20 PRINT "ROOTS OF QUADRATIC EQUATIONS" 25 PRINT 30 PRINT " 2" 31 PRINT "WHERE AX +BX +C = 0" 32 PRINT 33 PRINT "ENTER COEFFICIENT A"; 34 INPUT A 35 PRINT " ";A 36 IF A=0 THEN GOTO 33 38 PRINT "ENTER COEFFICIENT B"; 39 INPUT B 40 PRINT " ";B 41 PRINT "ENTER COEFFICIENT C"; 45 INPUT C 46 PRINT " ";C 47 FAST 50 LET S=B*B-4*A*C 60 LET R=SQR (ABS S) 70 IF S<0 THEN GOTO 100 80 PRINT "THE ROOTS ARE REAL AND ARE:" 85 PRINT (-B-R)/(2*A);" AND ";(R-B)/(2*A) 90 GOTO 110 100 PRINT "THE ROOTS ARE COMPLEX NUMBERS:" 102 LET S=R/(2*A) 103 PRINT " ";-B/(2*A);" + ";S;" I" 104 PRINT "AND ";-B/(2*A);" - ";S;" I" 110 PRINT 115 SLOW 120 PRINT "DO YOU WANT TO DO ANOTHER ONE?" 130 INPUT A$ 135 IF A$="Y" THEN RUN 140 IF A$="N" THEN STOP 150 PRINT "ENTER YES OR NO" 160 GOTO 120 170 SAVE "QUADRATI[C]" 180 GOTO 10 ```