/[emacs]/emacs/man/calc.texi
ViewVC logotype

Diff of /emacs/man/calc.texi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.27 by jpb, Wed Dec 8 22:47:37 2004 UTC revision 1.28 by jpb, Tue Dec 14 04:53:56 2004 UTC
# Line 13  Line 13 
13  @c @infoline foo  @c @infoline foo
14  @c    `foo' will appear only in non-TeX output  @c    `foo' will appear only in non-TeX output
15    
16  @c In TeX output, @tmath{expr} will typeset expr in  math mode.  @c @expr{expr} will typeset an expression;
 @c In any output, @expr{expr} will typeset an expression;  
17  @c $x$ in TeX, @samp{x} otherwise.  @c $x$ in TeX, @samp{x} otherwise.
18    
19  @iftex  @iftex
20  @macro texline{stuff}  @macro texline{stuff}
21  \stuff\  \stuff\
22  @end macro  @end macro
 @macro tmath{stuff}  
 @tex  
 $\stuff\$  
 @end tex  
 @end macro  
23  @alias infoline=comment  @alias infoline=comment
 @c @alias expr=math  
24  @tex  @tex
25  \gdef\expr#1{\tex  \gdef\exprsetup{\tex \let\t\ttfont \turnoffactive}
26               \let\t\ttfont  \gdef\expr{\exprsetup$\exprfinish}
27               \turnoffactive  \gdef\exprfinish#1{#1$\endgroup}
              $#1$  
              \endgroup}  
