ChipMaster's bwBASIC This also includes history going back to v2.10. *WARN* some binary files might have been corrupted by CRLF.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

77 lines
2.3 KiB

  1. 10 REM PERIOD SEARCH BY A DISCRETE FOURIER
  2. 20 REM TRANSFORM -- MARIA MITCHELL OBSERVATORY
  3. 25 REM
  4. 30 DIM X(100),Y(100)
  5. 40 GOSUB 360
  6. 50 REM
  7. 60 REM ***************** THE DFT *****************
  8. 70 REM
  9. 80 Z9=0: A5=0: F0=F1-F4: C0=(N-1)/(N*Q)
  10. 90 PRINT "TRIAL #";TAB(15);"PERIOD";
  11. 100 PRINT TAB(30);"FREQUENCY";TAB(45);"STRENGTH"
  12. 110 FOR K=1 TO M
  13. 120 F=F0+K*F4: B=P2*F: C=0: S=0
  14. 130 FOR I=1 TO N
  15. 140 A=B*X(I)
  16. 150 S=S+Y(I)*SIN(A): C=C+Y(I)*COS(A)
  17. 160 NEXT I
  18. 170 Z=(C*C+S*S)*C0: A5=A5+Z
  19. 180 IF Z<=Z9 THEN 200
  20. 190 Z9=Z: F9=F: REM NEW MAXIMUM STRENGTH
  21. 200 IF Z<Z0 THEN 230
  22. 210 PRINT K;TAB(15);1/F;TAB(30);F;TAB(45);Z
  23. 220 L=1: GOTO 250
  24. 230 IF L=0 THEN 250
  25. 240 L=0: PRINT
  26. 250 NEXT K
  27. 260 A5=A5/M
  28. 270 REM
  29. 280 PRINT
  30. 290 PRINT TAB(15);"PERIOD";TAB(30);"FREQUENCY";
  31. 300 PRINT TAB(45);"STRENGTH"
  32. 310 PRINT "AVERAGE";TAB(45);A5
  33. 320 PRINT "BEST";TAB(15);1/F9;TAB(30);F9;TAB(45);Z9
  34. 330 PRINT "AMPLITUDE ESTIMATE = ";4*SQR(Q*Z9)/N
  35. 340 END
  36. 350 REM
  37. 360 REM ******** THE INITIALIZING ROUTINES ********
  38. 370 P2=2*3.14159265: L=0
  39. 380 Z0=2: REM TO SKIP PRINTING "WORTHLESS" PERIODS
  40. 390 REM
  41. 400 REM -------------- SET X,Y,X4,Q ---------------
  42. 410 REM
  43. 420 Q=0: N=0
  44. 430 READ X,Y: IF X=9999 THEN 450
  45. 440 N=N+1: X(N)=X: Y(N)=Y: Q=Q+Y(N)*Y(N): GOTO 430
  46. 450 X4=X(N)-X(1)
  47. 460 REM
  48. 470 REM --------------- SET F1,F4,M ---------------
  49. 480 REM
  50. 490 PRINT "LONGEST USEFUL PERIOD TO TRY = ";X4/2
  51. 500 INPUT "LONGEST PERIOD TO TRY THIS RUN ";P9
  52. 510 INPUT "COARSE, MEDIUM OR FINE (C,M,F)";Z$
  53. 520 S9=0.20: REM ASSUME COARSE SPACING
  54. 530 IF Z$="M" THEN S9=0.10
  55. 540 IF Z$="F" THEN S9=0.05
  56. 550 F4=S9/X4: F1=1/P9
  57. 560 INPUT "MAXIMUM NUMBER OF TRIALS ";M
  58. 570 F8=F1+(M-1)*F4
  59. 580 PRINT "THEN SHORTEST ALLOWABLE PERIOD = ";1/F8
  60. 590 INPUT "SHORTEST PERIOD TO TRY THIS RUN ";P0
  61. 600 F8=1/P0: M=INT((F8-F1)/F4)+1
  62. 610 RETURN
  63. 620 REM
  64. 630 REM LIST OF X,Y VALUES
  65. 640 DATA -44.874, -0.129, -32.912, -0.008
  66. 650 DATA -15.959, 0.102, -14.964, 0.150
  67. 660 DATA 7.974, 0.124, 11.962, -0.054
  68. 670 DATA 12.961, -0.100, 13.959, -0.032
  69. 680 DATA 15.958, 0.113, 17.954, 0.052
  70. 690 DATA 36.895, -0.058, 40.881, 0.118
  71. 700 DATA 42.878, -0.033, 44.873, -0.039
  72. 710 DATA 9999,9999: REM DUMMY END VALUES
  73. 800 REM ******************************************
  74. 810 REM FROM SKY & TELESCOPE'S ASTRONOMICAL COM-
  75. 820 REM PUTING DEPARTMENT FOR SEPTEMBER, 1988
  76. 830 REM ******************************************