Compucolor.org – Virtual Media

Listing of file='SIN2.BAS;01' on disk='vmedia/chip_36-sector.ccvf'

1 REM        MORE ON SINE WAVES                     JULY 1981
2 REM
3 REM        TUTORIAL ON HORIZONTAL AND VERTICAL DISPLACEMENT
5 REM        16K COMPUCOLOR
6 REM
10 REM      PROGRAM WRITTEN BY JEAN BOHRER
11 REM      UNDER THE DIRECTION OF MARJORIE A. FITTING
12 REM      DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE
13 REM      SAN JOSE STATE UNIVERSITY, SAN JOSE, CA 95192
20 REM
21 REM "______________________________"
22 REM "!       SAN MATEO COUNTY      !"
23 REM "!     OFFICE OF EDUCATION     !"
24 REM "!             &               !"
25 REM "!  COMPUTER-USING EDUCATORS   !"
26 REM "!                             !"
27 REM "!          SOFTSWAP           !"
28 REM "!                             !"
29 REM "!333 MAIN STREET, REDWOOD CITY!"
30 REM "!CA 94063 (415)364-5600 EX4401!"
31 REM "_______________________________"
40 REM "_______________________________"
41 REM "! PROGRAMS MAY BE COPIED FOR  !"
42 REM "! EDUCATIONAL USE ONLY AND    !"
43 REM "! ARE NOT TO BE SOLD.         !"
44 REM "!!"
50 REM
60 REM
100 PLOT 12,23
110 PRINT "IN THE LAST EXERCISE YOU FOUND THAT AMPLITUDE  OF A"
120 PRINT "GRAPH COULD BE VARIED BY CHANGING THE VALUE OF A IN"
130 PRINT "THE EQUATION Y=A*SIN(X)."
140 PRINT :PRINT
150 PRINT "YOU ALSO DISCOVERED THAT A GRAPH CAN BE HORIZONTALLY"
160 PRINT "COMPRESSED OR EXPANDED, WHICH CAUSES A CHANGE IN THE"
170 PRINT "PERIOD. THIS WAS DONE BY CHANGING THE VALUE OF B IN "
180 PRINT "THE EQUATION Y=SIN(B*X)."
190 PRINT :PRINT
200 INPUT "PRESS RETURN TO CONTINUE.";A
210 PRINT :PRINT :PRINT :PRINT :PRINT
220 PRINT "NOW WE'D LIKE TO SEE HOW THE ADDITION OF A NUMBER"
230 PRINT "TO THE EQUATION Y=SIN(X) AFFECTS THE GRAPH."
240 PRINT
250 PRINT "WE WILL START WITH THE GRAPH OF Y=SIN(X) AND THEN"
260 PRINT "CHOOSE DIFFERENT VALUES FOR C IN THE EQUATION"
270 PRINT "Y=SIN(X+C)."
280 PRINT :PRINT :PRINT
290 INPUT "PRESS RETURN TO CONTINUE.";A
300 PLOT 12
310 GOSUB 1870
320 PLOT 3,4,0
330 PLOT 23
340 INPUT "WHAT IS THE Y-INTERCEPT OF THIS GRAPH?";A
350 IF A= 0THEN 390
360 PLOT 3,4,1
370 PRINT "NO, THE CURVE CROSSES THE Y-AXIS AT 0."
380 GOTO 410
390 PLOT 3,4,1
400 PRINT "CORRECT!"
410 PLOT 3,0,26
420 PRINT "CHOOSE SOME VALUES FOR C IN THE EQN. Y=SIN(X+C)"
430 PRINT "TO SEE HOW THIS AFFECTS THE GRAPH. LET -3<=C<=3."
440 PLOT 22
450 INPUT "C= ";C
460 IF C> 3OR C< - 3THEN 490
470 GOSUB 1780
480 GOTO 510
490 PLOT 3,7,28
500 PRINT "SORRY,";C;" IS OUT OF RANGE"
510 PLOT 3,0,29
520 PLOT 19
530 INPUT "TRY ANOTHER VALUE FOR C. C= ";C
540 IF C> 3OR C< - 3THEN 570
550 GOSUB 1780
560 GOTO 590
570 PLOT 3,32,29
580 PRINT "OUT OF RANGE"
590 PLOT 3,0,30
600 PLOT 21
610 IF C> 3OR C< - 3THEN
620 INPUT "CHOOSE 1 LAST VALUE FOR C. C= ";C
630 IF C> 3OR C< - 3THEN 660
640 GOSUB 1780
650 GOTO 680
660 PLOT 3,34,30
670 PRINT "OUT OF RANGE"
680 GOSUB 2380
690 INPUT A
700 PLOT 12,23
710 PRINT "FOR ALL THE GRAPHS YOU MADE, WHICH OF THE FOLLOWING"
720 PRINT "IS CORRECT?"
730 PRINT TAB( 10);"(1) THEY HAD THE SAME AMPLITUDE."
740 PRINT TAB( 10);"(2) THEY HAD THE SAME PERIOD."
750 PRINT TAB( 10);"(3) BOTH (1) AND (2)."
760 PRINT TAB( 10);"(4) NEITHER (1) NOR (2)."
770 PRINT
780 INPUT "ENTER THE NUMBER OF YOUR RESPONSE.";A
790 IF A= 3THEN 830
800 PRINT TAB( 4);"SORRY, THE CORRECT RESPONSE IS 3. ALL GRAPHS"
810 PRINT TAB( 4);"HAD AN AMPLITUDE OF 1 AND A PERIOD OF 2*PI."
820 GOTO 850
830 PRINT TAB( 4);"GOOD JOB! ALL GRAPHS HAD AN AMPLITUDE OF 1"
840 PRINT TAB( 4);"AND A PERIOD OF 2*PI."
850 PRINT
860 INPUT "DID ALL GRAPHS HAVE THE SAME Y-INTERCEPT?(Y/N)";B$
870 IF B$= "N"THEN 910
880 PRINT TAB( 4);"WRONG. THE Y-INTERCEPTS CHANGED AS THE"
890 PRINT TAB( 4);"CURVES SHIFTED LEFT OR RIGHT."
900 GOTO 930
910 PRINT TAB( 4);"RIGHT! THE Y-INTERCEPTS CHANGED AS THE"
920 PRINT TAB( 4);"GRAPH SHIFTED LEFT OR RIGHT."
930 PRINT :PRINT
940 FOR K= 1TO 1000:NEXT K
950 PRINT "THE AMOUNT OF HORIZONTAL TRANSLATION OF A GRAPH IS"
960 PRINT "CALLED THE PHASE SHIFT."
970 PRINT :PRINT
980 PRINT TAB( 10);"IN THE EQUATION Y=SIN(X+C), THE CONSTANT"
990 PRINT TAB( 10);"C IS CALLED THE PHASE SHIFT OF THE GRAPH."
1000 PLOT 2,18,50,242,102,50,102,38,18,38,18,50,255
1010 PRINT
1020 FOR K= 1TO 3000:NEXT K
1030 FOR X= 0TO 63STEP 2
1040 PLOT 3,X,23
1050 PRINT "c"
1060 NEXT X
1070 PRINT :PRINT
1080 PRINT "LET US NOW INVESTIGATE WHAT CHANGES OCCUR WHEN A"
1090 PRINT "NUMBER IS ADDED TO SIN(X)."
1100 PRINT "Y=SIN(X) WILL BE PLOTTED AGAIN, AND YOU WILL THEN"
1110 PRINT "CHOOSE VALUES FOR D IN THE EQUATION Y=SIN(X)+D."
1120 PRINT
1130 INPUT "PRESS RETURN TO CONTINUE.";A
1140 PLOT 12
1150 GOSUB 1870
1160 PLOT 23
1170 PLOT 3,4,0
1180 PRINT "CHOOSE VALUES FOR D IN THE EQUATION"
1190 PLOT 3,4,1
1200 PRINT "Y=SIN(X)+D SUCH THAT -2<=D<=2."
1210 PLOT 3,0,26
1220 PLOT 22
1230 INPUT "D= ";D
1240 IF D> 2OR D< - 2THEN 1270
1250 GOSUB 2290
1260 GOTO 1290
1270 PLOT 3,7,26
1280 PRINT "SORRY,";D;" IS OUT OF RANGE"
1290 PLOT 3,0,27
1300 PLOT 19
1310 INPUT "TRY ANOTHER VALUE FOR D. D= ";D
1320 IF D> 2OR D< - 2THEN 1350
1330 GOSUB 2290
1340 GOTO 1370
1350 PLOT 3,32,27
1360 PRINT "OUT OF RANGE"
1370 PLOT 3,0,28
1380 PLOT 21
1390 INPUT "CHOOSE 1 LAST VALUE FOR D. D= ";D
1400 IF D> 2OR D< - 2THEN 1430
1410 GOSUB 2290
1420 GOTO 1450
1430 PLOT 3,34,28
1440 PRINT "OUT OF RANGE"
1450 GOSUB 2380
1460 INPUT A
1470 PLOT 12,23
1480 PRINT "FOR THE GRAPHS YOU JUST MADE, WERE THE AMPLITUDES"
1490 INPUT "THE SAME?(Y/N)";A$
1500 IF A$= "Y"THEN 1530
1510 PRINT TAB( 4);"WRONG. ALL GRAPHS HAD AN AMPLITUDE OF 1."
1520 GOTO 1540
1530 PRINT TAB( 4);"GOOD! ALL GRAPHS HAD AMPLITUDE 1."
1540 PRINT :PRINT
1550 PRINT "DID THE POSITIONS OF THE MAXIMUMS AND MINIMUMS"
1560 INPUT "CHANGE AS D WAS CHANGED?(Y/N)";B$
1570 IF B$= "Y"THEN 1620
1580 PRINT TAB( 4);"SORRY, THE MAXIMUMS AND MINIMUMS MOVED"
1590 PRINT TAB( 4);"UP OR DOWN AS THE VALUE OF D CHANGED."
1600 PRINT :PRINT :PRINT
1610 GOTO 1640
1620 PRINT TAB( 4);"RIGHT! THEY MOVED UP OR DOWN."
1630 PRINT :PRINT :PRINT :PRINT
1640 FOR X= 1TO 1500:NEXT X
1650 PRINT "WHEREAS CHANGING THE VALUE OF C IN Y=SIN(X+C)"
1660 PRINT "CAUSES HORIZONTAL TRANSLATION OF A GRAPH (0R"
1670 PRINT "PHASE SHIFT),CHANGING THE VALUE OF D IN Y=SIN(X)+D"
1680 PRINT "CAUSES VERTICAL TRANSLATION OF A GRAPH."
1690 PRINT :PRINT
1700 PRINT TAB( 10);"IN THE EQUATION Y=SIN(X)+D, THE CONSTANT"
1710 PRINT TAB( 10);"D IS CALLED THE VERTICAL TRANSLATION OF"
1720 PRINT TAB( 10);"THE GRAPH WITH RESPECT TO THE X-AXIS."
1730 PLOT 2,18,58,242,102,58,102,42,18,42,18,58,255
1740 PLOT 3,0,29
1750 INPUT "WOULD YOU LIKE TO RUN THIS PROGRAM AGAIN?(Y/N)";A$
1760 IF A$= "Y"THEN 100
1765 LOAD "MENU":RUN
1770 END
1780 REM  PLOTS GRAPH OF Y=SIN(X+C)
1790 FOR X= 0TO 100STEP 2
1800 PLOT 2,X+ 7,15* SIN (X/ 8+ C)+ 70,255
1810 NEXT X
1820 PLOT 3,48,2
1830 PLOT 14
1840 PRINT "Y=SIN(X+";C;")  "
1850 PLOT 15
1860 RETURN
1870 REM  PLOTS AXES
1880 FOR X= 3TO 54
1890 PLOT 3,X,14
1900 PRINT "f"
1910 NEXT X
1920 PLOT 3,16,13
1930 PRINT "m"
1940 PLOT 3,28,13
1950 PRINT "o"
1960 PLOT 3,41,13
1970 PRINT "m"
1980 PLOT 3,53,13
1990 PRINT "o"
2000 FOR X= 2TO 25
2010 PLOT 3,3,X
2020 PRINT "o"
2030 NEXT X
2040 PLOT 3,1,3
2050 PRINT "3e"
2060 PLOT 3,1,6
2070 PRINT "2_"
2080 PLOT 3,1,10
2090 PRINT "1i"
2100 PLOT 3,1,14
2110 PRINT "0f"
2120 PLOT 3,0,18
2130 PRINT "-1e"
2140 PLOT 3,0,21
2150 PRINT "-2_"
2160 PLOT 3,0,25
2170 PRINT "-3i"
2180 PLOT 3,55,14
2190 PRINT "(UNITS OF"
2200 PLOT 3,58,15
2210 PRINT "PI)"
2220 PLOT 17
2230 FOR X= 0TO 100STEP 2
2240 PLOT 2,X+ 7,15* SIN (X/ 8)+ 70,255
2250 NEXT X
2260 PLOT 3,48,0
2270 PRINT "Y=SIN(X)"
2280 RETURN
2290 REM  PLOTS Y=SIN(X)+D
2300 FOR X= 0TO 100STEP 2
2310 PLOT 2,X+ 7,15* SIN (X/ 8)+ 70+ 15* D,255
2320 NEXT X
2330 PLOT 3,48,2
2340 PLOT 14
2350 PRINT "Y=SIN(X)+";D;"  "
2360 PLOT 15
2370 RETURN
2380 REM  SIGNAL TO CONTINUE
2390 PLOT 3,50,26
2400 PLOT 23
2410 PRINT "EXAMINE THESE"
2420 PLOT 3,50,27
2430 PRINT "GRAPHS, THEN"
2440 PLOT 3,50,28
2450 PRINT "PRESS RETURN"
2460 PLOT 3,50,29
2470 PRINT "TO CONTINUE."
2480 PLOT 31
2490 PLOT 2,98,27,242,127,27,127,4,98,4,98,27,255
2500 PLOT 15
2510 RETURN