28  @end tex  @end tex
29    @alias mathit=expr
30  @macro cpi{}  @macro cpi{}
31  @math{@pi{}}  @math{@pi{}}
32  @end macro  @end macro
# Line 49  $\stuff\$ Line 41  $\stuff\$
41  \stuff\  \stuff\
42  @end macro  @end macro
43  @alias expr=samp  @alias expr=samp
44    @alias mathit=i
45  @macro cpi{}  @macro cpi{}
46  @expr{pi}  @expr{pi}
47  @end macro  @end macro
# Line 624  then the command to operate on the numbe Line 617  then the command to operate on the numbe
617    
618  @noindent  @noindent
619  Type @kbd{2 @key{RET} 3 + Q} to compute  Type @kbd{2 @key{RET} 3 + Q} to compute
620  @texline @tmath{\sqrt{2+3} = 2.2360679775}.  @texline @math{\sqrt{2+3} = 2.2360679775}.
621  @infoline the square root of 2+3, which is 2.2360679775.  @infoline the square root of 2+3, which is 2.2360679775.
622    
623  @noindent  @noindent
624  Type @kbd{P 2 ^} to compute  Type @kbd{P 2 ^} to compute
625  @texline @tmath{\pi^2 = 9.86960440109}.  @texline @math{\pi^2 = 9.86960440109}.
626  @infoline the value of `pi' squared, 9.86960440109.  @infoline the value of `pi' squared, 9.86960440109.
627    
628  @noindent  @noindent
# Line 648  use the apostrophe key. Line 641  use the apostrophe key.
641    
642  @noindent  @noindent
643  Type @kbd{' sqrt(2+3) @key{RET}} to compute  Type @kbd{' sqrt(2+3) @key{RET}} to compute
644  @texline @tmath{\sqrt{2+3}}.  @texline @math{\sqrt{2+3}}.
645  @infoline the square root of 2+3.  @infoline the square root of 2+3.
646    
647  @noindent  @noindent
648  Type @kbd{' pi^2 @key{RET}} to enter  Type @kbd{' pi^2 @key{RET}} to enter
649  @texline @tmath{\pi^2}.  @texline @math{\pi^2}.
650  @infoline `pi' squared.    @infoline `pi' squared.  
651  To evaluate this symbolic formula as a number, type @kbd{=}.  To evaluate this symbolic formula as a number, type @kbd{=}.
652    
# Line 713  the lower-right @samp{8} and press @kbd{ Line 706  the lower-right @samp{8} and press @kbd{
706    
707  @noindent  @noindent
708  Type @kbd{v t} to transpose this  Type @kbd{v t} to transpose this
709  @texline @tmath{3\times2}  @texline @math{3\times2}
710  @infoline 3x2  @infoline 3x2
711  matrix into a  matrix into a
712  @texline @tmath{2\times3}  @texline @math{2\times3}
713  @infoline 2x3  @infoline 2x3
714  matrix.  Type @w{@kbd{v u}} to unpack the rows into two separate  matrix.  Type @w{@kbd{v u}} to unpack the rows into two separate
715  vectors.  Now type @w{@kbd{V R + @key{TAB} V R +}} to compute the sums  vectors.  Now type @w{@kbd{V R + @key{TAB} V R +}} to compute the sums
# Line 867  you do. Line 860  you do.
860    
861  In this case, the trail shows that four numbers (17.3, 3, 2, and 4)  In this case, the trail shows that four numbers (17.3, 3, 2, and 4)
862  were first entered into the Calculator, then the 2 and 4 were  were first entered into the Calculator, then the 2 and 4 were
863  multiplied to get 8, then the 3 and 8 were subtracted to get @i{-5}.  multiplied to get 8, then the 3 and 8 were subtracted to get @mathit{-5}.
864  (The @samp{>} symbol shows that this was the most recent calculation.)  (The @samp{>} symbol shows that this was the most recent calculation.)
865  The net result is the two numbers 17.3 and @i{-5} sitting on the stack.  The net result is the two numbers 17.3 and @mathit{-5} sitting on the stack.
866    
867  Most Calculator commands deal explicitly with the stack only, but  Most Calculator commands deal explicitly with the stack only, but
868  there is a set of commands that allow you to search back through  there is a set of commands that allow you to search back through
# Line 930  full complexity of the stack and trail. Line 923  full complexity of the stack and trail.
923    
924  Quick Mode is very simple:  It prompts you to type any formula in  Quick Mode is very simple:  It prompts you to type any formula in
925  standard algebraic notation (like @samp{4 - 2/3}) and then displays  standard algebraic notation (like @samp{4 - 2/3}) and then displays
926  the result at the bottom of the Emacs screen (@i{3.33333333333}  the result at the bottom of the Emacs screen (@mathit{3.33333333333}
927  in this case).  You are then back in the same editing buffer you  in this case).  You are then back in the same editing buffer you
928  were in before, ready to continue editing or to type @kbd{M-# q}  were in before, ready to continue editing or to type @kbd{M-# q}
929  again to do another quick calculation.  The result of the calculation  again to do another quick calculation.  The result of the calculation
# Line 1343  With any prefix argument, reset everythi Line 1336  With any prefix argument, reset everythi
1336  Calc was originally started as a two-week project to occupy a lull  Calc was originally started as a two-week project to occupy a lull
1337  in the author's schedule.  Basically, a friend asked if I remembered  in the author's schedule.  Basically, a friend asked if I remembered
1338  the value of  the value of
1339  @texline @tmath{2^{32}}.  @texline @math{2^{32}}.
1340  @infoline @expr{2^32}.    @infoline @expr{2^32}.  
1341  I didn't offhand, but I said, ``that's easy, just call up an  I didn't offhand, but I said, ``that's easy, just call up an
1342  @code{xcalc}.''  @code{Xcalc} duly reported that the answer to our  @code{xcalc}.''  @code{Xcalc} duly reported that the answer to our
# Line 1665  multiplication.)  Figure it out by hand, Line 1658  multiplication.)  Figure it out by hand,
1658  if you're right.  @xref{RPN Answer 1, 1}. (@bullet{})  if you're right.  @xref{RPN Answer 1, 1}. (@bullet{})
1659    
1660  (@bullet{}) @strong{Exercise 2.}  Compute  (@bullet{}) @strong{Exercise 2.}  Compute
1661  @texline @tmath{(2\times4) + (7\times9.4) + {5\over4}}  @texline @math{(2\times4) + (7\times9.4) + {5\over4}}
1662  @infoline @expr{2*4 + 7*9.5 + 5/4}  @infoline @expr{2*4 + 7*9.5 + 5/4}
1663  using the stack.  @xref{RPN Answer 2, 2}. (@bullet{})  using the stack.  @xref{RPN Answer 2, 2}. (@bullet{})
1664    
# Line 2000  $$ 2 + { 3 \times 4 \times 5 \over 6 \ti Line 1993  $$ 2 + { 3 \times 4 \times 5 \over 6 \ti
1993  @end tex  @end tex
1994    
1995  @noindent  @noindent
1996  The result of this expression will be the number @i{-6.99999826533}.  The result of this expression will be the number @mathit{-6.99999826533}.
1997    
1998  Calc's order of evaluation is the same as for most computer languages,  Calc's order of evaluation is the same as for most computer languages,
1999  except that @samp{*} binds more strongly than @samp{/}, as the above  except that @samp{*} binds more strongly than @samp{/}, as the above
# Line 2009  can often be omitted:  @samp{2 a} is the Line 2002  can often be omitted:  @samp{2 a} is the
2002    
2003  Operators at the same level are evaluated from left to right, except  Operators at the same level are evaluated from left to right, except
2004  that @samp{^} is evaluated from right to left.  Thus, @samp{2-3-4} is  that @samp{^} is evaluated from right to left.  Thus, @samp{2-3-4} is
2005  equivalent to @samp{(2-3)-4} or @i{-5}, whereas @samp{2^3^4} is equivalent  equivalent to @samp{(2-3)-4} or @mathit{-5}, whereas @samp{2^3^4} is equivalent
2006  to @samp{2^(3^4)} (a very large integer; try it!).  to @samp{2^(3^4)} (a very large integer; try it!).
2007    
2008  If you tire of typing the apostrophe all the time, there is an  If you tire of typing the apostrophe all the time, there is an
# Line 2079  accomplish this in Calc by performing yo Line 2072  accomplish this in Calc by performing yo
2072  of algebraic entries, using the @kbd{$} sign to tie them together.  of algebraic entries, using the @kbd{$} sign to tie them together.
2073  In an algebraic formula, @kbd{$} represents the number on the top  In an algebraic formula, @kbd{$} represents the number on the top
2074  of the stack.  Here, we perform the calculation  of the stack.  Here, we perform the calculation
2075  @texline @tmath{\sqrt{2\times4+1}},  @texline @math{\sqrt{2\times4+1}},
2076  @infoline @expr{sqrt(2*4+1)},  @infoline @expr{sqrt(2*4+1)},
2077  which on a traditional calculator would be done by pressing  which on a traditional calculator would be done by pressing
2078  @kbd{2 * 4 + 1 =} and then the square-root key.  @kbd{2 * 4 + 1 =} and then the square-root key.
# Line 2741  angle is measured in degrees.  For examp Line 2734  angle is measured in degrees.  For examp
2734  @noindent  @noindent
2735  The shift-@kbd{S} command computes the sine of an angle.  The sine  The shift-@kbd{S} command computes the sine of an angle.  The sine
2736  of 45 degrees is  of 45 degrees is
2737  @texline @tmath{\sqrt{2}/2};  @texline @math{\sqrt{2}/2};
2738  @infoline @expr{sqrt(2)/2};  @infoline @expr{sqrt(2)/2};
2739  squaring this yields @expr{2/4 = 0.5}.  However, there has been a slight  squaring this yields @expr{2/4 = 0.5}.  However, there has been a slight
2740  roundoff error because the representation of  roundoff error because the representation of
2741  @texline @tmath{\sqrt{2}/2}  @texline @math{\sqrt{2}/2}
2742  @infoline @expr{sqrt(2)/2}  @infoline @expr{sqrt(2)/2}
2743  wasn't exact.  The @kbd{c 1} command is a handy way to clean up numbers  wasn't exact.  The @kbd{c 1} command is a handy way to clean up numbers
2744  in this case; it temporarily reduces the precision by one digit while it  in this case; it temporarily reduces the precision by one digit while it
# Line 2786  either radians or degrees, depending on Line 2779  either radians or degrees, depending on
2779    
2780  @noindent  @noindent
2781  Here we compute the Inverse Sine of  Here we compute the Inverse Sine of
2782  @texline @tmath{\sqrt{0.5}},  @texline @math{\sqrt{0.5}},
2783  @infoline @expr{sqrt(0.5)},  @infoline @expr{sqrt(0.5)},
2784  first in radians, then in degrees.  first in radians, then in degrees.
2785    
# Line 2974  logarithm).  These can be modified by th Line 2967  logarithm).  These can be modified by th
2967    
2968  Let's compute the sine and cosine of an angle, and verify the  Let's compute the sine and cosine of an angle, and verify the
2969  identity  identity
2970  @texline @tmath{\sin^2x + \cos^2x = 1}.  @texline @math{\sin^2x + \cos^2x = 1}.
2971  @infoline @expr{sin(x)^2 + cos(x)^2 = 1}.    @infoline @expr{sin(x)^2 + cos(x)^2 = 1}.  
2972  We'll arbitrarily pick @i{-64} degrees as a good value for @expr{x}.  We'll arbitrarily pick @mathit{-64} degrees as a good value for @expr{x}.
2973  With the angular mode set to degrees (type @w{@kbd{m d}}), do:  With the angular mode set to degrees (type @w{@kbd{m d}}), do:
2974    
2975  @smallexample  @smallexample
# Line 2997  Remember, @kbd{f h} is the @code{calc-hy Line 2990  Remember, @kbd{f h} is the @code{calc-hy
2990  of squares, command.  of squares, command.
2991    
2992  Another identity is  Another identity is
2993  @texline @tmath{\displaystyle\tan x = {\sin x \over \cos x}}.  @texline @math{\displaystyle\tan x = {\sin x \over \cos x}}.
2994  @infoline @expr{tan(x) = sin(x) / cos(x)}.  @infoline @expr{tan(x) = sin(x) / cos(x)}.
2995  @smallexample  @smallexample
2996  @group  @group
# Line 3012  Another identity is Line 3005  Another identity is
3005    
3006  A physical interpretation of this calculation is that if you move  A physical interpretation of this calculation is that if you move
3007  @expr{0.89879} units downward and @expr{0.43837} units to the right,  @expr{0.89879} units downward and @expr{0.43837} units to the right,
3008  your direction of motion is @i{-64} degrees from horizontal.  Suppose  your direction of motion is @mathit{-64} degrees from horizontal.  Suppose
3009  we move in the opposite direction, up and to the left:  we move in the opposite direction, up and to the left:
3010    
3011  @smallexample  @smallexample
# Line 3060  the top two stack elements right after t Line 3053  the top two stack elements right after t
3053    
3054  A similar identity is supposed to hold for hyperbolic sines and cosines,  A similar identity is supposed to hold for hyperbolic sines and cosines,
3055  except that it is the @emph{difference}  except that it is the @emph{difference}
3056  @texline @tmath{\cosh^2x - \sinh^2x}  @texline @math{\cosh^2x - \sinh^2x}
3057  @infoline @expr{cosh(x)^2 - sinh(x)^2}  @infoline @expr{cosh(x)^2 - sinh(x)^2}
3058  that always equals one.  Let's try to verify this identity.  that always equals one.  Let's try to verify this identity.
3059    
# Line 3167  in this case). Line 3160  in this case).
3160    
3161  If you take the factorial of a non-integer, Calc uses a generalized  If you take the factorial of a non-integer, Calc uses a generalized
3162  factorial function defined in terms of Euler's Gamma function  factorial function defined in terms of Euler's Gamma function
3163  @texline @tmath{\Gamma(n)}  @texline @math{\Gamma(n)}
3164  @infoline @expr{gamma(n)}  @infoline @expr{gamma(n)}
3165  (which is itself available as the @kbd{f g} command).  (which is itself available as the @kbd{f g} command).
3166    
# Line 3184  factorial function defined in terms of E Line 3177  factorial function defined in terms of E
3177    
3178  @noindent  @noindent
3179  Here we verify the identity  Here we verify the identity
3180  @texline @tmath{n! = \Gamma(n+1)}.  @texline @math{n! = \Gamma(n+1)}.
3181  @infoline @expr{@var{n}!@: = gamma(@var{n}+1)}.  @infoline @expr{@var{n}!@: = gamma(@var{n}+1)}.
3182    
3183  The binomial coefficient @var{n}-choose-@var{m}  The binomial coefficient @var{n}-choose-@var{m}
3184  @texline or @tmath{\displaystyle {n \choose m}}  @texline or @math{\displaystyle {n \choose m}}
3185  is defined by  is defined by
3186  @texline @tmath{\displaystyle {n! \over m! \, (n-m)!}}  @texline @math{\displaystyle {n! \over m! \, (n-m)!}}
3187  @infoline @expr{n!@: / m!@: (n-m)!}  @infoline @expr{n!@: / m!@: (n-m)!}
3188  for all reals @expr{n} and @expr{m}.  The intermediate results in this  for all reals @expr{n} and @expr{m}.  The intermediate results in this
3189  formula can become quite large even if the final result is small; the  formula can become quite large even if the final result is small; the
# Line 3475  vector. Line 3468  vector.
3468    
3469  (@bullet{}) @strong{Exercise 1.}  Use @samp{*} to sum along the rows  (@bullet{}) @strong{Exercise 1.}  Use @samp{*} to sum along the rows
3470  of the above  of the above
3471  @texline @tmath{2\times3}  @texline @math{2\times3}
3472  @infoline 2x3  @infoline 2x3
3473  matrix to get @expr{[6, 15]}.  Now use @samp{*} to sum along the columns  matrix to get @expr{[6, 15]}.  Now use @samp{*} to sum along the columns
3474  to get @expr{[5, 7, 9]}.  to get @expr{[5, 7, 9]}.
# Line 3626  assume the vector was a row vector in or Line 3619  assume the vector was a row vector in or
3619  come out right, and the answer would be incorrect.  If you  come out right, and the answer would be incorrect.  If you
3620  don't feel safe letting Calc take either interpretation of your  don't feel safe letting Calc take either interpretation of your
3621  vectors, use explicit  vectors, use explicit
3622  @texline @tmath{N\times1}  @texline @math{N\times1}
3623  @infoline Nx1  @infoline Nx1
3624  or  or
3625  @texline @tmath{1\times N}  @texline @math{1\times N}
3626  @infoline 1xN  @infoline 1xN
3627  matrices instead.  In this case, you would enter the original column  matrices instead.  In this case, you would enter the original column
3628  vector as @samp{[[6], [2], [3]]} or @samp{[6; 2; 3]}.  vector as @samp{[[6], [2], [3]]} or @samp{[6; 2; 3]}.
# Line 3678  on the left by the transpose of @expr{A} Line 3671  on the left by the transpose of @expr{A}
3671  $A^T A \, X = A^T B$, where $A^T$ is the transpose \samp{trn(A)}.  $A^T A \, X = A^T B$, where $A^T$ is the transpose \samp{trn(A)}.
3672  @end tex  @end tex
3673  Now  Now
3674  @texline @tmath{A^T A}  @texline @math{A^T A}
3675  @infoline @expr{trn(A)*A}  @infoline @expr{trn(A)*A}
3676  is a square matrix so a solution is possible.  It turns out that the  is a square matrix so a solution is possible.  It turns out that the
3677  @expr{X} vector you compute in this way will be a ``least-squares''  @expr{X} vector you compute in this way will be a ``least-squares''
# Line 3774  of each element. Line 3767  of each element.
3767    
3768  (@bullet{}) @strong{Exercise 1.}  Compute a vector of powers of two  (@bullet{}) @strong{Exercise 1.}  Compute a vector of powers of two
3769  from  from
3770  @texline @tmath{2^{-4}}  @texline @math{2^{-4}}
3771  @infoline @expr{2^-4}  @infoline @expr{2^-4}
3772  to @expr{2^4}.  @xref{List Answer 1, 1}. (@bullet{})  to @expr{2^4}.  @xref{List Answer 1, 1}. (@bullet{})
3773    
# Line 3978  $$ m = {N \sum x y - \sum x \sum y  \ove Line 3971  $$ m = {N \sum x y - \sum x \sum y  \ove
3971    
3972  @noindent  @noindent
3973  where  where
3974  @texline @tmath{\sum x}  @texline @math{\sum x}
3975  @infoline @expr{sum(x)}  @infoline @expr{sum(x)}
3976  represents the sum of all the values of @expr{x}.  While there is an  represents the sum of all the values of @expr{x}.  While there is an
3977  actual @code{sum} function in Calc, it's easier to sum a vector using a  actual @code{sum} function in Calc, it's easier to sum a vector using a
# Line 4083  $$ b = {\sum y - m \sum x \over N} $$ Line 4076  $$ b = {\sum y - m \sum x \over N} $$
4076  @end smallexample  @end smallexample
4077    
4078  Let's ``plot'' this straight line approximation,  Let's ``plot'' this straight line approximation,
4079  @texline @tmath{y \approx m x + b},  @texline @math{y \approx m x + b},
4080  @infoline @expr{m x + b},  @infoline @expr{m x + b},
4081  and compare it with the original data.  and compare it with the original data.
4082    
# Line 4336  command to enable multi-line display of Line 4329  command to enable multi-line display of
4329  @cindex Maximizing a function over a list of values  @cindex Maximizing a function over a list of values
4330  @c [fix-ref Numerical Solutions]  @c [fix-ref Numerical Solutions]
4331  (@bullet{}) @strong{Exercise 8.}  Compute a list of values of Bessel's  (@bullet{}) @strong{Exercise 8.}  Compute a list of values of Bessel's
4332  @texline @tmath{J_1(x)}  @texline @math{J_1(x)}
4333  @infoline @expr{J1}  @infoline @expr{J1}
4334  function @samp{besJ(1,x)} for @expr{x} from 0 to 5 in steps of 0.25.  function @samp{besJ(1,x)} for @expr{x} from 0 to 5 in steps of 0.25.
4335  Find the value of @expr{x} (from among the above set of values) for  Find the value of @expr{x} (from among the above set of values) for
# Line 4348  of thing automatically; @pxref{Numerical Line 4341  of thing automatically; @pxref{Numerical
4341    
4342  @cindex Digits, vectors of  @cindex Digits, vectors of
4343  (@bullet{}) @strong{Exercise 9.}  You are given an integer in the range  (@bullet{}) @strong{Exercise 9.}  You are given an integer in the range
4344  @texline @tmath{0 \le N < 10^m}  @texline @math{0 \le N < 10^m}
4345  @infoline @expr{0 <= N < 10^m}  @infoline @expr{0 <= N < 10^m}
4346  for @expr{m=12} (i.e., an integer of less than  for @expr{m=12} (i.e., an integer of less than
4347  twelve digits).  Convert this integer into a vector of @expr{m}  twelve digits).  Convert this integer into a vector of @expr{m}
# Line 4364  happened?  How would you do this test? Line 4357  happened?  How would you do this test?
4357    
4358  (@bullet{}) @strong{Exercise 11.}  The area of a circle of radius one  (@bullet{}) @strong{Exercise 11.}  The area of a circle of radius one
4359  is @cpi{}.  The area of the  is @cpi{}.  The area of the
4360  @texline @tmath{2\times2}  @texline @math{2\times2}
4361  @infoline 2x2  @infoline 2x2
4362  square that encloses that circle is 4.  So if we throw @var{n} darts at  square that encloses that circle is 4.  So if we throw @var{n} darts at
4363  random points in the square, about @cpiover{4} of them will land inside  random points in the square, about @cpiover{4} of them will land inside
4364  the circle.  This gives us an entertaining way to estimate the value of  the circle.  This gives us an entertaining way to estimate the value of
4365  @cpi{}.  The @w{@kbd{k r}}  @cpi{}.  The @w{@kbd{k r}}
4366  command picks a random number between zero and the value on the stack.  command picks a random number between zero and the value on the stack.
4367  We could get a random floating-point number between @i{-1} and 1 by typing  We could get a random floating-point number between @mathit{-1} and 1 by typing
4368  @w{@kbd{2.0 k r 1 -}}.  Build a vector of 100 random @expr{(x,y)} points in  @w{@kbd{2.0 k r 1 -}}.  Build a vector of 100 random @expr{(x,y)} points in
4369  this square, then use vector mapping and reduction to count how many  this square, then use vector mapping and reduction to count how many
4370  points lie inside the unit circle.  Hint:  Use the @kbd{v b} command.  points lie inside the unit circle.  Hint:  Use the @kbd{v b} command.
# Line 4383  another way to calculate @cpi{}.  Say yo Line 4376  another way to calculate @cpi{}.  Say yo
4376  of vertical lines with a spacing of one inch.  Toss a one-inch matchstick  of vertical lines with a spacing of one inch.  Toss a one-inch matchstick
4377  onto the field.  The probability that the matchstick will land crossing  onto the field.  The probability that the matchstick will land crossing
4378  a line turns out to be  a line turns out to be
4379  @texline @tmath{2/\pi}.  @texline @math{2/\pi}.
4380  @infoline @expr{2/pi}.    @infoline @expr{2/pi}.  
4381  Toss 100 matchsticks to estimate @cpi{}.  (If you want still more fun,  Toss 100 matchsticks to estimate @cpi{}.  (If you want still more fun,
4382  the probability that the GCD (@w{@kbd{k g}}) of two large integers is  the probability that the GCD (@w{@kbd{k g}}) of two large integers is
4383  one turns out to be  one turns out to be
4384  @texline @tmath{6/\pi^2}.  @texline @math{6/\pi^2}.
4385  @infoline @expr{6/pi^2}.  @infoline @expr{6/pi^2}.
4386  That provides yet another way to estimate @cpi{}.)  That provides yet another way to estimate @cpi{}.)
4387  @xref{List Answer 12, 12}. (@bullet{})  @xref{List Answer 12, 12}. (@bullet{})
# Line 4418  value and a number of steps @var{n} from Line 4411  value and a number of steps @var{n} from
4411  function you give to the starting value 0, 1, 2, up to @var{n} times  function you give to the starting value 0, 1, 2, up to @var{n} times
4412  and returns a vector of the results.  Use this command to create a  and returns a vector of the results.  Use this command to create a
4413  ``random walk'' of 50 steps.  Start with the two-dimensional point  ``random walk'' of 50 steps.  Start with the two-dimensional point
4414  @expr{(0,0)}; then take one step a random distance between @i{-1} and 1  @expr{(0,0)}; then take one step a random distance between @mathit{-1} and 1
4415  in both @expr{x} and @expr{y}; then take another step, and so on.  Use the  in both @expr{x} and @expr{y}; then take another step, and so on.  Use the
4416  @kbd{g f} command to display this random walk.  Now modify your random  @kbd{g f} command to display this random walk.  Now modify your random
4417  walk to walk a unit distance, but in a random direction, at each step.  walk to walk a unit distance, but in a random direction, at each step.
# Line 4497  to allow for roundoff error!)  @xref{Typ Line 4490  to allow for roundoff error!)  @xref{Typ
4490  @end smallexample  @end smallexample
4491    
4492  @noindent  @noindent
4493  The square root of @i{-9} is by default rendered in rectangular form  The square root of @mathit{-9} is by default rendered in rectangular form
4494  (@w{@expr{0 + 3i}}), but we can convert it to polar form (3 with a  (@w{@expr{0 + 3i}}), but we can convert it to polar form (3 with a
4495  phase angle of 90 degrees).  All the usual arithmetic and scientific  phase angle of 90 degrees).  All the usual arithmetic and scientific
4496  operations are defined on both types of complex numbers.  operations are defined on both types of complex numbers.
# Line 4522  algebraic entry. Line 4515  algebraic entry.
4515    
4516  @noindent  @noindent
4517  Since infinity is infinitely large, multiplying it by any finite  Since infinity is infinitely large, multiplying it by any finite
4518  number (like @i{-17}) has no effect, except that since @i{-17}  number (like @mathit{-17}) has no effect, except that since @mathit{-17}
4519  is negative, it changes a plus infinity to a minus infinity.  is negative, it changes a plus infinity to a minus infinity.
4520  (``A huge positive number, multiplied by @i{-17}, yields a huge  (``A huge positive number, multiplied by @mathit{-17}, yields a huge
4521  negative number.'')  Adding any finite number to infinity also  negative number.'')  Adding any finite number to infinity also
4522  leaves it unchanged.  Taking an absolute value gives us plus  leaves it unchanged.  Taking an absolute value gives us plus
4523  infinity again.  Finally, we add this plus infinity to the minus  infinity again.  Finally, we add this plus infinity to the minus
4524  infinity we had earlier.  If you work it out, you might expect  infinity we had earlier.  If you work it out, you might expect
4525  the answer to be @i{-72} for this.  But the 72 has been completely  the answer to be @mathit{-72} for this.  But the 72 has been completely
4526  lost next to the infinities; by the time we compute @w{@samp{inf - inf}}  lost next to the infinities; by the time we compute @w{@samp{inf - inf}}
4527  the finite difference between them, if any, is undetectable.  the finite difference between them, if any, is undetectable.
4528  So we say the result is @dfn{indeterminate}, which Calc writes  So we say the result is @dfn{indeterminate}, which Calc writes
# Line 4686  a 60% chance that the result is correct Line 4679  a 60% chance that the result is correct
4679    
4680  @cindex Torus, volume of  @cindex Torus, volume of
4681  (@bullet{}) @strong{Exercise 7.}  The volume of a torus (a donut shape) is  (@bullet{}) @strong{Exercise 7.}  The volume of a torus (a donut shape) is
4682  @texline @tmath{2 \pi^2 R r^2}  @texline @math{2 \pi^2 R r^2}
4683  @infoline @w{@expr{2 pi^2 R r^2}}  @infoline @w{@expr{2 pi^2 R r^2}}
4684  where @expr{R} is the radius of the circle that  where @expr{R} is the radius of the circle that
4685  defines the center of the tube and @expr{r} is the radius of the tube  defines the center of the tube and @expr{r} is the radius of the tube
# Line 4786  that arises in the second one. Line 4779  that arises in the second one.
4779  @cindex Fermat, primality test of  @cindex Fermat, primality test of
4780  (@bullet{}) @strong{Exercise 10.}  A theorem of Pierre de Fermat  (@bullet{}) @strong{Exercise 10.}  A theorem of Pierre de Fermat
4781  says that  says that
4782  @texline @w{@tmath{x^{n-1} \bmod n = 1}}  @texline @w{@math{x^{n-1} \bmod n = 1}}
4783  @infoline @expr{x^(n-1) mod n = 1}  @infoline @expr{x^(n-1) mod n = 1}
4784  if @expr{n} is a prime number and @expr{x} is an integer less than  if @expr{n} is a prime number and @expr{x} is an integer less than
4785  @expr{n}.  If @expr{n} is @emph{not} a prime number, this will  @expr{n}.  If @expr{n} is @emph{not} a prime number, this will
# Line 4814  This calculation tells me it is six hour Line 4807  This calculation tells me it is six hour
4807    
4808  (@bullet{}) @strong{Exercise 11.}  A rule of thumb is that one year  (@bullet{}) @strong{Exercise 11.}  A rule of thumb is that one year
4809  is about  is about
4810  @texline @tmath{\pi \times 10^7}  @texline @math{\pi \times 10^7}
4811  @infoline @w{@expr{pi * 10^7}}  @infoline @w{@expr{pi * 10^7}}
4812  seconds.  What time will it be that many seconds from right now?  seconds.  What time will it be that many seconds from right now?
4813  @xref{Types Answer 11, 11}. (@bullet{})  @xref{Types Answer 11, 11}. (@bullet{})
# Line 5121  solution by pressing @kbd{H} (the Hyperb Line 5114  solution by pressing @kbd{H} (the Hyperb
5114    
5115  @noindent  @noindent
5116  Calc has invented the variable @samp{s1} to represent an unknown sign;  Calc has invented the variable @samp{s1} to represent an unknown sign;
5117  it is supposed to be either @i{+1} or @i{-1}.  Here we have used  it is supposed to be either @mathit{+1} or @mathit{-1}.  Here we have used
5118  the ``let'' command to evaluate the expression when the sign is negative.  the ``let'' command to evaluate the expression when the sign is negative.
5119  If we plugged this into our second derivative we would get the same,  If we plugged this into our second derivative we would get the same,
5120  negative, answer, so @expr{x = -1.19023} is also a maximum.  negative, answer, so @expr{x = -1.19023} is also a maximum.
# Line 5291  One way to do it is again with vector ma Line 5284  One way to do it is again with vector ma
5284    
5285  (@bullet{}) @strong{Exercise 3.}  Find the integral from 1 to @expr{y}  (@bullet{}) @strong{Exercise 3.}  Find the integral from 1 to @expr{y}
5286  of  of
5287  @texline @tmath{x \sin \pi x}  @texline @math{x \sin \pi x}
5288  @infoline @w{@expr{x sin(pi x)}}  @infoline @w{@expr{x sin(pi x)}}
5289  (where the sine is calculated in radians).  Find the values of the  (where the sine is calculated in radians).  Find the values of the
5290  integral for integers @expr{y} from 1 to 5.  @xref{Algebra Answer 3,  integral for integers @expr{y} from 1 to 5.  @xref{Algebra Answer 3,
# Line 5300  integral for integers @expr{y} from 1 to Line 5293  integral for integers @expr{y} from 1 to
5293  Calc's integrator can do many simple integrals symbolically, but many  Calc's integrator can do many simple integrals symbolically, but many
5294  others are beyond its capabilities.  Suppose we wish to find the area  others are beyond its capabilities.  Suppose we wish to find the area
5295  under the curve  under the curve
5296  @texline @tmath{\sin x \ln x}  @texline @math{\sin x \ln x}
5297  @infoline @expr{sin(x) ln(x)}  @infoline @expr{sin(x) ln(x)}
5298  over the same range of @expr{x}.  If you entered this formula and typed  over the same range of @expr{x}.  If you entered this formula and typed
5299  @kbd{a i x @key{RET}} (don't bother to try this), Calc would work for a  @kbd{a i x @key{RET}} (don't bother to try this), Calc would work for a
# Line 5442  $$ h (f(a) + f(a+h) + f(a+2h) + f(a+3h) Line 5435  $$ h (f(a) + f(a+h) + f(a+2h) + f(a+3h)
5435  @end tex  @end tex
5436    
5437  Compute the integral from 1 to 2 of  Compute the integral from 1 to 2 of
5438  @texline @tmath{\sin x \ln x}  @texline @math{\sin x \ln x}
5439  @infoline @expr{sin(x) ln(x)}  @infoline @expr{sin(x) ln(x)}
5440  using Simpson's rule with 10 slices.    using Simpson's rule with 10 slices.  
5441  @xref{Algebra Answer 4, 4}. (@bullet{})  @xref{Algebra Answer 4, 4}. (@bullet{})
# Line 5988  in @samp{a + 1} for @samp{x} in the defi Line 5981  in @samp{a + 1} for @samp{x} in the defi
5981  @end ignore  @end ignore
5982  @tindex Si  @tindex Si
5983  (@bullet{}) @strong{Exercise 1.}  The ``sine integral'' function  (@bullet{}) @strong{Exercise 1.}  The ``sine integral'' function
5984  @texline @tmath{{\rm Si}(x)}  @texline @math{{\rm Si}(x)}
5985  @infoline @expr{Si(x)}  @infoline @expr{Si(x)}
5986  is defined as the integral of @samp{sin(t)/t} for  is defined as the integral of @samp{sin(t)/t} for
5987  @expr{t = 0} to @expr{x} in radians.  (It was invented because this  @expr{t = 0} to @expr{x} in radians.  (It was invented because this
# Line 6066  the following functions: Line 6059  the following functions:
6059  @enumerate  @enumerate
6060  @item  @item
6061  Compute  Compute
6062  @texline @tmath{\displaystyle{\sin x \over x}},  @texline @math{\displaystyle{\sin x \over x}},
6063  @infoline @expr{sin(x) / x},  @infoline @expr{sin(x) / x},
6064  where @expr{x} is the number on the top of the stack.  where @expr{x} is the number on the top of the stack.
6065    
# Line 6132  key if you have one, makes a copy of the Line 6125  key if you have one, makes a copy of the
6125  @cindex Phi, golden ratio  @cindex Phi, golden ratio
6126  A fascinating property of the Fibonacci numbers is that the @expr{n}th  A fascinating property of the Fibonacci numbers is that the @expr{n}th
6127  Fibonacci number can be found directly by computing  Fibonacci number can be found directly by computing
6128  @texline @tmath{\phi^n / \sqrt{5}}  @texline @math{\phi^n / \sqrt{5}}
6129  @infoline @expr{phi^n / sqrt(5)}  @infoline @expr{phi^n / sqrt(5)}
6130  and then rounding to the nearest integer, where  and then rounding to the nearest integer, where
6131  @texline @tmath{\phi} (``phi''),  @texline @math{\phi} (``phi''),
6132  @infoline @expr{phi},  @infoline @expr{phi},
6133  the ``golden ratio,'' is  the ``golden ratio,'' is
6134  @texline @tmath{(1 + \sqrt{5}) / 2}.  @texline @math{(1 + \sqrt{5}) / 2}.
6135  @infoline @expr{(1 + sqrt(5)) / 2}.  @infoline @expr{(1 + sqrt(5)) / 2}.
6136  (For convenience, this constant is available from the @code{phi}  (For convenience, this constant is available from the @code{phi}
6137  variable, or the @kbd{I H P} command.)  variable, or the @kbd{I H P} command.)
# Line 6155  variable, or the @kbd{I H P} command.) Line 6148  variable, or the @kbd{I H P} command.)
6148  @cindex Continued fractions  @cindex Continued fractions
6149  (@bullet{}) @strong{Exercise 5.}  The @dfn{continued fraction}  (@bullet{}) @strong{Exercise 5.}  The @dfn{continued fraction}
6150  representation of  representation of
6151  @texline @tmath{\phi}  @texline @math{\phi}
6152  @infoline @expr{phi}  @infoline @expr{phi}
6153  is  is
6154  @texline @tmath{1 + 1/(1 + 1/(1 + 1/( \ldots )))}.  @texline @math{1 + 1/(1 + 1/(1 + 1/( \ldots )))}.
6155  @infoline @expr{1 + 1/(1 + 1/(1 + 1/( ...@: )))}.  @infoline @expr{1 + 1/(1 + 1/(1 + 1/( ...@: )))}.
6156  We can compute an approximate value by carrying this however far  We can compute an approximate value by carrying this however far
6157  and then replacing the innermost  and then replacing the innermost
6158  @texline @tmath{1/( \ldots )}  @texline @math{1/( \ldots )}
6159  @infoline @expr{1/( ...@: )}  @infoline @expr{1/( ...@: )}
6160  by 1.  Approximate  by 1.  Approximate
6161  @texline @tmath{\phi}  @texline @math{\phi}
6162  @infoline @expr{phi}  @infoline @expr{phi}
6163  using a twenty-term continued fraction.  using a twenty-term continued fraction.
6164  @xref{Programming Answer 5, 5}. (@bullet{})  @xref{Programming Answer 5, 5}. (@bullet{})
# Line 6265  The @dfn{Bernoulli numbers} are a sequen Line 6258  The @dfn{Bernoulli numbers} are a sequen
6258  property that all of the odd Bernoulli numbers are zero, and the  property that all of the odd Bernoulli numbers are zero, and the
6259  even ones, while difficult to compute, can be roughly approximated  even ones, while difficult to compute, can be roughly approximated
6260  by the formula  by the formula
6261  @texline @tmath{\displaystyle{2 n! \over (2 \pi)^n}}.  @texline @math{\displaystyle{2 n! \over (2 \pi)^n}}.
6262  @infoline @expr{2 n!@: / (2 pi)^n}.    @infoline @expr{2 n!@: / (2 pi)^n}.  
6263  Let's write a keyboard macro to compute (approximate) Bernoulli numbers.  Let's write a keyboard macro to compute (approximate) Bernoulli numbers.
6264  (Calc has a command, @kbd{k b}, to compute exact Bernoulli numbers, but  (Calc has a command, @kbd{k b}, to compute exact Bernoulli numbers, but
# Line 6439  $$ x_{\rm new} = x - {f(x) \over f'(x)} Line 6432  $$ x_{\rm new} = x - {f(x) \over f'(x)}
6432  @noindent  @noindent
6433  where @expr{f'(x)} is the derivative of @expr{f}.  The @expr{x}  where @expr{f'(x)} is the derivative of @expr{f}.  The @expr{x}
6434  values will quickly converge to a solution, i.e., eventually  values will quickly converge to a solution, i.e., eventually
6435  @texline @tmath{x_{\rm new}}  @texline @math{x_{\rm new}}
6436  @infoline @expr{new_x}  @infoline @expr{new_x}
6437  and @expr{x} will be equal to within the limits  and @expr{x} will be equal to within the limits
6438  of the current precision.  Write a program which takes a formula  of the current precision.  Write a program which takes a formula
6439  involving the variable @expr{x}, and an initial guess @expr{x_0},  involving the variable @expr{x}, and an initial guess @expr{x_0},
6440  on the stack, and produces a value of @expr{x} for which the formula  on the stack, and produces a value of @expr{x} for which the formula
6441  is zero.  Use it to find a solution of  is zero.  Use it to find a solution of
6442  @texline @tmath{\sin(\cos x) = 0.5}  @texline @math{\sin(\cos x) = 0.5}
6443  @infoline @expr{sin(cos(x)) = 0.5}  @infoline @expr{sin(cos(x)) = 0.5}
6444  near @expr{x = 4.5}.  (Use angles measured in radians.)  Note that  near @expr{x = 4.5}.  (Use angles measured in radians.)  Note that
6445  the built-in @w{@kbd{a R}} (@code{calc-find-root}) command uses Newton's  the built-in @w{@kbd{a R}} (@code{calc-find-root}) command uses Newton's
# Line 6456  method when it is able.  @xref{Programmi Line 6449  method when it is able.  @xref{Programmi
6449  @cindex Gamma constant, Euler's  @cindex Gamma constant, Euler's
6450  @cindex Euler's gamma constant  @cindex Euler's gamma constant
6451  (@bullet{}) @strong{Exercise 9.}  The @dfn{digamma} function  (@bullet{}) @strong{Exercise 9.}  The @dfn{digamma} function
6452  @texline @tmath{\psi(z) (``psi'')}  @texline @math{\psi(z) (``psi'')}
6453  @infoline @expr{psi(z)}  @infoline @expr{psi(z)}
6454  is defined as the derivative of  is defined as the derivative of
6455  @texline @tmath{\ln \Gamma(z)}.  @texline @math{\ln \Gamma(z)}.
6456  @infoline @expr{ln(gamma(z))}.    @infoline @expr{ln(gamma(z))}.  
6457  For large values of @expr{z}, it can be approximated by the infinite sum  For large values of @expr{z}, it can be approximated by the infinite sum
6458    
# Line 6478  $$ Line 6471  $$
6471    
6472  @noindent  @noindent
6473  where  where
6474  @texline @tmath{\sum}  @texline @math{\sum}
6475  @infoline @expr{sum}  @infoline @expr{sum}
6476  represents the sum over @expr{n} from 1 to infinity  represents the sum over @expr{n} from 1 to infinity
6477  (or to some limit high enough to give the desired accuracy), and  (or to some limit high enough to give the desired accuracy), and
# Line 6486  the @code{bern} function produces (exact Line 6479  the @code{bern} function produces (exact
6479  While this sum is not guaranteed to converge, in practice it is safe.  While this sum is not guaranteed to converge, in practice it is safe.
6480  An interesting mathematical constant is Euler's gamma, which is equal  An interesting mathematical constant is Euler's gamma, which is equal
6481  to about 0.5772.  One way to compute it is by the formula,  to about 0.5772.  One way to compute it is by the formula,
6482  @texline @tmath{\gamma = -\psi(1)}.  @texline @math{\gamma = -\psi(1)}.
6483  @infoline @expr{gamma = -psi(1)}.    @infoline @expr{gamma = -psi(1)}.  
6484  Unfortunately, 1 isn't a large enough argument  Unfortunately, 1 isn't a large enough argument
6485  for the above formula to work (5 is a much safer value for @expr{z}).  for the above formula to work (5 is a much safer value for @expr{z}).
6486  Fortunately, we can compute  Fortunately, we can compute
6487  @texline @tmath{\psi(1)}  @texline @math{\psi(1)}
6488  @infoline @expr{psi(1)}  @infoline @expr{psi(1)}
6489  from  from
6490  @texline @tmath{\psi(5)}  @texline @math{\psi(5)}
6491  @infoline @expr{psi(5)}  @infoline @expr{psi(5)}
6492  using the recurrence  using the recurrence
6493  @texline @tmath{\psi(z+1) = \psi(z) + {1 \over z}}.  @texline @math{\psi(z+1) = \psi(z) + {1 \over z}}.
6494  @infoline @expr{psi(z+1) = psi(z) + 1/z}.    @infoline @expr{psi(z+1) = psi(z) + 1/z}.  
6495  Your task:  Develop a program to compute  Your task:  Develop a program to compute
6496  @texline @tmath{\psi(z)};  @texline @math{\psi(z)};
6497  @infoline @expr{psi(z)};  @infoline @expr{psi(z)};
6498  it should ``pump up'' @expr{z}  it should ``pump up'' @expr{z}
6499  if necessary to be greater than 5, then use the above summation  if necessary to be greater than 5, then use the above summation
6500  formula.  Use looping commands to compute the sum.  Use your function  formula.  Use looping commands to compute the sum.  Use your function
6501  to compute  to compute
6502  @texline @tmath{\gamma}  @texline @math{\gamma}
6503  @infoline @expr{gamma}  @infoline @expr{gamma}
6504  to twelve decimal places.  (Calc has a built-in command  to twelve decimal places.  (Calc has a built-in command
6505  for Euler's constant, @kbd{I P}, which you can use to check your answer.)  for Euler's constant, @kbd{I P}, which you can use to check your answer.)
# Line 6683  This section includes answers to all the Line 6676  This section includes answers to all the
6676  @kbd{1 @key{RET} 2 @key{RET} 3 @key{RET} 4 + * -}  @kbd{1 @key{RET} 2 @key{RET} 3 @key{RET} 4 + * -}
6677    
6678  The result is  The result is
6679  @texline @tmath{1 - (2 \times (3 + 4)) = -13}.  @texline @math{1 - (2 \times (3 + 4)) = -13}.
6680  @infoline @expr{1 - (2 * (3 + 4)) = -13}.  @infoline @expr{1 - (2 * (3 + 4)) = -13}.
6681    
6682  @node RPN Answer 2, RPN Answer 3, RPN Answer 1, Answers to Exercises  @node RPN Answer 2, RPN Answer 3, RPN Answer 1, Answers to Exercises
6683  @subsection RPN Tutorial Exercise 2  @subsection RPN Tutorial Exercise 2
6684    
6685  @noindent  @noindent
6686  @texline @tmath{2\times4 + 7\times9.5 + {5\over4} = 75.75}  @texline @math{2\times4 + 7\times9.5 + {5\over4} = 75.75}
6687  @infoline @expr{2*4 + 7*9.5 + 5/4 = 75.75}  @infoline @expr{2*4 + 7*9.5 + 5/4 = 75.75}
6688    
6689  After computing the intermediate term  After computing the intermediate term
6690  @texline @tmath{2\times4 = 8},  @texline @math{2\times4 = 8},
6691  @infoline @expr{2*4 = 8},  @infoline @expr{2*4 = 8},
6692  you can leave that result on the stack while you compute the second  you can leave that result on the stack while you compute the second
6693  term.  With both of these results waiting on the stack you can then  term.  With both of these results waiting on the stack you can then
# Line 7003  give a floating-point result that is ina Line 6996  give a floating-point result that is ina
6996  down to an integer.  Consider @expr{123456789 / 2} when the current  down to an integer.  Consider @expr{123456789 / 2} when the current
6997  precision is 6 digits.  The true answer is @expr{61728394.5}, but  precision is 6 digits.  The true answer is @expr{61728394.5}, but
6998  with a precision of 6 this will be rounded to  with a precision of 6 this will be rounded to
6999  @texline @tmath{12345700.0/2.0 = 61728500.0}.  @texline @math{12345700.0/2.0 = 61728500.0}.
7000  @infoline @expr{12345700.@: / 2.@: = 61728500.}.  @infoline @expr{12345700.@: / 2.@: = 61728500.}.
7001  The result, when converted to an integer, will be off by 106.  The result, when converted to an integer, will be off by 106.
7002    
# Line 7114  Type @kbd{d N} to return to ``normal'' d Line 7107  Type @kbd{d N} to return to ``normal'' d
7107    
7108  @noindent  @noindent
7109  To solve  To solve
7110  @texline @tmath{A^T A \, X = A^T B},  @texline @math{A^T A \, X = A^T B},
7111  @infoline @expr{trn(A) * A * X = trn(A) * B},  @infoline @expr{trn(A) * A * X = trn(A) * B},
7112  first we compute  first we compute
7113  @texline @tmath{A' = A^T A}  @texline @math{A' = A^T A}
7114  @infoline @expr{A2 = trn(A) * A}  @infoline @expr{A2 = trn(A) * A}
7115  and  and
7116  @texline @tmath{B' = A^T B};  @texline @math{B' = A^T B};
7117  @infoline @expr{B2 = trn(A) * B};  @infoline @expr{B2 = trn(A) * B};
7118  now, we have a system  now, we have a system
7119  @texline @tmath{A' X = B'}  @texline @math{A' X = B'}
7120  @infoline @expr{A2 * X = B2}  @infoline @expr{A2 * X = B2}
7121  which we can solve using Calc's @samp{/} command.  which we can solve using Calc's @samp{/} command.
7122    
# Line 7155  $$ Line 7148  $$
7148    
7149  The first step is to enter the coefficient matrix.  We'll store it in  The first step is to enter the coefficient matrix.  We'll store it in
7150  quick variable number 7 for later reference.  Next, we compute the  quick variable number 7 for later reference.  Next, we compute the
7151  @texline @tmath{B'}  @texline @math{B'}
7152  @infoline @expr{B2}  @infoline @expr{B2}
7153  vector.  vector.
7154    
# Line 7173  vector. Line 7166  vector.
7166    
7167  @noindent  @noindent
7168  Now we compute the matrix  Now we compute the matrix
7169  @texline @tmath{A'}  @texline @math{A'}
7170  @infoline @expr{A2}  @infoline @expr{A2}
7171  and divide.  and divide.
7172    
# Line 7194  and divide. Line 7187  and divide.
7187  round-off error.)  round-off error.)
7188    
7189  Notice that the answers are similar to those for the  Notice that the answers are similar to those for the
7190  @texline @tmath{3\times3}  @texline @math{3\times3}
7191  @infoline 3x3  @infoline 3x3
7192  system solved in the text.  That's because the fourth equation that was  system solved in the text.  That's because the fourth equation that was
7193  added to the system is almost identical to the first one multiplied  added to the system is almost identical to the first one multiplied
7194  by two.  (If it were identical, we would have gotten the exact same  by two.  (If it were identical, we would have gotten the exact same
7195  answer since the  answer since the
7196  @texline @tmath{4\times3}  @texline @math{4\times3}
7197  @infoline 4x3  @infoline 4x3
7198  system would be equivalent to the original  system would be equivalent to the original
7199  @texline @tmath{3\times3}  @texline @math{3\times3}
7200  @infoline 3x3  @infoline 3x3
7201  system.)  system.)
7202    
# Line 7280  $$ m \times x + b \times 1 = y $$ Line 7273  $$ m \times x + b \times 1 = y $$
7273  @end tex  @end tex
7274    
7275  Thus we want a  Thus we want a
7276  @texline @tmath{19\times2}  @texline @math{19\times2}
7277  @infoline 19x2  @infoline 19x2
7278  matrix with our @expr{x} vector as one column and  matrix with our @expr{x} vector as one column and
7279  ones as the other column.  So, first we build the column of ones, then  ones as the other column.  So, first we build the column of ones, then
# Line 7299  we combine the two columns to form our @ Line 7292  we combine the two columns to form our @
7292    
7293  @noindent  @noindent
7294  Now we compute  Now we compute
7295  @texline @tmath{A^T y}  @texline @math{A^T y}
7296  @infoline @expr{trn(A) * y}  @infoline @expr{trn(A) * y}
7297  and  and
7298  @texline @tmath{A^T A}  @texline @math{A^T A}
7299  @infoline @expr{trn(A) * A}  @infoline @expr{trn(A) * A}
7300  and divide.  and divide.
7301    
# Line 7330  and divide. Line 7323  and divide.
7323  @end smallexample  @end smallexample
7324    
7325  Since we were solving equations of the form  Since we were solving equations of the form
7326  @texline @tmath{m \times x + b \times 1 = y},  @texline @math{m \times x + b \times 1 = y},
7327  @infoline @expr{m*x + b*1 = y},  @infoline @expr{m*x + b*1 = y},
7328  these numbers should be @expr{m} and @expr{b}, respectively.  Sure  these numbers should be @expr{m} and @expr{b}, respectively.  Sure
7329  enough, they agree exactly with the result computed using @kbd{V M} and  enough, they agree exactly with the result computed using @kbd{V M} and
# Line 7393  then raise the number to that power.) Line 7386  then raise the number to that power.)
7386    
7387  @noindent  @noindent
7388  A number @expr{j} is a divisor of @expr{n} if  A number @expr{j} is a divisor of @expr{n} if
7389  @texline @tmath{n \mathbin{\hbox{\code{\%}}} j = 0}.  @texline @math{n \mathbin{\hbox{\code{\%}}} j = 0}.
7390  @infoline @samp{n % j = 0}.    @infoline @samp{n % j = 0}.  
7391  The first step is to get a vector that identifies the divisors.  The first step is to get a vector that identifies the divisors.
7392    
# Line 7464  zero, so adding zeros on the left and ri Line 7457  zero, so adding zeros on the left and ri
7457  the job is pretty straightforward.  the job is pretty straightforward.
7458    
7459  Incidentally, Calc provides the  Incidentally, Calc provides the
7460  @texline @dfn{M@"obius} @tmath{\mu}  @texline @dfn{M@"obius} @math{\mu}
7461  @infoline @dfn{Moebius mu}  @infoline @dfn{Moebius mu}
7462  function which is zero if and only if its argument is square-free.  It  function which is zero if and only if its argument is square-free.  It
7463  would be a much more convenient way to do the above test in practice.  would be a much more convenient way to do the above test in practice.
# Line 7498  The numbers down the lefthand edge of th Line 7491  The numbers down the lefthand edge of th
7491  the ``triangular numbers'' (now you know why!).  The @expr{n}th  the ``triangular numbers'' (now you know why!).  The @expr{n}th
7492  triangular number is the sum of the integers from 1 to @expr{n}, and  triangular number is the sum of the integers from 1 to @expr{n}, and
7493  can be computed directly by the formula  can be computed directly by the formula
7494  @texline @tmath{n (n+1) \over 2}.  @texline @math{n (n+1) \over 2}.
7495  @infoline @expr{n * (n+1) / 2}.  @infoline @expr{n * (n+1) / 2}.
7496    
7497  @smallexample  @smallexample
# Line 7594  A way to isolate the maximum value is to Line 7587  A way to isolate the maximum value is to
7587  @noindent  @noindent
7588  It's a good idea to verify, as in the last step above, that only  It's a good idea to verify, as in the last step above, that only
7589  one value is equal to the maximum.  (After all, a plot of  one value is equal to the maximum.  (After all, a plot of
7590  @texline @tmath{\sin x}  @texline @math{\sin x}
7591  @infoline @expr{sin(x)}  @infoline @expr{sin(x)}
7592  might have many points all equal to the maximum value, 1.)  might have many points all equal to the maximum value, 1.)
7593    
# Line 7866  This problem can be made a lot easier by Line 7859  This problem can be made a lot easier by
7859  symmetries.  First of all, after some thought it's clear that the  symmetries.  First of all, after some thought it's clear that the
7860  @expr{y} axis can be ignored altogether.  Just pick a random @expr{x}  @expr{y} axis can be ignored altogether.  Just pick a random @expr{x}
7861  component for one end of the match, pick a random direction  component for one end of the match, pick a random direction
7862  @texline @tmath{\theta},  @texline @math{\theta},
7863  @infoline @expr{theta},  @infoline @expr{theta},
7864  and see if @expr{x} and  and see if @expr{x} and
7865  @texline @tmath{x + \cos \theta}  @texline @math{x + \cos \theta}
7866  @infoline @expr{x + cos(theta)}  @infoline @expr{x + cos(theta)}
7867  (which is the @expr{x} coordinate of the other endpoint) cross a line.  (which is the @expr{x} coordinate of the other endpoint) cross a line.
7868  The lines are at integer coordinates, so this happens when the two  The lines are at integer coordinates, so this happens when the two
# Line 7886  coordinates 0 and 1 for the lines on eit Line 7879  coordinates 0 and 1 for the lines on eit
7879  endpoint.  The rightmost endpoint will be between 0 and 1 if the  endpoint.  The rightmost endpoint will be between 0 and 1 if the
7880  match does not cross a line, or between 1 and 2 if it does.  So:  match does not cross a line, or between 1 and 2 if it does.  So:
7881  Pick random @expr{x} and  Pick random @expr{x} and
7882  @texline @tmath{\theta},  @texline @math{\theta},
7883  @infoline @expr{theta},  @infoline @expr{theta},
7884  compute  compute
7885  @texline @tmath{x + \cos \theta},  @texline @math{x + \cos \theta},
7886  @infoline @expr{x + cos(theta)},  @infoline @expr{x + cos(theta)},
7887  and count how many of the results are greater than one.  Simple!  and count how many of the results are greater than one.  Simple!
7888    
# Line 8214  precision slightly and try again: Line 8207  precision slightly and try again:
8207  @noindent  @noindent
8208  Aha!  It's unlikely that an irrational number would equal a fraction  Aha!  It's unlikely that an irrational number would equal a fraction
8209  this simple to within ten digits, so our original number was probably  this simple to within ten digits, so our original number was probably
8210  @texline @tmath{\sqrt{27 \pi / 53}}.  @texline @math{\sqrt{27 \pi / 53}}.
8211  @infoline @expr{sqrt(27 pi / 53)}.  @infoline @expr{sqrt(27 pi / 53)}.
8212    
8213  Notice that we didn't need to re-round the number when we reduced the  Notice that we didn't need to re-round the number when we reduced the
# Line 8475  as a possible value. Line 8468  as a possible value.
8468  The fourth calculation, @samp{1 / (-10 .. 10)}, has the same problem.  The fourth calculation, @samp{1 / (-10 .. 10)}, has the same problem.
8469  Zero is buried inside the interval, but it's still a possible value.  Zero is buried inside the interval, but it's still a possible value.
8470  It's not hard to see that the actual result of @samp{1 / (-10 .. 10)}  It's not hard to see that the actual result of @samp{1 / (-10 .. 10)}
8471  will be either greater than @i{0.1}, or less than @i{-0.1}.  Thus  will be either greater than @mathit{0.1}, or less than @mathit{-0.1}.  Thus
8472  the interval goes from minus infinity to plus infinity, with a ``hole''  the interval goes from minus infinity to plus infinity, with a ``hole''
8473  in it from @i{-0.1} to @i{0.1}.  Calc doesn't have any way to  in it from @mathit{-0.1} to @mathit{0.1}.  Calc doesn't have any way to
8474  represent this, so it just reports @samp{[-inf .. inf]} as the answer.  represent this, so it just reports @samp{[-inf .. inf]} as the answer.
8475  It may be disappointing to hear ``the answer lies somewhere between  It may be disappointing to hear ``the answer lies somewhere between
8476  minus infinity and plus infinity, inclusive,'' but that's the best  minus infinity and plus infinity, inclusive,'' but that's the best
# Line 8497  that interval arithmetic can do in this Line 8490  that interval arithmetic can do in this
8490  @end smallexample  @end smallexample
8491    
8492  @noindent  @noindent
8493  In the first case the result says, ``if a number is between @i{-3} and  In the first case the result says, ``if a number is between @mathit{-3} and
8494  3, its square is between 0 and 9.''  The second case says, ``the product  3, its square is between 0 and 9.''  The second case says, ``the product
8495  of two numbers each between @i{-3} and 3 is between @i{-9} and 9.''  of two numbers each between @mathit{-3} and 3 is between @mathit{-9} and 9.''
8496    
8497  An interval form is not a number; it is a symbol that can stand for  An interval form is not a number; it is a symbol that can stand for
8498  many different numbers.  Two identical-looking interval forms can stand  many different numbers.  Two identical-looking interval forms can stand
# Line 9255  algebraic entry, whichever way you prefe Line 9248  algebraic entry, whichever way you prefe
9248    
9249  @noindent  @noindent
9250  Computing  Computing
9251  @texline @tmath{\displaystyle{\sin x \over x}}:  @texline @math{\displaystyle{\sin x \over x}}:
9252  @infoline @expr{sin(x) / x}:  @infoline @expr{sin(x) / x}:
9253    
9254  Using the stack:  @kbd{C-x (  @key{RET} S @key{TAB} /  C-x )}.  Using the stack:  @kbd{C-x (  @key{RET} S @key{TAB} /  C-x )}.
# Line 9326  C-x ( ' [0, 1; 1, 1] ^ ($-1) * [1, 1] @k Line 9319  C-x ( ' [0, 1; 1, 1] ^ ($-1) * [1, 1] @k
9319  @noindent  @noindent
9320  This program is quite efficient because Calc knows how to raise a  This program is quite efficient because Calc knows how to raise a
9321  matrix (or other value) to the power @expr{n} in only  matrix (or other value) to the power @expr{n} in only
9322  @texline @tmath{\log_2 n}  @texline @math{\log_2 n}
9323  @infoline @expr{log(n,2)}  @infoline @expr{log(n,2)}
9324  steps.  For example, this program can compute the 1000th Fibonacci  steps.  For example, this program can compute the 1000th Fibonacci
9325  number (a 209-digit integer!) in about 10 steps; even though the  number (a 209-digit integer!) in about 10 steps; even though the
# Line 9380  harmonic number is 4.02. Line 9373  harmonic number is 4.02.
9373  @noindent  @noindent
9374  The first step is to compute the derivative @expr{f'(x)} and thus  The first step is to compute the derivative @expr{f'(x)} and thus
9375  the formula  the formula
9376  @texline @tmath{\displaystyle{x - {f(x) \over f'(x)}}}.  @texline @math{\displaystyle{x - {f(x) \over f'(x)}}}.
9377  @infoline @expr{x - f(x)/f'(x)}.  @infoline @expr{x - f(x)/f'(x)}.
9378    
9379  (Because this definition is long, it will be repeated in concise form  (Because this definition is long, it will be repeated in concise form
# Line 9497  method (among others) to look for numeri Line 9490  method (among others) to look for numeri
9490  The first step is to adjust @expr{z} to be greater than 5.  A simple  The first step is to adjust @expr{z} to be greater than 5.  A simple
9491  ``for'' loop will do the job here.  If @expr{z} is less than 5, we  ``for'' loop will do the job here.  If @expr{z} is less than 5, we
9492  reduce the problem using  reduce the problem using
9493  @texline @tmath{\psi(z) = \psi(z+1) - 1/z}.  @texline @math{\psi(z) = \psi(z+1) - 1/z}.
9494  @infoline @expr{psi(z) = psi(z+1) - 1/z}.  We go  @infoline @expr{psi(z) = psi(z+1) - 1/z}.  We go
9495  on to compute  on to compute
9496  @texline @tmath{\psi(z+1)},  @texline @math{\psi(z+1)},
9497  @infoline @expr{psi(z+1)},  @infoline @expr{psi(z+1)},
9498  and remember to add back a factor of @expr{-1/z} when we're done.  This  and remember to add back a factor of @expr{-1/z} when we're done.  This
9499  step is repeated until @expr{z > 5}.  step is repeated until @expr{z > 5}.
# Line 9541  are exactly equal, not just equal to wit Line 9534  are exactly equal, not just equal to wit
9534  @end smallexample  @end smallexample
9535    
9536  Now we compute the initial part of the sum:    Now we compute the initial part of the sum:  
9537  @texline @tmath{\ln z - {1 \over 2z}}  @texline @math{\ln z - {1 \over 2z}}
9538  @infoline @expr{ln(z) - 1/2z}  @infoline @expr{ln(z) - 1/2z}
9539  minus the adjustment factor.  minus the adjustment factor.
9540    
# Line 9584  up the value of @expr{2 n}.  (Calc does Line 9577  up the value of @expr{2 n}.  (Calc does
9577  @end smallexample  @end smallexample
9578    
9579  This is the value of  This is the value of
9580  @texline @tmath{-\gamma},  @texline @math{-\gamma},
9581  @infoline @expr{- gamma},  @infoline @expr{- gamma},
9582  with a slight bit of roundoff error.  To get a full 12 digits, let's use  with a slight bit of roundoff error.  To get a full 12 digits, let's use
9583  a higher precision:  a higher precision:
# Line 9619  C-x ) Line 9612  C-x )
9612  @noindent  @noindent
9613  Taking the derivative of a term of the form @expr{x^n} will produce  Taking the derivative of a term of the form @expr{x^n} will produce
9614  a term like  a term like
9615  @texline @tmath{n x^{n-1}}.  @texline @math{n x^{n-1}}.
9616  @infoline @expr{n x^(n-1)}.    @infoline @expr{n x^(n-1)}.  
9617  Taking the derivative of a constant  Taking the derivative of a constant
9618  produces zero.  From this it is easy to see that the @expr{n}th  produces zero.  From this it is easy to see that the @expr{n}th
# Line 10193  The first three keystrokes ``push'' the Line 10186  The first three keystrokes ``push'' the
10186  @kbd{+} key always ``pops'' the top two numbers from the stack, adds them,  @kbd{+} key always ``pops'' the top two numbers from the stack, adds them,
10187  and pushes the result (3) back onto the stack.  This number is ready for  and pushes the result (3) back onto the stack.  This number is ready for
10188  further calculations:  @kbd{5 -} pushes 5 onto the stack, then pops the  further calculations:  @kbd{5 -} pushes 5 onto the stack, then pops the
10189  3 and 5, subtracts them, and pushes the result (@i{-2}).  3 and 5, subtracts them, and pushes the result (@mathit{-2}).
10190    
10191  Note that the ``top'' of the stack actually appears at the @emph{bottom}  Note that the ``top'' of the stack actually appears at the @emph{bottom}
10192  of the buffer.  A line containing a single @samp{.} character signifies  of the buffer.  A line containing a single @samp{.} character signifies
# Line 10256  the two numbers on the top of the stack. Line 10249  the two numbers on the top of the stack.
10249  of the number on the top of the stack or the number currently being entered.  of the number on the top of the stack or the number currently being entered.
10250  The @kbd{_} key begins entry of a negative number or changes the sign of  The @kbd{_} key begins entry of a negative number or changes the sign of
10251  the number currently being entered.  The following sequences all enter the  the number currently being entered.  The following sequences all enter the
10252  number @i{-5} onto the stack:  @kbd{0 @key{RET} 5 -}, @kbd{5 n @key{RET}},  number @mathit{-5} onto the stack:  @kbd{0 @key{RET} 5 -}, @kbd{5 n @key{RET}},
10253  @kbd{5 @key{RET} n}, @kbd{_ 5 @key{RET}}, @kbd{5 _ @key{RET}}.  @kbd{5 @key{RET} n}, @kbd{_ 5 @key{RET}}, @kbd{5 _ @key{RET}}.
10254    
10255  Some other keys are active during numeric entry, such as @kbd{#} for  Some other keys are active during numeric entry, such as @kbd{#} for
# Line 10277  During numeric entry, the only editing k Line 10270  During numeric entry, the only editing k
10270  Calculations can also be entered in algebraic form.  This is accomplished  Calculations can also be entered in algebraic form.  This is accomplished
10271  by typing the apostrophe key, @kbd{'}, followed by the expression in  by typing the apostrophe key, @kbd{'}, followed by the expression in
10272  standard format:  @kbd{@key{'} 2+3*4 @key{RET}} computes  standard format:  @kbd{@key{'} 2+3*4 @key{RET}} computes
10273  @texline @tmath{2+(3\times4) = 14}  @texline @math{2+(3\times4) = 14}
10274  @infoline @expr{2+(3*4) = 14}  @infoline @expr{2+(3*4) = 14}
10275  and pushes that on the stack.  If you wish you can  and pushes that on the stack.  If you wish you can
10276  ignore the RPN aspect of Calc altogether and simply enter algebraic  ignore the RPN aspect of Calc altogether and simply enter algebraic
# Line 10687  approximation.  This value will not need Line 10680  approximation.  This value will not need
10680  unless you raise the precision still further.  Many operations such as  unless you raise the precision still further.  Many operations such as
10681  logarithms and sines make use of similarly cached values such as  logarithms and sines make use of similarly cached values such as
10682  @cpiover{4} and  @cpiover{4} and
10683  @texline @tmath{\ln 2}.  @texline @math{\ln 2}.
10684  @infoline @expr{ln(2)}.    @infoline @expr{ln(2)}.  
10685  The visible effect of caching is that  The visible effect of caching is that
10686  high-precision computations may seem to do extra work the first time.  high-precision computations may seem to do extra work the first time.
# Line 10846  A floating-point number or @dfn{float} i Line 10839  A floating-point number or @dfn{float} i
10839  notation.  The number of significant digits in the fractional part is  notation.  The number of significant digits in the fractional part is
10840  governed by the current floating precision (@pxref{Precision}).  The  governed by the current floating precision (@pxref{Precision}).  The
10841  range of acceptable values is from  range of acceptable values is from
10842  @texline @tmath{10^{-3999999}}  @texline @math{10^{-3999999}}
10843  @infoline @expr{10^-3999999}  @infoline @expr{10^-3999999}
10844  (inclusive) to  (inclusive) to
10845  @texline @tmath{10^{4000000}}  @texline @math{10^{4000000}}
10846  @infoline @expr{10^4000000}  @infoline @expr{10^4000000}
10847  (exclusive), plus the corresponding negative values and zero.  (exclusive), plus the corresponding negative values and zero.
10848    
# Line 10921  Rectangular complex numbers can also be Line 10914  Rectangular complex numbers can also be
10914  notation; @pxref{Complex Formats}.  notation; @pxref{Complex Formats}.
10915    
10916  Polar complex numbers are displayed in the form  Polar complex numbers are displayed in the form
10917  @texline `@t{(}@var{r}@t{;}@tmath{\theta}@t{)}'  @texline `@t{(}@var{r}@t{;}@math{\theta}@t{)}'
10918  @infoline `@t{(}@var{r}@t{;}@var{theta}@t{)}'  @infoline `@t{(}@var{r}@t{;}@var{theta}@t{)}'
10919  where @var{r} is the nonnegative magnitude and  where @var{r} is the nonnegative magnitude and
10920  @texline @tmath{\theta}  @texline @math{\theta}
10921  @infoline @var{theta}  @infoline @var{theta}
10922  is the argument or phase angle.  The range of  is the argument or phase angle.  The range of
10923  @texline @tmath{\theta}  @texline @math{\theta}
10924  @infoline @var{theta}  @infoline @var{theta}
10925  depends on the current angular mode (@pxref{Angular Modes}); it is  depends on the current angular mode (@pxref{Angular Modes}); it is
10926  generally between @i{-180} and @i{+180} degrees or the equivalent range  generally between @mathit{-180} and @mathit{+180} degrees or the equivalent range
10927  in radians.  in radians.
10928    
10929  Complex numbers are entered in stages using incomplete objects.  Complex numbers are entered in stages using incomplete objects.
# Line 10973  larger, becomes arbitrarily close to zer Line 10966  larger, becomes arbitrarily close to zer
10966  that if @expr{x} got ``all the way to infinity,'' then @expr{1 / x}  that if @expr{x} got ``all the way to infinity,'' then @expr{1 / x}
10967  would go all the way to zero.  Similarly, when they say that  would go all the way to zero.  Similarly, when they say that
10968  @samp{exp(inf) = inf}, they mean that  @samp{exp(inf) = inf}, they mean that
10969  @texline @tmath{e^x}  @texline @math{e^x}
10970  @infoline @expr{exp(x)}  @infoline @expr{exp(x)}
10971  grows without bound as @expr{x} grows.  The symbol @samp{-inf} likewise  grows without bound as @expr{x} grows.  The symbol @samp{-inf} likewise
10972  stands for an infinitely negative real value; for example, we say that  stands for an infinitely negative real value; for example, we say that
# Line 11070  of its elements. Line 11063  of its elements.
11063  @tindex vec  @tindex vec
11064  Algebraic functions for building vectors include @samp{vec(a, b, c)}  Algebraic functions for building vectors include @samp{vec(a, b, c)}
11065  to build @samp{[a, b, c]}, @samp{cvec(a, n, m)} to build an  to build @samp{[a, b, c]}, @samp{cvec(a, n, m)} to build an
11066  @texline @tmath{n\times m}  @texline @math{n\times m}
11067  @infoline @var{n}x@var{m}  @infoline @var{n}x@var{m}
11068  matrix of @samp{a}s, and @samp{index(n)} to build a vector of integers  matrix of @samp{a}s, and @samp{index(n)} to build a vector of integers
11069  from 1 to @samp{n}.  from 1 to @samp{n}.
# Line 11201  The @var{mins} value is an integer or in Line 11194  The @var{mins} value is an integer or in
11194  The @var{secs} value is a real number between 0 (inclusive) and 60  The @var{secs} value is a real number between 0 (inclusive) and 60
11195  (exclusive).  A positive HMS form is interpreted as @var{hours} +  (exclusive).  A positive HMS form is interpreted as @var{hours} +
11196  @var{mins}/60 + @var{secs}/3600.  A negative HMS form is interpreted  @var{mins}/60 + @var{secs}/3600.  A negative HMS form is interpreted
11197  as @i{- @var{hours}} @i{-} @var{mins}/60 @i{-} @var{secs}/3600.  as @mathit{- @var{hours}} @mathit{-} @var{mins}/60 @mathit{-} @var{secs}/3600.
11198  Display format for HMS forms is quite flexible.  @xref{HMS Formats}.  Display format for HMS forms is quite flexible.  @xref{HMS Formats}.
11199    
11200  HMS forms can be added and subtracted.  When they are added to numbers,  HMS forms can be added and subtracted.  When they are added to numbers,
# Line 11295  between, say, @samp{<12:00am Mon Jan 1, Line 11288  between, say, @samp{<12:00am Mon Jan 1,
11288    
11289  Calc uses the Julian calendar for all dates before the year 1752,  Calc uses the Julian calendar for all dates before the year 1752,
11290  including dates BC when the Julian calendar technically had not  including dates BC when the Julian calendar technically had not
11291  yet been invented.  Thus the claim that day number @i{-10000} is  yet been invented.  Thus the claim that day number @mathit{-10000} is
11292  called ``August 16, 28 BC'' should be taken with a grain of salt.  called ``August 16, 28 BC'' should be taken with a grain of salt.
11293    
11294  Please note that there is no ``year 0''; the day before  Please note that there is no ``year 0''; the day before
11295  @samp{<Sat Jan 1, +1>} is @samp{<Fri Dec 31, -1>}.  These are  @samp{<Sat Jan 1, +1>} is @samp{<Fri Dec 31, -1>}.  These are
11296  days 0 and @i{-1} respectively in Calc's internal numbering scheme.  days 0 and @mathit{-1} respectively in Calc's internal numbering scheme.
11297    
11298  @cindex Julian day counting  @cindex Julian day counting
11299  Another day counting system in common use is, confusingly, also  Another day counting system in common use is, confusingly, also
# Line 11308  called ``Julian.''  It was invented in 1 Line 11301  called ``Julian.''  It was invented in 1
11301  Scaliger, who named it in honor of his father Julius Caesar  Scaliger, who named it in honor of his father Julius Caesar
11302  Scaliger.  For obscure reasons he chose to start his day  Scaliger.  For obscure reasons he chose to start his day
11303  numbering on Jan 1, 4713 BC at noon, which in Calc's scheme  numbering on Jan 1, 4713 BC at noon, which in Calc's scheme
11304  is @i{-1721423.5} (recall that Calc starts at midnight instead  is @mathit{-1721423.5} (recall that Calc starts at midnight instead
11305  of noon).  Thus to convert a Calc date code obtained by  of noon).  Thus to convert a Calc date code obtained by
11306  unpacking a date form into a Julian day number, simply add  unpacking a date form into a Julian day number, simply add
11307  1721423.5.  The Julian code for @samp{6:00am Jan 9, 1991}  1721423.5.  The Julian code for @samp{6:00am Jan 9, 1991}
# Line 11341  an integer multiple of) some value @var{ Line 11334  an integer multiple of) some value @var{
11334  often arises in number theory.  Modulo forms are written  often arises in number theory.  Modulo forms are written
11335  `@var{a} @t{mod} @var{M}',  `@var{a} @t{mod} @var{M}',
11336  where @var{a} and @var{M} are real numbers or HMS forms, and  where @var{a} and @var{M} are real numbers or HMS forms, and
11337  @texline @tmath{0 \le a < M}.  @texline @math{0 \le a < M}.
11338  @infoline @expr{0 <= a < @var{M}}.  @infoline @expr{0 <= a < @var{M}}.
11339  In many applications @expr{a} and @expr{M} will be  In many applications @expr{a} and @expr{M} will be
11340  integers but this is not required.  integers but this is not required.
# Line 11373  division is left in symbolic form.  Othe Line 11366  division is left in symbolic form.  Othe
11366  roots, are not yet supported for modulo forms.  (Note that, although  roots, are not yet supported for modulo forms.  (Note that, although
11367  @w{`@t{(}@var{a} @t{mod} @var{M}@t{)^.5}'} will compute a ``modulo square root''  @w{`@t{(}@var{a} @t{mod} @var{M}@t{)^.5}'} will compute a ``modulo square root''
11368  in the sense of reducing  in the sense of reducing
11369  @texline @tmath{\sqrt a}  @texline @math{\sqrt a}
11370  @infoline @expr{sqrt(a)}  @infoline @expr{sqrt(a)}
11371  modulo @expr{M}, this is not a useful definition from the  modulo @expr{M}, this is not a useful definition from the
11372  number-theoretical point of view.)  number-theoretical point of view.)
# Line 11423  The algebraic function @samp{makemod(a, Line 11416  The algebraic function @samp{makemod(a,
11416  @cindex Standard deviations  @cindex Standard deviations
11417  An @dfn{error form} is a number with an associated standard  An @dfn{error form} is a number with an associated standard
11418  deviation, as in @samp{2.3 +/- 0.12}.  The notation  deviation, as in @samp{2.3 +/- 0.12}.  The notation
11419  @texline `@var{x} @t{+/-} @tmath{\sigma}'  @texline `@var{x} @t{+/-} @math{\sigma}'
11420  @infoline `@var{x} @t{+/-} sigma'  @infoline `@var{x} @t{+/-} sigma'
11421  stands for an uncertain value which follows  stands for an uncertain value which follows
11422  a normal or Gaussian distribution of mean @expr{x} and standard  a normal or Gaussian distribution of mean @expr{x} and standard
11423  deviation or ``error''  deviation or ``error''
11424  @texline @tmath{\sigma}.  @texline @math{\sigma}.
11425  @infoline @expr{sigma}.  @infoline @expr{sigma}.
11426  Both the mean and the error can be either numbers or  Both the mean and the error can be either numbers or
11427  formulas.  Generally these are real numbers but the mean may also be  formulas.  Generally these are real numbers but the mean may also be
# Line 11439  regular number by the Calculator. Line 11432  regular number by the Calculator.
11432  All arithmetic and transcendental functions accept error forms as input.  All arithmetic and transcendental functions accept error forms as input.
11433  Operations on the mean-value part work just like operations on regular  Operations on the mean-value part work just like operations on regular
11434  numbers.  The error part for any function @expr{f(x)} (such as  numbers.  The error part for any function @expr{f(x)} (such as
11435  @texline @tmath{\sin x}  @texline @math{\sin x}
11436  @infoline @expr{sin(x)})  @infoline @expr{sin(x)})
11437  is defined by the error of @expr{x} times the derivative of @expr{f}  is defined by the error of @expr{x} times the derivative of @expr{f}
11438  evaluated at the mean value of @expr{x}.  For a two-argument function  evaluated at the mean value of @expr{x}.  For a two-argument function
# Line 11470  Consult a good text on error analysis fo Line 11463  Consult a good text on error analysis fo
11463  of standard deviations.  Actual errors often are neither Gaussian-distributed  of standard deviations.  Actual errors often are neither Gaussian-distributed
11464  nor uncorrelated, and the above formulas are valid only when errors  nor uncorrelated, and the above formulas are valid only when errors
11465  are small.  As an example, the error arising from  are small.  As an example, the error arising from
11466  @texline `@t{sin(}@var{x} @t{+/-} @tmath{\sigma}@t{)}'  @texline `@t{sin(}@var{x} @t{+/-} @math{\sigma}@t{)}'
11467  @infoline `@t{sin(}@var{x} @t{+/-} @var{sigma}@t{)}'  @infoline `@t{sin(}@var{x} @t{+/-} @var{sigma}@t{)}'
11468  is  is
11469  @texline `@tmath{\sigma} @t{abs(cos(}@var{x}@t{))}'.    @texline `@math{\sigma} @t{abs(cos(}@var{x}@t{))}'.  
11470  @infoline `@var{sigma} @t{abs(cos(}@var{x}@t{))}'.    @infoline `@var{sigma} @t{abs(cos(}@var{x}@t{))}'.  
11471  When @expr{x} is close to zero,  When @expr{x} is close to zero,
11472  @texline @tmath{\cos x}  @texline @math{\cos x}
11473  @infoline @expr{cos(x)}  @infoline @expr{cos(x)}
11474  is close to one so the error in the sine is close to  is close to one so the error in the sine is close to
11475  @texline @tmath{\sigma};  @texline @math{\sigma};
11476  @infoline @expr{sigma};  @infoline @expr{sigma};
11477  this makes sense, since  this makes sense, since
11478  @texline @tmath{\sin x}  @texline @math{\sin x}
11479  @infoline @expr{sin(x)}  @infoline @expr{sin(x)}
11480  is approximately @expr{x} near zero, so a given error in @expr{x} will  is approximately @expr{x} near zero, so a given error in @expr{x} will
11481  produce about the same error in the sine.  Likewise, near 90 degrees  produce about the same error in the sine.  Likewise, near 90 degrees
11482  @texline @tmath{\cos x}  @texline @math{\cos x}
11483  @infoline @expr{cos(x)}  @infoline @expr{cos(x)}
11484  is nearly zero and so the computed error is  is nearly zero and so the computed error is
11485  small:  The sine curve is nearly flat in that region, so an error in @expr{x}  small:  The sine curve is nearly flat in that region, so an error in @expr{x}
11486  has relatively little effect on the value of  has relatively little effect on the value of
11487  @texline @tmath{\sin x}.  @texline @math{\sin x}.
11488  @infoline @expr{sin(x)}.    @infoline @expr{sin(x)}.  
11489  However, consider @samp{sin(90 +/- 1000)}.  The cosine of 90 is zero, so  However, consider @samp{sin(90 +/- 1000)}.  The cosine of 90 is zero, so
11490  Calc will report zero error!  We get an obviously wrong result because  Calc will report zero error!  We get an obviously wrong result because
11491  we have violated the small-error approximation underlying the error  we have violated the small-error approximation underlying the error
11492  analysis.  If the error in @expr{x} had been small, the error in  analysis.  If the error in @expr{x} had been small, the error in
11493  @texline @tmath{\sin x}  @texline @math{\sin x}
11494  @infoline @expr{sin(x)}  @infoline @expr{sin(x)}
11495  would indeed have been negligible.  would indeed have been negligible.
11496    
# Line 11606  contain zero inside them Calc is forced Line 11599  contain zero inside them Calc is forced
11599  While it may seem that intervals and error forms are similar, they are  While it may seem that intervals and error forms are similar, they are
11600  based on entirely different concepts of inexact quantities.  An error  based on entirely different concepts of inexact quantities.  An error
11601  form  form
11602  @texline `@var{x} @t{+/-} @tmath{\sigma}'  @texline `@var{x} @t{+/-} @math{\sigma}'
11603  @infoline `@var{x} @t{+/-} @var{sigma}'  @infoline `@var{x} @t{+/-} @var{sigma}'
11604  means a variable is random, and its value could  means a variable is random, and its value could
11605  be anything but is ``probably'' within one  be anything but is ``probably'' within one
11606  @texline @tmath{\sigma}  @texline @math{\sigma}
11607  @infoline @var{sigma}  @infoline @var{sigma}
11608  of the mean value @expr{x}. An interval  of the mean value @expr{x}. An interval
11609  `@t{[}@var{a} @t{..@:} @var{b}@t{]}' means a  `@t{[}@var{a} @t{..@:} @var{b}@t{]}' means a
# Line 11844  the C-style ``if'' operator @samp{a?b:c} Line 11837  the C-style ``if'' operator @samp{a?b:c}
11837    
11838  Note that, unlike in usual computer notation, multiplication binds more  Note that, unlike in usual computer notation, multiplication binds more
11839  strongly than division:  @samp{a*b/c*d} is equivalent to  strongly than division:  @samp{a*b/c*d} is equivalent to
11840  @texline @tmath{a b \over c d}.  @texline @math{a b \over c d}.
11841  @infoline @expr{(a*b)/(c*d)}.  @infoline @expr{(a*b)/(c*d)}.
11842    
11843  @cindex Multiplication, implicit  @cindex Multiplication, implicit
# Line 12042  intervening stack elements toward the to Line 12035  intervening stack elements toward the to
12035  element at level @var{n} up to the top.  (Compare with @key{LFD},  element at level @var{n} up to the top.  (Compare with @key{LFD},
12036  which copies instead of moving the element in level @var{n}.)  which copies instead of moving the element in level @var{n}.)
12037    
12038  With a negative argument @i{-@var{n}}, @key{TAB} rotates the stack  With a negative argument @mathit{-@var{n}}, @key{TAB} rotates the stack
12039  to move the object in level @var{n} to the deepest place in the  to move the object in level @var{n} to the deepest place in the
12040  stack, and the object in level @i{@var{n}+1} to the top.  @kbd{M-@key{TAB}}  stack, and the object in level @mathit{@var{n}+1} to the top.  @kbd{M-@key{TAB}}
12041  rotates the deepest stack element to be in level @i{n}, also  rotates the deepest stack element to be in level @mathit{n}, also
12042  putting the top stack element in level @i{@var{n}+1}.  putting the top stack element in level @mathit{@var{n}+1}.
12043    
12044  @xref{Selecting Subformulas}, for a way to apply these commands to  @xref{Selecting Subformulas}, for a way to apply these commands to
12045  any portion of a vector or formula on the stack.  any portion of a vector or formula on the stack.
# Line 12341  inside it, @kbd{m F} will not automatica Line 12334  inside it, @kbd{m F} will not automatica
12334  is because you are presumably switching to your @file{~/.emacs} file,  is because you are presumably switching to your @file{~/.emacs} file,
12335  which may contain other things you don't want to reread.  You can give  which may contain other things you don't want to reread.  You can give
12336  a numeric prefix argument of 1 to @kbd{m F} to force it to read the  a numeric prefix argument of 1 to @kbd{m F} to force it to read the
12337  file no matter what its name.  Conversely, an argument of @i{-1} tells  file no matter what its name.  Conversely, an argument of @mathit{-1} tells
12338  @kbd{m F} @emph{not} to read the new file.  An argument of 2 or @i{-2}  @kbd{m F} @emph{not} to read the new file.  An argument of 2 or @mathit{-2}
12339  tells @kbd{m F} not to reset the modes to their defaults beforehand,  tells @kbd{m F} not to reset the modes to their defaults beforehand,
12340  which is useful if you intend your new file to have a variant of the  which is useful if you intend your new file to have a variant of the
12341  modes present in the file you were using before.  modes present in the file you were using before.
# Line 12447  Hyperbolic Flag, which transforms @code{ Line 12440  Hyperbolic Flag, which transforms @code{
12440  If both of these flags are set at once, the effect will be  If both of these flags are set at once, the effect will be
12441  @code{calc-arcsinh}.  (The Hyperbolic flag is also used by some  @code{calc-arcsinh}.  (The Hyperbolic flag is also used by some
12442  non-trigonometric commands; for example @kbd{H L} computes a base-10,  non-trigonometric commands; for example @kbd{H L} computes a base-10,
12443  instead of base-@i{e}, logarithm.)  instead of base-@mathit{e}, logarithm.)
12444    
12445  Command names like @code{calc-arcsin} are provided for completeness, and  Command names like @code{calc-arcsin} are provided for completeness, and
12446  may be executed with @kbd{x} or @kbd{M-x}.  Their effect is simply to  may be executed with @kbd{x} or @kbd{M-x}.  Their effect is simply to
# Line 12591  i.e., @kbd{C-u 0 m i}, turns on a ``posi Line 12584  i.e., @kbd{C-u 0 m i}, turns on a ``posi
12584  which zero is treated as positive instead of being directionless.  which zero is treated as positive instead of being directionless.
12585  Thus, @samp{1 / 0 = inf} and @samp{-1 / 0 = -inf} in this mode.  Thus, @samp{1 / 0 = inf} and @samp{-1 / 0 = -inf} in this mode.
12586  Note that zero never actually has a sign in Calc; there are no  Note that zero never actually has a sign in Calc; there are no
12587  separate representations for @i{+0} and @i{-0}.  Positive  separate representations for @mathit{+0} and @mathit{-0}.  Positive
12588  infinite mode merely changes the interpretation given to the  infinite mode merely changes the interpretation given to the
12589  single symbol, @samp{0}.  One consequence of this is that, while  single symbol, @samp{0}.  One consequence of this is that, while
12590  you might expect @samp{1 / -0 = -inf}, actually @samp{1 / -0}  you might expect @samp{1 / -0 = -inf}, actually @samp{1 / -0}
# Line 12982  Numbers.  (Real or complex.) Line 12975  Numbers.  (Real or complex.)
12975  Calc uses this information to determine when certain simplifications  Calc uses this information to determine when certain simplifications
12976  of formulas are safe.  For example, @samp{(x^y)^z} cannot be  of formulas are safe.  For example, @samp{(x^y)^z} cannot be
12977  simplified to @samp{x^(y z)} in general; for example,  simplified to @samp{x^(y z)} in general; for example,
12978  @samp{((-3)^2)^1:2} is 3, but @samp{(-3)^(2*1:2) = (-3)^1} is @i{-3}.  @samp{((-3)^2)^1:2} is 3, but @samp{(-3)^(2*1:2) = (-3)^1} is @mathit{-3}.
12979  However, this simplification @emph{is} safe if @code{z} is known  However, this simplification @emph{is} safe if @code{z} is known
12980  to be an integer, or if @code{x} is known to be a nonnegative  to be an integer, or if @code{x} is known to be a nonnegative
12981  real number.  If you have given declarations that allow Calc to  real number.  If you have given declarations that allow Calc to
# Line 13095  The value is a constant with respect to Line 13088  The value is a constant with respect to
13088  @end table  @end table
13089    
13090  Calc does not check the declarations for a variable when you store  Calc does not check the declarations for a variable when you store
13091  a value in it.  However, storing @i{-3.5} in a variable that has  a value in it.  However, storing @mathit{-3.5} in a variable that has
13092  been declared @code{pos}, @code{int}, or @code{matrix} may have  been declared @code{pos}, @code{int}, or @code{matrix} may have
13093  unexpected effects; Calc may evaluate @samp{sqrt(x^2)} to @expr{3.5}  unexpected effects; Calc may evaluate @samp{sqrt(x^2)} to @expr{3.5}
13094  if it substitutes the value first, or to @expr{-3.5} if @code{x}  if it substitutes the value first, or to @expr{-3.5} if @code{x}
# Line 13330  command causes integers to be padded out Line 13323  command causes integers to be padded out
13323  current binary word size.  (@xref{Binary Functions}, for a discussion of  current binary word size.  (@xref{Binary Functions}, for a discussion of
13324  word size.)  If the absolute value of the word size is @expr{w}, all integers  word size.)  If the absolute value of the word size is @expr{w}, all integers
13325  are displayed with at least enough digits to represent  are displayed with at least enough digits to represent
13326  @texline @tmath{2^w-1}  @texline @math{2^w-1}
13327  @infoline @expr{(2^w)-1}  @infoline @expr{(2^w)-1}
13328  in the current radix.  (Larger integers will still be displayed in their  in the current radix.  (Larger integers will still be displayed in their
13329  entirety.)  entirety.)
# Line 14231  special names (like @code{\sin}) will us Line 14224  special names (like @code{\sin}) will us
14224  parentheses for very simple arguments.  During input, curly braces and  parentheses for very simple arguments.  During input, curly braces and
14225  parentheses work equally well for grouping, but when the document is  parentheses work equally well for grouping, but when the document is
14226  formatted the curly braces will be invisible.  Thus the printed result is  formatted the curly braces will be invisible.  Thus the printed result is
14227  @texline @tmath{\sin{2 x}}  @texline @math{\sin{2 x}}
14228  @infoline @expr{sin 2x}  @infoline @expr{sin 2x}
14229  but  but
14230  @texline @tmath{\sin(2 + x)}.  @texline @math{\sin(2 + x)}.
14231  @infoline @expr{sin(2 + x)}.  @infoline @expr{sin(2 + x)}.
14232    
14233  Function and variable names not treated specially by @TeX{} are simply  Function and variable names not treated specially by @TeX{} are simply
# Line 15728  Polar mode.  Value is 0 (rectangular) or Line 15721  Polar mode.  Value is 0 (rectangular) or
15721  Command is @kbd{m p}.  Command is @kbd{m p}.
15722    
15723  @item  @item
15724  Matrix/scalar mode.  Default value is @i{-1}.  Value is 0 for scalar  Matrix/scalar mode.  Default value is @mathit{-1}.  Value is 0 for scalar
15725  mode, @i{-2} for matrix mode, or @var{N} for  mode, @mathit{-2} for matrix mode, or @var{N} for
15726  @texline @tmath{N\times N}  @texline @math{N\times N}
15727  @infoline @var{N}x@var{N}  @infoline @var{N}x@var{N}
15728  matrix mode.  Command is @kbd{m v}.  matrix mode.  Command is @kbd{m v}.
15729    
15730  @item  @item
15731  Simplification mode.  Default is 1.  Value is @i{-1} for off (@kbd{m O}),  Simplification mode.  Default is 1.  Value is @mathit{-1} for off (@kbd{m O}),
15732  0 for @kbd{m N}, 2 for @kbd{m B}, 3 for @kbd{m A}, 4 for @kbd{m E},  0 for @kbd{m N}, 2 for @kbd{m B}, 3 for @kbd{m A}, 4 for @kbd{m E},
15733  or 5 for @w{@kbd{m U}}.  The @kbd{m D} command accepts these prefixes.  or 5 for @w{@kbd{m U}}.  The @kbd{m D} command accepts these prefixes.
15734    
15735  @item  @item
15736  Infinite mode.  Default is @i{-1} (off).  Value is 1 if the mode is on,  Infinite mode.  Default is @mathit{-1} (off).  Value is 1 if the mode is on,
15737  or 0 if the mode is on with positive zeros.  Command is @kbd{m i}.  or 0 if the mode is on with positive zeros.  Command is @kbd{m i}.
15738  @end enumerate  @end enumerate
15739    
# Line 16081  infinite in different directions the res Line 16074  infinite in different directions the res
16074  @tindex -  @tindex -
16075  The @kbd{-} (@code{calc-minus}) command subtracts two values.  The top  The @kbd{-} (@code{calc-minus}) command subtracts two values.  The top
16076  number on the stack is subtracted from the one behind it, so that the  number on the stack is subtracted from the one behind it, so that the
16077  computation @kbd{5 @key{RET} 2 -} produces 3, not @i{-3}.  All options  computation @kbd{5 @key{RET} 2 -} produces 3, not @mathit{-3}.  All options
16078  available for @kbd{+} are available for @kbd{-} as well.  available for @kbd{+} are available for @kbd{-} as well.
16079    
16080  @kindex *  @kindex *
# Line 16225  absolute value squared of a number, vect Line 16218  absolute value squared of a number, vect
16218  @pindex calc-sign  @pindex calc-sign
16219  @tindex sign  @tindex sign
16220  The @kbd{f s} (@code{calc-sign}) [@code{sign}] command returns 1 if its  The @kbd{f s} (@code{calc-sign}) [@code{sign}] command returns 1 if its
16221  argument is positive, @i{-1} if its argument is negative, or 0 if its  argument is positive, @mathit{-1} if its argument is negative, or 0 if its
16222  argument is zero.  In algebraic form, you can also write @samp{sign(a,x)}  argument is zero.  In algebraic form, you can also write @samp{sign(a,x)}
16223  which evaluates to @samp{x * sign(a)}, i.e., either @samp{x}, @samp{-x}, or  which evaluates to @samp{x * sign(a)}, i.e., either @samp{x}, @samp{-x}, or
16224  zero depending on the sign of @samp{a}.  zero depending on the sign of @samp{a}.
# Line 16288  The @kbd{f M} (@code{calc-mant-part}) [@ Line 16281  The @kbd{f M} (@code{calc-mant-part}) [@
16281  the ``mantissa'' part @expr{m} of its floating-point argument; @kbd{f X}  the ``mantissa'' part @expr{m} of its floating-point argument; @kbd{f X}
16282  (@code{calc-xpon-part}) [@code{xpon}] extracts the ``exponent'' part  (@code{calc-xpon-part}) [@code{xpon}] extracts the ``exponent'' part
16283  @expr{e}.  The original number is equal to  @expr{e}.  The original number is equal to
16284  @texline @tmath{m \times 10^e},  @texline @math{m \times 10^e},
16285  @infoline @expr{m * 10^e},  @infoline @expr{m * 10^e},
16286  where @expr{m} is in the interval @samp{[1.0 ..@: 10.0)} except that  where @expr{m} is in the interval @samp{[1.0 ..@: 10.0)} except that
16287  @expr{m=e=0} if the original number is zero.  For integers  @expr{m=e=0} if the original number is zero.  For integers
# Line 16321  For example, incrementing @samp{12.3456} Line 16314  For example, incrementing @samp{12.3456}
16314  is 6 digits yields @samp{12.3457}.  If the current precision had been  is 6 digits yields @samp{12.3457}.  If the current precision had been
16315  8 digits, the result would have been @samp{12.345601}.  Incrementing  8 digits, the result would have been @samp{12.345601}.  Incrementing
16316  @samp{0.0} produces  @samp{0.0} produces
16317  @texline @tmath{10^{-p}},  @texline @math{10^{-p}},
16318  @infoline @expr{10^-p},  @infoline @expr{10^-p},
16319  where @expr{p} is the current  where @expr{p} is the current
16320  precision.  These operations are defined only on integers and floats.  precision.  These operations are defined only on integers and floats.
# Line 16362  expressed as an integer-valued floating- Line 16355  expressed as an integer-valued floating-
16355  The @kbd{F} (@code{calc-floor}) [@code{floor} or @code{ffloor}] command  The @kbd{F} (@code{calc-floor}) [@code{floor} or @code{ffloor}] command
16356  truncates a real number to the next lower integer, i.e., toward minus  truncates a real number to the next lower integer, i.e., toward minus
16357  infinity.  Thus @kbd{3.6 F} produces 3, but @kbd{_3.6 F} produces  infinity.  Thus @kbd{3.6 F} produces 3, but @kbd{_3.6 F} produces
16358  @i{-4}.  @mathit{-4}.
16359    
16360  @kindex I F  @kindex I F
16361  @pindex calc-ceiling  @pindex calc-ceiling
# Line 16374  infinity.  Thus @kbd{3.6 F} produces 3, Line 16367  infinity.  Thus @kbd{3.6 F} produces 3,
16367  @kindex H I F  @kindex H I F
16368  The @kbd{I F} (@code{calc-ceiling}) [@code{ceil} or @code{fceil}]  The @kbd{I F} (@code{calc-ceiling}) [@code{ceil} or @code{fceil}]
16369  command truncates toward positive infinity.  Thus @kbd{3.6 I F} produces  command truncates toward positive infinity.  Thus @kbd{3.6 I F} produces
16370  4, and @kbd{_3.6 I F} produces @i{-3}.  4, and @kbd{_3.6 I F} produces @mathit{-3}.
16371    
16372  @kindex R  @kindex R
16373  @pindex calc-round  @pindex calc-round
# Line 16388  The @kbd{R} (@code{calc-round}) [@code{r Line 16381  The @kbd{R} (@code{calc-round}) [@code{r
16381  rounds to the nearest integer.  When the fractional part is .5 exactly,  rounds to the nearest integer.  When the fractional part is .5 exactly,
16382  this command rounds away from zero.  (All other rounding in the  this command rounds away from zero.  (All other rounding in the
16383  Calculator uses this convention as well.)  Thus @kbd{3.5 R} produces 4  Calculator uses this convention as well.)  Thus @kbd{3.5 R} produces 4
16384  but @kbd{3.4 R} produces 3; @kbd{_3.5 R} produces @i{-4}.  but @kbd{3.4 R} produces 3; @kbd{_3.5 R} produces @mathit{-4}.
16385    
16386  @kindex I R  @kindex I R
16387  @pindex calc-trunc  @pindex calc-trunc
# Line 16401  but @kbd{3.4 R} produces 3; @kbd{_3.5 R} Line 16394  but @kbd{3.4 R} produces 3; @kbd{_3.5 R}
16394  The @kbd{I R} (@code{calc-trunc}) [@code{trunc} or @code{ftrunc}]  The @kbd{I R} (@code{calc-trunc}) [@code{trunc} or @code{ftrunc}]
16395  command truncates toward zero.  In other words, it ``chops off''  command truncates toward zero.  In other words, it ``chops off''
16396  everything after the decimal point.  Thus @kbd{3.6 I R} produces 3 and  everything after the decimal point.  Thus @kbd{3.6 I R} produces 3 and
16397  @kbd{_3.6 I R} produces @i{-3}.  @kbd{_3.6 I R} produces @mathit{-3}.
16398    
16399  These functions may not be applied meaningfully to error forms, but they  These functions may not be applied meaningfully to error forms, but they
16400  do work for intervals.  As a convenience, applying @code{floor} to a  do work for intervals.  As a convenience, applying @code{floor} to a
# Line 16479  this command replaces each element by it Line 16472  this command replaces each element by it
16472  The @kbd{G} (@code{calc-argument}) [@code{arg}] command computes the  The @kbd{G} (@code{calc-argument}) [@code{arg}] command computes the
16473  ``argument'' or polar angle of a complex number.  For a number in polar  ``argument'' or polar angle of a complex number.  For a number in polar
16474  notation, this is simply the second component of the pair  notation, this is simply the second component of the pair
16475  @texline `@t{(}@var{r}@t{;}@tmath{\theta}@t{)}'.  @texline `@t{(}@var{r}@t{;}@math{\theta}@t{)}'.
16476  @infoline `@t{(}@var{r}@t{;}@var{theta}@t{)}'.  @infoline `@t{(}@var{r}@t{;}@var{theta}@t{)}'.
16477  The result is expressed according to the current angular mode and will  The result is expressed according to the current angular mode and will
16478  be in the range @i{-180} degrees (exclusive) to @i{+180} degrees  be in the range @mathit{-180} degrees (exclusive) to @mathit{+180} degrees
16479  (inclusive), or the equivalent range in radians.  (inclusive), or the equivalent range in radians.
16480    
16481  @pindex calc-imaginary  @pindex calc-imaginary
# Line 16513  or matrix argument, these functions oper Line 16506  or matrix argument, these functions oper
16506  @pindex calc-pack  @pindex calc-pack
16507  The @kbd{v p} (@code{calc-pack}) command can pack the top two numbers on  The @kbd{v p} (@code{calc-pack}) command can pack the top two numbers on
16508  the stack into a composite object such as a complex number.  With  the stack into a composite object such as a complex number.  With
16509  a prefix argument of @i{-1}, it produces a rectangular complex number;  a prefix argument of @mathit{-1}, it produces a rectangular complex number;
16510  with an argument of @i{-2}, it produces a polar complex number.  with an argument of @mathit{-2}, it produces a polar complex number.
16511  (Also, @pxref{Building Vectors}.)  (Also, @pxref{Building Vectors}.)
16512    
16513  @ignore  @ignore
# Line 16638  already a polar complex number, it uses Line 16631  already a polar complex number, it uses
16631  The @kbd{c c} (@code{calc-clean}) [@code{pclean}] command ``cleans'' the  The @kbd{c c} (@code{calc-clean}) [@code{pclean}] command ``cleans'' the
16632  number on the top of the stack.  Floating point numbers are re-rounded  number on the top of the stack.  Floating point numbers are re-rounded
16633  according to the current precision.  Polar numbers whose angular  according to the current precision.  Polar numbers whose angular
16634  components have strayed from the @i{-180} to @i{+180} degree range  components have strayed from the @mathit{-180} to @mathit{+180} degree range
16635  are normalized.  (Note that results will be undesirable if the current  are normalized.  (Note that results will be undesirable if the current
16636  angular mode is different from the one under which the number was  angular mode is different from the one under which the number was
16637  produced!)  Integers and fractions are generally unaffected by this  produced!)  Integers and fractions are generally unaffected by this
# Line 16894  of the input date form are lost.  With a Line 16887  of the input date form are lost.  With a
16887  @var{n} in the range from 1 to 366, @kbd{t Y} computes the  @var{n} in the range from 1 to 366, @kbd{t Y} computes the
16888  @var{n}th day of the year (366 is treated as 365 in non-leap  @var{n}th day of the year (366 is treated as 365 in non-leap
16889  years).  A prefix argument of 0 computes the last day of the  years).  A prefix argument of 0 computes the last day of the
16890  year (December 31).  A negative prefix argument from @i{-1} to  year (December 31).  A negative prefix argument from @mathit{-1} to
16891  @i{-12} computes the first day of the @var{n}th month of the year.  @mathit{-12} computes the first day of the @var{n}th month of the year.
16892    
16893  @kindex t W  @kindex t W
16894  @pindex calc-new-week  @pindex calc-new-week
# Line 17264  The Lisp variable @code{math-daylight-sa Line 17257  The Lisp variable @code{math-daylight-sa
17257  name of a function that is used to compute the daylight savings  name of a function that is used to compute the daylight savings
17258  adjustment for a given date.  The default is  adjustment for a given date.  The default is
17259  @code{math-std-daylight-savings}, which computes an adjustment  @code{math-std-daylight-savings}, which computes an adjustment
17260  (either 0 or @i{-1}) using the North American rules given above.  (either 0 or @mathit{-1}) using the North American rules given above.
17261    
17262  The daylight savings hook function is called with four arguments:  The daylight savings hook function is called with four arguments:
17263  The date, as a floating-point number in standard Calc format;  The date, as a floating-point number in standard Calc format;
# Line 17312  daylight savings hook: Line 17305  daylight savings hook:
17305  @noindent  @noindent
17306  The @code{bump} parameter is equal to zero when Calc is converting  The @code{bump} parameter is equal to zero when Calc is converting
17307  from a date form in a generalized time zone into a GMT date value.  from a date form in a generalized time zone into a GMT date value.
17308  It is @i{-1} when Calc is converting in the other direction.  The  It is @mathit{-1} when Calc is converting in the other direction.  The
17309  adjustments shown above ensure that the conversion behaves correctly  adjustments shown above ensure that the conversion behaves correctly
17310  and reasonably around the 2 a.m.@: transition in each direction.  and reasonably around the 2 a.m.@: transition in each direction.
17311    
# Line 17939  particular, negative arguments are conve Line 17932  particular, negative arguments are conve
17932    
17933  If the word size is negative, binary operations produce 2's complement  If the word size is negative, binary operations produce 2's complement
17934  integers from  integers from
17935  @texline @tmath{-2^{-w-1}}  @texline @math{-2^{-w-1}}
17936  @infoline @expr{-(2^(-w-1))}  @infoline @expr{-(2^(-w-1))}
17937  to  to
17938  @texline @tmath{2^{-w-1}-1}  @texline @math{2^{-w-1}-1}
17939  @infoline @expr{2^(-w-1)-1}  @infoline @expr{2^(-w-1)-1}
17940  inclusive.  Either mode accepts inputs in any range; the sign of  inclusive.  Either mode accepts inputs in any range; the sign of
17941  @expr{w} affects only the results produced.  @expr{w} affects only the results produced.
# Line 17958  addition do not use the current word siz Line 17951  addition do not use the current word siz
17951  generally is not ``binary.''  (However, @pxref{Simplification Modes},  generally is not ``binary.''  (However, @pxref{Simplification Modes},
17952  @code{calc-bin-simplify-mode}.)  For example, with a word size of 8  @code{calc-bin-simplify-mode}.)  For example, with a word size of 8
17953  bits @kbd{b c} converts a number to the range 0 to 255; with a word  bits @kbd{b c} converts a number to the range 0 to 255; with a word
17954  size of @i{-8} @kbd{b c} converts to the range @i{-128} to 127.  size of @mathit{-8} @kbd{b c} converts to the range @mathit{-128} to 127.
17955    
17956  @kindex b w  @kindex b w
17957  @pindex calc-word-size  @pindex calc-word-size
# Line 17974  When the binary operations are written i Line 17967  When the binary operations are written i
17967  optional second (or third) word-size parameter.  When a formula like  optional second (or third) word-size parameter.  When a formula like
17968  @samp{and(a,b)} is finally evaluated, the word size current at that time  @samp{and(a,b)} is finally evaluated, the word size current at that time
17969  will be used, but when @samp{and(a,b,-8)} is evaluated, a word size of  will be used, but when @samp{and(a,b,-8)} is evaluated, a word size of
17970  @i{-8} will always be used.  A symbolic binary function will be left  @mathit{-8} will always be used.  A symbolic binary function will be left
17971  in symbolic form unless the all of its argument(s) are integers or  in symbolic form unless the all of its argument(s) are integers or
17972  integer-valued floats.  integer-valued floats.
17973    
# Line 18126  One miscellaneous command is shift-@kbd{ Line 18119  One miscellaneous command is shift-@kbd{
18119  the value of @cpi{} (at the current precision) onto the stack.  With the  the value of @cpi{} (at the current precision) onto the stack.  With the
18120  Hyperbolic flag, it pushes the value @expr{e}, the base of natural logarithms.  Hyperbolic flag, it pushes the value @expr{e}, the base of natural logarithms.
18121  With the Inverse flag, it pushes Euler's constant  With the Inverse flag, it pushes Euler's constant
18122  @texline @tmath{\gamma}  @texline @math{\gamma}
18123  @infoline @expr{gamma}  @infoline @expr{gamma}
18124  (about 0.5772).  With both Inverse and Hyperbolic, it  (about 0.5772).  With both Inverse and Hyperbolic, it
18125  pushes the ``golden ratio''  pushes the ``golden ratio''
18126  @texline @tmath{\phi}  @texline @math{\phi}
18127  @infoline @expr{phi}  @infoline @expr{phi}
18128  (about 1.618).  (At present, Euler's constant is not available  (about 1.618).  (At present, Euler's constant is not available
18129  to unlimited precision; Calc knows only the first 100 digits.)  to unlimited precision; Calc knows only the first 100 digits.)
# Line 18210  The @kbd{H L} (@code{calc-log10}) [@code Line 18203  The @kbd{H L} (@code{calc-log10}) [@code
18203  it raises ten to a given power.)  Note that the common logarithm of a  it raises ten to a given power.)  Note that the common logarithm of a
18204  complex number is computed by taking the natural logarithm and dividing  complex number is computed by taking the natural logarithm and dividing
18205  by  by
18206  @texline @tmath{\ln10}.  @texline @math{\ln10}.
18207  @infoline @expr{ln(10)}.  @infoline @expr{ln(10)}.
18208    
18209  @kindex B  @kindex B
# Line 18220  by Line 18213  by
18213  @tindex alog  @tindex alog
18214  The @kbd{B} (@code{calc-log}) [@code{log}] command computes a logarithm  The @kbd{B} (@code{calc-log}) [@code{log}] command computes a logarithm
18215  to any base.  For example, @kbd{1024 @key{RET} 2 B} produces 10, since  to any base.  For example, @kbd{1024 @key{RET} 2 B} produces 10, since
18216  @texline @tmath{2^{10} = 1024}.  @texline @math{2^{10} = 1024}.
18217  @infoline @expr{2^10 = 1024}.    @infoline @expr{2^10 = 1024}.  
18218  In certain cases like @samp{log(3,9)}, the result  In certain cases like @samp{log(3,9)}, the result
18219  will be either @expr{1:2} or @expr{0.5} depending on the current Fraction  will be either @expr{1:2} or @expr{0.5} depending on the current Fraction
# Line 18242  integer arithmetic is used; otherwise, t Line 18235  integer arithmetic is used; otherwise, t
18235  @pindex calc-expm1  @pindex calc-expm1
18236  @tindex expm1  @tindex expm1
18237  The @kbd{f E} (@code{calc-expm1}) [@code{expm1}] command computes  The @kbd{f E} (@code{calc-expm1}) [@code{expm1}] command computes
18238  @texline @tmath{e^x - 1},  @texline @math{e^x - 1},
18239  @infoline @expr{exp(x)-1},  @infoline @expr{exp(x)-1},
18240  but using an algorithm that produces a more accurate  but using an algorithm that produces a more accurate
18241  answer when the result is close to zero, i.e., when  answer when the result is close to zero, i.e., when
18242  @texline @tmath{e^x}  @texline @math{e^x}
18243  @infoline @expr{exp(x)}  @infoline @expr{exp(x)}
18244  is close to one.  is close to one.
18245    
# Line 18254  is close to one. Line 18247  is close to one.
18247  @pindex calc-lnp1  @pindex calc-lnp1
18248  @tindex lnp1  @tindex lnp1
18249  The @kbd{f L} (@code{calc-lnp1}) [@code{lnp1}] command computes  The @kbd{f L} (@code{calc-lnp1}) [@code{lnp1}] command computes
18250  @texline @tmath{\ln(x+1)},  @texline @math{\ln(x+1)},
18251  @infoline @expr{ln(x+1)},  @infoline @expr{ln(x+1)},
18252  producing a more accurate answer when @expr{x} is close to zero.  producing a more accurate answer when @expr{x} is close to zero.
18253    
# Line 18388  variants of these functions. Line 18381  variants of these functions.
18381  @tindex arctan2  @tindex arctan2
18382  The @kbd{f T} (@code{calc-arctan2}) [@code{arctan2}] command takes two  The @kbd{f T} (@code{calc-arctan2}) [@code{arctan2}] command takes two
18383  numbers from the stack and computes the arc tangent of their ratio.  The  numbers from the stack and computes the arc tangent of their ratio.  The
18384  result is in the full range from @i{-180} (exclusive) to @i{+180}  result is in the full range from @mathit{-180} (exclusive) to @mathit{+180}
18385  (inclusive) degrees, or the analogous range in radians.  A similar  (inclusive) degrees, or the analogous range in radians.  A similar
18386  result would be obtained with @kbd{/} followed by @kbd{I T}, but the  result would be obtained with @kbd{/} followed by @kbd{I T}, but the
18387  value would only be in the range from @i{-90} to @i{+90} degrees  value would only be in the range from @mathit{-90} to @mathit{+90} degrees
18388  since the division loses information about the signs of the two  since the division loses information about the signs of the two
18389  components, and an error might result from an explicit division by zero  components, and an error might result from an explicit division by zero
18390  which @code{arctan2} would avoid.  By (arbitrary) definition,  which @code{arctan2} would avoid.  By (arbitrary) definition,
# Line 18440  gamma function.  For positive integer ar Line 18433  gamma function.  For positive integer ar
18433  factorial function:  @samp{gamma(n+1) = fact(n)}.  For general complex  factorial function:  @samp{gamma(n+1) = fact(n)}.  For general complex
18434  arguments the gamma function can be defined by the following definite  arguments the gamma function can be defined by the following definite
18435  integral:    integral:  
18436  @texline @tmath{\Gamma(a) = \int_0^\infty t^{a-1} e^t dt}.  @texline @math{\Gamma(a) = \int_0^\infty t^{a-1} e^t dt}.
18437  @infoline @expr{gamma(a) = integ(t^(a-1) exp(t), t, 0, inf)}.    @infoline @expr{gamma(a) = integ(t^(a-1) exp(t), t, 0, inf)}.  
18438  (The actual implementation uses far more efficient computational methods.)  (The actual implementation uses far more efficient computational methods.)
18439    
# Line 18474  integral: Line 18467  integral:
18467  The @kbd{f G} (@code{calc-inc-gamma}) [@code{gammaP}] command computes  The @kbd{f G} (@code{calc-inc-gamma}) [@code{gammaP}] command computes
18468  the incomplete gamma function, denoted @samp{P(a,x)}.  This is defined by  the incomplete gamma function, denoted @samp{P(a,x)}.  This is defined by
18469  the integral,  the integral,
18470  @texline @tmath{P(a,x) = \left( \int_0^x t^{a-1} e^t dt \right) / \Gamma(a)}.  @texline @math{P(a,x) = \left( \int_0^x t^{a-1} e^t dt \right) / \Gamma(a)}.
18471  @infoline @expr{gammaP(a,x) = integ(t^(a-1) exp(t), t, 0, x) / gamma(a)}.  @infoline @expr{gammaP(a,x) = integ(t^(a-1) exp(t), t, 0, x) / gamma(a)}.
18472  This implies that @samp{gammaP(a,inf) = 1} for any @expr{a} (see the  This implies that @samp{gammaP(a,inf) = 1} for any @expr{a} (see the
18473  definition of the normal gamma function).  definition of the normal gamma function).
# Line 18507  You can obtain these using the \kbd{H f Line 18500  You can obtain these using the \kbd{H f
18500  @tindex beta  @tindex beta
18501  The @kbd{f b} (@code{calc-beta}) [@code{beta}] command computes the  The @kbd{f b} (@code{calc-beta}) [@code{beta}] command computes the
18502  Euler beta function, which is defined in terms of the gamma function as  Euler beta function, which is defined in terms of the gamma function as
18503  @texline @tmath{B(a,b) = \Gamma(a) \Gamma(b) / \Gamma(a+b)},  @texline @math{B(a,b) = \Gamma(a) \Gamma(b) / \Gamma(a+b)},
18504  @infoline @expr{beta(a,b) = gamma(a) gamma(b) / gamma(a+b)},  @infoline @expr{beta(a,b) = gamma(a) gamma(b) / gamma(a+b)},
18505  or by  or by
18506  @texline @tmath{B(a,b) = \int_0^1 t^{a-1} (1-t)^{b-1} dt}.  @texline @math{B(a,b) = \int_0^1 t^{a-1} (1-t)^{b-1} dt}.
18507  @infoline @expr{beta(a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, 1)}.  @infoline @expr{beta(a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, 1)}.
18508    
18509  @kindex f B  @kindex f B
# Line 18520  or by Line 18513  or by
18513  @tindex betaB  @tindex betaB
18514  The @kbd{f B} (@code{calc-inc-beta}) [@code{betaI}] command computes  The @kbd{f B} (@code{calc-inc-beta}) [@code{betaI}] command computes
18515  the incomplete beta function @expr{I(x,a,b)}.  It is defined by  the incomplete beta function @expr{I(x,a,b)}.  It is defined by
18516  @texline @tmath{I(x,a,b) = \left( \int_0^x t^{a-1} (1-t)^{b-1} dt \right) / B(a,b)}.  @texline @math{I(x,a,b) = \left( \int_0^x t^{a-1} (1-t)^{b-1} dt \right) / B(a,b)}.
18517  @infoline @expr{betaI(x,a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, x) / beta(a,b)}.  @infoline @expr{betaI(x,a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, x) / beta(a,b)}.
18518  Once again, the @kbd{H} (hyperbolic) prefix gives the corresponding  Once again, the @kbd{H} (hyperbolic) prefix gives the corresponding
18519  un-normalized version [@code{betaB}].  un-normalized version [@code{betaB}].
# Line 18532  un-normalized version [@code{betaB}]. Line 18525  un-normalized version [@code{betaB}].
18525  @tindex erfc  @tindex erfc
18526  The @kbd{f e} (@code{calc-erf}) [@code{erf}] command computes the  The @kbd{f e} (@code{calc-erf}) [@code{erf}] command computes the
18527  error function  error function
18528  @texline @tmath{\hbox{erf}(x) = {2 \over \sqrt{\pi}} \int_0^x e^{-t^2} dt}.  @texline @math{\hbox{erf}(x) = {2 \over \sqrt{\pi}} \int_0^x e^{-t^2} dt}.
18529  @infoline @expr{erf(x) = 2 integ(exp(-(t^2)), t, 0, x) / sqrt(pi)}.  @infoline @expr{erf(x) = 2 integ(exp(-(t^2)), t, 0, x) / sqrt(pi)}.
18530  The complementary error function @kbd{I f e} (@code{calc-erfc}) [@code{erfc}]  The complementary error function @kbd{I f e} (@code{calc-erfc}) [@code{erfc}]
18531  is the corresponding integral from @samp{x} to infinity; the sum  is the corresponding integral from @samp{x} to infinity; the sum
18532  @texline @tmath{\hbox{erf}(x) + \hbox{erfc}(x) = 1}.  @texline @math{\hbox{erf}(x) + \hbox{erfc}(x) = 1}.
18533  @infoline @expr{erf(x) + erfc(x) = 1}.  @infoline @expr{erf(x) + erfc(x) = 1}.
18534    
18535  @kindex f j  @kindex f j
# Line 18612  occurrence of @code{eps} may stand for a Line 18605  occurrence of @code{eps} may stand for a
18605    
18606  For @samp{z1^z2}:  This is defined by @samp{exp(ln(z1)*z2)}.  For @samp{z1^z2}:  This is defined by @samp{exp(ln(z1)*z2)}.
18607  One interesting consequence of this is that @samp{(-8)^1:3} does  One interesting consequence of this is that @samp{(-8)^1:3} does
18608  not evaluate to @i{-2} as you might expect, but to the complex  not evaluate to @mathit{-2} as you might expect, but to the complex
18609  number @expr{(1., 1.732)}.  Both of these are valid cube roots  number @expr{(1., 1.732)}.  Both of these are valid cube roots
18610  of @i{-8} (as is @expr{(1., -1.732)}); Calc chooses a perhaps  of @mathit{-8} (as is @expr{(1., -1.732)}); Calc chooses a perhaps
18611  less-obvious root for the sake of mathematical consistency.  less-obvious root for the sake of mathematical consistency.
18612    
18613  For @samp{arcsin(z)}:  This is defined by @samp{-i*ln(i*z + sqrt(1-z^2))}.  For @samp{arcsin(z)}:  This is defined by @samp{-i*ln(i*z + sqrt(1-z^2))}.
18614  The branch cuts are on the real axis, less than @i{-1} and greater than 1.  The branch cuts are on the real axis, less than @mathit{-1} and greater than 1.
18615    
18616  For @samp{arccos(z)}:  This is defined by @samp{-i*ln(z + i*sqrt(1-z^2))},  For @samp{arccos(z)}:  This is defined by @samp{-i*ln(z + i*sqrt(1-z^2))},
18617  or equivalently by @samp{pi/2 - arcsin(z)}.  The branch cuts are on  or equivalently by @samp{pi/2 - arcsin(z)}.  The branch cuts are on
18618  the real axis, less than @i{-1} and greater than 1.  the real axis, less than @mathit{-1} and greater than 1.
18619    
18620  For @samp{arctan(z)}:  This is defined by  For @samp{arctan(z)}:  This is defined by
18621  @samp{(ln(1+i*z) - ln(1-i*z)) / (2*i)}.  The branch cuts are on the  @samp{(ln(1+i*z) - ln(1-i*z)) / (2*i)}.  The branch cuts are on the
# Line 18637  For @samp{arccosh(z)}:  This is defined Line 18630  For @samp{arccosh(z)}:  This is defined
18630  real axis less than 1.  real axis less than 1.
18631    
18632  For @samp{arctanh(z)}:  This is defined by @samp{(ln(1+z) - ln(1-z)) / 2}.  For @samp{arctanh(z)}:  This is defined by @samp{(ln(1+z) - ln(1-z)) / 2}.
18633  The branch cuts are on the real axis, less than @i{-1} and greater than 1.  The branch cuts are on the real axis, less than @mathit{-1} and greater than 1.
18634    
18635  The following tables for @code{arcsin}, @code{arccos}, and  The following tables for @code{arcsin}, @code{arccos}, and
18636  @code{arctan} assume the current angular mode is radians.  The  @code{arctan} assume the current angular mode is radians.  The
# Line 18710  random numbers of various sorts. Line 18703  random numbers of various sorts.
18703    
18704  Given a positive numeric prefix argument @expr{M}, it produces a random  Given a positive numeric prefix argument @expr{M}, it produces a random
18705  integer @expr{N} in the range  integer @expr{N} in the range
18706  @texline @tmath{0 \le N < M}.  @texline @math{0 \le N < M}.
18707  @infoline @expr{0 <= N < M}.    @infoline @expr{0 <= N < M}.  
18708  Each of the @expr{M} values appears with equal probability.  Each of the @expr{M} values appears with equal probability.
18709    
# Line 18720  the result is a random integer less than Line 18713  the result is a random integer less than
18713  while numeric prefix arguments are limited to six digits or so, an @expr{M}  while numeric prefix arguments are limited to six digits or so, an @expr{M}
18714  taken from the stack can be arbitrarily large.  If @expr{M} is negative,  taken from the stack can be arbitrarily large.  If @expr{M} is negative,
18715  the result is a random integer in the range  the result is a random integer in the range
18716  @texline @tmath{M < N \le 0}.  @texline @math{M < N \le 0}.
18717  @infoline @expr{M < N <= 0}.  @infoline @expr{M < N <= 0}.
18718    
18719  If the value on the stack is a floating-point number @expr{M}, the result  If the value on the stack is a floating-point number @expr{M}, the result
18720  is a random floating-point number @expr{N} in the range  is a random floating-point number @expr{N} in the range
18721  @texline @tmath{0 \le N < M}  @texline @math{0 \le N < M}
18722  @infoline @expr{0 <= N < M}  @infoline @expr{0 <= N < M}
18723  or  or
18724  @texline @tmath{M < N \le 0},  @texline @math{M < N \le 0},
18725  @infoline @expr{M < N <= 0},  @infoline @expr{M < N <= 0},
18726  according to the sign of @expr{M}.  according to the sign of @expr{M}.
18727    
# Line 18738  of one.  The algorithm used generates ra Line 18731  of one.  The algorithm used generates ra
18731  every other call to this function will be especially fast.  every other call to this function will be especially fast.
18732    
18733  If @expr{M} is an error form  If @expr{M} is an error form
18734  @texline @tmath{m} @code{+/-} @tmath{\sigma}  @texline @math{m} @code{+/-} @math{\sigma}
18735  @infoline @samp{m +/- s}  @infoline @samp{m +/- s}
18736  where @var{m} and  where @var{m} and
18737  @texline @tmath{\sigma}  @texline @math{\sigma}
18738  @infoline @var{s}  @infoline @var{s}
18739  are both real numbers, the result uses a Gaussian distribution with mean  are both real numbers, the result uses a Gaussian distribution with mean
18740  @var{m} and standard deviation  @var{m} and standard deviation
18741  @texline @tmath{\sigma}.  @texline @math{\sigma}.
18742  @var{s}.  @var{s}.
18743    
18744  If @expr{M} is an interval form, the lower and upper bounds specify the  If @expr{M} is an interval form, the lower and upper bounds specify the
# Line 18858  generators that are typically used to im Line 18851  generators that are typically used to im
18851  If @code{RandSeed} contains an integer, Calc uses this integer to  If @code{RandSeed} contains an integer, Calc uses this integer to
18852  seed an ``additive congruential'' method (Knuth's algorithm 3.2.2A,  seed an ``additive congruential'' method (Knuth's algorithm 3.2.2A,
18853  computing  computing
18854  @texline @tmath{X_{n-55} - X_{n-24}}.  @texline @math{X_{n-55} - X_{n-24}}.
18855  @infoline @expr{X_n-55 - X_n-24}).    @infoline @expr{X_n-55 - X_n-24}).  
18856  This method expands the seed  This method expands the seed
18857  value into a large table which is maintained internally; the variable  value into a large table which is maintained internally; the variable
# Line 18894  value. Line 18887  value.
18887    
18888  To create a random floating-point number with precision @var{p}, Calc  To create a random floating-point number with precision @var{p}, Calc
18889  simply creates a random @var{p}-digit integer and multiplies by  simply creates a random @var{p}-digit integer and multiplies by
18890  @texline @tmath{10^{-p}}.  @texline @math{10^{-p}}.
18891  @infoline @expr{10^-p}.    @infoline @expr{10^-p}.  
18892  The resulting random numbers should be very clean, but note  The resulting random numbers should be very clean, but note
18893  that relatively small numbers will have few significant random digits.  that relatively small numbers will have few significant random digits.
18894  In other words, with a precision of 12, you will occasionally get  In other words, with a precision of 12, you will occasionally get
18895  numbers on the order of  numbers on the order of
18896  @texline @tmath{10^{-9}}  @texline @math{10^{-9}}
18897  @infoline @expr{10^-9}  @infoline @expr{10^-9}
18898  or  or
18899  @texline @tmath{10^{-10}},  @texline @math{10^{-10}},
18900  @infoline @expr{10^-10},  @infoline @expr{10^-10},
18901  but those numbers will only have two or three random digits since they  but those numbers will only have two or three random digits since they
18902  correspond to small integers times  correspond to small integers times
18903  @texline @tmath{10^{-12}}.  @texline @math{10^{-12}}.
18904  @infoline @expr{10^-12}.  @infoline @expr{10^-12}.
18905    
18906  To create a random integer in the interval @samp{[0 .. @var{m})}, Calc  To create a random integer in the interval @samp{[0 .. @var{m})}, Calc
# Line 18958  numbers. Line 18951  numbers.
18951  The @kbd{k E} (@code{calc-extended-gcd}) [@code{egcd}] command computes  The @kbd{k E} (@code{calc-extended-gcd}) [@code{egcd}] command computes
18952  the GCD of two integers @expr{x} and @expr{y} and returns a vector  the GCD of two integers @expr{x} and @expr{y} and returns a vector
18953  @expr{[g, a, b]} where  @expr{[g, a, b]} where
18954  @texline @tmath{g = \gcd(x,y) = a x + b y}.  @texline @math{g = \gcd(x,y) = a x + b y}.
18955  @infoline @expr{g = gcd(x,y) = a x + b y}.  @infoline @expr{g = gcd(x,y) = a x + b y}.
18956    
18957  @kindex !  @kindex !
# Line 19002  on the top of the stack and @expr{N} is Line 18995  on the top of the stack and @expr{N} is
18995  are integers, the result is an exact integer.  Otherwise, the result is a  are integers, the result is an exact integer.  Otherwise, the result is a
18996  floating-point approximation.  The binomial coefficient is defined for all  floating-point approximation.  The binomial coefficient is defined for all
18997  real numbers by  real numbers by
18998  @texline @tmath{N! \over M! (N-M)!\,}.  @texline @math{N! \over M! (N-M)!\,}.
18999  @infoline @expr{N! / M! (N-M)!}.  @infoline @expr{N! / M! (N-M)!}.
19000    
19001  @kindex H k c  @kindex H k c
# Line 19045  functions. Line 19038  functions.
19038  @tindex stir2  @tindex stir2
19039  The @kbd{k s} (@code{calc-stirling-number}) [@code{stir1}] command  The @kbd{k s} (@code{calc-stirling-number}) [@code{stir1}] command
19040  computes a Stirling number of the first  computes a Stirling number of the first
19041  @texline kind@tie{}@tmath{n \brack m},  @texline kind@tie{}@math{n \brack m},
19042  @infoline kind,  @infoline kind,
19043  given two integers @expr{n} and @expr{m} on the stack.  The @kbd{H k s}  given two integers @expr{n} and @expr{m} on the stack.  The @kbd{H k s}
19044  [@code{stir2}] command computes a Stirling number of the second  [@code{stir2}] command computes a Stirling number of the second
19045  @texline kind@tie{}@tmath{n \brace m}.  @texline kind@tie{}@math{n \brace m}.
19046  @infoline kind.  @infoline kind.
19047  These are the number of @expr{m}-cycle permutations of @expr{n} objects,  These are the number of @expr{m}-cycle permutations of @expr{n} objects,
19048  and the number of ways to partition @expr{n} objects into @expr{m}  and the number of ways to partition @expr{n} objects into @expr{m}
# Line 19093  result is a vector of the prime factors Line 19086  result is a vector of the prime factors
19086  inputs, prime factors above 5000 may not be found, in which case the  inputs, prime factors above 5000 may not be found, in which case the
19087  last number in the vector will be an unfactored integer greater than 25  last number in the vector will be an unfactored integer greater than 25
19088  million (with a warning message).  For negative integers, the first  million (with a warning message).  For negative integers, the first
19089  element of the list will be @i{-1}.  For inputs @i{-1}, @i{0}, and  element of the list will be @mathit{-1}.  For inputs @mathit{-1}, @mathit{0}, and
19090  @i{1}, the result is a list of the same number.  @mathit{1}, the result is a list of the same number.
19091    
19092  @kindex k n  @kindex k n
19093  @pindex calc-next-prime  @pindex calc-next-prime
# Line 19128  analogously finds the next prime less th Line 19121  analogously finds the next prime less th
19121  @tindex totient  @tindex totient
19122  The @kbd{k t} (@code{calc-totient}) [@code{totient}] command computes the  The @kbd{k t} (@code{calc-totient}) [@code{totient}] command computes the
19123  Euler ``totient''  Euler ``totient''
19124  @texline function@tie{}@tmath{\phi(n)},  @texline function@tie{}@math{\phi(n)},
19125  @infoline function,  @infoline function,
19126  the number of integers less than @expr{n} which  the number of integers less than @expr{n} which
19127  are relatively prime to @expr{n}.  are relatively prime to @expr{n}.
# Line 19137  are relatively prime to @expr{n}. Line 19130  are relatively prime to @expr{n}.
19130  @pindex calc-moebius  @pindex calc-moebius
19131  @tindex moebius  @tindex moebius
19132  The @kbd{k m} (@code{calc-moebius}) [@code{moebius}] command computes the  The @kbd{k m} (@code{calc-moebius}) [@code{moebius}] command computes the
19133  @texline M@"obius @tmath{\mu}  @texline M@"obius @math{\mu}
19134  @infoline Moebius ``mu''  @infoline Moebius ``mu''
19135  function.  If the input number is a product of @expr{k}  function.  If the input number is a product of @expr{k}
19136  distinct factors, this is @expr{(-1)^k}.  If the input number has any  distinct factors, this is @expr{(-1)^k}.  If the input number has any
# Line 19201  recover the original arguments but subst Line 19194  recover the original arguments but subst
19194  @end ignore  @end ignore
19195  @tindex ltpc  @tindex ltpc
19196  The @samp{utpc(x,v)} function uses the chi-square distribution with  The @samp{utpc(x,v)} function uses the chi-square distribution with
19197  @texline @tmath{\nu}  @texline @math{\nu}
19198  @infoline @expr{v}  @infoline @expr{v}
19199  degrees of freedom.  It is the probability that a model is  degrees of freedom.  It is the probability that a model is
19200  correct if its chi-square statistic is @expr{x}.  correct if its chi-square statistic is @expr{x}.
# Line 19219  correct if its chi-square statistic is @ Line 19212  correct if its chi-square statistic is @
19212  @tindex ltpf  @tindex ltpf
19213  The @samp{utpf(F,v1,v2)} function uses the F distribution, used in  The @samp{utpf(F,v1,v2)} function uses the F distribution, used in
19214  various statistical tests.  The parameters  various statistical tests.  The parameters
19215  @texline @tmath{\nu_1}  @texline @math{\nu_1}
19216  @infoline @expr{v1}  @infoline @expr{v1}
19217  and  and
19218  @texline @tmath{\nu_2}  @texline @math{\nu_2}
19219  @infoline @expr{v2}  @infoline @expr{v2}
19220  are the degrees of freedom in the numerator and denominator,  are the degrees of freedom in the numerator and denominator,
19221  respectively, used in computing the statistic @expr{F}.  respectively, used in computing the statistic @expr{F}.
# Line 19240  respectively, used in computing the stat Line 19233  respectively, used in computing the stat
19233  @tindex ltpn  @tindex ltpn
19234  The @samp{utpn(x,m,s)} function uses a normal (Gaussian) distribution  The @samp{utpn(x,m,s)} function uses a normal (Gaussian) distribution
19235  with mean @expr{m} and standard deviation  with mean @expr{m} and standard deviation
19236  @texline @tmath{\sigma}.  @texline @math{\sigma}.
19237  @infoline @expr{s}.    @infoline @expr{s}.  
19238  It is the probability that such a normal-distributed random variable  It is the probability that such a normal-distributed random variable
19239  would exceed @expr{x}.  would exceed @expr{x}.
# Line 19273  Poisson random events will occur. Line 19266  Poisson random events will occur.
19266  @tindex ltpt  @tindex ltpt
19267  The @samp{utpt(t,v)} function uses the Student's ``t'' distribution  The @samp{utpt(t,v)} function uses the Student's ``t'' distribution
19268  with  with
19269  @texline @tmath{\nu}  @texline @math{\nu}
19270  @infoline @expr{v}  @infoline @expr{v}
19271  degrees of freedom.  It is the probability that a  degrees of freedom.  It is the probability that a
19272  t-distributed random variable will be greater than @expr{t}.  t-distributed random variable will be greater than @expr{t}.
19273  (Note:  This computes the distribution function  (Note:  This computes the distribution function
19274  @texline @tmath{A(t|\nu)}  @texline @math{A(t|\nu)}
19275  @infoline @expr{A(t|v)}  @infoline @expr{A(t|v)}
19276  where  where
19277  @texline @tmath{A(0|\nu) = 1}  @texline @math{A(0|\nu) = 1}
19278  @infoline @expr{A(0|v) = 1}  @infoline @expr{A(0|v) = 1}
19279  and  and
19280  @texline @tmath{A(\infty|\nu) \to 0}.  @texline @math{A(\infty|\nu) \to 0}.
19281  @infoline @expr{A(inf|v) -> 0}.    @infoline @expr{A(inf|v) -> 0}.  
19282  The @code{UTPT} operation on the HP-48 uses a different definition which  The @code{UTPT} operation on the HP-48 uses a different definition which
19283  returns half of Calc's value:  @samp{UTPT(t,v) = .5*utpt(t,v)}.)  returns half of Calc's value:  @samp{UTPT(t,v) = .5*utpt(t,v)}.)
# Line 19404  integer, is the exponent.  The result is Line 19397  integer, is the exponent.  The result is
19397  times ten to the power of the exponent.  times ten to the power of the exponent.
19398    
19399  @item -12  @item -12
19400  This is treated the same as @i{-11} by the @kbd{v p} command.  This is treated the same as @mathit{-11} by the @kbd{v p} command.
19401  When unpacking, @i{-12} specifies that a floating-point mantissa  When unpacking, @mathit{-12} specifies that a floating-point mantissa
19402  is desired.  is desired.
19403    
19404  @item -13  @item -13
# Line 19444  returned in the form @samp{[@w{[a, b, c] Line 19437  returned in the form @samp{[@w{[a, b, c]
19437  If any elements of the vector are negative, other kinds of  If any elements of the vector are negative, other kinds of
19438  packing are done at that level as described above.  For  packing are done at that level as described above.  For
19439  example, @samp{[2, 3, -4]} takes 12 objects and creates a  example, @samp{[2, 3, -4]} takes 12 objects and creates a
19440  @texline @tmath{2\times3}  @texline @math{2\times3}
19441  @infoline 2x3  @infoline 2x3
19442  matrix of error forms: @samp{[[a +/- b, c +/- d ... ]]}.  matrix of error forms: @samp{[[a +/- b, c +/- d ... ]]}.
19443  Also, @samp{[-4, -10]} will convert four integers into an  Also, @samp{[-4, -10]} will convert four integers into an
# Line 19482  the result of @kbd{C-u -4 v u} will be t Line 19475  the result of @kbd{C-u -4 v u} will be t
19475  @samp{[a, c^2, d]} and @w{@samp{[b, 0, 7]}}.  @samp{[a, c^2, d]} and @w{@samp{[b, 0, 7]}}.
19476    
19477  Note that the prefix argument can have an effect even when the input is  Note that the prefix argument can have an effect even when the input is
19478  not a vector.  For example, if the input is the number @i{-5}, then  not a vector.  For example, if the input is the number @mathit{-5}, then
19479  @kbd{c-u -1 v u} yields @i{-5} and 0 (the components of @i{-5}  @kbd{c-u -1 v u} yields @mathit{-5} and 0 (the components of @mathit{-5}
19480  when viewed as a rectangular complex number); @kbd{C-u -2 v u} yields 5  when viewed as a rectangular complex number); @kbd{C-u -2 v u} yields 5
19481  and 180 (assuming degrees mode); and @kbd{C-u -10 v u} yields @i{-5}  and 180 (assuming degrees mode); and @kbd{C-u -10 v u} yields @mathit{-5}
19482  and 1 (the numerator and denominator of @i{-5}, viewed as a rational  and 1 (the numerator and denominator of @mathit{-5}, viewed as a rational
19483  number).  Plain @kbd{v u} with this input would complain that the input  number).  Plain @kbd{v u} with this input would complain that the input
19484  is not a composite object.  is not a composite object.
19485    
19486  Unpacking mode @i{-11} converts a float into an integer mantissa and  Unpacking mode @mathit{-11} converts a float into an integer mantissa and
19487  an integer exponent, where the mantissa is not divisible by 10  an integer exponent, where the mantissa is not divisible by 10
19488  (except that 0.0 is represented by a mantissa and exponent of 0).  (except that 0.0 is represented by a mantissa and exponent of 0).
19489  Unpacking mode @i{-12} converts a float into a floating-point mantissa  Unpacking mode @mathit{-12} converts a float into a floating-point mantissa
19490  and integer exponent, where the mantissa (for non-zero numbers)  and integer exponent, where the mantissa (for non-zero numbers)
19491  is guaranteed to lie in the range [1 .. 10).  In both cases,  is guaranteed to lie in the range [1 .. 10).  In both cases,
19492  the mantissa is shifted left or right (and the exponent adjusted  the mantissa is shifted left or right (and the exponent adjusted
# Line 19593  the stack is a scalar, it is used for ea Line 19586  the stack is a scalar, it is used for ea
19586  the prefix argument is required.  the prefix argument is required.
19587    
19588  To build a constant square matrix, e.g., a  To build a constant square matrix, e.g., a
19589  @texline @tmath{3\times3}  @texline @math{3\times3}
19590  @infoline 3x3  @infoline 3x3
19591  matrix filled with ones, use @kbd{0 M-3 v d 1 +}, i.e., build a zero  matrix filled with ones, use @kbd{0 M-3 v d 1 +}, i.e., build a zero
19592  matrix first and then add a constant value to that matrix.  (Another  matrix first and then add a constant value to that matrix.  (Another
# Line 19626  The @kbd{v x} (@code{calc-index}) [@code Line 19619  The @kbd{v x} (@code{calc-index}) [@code
19619  of consecutive integers from 1 to @var{n}, where @var{n} is the numeric  of consecutive integers from 1 to @var{n}, where @var{n} is the numeric
19620  prefix argument.  If you do not provide a prefix argument, you will be  prefix argument.  If you do not provide a prefix argument, you will be
19621  prompted to enter a suitable number.  If @var{n} is negative, the result  prompted to enter a suitable number.  If @var{n} is negative, the result
19622  is a vector of negative integers from @var{n} to @i{-1}.  is a vector of negative integers from @var{n} to @mathit{-1}.
19623    
19624  With a prefix argument of just @kbd{C-u}, the @kbd{v x} command takes  With a prefix argument of just @kbd{C-u}, the @kbd{v x} command takes
19625  three values from the stack: @var{n}, @var{start}, and @var{incr} (with  three values from the stack: @var{n}, @var{start}, and @var{incr} (with
# Line 19819  With the Hyperbolic flag, @kbd{H v l} [@ Line 19812  With the Hyperbolic flag, @kbd{H v l} [@
19812  of the dimensions of a vector, matrix, or higher-order object.  For  of the dimensions of a vector, matrix, or higher-order object.  For
19813  example, @samp{mdims([[a,b,c],[d,e,f]])} returns @samp{[2, 3]} since  example, @samp{mdims([[a,b,c],[d,e,f]])} returns @samp{[2, 3]} since
19814  its argument is a  its argument is a
19815  @texline @tmath{2\times3}  @texline @math{2\times3}
19816  @infoline 2x3  @infoline 2x3
19817  matrix.  matrix.
19818    
# Line 19851  in the vector, the last row will be shor Line 19844  in the vector, the last row will be shor
19844  suitable for use as a matrix.  For example, with the matrix  suitable for use as a matrix.  For example, with the matrix
19845  @samp{[[1, 2], @w{[3, 4]}]} on the stack, @kbd{v a 4} produces  @samp{[[1, 2], @w{[3, 4]}]} on the stack, @kbd{v a 4} produces
19846  @samp{[[1, 2, 3, 4]]} (a  @samp{[[1, 2, 3, 4]]} (a
19847  @texline @tmath{1\times4}  @texline @math{1\times4}
19848  @infoline 1x4  @infoline 1x4
19849  matrix), @kbd{v a 1} produces @samp{[[1], [2], [3], [4]]} (a  matrix), @kbd{v a 1} produces @samp{[[1], [2], [3], [4]]} (a
19850  @texline @tmath{4\times1}  @texline @math{4\times1}
19851  @infoline 4x1  @infoline 4x1
19852  matrix), @kbd{v a 2} produces @samp{[[1, 2], [3, 4]]} (the original  matrix), @kbd{v a 2} produces @samp{[[1, 2], [3, 4]]} (the original
19853  @texline @tmath{2\times2}  @texline @math{2\times2}
19854  @infoline 2x2  @infoline 2x2
19855  matrix), @w{@kbd{v a 3}} produces @samp{[[1, 2, 3], [4]]} (not a  matrix), @w{@kbd{v a 3}} produces @samp{[[1, 2, 3], [4]]} (not a
19856  matrix), and @kbd{v a 0} produces the flattened list  matrix), and @kbd{v a 0} produces the flattened list
# Line 20177  sets are disjoint, i.e., if they share n Line 20170  sets are disjoint, i.e., if they share n
20170  will be the empty vector @samp{[]}.  Note that the characters @kbd{V}  will be the empty vector @samp{[]}.  Note that the characters @kbd{V}
20171  and @kbd{^} were chosen to be close to the conventional mathematical  and @kbd{^} were chosen to be close to the conventional mathematical
20172  notation for set  notation for set
20173  @texline union@tie{}(@tmath{A \cup B})  @texline union@tie{}(@math{A \cup B})
20174  @infoline union  @infoline union
20175  and  and
20176  @texline intersection@tie{}(@tmath{A \cap B}).  @texline intersection@tie{}(@math{A \cap B}).
20177  @infoline intersection.  @infoline intersection.
20178    
20179  @kindex V -  @kindex V -
# Line 20289  not include any negative numbers.  The i Line 20282  not include any negative numbers.  The i
20282  set of integers in the sense of @kbd{V F} (@code{vfloor}).  Beware  set of integers in the sense of @kbd{V F} (@code{vfloor}).  Beware
20283  that a simple input like @samp{[100]} can result in a huge integer  that a simple input like @samp{[100]} can result in a huge integer
20284  representation  representation
20285  @texline (@tmath{2^{100}}, a 31-digit integer, in this case).  @texline (@math{2^{100}}, a 31-digit integer, in this case).
20286  @infoline (@expr{2^100}, a 31-digit integer, in this case).  @infoline (@expr{2^100}, a 31-digit integer, in this case).
20287    
20288  @node Statistical Operations, Reducing and Mapping, Set Operations, Matrix Functions  @node Statistical Operations, Reducing and Mapping, Set Operations, Matrix Functions
# Line 20401  plus or minus infinity. Line 20394  plus or minus infinity.
20394  The @kbd{u M} (@code{calc-vector-mean}) [@code{vmean}] command  The @kbd{u M} (@code{calc-vector-mean}) [@code{vmean}] command
20395  computes the average (arithmetic mean) of the data values.  computes the average (arithmetic mean) of the data values.
20396  If the inputs are error forms  If the inputs are error forms
20397  @texline @tmath{x \pm \sigma},  @texline @math{x \pm \sigma},
20398  @infoline @samp{x +/- s},  @infoline @samp{x +/- s},
20399  this is the weighted mean of the @expr{x} values with weights  this is the weighted mean of the @expr{x} values with weights
20400  @texline @tmath{1 /\sigma^2}.  @texline @math{1 /\sigma^2}.
20401  @infoline @expr{1 / s^2}.  @infoline @expr{1 / s^2}.
20402  @tex  @tex
20403  \turnoffactive  \turnoffactive
# Line 20416  values divided by the count of the value Line 20409  values divided by the count of the value
20409    
20410  Note that a plain number can be considered an error form with  Note that a plain number can be considered an error form with
20411  error  error
20412  @texline @tmath{\sigma = 0}.  @texline @math{\sigma = 0}.
20413  @infoline @expr{s = 0}.    @infoline @expr{s = 0}.  
20414  If the input to @kbd{u M} is a mixture of  If the input to @kbd{u M} is a mixture of
20415  plain numbers and error forms, the result is the mean of the  plain numbers and error forms, the result is the mean of the
# Line 20525  for a vector of numbers simply by using Line 20518  for a vector of numbers simply by using
20518  @cindex Sample statistics  @cindex Sample statistics
20519  The @kbd{u S} (@code{calc-vector-sdev}) [@code{vsdev}] command  The @kbd{u S} (@code{calc-vector-sdev}) [@code{vsdev}] command
20520  computes the standard  computes the standard
20521  @texline deviation@tie{}@tmath{\sigma}  @texline deviation@tie{}@math{\sigma}
20522  @infoline deviation  @infoline deviation
20523  of the data values.  If the values are error forms, the errors are used  of the data values.  If the values are error forms, the errors are used
20524  as weights just as for @kbd{u M}.  This is the @emph{sample} standard  as weights just as for @kbd{u M}.  This is the @emph{sample} standard
# Line 20541  This function also applies to distributi Line 20534  This function also applies to distributi
20534  of a single error form is simply the error part.  The standard deviation  of a single error form is simply the error part.  The standard deviation
20535  of a continuous interval happens to equal the difference between the  of a continuous interval happens to equal the difference between the
20536  limits, divided by  limits, divided by
20537  @texline @tmath{\sqrt{12}}.  @texline @math{\sqrt{12}}.
20538  @infoline @expr{sqrt(12)}.    @infoline @expr{sqrt(12)}.  
20539  The standard deviation of an integer interval is the same as the  The standard deviation of an integer interval is the same as the
20540  standard deviation of a vector of those integers.  standard deviation of a vector of those integers.
# Line 20579  The @kbd{H u S} (@code{calc-vector-varia Line 20572  The @kbd{H u S} (@code{calc-vector-varia
20572  @kbd{H I u S} (@code{calc-vector-pop-variance}) [@code{vpvar}]  @kbd{H I u S} (@code{calc-vector-pop-variance}) [@code{vpvar}]
20573  commands compute the variance of the data values.  The variance  commands compute the variance of the data values.  The variance
20574  is the  is the
20575  @texline square@tie{}@tmath{\sigma^2}  @texline square@tie{}@math{\sigma^2}
20576  @infoline square  @infoline square
20577  of the standard deviation, i.e., the sum of the  of the standard deviation, i.e., the sum of the
20578  squares of the deviations of the data values from the mean.  squares of the deviations of the data values from the mean.
# Line 20603  vectors of equal size.  The vectors are Line 20596  vectors of equal size.  The vectors are
20596  way as by the single-variable statistical functions.  Given a numeric  way as by the single-variable statistical functions.  Given a numeric
20597  prefix argument of 1, these functions instead take one object from  prefix argument of 1, these functions instead take one object from
20598  the stack, which must be an  the stack, which must be an
20599  @texline @tmath{N\times2}  @texline @math{N\times2}
20600  @infoline Nx2  @infoline Nx2
20601  matrix of data values.  Once again, variable names can be used in place  matrix of data values.  Once again, variable names can be used in place
20602  of actual vectors and matrices.  of actual vectors and matrices.
# Line 20861  If any argument to @kbd{V M} is a matrix Line 20854  If any argument to @kbd{V M} is a matrix
20854  across all elements of the matrix.  For example, given the matrix  across all elements of the matrix.  For example, given the matrix
20855  @expr{[[1, -2, 3], [-4, 5, -6]]}, @kbd{V M A} takes six absolute values to  @expr{[[1, -2, 3], [-4, 5, -6]]}, @kbd{V M A} takes six absolute values to
20856  produce another  produce another
20857  @texline @tmath{3\times2}  @texline @math{3\times2}
20858  @infoline 3x2  @infoline 3x2
20859  matrix, @expr{[[1, 2, 3], [4, 5, 6]]}.  matrix, @expr{[[1, 2, 3], [4, 5, 6]]}.
20860    
# Line 22014  as if in algebraic simplification mode. Line 22007  as if in algebraic simplification mode.
22007  @kbd{a s}; @pxref{Simplifying Formulas}.  If you give a numeric prefix  @kbd{a s}; @pxref{Simplifying Formulas}.  If you give a numeric prefix
22008  of 3 or more, it uses extended simplification mode (@kbd{a e}).  of 3 or more, it uses extended simplification mode (@kbd{a e}).
22009    
22010  If you give a negative prefix argument @i{-1}, @i{-2}, or @i{-3},  If you give a negative prefix argument @mathit{-1}, @mathit{-2}, or @mathit{-3},
22011  it simplifies in the corresponding mode but only works on the top-level  it simplifies in the corresponding mode but only works on the top-level
22012  function call of the formula.  For example, @samp{(2 + 3) * (2 + 3)} will  function call of the formula.  For example, @samp{(2 + 3) * (2 + 3)} will
22013  simplify to @samp{(2 + 3)^2}, without simplifying the sub-formulas  simplify to @samp{(2 + 3)^2}, without simplifying the sub-formulas
# Line 22286  simplifications.) Line 22279  simplifications.)
22279    
22280  The distributive law is used to simplify sums in some cases:  The distributive law is used to simplify sums in some cases:
22281  @expr{a x + b x} to @expr{(a + b) x}, where @expr{a} represents  @expr{a x + b x} to @expr{(a + b) x}, where @expr{a} represents
22282  a number or an implicit 1 or @i{-1} (as in @expr{x} or @expr{-x})  a number or an implicit 1 or @mathit{-1} (as in @expr{x} or @expr{-x})
22283  and similarly for @expr{b}.  Use the @kbd{a c}, @w{@kbd{a f}}, or  and similarly for @expr{b}.  Use the @kbd{a c}, @w{@kbd{a f}}, or
22284  @kbd{j M} commands to merge sums with non-numeric coefficients  @kbd{j M} commands to merge sums with non-numeric coefficients
22285  using the distributive law.  using the distributive law.
# Line 22330  rewritten to @expr{a (c - b)}. Line 22323  rewritten to @expr{a (c - b)}.
22323    
22324  The distributive law of products and powers is used for adjacent  The distributive law of products and powers is used for adjacent
22325  terms of the product: @expr{x^a x^b} goes to  terms of the product: @expr{x^a x^b} goes to
22326  @texline @tmath{x^{a+b}}  @texline @math{x^{a+b}}
22327  @infoline @expr{x^(a+b)}  @infoline @expr{x^(a+b)}
22328  where @expr{a} is a number, or an implicit 1 (as in @expr{x}),  where @expr{a} is a number, or an implicit 1 (as in @expr{x}),
22329  or the implicit one-half of @expr{@t{sqrt}(x)}, and similarly for  or the implicit one-half of @expr{@t{sqrt}(x)}, and similarly for
# Line 22341  If the sum of the powers is zero, the pr Line 22334  If the sum of the powers is zero, the pr
22334    
22335  The product of a negative power times anything but another negative  The product of a negative power times anything but another negative
22336  power is changed to use division:    power is changed to use division:  
22337  @texline @tmath{x^{-2} y}  @texline @math{x^{-2} y}
22338  @infoline @expr{x^(-2) y}  @infoline @expr{x^(-2) y}
22339  goes to @expr{y / x^2} unless matrix mode is  goes to @expr{y / x^2} unless matrix mode is
22340  in effect and neither @expr{x} nor @expr{y} are scalar (in which  in effect and neither @expr{x} nor @expr{y} are scalar (in which
# Line 22365  infinite quantity, as directed by the cu Line 22358  infinite quantity, as directed by the cu
22358  @xref{Infinite Mode}.  @xref{Infinite Mode}.
22359    
22360  The expression  The expression
22361  @texline @tmath{a / b^{-c}}  @texline @math{a / b^{-c}}
22362  @infoline @expr{a / b^(-c)}  @infoline @expr{a / b^(-c)}
22363  is changed to @expr{a b^c}, where @expr{-c} is any negative-looking  is changed to @expr{a b^c}, where @expr{-c} is any negative-looking
22364  power.  Also, @expr{1 / b^c} is changed to  power.  Also, @expr{1 / b^c} is changed to
22365  @texline @tmath{b^{-c}}  @texline @math{b^{-c}}
22366  @infoline @expr{b^(-c)}  @infoline @expr{b^(-c)}
22367  for any power @expr{c}.  for any power @expr{c}.
22368    
# Line 22410  Powers of products or quotients @expr{(a Line 22403  Powers of products or quotients @expr{(a
22403  are distributed to @expr{a^c b^c}, @expr{a^c / b^c} only if @expr{c}  are distributed to @expr{a^c b^c}, @expr{a^c / b^c} only if @expr{c}
22404  is an integer, or if either @expr{a} or @expr{b} are nonnegative  is an integer, or if either @expr{a} or @expr{b} are nonnegative
22405  real numbers.  Powers of powers @expr{(a^b)^c} are simplified to  real numbers.  Powers of powers @expr{(a^b)^c} are simplified to
22406  @texline @tmath{a^{b c}}  @texline @math{a^{b c}}
22407  @infoline @expr{a^(b c)}  @infoline @expr{a^(b c)}
22408  only when @expr{c} is an integer and @expr{b c} also  only when @expr{c} is an integer and @expr{b c} also
22409  evaluates to an integer.  Without these restrictions these simplifications  evaluates to an integer.  Without these restrictions these simplifications
22410  would not be safe because of problems with principal values.  would not be safe because of problems with principal values.
22411  (In other words,  (In other words,
22412  @texline @tmath{((-3)^{1/2})^2}  @texline @math{((-3)^{1/2})^2}
22413  @infoline @expr{((-3)^1:2)^2}  @infoline @expr{((-3)^1:2)^2}
22414  is safe to simplify, but  is safe to simplify, but
22415  @texline @tmath{((-3)^2)^{1/2}}  @texline @math{((-3)^2)^{1/2}}
22416  @infoline @expr{((-3)^2)^1:2}  @infoline @expr{((-3)^2)^1:2}
22417  is not.)  @xref{Declarations}, for ways to inform Calc that your  is not.)  @xref{Declarations}, for ways to inform Calc that your
22418  variables satisfy these requirements.  variables satisfy these requirements.
22419    
22420  As a special case of this rule, @expr{@t{sqrt}(x)^n} is simplified to  As a special case of this rule, @expr{@t{sqrt}(x)^n} is simplified to
22421  @texline @tmath{x^{n/2}}  @texline @math{x^{n/2}}
22422  @infoline @expr{x^(n/2)}  @infoline @expr{x^(n/2)}
22423  only for even integers @expr{n}.  only for even integers @expr{n}.
22424    
# Line 22438  even integer, or to @expr{-(a^b)} if @ex Line 22431  even integer, or to @expr{-(a^b)} if @ex
22431  for any negative-looking expression @expr{-a}.  for any negative-looking expression @expr{-a}.
22432    
22433  Square roots @expr{@t{sqrt}(x)} generally act like one-half powers  Square roots @expr{@t{sqrt}(x)} generally act like one-half powers
22434  @texline @tmath{x^{1:2}}  @texline @math{x^{1:2}}
22435  @infoline @expr{x^1:2}  @infoline @expr{x^1:2}
22436  for the purposes of the above-listed simplifications.  for the purposes of the above-listed simplifications.
22437    
22438  Also, note that  Also, note that
22439  @texline @tmath{1 / x^{1:2}}  @texline @math{1 / x^{1:2}}
22440  @infoline @expr{1 / x^1:2}  @infoline @expr{1 / x^1:2}
22441  is changed to  is changed to
22442  @texline @tmath{x^{-1:2}},  @texline @math{x^{-1:2}},
22443  @infoline @expr{x^(-1:2)},  @infoline @expr{x^(-1:2)},
22444  but @expr{1 / @t{sqrt}(x)} is left alone.  but @expr{1 / @t{sqrt}(x)} is left alone.
22445    
# Line 22589  Thus @expr{(x + y) (y + x)} will be simp Line 22582  Thus @expr{(x + y) (y + x)} will be simp
22582  A subtle point is that @expr{(x - y) (y - x)} will @emph{not}  A subtle point is that @expr{(x - y) (y - x)} will @emph{not}
22583  be simplified to @expr{-(x - y)^2}; Calc does not notice that  be simplified to @expr{-(x - y)^2}; Calc does not notice that
22584  one term can be written as a constant times the other, even if  one term can be written as a constant times the other, even if
22585  that constant is @i{-1}.  that constant is @mathit{-1}.
22586    
22587  A fraction times any expression, @expr{(a:b) x}, is changed to  A fraction times any expression, @expr{(a:b) x}, is changed to
22588  a quotient involving integers:  @expr{a x / b}.  This is not  a quotient involving integers:  @expr{a x / b}.  This is not
# Line 22632  Square roots of integer or rational argu Line 22625  Square roots of integer or rational argu
22625  several ways.  (Note that these will be left unevaluated only in  several ways.  (Note that these will be left unevaluated only in
22626  Symbolic mode.)  First, square integer or rational factors are  Symbolic mode.)  First, square integer or rational factors are
22627  pulled out so that @expr{@t{sqrt}(8)} is rewritten as  pulled out so that @expr{@t{sqrt}(8)} is rewritten as
22628  @texline @tmath{$2\,\t{sqrt}(2)$}.  @texline @math{2\,\t{sqrt}(2)}.
22629  @infoline @expr{2 sqrt(2)}.    @infoline @expr{2 sqrt(2)}.  
22630  Conceptually speaking this implies factoring the argument into primes  Conceptually speaking this implies factoring the argument into primes
22631  and moving pairs of primes out of the square root, but for reasons of  and moving pairs of primes out of the square root, but for reasons of
# Line 22694  functions are known, except for negative Line 22687  functions are known, except for negative
22687  @code{arctan}, @code{arcsinh}, and @code{arctanh}.  Note that  @code{arctan}, @code{arcsinh}, and @code{arctanh}.  Note that
22688  @expr{@t{arcsin}(@t{sin}(x))} can @emph{not} safely change to  @expr{@t{arcsin}(@t{sin}(x))} can @emph{not} safely change to
22689  @expr{x}, since this only correct within an integer multiple of  @expr{x}, since this only correct within an integer multiple of
22690  @texline @tmath{2 \pi}  @texline @math{2 \pi}
22691  @infoline @expr{2 pi}  @infoline @expr{2 pi}
22692  radians or 360 degrees.  However, @expr{@t{arcsinh}(@t{sinh}(x))} is  radians or 360 degrees.  However, @expr{@t{arcsinh}(@t{sinh}(x))} is
22693  simplified to @expr{x} if @expr{x} is known to be real.  simplified to @expr{x} if @expr{x} is known to be real.
22694    
22695  Several simplifications that apply to logarithms and exponentials  Several simplifications that apply to logarithms and exponentials
22696  are that @expr{@t{exp}(@t{ln}(x))},  are that @expr{@t{exp}(@t{ln}(x))},
22697  @texline @t{e}@tmath{^{\ln(x)}},  @texline @t{e}@math{^{\ln(x)}},
22698  @infoline @expr{e^@t{ln}(x)},  @infoline @expr{e^@t{ln}(x)},
22699  and  and
22700  @texline @tmath{10^{{\rm log10}(x)}}  @texline @math{10^{{\rm log10}(x)}}
22701  @infoline @expr{10^@t{log10}(x)}  @infoline @expr{10^@t{log10}(x)}
22702  all reduce to @expr{x}.  Also, @expr{@t{ln}(@t{exp}(x))}, etc., can  all reduce to @expr{x}.  Also, @expr{@t{ln}(@t{exp}(x))}, etc., can
22703  reduce to @expr{x} if @expr{x} is provably real.  The form  reduce to @expr{x} if @expr{x} is provably real.  The form
22704  @expr{@t{exp}(x)^y} is simplified to @expr{@t{exp}(x y)}.  If @expr{x}  @expr{@t{exp}(x)^y} is simplified to @expr{@t{exp}(x y)}.  If @expr{x}
22705  is a suitable multiple of  is a suitable multiple of
22706  @texline @tmath{\pi i}  @texline @math{\pi i}
22707  @infoline @expr{pi i}  @infoline @expr{pi i}
22708  (as described above for the trigonometric functions), then  (as described above for the trigonometric functions), then
22709  @expr{@t{exp}(x)} or @expr{e^x} will be expanded.  Finally,  @expr{@t{exp}(x)} or @expr{e^x} will be expanded.  Finally,
# Line 22795  are folded down to the 360-degree range Line 22788  are folded down to the 360-degree range
22788  functions always produce.  functions always produce.
22789    
22790  Powers of powers @expr{(x^a)^b} are simplified to  Powers of powers @expr{(x^a)^b} are simplified to
22791  @texline @tmath{x^{a b}}  @texline @math{x^{a b}}
22792  @infoline @expr{x^(a b)}  @infoline @expr{x^(a b)}
22793  for all @expr{a} and @expr{b}.  These results will be valid only  for all @expr{a} and @expr{b}.  These results will be valid only
22794  in a restricted range of @expr{x}; for example, in  in a restricted range of @expr{x}; for example, in
22795  @texline @tmath{(x^2)^{1:2}}  @texline @math{(x^2)^{1:2}}
22796  @infoline @expr{(x^2)^1:2}  @infoline @expr{(x^2)^1:2}
22797  the powers cancel to get @expr{x}, which is valid for positive values  the powers cancel to get @expr{x}, which is valid for positive values
22798  of @expr{x} but not for negative or complex values.  of @expr{x} but not for negative or complex values.
22799    
22800  Similarly, @expr{@t{sqrt}(x^a)} and @expr{@t{sqrt}(x)^a} are both  Similarly, @expr{@t{sqrt}(x^a)} and @expr{@t{sqrt}(x)^a} are both
22801  simplified (possibly unsafely) to  simplified (possibly unsafely) to
22802  @texline @tmath{x^{a/2}}.  @texline @math{x^{a/2}}.
22803  @infoline @expr{x^(a/2)}.  @infoline @expr{x^(a/2)}.
22804    
22805  Forms like @expr{@t{sqrt}(1 - sin(x)^2)} are simplified to, e.g.,  Forms like @expr{@t{sqrt}(1 - sin(x)^2)} are simplified to, e.g.,
# Line 22882  number for an answer, then the quotient Line 22875  number for an answer, then the quotient
22875  For powers and square roots, the ``unsafe'' simplifications  For powers and square roots, the ``unsafe'' simplifications
22876  @expr{(a b)^c} to @expr{a^c b^c}, @expr{(a/b)^c} to @expr{a^c / b^c},  @expr{(a b)^c} to @expr{a^c b^c}, @expr{(a/b)^c} to @expr{a^c / b^c},
22877  and @expr{(a^b)^c} to  and @expr{(a^b)^c} to
22878  @texline @tmath{a^{b c}}  @texline @math{a^{b c}}
22879  @infoline @expr{a^(b c)}  @infoline @expr{a^(b c)}
22880  are done if the powers are real numbers.  (These are safe in the context  are done if the powers are real numbers.  (These are safe in the context
22881  of units because all numbers involved can reasonably be assumed to be  of units because all numbers involved can reasonably be assumed to be
# Line 22897  is simplified by noting that @expr{1.5 = Line 22890  is simplified by noting that @expr{1.5 =
22890  is defined in terms of @samp{m^2}, and that the 2 in the power of  is defined in terms of @samp{m^2}, and that the 2 in the power of
22891  @code{m} is a multiple of 2 in @expr{3:2}.  Thus, @code{acre^1.5} is  @code{m} is a multiple of 2 in @expr{3:2}.  Thus, @code{acre^1.5} is
22892  replaced by approximately  replaced by approximately
22893  @texline @tmath{(4046 m^2)^{1.5}}  @texline @math{(4046 m^2)^{1.5}}
22894  @infoline @expr{(4046 m^2)^1.5},  @infoline @expr{(4046 m^2)^1.5},
22895  which is then changed to  which is then changed to
22896  @texline @tmath{4046^{1.5} \, (m^2)^{1.5}},  @texline @math{4046^{1.5} \, (m^2)^{1.5}},
22897  @infoline @expr{4046^1.5 (m^2)^1.5},  @infoline @expr{4046^1.5 (m^2)^1.5},
22898  then to @expr{257440 m^3}.  then to @expr{257440 m^3}.
22899    
# Line 23190  answer! Line 23183  answer!
23183  If you use the @code{deriv} function directly in an algebraic formula,  If you use the @code{deriv} function directly in an algebraic formula,
23184  you can write @samp{deriv(f,x,x0)} which represents the derivative  you can write @samp{deriv(f,x,x0)} which represents the derivative
23185  of @expr{f} with respect to @expr{x}, evaluated at the point  of @expr{f} with respect to @expr{x}, evaluated at the point
23186  @texline @tmath{x=x_0}.  @texline @math{x=x_0}.
23187  @infoline @expr{x=x0}.  @infoline @expr{x=x0}.
23188    
23189  If the formula being differentiated contains functions which Calc does  If the formula being differentiated contains functions which Calc does
# Line 23230  all integrable functions, but it is able Line 23223  all integrable functions, but it is able
23223  classes of formulas.  In particular, any polynomial or rational function  classes of formulas.  In particular, any polynomial or rational function
23224  (a polynomial divided by a polynomial) is acceptable.  (Rational functions  (a polynomial divided by a polynomial) is acceptable.  (Rational functions
23225  don't have to be in explicit quotient form, however;  don't have to be in explicit quotient form, however;
23226  @texline @tmath{x/(1+x^{-2})}  @texline @math{x/(1+x^{-2})}
23227  @infoline @expr{x/(1+x^-2)}  @infoline @expr{x/(1+x^-2)}
23228  is not strictly a quotient of polynomials, but it is equivalent to  is not strictly a quotient of polynomials, but it is equivalent to
23229  @expr{x^3/(x^2+1)}, which is.)  Also, square roots of terms involving  @expr{x^3/(x^2+1)}, which is.)  Also, square roots of terms involving
# Line 23256  integral $\int_a^b f(x) \, dx$. Line 23249  integral $\int_a^b f(x) \, dx$.
23249  Please note that the current implementation of Calc's integrator sometimes  Please note that the current implementation of Calc's integrator sometimes
23250  produces results that are significantly more complex than they need to  produces results that are significantly more complex than they need to
23251  be.  For example, the integral Calc finds for  be.  For example, the integral Calc finds for
23252  @texline @tmath{1/(x+\sqrt{x^2+1})}  @texline @math{1/(x+\sqrt{x^2+1})}
23253  @infoline @expr{1/(x+sqrt(x^2+1))}  @infoline @expr{1/(x+sqrt(x^2+1))}
23254  is several times more complicated than the answer Mathematica  is several times more complicated than the answer Mathematica
23255  returns for the same input, although the two forms are numerically  returns for the same input, although the two forms are numerically
# Line 23264  equivalent.  Also, any indefinite integr Line 23257  equivalent.  Also, any indefinite integr
23257  an arbitrary constant of integration added to it, although Calc does not  an arbitrary constant of integration added to it, although Calc does not
23258  write an explicit constant of integration in its result.  For example,  write an explicit constant of integration in its result.  For example,
23259  Calc's solution for  Calc's solution for
23260  @texline @tmath{1/(1+\tan x)}  @texline @math{1/(1+\tan x)}
23261  @infoline @expr{1/(1+tan(x))}  @infoline @expr{1/(1+tan(x))}
23262  differs from the solution given in the @emph{CRC Math Tables} by a  differs from the solution given in the @emph{CRC Math Tables} by a
23263  constant factor of    constant factor of  
23264  @texline @tmath{\pi i / 2}  @texline @math{\pi i / 2}
23265  @infoline @expr{pi i / 2},  @infoline @expr{pi i / 2},
23266  due to a different choice of constant of integration.  due to a different choice of constant of integration.
23267    
# Line 23328  in your @code{IntegRules}. Line 23321  in your @code{IntegRules}.
23321  As a more serious example, the expression @samp{exp(x)/x} cannot be  As a more serious example, the expression @samp{exp(x)/x} cannot be
23322  integrated in terms of the standard functions, so the ``exponential  integrated in terms of the standard functions, so the ``exponential
23323  integral'' function  integral'' function
23324  @texline @tmath{{\rm Ei}(x)}  @texline @math{{\rm Ei}(x)}
23325  @infoline @expr{Ei(x)}  @infoline @expr{Ei(x)}
23326  was invented to describe it.  was invented to describe it.
23327  We can get Calc to do this integral in terms of a made-up @code{Ei}  We can get Calc to do this integral in terms of a made-up @code{Ei}
# Line 23501  form @expr{X = 0}. Line 23494  form @expr{X = 0}.
23494  This command also works for inequalities, as in @expr{y < 3x + 6}.  This command also works for inequalities, as in @expr{y < 3x + 6}.
23495  Some inequalities cannot be solved where the analogous equation could  Some inequalities cannot be solved where the analogous equation could
23496  be; for example, solving  be; for example, solving
23497  @texline @tmath{a < b \, c}  @texline @math{a < b \, c}
23498  @infoline @expr{a < b c}  @infoline @expr{a < b c}
23499  for @expr{b} is impossible  for @expr{b} is impossible
23500  without knowing the sign of @expr{c}.  In this case, @kbd{a S} will  without knowing the sign of @expr{c}.  In this case, @kbd{a S} will
23501  produce the result  produce the result
23502  @texline @tmath{b \mathbin{\hbox{\code{!=}}} a/c}  @texline @math{b \mathbin{\hbox{\code{!=}}} a/c}
23503  @infoline @expr{b != a/c}  @infoline @expr{b != a/c}
23504  (using the not-equal-to operator) to signify that the direction of the  (using the not-equal-to operator) to signify that the direction of the
23505  inequality is now unknown.  The inequality  inequality is now unknown.  The inequality
23506  @texline @tmath{a \le b \, c}  @texline @math{a \le b \, c}
23507  @infoline @expr{a <= b c}  @infoline @expr{a <= b c}
23508  is not even partially solved.  @xref{Declarations}, for a way to tell  is not even partially solved.  @xref{Declarations}, for a way to tell
23509  Calc that the signs of the variables in a formula are in fact known.  Calc that the signs of the variables in a formula are in fact known.
# Line 23537  Some equations have more than one soluti Line 23530  Some equations have more than one soluti
23530  general family of solutions.  It will invent variables @code{n1},  general family of solutions.  It will invent variables @code{n1},
23531  @code{n2}, @dots{}, which represent independent arbitrary integers, and  @code{n2}, @dots{}, which represent independent arbitrary integers, and
23532  @code{s1}, @code{s2}, @dots{}, which represent independent arbitrary  @code{s1}, @code{s2}, @dots{}, which represent independent arbitrary
23533  signs (either @i{+1} or @i{-1}).  If you don't use the Hyperbolic  signs (either @mathit{+1} or @mathit{-1}).  If you don't use the Hyperbolic
23534  flag, Calc will use zero in place of all arbitrary integers, and plus  flag, Calc will use zero in place of all arbitrary integers, and plus
23535  one in place of all arbitrary signs.  Note that variables like @code{n1}  one in place of all arbitrary signs.  Note that variables like @code{n1}
23536  and @code{s1} are not given any special interpretation in Calc except by  and @code{s1} are not given any special interpretation in Calc except by
# Line 23970  with the minimum value itself. Line 23963  with the minimum value itself.
23963    
23964  Note that this command looks for a @emph{local} minimum.  Many functions  Note that this command looks for a @emph{local} minimum.  Many functions
23965  have more than one minimum; some, like  have more than one minimum; some, like
23966  @texline @tmath{x \sin x},  @texline @math{x \sin x},
23967  @infoline @expr{x sin(x)},  @infoline @expr{x sin(x)},
23968  have infinitely many.  In fact, there is no easy way to define the  have infinitely many.  In fact, there is no easy way to define the
23969  ``global'' minimum of  ``global'' minimum of
23970  @texline @tmath{x \sin x}  @texline @math{x \sin x}
23971  @infoline @expr{x sin(x)}  @infoline @expr{x sin(x)}
23972  but Calc can still locate any particular local minimum  but Calc can still locate any particular local minimum
23973  for you.  Calc basically goes downhill from the initial guess until it  for you.  Calc basically goes downhill from the initial guess until it
# Line 24097  the @dfn{parameters} of the model. Line 24090  the @dfn{parameters} of the model.
24090  The @kbd{a F} command takes the data set to be fitted from the stack.  The @kbd{a F} command takes the data set to be fitted from the stack.
24091  By default, it expects the data in the form of a matrix.  For example,  By default, it expects the data in the form of a matrix.  For example,
24092  for a linear or polynomial fit, this would be a  for a linear or polynomial fit, this would be a
24093  @texline @tmath{2\times N}  @texline @math{2\times N}
24094  @infoline 2xN  @infoline 2xN
24095  matrix where the first row is a list of @expr{x} values and the second  matrix where the first row is a list of @expr{x} values and the second
24096  row has the corresponding @expr{y} values.  For the multilinear fit  row has the corresponding @expr{y} values.  For the multilinear fit
# Line 24105  shown above, the matrix would have four Line 24098  shown above, the matrix would have four
24098  @expr{x_3}, and @expr{y}, respectively).  @expr{x_3}, and @expr{y}, respectively).
24099    
24100  If you happen to have an  If you happen to have an
24101  @texline @tmath{N\times2}  @texline @math{N\times2}
24102  @infoline Nx2  @infoline Nx2
24103  matrix instead of a  matrix instead of a
24104  @texline @tmath{2\times N}  @texline @math{2\times N}
24105  @infoline 2xN  @infoline 2xN
24106  matrix, just press @kbd{v t} first to transpose the matrix.  matrix, just press @kbd{v t} first to transpose the matrix.
24107    
# Line 24206  which is clearly zero if @expr{a + b x} Line 24199  which is clearly zero if @expr{a + b x}
24199  and increases as various @expr{a + b x_i} values fail to match the  and increases as various @expr{a + b x_i} values fail to match the
24200  corresponding @expr{y_i} values.  There are several reasons why the  corresponding @expr{y_i} values.  There are several reasons why the
24201  summand is squared, one of them being to ensure that  summand is squared, one of them being to ensure that
24202  @texline @tmath{\chi^2 \ge 0}.  @texline @math{\chi^2 \ge 0}.
24203  @infoline @expr{chi^2 >= 0}.  @infoline @expr{chi^2 >= 0}.
24204  Least-squares fitting simply chooses the values of @expr{a} and @expr{b}  Least-squares fitting simply chooses the values of @expr{a} and @expr{b}
24205  for which the error  for which the error
24206  @texline @tmath{\chi^2}  @texline @math{\chi^2}
24207  @infoline @expr{chi^2}  @infoline @expr{chi^2}
24208  is as small as possible.  is as small as possible.
24209    
# Line 24266  line slightly to improve the fit. Line 24259  line slightly to improve the fit.
24259    
24260  An important result from the theory of polynomial fitting is that it  An important result from the theory of polynomial fitting is that it
24261  is always possible to fit @var{n} data points exactly using a polynomial  is always possible to fit @var{n} data points exactly using a polynomial
24262  of degree @i{@var{n}-1}, sometimes called an @dfn{interpolating polynomial}.  of degree @mathit{@var{n}-1}, sometimes called an @dfn{interpolating polynomial}.
24263  Using the modified (14) data matrix, a model number of 4 gives  Using the modified (14) data matrix, a model number of 4 gives
24264  a polynomial that exactly matches all five data points:  a polynomial that exactly matches all five data points:
24265    
# Line 24371  contain error forms.  The data values mu Line 24364  contain error forms.  The data values mu
24364  or all be plain numbers.  Error forms can go anywhere but generally  or all be plain numbers.  Error forms can go anywhere but generally
24365  go on the numbers in the last row of the data matrix.  If the last  go on the numbers in the last row of the data matrix.  If the last
24366  row contains error forms  row contains error forms
24367  @texline `@var{y_i}@w{ @t{+/-} }@tmath{\sigma_i}',  @texline `@var{y_i}@w{ @t{+/-} }@math{\sigma_i}',
24368  @infoline `@var{y_i}@w{ @t{+/-} }@var{sigma_i}',  @infoline `@var{y_i}@w{ @t{+/-} }@var{sigma_i}',
24369  then the  then the
24370  @texline @tmath{\chi^2}  @texline @math{\chi^2}
24371  @infoline @expr{chi^2}  @infoline @expr{chi^2}
24372  statistic is now,  statistic is now,
24373    
# Line 24397  the fitting operation. Line 24390  the fitting operation.
24390  If there are error forms on other rows of the data matrix, all the  If there are error forms on other rows of the data matrix, all the
24391  errors for a given data point are combined; the square root of the  errors for a given data point are combined; the square root of the
24392  sum of the squares of the errors forms the  sum of the squares of the errors forms the
24393  @texline @tmath{\sigma_i}  @texline @math{\sigma_i}
24394  @infoline @expr{sigma_i}  @infoline @expr{sigma_i}
24395  used for the data point.  used for the data point.
24396    
# Line 24407  probably use @kbd{H a F} so that the out Line 24400  probably use @kbd{H a F} so that the out
24400  estimates.  estimates.
24401    
24402  If the input contains error forms but all the  If the input contains error forms but all the
24403  @texline @tmath{\sigma_i}  @texline @math{\sigma_i}
24404  @infoline @expr{sigma_i}  @infoline @expr{sigma_i}
24405  values are the same, it is easy to see that the resulting fitted model  values are the same, it is easy to see that the resulting fitted model
24406  will be the same as if the input did not have error forms at all  will be the same as if the input did not have error forms at all
24407  @texline (@tmath{\chi^2}  @texline (@math{\chi^2}
24408  @infoline (@expr{chi^2}  @infoline (@expr{chi^2}
24409  is simply scaled uniformly by  is simply scaled uniformly by
24410  @texline @tmath{1 / \sigma^2},  @texline @math{1 / \sigma^2},
24411  @infoline @expr{1 / sigma^2},  @infoline @expr{1 / sigma^2},
24412  which doesn't affect where it has a minimum).  But there @emph{will} be  which doesn't affect where it has a minimum).  But there @emph{will} be
24413  a difference in the estimated errors of the coefficients reported by  a difference in the estimated errors of the coefficients reported by
# Line 24449  will have length @expr{M = d+1} with the Line 24442  will have length @expr{M = d+1} with the
24442  @item  @item
24443  The covariance matrix @expr{C} computed from the fit.  This is  The covariance matrix @expr{C} computed from the fit.  This is
24444  an @var{m}x@var{m} symmetric matrix; the diagonal elements  an @var{m}x@var{m} symmetric matrix; the diagonal elements
24445  @texline @tmath{C_{jj}}  @texline @math{C_{jj}}
24446  @infoline @expr{C_j_j}  @infoline @expr{C_j_j}
24447  are the variances  are the variances
24448  @texline @tmath{\sigma_j^2}  @texline @math{\sigma_j^2}
24449  @infoline @expr{sigma_j^2}  @infoline @expr{sigma_j^2}
24450  of the parameters.  The other elements are covariances  of the parameters.  The other elements are covariances
24451  @texline @tmath{\sigma_{ij}^2}  @texline @math{\sigma_{ij}^2}
24452  @infoline @expr{sigma_i_j^2}  @infoline @expr{sigma_i_j^2}
24453  that describe the correlation between pairs of parameters.  (A related  that describe the correlation between pairs of parameters.  (A related
24454  set of numbers, the @dfn{linear correlation coefficients}  set of numbers, the @dfn{linear correlation coefficients}
24455  @texline @tmath{r_{ij}},  @texline @math{r_{ij}},
24456  @infoline @expr{r_i_j},  @infoline @expr{r_i_j},
24457  are defined as  are defined as
24458  @texline @tmath{\sigma_{ij}^2 / \sigma_i \, \sigma_j}.)  @texline @math{\sigma_{ij}^2 / \sigma_i \, \sigma_j}.)
24459  @infoline @expr{sigma_i_j^2 / sigma_i sigma_j}.)  @infoline @expr{sigma_i_j^2 / sigma_i sigma_j}.)
24460    
24461  @item  @item
# Line 24473  polynomial and multilinear fits describe Line 24466  polynomial and multilinear fits describe
24466    
24467  @item  @item
24468  The value of  The value of
24469  @texline @tmath{\chi^2}  @texline @math{\chi^2}
24470  @infoline @expr{chi^2}  @infoline @expr{chi^2}
24471  for the fit, calculated by the formulas shown above.  This gives a  for the fit, calculated by the formulas shown above.  This gives a
24472  measure of the quality of the fit; statisticians consider  measure of the quality of the fit; statisticians consider
24473  @texline @tmath{\chi^2 \approx N - M}  @texline @math{\chi^2 \approx N - M}
24474  @infoline @expr{chi^2 = N - M}  @infoline @expr{chi^2 = N - M}
24475  to indicate a moderately good fit (where again @expr{N} is the number of  to indicate a moderately good fit (where again @expr{N} is the number of
24476  data points and @expr{M} is the number of parameters).  data points and @expr{M} is the number of parameters).
# Line 24486  data points and @expr{M} is the number o Line 24479  data points and @expr{M} is the number o
24479  A measure of goodness of fit expressed as a probability @expr{Q}.  A measure of goodness of fit expressed as a probability @expr{Q}.
24480  This is computed from the @code{utpc} probability distribution  This is computed from the @code{utpc} probability distribution
24481  function using  function using
24482  @texline @tmath{\chi^2}  @texline @math{\chi^2}
24483  @infoline @expr{chi^2}  @infoline @expr{chi^2}
24484  with @expr{N - M} degrees of freedom.  A  with @expr{N - M} degrees of freedom.  A
24485  value of 0.5 implies a good fit; some texts recommend that often  value of 0.5 implies a good fit; some texts recommend that often
24486  @expr{Q = 0.1} or even 0.001 can signify an acceptable fit.  In  @expr{Q = 0.1} or even 0.001 can signify an acceptable fit.  In
24487  particular,  particular,
24488  @texline @tmath{\chi^2}  @texline @math{\chi^2}
24489  @infoline @expr{chi^2}  @infoline @expr{chi^2}
24490  statistics assume the errors in your inputs  statistics assume the errors in your inputs
24491  follow a normal (Gaussian) distribution; if they don't, you may  follow a normal (Gaussian) distribution; if they don't, you may
# Line 24501  have to accept smaller values of @expr{Q Line 24494  have to accept smaller values of @expr{Q
24494  The @expr{Q} value is computed only if the input included error  The @expr{Q} value is computed only if the input included error
24495  estimates.  Otherwise, Calc will report the symbol @code{nan}  estimates.  Otherwise, Calc will report the symbol @code{nan}
24496  for @expr{Q}.  The reason is that in this case the  for @expr{Q}.  The reason is that in this case the
24497  @texline @tmath{\chi^2}  @texline @math{\chi^2}
24498  @infoline @expr{chi^2}  @infoline @expr{chi^2}
24499  value has effectively been used to estimate the original errors  value has effectively been used to estimate the original errors
24500  in the input, and thus there is no redundant information left  in the input, and thus there is no redundant information left
# Line 24520  Here is a complete list of the standard Line 24513  Here is a complete list of the standard
24513    
24514  @table @kbd  @table @kbd
24515  @item 1  @item 1
24516  Linear or multilinear.  @i{a + b x + c y + d z}.  Linear or multilinear.  @mathit{a + b x + c y + d z}.
24517  @item 2-9  @item 2-9
24518  Polynomials.  @i{a + b x + c x^2 + d x^3}.  Polynomials.  @mathit{a + b x + c x^2 + d x^3}.
24519  @item e  @item e
24520  Exponential.  @i{a} @t{exp}@i{(b x)} @t{exp}@i{(c y)}.  Exponential.  @mathit{a} @t{exp}@mathit{(b x)} @t{exp}@mathit{(c y)}.
24521  @item E  @item E
24522  Base-10 exponential.  @i{a} @t{10^}@i{(b x)} @t{10^}@i{(c y)}.  Base-10 exponential.  @mathit{a} @t{10^}@mathit{(b x)} @t{10^}@mathit{(c y)}.
24523  @item x  @item x
24524  Exponential (alternate notation).  @t{exp}@i{(a + b x + c y)}.  Exponential (alternate notation).  @t{exp}@mathit{(a + b x + c y)}.
24525  @item X  @item X
24526  Base-10 exponential (alternate).  @t{10^}@i{(a + b x + c y)}.  Base-10 exponential (alternate).  @t{10^}@mathit{(a + b x + c y)}.
24527  @item l  @item l
24528  Logarithmic.  @i{a + b} @t{ln}@i{(x) + c} @t{ln}@i{(y)}.  Logarithmic.  @mathit{a + b} @t{ln}@mathit{(x) + c} @t{ln}@mathit{(y)}.
24529  @item L  @item L
24530  Base-10 logarithmic.  @i{a + b} @t{log10}@i{(x) + c} @t{log10}@i{(y)}.  Base-10 logarithmic.  @mathit{a + b} @t{log10}@mathit{(x) + c} @t{log10}@mathit{(y)}.
24531  @item ^  @item ^
24532  General exponential.  @i{a b^x c^y}.  General exponential.  @mathit{a b^x c^y}.
24533  @item p  @item p
24534  Power law.  @i{a x^b y^c}.  Power law.  @mathit{a x^b y^c}.
24535  @item q  @item q
24536  Quadratic.  @i{a + b (x-c)^2 + d (x-e)^2}.  Quadratic.  @mathit{a + b (x-c)^2 + d (x-e)^2}.
24537  @item g  @item g
24538  Gaussian.    Gaussian.  
24539  @texline @tmath{{a \over b \sqrt{2 \pi}} \exp\left( -{1 \over 2} \left( x - c \over b \right)^2 \right)}.  @texline @math{{a \over b \sqrt{2 \pi}} \exp\left( -{1 \over 2} \left( x - c \over b \right)^2 \right)}.
24540  @infoline @i{(a / b sqrt(2 pi)) exp(-0.5*((x-c)/b)^2)}.  @infoline @mathit{(a / b sqrt(2 pi)) exp(-0.5*((x-c)/b)^2)}.
24541  @end table  @end table
24542    
24543  All of these models are used in the usual way; just press the appropriate  All of these models are used in the usual way; just press the appropriate
# Line 24656  Calc uses the principal values of invers Line 24649  Calc uses the principal values of invers
24649  and @code{arcsin} when doing fits.  For example, when you enter  and @code{arcsin} when doing fits.  For example, when you enter
24650  the model @samp{y = sin(a t + b)} Calc actually uses the easier  the model @samp{y = sin(a t + b)} Calc actually uses the easier
24651  form @samp{arcsin(y) = a t + b}.  The @code{arcsin} function always  form @samp{arcsin(y) = a t + b}.  The @code{arcsin} function always
24652  returns results in the range from @i{-90} to 90 degrees (or the  returns results in the range from @mathit{-90} to 90 degrees (or the
24653  equivalent range in radians).  Suppose you had data that you  equivalent range in radians).  Suppose you had data that you
24654  believed to represent roughly three oscillations of a sine wave,  believed to represent roughly three oscillations of a sine wave,
24655  so that the argument of the sine might go from zero to  so that the argument of the sine might go from zero to
24656  @texline @tmath{3\times360}  @texline @math{3\times360}
24657  @infoline @i{3*360}  @infoline @mathit{3*360}
24658  degrees.  degrees.
24659  The above model would appear to be a good way to determine the  The above model would appear to be a good way to determine the
24660  true frequency and phase of the sine wave, but in practice it  true frequency and phase of the sine wave, but in practice it
24661  would fail utterly.  The righthand side of the actual model  would fail utterly.  The righthand side of the actual model
24662  @samp{arcsin(y) = a t + b} will grow smoothly with @expr{t}, but  @samp{arcsin(y) = a t + b} will grow smoothly with @expr{t}, but
24663  the lefthand side will bounce back and forth between @i{-90} and 90.  the lefthand side will bounce back and forth between @mathit{-90} and 90.
24664  No values of @expr{a} and @expr{b} can make the two sides match,  No values of @expr{a} and @expr{b} can make the two sides match,
24665  even approximately.  even approximately.
24666    
# Line 24722  ln(y) = ln(a) + b ln(x) Line 24715  ln(y) = ln(a) + b ln(x)
24715    
24716  @noindent  @noindent
24717  which matches the desired form with  which matches the desired form with
24718  @texline @tmath{Y = \ln(y)},  @texline @math{Y = \ln(y)},
24719  @infoline @expr{Y = ln(y)},  @infoline @expr{Y = ln(y)},
24720  @texline @tmath{A = \ln(a)},  @texline @math{A = \ln(a)},
24721  @infoline @expr{A = ln(a)},  @infoline @expr{A = ln(a)},
24722  @expr{F = 1}, @expr{B = b}, and  @expr{F = 1}, @expr{B = b}, and
24723  @texline @tmath{G = \ln(x)}.  @texline @math{G = \ln(x)}.
24724  @infoline @expr{G = ln(x)}.    @infoline @expr{G = ln(x)}.  
24725  Calc thus computes the logarithms of your @expr{y} and @expr{x} values,  Calc thus computes the logarithms of your @expr{y} and @expr{x} values,
24726  does a linear fit for @expr{A} and @expr{B}, then solves to get  does a linear fit for @expr{A} and @expr{B}, then solves to get
24727  @texline @tmath{a = \exp(A)}  @texline @math{a = \exp(A)}
24728  @infoline @expr{a = exp(A)}  @infoline @expr{a = exp(A)}
24729  and @expr{b = B}.  and @expr{b = B}.
24730    
# Line 24745  y = a + b c^2 - 2 b c x + b x^2 Line 24738  y = a + b c^2 - 2 b c x + b x^2
24738    
24739  @noindent  @noindent
24740  which matches with @expr{Y = y}, @expr{A = a + b c^2}, @expr{F = 1},  which matches with @expr{Y = y}, @expr{A = a + b c^2}, @expr{F = 1},
24741  @expr{B = -2 b c}, @expr{G = x} (the @i{-2} factor could just as easily  @expr{B = -2 b c}, @expr{G = x} (the @mathit{-2} factor could just as easily
24742  have been put into @expr{G} instead of @expr{B}), @expr{C = b}, and  have been put into @expr{G} instead of @expr{B}), @expr{C = b}, and
24743  @expr{H = x^2}.  @expr{H = x^2}.
24744    
# Line 24777  from the list of parameters when you ans Line 24770  from the list of parameters when you ans
24770  A last desperate step would be to use the general-purpose  A last desperate step would be to use the general-purpose
24771  @code{minimize} function rather than @code{fit}.  After all, both  @code{minimize} function rather than @code{fit}.  After all, both
24772  functions solve the problem of minimizing an expression (the  functions solve the problem of minimizing an expression (the
24773  @texline @tmath{\chi^2}  @texline @math{\chi^2}
24774  @infoline @expr{chi^2}  @infoline @expr{chi^2}
24775  sum) by adjusting certain parameters in the expression.  The @kbd{a F}  sum) by adjusting certain parameters in the expression.  The @kbd{a F}
24776  command is able to use a vastly more efficient algorithm due to its  command is able to use a vastly more efficient algorithm due to its
# Line 24788  A compromise would be to pick out a few Line 24781  A compromise would be to pick out a few
24781  fit is linearizable, and use @code{minimize} on a call to @code{fit}  fit is linearizable, and use @code{minimize} on a call to @code{fit}
24782  which efficiently takes care of the rest of the parameters.  The thing  which efficiently takes care of the rest of the parameters.  The thing
24783  to be minimized would be the value of  to be minimized would be the value of
24784  @texline @tmath{\chi^2}  @texline @math{\chi^2}
24785  @infoline @expr{chi^2}  @infoline @expr{chi^2}
24786  returned as the fifth result of the @code{xfit} function:  returned as the fifth result of the @code{xfit} function:
24787    
# Line 24848  and @expr{y} to be plain numbers, and ma Line 24841  and @expr{y} to be plain numbers, and ma
24841  form with this combined error.  The @expr{Y(x,y,z)} part of the  form with this combined error.  The @expr{Y(x,y,z)} part of the
24842  linearized model is evaluated, and the result should be an error  linearized model is evaluated, and the result should be an error
24843  form.  The error part of that result is used for  form.  The error part of that result is used for
24844  @texline @tmath{\sigma_i}  @texline @math{\sigma_i}
24845  @infoline @expr{sigma_i}  @infoline @expr{sigma_i}
24846  for the data point.  If for some reason @expr{Y(x,y,z)} does not return  for the data point.  If for some reason @expr{Y(x,y,z)} does not return
24847  an error form, the combined error from @expr{z} is used directly for  an error form, the combined error from @expr{z} is used directly for
24848  @texline @tmath{\sigma_i}.  @texline @math{\sigma_i}.
24849  @infoline @expr{sigma_i}.    @infoline @expr{sigma_i}.  
24850  Finally, @expr{z} is also stripped of its error  Finally, @expr{z} is also stripped of its error
24851  for use in computing @expr{F(x,y,z)}, @expr{G(x,y,z)} and so on;  for use in computing @expr{F(x,y,z)}, @expr{G(x,y,z)} and so on;
# Line 24864  the most reasonable thing in the typical Line 24857  the most reasonable thing in the typical
24857  depends only on the dependent variable @expr{z}, and in fact is  depends only on the dependent variable @expr{z}, and in fact is
24858  often simply equal to @expr{z}.  For common cases like polynomials  often simply equal to @expr{z}.  For common cases like polynomials
24859  and multilinear models, the combined error is simply used as the  and multilinear models, the combined error is simply used as the
24860  @texline @tmath{\sigma}  @texline @math{\sigma}
24861  @infoline @expr{sigma}  @infoline @expr{sigma}
24862  for the data point with no further ado.)  for the data point with no further ado.)
24863    
# Line 25218  If the lower limit is greater than the u Line 25211  If the lower limit is greater than the u
25211  positive step size), the result is generally zero.  However,  positive step size), the result is generally zero.  However,
25212  Calc only guarantees a zero result when the upper limit is  Calc only guarantees a zero result when the upper limit is
25213  exactly one step less than the lower limit, i.e., if the number  exactly one step less than the lower limit, i.e., if the number
25214  of iterations is @i{-1}.  Thus @samp{sum(f(k), k, n, n-1)} is zero  of iterations is @mathit{-1}.  Thus @samp{sum(f(k), k, n, n-1)} is zero
25215  but the sum from @samp{n} to @samp{n-2} may report a nonzero value  but the sum from @samp{n} to @samp{n-2} may report a nonzero value
25216  if Calc used a closed form solution.  if Calc used a closed form solution.
25217    
# Line 25244  formula works out to the indeterminate f Line 25237  formula works out to the indeterminate f
25237  Calc will not assume is zero.  Better would be to use  Calc will not assume is zero.  Better would be to use
25238  @samp{(k != k_0) ? 1/(k-k_0) : 0}; the @samp{? :} operator does  @samp{(k != k_0) ? 1/(k-k_0) : 0}; the @samp{? :} operator does
25239  an ``if-then-else'' test:  This expression says, ``if  an ``if-then-else'' test:  This expression says, ``if
25240  @texline @tmath{k \ne k_0},  @texline @math{k \ne k_0},
25241  @infoline @expr{k != k_0},  @infoline @expr{k != k_0},
25242  then @expr{1/(k-k_0)}, else zero.''  Now the formula @expr{1/(k-k_0)}  then @expr{1/(k-k_0)}, else zero.''  Now the formula @expr{1/(k-k_0)}
25243  will not even be evaluated by Calc when @expr{k = k_0}.  will not even be evaluated by Calc when @expr{k = k_0}.
# Line 26259  then the rule set @samp{[f(0) := 0, impo Line 26252  then the rule set @samp{[f(0) := 0, impo
26252  all three rules.  It is possible to modify the imported rules  all three rules.  It is possible to modify the imported rules
26253  slightly:  @samp{import(x, v1, x1, v2, x2, @dots{})} imports  slightly:  @samp{import(x, v1, x1, v2, x2, @dots{})} imports
26254  the rule set @expr{x} with all occurrences of  the rule set @expr{x} with all occurrences of
26255  @texline @tmath{v_1},  @texline @math{v_1},
26256  @infoline @expr{v1},  @infoline @expr{v1},
26257  as either a variable name or a function name, replaced with  as either a variable name or a function name, replaced with
26258  @texline @tmath{x_1}  @texline @math{x_1}
26259  @infoline @expr{x1}  @infoline @expr{x1}
26260  and so on.  (If  and so on.  (If
26261  @texline @tmath{v_1}  @texline @math{v_1}
26262  @infoline @expr{v1}  @infoline @expr{v1}
26263  is used as a function name, then  is used as a function name, then
26264  @texline @tmath{x_1}  @texline @math{x_1}
26265  @infoline @expr{x1}  @infoline @expr{x1}
26266  must be either a function name itself or a @w{@samp{< >}} nameless  must be either a function name itself or a @w{@samp{< >}} nameless
26267  function; @pxref{Specifying Operators}.)  For example, @samp{[g(0) := 0,  function; @pxref{Specifying Operators}.)  For example, @samp{[g(0) := 0,
# Line 27734  in its normal terms, and @kbd{u b} expre Line 27727  in its normal terms, and @kbd{u b} expre
27727  units.  units.
27728    
27729  Two units, @code{pi} and @code{fsc} (the fine structure constant,  Two units, @code{pi} and @code{fsc} (the fine structure constant,
27730  approximately @i{1/137}) are dimensionless.  The units simplification  approximately @mathit{1/137}) are dimensionless.  The units simplification
27731  commands simply treat these names as equivalent to their corresponding  commands simply treat these names as equivalent to their corresponding
27732  values.  However you can, for example, use @kbd{u c} to convert a pure  values.  However you can, for example, use @kbd{u c} to convert a pure
27733  number into multiples of the fine structure constant, or @kbd{u b} to  number into multiples of the fine structure constant, or @kbd{u b} to
# Line 27951  All the arithmetic stores accept the Inv Line 27944  All the arithmetic stores accept the Inv
27944  order of the operands.  If @expr{v} represents the contents of the  order of the operands.  If @expr{v} represents the contents of the
27945  variable, and @expr{a} is the value drawn from the stack, then regular  variable, and @expr{a} is the value drawn from the stack, then regular
27946  @w{@kbd{s -}} assigns  @w{@kbd{s -}} assigns
27947  @texline @tmath{v \coloneq v - a},  @texline @math{v \coloneq v - a},
27948  @infoline @expr{v := v - a},  @infoline @expr{v := v - a},
27949  but @kbd{I s -} assigns  but @kbd{I s -} assigns
27950  @texline @tmath{v \coloneq a - v}.  @texline @math{v \coloneq a - v}.
27951  @infoline @expr{v := a - v}.    @infoline @expr{v := a - v}.  
27952  While @kbd{I s *} might seem pointless, it is  While @kbd{I s *} might seem pointless, it is
27953  useful if matrix multiplication is involved.  Actually, all the  useful if matrix multiplication is involved.  Actually, all the
# Line 28541  the same length); either or both may ins Line 28534  the same length); either or both may ins
28534  ``z'' value must be a matrix with the same number of rows as elements  ``z'' value must be a matrix with the same number of rows as elements
28535  in ``x'', and the same number of columns as elements in ``y''.  The  in ``x'', and the same number of columns as elements in ``y''.  The
28536  result is a surface plot where  result is a surface plot where
28537  @texline @tmath{z_{ij}}  @texline @math{z_{ij}}
28538  @infoline @expr{z_ij}  @infoline @expr{z_ij}
28539  is the height of the point  is the height of the point
28540  at coordinate @expr{(x_i, y_j)} on the surface.  The 3D graph will  at coordinate @expr{(x_i, y_j)} on the surface.  The 3D graph will
# Line 28652  values covered by all the curves ought t Line 28645  values covered by all the curves ought t
28645  they are to look nice on the same graph.)  they are to look nice on the same graph.)
28646    
28647  For example, to plot  For example, to plot
28648  @texline @tmath{\sin n x}  @texline @math{\sin n x}
28649  @infoline @expr{sin(n x)}  @infoline @expr{sin(n x)}
28650  for integers @expr{n}  for integers @expr{n}
28651  from 1 to 5, you could use @kbd{v x} to create a vector of integers  from 1 to 5, you could use @kbd{v x} to create a vector of integers
# Line 28903  values, but if you store a vector of int Line 28896  values, but if you store a vector of int
28896  the @kbd{g a} and @kbd{g f} commands will use those style numbers  the @kbd{g a} and @kbd{g f} commands will use those style numbers
28897  instead of the defaults for new curves that are added to the graph.  instead of the defaults for new curves that are added to the graph.
28898  An entry should be a positive integer for a specific style, or 0 to let  An entry should be a positive integer for a specific style, or 0 to let
28899  the style be chosen automatically, or @i{-1} to turn off lines or points  the style be chosen automatically, or @mathit{-1} to turn off lines or points
28900  altogether.  If there are more curves than elements in the vector, the  altogether.  If there are more curves than elements in the vector, the
28901  last few curves will continue to have the default styles.  Of course,  last few curves will continue to have the default styles.  Of course,
28902  you can later use @kbd{g s} and @kbd{g S} to change any of these styles.  you can later use @kbd{g s} and @kbd{g S} to change any of these styles.
# Line 28942  picture of the graph composed of charact Line 28935  picture of the graph composed of charact
28935  to a buffer called @samp{*Gnuplot Trail*}, which Calc then displays.  to a buffer called @samp{*Gnuplot Trail*}, which Calc then displays.
28936  The graph is made the same size as the Emacs screen, which on most  The graph is made the same size as the Emacs screen, which on most
28937  dumb terminals will be  dumb terminals will be
28938  @texline @tmath{80\times24}  @texline @math{80\times24}
28939  @infoline 80x24  @infoline 80x24
28940  characters.  The graph is displayed in  characters.  The graph is displayed in
28941  an Emacs ``recursive edit''; type @kbd{q} or @kbd{M-# M-#} to exit  an Emacs ``recursive edit''; type @kbd{q} or @kbd{M-# M-#} to exit
# Line 29252  would correctly split the line into two Line 29245  would correctly split the line into two
29245    
29246  @xref{Matrix Functions}, to see how to pull the matrix apart into its  @xref{Matrix Functions}, to see how to pull the matrix apart into its
29247  constituent rows and columns.  (If it is a  constituent rows and columns.  (If it is a
29248  @texline @tmath{1\times1}  @texline @math{1\times1}
29249  @infoline 1x1  @infoline 1x1
29250  matrix, just hit @kbd{v u} (@code{calc-unpack}) twice.)  matrix, just hit @kbd{v u} (@code{calc-unpack}) twice.)
29251    
# Line 29590  same limit as last time. Line 29583  same limit as last time.
29583  @key{INV GCD} computes the LCM (least common multiple) function.  @key{INV GCD} computes the LCM (least common multiple) function.
29584    
29585  @key{INV FACT} is the gamma function.    @key{INV FACT} is the gamma function.  
29586  @texline @tmath{\Gamma(x) = (x-1)!}.  @texline @math{\Gamma(x) = (x-1)!}.
29587  @infoline @expr{gamma(x) = (x-1)!}.  @infoline @expr{gamma(x) = (x-1)!}.
29588    
29589  @key{PERM} is the number-of-permutations function, which is on the  @key{PERM} is the number-of-permutations function, which is on the
# Line 31018  forced to use upward-counting convention Line 31011  forced to use upward-counting convention
31011  is greater than @var{final} the body will not be executed at all.  is greater than @var{final} the body will not be executed at all.
31012  Note that @var{step} may still be negative in this loop; the prefix  Note that @var{step} may still be negative in this loop; the prefix
31013  argument merely constrains the loop-finished test.  Likewise, a prefix  argument merely constrains the loop-finished test.  Likewise, a prefix
31014  argument of @i{-1} forces downward-counting conventions.  argument of @mathit{-1} forces downward-counting conventions.
31015    
31016  @kindex Z @{  @kindex Z @{
31017  @kindex Z @}  @kindex Z @}
# Line 31989  same thing with a single division by 512 Line 31982  same thing with a single division by 512
31982  @tindex mysin  @tindex mysin
31983  A somewhat limited sine function could be defined as follows, using the  A somewhat limited sine function could be defined as follows, using the
31984  well-known Taylor series expansion for  well-known Taylor series expansion for
31985  @texline @tmath{\sin x}:  @texline @math{\sin x}:
31986  @infoline @samp{sin(x)}:  @infoline @samp{sin(x)}:
31987    
31988  @smallexample  @smallexample
# Line 32512  which is not a Lisp list. Line 32505  which is not a Lisp list.
32505  Large integers are stored as lists of the form @samp{(bigpos @var{d0}  Large integers are stored as lists of the form @samp{(bigpos @var{d0}
32506  @var{d1} @var{d2} @dots{})} for positive integers 1000000 or more, or  @var{d1} @var{d2} @dots{})} for positive integers 1000000 or more, or
32507  @samp{(bigneg @var{d0} @var{d1} @var{d2} @dots{})} for negative integers  @samp{(bigneg @var{d0} @var{d1} @var{d2} @dots{})} for negative integers
32508  @i{-1000000} or less.  Each @var{d} is a base-1000 ``digit,'' a Lisp integer  @mathit{-1000000} or less.  Each @var{d} is a base-1000 ``digit,'' a Lisp integer
32509  from 0 to 999.  The least significant digit is @var{d0}; the last digit,  from 0 to 999.  The least significant digit is @var{d0}; the last digit,
32510  @var{dn}, which is always nonzero, is the most significant digit.  For  @var{dn}, which is always nonzero, is the most significant digit.  For
32511  example, the integer @i{-12345678} is stored as @samp{(bigneg 678 345 12)}.  example, the integer @mathit{-12345678} is stored as @samp{(bigneg 678 345 12)}.
32512    
32513  The distinction between small and large integers is entirely hidden from  The distinction between small and large integers is entirely hidden from
32514  the user.  In @code{defmath} definitions, the Lisp predicate @code{integerp}  the user.  In @code{defmath} definitions, the Lisp predicate @code{integerp}
# Line 32536  Floating-point numbers are stored in the Line 32529  Floating-point numbers are stored in the
32529  @samp{10^@var{p}} in absolute value (@var{p} represents the current  @samp{10^@var{p}} in absolute value (@var{p} represents the current
32530  precision), and @var{exp} (the ``exponent'') is a fixnum.  The value of  precision), and @var{exp} (the ``exponent'') is a fixnum.  The value of
32531  the float is @samp{@var{mant} * 10^@var{exp}}.  For example, the number  the float is @samp{@var{mant} * 10^@var{exp}}.  For example, the number
32532  @i{-3.14} is stored as @samp{(float -314 -2) = -314*10^-2}.  Other constraints  @mathit{-3.14} is stored as @samp{(float -314 -2) = -314*10^-2}.  Other constraints
32533  are that the number 0.0 is always stored as @samp{(float 0 0)}, and,  are that the number 0.0 is always stored as @samp{(float 0 0)}, and,
32534  except for the 0.0 case, the rightmost base-10 digit of @var{mant} is  except for the 0.0 case, the rightmost base-10 digit of @var{mant} is
32535  always nonzero.  (If the rightmost digit is zero, the number is  always nonzero.  (If the rightmost digit is zero, the number is
# Line 32848  is applied to the top stack element, or, Line 32841  is applied to the top stack element, or,
32841  specified, nothing happens.  When the argument is two or more,  specified, nothing happens.  When the argument is two or more,
32842  the binary function @var{func} is reduced across the top @var{arg}  the binary function @var{func} is reduced across the top @var{arg}
32843  stack elements; when the argument is negative, the function is  stack elements; when the argument is negative, the function is
32844  mapped between the next-to-top @i{-@var{arg}} stack elements and the  mapped between the next-to-top @mathit{-@var{arg}} stack elements and the
32845  top element.  top element.
32846  @end defun  @end defun
32847    
# Line 33267  or formula, this calls @code{reject-arg} Line 33260  or formula, this calls @code{reject-arg}
33260  @end defun  @end defun
33261    
33262  @defun compare x y  @defun compare x y
33263  Compare the numbers @var{x} and @var{y}, and return @i{-1} if  Compare the numbers @var{x} and @var{y}, and return @mathit{-1} if
33264  @samp{(lessp @var{x} @var{y})}, 1 if @samp{(lessp @var{y} @var{x})},  @samp{(lessp @var{x} @var{y})}, 1 if @samp{(lessp @var{y} @var{x})},
33265  0 if @samp{(math-equal @var{x} @var{y})}, or 2 if the order is  0 if @samp{(math-equal @var{x} @var{y})}, or 2 if the order is
33266  undefined or cannot be determined.  undefined or cannot be determined.
# Line 33280  considered to have zero digits. Line 33273  considered to have zero digits.
33273  @end defun  @end defun
33274    
33275  @defun scale-int x n  @defun scale-int x n
33276  Shift integer @var{x} left @var{n} decimal digits, or right @i{-@var{n}}  Shift integer @var{x} left @var{n} decimal digits, or right @mathit{-@var{n}}
33277  digits with truncation toward zero.  digits with truncation toward zero.
33278  @end defun  @end defun
33279    
# Line 33488  function @code{frac}, and can be rather Line 33481  function @code{frac}, and can be rather
33481  @defun quarter-integer n  @defun quarter-integer n
33482  If @var{n} is an integer or integer-valued float, this function  If @var{n} is an integer or integer-valued float, this function
33483  returns zero.  If @var{n} is a half-integer (i.e., an integer plus  returns zero.  If @var{n} is a half-integer (i.e., an integer plus
33484  @i{1:2} or 0.5), it returns 2.  If @var{n} is a quarter-integer,  @mathit{1:2} or 0.5), it returns 2.  If @var{n} is a quarter-integer,
33485  it returns 1 or 3.  If @var{n} is anything else, this function  it returns 1 or 3.  If @var{n} is anything else, this function
33486  returns @code{nil}.  returns @code{nil}.
33487  @end defun  @end defun
# Line 35631  input data set.  Each entry may be a sin Line 35624  input data set.  Each entry may be a sin
35624  @c 20  @c 20
35625  @item  @item
35626  With a prefix argument of 1, take a single  With a prefix argument of 1, take a single
35627  @texline @tmath{@var{n}\times2}  @texline @var{n}@math{\times2}
35628  @infoline @i{@var{N}x2}  @infoline @mathit{@var{N}x2}
35629  matrix from the stack instead of two separate data vectors.  matrix from the stack instead of two separate data vectors.
35630    
35631  @c 21  @c 21
# Line 35834  to evaluate variables. Line 35827  to evaluate variables.
35827  The variable is replaced by the formula shown on the right.  The  The variable is replaced by the formula shown on the right.  The
35828  Inverse flag reverses the order of the operands, e.g., @kbd{I s - x}  Inverse flag reverses the order of the operands, e.g., @kbd{I s - x}
35829  assigns  assigns
35830  @texline @tmath{x \coloneq a-x}.  @texline @math{x \coloneq a-x}.
35831  @infoline @expr{x := a-x}.  @infoline @expr{x := a-x}.
35832    
35833  @c 48  @c 48
# Line 35842  assigns Line 35835  assigns
35835  Press @kbd{?} repeatedly to see how to choose a model.  Answer the  Press @kbd{?} repeatedly to see how to choose a model.  Answer the
35836  variables prompt with @expr{iv} or @expr{iv;pv} to specify  variables prompt with @expr{iv} or @expr{iv;pv} to specify
35837  independent and parameter variables.  A positive prefix argument  independent and parameter variables.  A positive prefix argument
35838  takes @i{@var{n}+1} vectors from the stack; a zero prefix takes a matrix  takes @mathit{@var{n}+1} vectors from the stack; a zero prefix takes a matrix
35839  and a vector from the stack.  and a vector from the stack.
35840    
35841  @c 49  @c 49

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26