home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD1.bin
/
gnu
/
info
/
calc.info-15
(
.txt
)
< prev
next >
Wrap
GNU Info File
|
1994-12-22
|
47KB
|
759 lines
This is Info file calc.info, produced by Makeinfo-1.55 from the input
file calc.texinfo.
This file documents Calc, the GNU Emacs calculator.
Copyright (C) 1990, 1991 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided also
that the section entitled "GNU General Public License" is included
exactly as in the original, and provided that the entire resulting
derived work is distributed under the terms of a permission notice
identical to this one.
Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that the section entitled "GNU General Public License"
may be included in a translation approved by the author instead of in
the original English.
File: calc.info, Node: Branch Cuts, Next: Random Numbers, Prev: Advanced Math Functions, Up: Scientific Functions
Branch Cuts and Principal Values
================================
All of the logarithmic, trigonometric, and other scientific functions
are defined for complex numbers as well as for reals. This section
describes the values returned in cases where the general result is a
family of possible values. Calc follows section 12.5.3 of Steele's
"Common Lisp, the Language", second edition, in these matters. This
section will describe each function briefly; for a more detailed
discussion (including some nifty diagrams), consult Steele's book.
Note that the branch cuts for `arctan' and `arctanh' were changed
between the first and second editions of Steele. Versions of Calc
starting with 2.00 follow the second edition.
The new branch cuts exactly match those of the HP-28/48 calculators.
They also match those of Mathematica 1.2, except that Mathematica's
`arctan' cut is always in the right half of the complex plane, and its
`arctanh' cut is always in the top half of the plane. Calc's cuts are
continuous with quadrants I and III for `arctan', or II and IV for
`arctanh'.
Note: The current implementations of these functions with complex
arguments are designed with proper behavior around the branch cuts in
mind, *not* efficiency or accuracy. You may need to increase the
floating precision and wait a while to get suitable answers from them.
For `sqrt(a+bi)': When `a<0' and `b' is small but positive or zero,
the result is close to the `+i' axis. For `b' small and negative, the
result is close to the `-i' axis. The result always lies in the right
half of the complex plane.
For `ln(a+bi)': The real part is defined as `ln(abs(a+bi))'. The
imaginary part is defined as `arg(a+bi) = arctan2(b,a)'. Thus the
branch cuts for `sqrt' and `ln' both lie on the negative real axis.
The following table describes these branch cuts in another way. If
the real and imaginary parts of `z' are as shown, then the real and
imaginary parts of `f(z)' will be as shown. Here `eps' stands for a
small positive value; each occurrence of `eps' may stand for a
different small value.
z sqrt(z) ln(z)
----------------------------------------
+, 0 +, 0 any, 0
-, 0 0, + any, pi
-, +eps +eps, + +eps, +
-, -eps +eps, - +eps, -
For `z1^z2': This is defined by `exp(ln(z1)*z2)'. One interesting
consequence of this is that `(-8)^1:3' does not evaluate to -2 as you
might expect, but to the complex number `(1., 1.732)'. Both of these
are valid cube roots of -8 (as is `(1., -1.732)'); Calc chooses a
perhaps less-obvious root for the sake of mathematical consistency.
For `arcsin(z)': This is defined by `-i*ln(i*z + sqrt(1-z^2))'.
The branch cuts are on the real axis, less than -1 and greater than 1.
For `arccos(z)': This is defined by `-i*ln(z + i*sqrt(1-z^2))', or
equivalently by `pi/2 - arcsin(z)'. The branch cuts are on the real
axis, less than -1 and greater than 1.
For `arctan(z)': This is defined by `(ln(1+i*z) - ln(1-i*z)) /
(2*i)'. The branch cuts are on the imaginary axis, below `-i' and
above `i'.
For `arcsinh(z)': This is defined by `ln(z + sqrt(1+z^2))'. The
branch cuts are on the imaginary axis, below `-i' and above `i'.
For `arccosh(z)': This is defined by `ln(z +
(z+1)*sqrt((z-1)/(z+1)))'. The branch cut is on the real axis less
than 1.
For `arctanh(z)': This is defined by `(ln(1+z) - ln(1-z)) / 2'.
The branch cuts are on the real axis, less than -1 and greater than 1.
The following tables for `arcsin', `arccos', and `arctan' assume the
current angular mode is radians. The hyperbolic functions operate
independently of the angular mode.
z arcsin(z) arccos(z)
-------------------------------------------------------
(-1..1), 0 (-pi/2..pi/2), 0 (0..pi), 0
(-1..1), +eps (-pi/2..pi/2), +eps (0..pi), -eps
(-1..1), -eps (-pi/2..pi/2), -eps (0..pi), +eps
<-1, 0 -pi/2, + pi, -
<-1, +eps -pi/2 + eps, + pi - eps, -
<-1, -eps -pi/2 + eps, - pi - eps, +
>1, 0 pi/2, - 0, +
>1, +eps pi/2 - eps, + +eps, -
>1, -eps pi/2 - eps, - +eps, +
z arccosh(z) arctanh(z)
-----------------------------------------------------
(-1..1), 0 0, (0..pi) any, 0
(-1..1), +eps +eps, (0..pi) any, +eps
(-1..1), -eps +eps, (-pi..0) any, -eps
<-1, 0 +, pi -, pi/2
<-1, +eps +, pi - eps -, pi/2 - eps
<-1, -eps +, -pi + eps -, -pi/2 + eps
>1, 0 +, 0 +, -pi/2
>1, +eps +, +eps +, pi/2 - eps
>1, -eps +, -eps +, -pi/2 + eps
z arcsinh(z) arctan(z)
-----------------------------------------------------
0, (-1..1) 0, (-pi/2..pi/2) 0, any
0, <-1 -, -pi/2 -pi/2, -
+eps, <-1 +, -pi/2 + eps pi/2 - eps, -
-eps, <-1 -, -pi/2 + eps -pi/2 + eps, -
0, >1 +, pi/2 pi/2, +
+eps, >1 +, pi/2 - eps pi/2 - eps, +
-eps, >1 -, pi/2 - eps -pi/2 + eps, +
Finally, the following identities help to illustrate the relationship
between the complex trigonometric and hyperbolic functions. They are
valid everywhere, including on the branch cuts.
sin(i*z) = i*sinh(z) arcsin(i*z) = i*arcsinh(z)
cos(i*z) = cosh(z) arcsinh(i*z) = i*arcsin(z)
tan(i*z) = i*tanh(z) arctan(i*z) = i*arctanh(z)
sinh(i*z) = i*sin(z) cosh(i*z) = cos(z)
The "advanced math" functions (gamma, Bessel, etc.) are also defined
for general complex arguments, but their branch cuts and principal
values are not rigorously specified at present.
File: calc.info, Node: Random Numbers, Next: Combinatorial Functions, Prev: Branch Cuts, Up: Scientific Functions
Random Numbers
==============
The `k r' (`calc-random') [`random'] command produces random numbers of
various sorts.
Given a positive numeric prefix argument `M', it produces a random
integer `N' in the range `0 <= N < M'. Each of the `M' values appears
with equal probability.
With no numeric prefix argument, the `k r' command takes its argument
from the stack instead. Once again, if this is a positive integer `M'
the result is a random integer less than `M'. However, note that while
numeric prefix arguments are limited to six digits or so, an `M' taken
from the stack can be arbitrarily large. If `M' is negative, the
result is a random integer in the range `M < N <= 0'.
If the value on the stack is a floating-point number `M', the result
is a random floating-point n