home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 245.lha / Graf.doc < prev    next >
Text File  |  1989-04-09  |  8KB  |  184 lines

  1. Graf    -    Bill Nickerson
  2. ==============================
  3.  
  4. History.
  5. ========
  6. Graf is a program originally meant for graphing multiple functions of one
  7. variable entered from the keyboard. A calculator mode was so easy to add
  8. that it is included also.
  9.  
  10. The inspiration for graf came from the graph sketching classes we had in
  11. intro calculus. I wanted a nice and quick way of checking my work. Also, since
  12. I was marking and teaching a night class for a translators, I wanted a sample
  13. lexical analyzer and expression parser. Besides, I hadn't really done anything
  14. majorly graphic with my Amiga since I got it a couple years ago and this just
  15. happen to be a good excuse.
  16.  
  17. Execution.
  18. ==========
  19. Graf must be run from some sort of cli. If no arguments are given, then you
  20. are popped into graphing mode, indicated by a window appearing in the upper
  21. left hand corner of the screen. If you give it the solitary argument "calc",
  22. then a title line is output and you are in calculator mode, indicated by the
  23. number 1 in square brackets at the left side of the current line. If any
  24. other arguments are given, a usage message is displayed and you get the cli
  25. back.
  26.  
  27. Functions Available.
  28. ====================
  29. Before the operation of the program is explained, a list of functions would
  30. probably be useful. The parser is really quite powerful and does a lot of
  31. error checking for you. Errors that are made during parsing are indicated
  32. and errors that occur during evaluation (like taking the square root of -1)
  33. are either pointed out or ignored, depending on which mode you happen to be
  34. in. Anyhow, a list of functions....
  35.  
  36. --**-----------
  37. NOTE: arguments to the trig functions must be given in radians.
  38. --**-----------
  39.  
  40. -x        - negation of x.
  41.  
  42. acos(x)        - arccos of x.
  43. asin(x)        - arcsin of x.
  44. atan(x)        - arctan of x.
  45. cosh(x)        - hyperbolic cos of x.
  46. sinh(x)        - hyperbolic sin of x.
  47. tanh(x)        - hyperbolic tan of x.
  48. cos(x)        - cos of x.
  49. sin(x)        - sin of x.
  50. tan(x)        - tan of x.
  51.  
  52. exp(x)        - e to power x.
  53. ln(x)        - natural log of x.
  54. log(x)        - log base 10 of x.
  55.  
  56. sqrt(x)        - square root of x.
  57. <<(x)        - floor of x.
  58. >>(x)        - ceiling of x.
  59. |(x)        - absolute value of x.
  60. !(x)        - factorial of floor of x.
  61.  
  62. x * y        - product of x and y.
  63. x / y        - division of x by y.
  64. x % y        - modulus of x by y.
  65. x ^ y        - x to power of y.
  66. x + y        - sum of x and y.
  67. x - y        - difference of x and y.
  68. x : y        - sum of integers between floor of x and y.
  69.  
  70. Parentheses work the way they usually do, the usual limits on boundaries apply,
  71. and precedence is as usual. For the most part, the functions above are listed
  72. according to precedence. Summation is a bit weird, but examples should suffice.
  73.  
  74.     1:3+2:5        is (((1:3)+2):5) == ((6+2):5) == (8:5) == 26
  75.     (1:3)+(2:5)    is ((1:3)+(2:5)) == (6 + 14) == 20
  76.     1:3*2:5        is ((1:(3*2)):5) == ((1:6):5) == 21:5 == 221
  77.  
  78. --**-----------
  79. As a side note, how many have noticed that a few of the IEEE math routines
  80. do not give errors where there should be some? For example, tan of 90 degrees
  81. actually returns a value (defined as HUGE in <math.h>) and no error. This is
  82. probably supposed to stand for infinity, but I'd rather it be an error. If you
  83. get weird values for invalid functions, the math routines could be to blame....
  84. --**-----------
  85.  
  86. Graphing.
  87. =========
  88.  
  89. After the little window pops up when you type "graf" from your cli, you can
  90. see three options: "graph", "enter", and "quit". It is obvious which one exits
  91. the program, so I won't dwell on it. The one to start with is "enter". This
  92. option is used to enter up to 10 functions into the system.
  93.  
  94. Enter.
  95. ------
  96. Initially, you get a window titled "Select" with 10 little boxes down the
  97. left side. Graf wants you to select a function to enter (if blank) or change
  98. (if not blank). When you click on one of them, a new window titled "Enter"
  99. appears. This window is more interesting and has a lot of things to play
  100. with. First, an explanation of the different gadgets.
  101.  
  102. The "okay" and "cancel" gadgets do just what you normally expect.
  103.  
  104. The "join" gadget toggles everytime you click it (try it if you don't believe
  105. me). It is used for functions that define dots that have gaps between them.
  106. When join is active, the dots are joined together as they are plotted giving a
  107. smooth plot instead of something resembling bird droppings. Try functions with
  108. and without join to see how it works. Each function has its own join flag, so
  109. you can use it at your own descretion.
  110.  
  111. The funny little arrow gadget is very important. To the right of it are the
  112. words "Y lo" (lower Y axis boundary), "Y hi" (upper Y axis boundary),
  113. "X lo" (left X axis boundary), "X hi" (right X axis boundary), and some
  114. numbers. Each triangle on the arrow gadget controls a graph boundary on both
  115. the X and Y axes. You enter numbers representing boundaries in the string
  116. gadget at the top of the window. Commonsense tells you which triangle controls
  117. what. If you enter an illegal number, the screen will flash and no boundary
  118. is changed. If a legal number is entered, the boundary is updated on the
  119. screen. The square at the middle controls the entry of functions. When you
  120. click on it, whatever is in the string gadget at the top gets checked and,
  121. if valid, entered as a function to be graphed. If the string is invalid, the
  122. screen blinks and nothing is changed. As much of the function as will fit is
  123. displayed in the area just above the graph boundaries.
  124.  
  125. Right now, the cursor is on a string gadget and is waiting for you to
  126. enter something. Using this, you can enter any function up to 80 characters in
  127. length. At this point, you may be wondering how you can write a function
  128. of x. It is not what you think. The parser will not accept anything but the
  129. functions and symbols given above and one special symbol - "#". It is this
  130. special symbol that represents x. An example of a function and its alternate
  131. representation might be
  132.  
  133.     F(x) = sin(x) + x    ==    sin(#) + #
  134.  
  135. Try entering a few functions and changing the graph boundaries. When you're
  136. finished, click on "okay".
  137.  
  138. Graph.
  139. ------
  140. The next option to try is "graph". The Select window appears again, but this
  141. time there are "okay" and "cancel" gadgets at the bottom. In this window,
  142. you can select any number of the functions just by clicking on their select
  143. boxes. Each box toggles as you click it so you'll know which ones you've
  144. chosen. Click okay to begin graphing them or cancel to quit.
  145.  
  146. The evaluator is fairly quick, so you shouldn't have to wait long for your
  147. graph. You will notice speed differences if you have a lot of trancendental
  148. functions, though. After all graphs have been completed, a full screen
  149. crosshair appears and you can move the mouse around to check the approximate
  150. locations of different points on your function. I thought this might be a
  151. useful little feature (ie. approximating "zeroes" of a function). The window
  152. initially in the upper left tracks position. It can be moved, but you'll have
  153. to click in the graphing window again to get your location displayed. To
  154. exit back to the main menu, hit any key on the keyboard. And that's it.
  155.  
  156. Using the Calculator.
  157. =====================
  158. If you typed "graf calc" at the cli, you now have a "[1]" sitting at the left
  159. of your cursor. This indicates the current line you're about to enter for
  160. evaluation. Here the rules are simple:
  161.  
  162. - enter a function.
  163. - If the function has "#" anywhere in it, you will enter a loop and will
  164.     be prompted to enter values for "#". The function is evaluated at
  165.     the given value and the result is displayed. To exit the loop,
  166.     enter "1\".
  167. - If the function is valid, you get an answer.
  168. - If the function is invalid, whether because of syntax or the rules of
  169.     math, you get an error.
  170. - to exit, press <CTRL> \ to signal end-of-file.
  171.  
  172. Looping when a function contains "#" is useful for when you want evaluate one
  173. function for many values. The same operators described above are valid in the
  174. calculator. It's as simple as that.
  175.  
  176. Questions, Bitching, Etc.
  177. =========================
  178.  
  179. Contact Bill Nickerson, 840493n@aucs on BitNet. I graduate in May, so don't
  180. bother after then. I may pop up somwhere later on....
  181.  
  182. --**-----------
  183. This has been a FreeWare Production.
  184.