home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / info / calc.info-13 (.txt) < prev    next >
GNU Info File  |  1994-12-22  |  43KB  |  685 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: Basic Arithmetic,  Next: Integer Truncation,  Prev: Arithmetic,  Up: Arithmetic
  20. Basic Arithmetic
  21. ================
  22. The `+' (`calc-plus') command adds two numbers.  The numbers may be any
  23. of the standard Calc data types.  The resulting sum is pushed back onto
  24. the stack.
  25.    If both arguments of `+' are vectors or matrices (of matching
  26. dimensions), the result is a vector or matrix sum.  If one argument is
  27. a vector and the other a scalar (i.e., a non-vector), the scalar is
  28. added to each of the elements of the vector to form a new vector.  If
  29. the scalar is not a number, the operation is left in symbolic form:
  30. Suppose you added `x' to the vector `[1,2]'.  You may want the result
  31. `[1+x,2+x]', or you may plan to substitute a 2-vector for `x' in the
  32. future.  Since the Calculator can't tell which interpretation you want,
  33. it makes the safest assumption.  *Note Reducing and Mapping::, for a
  34. way to add `x' to every element of a vector.
  35.    If either argument of `+' is a complex number, the result will in
  36. general be complex.  If one argument is in rectangular form and the
  37. other polar, the current Polar Mode determines the form of the result.
  38. If Symbolic Mode is enabled, the sum may be left as a formula if the
  39. necessary conversions for polar addition are non-trivial.
  40.    If both arguments of `+' are HMS forms, the forms are added
  41. according to the usual conventions of hours-minutes-seconds notation.
  42. If one argument is an HMS form and the other is a number, that number
  43. is converted from degrees or radians (depending on the current Angular
  44. Mode) to HMS format and then the two HMS forms are added.
  45.    If one argument of `+' is a date form, the other can be either a
  46. real number, which advances the date by a certain number of days, or an
  47. HMS form, which advances the date by a certain amount of time.
  48. Subtracting two date forms yields the number of days between them.
  49. Adding two date forms is meaningless, but Calc interprets it as the
  50. subtraction of one date form and the negative of the other.  (The
  51. negative of a date form can be understood by remembering that dates are
  52. stored as the number of days before or after Jan 1, 1 AD.)
  53.    If both arguments of `+' are error forms, the result is an error form
  54. with an appropriately computed standard deviation.  If one argument is
  55. an error form and the other is a number, the number is taken to have
  56. zero error.  Error forms may have symbolic formulas as their mean
  57. and/or error parts; adding these will produce a symbolic error form
  58. result.  However, adding an error form to a plain symbolic formula (as
  59. in `(a +/- b) + c') will not work, for the same reasons just mentioned
  60. for vectors.  Instead you must write `(a +/- b) + (c +/- 0)'.
  61.    If both arguments of `+' are modulo forms with equal values of `M',
  62. or if one argument is a modulo form and the other a plain number, the
  63. result is a modulo form which represents the sum, modulo `M', of the
  64. two values.
  65.    If both arguments of `+' are intervals, the result is an interval
  66. which describes all possible sums of the possible input values.  If one
  67. argument is a plain number, it is treated as the interval `[x .. x]'.
  68.    If one argument of `+' is an infinity and the other is not, the
  69. result is that same infinity.  If both arguments are infinite and in
  70. the same direction, the result is the same infinity, but if they are
  71. infinite in different directions the result is `nan'.
  72.    The `-' (`calc-minus') command subtracts two values.  The top number
  73. on the stack is subtracted from the one behind it, so that the
  74. computation `5 RET 2 -' produces 3, not -3.  All options available for
  75. `+' are available for `-' as well.
  76.    The `*' (`calc-times') command multiplies two numbers.  If one
  77. argument is a vector and the other a scalar, the scalar is multiplied by
  78. the elements of the vector to produce a new vector.  If both arguments
  79. are vectors, the interpretation depends on the dimensions of the
  80. vectors:  If both arguments are matrices, a matrix multiplication is
  81. done.  If one argument is a matrix and the other a plain vector, the
  82. vector is interpreted as a row vector or column vector, whichever is
  83. dimensionally correct.  If both arguments are plain vectors, the result
  84. is a single scalar number which is the dot product of the two vectors.
  85.    If one argument of `*' is an HMS form and the other a number, the
  86. HMS form is multiplied by that amount.  It is an error to multiply two
  87. HMS forms together, or to attempt any multiplication involving date
  88. forms.  Error forms, modulo forms, and intervals can be multiplied; see
  89. the comments for addition of those forms.  When two error forms or
  90. intervals are multiplied they are considered to be statistically
  91. independent; thus, `[-2 .. 3] * [-2 .. 3]' is `[-6 .. 9]', whereas
  92. `[-2 .. 3] ^ 2' is `[0 .. 9]'.
  93.    The `/' (`calc-divide') command divides two numbers.  When dividing
  94. a scalar `B' by a square matrix `A', the computation performed is `B'
  95. times the inverse of `A'.  This also occurs if `B' is itself a vector
  96. or matrix, in which case the effect is to solve the set of linear
  97. equations represented by `B'.  If `B' is a matrix with the same number
  98. of rows as `A', or a plain vector (which is interpreted here as a
  99. column vector), then the equation `A X = B' is solved for the vector or
  100. matrix `X'.  Otherwise, if `B' is a non-square matrix with the same
  101. number of *columns* as `A', the equation `X A = B' is solved.  If you
  102. wish a vector `B' to be interpreted as a row vector to be solved as `X
  103. A = B', make it into a one-row matrix with `C-u 1 v p' first.  To force
  104. a left-handed solution with a square matrix `B', transpose `A' and `B'
  105. before dividing, then transpose the result.
  106.    HMS forms can be divided by real numbers or by other HMS forms.
  107. Error forms can be divided in any combination of ways.  Modulo forms
  108. where both values and the modulo are integers can be divided to get an
  109. integer modulo form result.  Intervals can be divided; dividing by an
  110. interval that encompasses zero or has zero as a limit will result in an
  111. infinite interval.
  112.    The `^' (`calc-power') command raises a number to a power.  If the
  113. power is an integer, an exact result is computed using repeated
  114. multiplications.  For non-integer powers, Calc uses Newton's method or
  115. logarithms and exponentials.  Square matrices can be raised to integer
  116. powers.  If either argument is an error (or interval or modulo) form,
  117. the result is also an error (or interval or modulo) form.
  118.    If you press the `I' (inverse) key first, the `I ^' command computes
  119. an Nth root:  `125 RET 3 I ^' computes the number 5.  (This is entirely
  120. equivalent to `125 RET 1:3 ^'.)
  121.    The `\' (`calc-idiv') command divides two numbers on the stack to
  122. produce an integer result.  It is equivalent to dividing with /, then
  123. rounding down with `F' (`calc-floor'), only a bit more convenient and
  124. efficient.  Also, since it is an all-integer operation when the
  125. arguments are integers, it avoids problems that `/ F' would have with
  126. floating-point roundoff.
  127.    The `%' (`calc-mod') command performs a "modulo" (or "remainder")
  128. operation.  Mathematically, `a%b = a - (a\b)*b', and is defined for all
  129. real numbers `a' and `b' (except `b=0')