home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / info / calc.info-9 (.txt) < prev    next >
GNU Info File  |  1994-12-22  |  51KB  |  838 lines

  1. This is Info file calc.info, produced by Makeinfo-1.55 from the input
  2. file calc.texinfo.
  3.    This file documents Calc, the GNU Emacs calculator.
  4.    Copyright (C) 1990, 1991 Free Software Foundation, Inc.
  5.    Permission is granted to make and distribute verbatim copies of this
  6. manual provided the copyright notice and this permission notice are
  7. preserved on all copies.
  8.    Permission is granted to copy and distribute modified versions of
  9. this manual under the conditions for verbatim copying, provided also
  10. that the section entitled "GNU General Public License" is included
  11. exactly as in the original, and provided that the entire resulting
  12. derived work is distributed under the terms of a permission notice
  13. identical to this one.
  14.    Permission is granted to copy and distribute translations of this
  15. manual into another language, under the above conditions for modified
  16. versions, except that the section entitled "GNU General Public License"
  17. may be included in a translation approved by the author instead of in
  18. the original English.
  19. File: calc.info,  Node: Caches,  Next: Debugging Calc,  Prev: Recursion Depth,  Up: Troubleshooting Commands
  20. Caches
  21. ------
  22. Calc saves certain values after they have been computed once.  For
  23. example, the `P' (`calc-pi') command initially "knows" the constant
  24. `pi' to about 20 decimal places; if the current precision is greater
  25. than this, it will recompute `pi' using a series approximation.  This
  26. value will not need to be recomputed ever again unless you raise the
  27. precision still further.  Many operations such as logarithms and sines
  28. make use of similarly cached values such as `pi/4' and `ln(2)'.  The
  29. visible effect of caching is that high-precision computations may seem
  30. to do extra work the first time.  Other things cached include powers of
  31. two (for the binary arithmetic functions), matrix inverses and
  32. determinants, symbolic integrals, and data points computed by the
  33. graphing commands.
  34.    If you suspect a Calculator cache has become corrupt, you can use the
  35. `calc-flush-caches' command to reset all caches to the empty state.
  36. (This should only be necessary in the event of bugs in the Calculator.)
  37. The `M-# 0' (with the zero key) command also resets caches along with
  38. all other aspects of the Calculator's state.
  39. File: calc.info,  Node: Debugging Calc,  Prev: Caches,  Up: Troubleshooting Commands
  40. Debugging Calc
  41. --------------
  42. A few commands exist to help in the debugging of Calc commands.  *Note
  43. Programming::, to see the various ways that you can write your own Calc
  44. commands.
  45.    The `Z T' (`calc-timing') command turns on and off a mode in which
  46. the timing of slow commands is reported in the Trail.  Any Calc command
  47. that takes two seconds or longer writes a line to the Trail showing how
  48. many seconds it took.  This value is accurate only to within one second.
  49.    All steps of executing a command are included; in particular, time
  50. taken to format the result for display in the stack and trail is
  51. counted.  Some prompts also count time taken waiting for them to be
  52. answered, while others do not; this depends on the exact implementation
  53. of the command.  For best results, if you are timing a sequence that
  54. includes prompts or multiple commands, define a keyboard macro to run
  55. the whole sequence at once.  Calc's `X' command (*note Keyboard
  56. Macros::.) will then report the time taken to execute the whole macro.
  57.    Another advantage of the `X' command is that while it is executing,
  58. the stack and trail are not updated from step to step.  So if you
  59. expect the output of your test sequence to leave a result that may take
  60. a long time to format and you don't wish to count this formatting time,
  61. end your sequence with a DEL keystroke to clear the result from the
  62. stack.  When you run the sequence with `X', Calc will never bother to
  63. format the large result.
  64.    Another thing `Z T' does is to increase the Emacs variable
  65. `gc-cons-threshold' to a much higher value (two million; the usual
  66. default in Calc is 250,000) for the duration of each command.  This
  67. generally prevents garbage collection during the timing of the command,
  68. though it may cause your Emacs process to grow abnormally large.
  69. (Garbage collection time is a major unpredictable factor in the timing
  70. of Emacs operations.)
  71.    Another command that is useful when debugging your own Lisp
  72. extensions to Calc is `M-x calc-pass-errors', which disables the error
  73. handler that changes the "`max-lisp-eval-depth' exceeded" message to
  74. the much more friendly "Computation got stuck or ran too long."  This
  75. handler interferes with the Emacs Lisp debugger's `debug-on-error'
  76. mode.  Errors are reported in the handler itself rather than at the
  77. true location of the error.  After you have executed
  78. `calc-pass-errors', Lisp errors will be reported correctly but the
  79. user-friendly message will be lost.
  80. File: calc.info,  Node: Data Types,  Next: Stack and Trail,  Prev: Introduction,  Up: Top
  81. Data Types
  82. **********
  83. This chapter discusses the various types of objects that can be placed
  84. on the Calculator stack, how they are displayed, and how they are
  85. entered.  (*Note Data Type Formats::, for information on how these data
  86. types are represented as underlying Lisp objects.)
  87.    Integers, fractions, and floats are various ways of describing real
  88. numbers.  HMS forms also for many purposes act as real numbers.  These
  89. types can be combined to form complex numbers, modulo forms, error
  90. forms, or interval forms.  (But these last four types cannot be combined
  91. arbitrarily: error forms may not contain modulo forms, for example.)
  92. Finally, all these types of numbers may be combined into vectors,
  93. matrices, or algebraic formulas.
  94. * Menu:
  95. * Integers::                The most basic data type.
  96. * Fractions::               This and above are called "rationals".
  97. * Floats::                  This and above are called "reals".
  98. * Complex Numbers::         This and above are called "numbers".
  99. * Infinities::
  100. * Vectors and Matrices::
  101. * Strings::
  102. * HMS Forms::
  103. * Date Forms::
  104. * Modulo Forms::
  105. * Error Forms::
  106. * Interval Forms::
  107. * Incomplete Objects::
  108. * Variables::
  109. * Formulas::
  110. File: calc.info,  Node: Integers,  Next: Fractions,  Prev: Data Types,  Up: Data Types
  111. Integers
  112. ========
  113. The Calculator stores integers to arbitrary precision.  Addition,
  114. subtraction, and multiplication of integers always yields an exact
  115. integer result.  (If the result of a division or exponentiation of
  116. integers is not an integer, it is expressed in fractional or
  117. floating-point form according to the current Fraction Mode.  *Note
  118. Fraction Mode::.)
  119.    A decimal integer is represented as an optional sign followed by a
  120. sequence of digits.  Grouping (*note Grouping Digits::.) can be used to
  121. insert a comma at every third digit for display purposes, but you must
  122. not type commas during the entry of numbers.
  123.    A non-decimal integer is represented as an optional sign, a radix
  124. between 2 and 36, a `#' symbol, and one or more digits.  For radix 11
  125. and above, the letters A through Z (upper- or lower-case) count as
  126. digits and do not terminate numeric entry mode.  *Note Radix Modes::,
  127. for how to set the default radix for display of integers.  Numbers of
  128. any radix may be entered at any time.  If you press `#' at the
  129. beginning of a number, the current display radix is used.
  130. File: calc.info,  Node: Fractions,  Next: Floats,  Prev: Integers,  Up: Data Types
  131. Fractions
  132. =========
  133. A "fraction" is a ratio of two integers.  Fractions are traditionally
  134. written "2/3" but Calc uses the notation `2:3'.  (The `/' key performs
  135. RPN division; the following two sequences push the number `2:3' on the
  136. stack:  `2 : 3 RET', or `2 RET 3 /' assuming Fraction Mode has been
  137. enabled.) When the Calculator produces a fractional result it always
  138. reduces it to simplest form, which may in fact be an integer.
  139.    Fractions may also be entered in a three-part form, where `2:3:4'
  140. represents two-and-three-quarters.  *Note Fraction Formats::, for
  141. fraction display formats.
  142.    Non-decimal fractions are entered and displayed as `RADIX#NUM:DENOM'
  143. (or in the analogous three-part form).  The numerator and denominator
  144. always use the same radix.
  145. File: calc.info,  Node: Floats,  Next: Complex Numbers,  Prev: Fractions,  Up: Data Types
  146. Floats
  147. ======
  148. A floatin