Superposition

Developer(s): Allan Feldman
Date: 1982
Type: Program
Platform(s): ZX81, TS 1000
Tags: Science

Enter the amplitude and frequency of each of two waves. The program plots both waves, then PRESS ENTER FOR SUPERPOSITION plots their sum, scaling it down if it would run off the screen and telling you by how much. It needs 16K.

As printed, only sums above the screen are scaled; a sum far below the axis gives a negative PLOT position and the program stops with report B.

Published in Syntax December 1982 (Superposition).

Related Articles

Program models superposition by graphing two sinusoids, waves of constant wavelength and amplitude, and their combination.

Image Gallery

Source Code

  10 REM SUPERPOSITION
  20 PRINT "SUPERPOSITION"
  30 PRINT
  35 PRINT "NOTE-AMPLITUDE MUST BE"
  36 PRINT "     LESS THAN OR EQUAL TO 2"
  40 DIM A(2)
  50 DIM T(2)
  60 DIM Y(63,2)
  70 FOR I=1 TO 2
  80 PRINT "WHAT IS THE AMPLITUDE"
  82 PRINT "OF WAVE";I;"?"
  85 INPUT A(I)
  90 PRINT "WHAT IS THE FREQUENCY"
  92 PRINT "OF WAVE";I;"?"
  95 INPUT T(I)
 100 NEXT I
 110 CLS
 120 PRINT "SUPERPOSITION"
 140 FOR I=1 TO 2
 150 FOR X=1 TO 63
 160 LET Y(X,I)=A(I)*SIN (T(I)*X*PI/32)
 170 PLOT X,22+10*Y(X,I)
 180 NEXT X
 190 NEXT I
 200 PRINT AT 21,0;"PRESS ENTER FOR SUPERPOSITION"
 205 INPUT Z$
 210 CLS
 212 LET C=1
 215 FAST
 220 FOR X=1 TO 63
 230 LET YS=(Y(X,1)+Y(X,2))/C
 235 IF YS>2 THEN GOTO 500
 240 PLOT X,22+10*YS
 250 NEXT X
 255 IF C>1 THEN PRINT AT 21,0;"AMPLITUDE DIVIDED BY ";C
 260 STOP
 500 LET C=C+1
 510 CLS
 520 GOTO 220

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