home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / info / calc.info-15 (.txt) < prev    next >
GNU Info File  |  1994-12-22  |  47KB  |  759 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: Branch Cuts,  Next: Random Numbers,  Prev: Advanced Math Functions,  Up: Scientific Functions
  20. Branch Cuts and Principal Values
  21. ================================
  22. All of the logarithmic, trigonometric, and other scientific functions
  23. are defined for complex numbers as well as for reals.  This section
  24. describes the values returned in cases where the general result is a
  25. family of possible values.  Calc follows section 12.5.3 of Steele's
  26. "Common Lisp, the Language", second edition, in these matters.  This
  27. section will describe each function briefly; for a more detailed
  28. discussion (including some nifty diagrams), consult Steele's book.
  29.    Note that the branch cuts for `arctan' and `arctanh' were changed
  30. between the first and second editions of Steele.  Versions of Calc
  31. starting with 2.00 follow the second edition.
  32.    The new branch cuts exactly match those of the HP-28/48 calculators.
  33. They also match those of Mathematica 1.2, except that Mathematica's
  34. `arctan' cut is always in the right half of the complex plane, and its
  35. `arctanh' cut is always in the top half of the plane.  Calc's cuts are
  36. continuous with quadrants I and III for `arctan', or II and IV for
  37. `arctanh'.
  38.    Note:  The current implementations of these functions with complex
  39. arguments are designed with proper behavior around the branch cuts in
  40. mind, *not* efficiency or accuracy.  You may need to increase the
  41. floating precision and wait a while to get suitable answers from them.
  42.    For `sqrt(a+bi)':  When `a<0' and `b' is small but positive or zero,
  43. the result is close to the `+i' axis.  For `b' small and negative, the
  44. result is close to the `-i' axis.  The result always lies in the right
  45. half of the complex plane.
  46.    For `ln(a+bi)':  The real part is defined as `ln(abs(a+bi))'.  The
  47. imaginary part is defined as `arg(a+bi) = arctan2(b,a)'.  Thus the
  48. branch cuts for `sqrt' and `ln' both lie on the negative real axis.
  49.    The following table describes these branch cuts in another way.  If
  50. the real and imaginary parts of `z' are as shown, then the real and
  51. imaginary parts of `f(z)' will be as shown.  Here `eps' stands for a
  52. small positive value; each occurrence of `eps' may stand for a
  53. different small value.
  54.           z           sqrt(z)       ln(z)
  55.      ----------------------------------------
  56.         +,   0         +,  0       any, 0
  57.         -,   0         0,  +       any, pi
  58.         -, +eps      +eps, +      +eps, +
  59.         -, -eps      +eps, -      +eps, -
  60.    For `z1^z2':  This is defined by `exp(ln(z1)*z2)'.  One interesting
  61. consequence of this is that `(-8)^1:3' does not evaluate to -2 as you
  62. might expect, but to the complex number `(1., 1.732)'.  Both of these
  63. are valid cube roots of -8 (as is `(1., -1.732)'); Calc chooses a
  64. perhaps less-obvious root for the sake of mathematical consistency.
  65.    For `arcsin(z)':  This is defined by `-i*ln(i*z + sqrt(1-z^2))'.
  66. The branch cuts are on the real axis, less than -1 and greater than 1.
  67.    For `arccos(z)':  This is defined by `-i*ln(z + i*sqrt(1-z^2))', or
  68. equivalently by `pi/2 - arcsin(z)'.  The branch cuts are on the real
  69. axis, less than -1 and greater than 1.
  70.    For `arctan(z)':  This is defined by `(ln(1+i*z) - ln(1-i*z)) /
  71. (2*i)'.  The branch cuts are on the imaginary axis, below `-i' and
  72. above `i'.
  73.    For `arcsinh(z)':  This is defined by `ln(z + sqrt(1+z^2))'.  The
  74. branch cuts are on the imaginary axis, below `-i' and above `i'.
  75.    For `arccosh(z)':  This is defined by `ln(z +
  76. (z+1)*sqrt((z-1)/(z+1)))'.  The branch cut is on the real axis less
  77. than 1.
  78.    For `arctanh(z)':  This is defined by `(ln(1+z) - ln(1-z)) / 2'.
  79. The branch cuts are on the real axis, less than -1 and greater than 1.
  80.    The following tables for `arcsin', `arccos', and `arctan' assume the
  81. current angular mode is radians.  The hyperbolic functions operate
  82. independently of the angular mode.
  83.             z             arcsin(z)            arccos(z)
  84.      -------------------------------------------------------
  85.       (-1..1),  0      (-pi/2..pi/2), 0       (0..pi), 0
  86.       (-1..1), +eps    (-pi/2..pi/2), +eps    (0..pi), -eps
  87.       (-1..1), -eps    (-pi/2..pi/2), -eps    (0..pi), +eps
  88.         <-1,    0          -pi/2,     +         pi,    -
  89.         <-1,  +eps      -pi/2 + eps,  +      pi - eps, -
  90.         <-1,  -eps      -pi/2 + eps,  -      pi - eps, +
  91.          >1,    0           pi/2,     -          0,    +
  92.          >1,  +eps       pi/2 - eps,  +        +eps,   -
  93.          >1,  -eps       pi/2 - eps,  -        +eps,   +
  94.             z            arccosh(z)         arctanh(z)
  95.      -----------------------------------------------------
  96.       (-1..1),  0        0,  (0..pi)       any,     0
  97.       (-1..1), +eps    +eps, (0..pi)       any,    +eps
  98.       (-1..1), -eps    +eps, (-pi..0)      any,    -eps
  99.         <-1,    0        +,    pi           -,     pi/2
  100.         <-1,  +eps       +,  pi - eps       -,  pi/2 - eps
  101.         <-1,  -eps       +, -pi + eps       -, -pi/2 + eps
  102.          >1,    0        +,     0           +,    -pi/2
  103.          >1,  +eps       +,   +eps          +,  pi/2 - eps
  104.          >1,  -eps       +,   -eps          +, -pi/2 + eps
  105.             z           arcsinh(z)           arctan(z)
  106.      -----------------------------------------------------
  107.         0, (-1..1)    0, (-pi/2..pi/2)         0,     any
  108.         0,   <-1      -,    -pi/2            -pi/2,    -
  109.       +eps,  <-1      +, -pi/2 + eps       pi/2 - eps, -
  110.       -eps,  <-1      -, -pi/2 + eps      -pi/2 + eps, -
  111.         0,    >1      +,     pi/2             pi/2,    +
  112.       +eps,   >1      +,  pi/2 - eps       pi/2 - eps, +
  113.       -eps,   >1      -,  pi/2 - eps      -pi/2 + eps, +
  114.    Finally, the following identities help to illustrate the relationship
  115. between the complex trigonometric and hyperbolic functions.  They are
  116. valid everywhere, including on the branch cuts.
  117.      sin(i*z)  = i*sinh(z)       arcsin(i*z)  = i*arcsinh(z)
  118.      cos(i*z)  =   cosh(z)       arcsinh(i*z) = i*arcsin(z)
  119.      tan(i*z)  = i*tanh(z)       arctan(i*z)  = i*arctanh(z)
  120.      sinh(i*z) = i*sin(z)        cosh(i*z)    =   cos(z)
  121.    The "advanced math" functions (gamma, Bessel, etc.) are also defined
  122. for general complex arguments, but their branch cuts and principal
  123. values are not rigorously specified at present.
  124. File: calc.info,  Node: Random Numbers,  Next: Combinatorial Functions,  Prev: Branch Cuts,  Up: Scientific Functions
  125. Random Numbers
  126. ==============
  127. The `k r' (`calc-random') [`random'] command produces random numbers of
  128. various sorts.
  129.    Given a positive numeric prefix argument `M', it produces a random
  130. integer `N' in the range `0 <= N < M'.  Each of the `M' values appears
  131. with equal probability.
  132.    With no numeric prefix argument, the `k r' command takes its argument
  133. from the stack instead.  Once again, if this is a positive integer `M'
  134. the result is a random integer less than `M'.  However, note that while
  135. numeric prefix arguments are limited to six digits or so, an `M' taken
  136. from the stack can be arbitrarily large.  If `M' is negative, the
  137. result is a random integer in the range `M < N <= 0'.
  138.    If the value on the stack is a floating-point number `M', the result
  139. is a random floating-point n