(Formulas, Composition Basics): Lower the precedence of negation.
[bpt/emacs.git] / doc / misc / calc.texi
index 59153b6..2441f0c 100644 (file)
@@ -1156,16 +1156,16 @@ solid implementation of Lisp, and the humble task of calculating
 turned out to be more open-ended than one might have expected.
 
 Emacs Lisp didn't have built-in floating point math (now it does), so
-this had to be
-simulated in software.  In fact, Emacs integers will only comfortably
-fit six decimal digits or so---not enough for a decent calculator.  So
-I had to write my own high-precision integer code as well, and once I had
-this I figured that arbitrary-size integers were just as easy as large
-integers.  Arbitrary floating-point precision was the logical next step.
-Also, since the large integer arithmetic was there anyway it seemed only
-fair to give the user direct access to it, which in turn made it practical
-to support fractions as well as floats.  All these features inspired me
-to look around for other data types that might be worth having.
+this had to be simulated in software.  In fact, Emacs integers would
+only comfortably fit six decimal digits or so---not enough for a decent
+calculator.  So I had to write my own high-precision integer code as
+well, and once I had this I figured that arbitrary-size integers were
+just as easy as large integers.  Arbitrary floating-point precision was
+the logical next step.  Also, since the large integer arithmetic was
+there anyway it seemed only fair to give the user direct access to it,
+which in turn made it practical to support fractions as well as floats.
+All these features inspired me to look around for other data types that
+might be worth having.
 
 Around this time, my friend Rick Koshi showed me his nifty new HP-28
 calculator.  It allowed the user to manipulate formulas as well as
@@ -11579,8 +11579,7 @@ with their equivalent function names, are:
 
 postfix @samp{%} [@code{percent}] (as in @samp{25% = 0.25});
 
-prefix @samp{+} and @samp{-} [@code{neg}] (as in @samp{-x})
-and prefix @samp{!} [@code{lnot}] (logical ``not,'' as in @samp{!x});
+prefix @samp{!} [@code{lnot}] (logical ``not,'' as in @samp{!x});
 
 @samp{+/-} [@code{sdev}] (the standard deviation symbol) and
 @samp{mod} [@code{makemod}] (the symbol for modulo forms);
@@ -11590,6 +11589,8 @@ and postfix @samp{!!} [@code{dfact}] (double factorial);
 
 @samp{^} [@code{pow}] (raised-to-the-power-of);
 
+prefix @samp{+} and @samp{-} [@code{neg}] (as in @samp{-x});
+
 @samp{*} [@code{mul}];
 
 @samp{/} [@code{div}], @samp{%} [@code{mod}] (modulo), and
@@ -14610,15 +14611,15 @@ The operator table used by normal and Big language modes has the
 following precedences:
 
 @example
-_     1200   @r{(subscripts)}
-%     1100   @r{(as in n}%@r{)}
--     1000   @r{(as in }-@r{n)}
-!     1000   @r{(as in }!@r{n)}
+_     1200    @r{(subscripts)}
+%     1100    @r{(as in n}%@r{)}
+!     1000    @r{(as in }!@r{n)}
 mod    400
 +/-    300
 !!     210    @r{(as in n}!!@r{)}
 !      210    @r{(as in n}!@r{)}
 ^      200
+-      197    @r{(as in }-@r{n)}
 *      195    @r{(or implicit multiplication)}
 / % \  190
 + -    180    @r{(as in a}+@r{b)}
@@ -17255,11 +17256,6 @@ daylight saving time (e.g., @code{PDT} or @code{PST}) the
 the algorithms described above are used.  If @var{zone} is omitted,
 the computation is done for the current time zone.
 
-@xref{Reporting Bugs}, for the address of Calc's author, if you
-should wish to contribute your improved versions of
-@code{math-tzone-names} and @code{math-daylight-savings-hook}
-to the Calc distribution.
-
 @node Financial Functions, Binary Functions, Date Arithmetic, Arithmetic
 @section Financial Functions
 
@@ -18325,11 +18321,11 @@ vector as an argument and computes @code{arctan2} of the elements.
 @pindex calc-coth
 @tindex coth
 The remaining trigonometric functions, @code{calc-sec} [@code{sec}],
-@code{calc-csc} [@code{csc}] and @code{calc-sec} [@code{sec}], are also
+@code{calc-csc} [@code{csc}] and @code{calc-cot} [@code{cot}], are also
 available.  With the Hyperbolic flag, these compute their hyperbolic
 counterparts, which are also available separately as @code{calc-sech}
-[@code{sech}], @code{calc-csch} [@code{csch}] and @code{calc-sech}
-[@code{sech}].  (These commmands do not accept the Inverse flag.)
+[@code{sech}], @code{calc-csch} [@code{csch}] and @code{calc-coth}
+[@code{coth}].  (These commands do not accept the Inverse flag.)
 
 @node Advanced Math Functions, Branch Cuts, Trigonometric and Hyperbolic Functions, Scientific Functions
 @section Advanced Mathematical Functions
@@ -21362,16 +21358,17 @@ entire four-term sum.
 @pindex calc-break-selections
 The @kbd{j b} (@code{calc-break-selections}) command controls a mode
 in which the ``deep structure'' of these associative formulas shows
