home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / info / calc.info-18 (.txt) < prev    next >
GNU Info File  |  1994-12-22  |  46KB  |  730 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: Default Simplifications,  Next: Algebraic Simplifications,  Prev: Simplifying Formulas,  Up: Simplifying Formulas
  20. Default Simplifications
  21. -----------------------
  22. This section describes the "default simplifications," those which are
  23. normally applied to all results.  For example, if you enter the variable
  24. `x' on the stack twice and push `+', Calc's default simplifications
  25. automatically change `x + x' to `2 x'.
  26.    The `m O' command turns off the default simplifications, so that `x
  27. + x' will remain in this form unless you give an explicit "simplify"
  28. command like `=' or `a v'.  *Note Algebraic Manipulation::.  The `m D'
  29. command turns the default simplifications back on.
  30.    The most basic default simplification is the evaluation of functions.
  31. For example, `2 + 3' is evaluated to `5', and `sqrt(9)' is evaluated to
  32. `3'.  Evaluation does not occur if the arguments to a function are
  33. somehow of the wrong type (`tan([2,3,4])', range (`tan(90)'), or number
  34. (`tan(3,5)'), or if the function name is not recognized (`f(5)'), or if
  35. "symbolic" mode (*note Symbolic Mode::.) prevents evaluation
  36. (`sqrt(2)').
  37.    Calc simplifies (evaluates) the arguments to a function before it
  38. simplifies the function itself.  Thus `sqrt(5+4)' is simplified to
  39. `sqrt(9)' before the `sqrt' function itself is applied.  There are very
  40. few exceptions to this rule: `quote', `lambda', and `condition' (the
  41. `::' operator) do not evaluate their arguments, `if' (the `? :'
  42. operator) does not evaluate all of its arguments, and `evalto' does not
  43. evaluate its lefthand argument.
  44.    Most commands apply the default simplifications to all arguments they
  45. take from the stack, perform a particular operation, then simplify the
  46. result before pushing it back on the stack.  In the common special case
  47. of regular arithmetic commands like `+' and `Q' [`sqrt'], the arguments
  48. are simply popped from the stack and collected into a suitable function
  49. call, which is then simplified (the arguments being simplified first as
  50. part of the process, as described above).
  51.    The default simplifications are too numerous to describe completely
  52. here, but this section will describe the ones that apply to the major
  53. arithmetic operators.  This list will be rather technical in nature,
  54. and will probably be interesting to you only if you are a serious user
  55. of Calc's algebra facilities.
  56.    As well as the simplifications described here, if you have stored
  57. any rewrite rules in the variable `EvalRules' then these rules will
  58. also be applied before any built-in default simplifications.  *Note
  59. Automatic Rewrites::, for details.
  60.    And now, on with the default simplifications:
  61.    Arithmetic operators like `+' and `*' always take two arguments in
  62. Calc's internal form.  Sums and products of three or more terms are
  63. arranged by the associative law of algebra into a left-associative form
  64. for sums, `((a + b) + c) + d', and a right-associative form for
  65. products, `a * (b * (c * d))'.  Formulas like `(a + b) + (c + d)' are
  66. rearranged to left-associative form, though this rarely matters since
  67. Calc's algebra commands are designed to hide the inner structure of
  68. sums and products as much as possible.  Sums and products in their
  69. proper associative form will be written without parentheses in the
  70. examples below.
  71.    Sums and products are *not* rearranged according to the commutative
  72. law (`a + b' to `b + a') except in a few special cases described below.
  73. Some algebra programs always rearrange terms into a canonical order,
  74. which enables them to see that `a b + b a' can be simplified to `2 a b'.
  75. Calc assumes you have put the terms into the order you want and
  76. generally leaves that order alone, with the consequence that formulas
  77. like the above will only be simplified if you explicitly give the `a s'
  78. command.  *Note Algebraic Simplifications::.
  79.    Differences `a - b' are treated like sums `a + (-b)' for purposes of
  80. simplification; one of the default simplifications is to rewrite `a +
  81. (-b)' or `(-b) + a', where `-b' represents a "negative-looking" term,
  82. into `a - b' form.  "Negative-looking" means negative numbers, negated
  83. formulas like `-x', and products or quotients in which either term is
  84. negative-looking.
  85.    Other simplifications involving negation are `-(-x)' to `x'; `-(a
  86. b)' or `-(a/b)' where either `a' or `b' is negative-looking, simplified
  87. by negating that term, or else where `a' or `b' is any number, by
  88. negating that number; `-(a + b)' to `-a - b', and `-(b - a)' to `a - b'.
  89. (This, and rewriting `(-b) + a' to `a - b', are the only cases where
  90. the order of terms in a sum is changed by the default simplifications.)
  91.    The distributive law is used to simplify sums in some cases: `a x +
  92. b x' to `(a + b) x', where `a' represents a number or an implicit 1 or
  93. -1 (as in `x' or `-x') and similarly for `b'.  Use the `a c', `a f', or
  94. `j M' commands to merge sums with non-numeric coefficients using the
  95. distributive law.
  96.    The distributive law is only used for sums of two terms, or for
  97. adjacent terms in a larger sum.  Thus `a + b + b + c' is simplified to
  98. `a + 2 b + c', but `a + b + c + b' is not simplified.  The reason is
  99. that comparing all terms of a sum with one another would require time
  100. proportional to the square of the number of terms; Calc relegates
  101. potentially slow operations like this to commands that have to be
  102. invoked explicitly, like `a s'.
  103.    Finally, `a + 0' and `0 + a' are simplified to `a'.  A consequence
  104. of the above rules is that `0 - a' is simplified to `-a'.
  105.    The products `1 a' and `a 1' are simplified to `a'; `(-1) a' and `a
  106. (-1)' are simplified to `-a'; `0 a' and `a 0' are simplified to `0',
  107. except that in matrix mode where `a' is not provably scalar the result
  108. is the generic zero matrix `idn(0)', and that if `a' is infinite the
  109. result is `nan'.
  110.    Also, `(-a) b' and `a (-b)' are simplified to `-(a b)', where this
  111. occurs for negated formulas but not for regular negative numbers.
  112.    Products are commuted only to move numbers to the front: `a b 2' is
  113. commuted to `2 a b'.
  114.    The product `a (b + c)' is distributed over the sum only if `a' and
  115. at least one of `b' and `c' are numbers: `2 (x + 3)' goes to `2 x + 6'.
  116. The formula `(-a) (b - c)', where `-a' is a negative number, is
  117. rewritten to `a (c - b)'.
  118.    The distributive law of products and powers is used for adjacent
  119. terms of the product: `x^a x^b' goes to `x^(a+b)' where `a' is a
  120. number, or an implicit 1 (as in `x'), or the implicit one-half of
  121. `sqrt(x)', and similarly for `b'.  The result is written using `sqrt'
  122. or `1/sqrt' if the sum of the powers is `1/2' or `-1/2', respectively.
  123. If the sum of the powers is zero, the product is simplified to `1' or
  124. to `idn(1)' if matrix mode is enabled.
  125.    The product of a negative power times anything but another negative
  126. power is changed to use division:  `x^(-2) y' goes to `y / x^2' unless
  127. matrix mode is in effect and neither `x' nor `y' are scalar (in which
  128. case it is considered unsafe to rearrange the order of the terms).
  129.    Finally, `a (b/c)' is rewritten to `(a b)/c', and also `(a/b) c' is
  130. changed to `(a c)/b' unless in matrix mode.
  131.    Simplifications for quotients are analogous to those for products.
  132. The quotien