Paradox

Developer(s): John Pazmino
Date: 198x
Type: Program
Platform(s): TS 2068

This program simulates Einstein’s Twin Paradox, calculating the time dilation experienced by a traveling twin versus one who remains stationary. The user inputs the traveler’s speed in km/h (capped just below the speed of light at 299,792 km/h), and the program computes elapsed time for each year of an 8-year outward and 8-year inward journey using the relativistic Doppler factor. The outward trip uses the ratio `SQR((1+v)/(1-v))` and the inward trip uses its reciprocal, reflecting the asymmetric aging predicted by special relativity. Results are displayed as the age difference in years, days, hours, minutes, and seconds depending on the magnitude of the difference.


Program Structure

The program is organized into a straightforward linear flow with no subroutines. Lines 10–20 are REMs serving as a header and attribution block. Lines 30–70 handle user-facing prompts and input. Lines 80–230 perform the core relativistic calculations and display per-year tables. Lines 240–300 present the final age-difference summary, and line 330 loops back via RUN after a keypress.

  1. Lines 10–20: REM header
  2. Lines 30–70: Introduction and speed input
  3. Lines 80–100: Input validation and normalization
  4. Lines 110–180: Outward trip calculation and display
  5. Lines 190–230: Inward trip calculation and display
  6. Lines 240–300: Age difference output in multiple units
  7. Lines 310–330: Keypress wait and restart

Relativistic Calculation

The program normalizes the input speed to a fraction of the speed of light at line 100 (LET v=v/299792). Line 110 computes the relativistic Doppler factor a=(1+v)/(1-v). For the outward leg, each year t of Earth time maps to t*SQR(a) years for the traveler (line 160). For the inward leg, line 210 uses t*SQR(1/a), the reciprocal factor. This correctly models the asymmetric time accumulation that resolves the apparent paradox.

Notable Techniques

  • The input guard at line 80 uses 299791.9999 to prevent a division-by-zero in line 110 when v approaches 1 (i.e., exactly the speed of light), since 1-v would become zero.
  • The PAUSE 0 followed by RUN at line 330 is an efficient idiom for waiting for any keypress before restarting the program from the beginning.
  • The lower stream print at line 310 (PRINT #1;) places the prompt on the bottom status line rather than the main screen, keeping the results visible.
  • The age difference is presented conditionally at lines 260–290: each unit is only printed if the value is at least 1 in that unit, avoiding cluttered output for small differences. Line 300 always prints the seconds value regardless.

Bugs and Anomalies

There is an error in the final age-difference calculation at line 250: LET y=tr-t-7. After the inner loop at lines 200–230 exits, t holds the value 9 (the BASIC loop variable increments before the exit condition is tested). The traveler’s total elapsed time is tr, and the Earth twin’s is 16 years (8 out + 8 in). The correct expression should be tr-16, but the code computes tr-9-7 = tr-16, which happens to give the correct result only because the loop variable retains 9 after exit — a coincidental correctness that depends on BASIC’s loop-exit behavior leaving t=9.

Line 280 contains a typo in the conditional multiplier: the IF tests y*3760 but the body prints y*8760. The correct multiplier for hours per year is 8,760, so the threshold test should also use 8,760. This means the hours line may print when the difference is actually less than one hour (if y*3760 >= 1 but y*8760 < 1 — not possible arithmetically since 8760 > 3760, so in practice the hours line will be suppressed when it should print for very small values near 1/8760 of a year).

LineUnitMultiplier in IFMultiplier in PRINTCorrect?
260Years11Yes
270Days365365Yes
280Hours37608760No — IF uses wrong value
290Minutes525600525600Yes
300Seconds(always)31536000Yes

Image Gallery

Source Code

  10 REM \{20}\{1}> PARADOX OF 2 TWINS <\{20}\{0}                                        by John Pazmino                                          \* Timex/Sinclair User   V. 1, #7 
  20 REM based on Einstein's Twin Paradox theory
  30 PRINT "* * PARADOX OF THE TWO TWINS * *"
  40 PRINT ,,"Twin 1 stays on Earth.  Twin 2  travels for 8 years and returns"
  50 PRINT ,,"How much younger is twin 2 than twin 1?"
  60 PRINT ,,"Input speed of twin 2 (speed of light. 299,792 KM/H is maximum)"
  70 INPUT v
  80 IF v>299791.9999 THEN GO TO 60
  90 CLS 
 100 LET v=v/299792
 110 LET a=(1+v)/(1-v)
 120 PRINT "PCT of light=";v*100
 130 PRINT "Yrs for 2","Yrs for 1"
 140 PRINT "Outward Trip"
 150 FOR t=1 TO 8
 160 LET to=t* SQR a
 170 PRINT t,to
 180 NEXT t
 190 PRINT "Inward Trip"
 200 FOR t=1 TO 8
 210 LET tr=to+t* SQR (1/a)
 220 PRINT t+8,tr
 230 NEXT t
 240 LET a$="Younger by "
 250 LET y=tr-t-7
 260 IF y >=1 THEN PRINT a$;y;" yrs."
 270 IF (y*365) >=1 THEN PRINT a$;y*365;" days"
 280 IF (y*3760) >=1 THEN PRINT a$;y*8760;" hrs."
 290 IF (y*525600) >=1 THEN PRINT a$;y*525600;" mins."
 300 PRINT a$;y*31536000;" secs."
 310 PRINT #1;"INKEY$ for next RUN :"
 330 PAUSE 0:RUN 

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.