-through.  Calc actually stores the above formulas as @samp{((a + b) - c) + d}
-and @samp{x * (y * z)}.  (Note that for certain obscure reasons, Calc
-treats multiplication as right-associative.)  Once you have enabled
-@kbd{j b} mode, selecting with the cursor on the @samp{-} sign would
-only select the @samp{a + b - c} portion, which makes sense when the
-deep structure of the sum is considered.  There is no way to select
-the @samp{b - c + d} portion; although this might initially look
-like just as legitimate a sub-formula as @samp{a + b - c}, the deep
-structure shows that it isn't.  The @kbd{d U} command can be used
-to view the deep structure of any formula (@pxref{Normal Language Modes}).
+through.  Calc actually stores the above formulas as 
+@samp{((a + b) - c) + d} and @samp{x * (y * z)}.  (Note that for certain 
+obscure reasons, by default Calc treats multiplication as
+right-associative.)  Once you have enabled @kbd{j b} mode, selecting
+with the cursor on the @samp{-} sign would only select the @samp{a + b -
+c} portion, which makes sense when the deep structure of the sum is
+considered.  There is no way to select the @samp{b - c + d} portion;
+although this might initially look like just as legitimate a sub-formula
+as @samp{a + b - c}, the deep structure shows that it isn't.  The @kbd{d
+U} command can be used to view the deep structure of any formula
+(@pxref{Normal Language Modes}).
 
 When @kbd{j b} mode has not been enabled, the deep structure is
 generally hidden by the selection commands---what you see is what
@@ -22163,13 +22160,13 @@ Arithmetic operators like @kbd{+} and @kbd{*} always take two
 arguments in Calc's internal form.  Sums and products of three or
 more terms are arranged by the associative law of algebra into
 a left-associative form for sums, @expr{((a + b) + c) + d}, and
-a right-associative form for products, @expr{a * (b * (c * d))}.
-Formulas like @expr{(a + b) + (c + d)} are rearranged to
-left-associative form, though this rarely matters since Calc's
-algebra commands are designed to hide the inner structure of
-sums and products as much as possible.  Sums and products in
-their proper associative form will be written without parentheses
-in the examples below.
+(by default) a right-associative form for products, 
+@expr{a * (b * (c * d))}.  Formulas like @expr{(a + b) + (c + d)} are
+rearranged to left-associative form, though this rarely matters since
+Calc's algebra commands are designed to hide the inner structure of sums
+and products as much as possible.  Sums and products in their proper
+associative form will be written without parentheses in the examples
+below.
 
 Sums and products are @emph{not} rearranged according to the
 commutative law (@expr{a + b} to @expr{b + a}) except in a few
@@ -27522,8 +27519,8 @@ If the value on the stack does not contain any units, @kbd{u c} will
 prompt first for the old units which this value should be considered
 to have, then for the new units.  Assuming the old and new units you
 give are consistent with each other, the result also will not contain
-any units.  For example, @kbd{@w{u c} cm @key{RET} in @key{RET}} converts the number
-2 on the stack to 5.08.
+any units.  For example, @kbd{@w{u c} cm @key{RET} in @key{RET}}
+converts the number 2 on the stack to 5.08.
 
 @kindex u b
 @pindex calc-base-units
@@ -27647,6 +27644,29 @@ column of the Units Table.
 @section Predefined Units
 
 @noindent
+The definitions of many units have changed over the years.  For example,
+the meter was originally defined in 1791 as one ten-millionth of the
+distance from the equator to the north pole.  In order to be more
+precise, the definition was adjusted several times, and now a meter is
+defined as the distance that light will travel in a vacuum in
+1/299792458 of a second; consequently, the speed of light in a
+vacuum is exactly 299792458 m/s.  Many other units have been
+redefined in terms of fundamental physical processes; a second, for
+example, is currently defined as 9192631770 periods of a certain
+radiation related to the cesium-133 atom.  The only SI unit that is not
+based on a fundamental physical process (although there are efforts to
+change this) is the kilogram, which was originally defined as the mass
+of one liter of water, but is now defined as the mass of the
+International Prototype Kilogram (IPK), a cylinder of platinum-iridium
+kept at the Bureau International des Poids et Mesures in S@`evres,
+France.  (There are several copies of the IPK throughout the world.)
+The British imperial units, once defined in terms of physical objects,
+were redefined in 1963 in terms of SI units.  The US customary units,
+which were the same as British units until the British imperial system
+was created in 1824, were also defined in terms of the SI units in 1893.
+Because of these redefinitions, conversions between metric, British
+Imperial, and US customary units can often be done precisely.
+
 Since the exact definitions of many kinds of units have evolved over the
 years, and since certain countries sometimes have local differences in
 their definitions, it is a good idea to examine Calc's definition of a
@@ -34850,12 +34870,14 @@ and @code{calc-embedded-open-close-plain-alist}.
 
 @defvar calc-multiplication-has-precedence
 The variable @code{calc-multiplication-has-precedence} determines
-whether multiplication has precedence over division in algebraic formulas
-in normal language modes.  If @code{calc-multiplication-has-precedence}
-is non-@code{nil}, then multiplication has precedence, and so for
-example @samp{a/b*c} will be interpreted as @samp{a/(b*c)}. If
-@code{calc-multiplication-has-precedence} is @code{nil}, then
-multiplication has the same precedence as division, and so for example
+whether multiplication has precedence over division in algebraic
+formulas in normal language modes.  If
+@code{calc-multiplication-has-precedence} is non-@code{nil}, then
+multiplication has precedence (and, for certain obscure reasons, is
+right associative), and so for example @samp{a/b*c} will be interpreted
+as @samp{a/(b*c)}. If @code{calc-multiplication-has-precedence} is
+@code{nil}, then multiplication has the same precedence as division
+(and, like division, is left associative), and so for example
 @samp{a/b*c} will be interpreted as @samp{(a/b)*c}.  The default value
 of @code{calc-multiplication-has-precedence} is @code{t}.
 @end defvar