How Did the Sinclair ZX80 Calculate Trigonometric Functions?
The Sinclair ZX80 calculated trigonometric functions primarily through the use of pre-calculated lookup tables stored in its read-only memory, rather than relying on complex polynomial series expansions. This approach was necessitated by the computer’s severe hardware constraints, specifically its limited 4KB ROM and 1KB RAM, which required extreme efficiency in code size and execution speed. By storing sine values for a specific range and utilizing mathematical symmetry properties, the ZX80 could derive cosine and tangent values while conserving precious memory resources for the BASIC interpreter and system operations.
Released in 1980, the ZX80 was designed to be an affordable entry point into home computing, powered by a Z80 processor running at 3.25 MHz. The machine’s architecture left very little room for mathematical libraries within the 4KB ROM chip that housed the operating system and Sinclair BASIC. Implementing standard algorithms like Taylor series or CORDIC for trigonometry would have consumed too much space and processing time. Consequently, the engineering team, led by John Grant who wrote the floating-point arithmetic package, opted for a solution that prioritized memory conservation over high-precision mathematical flexibility.
The core of the calculation method involved a lookup table containing sine values for angles between 0 and 90 degrees. When a user requested a sine calculation for any given angle, the software would first normalize the input value to fit within this primary quadrant. The system would then access the stored value directly from the ROM. This method was significantly faster than calculating the value from scratch every time and ensured that the trigonometric routines remained small enough to coexist with the rest of the system software.
To handle cosine and tangent functions, the ZX80 relied on trigonometric identities and symmetry rather than storing additional tables. Since cosine is simply a phase-shifted sine wave, the system could calculate COS(x) by querying the sine table with a modified input value. Similarly, the tangent function was derived by dividing the calculated sine value by the calculated cosine value. This reuse of the single sine table allowed the ZX80 to offer a full suite of trigonometric commands within BASIC without exceeding its tight memory budget.
While this method was efficient, it did impose limitations on precision compared to later machines like the ZX Spectrum, which had more ROM space for refined algorithms. The ZX80 used a 5-byte floating-point format, and the lookup table resolution matched this constraint to provide adequate accuracy for educational and simple graphical tasks. This clever optimization exemplifies the engineering ingenuity of the early microcomputer era, where software had to be meticulously crafted to overcome significant hardware limitations.