Superposition

Author(s): Allan Feldman
Publication: Syntax
Pub Details: Syntax/Syntax ZX80 v3 n12 (Volume 3, Issue 12)
Date: December 1982
Pages: 4

Waves of light, sound or water create disturbances in the medium they travel through. Their height (amplitude) affects the disturbance they create. When they meet at the same point in space, their amplitudes add. This process is called superposition.

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

You can specify the amplitude and frequency for each wave. The maximum amplitude of a single wave is 2 (this will fill the television screen). If you set the frequency at 1, you get one sine wave on the screen. The program then prompts for the same information for the second wave. If the frequency is three, you get three complete waves. The program prompts for the amplitude and frequency of the each wave in turn, then graphs the two waves on the screen. The program then waits for you to tell it to graph the superposition.

Since the greatest amplitude that can be shown is 2, the program checks for too large a sum. If the sum exceeds 2 the superposition is divided by a factor. At the end of the run, you are told the factor. You can avoid the subroutine that divides, just replace line 36 with PRINT” LESS THAN OR EQUAL TO 1″.

To run SUPERPOSITION, enter the program listing, RUN and ENTER.

  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
SYNTACTIC SUM: 44205, 8K/16K

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