home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1987 February / Ahoy_Magazine_87-02_1987_Double_L_Side_B.d64 / graphing.txt < prev    next >
Text File  |  2022-10-26  |  5KB  |  158 lines

  1. GRAPHIC SOLUTIONS for COMAL 0.14
  2. by Lowell Toms
  3.  
  4. Recently, I ran across a new hand
  5. held calculator which was able to
  6. plot functions on a slightly
  7. oversized LCD screen. Well, it was
  8. pretty neat, but the last thing I
  9. need is another calculator. While a
  10. graphing routine may be a chore to
  11. program in BASIC, COMAL is a natural
  12. for the task. Before you skip on to
  13. the next program while mumbling who
  14. needs another graphing routine, you
  15. should know that this one has some
  16. different capabilities. The routine
  17. can plot up to six equations (y=f(x))
  18. on the same screen. These equations
  19. are entered and deleted while the
  20. program is running. The range and
  21. origin of the X and Y axes are easily
  22. modified from within the program.
  23. Finally, a joystick controlled
  24. routine prints the coordinates of any
  25. interesting point to the screen. This
  26. eliminates the need for an extensive
  27. grid, and gives much more accurate
  28. results than the eyeball approach.
  29. Hopefully, I've piqued your curiosity
  30. enough that you're ready to load the
  31. program.
  32.  
  33. Graphic'solutions includes four
  34. different processes. When the initial
  35. menu screen appears you may select to
  36. enter a function, define the axes,
  37. plot a function, or find a point on
  38. your plot. Select 1 and a new menu
  39. appears which allows you to enter a
  40. function, view previously entered
  41. functions, clear all functions, or
  42. return to the main menu. Select 1
  43. again and you are asked in which
  44. position (1-6) you want to place your
  45. function. If you hit <RETURN>, the
  46. function is automatically placed in
  47. the first open position, (enter
  48. another number to overwrite a
  49. previous entry). Now, you are asked
  50. to enter your function:
  51.  
  52. Y=X^4+5*X^3-7*X^2-29*X+30
  53.  
  54. The computer pauses for a moment
  55. while the formula is entered. If
  56. you've made a syntax error in the
  57. formula, the program stops and an
  58. error message is displayed. Just
  59. correct the error and hit <RETURN>
  60. until each displayed line is entered
  61. and RUN sends you back to the main
  62. menu.
  63.  
  64. Now, let's set the axes. Select 2,
  65. and you are asked to specify the
  66. origin. For this case, hit <RETURN>
  67. and the default values of 0,0 are
  68. entered. Next, you're asked to set
  69. the x tic marks. Hit <RETURN> and the
  70. default value of 1 is entered. For
  71. the y tic marks, enter 10 and hit
  72. <RETURN>. The next question asks if
  73. you want the origin and tic values
  74. displayed on the graph. Hit <RETURN>,
  75. and the values will be displayed. The
  76. main menu is displayed again, with
  77. the new values shown below the set
  78. axes selection.
  79.  
  80. It's finally time to plot. Select 3
  81. from the menu, and then select 1 from
  82. the plot menu. Enter 1 (or -1 for
  83. faster, but cruder plot) of function
  84. 1. When the function plot is
  85. complete, a > appears in the upper
  86. left corner. Hit any key, and you
  87. will return to the plot menu. Type 3
  88. to return to the main menu, and
  89. select 4.
  90.  
  91. Selection 4 is the joystick point
  92. finding routine. Plug your joystick
  93. into port 2, select 1, and hit
  94. <RETURN>. The plot reappears with the
  95. turtle present at the screen center.
  96. The turtle speed can be varied by
  97. pressing the + and - keys. Move the
  98. turtle to the point of interest and
  99. hit the fire button. The point's
  100. coordinates are displayed in the
  101. lower right corner.
  102.  
  103. You're certainly not limited to
  104. graphing polynomials. Set the axes
  105. back to their default values (type 2
  106. from the main menu and then hit
  107. <RETURN> to all the prompts). Enter
  108. Y=TAN(X) keeping the same axes as
  109. before. Next try Y=1/X. This equation
  110. will create an error at x=0 unless
  111. you answer y to the avoid a point?
  112. query in the plot section and enter 0
  113. as the point to avoid. Some functions
  114. such as SQR don't digest negative
  115. numbers very well so you have the
  116. option of specifying positive x
  117. values only. Of course you could just
  118. shift the axes, but you may wish to
  119. plot another function on the same
  120. screen without a shifted origin. The
  121. plotting option also allows automatic
  122. plotting of all the entered functions
  123. by selecting 7 (or -7). You must
  124. press a key when the > appears, but
  125. the routine starts plotting the next
  126. function instead of returning to the
  127. menu.
  128.  
  129. I was forced to make some compromises
  130. in the program due to the 12k
  131. available memory (and my inexperience
  132. with COMAL). The most serious
  133. compromise was the elimination of the
  134. bulk of the code comments. Even with
  135. minimal comments, the free memory
  136. available is only about 1/2k, so you
  137. may want to watch the memory size if
  138. you enter large formulas. (You must
  139. have an expanded memory version of
  140. COMAL 0.14 to run this program. The
  141. HI program on this disk expands
  142. memory.)
  143.  
  144. Another warning is also in order. Do
  145. not renumber the first section of the
  146. program (lines 1-999). This section
  147. is the area where the dynamic
  148. keyboard routine modifies program
  149. lines. There is no screen dump
  150. utility built into the program, but
  151. there are plenty of dump routines
  152. available (try the Utilities #2).
  153.  
  154. I hope you enjoy the program, and I
  155. would like to thank Dick Klingens for
  156. his STR$ and VAL routine listed in
  157. COMAL Today #12.
  158.