50 REM WAVES-COPYRIGHT 1970, POLYTECHNIC INSTITUTE OF BROOKLYN
100 REM  JOHN W. HOSIE, NORTHPORT HS, PHYSICS, 8/9/68
105 REM  REVISED BY C.LOSIK  8-17-70 
110 REM  WE SORT THE W(I) TO PLOT THE WAVE VALUES. 
115 REM  L,A,P ARE WAVELENGTH, AMPLITUDE, AND PHASE
120 DIM W(3) 
124 REM  TWO PI !
125 LET P2=2*3.14159 
130 PRINT " ","WAVES AND THEIR SUPERPOSITION"
140 PRINT "DO YOU NEED INSTRUCTIONS (1=YES, 0=NO) : "; 
150 INPUT A
160 IF A=0 THEN 350
170 IF A<>1 THEN 140 
180 PRINT
190 PRINT "IN THIS PROGRAM YOU MAY OBSERVE THE EFFECTS OF" 
200 PRINT "CHANGING WAVELENGTH, AMPLITUDE, AND PHASE ON TWO" 
210 PRINT "WAVES AND ON THEIR SUM (OR SUPERPOSITION)." 
220 PRINT
230 PRINT "WAVE 'A' IS FIXED.  ITS WAVELENGTH IS 4, ITS AMPLITUDE" 
240 PRINT "IS 10, AND ITS PHASE IS 0." 
250 PRINT
260 PRINT "WAVE 'B' MAY BE CHANGED BY YOU.  FOR BEST RESULTS :"
270 PRINT " ","WAVELENGTH (L) BETWEEN 2 AND 4" 
280 PRINT " ","AMPLITUDE (A) BETWEEN 5 AND 10" 
290 PRINT " ","PHASE (P) BETWEEN 0 AND 1"
300 PRINT " ","(FOR EXAMPLE, .5 PHASE = 1/2 WAVELENGTH"
310 PRINT
320 PRINT "IT IS EASIEST TO SEE THE EFFECTS OF CHANGES IN EACH"
330 PRINT "PARAMETER IF YOU HOLD TWO CONSTANT AND VARY THE OTHER," 
340 PRINT "ALTHOUGH ALL THREE MAY BE VARIED AT ONCE."
350 PRINT
360 PRINT "WHAT IS YOUR CHOICE OF WAVELENGTH, AMPLITUDE, AND PHASE"; 
370 INPUT L,A,P
373 IF L>0 THEN 380
375 PRINT "WAVELENGTH IS ALWAYS A POSITIVE QUANTITY."
377 GO TO 350
380 IF L<=8 THEN 410 
390 PRINT "YOUR WAVELENGTH IS TOO LONG FOR GOOD DISPLAY."
400 GO TO 350
410 IF L>=1 THEN 415 
412 PRINT "YOUR WAVELENGTH IS TOO SHORT FOR GOOD DISPLAY." 
413 GO TO 350
415 IF ABS(A)<=15 THEN 440 
420 PRINT "YOUR AMPLITUDE IS TOO LARGE FOR DISPLAY." 
430 GO TO 350
440 IF ABS(P-.5)<=.5 THEN 470
450 PRINT "YOUR PHASE CAN ONLY BE BETWEEN 0 AND 1."
460 GO TO 350
470 PRINT
480 PRINT "NOTATION:","A = 'A' WAVE" 
490 PRINT " ","B = 'B' WAVE" 
500 PRINT " ","S = SUPERPOSITION WAVE" 
510 PRINT
520 PRINT "      X (CM.)","     -20       -10        0        +10       +20" 
530 PRINT " ","-I----I---------I---------I---------I---------I----I" 
540 FOR X=0 TO 4 STEP .2 
545 PRINT "       "; INT(10*X+.5)/10,"-";  
550 LET W(1)=INT(10*SIN(P2*X/4)+.5)
560 LET W(2)=INT(A*SIN(P2*(X/L+P))+.5) 
570 LET W(3)=INT(W(1)+W(2)+.5) 
580 REM  FIND WHICH IS SMALLEST, THEN PRINT IT AND MAXIMIZE IT 
600 FOR Q=1 TO 3 
605 LET K=1E20 
610 FOR I=1 TO 3 
620 IF W(I)>K THEN 640 
630 LET K=W(I) 
640 NEXT I 
650 PRINT TAB(K+40); 
660 FOR I=1 TO 3 
670 IF ABS(W(I)-K)<.0001 THEN 700  
680 NEXT I 
690 STOP 
700 IF I<>1 THEN 730 
710 PRINT "A"; 
720 GO TO 780
730 IF I<>2 THEN 760 
740 PRINT "B"; 
750 GO TO 780
760 IF I<>3 THEN 690 
770 PRINT "S"; 
780 LET W(I)=1E25
790 NEXT Q 
795 PRINT " "
800 NEXT X 
810 PRINT " ","-I----I---------I---------I---------I---------I----I" 
820 PRINT
830 PRINT "WANT TO TRY ANOTHER SET OF VALUES (1=YES, 0=NO) : ";
840 INPUT A
850 IF A=1 THEN 350
860 IF A<>0 THEN 820 
870 END
