aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Belanger2004-12-14 04:53:56 +0000
committerJay Belanger2004-12-14 04:53:56 +0000
commit8e04863ed5559631ee420d43fa3ff5c58b7406ce (patch)
tree91fb53a784c47f1d195961ab1194b96e571470ef
parenta0e4e2757acd079e2392ed976312d6b082119448 (diff)
downloademacs-8e04863ed5559631ee420d43fa3ff5c58b7406ce.tar.gz
emacs-8e04863ed5559631ee420d43fa3ff5c58b7406ce.zip
Replace @tmath macro with @math.
Fix TeX definition of @expr. Replace @i by @mathi.
-rw-r--r--man/calc.texi759
1 files changed, 376 insertions, 383 deletions
diff --git a/man/calc.texi b/man/calc.texi
index 027ebc7c960..16447e4e953 100644
--- a/man/calc.texi
+++ b/man/calc.texi
@@ -13,28 +13,20 @@
13@c @infoline foo 13@c @infoline foo
14@c `foo' will appear only in non-TeX output 14@c `foo' will appear only in non-TeX output
15 15
16@c In TeX output, @tmath{expr} will typeset expr in math mode. 16@c @expr{expr} will typeset an expression;
17@c In any output, @expr{expr} will typeset an expression;
18@c $x$ in TeX, @samp{x} otherwise. 17@c $x$ in TeX, @samp{x} otherwise.
19 18
20@iftex 19@iftex
21@macro texline{stuff} 20@macro texline{stuff}
22\stuff\ 21\stuff\
23@end macro 22@end macro
24@macro tmath{stuff}
25@tex
26$\stuff\$
27@end tex
28@end macro
29@alias infoline=comment 23@alias infoline=comment
30@c @alias expr=math
31@tex 24@tex
32\gdef\expr#1{\tex 25\gdef\exprsetup{\tex \let\t\ttfont \turnoffactive}
33 \let\t\ttfont 26\gdef\expr{\exprsetup$\exprfinish}
34 \turnoffactive 27\gdef\exprfinish#1{#1$\endgroup}
35 $#1$
36 \endgroup}
37@end tex 28@end tex
29@alias mathit=expr
38@macro cpi{} 30@macro cpi{}
39@math{@pi{}} 31@math{@pi{}}
40@end macro 32@end macro
@@ -49,6 +41,7 @@ $\stuff\$
49\stuff\ 41\stuff\
50@end macro 42@end macro
51@alias expr=samp 43@alias expr=samp
44@alias mathit=i
52@macro cpi{} 45@macro cpi{}
53@expr{pi} 46@expr{pi}
54@end macro 47@end macro
@@ -624,12 +617,12 @@ then the command to operate on the numbers.
624 617
625@noindent 618@noindent
626Type @kbd{2 @key{RET} 3 + Q} to compute 619Type @kbd{2 @key{RET} 3 + Q} to compute
627@texline @tmath{\sqrt{2+3} = 2.2360679775}. 620@texline @math{\sqrt{2+3} = 2.2360679775}.
628@infoline the square root of 2+3, which is 2.2360679775. 621@infoline the square root of 2+3, which is 2.2360679775.
629 622
630@noindent 623@noindent
631Type @kbd{P 2 ^} to compute 624Type @kbd{P 2 ^} to compute
632@texline @tmath{\pi^2 = 9.86960440109}. 625@texline @math{\pi^2 = 9.86960440109}.
633@infoline the value of `pi' squared, 9.86960440109. 626@infoline the value of `pi' squared, 9.86960440109.
634 627
635@noindent 628@noindent
@@ -648,12 +641,12 @@ use the apostrophe key.
648 641
649@noindent 642@noindent
650Type @kbd{' sqrt(2+3) @key{RET}} to compute 643Type @kbd{' sqrt(2+3) @key{RET}} to compute
651@texline @tmath{\sqrt{2+3}}. 644@texline @math{\sqrt{2+3}}.
652@infoline the square root of 2+3. 645@infoline the square root of 2+3.
653 646
654@noindent 647@noindent
655Type @kbd{' pi^2 @key{RET}} to enter 648Type @kbd{' pi^2 @key{RET}} to enter
656@texline @tmath{\pi^2}. 649@texline @math{\pi^2}.
657@infoline `pi' squared. 650@infoline `pi' squared.
658To evaluate this symbolic formula as a number, type @kbd{=}. 651To evaluate this symbolic formula as a number, type @kbd{=}.
659 652
@@ -713,10 +706,10 @@ the lower-right @samp{8} and press @kbd{M-# r}.
713 706
714@noindent 707@noindent
715Type @kbd{v t} to transpose this 708Type @kbd{v t} to transpose this
716@texline @tmath{3\times2} 709@texline @math{3\times2}
717@infoline 3x2 710@infoline 3x2
718matrix into a 711matrix into a
719@texline @tmath{2\times3} 712@texline @math{2\times3}
720@infoline 2x3 713@infoline 2x3
721matrix. Type @w{@kbd{v u}} to unpack the rows into two separate 714matrix. Type @w{@kbd{v u}} to unpack the rows into two separate
722vectors. Now type @w{@kbd{V R + @key{TAB} V R +}} to compute the sums 715vectors. Now type @w{@kbd{V R + @key{TAB} V R +}} to compute the sums
@@ -867,9 +860,9 @@ you do.
867 860
868In this case, the trail shows that four numbers (17.3, 3, 2, and 4) 861In this case, the trail shows that four numbers (17.3, 3, 2, and 4)
869were first entered into the Calculator, then the 2 and 4 were 862were first entered into the Calculator, then the 2 and 4 were
870multiplied to get 8, then the 3 and 8 were subtracted to get @i{-5}. 863multiplied to get 8, then the 3 and 8 were subtracted to get @mathit{-5}.
871(The @samp{>} symbol shows that this was the most recent calculation.) 864(The @samp{>} symbol shows that this was the most recent calculation.)
872The net result is the two numbers 17.3 and @i{-5} sitting on the stack. 865The net result is the two numbers 17.3 and @mathit{-5} sitting on the stack.
873 866
874Most Calculator commands deal explicitly with the stack only, but 867Most Calculator commands deal explicitly with the stack only, but
875there is a set of commands that allow you to search back through 868there is a set of commands that allow you to search back through
@@ -930,7 +923,7 @@ full complexity of the stack and trail. To use it, type @kbd{M-# q}
930 923
931Quick Mode is very simple: It prompts you to type any formula in 924Quick Mode is very simple: It prompts you to type any formula in
932standard algebraic notation (like @samp{4 - 2/3}) and then displays 925standard algebraic notation (like @samp{4 - 2/3}) and then displays
933the result at the bottom of the Emacs screen (@i{3.33333333333} 926the result at the bottom of the Emacs screen (@mathit{3.33333333333}
934in this case). You are then back in the same editing buffer you 927in this case). You are then back in the same editing buffer you
935were in before, ready to continue editing or to type @kbd{M-# q} 928were in before, ready to continue editing or to type @kbd{M-# q}
936again to do another quick calculation. The result of the calculation 929again to do another quick calculation. The result of the calculation
@@ -1343,7 +1336,7 @@ With any prefix argument, reset everything but the stack.
1343Calc was originally started as a two-week project to occupy a lull 1336Calc was originally started as a two-week project to occupy a lull
1344in the author's schedule. Basically, a friend asked if I remembered 1337in the author's schedule. Basically, a friend asked if I remembered
1345the value of 1338the value of
1346@texline @tmath{2^{32}}. 1339@texline @math{2^{32}}.
1347@infoline @expr{2^32}. 1340@infoline @expr{2^32}.
1348I didn't offhand, but I said, ``that's easy, just call up an 1341I didn't offhand, but I said, ``that's easy, just call up an
1349@code{xcalc}.'' @code{Xcalc} duly reported that the answer to our 1342@code{xcalc}.'' @code{Xcalc} duly reported that the answer to our
@@ -1665,7 +1658,7 @@ multiplication.) Figure it out by hand, then try it with Calc to see
1665if you're right. @xref{RPN Answer 1, 1}. (@bullet{}) 1658if you're right. @xref{RPN Answer 1, 1}. (@bullet{})
1666 1659
1667(@bullet{}) @strong{Exercise 2.} Compute 1660(@bullet{}) @strong{Exercise 2.} Compute
1668@texline @tmath{(2\times4) + (7\times9.4) + {5\over4}} 1661@texline @math{(2\times4) + (7\times9.4) + {5\over4}}
1669@infoline @expr{2*4 + 7*9.5 + 5/4} 1662@infoline @expr{2*4 + 7*9.5 + 5/4}
1670using the stack. @xref{RPN Answer 2, 2}. (@bullet{}) 1663using the stack. @xref{RPN Answer 2, 2}. (@bullet{})
1671 1664
@@ -2000,7 +1993,7 @@ $$ 2 + { 3 \times 4 \times 5 \over 6 \times 7^8 } - 9 $$
2000@end tex 1993@end tex
2001 1994
2002@noindent 1995@noindent
2003The result of this expression will be the number @i{-6.99999826533}. 1996The result of this expression will be the number @mathit{-6.99999826533}.
2004 1997
2005Calc's order of evaluation is the same as for most computer languages, 1998Calc's order of evaluation is the same as for most computer languages,
2006except that @samp{*} binds more strongly than @samp{/}, as the above 1999except that @samp{*} binds more strongly than @samp{/}, as the above
@@ -2009,7 +2002,7 @@ can often be omitted: @samp{2 a} is the same as @samp{2*a}.
2009 2002
2010Operators at the same level are evaluated from left to right, except 2003Operators at the same level are evaluated from left to right, except
2011that @samp{^} is evaluated from right to left. Thus, @samp{2-3-4} is 2004that @samp{^} is evaluated from right to left. Thus, @samp{2-3-4} is
2012equivalent to @samp{(2-3)-4} or @i{-5}, whereas @samp{2^3^4} is equivalent 2005equivalent to @samp{(2-3)-4} or @mathit{-5}, whereas @samp{2^3^4} is equivalent
2013to @samp{2^(3^4)} (a very large integer; try it!). 2006to @samp{2^(3^4)} (a very large integer; try it!).
2014 2007
2015If you tire of typing the apostrophe all the time, there is an 2008If you tire of typing the apostrophe all the time, there is an
@@ -2079,7 +2072,7 @@ accomplish this in Calc by performing your calculation as a series
2079of algebraic entries, using the @kbd{$} sign to tie them together. 2072of algebraic entries, using the @kbd{$} sign to tie them together.
2080In an algebraic formula, @kbd{$} represents the number on the top 2073In an algebraic formula, @kbd{$} represents the number on the top
2081of the stack. Here, we perform the calculation 2074of the stack. Here, we perform the calculation
2082@texline @tmath{\sqrt{2\times4+1}}, 2075@texline @math{\sqrt{2\times4+1}},
2083@infoline @expr{sqrt(2*4+1)}, 2076@infoline @expr{sqrt(2*4+1)},
2084which on a traditional calculator would be done by pressing 2077which on a traditional calculator would be done by pressing
2085@kbd{2 * 4 + 1 =} and then the square-root key. 2078@kbd{2 * 4 + 1 =} and then the square-root key.
@@ -2741,11 +2734,11 @@ angle is measured in degrees. For example,
2741@noindent 2734@noindent
2742The shift-@kbd{S} command computes the sine of an angle. The sine 2735The shift-@kbd{S} command computes the sine of an angle. The sine
2743of 45 degrees is 2736of 45 degrees is
2744@texline @tmath{\sqrt{2}/2}; 2737@texline @math{\sqrt{2}/2};
2745@infoline @expr{sqrt(2)/2}; 2738@infoline @expr{sqrt(2)/2};
2746squaring this yields @expr{2/4 = 0.5}. However, there has been a slight 2739squaring this yields @expr{2/4 = 0.5}. However, there has been a slight
2747roundoff error because the representation of 2740roundoff error because the representation of
2748@texline @tmath{\sqrt{2}/2} 2741@texline @math{\sqrt{2}/2}
2749@infoline @expr{sqrt(2)/2} 2742@infoline @expr{sqrt(2)/2}
2750wasn't exact. The @kbd{c 1} command is a handy way to clean up numbers 2743wasn't exact. The @kbd{c 1} command is a handy way to clean up numbers
2751in this case; it temporarily reduces the precision by one digit while it 2744in this case; it temporarily reduces the precision by one digit while it
@@ -2786,7 +2779,7 @@ either radians or degrees, depending on the current angular mode.
2786 2779
2787@noindent 2780@noindent
2788Here we compute the Inverse Sine of 2781Here we compute the Inverse Sine of
2789@texline @tmath{\sqrt{0.5}}, 2782@texline @math{\sqrt{0.5}},
2790@infoline @expr{sqrt(0.5)}, 2783@infoline @expr{sqrt(0.5)},
2791first in radians, then in degrees. 2784first in radians, then in degrees.
2792 2785
@@ -2974,9 +2967,9 @@ logarithm). These can be modified by the @kbd{I} (inverse) and
2974 2967
2975Let's compute the sine and cosine of an angle, and verify the 2968Let's compute the sine and cosine of an angle, and verify the
2976identity 2969identity
2977@texline @tmath{\sin^2x + \cos^2x = 1}. 2970@texline @math{\sin^2x + \cos^2x = 1}.
2978@infoline @expr{sin(x)^2 + cos(x)^2 = 1}. 2971@infoline @expr{sin(x)^2 + cos(x)^2 = 1}.
2979We'll arbitrarily pick @i{-64} degrees as a good value for @expr{x}. 2972We'll arbitrarily pick @mathit{-64} degrees as a good value for @expr{x}.
2980With the angular mode set to degrees (type @w{@kbd{m d}}), do: 2973With the angular mode set to degrees (type @w{@kbd{m d}}), do:
2981 2974
2982@smallexample 2975@smallexample
@@ -2997,7 +2990,7 @@ Remember, @kbd{f h} is the @code{calc-hypot}, or square-root of sum
2997of squares, command. 2990of squares, command.
2998 2991
2999Another identity is 2992Another identity is
3000@texline @tmath{\displaystyle\tan x = {\sin x \over \cos x}}. 2993@texline @math{\displaystyle\tan x = {\sin x \over \cos x}}.
3001@infoline @expr{tan(x) = sin(x) / cos(x)}. 2994@infoline @expr{tan(x) = sin(x) / cos(x)}.
3002@smallexample 2995@smallexample
3003@group 2996@group
@@ -3012,7 +3005,7 @@ Another identity is
3012 3005
3013A physical interpretation of this calculation is that if you move 3006A physical interpretation of this calculation is that if you move
3014@expr{0.89879} units downward and @expr{0.43837} units to the right, 3007@expr{0.89879} units downward and @expr{0.43837} units to the right,
3015your direction of motion is @i{-64} degrees from horizontal. Suppose 3008your direction of motion is @mathit{-64} degrees from horizontal. Suppose
3016we move in the opposite direction, up and to the left: 3009we move in the opposite direction, up and to the left:
3017 3010
3018@smallexample 3011@smallexample
@@ -3060,7 +3053,7 @@ the top two stack elements right after the @kbd{U U}, then a pair of
3060 3053
3061A similar identity is supposed to hold for hyperbolic sines and cosines, 3054A similar identity is supposed to hold for hyperbolic sines and cosines,
3062except that it is the @emph{difference} 3055except that it is the @emph{difference}
3063@texline @tmath{\cosh^2x - \sinh^2x} 3056@texline @math{\cosh^2x - \sinh^2x}
3064@infoline @expr{cosh(x)^2 - sinh(x)^2} 3057@infoline @expr{cosh(x)^2 - sinh(x)^2}
3065that always equals one. Let's try to verify this identity. 3058that always equals one. Let's try to verify this identity.
3066 3059
@@ -3167,7 +3160,7 @@ in this case).
3167 3160
3168If you take the factorial of a non-integer, Calc uses a generalized 3161If you take the factorial of a non-integer, Calc uses a generalized
3169factorial function defined in terms of Euler's Gamma function 3162factorial function defined in terms of Euler's Gamma function
3170@texline @tmath{\Gamma(n)} 3163@texline @math{\Gamma(n)}
3171@infoline @expr{gamma(n)} 3164@infoline @expr{gamma(n)}
3172(which is itself available as the @kbd{f g} command). 3165(which is itself available as the @kbd{f g} command).
3173 3166
@@ -3184,13 +3177,13 @@ factorial function defined in terms of Euler's Gamma function
3184 3177
3185@noindent 3178@noindent
3186Here we verify the identity 3179Here we verify the identity
3187@texline @tmath{n! = \Gamma(n+1)}. 3180@texline @math{n! = \Gamma(n+1)}.
3188@infoline @expr{@var{n}!@: = gamma(@var{n}+1)}. 3181@infoline @expr{@var{n}!@: = gamma(@var{n}+1)}.
3189 3182
3190The binomial coefficient @var{n}-choose-@var{m} 3183The binomial coefficient @var{n}-choose-@var{m}
3191@texline or @tmath{\displaystyle {n \choose m}} 3184@texline or @math{\displaystyle {n \choose m}}
3192is defined by 3185is defined by
3193@texline @tmath{\displaystyle {n! \over m! \, (n-m)!}} 3186@texline @math{\displaystyle {n! \over m! \, (n-m)!}}
3194@infoline @expr{n!@: / m!@: (n-m)!} 3187@infoline @expr{n!@: / m!@: (n-m)!}
3195for all reals @expr{n} and @expr{m}. The intermediate results in this 3188for all reals @expr{n} and @expr{m}. The intermediate results in this
3196formula can become quite large even if the final result is small; the 3189formula can become quite large even if the final result is small; the
@@ -3475,7 +3468,7 @@ vector.
3475 3468
3476(@bullet{}) @strong{Exercise 1.} Use @samp{*} to sum along the rows 3469(@bullet{}) @strong{Exercise 1.} Use @samp{*} to sum along the rows
3477of the above 3470of the above
3478@texline @tmath{2\times3} 3471@texline @math{2\times3}
3479@infoline 2x3 3472@infoline 2x3
3480matrix to get @expr{[6, 15]}. Now use @samp{*} to sum along the columns 3473matrix to get @expr{[6, 15]}. Now use @samp{*} to sum along the columns
3481to get @expr{[5, 7, 9]}. 3474to get @expr{[5, 7, 9]}.
@@ -3626,10 +3619,10 @@ assume the vector was a row vector in order to make the dimensions
3626come out right, and the answer would be incorrect. If you 3619come out right, and the answer would be incorrect. If you
3627don't feel safe letting Calc take either interpretation of your 3620don't feel safe letting Calc take either interpretation of your
3628vectors, use explicit 3621vectors, use explicit
3629@texline @tmath{N\times1} 3622@texline @math{N\times1}
3630@infoline Nx1 3623@infoline Nx1
3631or 3624or
3632@texline @tmath{1\times N} 3625@texline @math{1\times N}
3633@infoline 1xN 3626@infoline 1xN
3634matrices instead. In this case, you would enter the original column 3627matrices instead. In this case, you would enter the original column
3635vector as @samp{[[6], [2], [3]]} or @samp{[6; 2; 3]}. 3628vector as @samp{[[6], [2], [3]]} or @samp{[6; 2; 3]}.
@@ -3678,7 +3671,7 @@ on the left by the transpose of @expr{A}:
3678$A^T A \, X = A^T B$, where $A^T$ is the transpose \samp{trn(A)}. 3671$A^T A \, X = A^T B$, where $A^T$ is the transpose \samp{trn(A)}.
3679@end tex 3672@end tex
3680Now 3673Now
3681@texline @tmath{A^T A} 3674@texline @math{A^T A}
3682@infoline @expr{trn(A)*A} 3675@infoline @expr{trn(A)*A}
3683is a square matrix so a solution is possible. It turns out that the 3676is a square matrix so a solution is possible. It turns out that the
3684@expr{X} vector you compute in this way will be a ``least-squares'' 3677@expr{X} vector you compute in this way will be a ``least-squares''
@@ -3774,7 +3767,7 @@ of each element.
3774 3767
3775(@bullet{}) @strong{Exercise 1.} Compute a vector of powers of two 3768(@bullet{}) @strong{Exercise 1.} Compute a vector of powers of two
3776from 3769from
3777@texline @tmath{2^{-4}} 3770@texline @math{2^{-4}}
3778@infoline @expr{2^-4} 3771@infoline @expr{2^-4}
3779to @expr{2^4}. @xref{List Answer 1, 1}. (@bullet{}) 3772to @expr{2^4}. @xref{List Answer 1, 1}. (@bullet{})
3780 3773
@@ -3978,7 +3971,7 @@ $$ m = {N \sum x y - \sum x \sum y \over
3978 3971
3979@noindent 3972@noindent
3980where 3973where
3981@texline @tmath{\sum x} 3974@texline @math{\sum x}
3982@infoline @expr{sum(x)} 3975@infoline @expr{sum(x)}
3983represents the sum of all the values of @expr{x}. While there is an 3976represents the sum of all the values of @expr{x}. While there is an
3984actual @code{sum} function in Calc, it's easier to sum a vector using a 3977actual @code{sum} function in Calc, it's easier to sum a vector using a
@@ -4083,7 +4076,7 @@ $$ b = {\sum y - m \sum x \over N} $$
4083@end smallexample 4076@end smallexample
4084 4077
4085Let's ``plot'' this straight line approximation, 4078Let's ``plot'' this straight line approximation,
4086@texline @tmath{y \approx m x + b}, 4079@texline @math{y \approx m x + b},
4087@infoline @expr{m x + b}, 4080@infoline @expr{m x + b},
4088and compare it with the original data. 4081and compare it with the original data.
4089 4082
@@ -4336,7 +4329,7 @@ command to enable multi-line display of vectors.)
4336@cindex Maximizing a function over a list of values 4329@cindex Maximizing a function over a list of values
4337@c [fix-ref Numerical Solutions] 4330@c [fix-ref Numerical Solutions]
4338(@bullet{}) @strong{Exercise 8.} Compute a list of values of Bessel's 4331(@bullet{}) @strong{Exercise 8.} Compute a list of values of Bessel's
4339@texline @tmath{J_1(x)} 4332@texline @math{J_1(x)}
4340@infoline @expr{J1} 4333@infoline @expr{J1}
4341function @samp{besJ(1,x)} for @expr{x} from 0 to 5 in steps of 0.25. 4334function @samp{besJ(1,x)} for @expr{x} from 0 to 5 in steps of 0.25.
4342Find the value of @expr{x} (from among the above set of values) for 4335Find the value of @expr{x} (from among the above set of values) for
@@ -4348,7 +4341,7 @@ of thing automatically; @pxref{Numerical Solutions}.)
4348 4341
4349@cindex Digits, vectors of 4342@cindex Digits, vectors of
4350(@bullet{}) @strong{Exercise 9.} You are given an integer in the range 4343(@bullet{}) @strong{Exercise 9.} You are given an integer in the range
4351@texline @tmath{0 \le N < 10^m} 4344@texline @math{0 \le N < 10^m}
4352@infoline @expr{0 <= N < 10^m} 4345@infoline @expr{0 <= N < 10^m}
4353for @expr{m=12} (i.e., an integer of less than 4346for @expr{m=12} (i.e., an integer of less than
4354twelve digits). Convert this integer into a vector of @expr{m} 4347twelve digits). Convert this integer into a vector of @expr{m}
@@ -4364,14 +4357,14 @@ happened? How would you do this test? @xref{List Answer 10, 10}. (@bullet{})
4364 4357
4365(@bullet{}) @strong{Exercise 11.} The area of a circle of radius one 4358(@bullet{}) @strong{Exercise 11.} The area of a circle of radius one
4366is @cpi{}. The area of the 4359is @cpi{}. The area of the
4367@texline @tmath{2\times2} 4360@texline @math{2\times2}
4368@infoline 2x2 4361@infoline 2x2
4369square that encloses that circle is 4. So if we throw @var{n} darts at 4362square that encloses that circle is 4. So if we throw @var{n} darts at
4370random points in the square, about @cpiover{4} of them will land inside 4363random points in the square, about @cpiover{4} of them will land inside
4371the circle. This gives us an entertaining way to estimate the value of 4364the circle. This gives us an entertaining way to estimate the value of
4372@cpi{}. The @w{@kbd{k r}} 4365@cpi{}. The @w{@kbd{k r}}
4373command picks a random number between zero and the value on the stack. 4366command picks a random number between zero and the value on the stack.
4374We could get a random floating-point number between @i{-1} and 1 by typing 4367We could get a random floating-point number between @mathit{-1} and 1 by typing
4375@w{@kbd{2.0 k r 1 -}}. Build a vector of 100 random @expr{(x,y)} points in 4368@w{@kbd{2.0 k r 1 -}}. Build a vector of 100 random @expr{(x,y)} points in
4376this square, then use vector mapping and reduction to count how many 4369this square, then use vector mapping and reduction to count how many
4377points lie inside the unit circle. Hint: Use the @kbd{v b} command. 4370points lie inside the unit circle. Hint: Use the @kbd{v b} command.
@@ -4383,12 +4376,12 @@ another way to calculate @cpi{}. Say you have an infinite field
4383of vertical lines with a spacing of one inch. Toss a one-inch matchstick 4376of vertical lines with a spacing of one inch. Toss a one-inch matchstick
4384onto the field. The probability that the matchstick will land crossing 4377onto the field. The probability that the matchstick will land crossing
4385a line turns out to be 4378a line turns out to be
4386@texline @tmath{2/\pi}. 4379@texline @math{2/\pi}.
4387@infoline @expr{2/pi}. 4380@infoline @expr{2/pi}.
4388Toss 100 matchsticks to estimate @cpi{}. (If you want still more fun, 4381Toss 100 matchsticks to estimate @cpi{}. (If you want still more fun,
4389the probability that the GCD (@w{@kbd{k g}}) of two large integers is 4382the probability that the GCD (@w{@kbd{k g}}) of two large integers is
4390one turns out to be 4383one turns out to be
4391@texline @tmath{6/\pi^2}. 4384@texline @math{6/\pi^2}.
4392@infoline @expr{6/pi^2}. 4385@infoline @expr{6/pi^2}.
4393That provides yet another way to estimate @cpi{}.) 4386That provides yet another way to estimate @cpi{}.)
4394@xref{List Answer 12, 12}. (@bullet{}) 4387@xref{List Answer 12, 12}. (@bullet{})
@@ -4418,7 +4411,7 @@ value and a number of steps @var{n} from the stack; it then applies the
4418function you give to the starting value 0, 1, 2, up to @var{n} times 4411function you give to the starting value 0, 1, 2, up to @var{n} times
4419and returns a vector of the results. Use this command to create a 4412and returns a vector of the results. Use this command to create a
4420``random walk'' of 50 steps. Start with the two-dimensional point 4413``random walk'' of 50 steps. Start with the two-dimensional point
4421@expr{(0,0)}; then take one step a random distance between @i{-1} and 1 4414@expr{(0,0)}; then take one step a random distance between @mathit{-1} and 1
4422in both @expr{x} and @expr{y}; then take another step, and so on. Use the 4415in both @expr{x} and @expr{y}; then take another step, and so on. Use the
4423@kbd{g f} command to display this random walk. Now modify your random 4416@kbd{g f} command to display this random walk. Now modify your random
4424walk to walk a unit distance, but in a random direction, at each step. 4417walk to walk a unit distance, but in a random direction, at each step.
@@ -4497,7 +4490,7 @@ to allow for roundoff error!) @xref{Types Answer 1, 1}. (@bullet{})
4497@end smallexample 4490@end smallexample
4498 4491
4499@noindent 4492@noindent
4500The square root of @i{-9} is by default rendered in rectangular form 4493The square root of @mathit{-9} is by default rendered in rectangular form
4501(@w{@expr{0 + 3i}}), but we can convert it to polar form (3 with a 4494(@w{@expr{0 + 3i}}), but we can convert it to polar form (3 with a
4502phase angle of 90 degrees). All the usual arithmetic and scientific 4495phase angle of 90 degrees). All the usual arithmetic and scientific
4503operations are defined on both types of complex numbers. 4496operations are defined on both types of complex numbers.
@@ -4522,14 +4515,14 @@ algebraic entry.
4522 4515
4523@noindent 4516@noindent
4524Since infinity is infinitely large, multiplying it by any finite 4517Since infinity is infinitely large, multiplying it by any finite
4525number (like @i{-17}) has no effect, except that since @i{-17} 4518number (like @mathit{-17}) has no effect, except that since @mathit{-17}
4526is negative, it changes a plus infinity to a minus infinity. 4519is negative, it changes a plus infinity to a minus infinity.
4527(``A huge positive number, multiplied by @i{-17}, yields a huge 4520(``A huge positive number, multiplied by @mathit{-17}, yields a huge
4528negative number.'') Adding any finite number to infinity also 4521negative number.'') Adding any finite number to infinity also
4529leaves it unchanged. Taking an absolute value gives us plus 4522leaves it unchanged. Taking an absolute value gives us plus
4530infinity again. Finally, we add this plus infinity to the minus 4523infinity again. Finally, we add this plus infinity to the minus
4531infinity we had earlier. If you work it out, you might expect 4524infinity we had earlier. If you work it out, you might expect
4532the answer to be @i{-72} for this. But the 72 has been completely 4525the answer to be @mathit{-72} for this. But the 72 has been completely
4533lost next to the infinities; by the time we compute @w{@samp{inf - inf}} 4526lost next to the infinities; by the time we compute @w{@samp{inf - inf}}
4534the finite difference between them, if any, is undetectable. 4527the finite difference between them, if any, is undetectable.
4535So we say the result is @dfn{indeterminate}, which Calc writes 4528So we say the result is @dfn{indeterminate}, which Calc writes
@@ -4686,7 +4679,7 @@ a 60% chance that the result is correct within 0.59 degrees.
4686 4679
4687@cindex Torus, volume of 4680@cindex Torus, volume of
4688(@bullet{}) @strong{Exercise 7.} The volume of a torus (a donut shape) is 4681(@bullet{}) @strong{Exercise 7.} The volume of a torus (a donut shape) is
4689@texline @tmath{2 \pi^2 R r^2} 4682@texline @math{2 \pi^2 R r^2}
4690@infoline @w{@expr{2 pi^2 R r^2}} 4683@infoline @w{@expr{2 pi^2 R r^2}}
4691where @expr{R} is the radius of the circle that 4684where @expr{R} is the radius of the circle that
4692defines the center of the tube and @expr{r} is the radius of the tube 4685defines the center of the tube and @expr{r} is the radius of the tube
@@ -4786,7 +4779,7 @@ that arises in the second one.
4786@cindex Fermat, primality test of 4779@cindex Fermat, primality test of
4787(@bullet{}) @strong{Exercise 10.} A theorem of Pierre de Fermat 4780(@bullet{}) @strong{Exercise 10.} A theorem of Pierre de Fermat
4788says that 4781says that
4789@texline @w{@tmath{x^{n-1} \bmod n = 1}} 4782@texline @w{@math{x^{n-1} \bmod n = 1}}
4790@infoline @expr{x^(n-1) mod n = 1} 4783@infoline @expr{x^(n-1) mod n = 1}
4791if @expr{n} is a prime number and @expr{x} is an integer less than 4784if @expr{n} is a prime number and @expr{x} is an integer less than
4792@expr{n}. If @expr{n} is @emph{not} a prime number, this will 4785@expr{n}. If @expr{n} is @emph{not} a prime number, this will
@@ -4814,7 +4807,7 @@ This calculation tells me it is six hours and 22 minutes until midnight.
4814 4807
4815(@bullet{}) @strong{Exercise 11.} A rule of thumb is that one year 4808(@bullet{}) @strong{Exercise 11.} A rule of thumb is that one year
4816is about 4809is about
4817@texline @tmath{\pi \times 10^7} 4810@texline @math{\pi \times 10^7}
4818@infoline @w{@expr{pi * 10^7}} 4811@infoline @w{@expr{pi * 10^7}}
4819seconds. What time will it be that many seconds from right now? 4812seconds. What time will it be that many seconds from right now?
4820@xref{Types Answer 11, 11}. (@bullet{}) 4813@xref{Types Answer 11, 11}. (@bullet{})
@@ -5121,7 +5114,7 @@ solution by pressing @kbd{H} (the Hyperbolic flag) before @kbd{a S}.
5121 5114
5122@noindent 5115@noindent
5123Calc has invented the variable @samp{s1} to represent an unknown sign; 5116Calc has invented the variable @samp{s1} to represent an unknown sign;
5124it is supposed to be either @i{+1} or @i{-1}. Here we have used 5117it is supposed to be either @mathit{+1} or @mathit{-1}. Here we have used
5125the ``let'' command to evaluate the expression when the sign is negative. 5118the ``let'' command to evaluate the expression when the sign is negative.
5126If we plugged this into our second derivative we would get the same, 5119If we plugged this into our second derivative we would get the same,
5127negative, answer, so @expr{x = -1.19023} is also a maximum. 5120negative, answer, so @expr{x = -1.19023} is also a maximum.
@@ -5291,7 +5284,7 @@ One way to do it is again with vector mapping and reduction:
5291 5284
5292(@bullet{}) @strong{Exercise 3.} Find the integral from 1 to @expr{y} 5285(@bullet{}) @strong{Exercise 3.} Find the integral from 1 to @expr{y}
5293of 5286of
5294@texline @tmath{x \sin \pi x} 5287@texline @math{x \sin \pi x}
5295@infoline @w{@expr{x sin(pi x)}} 5288@infoline @w{@expr{x sin(pi x)}}
5296(where the sine is calculated in radians). Find the values of the 5289(where the sine is calculated in radians). Find the values of the
5297integral for integers @expr{y} from 1 to 5. @xref{Algebra Answer 3, 5290integral for integers @expr{y} from 1 to 5. @xref{Algebra Answer 3,
@@ -5300,7 +5293,7 @@ integral for integers @expr{y} from 1 to 5. @xref{Algebra Answer 3,
5300Calc's integrator can do many simple integrals symbolically, but many 5293Calc's integrator can do many simple integrals symbolically, but many
5301others are beyond its capabilities. Suppose we wish to find the area 5294others are beyond its capabilities. Suppose we wish to find the area
5302under the curve 5295under the curve
5303@texline @tmath{\sin x \ln x} 5296@texline @math{\sin x \ln x}
5304@infoline @expr{sin(x) ln(x)} 5297@infoline @expr{sin(x) ln(x)}
5305over the same range of @expr{x}. If you entered this formula and typed 5298over the same range of @expr{x}. If you entered this formula and typed
5306@kbd{a i x @key{RET}} (don't bother to try this), Calc would work for a 5299@kbd{a i x @key{RET}} (don't bother to try this), Calc would work for a
@@ -5442,7 +5435,7 @@ $$ h (f(a) + f(a+h) + f(a+2h) + f(a+3h) + \cdots
5442@end tex 5435@end tex
5443 5436
5444Compute the integral from 1 to 2 of 5437Compute the integral from 1 to 2 of
5445@texline @tmath{\sin x \ln x} 5438@texline @math{\sin x \ln x}
5446@infoline @expr{sin(x) ln(x)} 5439@infoline @expr{sin(x) ln(x)}
5447using Simpson's rule with 10 slices. 5440using Simpson's rule with 10 slices.
5448@xref{Algebra Answer 4, 4}. (@bullet{}) 5441@xref{Algebra Answer 4, 4}. (@bullet{})
@@ -5988,7 +5981,7 @@ in @samp{a + 1} for @samp{x} in the defining formula.
5988@end ignore 5981@end ignore
5989@tindex Si 5982@tindex Si
5990(@bullet{}) @strong{Exercise 1.} The ``sine integral'' function 5983(@bullet{}) @strong{Exercise 1.} The ``sine integral'' function
5991@texline @tmath{{\rm Si}(x)} 5984@texline @math{{\rm Si}(x)}
5992@infoline @expr{Si(x)} 5985@infoline @expr{Si(x)}
5993is defined as the integral of @samp{sin(t)/t} for 5986is defined as the integral of @samp{sin(t)/t} for
5994@expr{t = 0} to @expr{x} in radians. (It was invented because this 5987@expr{t = 0} to @expr{x} in radians. (It was invented because this
@@ -6066,7 +6059,7 @@ the following functions:
6066@enumerate 6059@enumerate
6067@item 6060@item
6068Compute 6061Compute
6069@texline @tmath{\displaystyle{\sin x \over x}}, 6062@texline @math{\displaystyle{\sin x \over x}},
6070@infoline @expr{sin(x) / x}, 6063@infoline @expr{sin(x) / x},
6071where @expr{x} is the number on the top of the stack. 6064where @expr{x} is the number on the top of the stack.
6072 6065
@@ -6132,13 +6125,13 @@ key if you have one, makes a copy of the number in level 2.)
6132@cindex Phi, golden ratio 6125@cindex Phi, golden ratio
6133A fascinating property of the Fibonacci numbers is that the @expr{n}th 6126A fascinating property of the Fibonacci numbers is that the @expr{n}th
6134Fibonacci number can be found directly by computing 6127Fibonacci number can be found directly by computing
6135@texline @tmath{\phi^n / \sqrt{5}} 6128@texline @math{\phi^n / \sqrt{5}}
6136@infoline @expr{phi^n / sqrt(5)} 6129@infoline @expr{phi^n / sqrt(5)}
6137and then rounding to the nearest integer, where 6130and then rounding to the nearest integer, where
6138@texline @tmath{\phi} (``phi''), 6131@texline @math{\phi} (``phi''),
6139@infoline @expr{phi}, 6132@infoline @expr{phi},
6140the ``golden ratio,'' is 6133the ``golden ratio,'' is
6141@texline @tmath{(1 + \sqrt{5}) / 2}. 6134@texline @math{(1 + \sqrt{5}) / 2}.
6142@infoline @expr{(1 + sqrt(5)) / 2}. 6135@infoline @expr{(1 + sqrt(5)) / 2}.
6143(For convenience, this constant is available from the @code{phi} 6136(For convenience, this constant is available from the @code{phi}
6144variable, or the @kbd{I H P} command.) 6137variable, or the @kbd{I H P} command.)
@@ -6155,17 +6148,17 @@ variable, or the @kbd{I H P} command.)
6155@cindex Continued fractions 6148@cindex Continued fractions
6156(@bullet{}) @strong{Exercise 5.} The @dfn{continued fraction} 6149(@bullet{}) @strong{Exercise 5.} The @dfn{continued fraction}
6157representation of 6150representation of
6158@texline @tmath{\phi} 6151@texline @math{\phi}
6159@infoline @expr{phi} 6152@infoline @expr{phi}
6160is 6153is
6161@texline @tmath{1 + 1/(1 + 1/(1 + 1/( \ldots )))}. 6154@texline @math{1 + 1/(1 + 1/(1 + 1/( \ldots )))}.
6162@infoline @expr{1 + 1/(1 + 1/(1 + 1/( ...@: )))}. 6155@infoline @expr{1 + 1/(1 + 1/(1 + 1/( ...@: )))}.
6163We can compute an approximate value by carrying this however far 6156We can compute an approximate value by carrying this however far
6164and then replacing the innermost 6157and then replacing the innermost
6165@texline @tmath{1/( \ldots )} 6158@texline @math{1/( \ldots )}
6166@infoline @expr{1/( ...@: )} 6159@infoline @expr{1/( ...@: )}
6167by 1. Approximate 6160by 1. Approximate
6168@texline @tmath{\phi} 6161@texline @math{\phi}
6169@infoline @expr{phi} 6162@infoline @expr{phi}
6170using a twenty-term continued fraction. 6163using a twenty-term continued fraction.
6171@xref{Programming Answer 5, 5}. (@bullet{}) 6164@xref{Programming Answer 5, 5}. (@bullet{})
@@ -6265,7 +6258,7 @@ The @dfn{Bernoulli numbers} are a sequence with the interesting
6265property that all of the odd Bernoulli numbers are zero, and the 6258property that all of the odd Bernoulli numbers are zero, and the
6266even ones, while difficult to compute, can be roughly approximated 6259even ones, while difficult to compute, can be roughly approximated
6267by the formula 6260by the formula
6268@texline @tmath{\displaystyle{2 n! \over (2 \pi)^n}}. 6261@texline @math{\displaystyle{2 n! \over (2 \pi)^n}}.
6269@infoline @expr{2 n!@: / (2 pi)^n}. 6262@infoline @expr{2 n!@: / (2 pi)^n}.
6270Let's write a keyboard macro to compute (approximate) Bernoulli numbers. 6263Let's write a keyboard macro to compute (approximate) Bernoulli numbers.
6271(Calc has a command, @kbd{k b}, to compute exact Bernoulli numbers, but 6264(Calc has a command, @kbd{k b}, to compute exact Bernoulli numbers, but
@@ -6439,14 +6432,14 @@ $$ x_{\rm new} = x - {f(x) \over f'(x)} $$
6439@noindent 6432@noindent
6440where @expr{f'(x)} is the derivative of @expr{f}. The @expr{x} 6433where @expr{f'(x)} is the derivative of @expr{f}. The @expr{x}
6441values will quickly converge to a solution, i.e., eventually 6434values will quickly converge to a solution, i.e., eventually
6442@texline @tmath{x_{\rm new}} 6435@texline @math{x_{\rm new}}
6443@infoline @expr{new_x} 6436@infoline @expr{new_x}
6444and @expr{x} will be equal to within the limits 6437and @expr{x} will be equal to within the limits
6445of the current precision. Write a program which takes a formula 6438of the current precision. Write a program which takes a formula
6446involving the variable @expr{x}, and an initial guess @expr{x_0}, 6439involving the variable @expr{x}, and an initial guess @expr{x_0},
6447on the stack, and produces a value of @expr{x} for which the formula 6440on the stack, and produces a value of @expr{x} for which the formula
6448is zero. Use it to find a solution of 6441is zero. Use it to find a solution of
6449@texline @tmath{\sin(\cos x) = 0.5} 6442@texline @math{\sin(\cos x) = 0.5}
6450@infoline @expr{sin(cos(x)) = 0.5} 6443@infoline @expr{sin(cos(x)) = 0.5}
6451near @expr{x = 4.5}. (Use angles measured in radians.) Note that 6444near @expr{x = 4.5}. (Use angles measured in radians.) Note that
6452the built-in @w{@kbd{a R}} (@code{calc-find-root}) command uses Newton's 6445the built-in @w{@kbd{a R}} (@code{calc-find-root}) command uses Newton's
@@ -6456,10 +6449,10 @@ method when it is able. @xref{Programming Answer 8, 8}. (@bullet{})
6456@cindex Gamma constant, Euler's 6449@cindex Gamma constant, Euler's
6457@cindex Euler's gamma constant 6450@cindex Euler's gamma constant
6458(@bullet{}) @strong{Exercise 9.} The @dfn{digamma} function 6451(@bullet{}) @strong{Exercise 9.} The @dfn{digamma} function
6459@texline @tmath{\psi(z) (``psi'')} 6452@texline @math{\psi(z) (``psi'')}
6460@infoline @expr{psi(z)} 6453@infoline @expr{psi(z)}
6461is defined as the derivative of 6454is defined as the derivative of
6462@texline @tmath{\ln \Gamma(z)}. 6455@texline @math{\ln \Gamma(z)}.
6463@infoline @expr{ln(gamma(z))}. 6456@infoline @expr{ln(gamma(z))}.
6464For large values of @expr{z}, it can be approximated by the infinite sum 6457For large values of @expr{z}, it can be approximated by the infinite sum
6465 6458
@@ -6478,7 +6471,7 @@ $$
6478 6471
6479@noindent 6472@noindent
6480where 6473where
6481@texline @tmath{\sum} 6474@texline @math{\sum}
6482@infoline @expr{sum} 6475@infoline @expr{sum}
6483represents the sum over @expr{n} from 1 to infinity 6476represents the sum over @expr{n} from 1 to infinity
6484(or to some limit high enough to give the desired accuracy), and 6477(or to some limit high enough to give the desired accuracy), and
@@ -6486,27 +6479,27 @@ the @code{bern} function produces (exact) Bernoulli numbers.
6486While this sum is not guaranteed to converge, in practice it is safe. 6479While this sum is not guaranteed to converge, in practice it is safe.
6487An interesting mathematical constant is Euler's gamma, which is equal 6480An interesting mathematical constant is Euler's gamma, which is equal
6488to about 0.5772. One way to compute it is by the formula, 6481to about 0.5772. One way to compute it is by the formula,
6489@texline @tmath{\gamma = -\psi(1)}. 6482@texline @math{\gamma = -\psi(1)}.
6490@infoline @expr{gamma = -psi(1)}. 6483@infoline @expr{gamma = -psi(1)}.
6491Unfortunately, 1 isn't a large enough argument 6484Unfortunately, 1 isn't a large enough argument
6492for the above formula to work (5 is a much safer value for @expr{z}). 6485for the above formula to work (5 is a much safer value for @expr{z}).
6493Fortunately, we can compute 6486Fortunately, we can compute
6494@texline @tmath{\psi(1)} 6487@texline @math{\psi(1)}
6495@infoline @expr{psi(1)} 6488@infoline @expr{psi(1)}
6496from 6489from
6497@texline @tmath{\psi(5)} 6490@texline @math{\psi(5)}
6498@infoline @expr{psi(5)} 6491@infoline @expr{psi(5)}
6499using the recurrence 6492using the recurrence
6500@texline @tmath{\psi(z+1) = \psi(z) + {1 \over z}}. 6493@texline @math{\psi(z+1) = \psi(z) + {1 \over z}}.
6501@infoline @expr{psi(z+1) = psi(z) + 1/z}. 6494@infoline @expr{psi(z+1) = psi(z) + 1/z}.
6502Your task: Develop a program to compute 6495Your task: Develop a program to compute
6503@texline @tmath{\psi(z)}; 6496@texline @math{\psi(z)};
6504@infoline @expr{psi(z)}; 6497@infoline @expr{psi(z)};
6505it should ``pump up'' @expr{z} 6498it should ``pump up'' @expr{z}
6506if necessary to be greater than 5, then use the above summation 6499if necessary to be greater than 5, then use the above summation
6507formula. Use looping commands to compute the sum. Use your function 6500formula. Use looping commands to compute the sum. Use your function
6508to compute 6501to compute
6509@texline @tmath{\gamma} 6502@texline @math{\gamma}
6510@infoline @expr{gamma} 6503@infoline @expr{gamma}
6511to twelve decimal places. (Calc has a built-in command 6504to twelve decimal places. (Calc has a built-in command
6512for Euler's constant, @kbd{I P}, which you can use to check your answer.) 6505for Euler's constant, @kbd{I P}, which you can use to check your answer.)
@@ -6683,18 +6676,18 @@ This section includes answers to all the exercises in the Calc tutorial.
6683@kbd{1 @key{RET} 2 @key{RET} 3 @key{RET} 4 + * -} 6676@kbd{1 @key{RET} 2 @key{RET} 3 @key{RET} 4 + * -}
6684 6677
6685The result is 6678The result is
6686@texline @tmath{1 - (2 \times (3 + 4)) = -13}. 6679@texline @math{1 - (2 \times (3 + 4)) = -13}.
6687@infoline @expr{1 - (2 * (3 + 4)) = -13}. 6680@infoline @expr{1 - (2 * (3 + 4)) = -13}.
6688 6681
6689@node RPN Answer 2, RPN Answer 3, RPN Answer 1, Answers to Exercises 6682@node RPN Answer 2, RPN Answer 3, RPN Answer 1, Answers to Exercises
6690@subsection RPN Tutorial Exercise 2 6683@subsection RPN Tutorial Exercise 2
6691 6684
6692@noindent 6685@noindent
6693@texline @tmath{2\times4 + 7\times9.5 + {5\over4} = 75.75} 6686@texline @math{2\times4 + 7\times9.5 + {5\over4} = 75.75}
6694@infoline @expr{2*4 + 7*9.5 + 5/4 = 75.75} 6687@infoline @expr{2*4 + 7*9.5 + 5/4 = 75.75}
6695 6688
6696After computing the intermediate term 6689After computing the intermediate term
6697@texline @tmath{2\times4 = 8}, 6690@texline @math{2\times4 = 8},
6698@infoline @expr{2*4 = 8}, 6691@infoline @expr{2*4 = 8},
6699you can leave that result on the stack while you compute the second 6692you can leave that result on the stack while you compute the second
6700term. With both of these results waiting on the stack you can then 6693term. With both of these results waiting on the stack you can then
@@ -7003,7 +6996,7 @@ give a floating-point result that is inaccurate even when rounded
7003down to an integer. Consider @expr{123456789 / 2} when the current 6996down to an integer. Consider @expr{123456789 / 2} when the current
7004precision is 6 digits. The true answer is @expr{61728394.5}, but 6997precision is 6 digits. The true answer is @expr{61728394.5}, but
7005with a precision of 6 this will be rounded to 6998with a precision of 6 this will be rounded to
7006@texline @tmath{12345700.0/2.0 = 61728500.0}. 6999@texline @math{12345700.0/2.0 = 61728500.0}.
7007@infoline @expr{12345700.@: / 2.@: = 61728500.}. 7000@infoline @expr{12345700.@: / 2.@: = 61728500.}.
7008The result, when converted to an integer, will be off by 106. 7001The result, when converted to an integer, will be off by 106.
7009 7002
@@ -7114,16 +7107,16 @@ Type @kbd{d N} to return to ``normal'' display mode afterwards.
7114 7107
7115@noindent 7108@noindent
7116To solve 7109To solve
7117@texline @tmath{A^T A \, X = A^T B}, 7110@texline @math{A^T A \, X = A^T B},
7118@infoline @expr{trn(A) * A * X = trn(A) * B}, 7111@infoline @expr{trn(A) * A * X = trn(A) * B},
7119first we compute 7112first we compute
7120@texline @tmath{A' = A^T A} 7113@texline @math{A' = A^T A}
7121@infoline @expr{A2 = trn(A) * A} 7114@infoline @expr{A2 = trn(A) * A}
7122and 7115and
7123@texline @tmath{B' = A^T B}; 7116@texline @math{B' = A^T B};
7124@infoline @expr{B2 = trn(A) * B}; 7117@infoline @expr{B2 = trn(A) * B};
7125now, we have a system 7118now, we have a system
7126@texline @tmath{A' X = B'} 7119@texline @math{A' X = B'}
7127@infoline @expr{A2 * X = B2} 7120@infoline @expr{A2 * X = B2}
7128which we can solve using Calc's @samp{/} command. 7121which we can solve using Calc's @samp{/} command.
7129 7122
@@ -7155,7 +7148,7 @@ $$
7155 7148
7156The first step is to enter the coefficient matrix. We'll store it in 7149The first step is to enter the coefficient matrix. We'll store it in
7157quick variable number 7 for later reference. Next, we compute the 7150quick variable number 7 for later reference. Next, we compute the
7158@texline @tmath{B'} 7151@texline @math{B'}
7159@infoline @expr{B2} 7152@infoline @expr{B2}
7160vector. 7153vector.
7161 7154
@@ -7173,7 +7166,7 @@ vector.
7173 7166
7174@noindent 7167@noindent
7175Now we compute the matrix 7168Now we compute the matrix
7176@texline @tmath{A'} 7169@texline @math{A'}
7177@infoline @expr{A2} 7170@infoline @expr{A2}
7178and divide. 7171and divide.
7179 7172
@@ -7194,16 +7187,16 @@ and divide.
7194round-off error.) 7187round-off error.)
7195 7188
7196Notice that the answers are similar to those for the 7189Notice that the answers are similar to those for the
7197@texline @tmath{3\times3} 7190@texline @math{3\times3}
7198@infoline 3x3 7191@infoline 3x3
7199system solved in the text. That's because the fourth equation that was 7192system solved in the text. That's because the fourth equation that was
7200added to the system is almost identical to the first one multiplied 7193added to the system is almost identical to the first one multiplied
7201by two. (If it were identical, we would have gotten the exact same 7194by two. (If it were identical, we would have gotten the exact same
7202answer since the 7195answer since the
7203@texline @tmath{4\times3} 7196@texline @math{4\times3}
7204@infoline 4x3 7197@infoline 4x3
7205system would be equivalent to the original 7198system would be equivalent to the original
7206@texline @tmath{3\times3} 7199@texline @math{3\times3}
7207@infoline 3x3 7200@infoline 3x3
7208system.) 7201system.)
7209 7202
@@ -7280,7 +7273,7 @@ $$ m \times x + b \times 1 = y $$
7280@end tex 7273@end tex
7281 7274
7282Thus we want a 7275Thus we want a
7283@texline @tmath{19\times2} 7276@texline @math{19\times2}
7284@infoline 19x2 7277@infoline 19x2
7285matrix with our @expr{x} vector as one column and 7278matrix with our @expr{x} vector as one column and
7286ones as the other column. So, first we build the column of ones, then 7279ones as the other column. So, first we build the column of ones, then
@@ -7299,10 +7292,10 @@ we combine the two columns to form our @expr{A} matrix.
7299 7292
7300@noindent 7293@noindent
7301Now we compute 7294Now we compute
7302@texline @tmath{A^T y} 7295@texline @math{A^T y}
7303@infoline @expr{trn(A) * y} 7296@infoline @expr{trn(A) * y}
7304and 7297and
7305@texline @tmath{A^T A} 7298@texline @math{A^T A}
7306@infoline @expr{trn(A) * A} 7299@infoline @expr{trn(A) * A}
7307and divide. 7300and divide.
7308 7301
@@ -7330,7 +7323,7 @@ and divide.
7330@end smallexample 7323@end smallexample
7331 7324
7332Since we were solving equations of the form 7325Since we were solving equations of the form
7333@texline @tmath{m \times x + b \times 1 = y}, 7326@texline @math{m \times x + b \times 1 = y},
7334@infoline @expr{m*x + b*1 = y}, 7327@infoline @expr{m*x + b*1 = y},
7335these numbers should be @expr{m} and @expr{b}, respectively. Sure 7328these numbers should be @expr{m} and @expr{b}, respectively. Sure
7336enough, they agree exactly with the result computed using @kbd{V M} and 7329enough, they agree exactly with the result computed using @kbd{V M} and
@@ -7393,7 +7386,7 @@ then raise the number to that power.)
7393 7386
7394@noindent 7387@noindent
7395A number @expr{j} is a divisor of @expr{n} if 7388A number @expr{j} is a divisor of @expr{n} if
7396@texline @tmath{n \mathbin{\hbox{\code{\%}}} j = 0}. 7389@texline @math{n \mathbin{\hbox{\code{\%}}} j = 0}.
7397@infoline @samp{n % j = 0}. 7390@infoline @samp{n % j = 0}.
7398The first step is to get a vector that identifies the divisors. 7391The first step is to get a vector that identifies the divisors.
7399 7392
@@ -7464,7 +7457,7 @@ zero, so adding zeros on the left and right is safe. From then on
7464the job is pretty straightforward. 7457the job is pretty straightforward.
7465 7458
7466Incidentally, Calc provides the 7459Incidentally, Calc provides the
7467@texline @dfn{M@"obius} @tmath{\mu} 7460@texline @dfn{M@"obius} @math{\mu}
7468@infoline @dfn{Moebius mu} 7461@infoline @dfn{Moebius mu}
7469function which is zero if and only if its argument is square-free. It 7462function which is zero if and only if its argument is square-free. It
7470would be a much more convenient way to do the above test in practice. 7463would be a much more convenient way to do the above test in practice.
@@ -7498,7 +7491,7 @@ The numbers down the lefthand edge of the list we desire are called
7498the ``triangular numbers'' (now you know why!). The @expr{n}th 7491the ``triangular numbers'' (now you know why!). The @expr{n}th
7499triangular number is the sum of the integers from 1 to @expr{n}, and 7492triangular number is the sum of the integers from 1 to @expr{n}, and
7500can be computed directly by the formula 7493can be computed directly by the formula
7501@texline @tmath{n (n+1) \over 2}. 7494@texline @math{n (n+1) \over 2}.
7502@infoline @expr{n * (n+1) / 2}. 7495@infoline @expr{n * (n+1) / 2}.
7503 7496
7504@smallexample 7497@smallexample
@@ -7594,7 +7587,7 @@ A way to isolate the maximum value is to compute the maximum using
7594@noindent 7587@noindent
7595It's a good idea to verify, as in the last step above, that only 7588It's a good idea to verify, as in the last step above, that only
7596one value is equal to the maximum. (After all, a plot of 7589one value is equal to the maximum. (After all, a plot of
7597@texline @tmath{\sin x} 7590@texline @math{\sin x}
7598@infoline @expr{sin(x)} 7591@infoline @expr{sin(x)}
7599might have many points all equal to the maximum value, 1.) 7592might have many points all equal to the maximum value, 1.)
7600 7593
@@ -7866,10 +7859,10 @@ This problem can be made a lot easier by taking advantage of some
7866symmetries. First of all, after some thought it's clear that the 7859symmetries. First of all, after some thought it's clear that the
7867@expr{y} axis can be ignored altogether. Just pick a random @expr{x} 7860@expr{y} axis can be ignored altogether. Just pick a random @expr{x}
7868component for one end of the match, pick a random direction 7861component for one end of the match, pick a random direction
7869@texline @tmath{\theta}, 7862@texline @math{\theta},
7870@infoline @expr{theta}, 7863@infoline @expr{theta},
7871and see if @expr{x} and 7864and see if @expr{x} and
7872@texline @tmath{x + \cos \theta} 7865@texline @math{x + \cos \theta}
7873@infoline @expr{x + cos(theta)} 7866@infoline @expr{x + cos(theta)}
7874(which is the @expr{x} coordinate of the other endpoint) cross a line. 7867(which is the @expr{x} coordinate of the other endpoint) cross a line.
7875The lines are at integer coordinates, so this happens when the two 7868The lines are at integer coordinates, so this happens when the two
@@ -7886,10 +7879,10 @@ coordinates 0 and 1 for the lines on either side of the leftmost
7886endpoint. The rightmost endpoint will be between 0 and 1 if the 7879endpoint. The rightmost endpoint will be between 0 and 1 if the
7887match does not cross a line, or between 1 and 2 if it does. So: 7880match does not cross a line, or between 1 and 2 if it does. So:
7888Pick random @expr{x} and 7881Pick random @expr{x} and
7889@texline @tmath{\theta}, 7882@texline @math{\theta},
7890@infoline @expr{theta}, 7883@infoline @expr{theta},
7891compute 7884compute
7892@texline @tmath{x + \cos \theta}, 7885@texline @math{x + \cos \theta},
7893@infoline @expr{x + cos(theta)}, 7886@infoline @expr{x + cos(theta)},
7894and count how many of the results are greater than one. Simple! 7887and count how many of the results are greater than one. Simple!
7895 7888
@@ -8214,7 +8207,7 @@ precision slightly and try again:
8214@noindent 8207@noindent
8215Aha! It's unlikely that an irrational number would equal a fraction 8208Aha! It's unlikely that an irrational number would equal a fraction
8216this simple to within ten digits, so our original number was probably 8209this simple to within ten digits, so our original number was probably
8217@texline @tmath{\sqrt{27 \pi / 53}}. 8210@texline @math{\sqrt{27 \pi / 53}}.
8218@infoline @expr{sqrt(27 pi / 53)}. 8211@infoline @expr{sqrt(27 pi / 53)}.
8219 8212
8220Notice that we didn't need to re-round the number when we reduced the 8213Notice that we didn't need to re-round the number when we reduced the
@@ -8475,9 +8468,9 @@ as a possible value.
8475The fourth calculation, @samp{1 / (-10 .. 10)}, has the same problem. 8468The fourth calculation, @samp{1 / (-10 .. 10)}, has the same problem.
8476Zero is buried inside the interval, but it's still a possible value. 8469Zero is buried inside the interval, but it's still a possible value.
8477It's not hard to see that the actual result of @samp{1 / (-10 .. 10)} 8470It's not hard to see that the actual result of @samp{1 / (-10 .. 10)}
8478will be either greater than @i{0.1}, or less than @i{-0.1}. Thus 8471will be either greater than @mathit{0.1}, or less than @mathit{-0.1}. Thus
8479the interval goes from minus infinity to plus infinity, with a ``hole'' 8472the interval goes from minus infinity to plus infinity, with a ``hole''
8480in it from @i{-0.1} to @i{0.1}. Calc doesn't have any way to 8473in it from @mathit{-0.1} to @mathit{0.1}. Calc doesn't have any way to
8481represent this, so it just reports @samp{[-inf .. inf]} as the answer. 8474represent this, so it just reports @samp{[-inf .. inf]} as the answer.
8482It may be disappointing to hear ``the answer lies somewhere between 8475It may be disappointing to hear ``the answer lies somewhere between
8483minus infinity and plus infinity, inclusive,'' but that's the best 8476minus infinity and plus infinity, inclusive,'' but that's the best
@@ -8497,9 +8490,9 @@ that interval arithmetic can do in this case.
8497@end smallexample 8490@end smallexample
8498 8491
8499@noindent 8492@noindent
8500In the first case the result says, ``if a number is between @i{-3} and 8493In the first case the result says, ``if a number is between @mathit{-3} and
85013, its square is between 0 and 9.'' The second case says, ``the product 84943, its square is between 0 and 9.'' The second case says, ``the product
8502of two numbers each between @i{-3} and 3 is between @i{-9} and 9.'' 8495of two numbers each between @mathit{-3} and 3 is between @mathit{-9} and 9.''
8503 8496
8504An interval form is not a number; it is a symbol that can stand for 8497An interval form is not a number; it is a symbol that can stand for
8505many different numbers. Two identical-looking interval forms can stand 8498many different numbers. Two identical-looking interval forms can stand
@@ -9255,7 +9248,7 @@ algebraic entry, whichever way you prefer:
9255 9248
9256@noindent 9249@noindent
9257Computing 9250Computing
9258@texline @tmath{\displaystyle{\sin x \over x}}: 9251@texline @math{\displaystyle{\sin x \over x}}:
9259@infoline @expr{sin(x) / x}: 9252@infoline @expr{sin(x) / x}:
9260 9253
9261Using the stack: @kbd{C-x ( @key{RET} S @key{TAB} / C-x )}. 9254Using the stack: @kbd{C-x ( @key{RET} S @key{TAB} / C-x )}.
@@ -9326,7 +9319,7 @@ C-x ( ' [0, 1; 1, 1] ^ ($-1) * [1, 1] @key{RET} v u @key{DEL} C-x )
9326@noindent 9319@noindent
9327This program is quite efficient because Calc knows how to raise a 9320This program is quite efficient because Calc knows how to raise a
9328matrix (or other value) to the power @expr{n} in only 9321matrix (or other value) to the power @expr{n} in only
9329@texline @tmath{\log_2 n} 9322@texline @math{\log_2 n}
9330@infoline @expr{log(n,2)} 9323@infoline @expr{log(n,2)}
9331steps. For example, this program can compute the 1000th Fibonacci 9324steps. For example, this program can compute the 1000th Fibonacci
9332number (a 209-digit integer!) in about 10 steps; even though the 9325number (a 209-digit integer!) in about 10 steps; even though the
@@ -9380,7 +9373,7 @@ harmonic number is 4.02.
9380@noindent 9373@noindent
9381The first step is to compute the derivative @expr{f'(x)} and thus 9374The first step is to compute the derivative @expr{f'(x)} and thus
9382the formula 9375the formula
9383@texline @tmath{\displaystyle{x - {f(x) \over f'(x)}}}. 9376@texline @math{\displaystyle{x - {f(x) \over f'(x)}}}.
9384@infoline @expr{x - f(x)/f'(x)}. 9377@infoline @expr{x - f(x)/f'(x)}.
9385 9378
9386(Because this definition is long, it will be repeated in concise form 9379(Because this definition is long, it will be repeated in concise form
@@ -9497,10 +9490,10 @@ method (among others) to look for numerical solutions to any equation.
9497The first step is to adjust @expr{z} to be greater than 5. A simple 9490The first step is to adjust @expr{z} to be greater than 5. A simple
9498``for'' loop will do the job here. If @expr{z} is less than 5, we 9491``for'' loop will do the job here. If @expr{z} is less than 5, we
9499reduce the problem using 9492reduce the problem using
9500@texline @tmath{\psi(z) = \psi(z+1) - 1/z}. 9493@texline @math{\psi(z) = \psi(z+1) - 1/z}.
9501@infoline @expr{psi(z) = psi(z+1) - 1/z}. We go 9494@infoline @expr{psi(z) = psi(z+1) - 1/z}. We go
9502on to compute 9495on to compute
9503@texline @tmath{\psi(z+1)}, 9496@texline @math{\psi(z+1)},
9504@infoline @expr{psi(z+1)}, 9497@infoline @expr{psi(z+1)},
9505and remember to add back a factor of @expr{-1/z} when we're done. This 9498and remember to add back a factor of @expr{-1/z} when we're done. This
9506step is repeated until @expr{z > 5}. 9499step is repeated until @expr{z > 5}.
@@ -9541,7 +9534,7 @@ are exactly equal, not just equal to within the current precision.)
9541@end smallexample 9534@end smallexample
9542 9535
9543Now we compute the initial part of the sum: 9536Now we compute the initial part of the sum:
9544@texline @tmath{\ln z - {1 \over 2z}} 9537@texline @math{\ln z - {1 \over 2z}}
9545@infoline @expr{ln(z) - 1/2z} 9538@infoline @expr{ln(z) - 1/2z}
9546minus the adjustment factor. 9539minus the adjustment factor.
9547 9540
@@ -9584,7 +9577,7 @@ up the value of @expr{2 n}. (Calc does have a summation command,
9584@end smallexample 9577@end smallexample
9585 9578
9586This is the value of 9579This is the value of
9587@texline @tmath{-\gamma}, 9580@texline @math{-\gamma},
9588@infoline @expr{- gamma}, 9581@infoline @expr{- gamma},
9589with a slight bit of roundoff error. To get a full 12 digits, let's use 9582with a slight bit of roundoff error. To get a full 12 digits, let's use
9590a higher precision: 9583a higher precision:
@@ -9619,7 +9612,7 @@ C-x )
9619@noindent 9612@noindent
9620Taking the derivative of a term of the form @expr{x^n} will produce 9613Taking the derivative of a term of the form @expr{x^n} will produce
9621a term like 9614a term like
9622@texline @tmath{n x^{n-1}}. 9615@texline @math{n x^{n-1}}.
9623@infoline @expr{n x^(n-1)}. 9616@infoline @expr{n x^(n-1)}.
9624Taking the derivative of a constant 9617Taking the derivative of a constant
9625produces zero. From this it is easy to see that the @expr{n}th 9618produces zero. From this it is easy to see that the @expr{n}th
@@ -10193,7 +10186,7 @@ The first three keystrokes ``push'' the numbers 1 and 2 onto the stack. The
10193@kbd{+} key always ``pops'' the top two numbers from the stack, adds them, 10186@kbd{+} key always ``pops'' the top two numbers from the stack, adds them,
10194and pushes the result (3) back onto the stack. This number is ready for 10187and pushes the result (3) back onto the stack. This number is ready for
10195further calculations: @kbd{5 -} pushes 5 onto the stack, then pops the 10188further calculations: @kbd{5 -} pushes 5 onto the stack, then pops the
101963 and 5, subtracts them, and pushes the result (@i{-2}). 101893 and 5, subtracts them, and pushes the result (@mathit{-2}).
10197 10190
10198Note that the ``top'' of the stack actually appears at the @emph{bottom} 10191Note that the ``top'' of the stack actually appears at the @emph{bottom}
10199of the buffer. A line containing a single @samp{.} character signifies 10192of the buffer. A line containing a single @samp{.} character signifies
@@ -10256,7 +10249,7 @@ the two numbers on the top of the stack. The @kbd{n} key changes the sign
10256of the number on the top of the stack or the number currently being entered. 10249of the number on the top of the stack or the number currently being entered.
10257The @kbd{_} key begins entry of a negative number or changes the sign of 10250The @kbd{_} key begins entry of a negative number or changes the sign of
10258the number currently being entered. The following sequences all enter the 10251the number currently being entered. The following sequences all enter the
10259number @i{-5} onto the stack: @kbd{0 @key{RET} 5 -}, @kbd{5 n @key{RET}}, 10252number @mathit{-5} onto the stack: @kbd{0 @key{RET} 5 -}, @kbd{5 n @key{RET}},
10260@kbd{5 @key{RET} n}, @kbd{_ 5 @key{RET}}, @kbd{5 _ @key{RET}}. 10253@kbd{5 @key{RET} n}, @kbd{_ 5 @key{RET}}, @kbd{5 _ @key{RET}}.
10261 10254
10262Some other keys are active during numeric entry, such as @kbd{#} for 10255Some other keys are active during numeric entry, such as @kbd{#} for
@@ -10277,7 +10270,7 @@ During numeric entry, the only editing key available is @key{DEL}.
10277Calculations can also be entered in algebraic form. This is accomplished 10270Calculations can also be entered in algebraic form. This is accomplished
10278by typing the apostrophe key, @kbd{'}, followed by the expression in 10271by typing the apostrophe key, @kbd{'}, followed by the expression in
10279standard format: @kbd{@key{'} 2+3*4 @key{RET}} computes 10272standard format: @kbd{@key{'} 2+3*4 @key{RET}} computes
10280@texline @tmath{2+(3\times4) = 14} 10273@texline @math{2+(3\times4) = 14}
10281@infoline @expr{2+(3*4) = 14} 10274@infoline @expr{2+(3*4) = 14}
10282and pushes that on the stack. If you wish you can 10275and pushes that on the stack. If you wish you can
10283ignore the RPN aspect of Calc altogether and simply enter algebraic 10276ignore the RPN aspect of Calc altogether and simply enter algebraic
@@ -10687,7 +10680,7 @@ approximation. This value will not need to be recomputed ever again
10687unless you raise the precision still further. Many operations such as 10680unless you raise the precision still further. Many operations such as
10688logarithms and sines make use of similarly cached values such as 10681logarithms and sines make use of similarly cached values such as
10689@cpiover{4} and 10682@cpiover{4} and
10690@texline @tmath{\ln 2}. 10683@texline @math{\ln 2}.
10691@infoline @expr{ln(2)}. 10684@infoline @expr{ln(2)}.
10692The visible effect of caching is that 10685The visible effect of caching is that
10693high-precision computations may seem to do extra work the first time. 10686high-precision computations may seem to do extra work the first time.
@@ -10846,10 +10839,10 @@ A floating-point number or @dfn{float} is a number stored in scientific
10846notation. The number of significant digits in the fractional part is 10839notation. The number of significant digits in the fractional part is
10847governed by the current floating precision (@pxref{Precision}). The 10840governed by the current floating precision (@pxref{Precision}). The
10848range of acceptable values is from 10841range of acceptable values is from
10849@texline @tmath{10^{-3999999}} 10842@texline @math{10^{-3999999}}
10850@infoline @expr{10^-3999999} 10843@infoline @expr{10^-3999999}
10851(inclusive) to 10844(inclusive) to
10852@texline @tmath{10^{4000000}} 10845@texline @math{10^{4000000}}
10853@infoline @expr{10^4000000} 10846@infoline @expr{10^4000000}
10854(exclusive), plus the corresponding negative values and zero. 10847(exclusive), plus the corresponding negative values and zero.
10855 10848
@@ -10921,16 +10914,16 @@ Rectangular complex numbers can also be displayed in @samp{@var{a}+@var{b}i}
10921notation; @pxref{Complex Formats}. 10914notation; @pxref{Complex Formats}.
10922 10915
10923Polar complex numbers are displayed in the form 10916Polar complex numbers are displayed in the form
10924@texline `@t{(}@var{r}@t{;}@tmath{\theta}@t{)}' 10917@texline `@t{(}@var{r}@t{;}@math{\theta}@t{)}'
10925@infoline `@t{(}@var{r}@t{;}@var{theta}@t{)}' 10918@infoline `@t{(}@var{r}@t{;}@var{theta}@t{)}'
10926where @var{r} is the nonnegative magnitude and 10919where @var{r} is the nonnegative magnitude and
10927@texline @tmath{\theta} 10920@texline @math{\theta}
10928@infoline @var{theta} 10921@infoline @var{theta}
10929is the argument or phase angle. The range of 10922is the argument or phase angle. The range of
10930@texline @tmath{\theta} 10923@texline @math{\theta}
10931@infoline @var{theta} 10924@infoline @var{theta}
10932depends on the current angular mode (@pxref{Angular Modes}); it is 10925depends on the current angular mode (@pxref{Angular Modes}); it is
10933generally between @i{-180} and @i{+180} degrees or the equivalent range 10926generally between @mathit{-180} and @mathit{+180} degrees or the equivalent range
10934in radians. 10927in radians.
10935 10928
10936Complex numbers are entered in stages using incomplete objects. 10929Complex numbers are entered in stages using incomplete objects.
@@ -10973,7 +10966,7 @@ larger, becomes arbitrarily close to zero. So you can imagine
10973that if @expr{x} got ``all the way to infinity,'' then @expr{1 / x} 10966that if @expr{x} got ``all the way to infinity,'' then @expr{1 / x}
10974would go all the way to zero. Similarly, when they say that 10967would go all the way to zero. Similarly, when they say that
10975@samp{exp(inf) = inf}, they mean that 10968@samp{exp(inf) = inf}, they mean that
10976@texline @tmath{e^x} 10969@texline @math{e^x}
10977@infoline @expr{exp(x)} 10970@infoline @expr{exp(x)}
10978grows without bound as @expr{x} grows. The symbol @samp{-inf} likewise 10971grows without bound as @expr{x} grows. The symbol @samp{-inf} likewise
10979stands for an infinitely negative real value; for example, we say that 10972stands for an infinitely negative real value; for example, we say that
@@ -11070,7 +11063,7 @@ of its elements.
11070@tindex vec 11063@tindex vec
11071Algebraic functions for building vectors include @samp{vec(a, b, c)} 11064Algebraic functions for building vectors include @samp{vec(a, b, c)}
11072to build @samp{[a, b, c]}, @samp{cvec(a, n, m)} to build an 11065to build @samp{[a, b, c]}, @samp{cvec(a, n, m)} to build an
11073@texline @tmath{n\times m} 11066@texline @math{n\times m}
11074@infoline @var{n}x@var{m} 11067@infoline @var{n}x@var{m}
11075matrix of @samp{a}s, and @samp{index(n)} to build a vector of integers 11068matrix of @samp{a}s, and @samp{index(n)} to build a vector of integers
11076from 1 to @samp{n}. 11069from 1 to @samp{n}.
@@ -11201,7 +11194,7 @@ The @var{mins} value is an integer or integer-valued float between 0 and 59.
11201The @var{secs} value is a real number between 0 (inclusive) and 60 11194The @var{secs} value is a real number between 0 (inclusive) and 60
11202(exclusive). A positive HMS form is interpreted as @var{hours} + 11195(exclusive). A positive HMS form is interpreted as @var{hours} +
11203@var{mins}/60 + @var{secs}/3600. A negative HMS form is interpreted 11196@var{mins}/60 + @var{secs}/3600. A negative HMS form is interpreted
11204as @i{- @var{hours}} @i{-} @var{mins}/60 @i{-} @var{secs}/3600. 11197as @mathit{- @var{hours}} @mathit{-} @var{mins}/60 @mathit{-} @var{secs}/3600.
11205Display format for HMS forms is quite flexible. @xref{HMS Formats}. 11198Display format for HMS forms is quite flexible. @xref{HMS Formats}.
11206 11199
11207HMS forms can be added and subtracted. When they are added to numbers, 11200HMS forms can be added and subtracted. When they are added to numbers,
@@ -11295,12 +11288,12 @@ between, say, @samp{<12:00am Mon Jan 1, 1900>} and
11295 11288
11296Calc uses the Julian calendar for all dates before the year 1752, 11289Calc uses the Julian calendar for all dates before the year 1752,
11297including dates BC when the Julian calendar technically had not 11290including dates BC when the Julian calendar technically had not
11298yet been invented. Thus the claim that day number @i{-10000} is 11291yet been invented. Thus the claim that day number @mathit{-10000} is
11299called ``August 16, 28 BC'' should be taken with a grain of salt. 11292called ``August 16, 28 BC'' should be taken with a grain of salt.
11300 11293
11301Please note that there is no ``year 0''; the day before 11294Please note that there is no ``year 0''; the day before
11302@samp{<Sat Jan 1, +1>} is @samp{<Fri Dec 31, -1>}. These are 11295@samp{<Sat Jan 1, +1>} is @samp{<Fri Dec 31, -1>}. These are
11303days 0 and @i{-1} respectively in Calc's internal numbering scheme. 11296days 0 and @mathit{-1} respectively in Calc's internal numbering scheme.
11304 11297
11305@cindex Julian day counting 11298@cindex Julian day counting
11306Another day counting system in common use is, confusingly, also 11299Another day counting system in common use is, confusingly, also
@@ -11308,7 +11301,7 @@ called ``Julian.'' It was invented in 1583 by Joseph Justus
11308Scaliger, who named it in honor of his father Julius Caesar 11301Scaliger, who named it in honor of his father Julius Caesar
11309Scaliger. For obscure reasons he chose to start his day 11302Scaliger. For obscure reasons he chose to start his day
11310numbering on Jan 1, 4713 BC at noon, which in Calc's scheme 11303numbering on Jan 1, 4713 BC at noon, which in Calc's scheme
11311is @i{-1721423.5} (recall that Calc starts at midnight instead 11304is @mathit{-1721423.5} (recall that Calc starts at midnight instead
11312of noon). Thus to convert a Calc date code obtained by 11305of noon). Thus to convert a Calc date code obtained by
11313unpacking a date form into a Julian day number, simply add 11306unpacking a date form into a Julian day number, simply add
113141721423.5. The Julian code for @samp{6:00am Jan 9, 1991} 113071721423.5. The Julian code for @samp{6:00am Jan 9, 1991}
@@ -11341,7 +11334,7 @@ an integer multiple of) some value @var{M}. Arithmetic modulo @var{M}
11341often arises in number theory. Modulo forms are written 11334often arises in number theory. Modulo forms are written
11342`@var{a} @t{mod} @var{M}', 11335`@var{a} @t{mod} @var{M}',
11343where @var{a} and @var{M} are real numbers or HMS forms, and 11336where @var{a} and @var{M} are real numbers or HMS forms, and
11344@texline @tmath{0 \le a < M}. 11337@texline @math{0 \le a < M}.
11345@infoline @expr{0 <= a < @var{M}}. 11338@infoline @expr{0 <= a < @var{M}}.
11346In many applications @expr{a} and @expr{M} will be 11339In many applications @expr{a} and @expr{M} will be
11347integers but this is not required. 11340integers but this is not required.
@@ -11373,7 +11366,7 @@ division is left in symbolic form. Other operations, such as square
11373roots, are not yet supported for modulo forms. (Note that, although 11366roots, are not yet supported for modulo forms. (Note that, although
11374@w{`@t{(}@var{a} @t{mod} @var{M}@t{)^.5}'} will compute a ``modulo square root'' 11367@w{`@t{(}@var{a} @t{mod} @var{M}@t{)^.5}'} will compute a ``modulo square root''
11375in the sense of reducing 11368in the sense of reducing
11376@texline @tmath{\sqrt a} 11369@texline @math{\sqrt a}
11377@infoline @expr{sqrt(a)} 11370@infoline @expr{sqrt(a)}
11378modulo @expr{M}, this is not a useful definition from the 11371modulo @expr{M}, this is not a useful definition from the
11379number-theoretical point of view.) 11372number-theoretical point of view.)
@@ -11423,12 +11416,12 @@ The algebraic function @samp{makemod(a, m)} builds the modulo form
11423@cindex Standard deviations 11416@cindex Standard deviations
11424An @dfn{error form} is a number with an associated standard 11417An @dfn{error form} is a number with an associated standard
11425deviation, as in @samp{2.3 +/- 0.12}. The notation 11418deviation, as in @samp{2.3 +/- 0.12}. The notation
11426@texline `@var{x} @t{+/-} @tmath{\sigma}' 11419@texline `@var{x} @t{+/-} @math{\sigma}'
11427@infoline `@var{x} @t{+/-} sigma' 11420@infoline `@var{x} @t{+/-} sigma'
11428stands for an uncertain value which follows 11421stands for an uncertain value which follows
11429a normal or Gaussian distribution of mean @expr{x} and standard 11422a normal or Gaussian distribution of mean @expr{x} and standard
11430deviation or ``error'' 11423deviation or ``error''
11431@texline @tmath{\sigma}. 11424@texline @math{\sigma}.
11432@infoline @expr{sigma}. 11425@infoline @expr{sigma}.
11433Both the mean and the error can be either numbers or 11426Both the mean and the error can be either numbers or
11434formulas. Generally these are real numbers but the mean may also be 11427formulas. Generally these are real numbers but the mean may also be
@@ -11439,7 +11432,7 @@ regular number by the Calculator.
11439All arithmetic and transcendental functions accept error forms as input. 11432All arithmetic and transcendental functions accept error forms as input.
11440Operations on the mean-value part work just like operations on regular 11433Operations on the mean-value part work just like operations on regular
11441numbers. The error part for any function @expr{f(x)} (such as 11434numbers. The error part for any function @expr{f(x)} (such as
11442@texline @tmath{\sin x} 11435@texline @math{\sin x}
11443@infoline @expr{sin(x)}) 11436@infoline @expr{sin(x)})
11444is defined by the error of @expr{x} times the derivative of @expr{f} 11437is defined by the error of @expr{x} times the derivative of @expr{f}
11445evaluated at the mean value of @expr{x}. For a two-argument function 11438evaluated at the mean value of @expr{x}. For a two-argument function
@@ -11470,34 +11463,34 @@ Consult a good text on error analysis for a discussion of the proper use
11470of standard deviations. Actual errors often are neither Gaussian-distributed 11463of standard deviations. Actual errors often are neither Gaussian-distributed
11471nor uncorrelated, and the above formulas are valid only when errors 11464nor uncorrelated, and the above formulas are valid only when errors
11472are small. As an example, the error arising from 11465are small. As an example, the error arising from
11473@texline `@t{sin(}@var{x} @t{+/-} @tmath{\sigma}@t{)}' 11466@texline `@t{sin(}@var{x} @t{+/-} @math{\sigma}@t{)}'
11474@infoline `@t{sin(}@var{x} @t{+/-} @var{sigma}@t{)}' 11467@infoline `@t{sin(}@var{x} @t{+/-} @var{sigma}@t{)}'
11475is 11468is
11476@texline `@tmath{\sigma} @t{abs(cos(}@var{x}@t{))}'. 11469@texline `@math{\sigma} @t{abs(cos(}@var{x}@t{))}'.
11477@infoline `@var{sigma} @t{abs(cos(}@var{x}@t{))}'. 11470@infoline `@var{sigma} @t{abs(cos(}@var{x}@t{))}'.
11478When @expr{x} is close to zero, 11471When @expr{x} is close to zero,
11479@texline @tmath{\cos x} 11472@texline @math{\cos x}
11480@infoline @expr{cos(x)} 11473@infoline @expr{cos(x)}
11481is close to one so the error in the sine is close to 11474is close to one so the error in the sine is close to
11482@texline @tmath{\sigma}; 11475@texline @math{\sigma};
11483@infoline @expr{sigma}; 11476@infoline @expr{sigma};
11484this makes sense, since 11477this makes sense, since
11485@texline @tmath{\sin x} 11478@texline @math{\sin x}
11486@infoline @expr{sin(x)} 11479@infoline @expr{sin(x)}
11487is approximately @expr{x} near zero, so a given error in @expr{x} will 11480is approximately @expr{x} near zero, so a given error in @expr{x} will
11488produce about the same error in the sine. Likewise, near 90 degrees 11481produce about the same error in the sine. Likewise, near 90 degrees
11489@texline @tmath{\cos x} 11482@texline @math{\cos x}
11490@infoline @expr{cos(x)} 11483@infoline @expr{cos(x)}
11491is nearly zero and so the computed error is 11484is nearly zero and so the computed error is
11492small: The sine curve is nearly flat in that region, so an error in @expr{x} 11485small: The sine curve is nearly flat in that region, so an error in @expr{x}
11493has relatively little effect on the value of 11486has relatively little effect on the value of
11494@texline @tmath{\sin x}. 11487@texline @math{\sin x}.
11495@infoline @expr{sin(x)}. 11488@infoline @expr{sin(x)}.
11496However, consider @samp{sin(90 +/- 1000)}. The cosine of 90 is zero, so 11489However, consider @samp{sin(90 +/- 1000)}. The cosine of 90 is zero, so
11497Calc will report zero error! We get an obviously wrong result because 11490Calc will report zero error! We get an obviously wrong result because
11498we have violated the small-error approximation underlying the error 11491we have violated the small-error approximation underlying the error
11499analysis. If the error in @expr{x} had been small, the error in 11492analysis. If the error in @expr{x} had been small, the error in
11500@texline @tmath{\sin x} 11493@texline @math{\sin x}
11501@infoline @expr{sin(x)} 11494@infoline @expr{sin(x)}
11502would indeed have been negligible. 11495would indeed have been negligible.
11503 11496
@@ -11606,11 +11599,11 @@ contain zero inside them Calc is forced to give the result,
11606While it may seem that intervals and error forms are similar, they are 11599While it may seem that intervals and error forms are similar, they are
11607based on entirely different concepts of inexact quantities. An error 11600based on entirely different concepts of inexact quantities. An error
11608form 11601form
11609@texline `@var{x} @t{+/-} @tmath{\sigma}' 11602@texline `@var{x} @t{+/-} @math{\sigma}'
11610@infoline `@var{x} @t{+/-} @var{sigma}' 11603@infoline `@var{x} @t{+/-} @var{sigma}'
11611means a variable is random, and its value could 11604means a variable is random, and its value could
11612be anything but is ``probably'' within one 11605be anything but is ``probably'' within one
11613@texline @tmath{\sigma} 11606@texline @math{\sigma}
11614@infoline @var{sigma} 11607@infoline @var{sigma}
11615of the mean value @expr{x}. An interval 11608of the mean value @expr{x}. An interval
11616`@t{[}@var{a} @t{..@:} @var{b}@t{]}' means a 11609`@t{[}@var{a} @t{..@:} @var{b}@t{]}' means a
@@ -11844,7 +11837,7 @@ the C-style ``if'' operator @samp{a?b:c} [@code{if}];
11844 11837
11845Note that, unlike in usual computer notation, multiplication binds more 11838Note that, unlike in usual computer notation, multiplication binds more
11846strongly than division: @samp{a*b/c*d} is equivalent to 11839strongly than division: @samp{a*b/c*d} is equivalent to
11847@texline @tmath{a b \over c d}. 11840@texline @math{a b \over c d}.
11848@infoline @expr{(a*b)/(c*d)}. 11841@infoline @expr{(a*b)/(c*d)}.
11849 11842
11850@cindex Multiplication, implicit 11843@cindex Multiplication, implicit
@@ -12042,11 +12035,11 @@ intervening stack elements toward the top. @kbd{M-@key{TAB}} moves the
12042element at level @var{n} up to the top. (Compare with @key{LFD}, 12035element at level @var{n} up to the top. (Compare with @key{LFD},
12043which copies instead of moving the element in level @var{n}.) 12036which copies instead of moving the element in level @var{n}.)
12044 12037
12045With a negative argument @i{-@var{n}}, @key{TAB} rotates the stack 12038With a negative argument @mathit{-@var{n}}, @key{TAB} rotates the stack
12046to move the object in level @var{n} to the deepest place in the 12039to move the object in level @var{n} to the deepest place in the
12047stack, and the object in level @i{@var{n}+1} to the top. @kbd{M-@key{TAB}} 12040stack, and the object in level @mathit{@var{n}+1} to the top. @kbd{M-@key{TAB}}
12048rotates the deepest stack element to be in level @i{n}, also 12041rotates the deepest stack element to be in level @mathit{n}, also
12049putting the top stack element in level @i{@var{n}+1}. 12042putting the top stack element in level @mathit{@var{n}+1}.
12050 12043
12051@xref{Selecting Subformulas}, for a way to apply these commands to 12044@xref{Selecting Subformulas}, for a way to apply these commands to
12052any portion of a vector or formula on the stack. 12045any portion of a vector or formula on the stack.
@@ -12341,8 +12334,8 @@ inside it, @kbd{m F} will not automatically load the new file. This
12341is because you are presumably switching to your @file{~/.emacs} file, 12334is because you are presumably switching to your @file{~/.emacs} file,
12342which may contain other things you don't want to reread. You can give 12335which may contain other things you don't want to reread. You can give
12343a numeric prefix argument of 1 to @kbd{m F} to force it to read the 12336a numeric prefix argument of 1 to @kbd{m F} to force it to read the
12344file no matter what its name. Conversely, an argument of @i{-1} tells 12337file no matter what its name. Conversely, an argument of @mathit{-1} tells
12345@kbd{m F} @emph{not} to read the new file. An argument of 2 or @i{-2} 12338@kbd{m F} @emph{not} to read the new file. An argument of 2 or @mathit{-2}
12346tells @kbd{m F} not to reset the modes to their defaults beforehand, 12339tells @kbd{m F} not to reset the modes to their defaults beforehand,
12347which is useful if you intend your new file to have a variant of the 12340which is useful if you intend your new file to have a variant of the
12348modes present in the file you were using before. 12341modes present in the file you were using before.
@@ -12447,7 +12440,7 @@ Hyperbolic Flag, which transforms @code{calc-sin} into @code{calc-sinh}.
12447If both of these flags are set at once, the effect will be 12440If both of these flags are set at once, the effect will be
12448@code{calc-arcsinh}. (The Hyperbolic flag is also used by some 12441@code{calc-arcsinh}. (The Hyperbolic flag is also used by some
12449non-trigonometric commands; for example @kbd{H L} computes a base-10, 12442non-trigonometric commands; for example @kbd{H L} computes a base-10,
12450instead of base-@i{e}, logarithm.) 12443instead of base-@mathit{e}, logarithm.)
12451 12444
12452Command names like @code{calc-arcsin} are provided for completeness, and 12445Command names like @code{calc-arcsin} are provided for completeness, and
12453may be executed with @kbd{x} or @kbd{M-x}. Their effect is simply to 12446may be executed with @kbd{x} or @kbd{M-x}. Their effect is simply to
@@ -12591,7 +12584,7 @@ i.e., @kbd{C-u 0 m i}, turns on a ``positive infinite mode'' in
12591which zero is treated as positive instead of being directionless. 12584which zero is treated as positive instead of being directionless.
12592Thus, @samp{1 / 0 = inf} and @samp{-1 / 0 = -inf} in this mode. 12585Thus, @samp{1 / 0 = inf} and @samp{-1 / 0 = -inf} in this mode.
12593Note that zero never actually has a sign in Calc; there are no 12586Note that zero never actually has a sign in Calc; there are no
12594separate representations for @i{+0} and @i{-0}. Positive 12587separate representations for @mathit{+0} and @mathit{-0}. Positive
12595infinite mode merely changes the interpretation given to the 12588infinite mode merely changes the interpretation given to the
12596single symbol, @samp{0}. One consequence of this is that, while 12589single symbol, @samp{0}. One consequence of this is that, while
12597you might expect @samp{1 / -0 = -inf}, actually @samp{1 / -0} 12590you might expect @samp{1 / -0 = -inf}, actually @samp{1 / -0}
@@ -12982,7 +12975,7 @@ Numbers. (Real or complex.)
12982Calc uses this information to determine when certain simplifications 12975Calc uses this information to determine when certain simplifications
12983of formulas are safe. For example, @samp{(x^y)^z} cannot be 12976of formulas are safe. For example, @samp{(x^y)^z} cannot be
12984simplified to @samp{x^(y z)} in general; for example, 12977simplified to @samp{x^(y z)} in general; for example,
12985@samp{((-3)^2)^1:2} is 3, but @samp{(-3)^(2*1:2) = (-3)^1} is @i{-3}. 12978@samp{((-3)^2)^1:2} is 3, but @samp{(-3)^(2*1:2) = (-3)^1} is @mathit{-3}.
12986However, this simplification @emph{is} safe if @code{z} is known 12979However, this simplification @emph{is} safe if @code{z} is known
12987to be an integer, or if @code{x} is known to be a nonnegative 12980to be an integer, or if @code{x} is known to be a nonnegative
12988real number. If you have given declarations that allow Calc to 12981real number. If you have given declarations that allow Calc to
@@ -13095,7 +13088,7 @@ The value is a constant with respect to other variables.
13095@end table 13088@end table
13096 13089
13097Calc does not check the declarations for a variable when you store 13090Calc does not check the declarations for a variable when you store
13098a value in it. However, storing @i{-3.5} in a variable that has 13091a value in it. However, storing @mathit{-3.5} in a variable that has
13099been declared @code{pos}, @code{int}, or @code{matrix} may have 13092been declared @code{pos}, @code{int}, or @code{matrix} may have
13100unexpected effects; Calc may evaluate @samp{sqrt(x^2)} to @expr{3.5} 13093unexpected effects; Calc may evaluate @samp{sqrt(x^2)} to @expr{3.5}
13101if it substitutes the value first, or to @expr{-3.5} if @code{x} 13094if it substitutes the value first, or to @expr{-3.5} if @code{x}
@@ -13330,7 +13323,7 @@ command causes integers to be padded out with leading zeros according to the
13330current binary word size. (@xref{Binary Functions}, for a discussion of 13323current binary word size. (@xref{Binary Functions}, for a discussion of
13331word size.) If the absolute value of the word size is @expr{w}, all integers 13324word size.) If the absolute value of the word size is @expr{w}, all integers
13332are displayed with at least enough digits to represent 13325are displayed with at least enough digits to represent
13333@texline @tmath{2^w-1} 13326@texline @math{2^w-1}
13334@infoline @expr{(2^w)-1} 13327@infoline @expr{(2^w)-1}
13335in the current radix. (Larger integers will still be displayed in their 13328in the current radix. (Larger integers will still be displayed in their
13336entirety.) 13329entirety.)
@@ -14231,10 +14224,10 @@ special names (like @code{\sin}) will use curly braces instead of
14231parentheses for very simple arguments. During input, curly braces and 14224parentheses for very simple arguments. During input, curly braces and
14232parentheses work equally well for grouping, but when the document is 14225parentheses work equally well for grouping, but when the document is
14233formatted the curly braces will be invisible. Thus the printed result is 14226formatted the curly braces will be invisible. Thus the printed result is
14234@texline @tmath{\sin{2 x}} 14227@texline @math{\sin{2 x}}
14235@infoline @expr{sin 2x} 14228@infoline @expr{sin 2x}
14236but 14229but
14237@texline @tmath{\sin(2 + x)}. 14230@texline @math{\sin(2 + x)}.
14238@infoline @expr{sin(2 + x)}. 14231@infoline @expr{sin(2 + x)}.
14239 14232
14240Function and variable names not treated specially by @TeX{} are simply 14233Function and variable names not treated specially by @TeX{} are simply
@@ -15728,19 +15721,19 @@ Polar mode. Value is 0 (rectangular) or 1 (polar); default is 0.
15728Command is @kbd{m p}. 15721Command is @kbd{m p}.
15729 15722
15730@item 15723@item
15731Matrix/scalar mode. Default value is @i{-1}. Value is 0 for scalar 15724Matrix/scalar mode. Default value is @mathit{-1}. Value is 0 for scalar
15732mode, @i{-2} for matrix mode, or @var{N} for 15725mode, @mathit{-2} for matrix mode, or @var{N} for
15733@texline @tmath{N\times N} 15726@texline @math{N\times N}
15734@infoline @var{N}x@var{N} 15727@infoline @var{N}x@var{N}
15735matrix mode. Command is @kbd{m v}. 15728matrix mode. Command is @kbd{m v}.
15736 15729
15737@item 15730@item
15738Simplification mode. Default is 1. Value is @i{-1} for off (@kbd{m O}), 15731Simplification mode. Default is 1. Value is @mathit{-1} for off (@kbd{m O}),
157390 for @kbd{m N}, 2 for @kbd{m B}, 3 for @kbd{m A}, 4 for @kbd{m E}, 157320 for @kbd{m N}, 2 for @kbd{m B}, 3 for @kbd{m A}, 4 for @kbd{m E},
15740or 5 for @w{@kbd{m U}}. The @kbd{m D} command accepts these prefixes. 15733or 5 for @w{@kbd{m U}}. The @kbd{m D} command accepts these prefixes.
15741 15734
15742@item 15735@item
15743Infinite mode. Default is @i{-1} (off). Value is 1 if the mode is on, 15736Infinite mode. Default is @mathit{-1} (off). Value is 1 if the mode is on,
15744or 0 if the mode is on with positive zeros. Command is @kbd{m i}. 15737or 0 if the mode is on with positive zeros. Command is @kbd{m i}.
15745@end enumerate 15738@end enumerate
15746 15739
@@ -16081,7 +16074,7 @@ infinite in different directions the result is @code{nan}.
16081@tindex - 16074@tindex -
16082The @kbd{-} (@code{calc-minus}) command subtracts two values. The top 16075The @kbd{-} (@code{calc-minus}) command subtracts two values. The top
16083number on the stack is subtracted from the one behind it, so that the 16076number on the stack is subtracted from the one behind it, so that the
16084computation @kbd{5 @key{RET} 2 -} produces 3, not @i{-3}. All options 16077computation @kbd{5 @key{RET} 2 -} produces 3, not @mathit{-3}. All options
16085available for @kbd{+} are available for @kbd{-} as well. 16078available for @kbd{+} are available for @kbd{-} as well.
16086 16079
16087@kindex * 16080@kindex *
@@ -16225,7 +16218,7 @@ absolute value squared of a number, vector or matrix, or error form.
16225@pindex calc-sign 16218@pindex calc-sign
16226@tindex sign 16219@tindex sign
16227The @kbd{f s} (@code{calc-sign}) [@code{sign}] command returns 1 if its 16220The @kbd{f s} (@code{calc-sign}) [@code{sign}] command returns 1 if its
16228argument is positive, @i{-1} if its argument is negative, or 0 if its 16221argument is positive, @mathit{-1} if its argument is negative, or 0 if its
16229argument is zero. In algebraic form, you can also write @samp{sign(a,x)} 16222argument is zero. In algebraic form, you can also write @samp{sign(a,x)}
16230which evaluates to @samp{x * sign(a)}, i.e., either @samp{x}, @samp{-x}, or 16223which evaluates to @samp{x * sign(a)}, i.e., either @samp{x}, @samp{-x}, or
16231zero depending on the sign of @samp{a}. 16224zero depending on the sign of @samp{a}.
@@ -16288,7 +16281,7 @@ The @kbd{f M} (@code{calc-mant-part}) [@code{mant}] function extracts
16288the ``mantissa'' part @expr{m} of its floating-point argument; @kbd{f X} 16281the ``mantissa'' part @expr{m} of its floating-point argument; @kbd{f X}
16289(@code{calc-xpon-part}) [@code{xpon}] extracts the ``exponent'' part 16282(@code{calc-xpon-part}) [@code{xpon}] extracts the ``exponent'' part
16290@expr{e}. The original number is equal to 16283@expr{e}. The original number is equal to
16291@texline @tmath{m \times 10^e}, 16284@texline @math{m \times 10^e},
16292@infoline @expr{m * 10^e}, 16285@infoline @expr{m * 10^e},
16293where @expr{m} is in the interval @samp{[1.0 ..@: 10.0)} except that 16286where @expr{m} is in the interval @samp{[1.0 ..@: 10.0)} except that
16294@expr{m=e=0} if the original number is zero. For integers 16287@expr{m=e=0} if the original number is zero. For integers
@@ -16321,7 +16314,7 @@ For example, incrementing @samp{12.3456} when the current precision
16321is 6 digits yields @samp{12.3457}. If the current precision had been 16314is 6 digits yields @samp{12.3457}. If the current precision had been
163228 digits, the result would have been @samp{12.345601}. Incrementing 163158 digits, the result would have been @samp{12.345601}. Incrementing
16323@samp{0.0} produces 16316@samp{0.0} produces
16324@texline @tmath{10^{-p}}, 16317@texline @math{10^{-p}},
16325@infoline @expr{10^-p}, 16318@infoline @expr{10^-p},
16326where @expr{p} is the current 16319where @expr{p} is the current
16327precision. These operations are defined only on integers and floats. 16320precision. These operations are defined only on integers and floats.
@@ -16362,7 +16355,7 @@ expressed as an integer-valued floating-point number.
16362The @kbd{F} (@code{calc-floor}) [@code{floor} or @code{ffloor}] command 16355The @kbd{F} (@code{calc-floor}) [@code{floor} or @code{ffloor}] command
16363truncates a real number to the next lower integer, i.e., toward minus 16356truncates a real number to the next lower integer, i.e., toward minus
16364infinity. Thus @kbd{3.6 F} produces 3, but @kbd{_3.6 F} produces 16357infinity. Thus @kbd{3.6 F} produces 3, but @kbd{_3.6 F} produces
16365@i{-4}. 16358@mathit{-4}.
16366 16359
16367@kindex I F 16360@kindex I F
16368@pindex calc-ceiling 16361@pindex calc-ceiling
@@ -16374,7 +16367,7 @@ infinity. Thus @kbd{3.6 F} produces 3, but @kbd{_3.6 F} produces
16374@kindex H I F 16367@kindex H I F
16375The @kbd{I F} (@code{calc-ceiling}) [@code{ceil} or @code{fceil}] 16368The @kbd{I F} (@code{calc-ceiling}) [@code{ceil} or @code{fceil}]
16376command truncates toward positive infinity. Thus @kbd{3.6 I F} produces 16369command truncates toward positive infinity. Thus @kbd{3.6 I F} produces
163774, and @kbd{_3.6 I F} produces @i{-3}. 163704, and @kbd{_3.6 I F} produces @mathit{-3}.
16378 16371
16379@kindex R 16372@kindex R
16380@pindex calc-round 16373@pindex calc-round
@@ -16388,7 +16381,7 @@ The @kbd{R} (@code{calc-round}) [@code{round} or @code{fround}] command
16388rounds to the nearest integer. When the fractional part is .5 exactly, 16381rounds to the nearest integer. When the fractional part is .5 exactly,
16389this command rounds away from zero. (All other rounding in the 16382this command rounds away from zero. (All other rounding in the
16390Calculator uses this convention as well.) Thus @kbd{3.5 R} produces 4 16383Calculator uses this convention as well.) Thus @kbd{3.5 R} produces 4
16391but @kbd{3.4 R} produces 3; @kbd{_3.5 R} produces @i{-4}. 16384but @kbd{3.4 R} produces 3; @kbd{_3.5 R} produces @mathit{-4}.
16392 16385
16393@kindex I R 16386@kindex I R
16394@pindex calc-trunc 16387@pindex calc-trunc
@@ -16401,7 +16394,7 @@ but @kbd{3.4 R} produces 3; @kbd{_3.5 R} produces @i{-4}.
16401The @kbd{I R} (@code{calc-trunc}) [@code{trunc} or @code{ftrunc}] 16394The @kbd{I R} (@code{calc-trunc}) [@code{trunc} or @code{ftrunc}]
16402command truncates toward zero. In other words, it ``chops off'' 16395command truncates toward zero. In other words, it ``chops off''
16403everything after the decimal point. Thus @kbd{3.6 I R} produces 3 and 16396everything after the decimal point. Thus @kbd{3.6 I R} produces 3 and
16404@kbd{_3.6 I R} produces @i{-3}. 16397@kbd{_3.6 I R} produces @mathit{-3}.
16405 16398
16406These functions may not be applied meaningfully to error forms, but they 16399These functions may not be applied meaningfully to error forms, but they
16407do work for intervals. As a convenience, applying @code{floor} to a 16400do work for intervals. As a convenience, applying @code{floor} to a
@@ -16479,10 +16472,10 @@ this command replaces each element by its complex conjugate.
16479The @kbd{G} (@code{calc-argument}) [@code{arg}] command computes the 16472The @kbd{G} (@code{calc-argument}) [@code{arg}] command computes the
16480``argument'' or polar angle of a complex number. For a number in polar 16473``argument'' or polar angle of a complex number. For a number in polar
16481notation, this is simply the second component of the pair 16474notation, this is simply the second component of the pair
16482@texline `@t{(}@var{r}@t{;}@tmath{\theta}@t{)}'. 16475@texline `@t{(}@var{r}@t{;}@math{\theta}@t{)}'.
16483@infoline `@t{(}@var{r}@t{;}@var{theta}@t{)}'. 16476@infoline `@t{(}@var{r}@t{;}@var{theta}@t{)}'.
16484The result is expressed according to the current angular mode and will 16477The result is expressed according to the current angular mode and will
16485be in the range @i{-180} degrees (exclusive) to @i{+180} degrees 16478be in the range @mathit{-180} degrees (exclusive) to @mathit{+180} degrees
16486(inclusive), or the equivalent range in radians. 16479(inclusive), or the equivalent range in radians.
16487 16480
16488@pindex calc-imaginary 16481@pindex calc-imaginary
@@ -16513,8 +16506,8 @@ or matrix argument, these functions operate element-wise.
16513@pindex calc-pack 16506@pindex calc-pack
16514The @kbd{v p} (@code{calc-pack}) command can pack the top two numbers on 16507The @kbd{v p} (@code{calc-pack}) command can pack the top two numbers on
16515the stack into a composite object such as a complex number. With 16508the stack into a composite object such as a complex number. With
16516a prefix argument of @i{-1}, it produces a rectangular complex number; 16509a prefix argument of @mathit{-1}, it produces a rectangular complex number;
16517with an argument of @i{-2}, it produces a polar complex number. 16510with an argument of @mathit{-2}, it produces a polar complex number.
16518(Also, @pxref{Building Vectors}.) 16511(Also, @pxref{Building Vectors}.)
16519 16512
16520@ignore 16513@ignore
@@ -16638,7 +16631,7 @@ already a polar complex number, it uses @code{rect} instead. The
16638The @kbd{c c} (@code{calc-clean}) [@code{pclean}] command ``cleans'' the 16631The @kbd{c c} (@code{calc-clean}) [@code{pclean}] command ``cleans'' the
16639number on the top of the stack. Floating point numbers are re-rounded 16632number on the top of the stack. Floating point numbers are re-rounded
16640according to the current precision. Polar numbers whose angular 16633according to the current precision. Polar numbers whose angular
16641components have strayed from the @i{-180} to @i{+180} degree range 16634components have strayed from the @mathit{-180} to @mathit{+180} degree range
16642are normalized. (Note that results will be undesirable if the current 16635are normalized. (Note that results will be undesirable if the current
16643angular mode is different from the one under which the number was 16636angular mode is different from the one under which the number was
16644produced!) Integers and fractions are generally unaffected by this 16637produced!) Integers and fractions are generally unaffected by this
@@ -16894,8 +16887,8 @@ of the input date form are lost. With a numeric prefix argument
16894@var{n} in the range from 1 to 366, @kbd{t Y} computes the 16887@var{n} in the range from 1 to 366, @kbd{t Y} computes the
16895@var{n}th day of the year (366 is treated as 365 in non-leap 16888@var{n}th day of the year (366 is treated as 365 in non-leap
16896years). A prefix argument of 0 computes the last day of the 16889years). A prefix argument of 0 computes the last day of the
16897year (December 31). A negative prefix argument from @i{-1} to 16890year (December 31). A negative prefix argument from @mathit{-1} to
16898@i{-12} computes the first day of the @var{n}th month of the year. 16891@mathit{-12} computes the first day of the @var{n}th month of the year.
16899 16892
16900@kindex t W 16893@kindex t W
16901@pindex calc-new-week 16894@pindex calc-new-week
@@ -17264,7 +17257,7 @@ The Lisp variable @code{math-daylight-savings-hook} holds the
17264name of a function that is used to compute the daylight savings 17257name of a function that is used to compute the daylight savings
17265adjustment for a given date. The default is 17258adjustment for a given date. The default is
17266@code{math-std-daylight-savings}, which computes an adjustment 17259@code{math-std-daylight-savings}, which computes an adjustment
17267(either 0 or @i{-1}) using the North American rules given above. 17260(either 0 or @mathit{-1}) using the North American rules given above.
17268 17261
17269The daylight savings hook function is called with four arguments: 17262The daylight savings hook function is called with four arguments:
17270The date, as a floating-point number in standard Calc format; 17263The date, as a floating-point number in standard Calc format;
@@ -17312,7 +17305,7 @@ daylight savings hook:
17312@noindent 17305@noindent
17313The @code{bump} parameter is equal to zero when Calc is converting 17306The @code{bump} parameter is equal to zero when Calc is converting
17314from a date form in a generalized time zone into a GMT date value. 17307from a date form in a generalized time zone into a GMT date value.
17315It is @i{-1} when Calc is converting in the other direction. The 17308It is @mathit{-1} when Calc is converting in the other direction. The
17316adjustments shown above ensure that the conversion behaves correctly 17309adjustments shown above ensure that the conversion behaves correctly
17317and reasonably around the 2 a.m.@: transition in each direction. 17310and reasonably around the 2 a.m.@: transition in each direction.
17318 17311
@@ -17939,10 +17932,10 @@ particular, negative arguments are converted to positive integers modulo
17939 17932
17940If the word size is negative, binary operations produce 2's complement 17933If the word size is negative, binary operations produce 2's complement
17941integers from 17934integers from
17942@texline @tmath{-2^{-w-1}} 17935@texline @math{-2^{-w-1}}
17943@infoline @expr{-(2^(-w-1))} 17936@infoline @expr{-(2^(-w-1))}
17944to 17937to
17945@texline @tmath{2^{-w-1}-1} 17938@texline @math{2^{-w-1}-1}
17946@infoline @expr{2^(-w-1)-1} 17939@infoline @expr{2^(-w-1)-1}
17947inclusive. Either mode accepts inputs in any range; the sign of 17940inclusive. Either mode accepts inputs in any range; the sign of
17948@expr{w} affects only the results produced. 17941@expr{w} affects only the results produced.
@@ -17958,7 +17951,7 @@ addition do not use the current word size, since integer addition
17958generally is not ``binary.'' (However, @pxref{Simplification Modes}, 17951generally is not ``binary.'' (However, @pxref{Simplification Modes},
17959@code{calc-bin-simplify-mode}.) For example, with a word size of 8 17952@code{calc-bin-simplify-mode}.) For example, with a word size of 8
17960bits @kbd{b c} converts a number to the range 0 to 255; with a word 17953bits @kbd{b c} converts a number to the range 0 to 255; with a word
17961size of @i{-8} @kbd{b c} converts to the range @i{-128} to 127. 17954size of @mathit{-8} @kbd{b c} converts to the range @mathit{-128} to 127.
17962 17955
17963@kindex b w 17956@kindex b w
17964@pindex calc-word-size 17957@pindex calc-word-size
@@ -17974,7 +17967,7 @@ When the binary operations are written in symbolic form, they take an
17974optional second (or third) word-size parameter. When a formula like 17967optional second (or third) word-size parameter. When a formula like
17975@samp{and(a,b)} is finally evaluated, the word size current at that time 17968@samp{and(a,b)} is finally evaluated, the word size current at that time
17976will be used, but when @samp{and(a,b,-8)} is evaluated, a word size of 17969will be used, but when @samp{and(a,b,-8)} is evaluated, a word size of
17977@i{-8} will always be used. A symbolic binary function will be left 17970@mathit{-8} will always be used. A symbolic binary function will be left
17978in symbolic form unless the all of its argument(s) are integers or 17971in symbolic form unless the all of its argument(s) are integers or
17979integer-valued floats. 17972integer-valued floats.
17980 17973
@@ -18126,11 +18119,11 @@ One miscellaneous command is shift-@kbd{P} (@code{calc-pi}), which pushes
18126the value of @cpi{} (at the current precision) onto the stack. With the 18119the value of @cpi{} (at the current precision) onto the stack. With the
18127Hyperbolic flag, it pushes the value @expr{e}, the base of natural logarithms. 18120Hyperbolic flag, it pushes the value @expr{e}, the base of natural logarithms.
18128With the Inverse flag, it pushes Euler's constant 18121With the Inverse flag, it pushes Euler's constant
18129@texline @tmath{\gamma} 18122@texline @math{\gamma}
18130@infoline @expr{gamma} 18123@infoline @expr{gamma}
18131(about 0.5772). With both Inverse and Hyperbolic, it 18124(about 0.5772). With both Inverse and Hyperbolic, it
18132pushes the ``golden ratio'' 18125pushes the ``golden ratio''
18133@texline @tmath{\phi} 18126@texline @math{\phi}
18134@infoline @expr{phi} 18127@infoline @expr{phi}
18135(about 1.618). (At present, Euler's constant is not available 18128(about 1.618). (At present, Euler's constant is not available
18136to unlimited precision; Calc knows only the first 100 digits.) 18129to unlimited precision; Calc knows only the first 100 digits.)
@@ -18210,7 +18203,7 @@ The @kbd{H L} (@code{calc-log10}) [@code{log10}] command computes the common
18210it raises ten to a given power.) Note that the common logarithm of a 18203it raises ten to a given power.) Note that the common logarithm of a
18211complex number is computed by taking the natural logarithm and dividing 18204complex number is computed by taking the natural logarithm and dividing
18212by 18205by
18213@texline @tmath{\ln10}. 18206@texline @math{\ln10}.
18214@infoline @expr{ln(10)}. 18207@infoline @expr{ln(10)}.
18215 18208
18216@kindex B 18209@kindex B
@@ -18220,7 +18213,7 @@ by
18220@tindex alog 18213@tindex alog
18221The @kbd{B} (@code{calc-log}) [@code{log}] command computes a logarithm 18214The @kbd{B} (@code{calc-log}) [@code{log}] command computes a logarithm
18222to any base. For example, @kbd{1024 @key{RET} 2 B} produces 10, since 18215to any base. For example, @kbd{1024 @key{RET} 2 B} produces 10, since
18223@texline @tmath{2^{10} = 1024}. 18216@texline @math{2^{10} = 1024}.
18224@infoline @expr{2^10 = 1024}. 18217@infoline @expr{2^10 = 1024}.
18225In certain cases like @samp{log(3,9)}, the result 18218In certain cases like @samp{log(3,9)}, the result
18226will be either @expr{1:2} or @expr{0.5} depending on the current Fraction 18219will be either @expr{1:2} or @expr{0.5} depending on the current Fraction
@@ -18242,11 +18235,11 @@ integer arithmetic is used; otherwise, this is equivalent to
18242@pindex calc-expm1 18235@pindex calc-expm1
18243@tindex expm1 18236@tindex expm1
18244The @kbd{f E} (@code{calc-expm1}) [@code{expm1}] command computes 18237The @kbd{f E} (@code{calc-expm1}) [@code{expm1}] command computes
18245@texline @tmath{e^x - 1}, 18238@texline @math{e^x - 1},
18246@infoline @expr{exp(x)-1}, 18239@infoline @expr{exp(x)-1},
18247but using an algorithm that produces a more accurate 18240but using an algorithm that produces a more accurate
18248answer when the result is close to zero, i.e., when 18241answer when the result is close to zero, i.e., when
18249@texline @tmath{e^x} 18242@texline @math{e^x}
18250@infoline @expr{exp(x)} 18243@infoline @expr{exp(x)}
18251is close to one. 18244is close to one.
18252 18245
@@ -18254,7 +18247,7 @@ is close to one.
18254@pindex calc-lnp1 18247@pindex calc-lnp1
18255@tindex lnp1 18248@tindex lnp1
18256The @kbd{f L} (@code{calc-lnp1}) [@code{lnp1}] command computes 18249The @kbd{f L} (@code{calc-lnp1}) [@code{lnp1}] command computes
18257@texline @tmath{\ln(x+1)}, 18250@texline @math{\ln(x+1)},
18258@infoline @expr{ln(x+1)}, 18251@infoline @expr{ln(x+1)},
18259producing a more accurate answer when @expr{x} is close to zero. 18252producing a more accurate answer when @expr{x} is close to zero.
18260 18253
@@ -18388,10 +18381,10 @@ variants of these functions.
18388@tindex arctan2 18381@tindex arctan2
18389The @kbd{f T} (@code{calc-arctan2}) [@code{arctan2}] command takes two 18382The @kbd{f T} (@code{calc-arctan2}) [@code{arctan2}] command takes two
18390numbers from the stack and computes the arc tangent of their ratio. The 18383numbers from the stack and computes the arc tangent of their ratio. The
18391result is in the full range from @i{-180} (exclusive) to @i{+180} 18384result is in the full range from @mathit{-180} (exclusive) to @mathit{+180}
18392(inclusive) degrees, or the analogous range in radians. A similar 18385(inclusive) degrees, or the analogous range in radians. A similar
18393result would be obtained with @kbd{/} followed by @kbd{I T}, but the 18386result would be obtained with @kbd{/} followed by @kbd{I T}, but the
18394value would only be in the range from @i{-90} to @i{+90} degrees 18387value would only be in the range from @mathit{-90} to @mathit{+90} degrees
18395since the division loses information about the signs of the two 18388since the division loses information about the signs of the two
18396components, and an error might result from an explicit division by zero 18389components, and an error might result from an explicit division by zero
18397which @code{arctan2} would avoid. By (arbitrary) definition, 18390which @code{arctan2} would avoid. By (arbitrary) definition,
@@ -18440,7 +18433,7 @@ gamma function. For positive integer arguments, this is related to the
18440factorial function: @samp{gamma(n+1) = fact(n)}. For general complex 18433factorial function: @samp{gamma(n+1) = fact(n)}. For general complex
18441arguments the gamma function can be defined by the following definite 18434arguments the gamma function can be defined by the following definite
18442integral: 18435integral:
18443@texline @tmath{\Gamma(a) = \int_0^\infty t^{a-1} e^t dt}. 18436@texline @math{\Gamma(a) = \int_0^\infty t^{a-1} e^t dt}.
18444@infoline @expr{gamma(a) = integ(t^(a-1) exp(t), t, 0, inf)}. 18437@infoline @expr{gamma(a) = integ(t^(a-1) exp(t), t, 0, inf)}.
18445(The actual implementation uses far more efficient computational methods.) 18438(The actual implementation uses far more efficient computational methods.)
18446 18439
@@ -18474,7 +18467,7 @@ integral:
18474The @kbd{f G} (@code{calc-inc-gamma}) [@code{gammaP}] command computes 18467The @kbd{f G} (@code{calc-inc-gamma}) [@code{gammaP}] command computes
18475the incomplete gamma function, denoted @samp{P(a,x)}. This is defined by 18468the incomplete gamma function, denoted @samp{P(a,x)}. This is defined by
18476the integral, 18469the integral,
18477@texline @tmath{P(a,x) = \left( \int_0^x t^{a-1} e^t dt \right) / \Gamma(a)}. 18470@texline @math{P(a,x) = \left( \int_0^x t^{a-1} e^t dt \right) / \Gamma(a)}.
18478@infoline @expr{gammaP(a,x) = integ(t^(a-1) exp(t), t, 0, x) / gamma(a)}. 18471@infoline @expr{gammaP(a,x) = integ(t^(a-1) exp(t), t, 0, x) / gamma(a)}.
18479This implies that @samp{gammaP(a,inf) = 1} for any @expr{a} (see the 18472This implies that @samp{gammaP(a,inf) = 1} for any @expr{a} (see the
18480definition of the normal gamma function). 18473definition of the normal gamma function).
@@ -18507,10 +18500,10 @@ You can obtain these using the \kbd{H f G} [\code{gammag}] and
18507@tindex beta 18500@tindex beta
18508The @kbd{f b} (@code{calc-beta}) [@code{beta}] command computes the 18501The @kbd{f b} (@code{calc-beta}) [@code{beta}] command computes the
18509Euler beta function, which is defined in terms of the gamma function as 18502Euler beta function, which is defined in terms of the gamma function as
18510@texline @tmath{B(a,b) = \Gamma(a) \Gamma(b) / \Gamma(a+b)}, 18503@texline @math{B(a,b) = \Gamma(a) \Gamma(b) / \Gamma(a+b)},
18511@infoline @expr{beta(a,b) = gamma(a) gamma(b) / gamma(a+b)}, 18504@infoline @expr{beta(a,b) = gamma(a) gamma(b) / gamma(a+b)},
18512or by 18505or by
18513@texline @tmath{B(a,b) = \int_0^1 t^{a-1} (1-t)^{b-1} dt}. 18506@texline @math{B(a,b) = \int_0^1 t^{a-1} (1-t)^{b-1} dt}.
18514@infoline @expr{beta(a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, 1)}. 18507@infoline @expr{beta(a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, 1)}.
18515 18508
18516@kindex f B 18509@kindex f B
@@ -18520,7 +18513,7 @@ or by
18520@tindex betaB 18513@tindex betaB
18521The @kbd{f B} (@code{calc-inc-beta}) [@code{betaI}] command computes 18514The @kbd{f B} (@code{calc-inc-beta}) [@code{betaI}] command computes
18522the incomplete beta function @expr{I(x,a,b)}. It is defined by 18515the incomplete beta function @expr{I(x,a,b)}. It is defined by
18523@texline @tmath{I(x,a,b) = \left( \int_0^x t^{a-1} (1-t)^{b-1} dt \right) / B(a,b)}. 18516@texline @math{I(x,a,b) = \left( \int_0^x t^{a-1} (1-t)^{b-1} dt \right) / B(a,b)}.
18524@infoline @expr{betaI(x,a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, x) / beta(a,b)}. 18517@infoline @expr{betaI(x,a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, x) / beta(a,b)}.
18525Once again, the @kbd{H} (hyperbolic) prefix gives the corresponding 18518Once again, the @kbd{H} (hyperbolic) prefix gives the corresponding
18526un-normalized version [@code{betaB}]. 18519un-normalized version [@code{betaB}].
@@ -18532,11 +18525,11 @@ un-normalized version [@code{betaB}].
18532@tindex erfc 18525@tindex erfc
18533The @kbd{f e} (@code{calc-erf}) [@code{erf}] command computes the 18526The @kbd{f e} (@code{calc-erf}) [@code{erf}] command computes the
18534error function 18527error function
18535@texline @tmath{\hbox{erf}(x) = {2 \over \sqrt{\pi}} \int_0^x e^{-t^2} dt}. 18528@texline @math{\hbox{erf}(x) = {2 \over \sqrt{\pi}} \int_0^x e^{-t^2} dt}.
18536@infoline @expr{erf(x) = 2 integ(exp(-(t^2)), t, 0, x) / sqrt(pi)}. 18529@infoline @expr{erf(x) = 2 integ(exp(-(t^2)), t, 0, x) / sqrt(pi)}.
18537The complementary error function @kbd{I f e} (@code{calc-erfc}) [@code{erfc}] 18530The complementary error function @kbd{I f e} (@code{calc-erfc}) [@code{erfc}]
18538is the corresponding integral from @samp{x} to infinity; the sum 18531is the corresponding integral from @samp{x} to infinity; the sum
18539@texline @tmath{\hbox{erf}(x) + \hbox{erfc}(x) = 1}. 18532@texline @math{\hbox{erf}(x) + \hbox{erfc}(x) = 1}.
18540@infoline @expr{erf(x) + erfc(x) = 1}. 18533@infoline @expr{erf(x) + erfc(x) = 1}.
18541 18534
18542@kindex f j 18535@kindex f j
@@ -18612,17 +18605,17 @@ occurrence of @code{eps} may stand for a different small value.
18612 18605
18613For @samp{z1^z2}: This is defined by @samp{exp(ln(z1)*z2)}. 18606For @samp{z1^z2}: This is defined by @samp{exp(ln(z1)*z2)}.
18614One interesting consequence of this is that @samp{(-8)^1:3} does 18607One interesting consequence of this is that @samp{(-8)^1:3} does
18615not evaluate to @i{-2} as you might expect, but to the complex 18608not evaluate to @mathit{-2} as you might expect, but to the complex
18616number @expr{(1., 1.732)}. Both of these are valid cube roots 18609number @expr{(1., 1.732)}. Both of these are valid cube roots
18617of @i{-8} (as is @expr{(1., -1.732)}); Calc chooses a perhaps 18610of @mathit{-8} (as is @expr{(1., -1.732)}); Calc chooses a perhaps
18618less-obvious root for the sake of mathematical consistency. 18611less-obvious root for the sake of mathematical consistency.
18619 18612
18620For @samp{arcsin(z)}: This is defined by @samp{-i*ln(i*z + sqrt(1-z^2))}. 18613For @samp{arcsin(z)}: This is defined by @samp{-i*ln(i*z + sqrt(1-z^2))}.
18621The branch cuts are on the real axis, less than @i{-1} and greater than 1. 18614The branch cuts are on the real axis, less than @mathit{-1} and greater than 1.
18622 18615
18623For @samp{arccos(z)}: This is defined by @samp{-i*ln(z + i*sqrt(1-z^2))}, 18616For @samp{arccos(z)}: This is defined by @samp{-i*ln(z + i*sqrt(1-z^2))},
18624or equivalently by @samp{pi/2 - arcsin(z)}. The branch cuts are on 18617or equivalently by @samp{pi/2 - arcsin(z)}. The branch cuts are on
18625the real axis, less than @i{-1} and greater than 1. 18618the real axis, less than @mathit{-1} and greater than 1.
18626 18619
18627For @samp{arctan(z)}: This is defined by 18620For @samp{arctan(z)}: This is defined by
18628@samp{(ln(1+i*z) - ln(1-i*z)) / (2*i)}. The branch cuts are on the 18621@samp{(ln(1+i*z) - ln(1-i*z)) / (2*i)}. The branch cuts are on the
@@ -18637,7 +18630,7 @@ For @samp{arccosh(z)}: This is defined by
18637real axis less than 1. 18630real axis less than 1.
18638 18631
18639For @samp{arctanh(z)}: This is defined by @samp{(ln(1+z) - ln(1-z)) / 2}. 18632For @samp{arctanh(z)}: This is defined by @samp{(ln(1+z) - ln(1-z)) / 2}.
18640The branch cuts are on the real axis, less than @i{-1} and greater than 1. 18633The branch cuts are on the real axis, less than @mathit{-1} and greater than 1.
18641 18634
18642The following tables for @code{arcsin}, @code{arccos}, and 18635The following tables for @code{arcsin}, @code{arccos}, and
18643@code{arctan} assume the current angular mode is radians. The 18636@code{arctan} assume the current angular mode is radians. The
@@ -18710,7 +18703,7 @@ random numbers of various sorts.
18710 18703
18711Given a positive numeric prefix argument @expr{M}, it produces a random 18704Given a positive numeric prefix argument @expr{M}, it produces a random
18712integer @expr{N} in the range 18705integer @expr{N} in the range
18713@texline @tmath{0 \le N < M}. 18706@texline @math{0 \le N < M}.
18714@infoline @expr{0 <= N < M}. 18707@infoline @expr{0 <= N < M}.
18715Each of the @expr{M} values appears with equal probability. 18708Each of the @expr{M} values appears with equal probability.
18716 18709
@@ -18720,15 +18713,15 @@ the result is a random integer less than @expr{M}. However, note that
18720while numeric prefix arguments are limited to six digits or so, an @expr{M} 18713while numeric prefix arguments are limited to six digits or so, an @expr{M}
18721taken from the stack can be arbitrarily large. If @expr{M} is negative, 18714taken from the stack can be arbitrarily large. If @expr{M} is negative,
18722the result is a random integer in the range 18715the result is a random integer in the range
18723@texline @tmath{M < N \le 0}. 18716@texline @math{M < N \le 0}.
18724@infoline @expr{M < N <= 0}. 18717@infoline @expr{M < N <= 0}.
18725 18718
18726If the value on the stack is a floating-point number @expr{M}, the result 18719If the value on the stack is a floating-point number @expr{M}, the result
18727is a random floating-point number @expr{N} in the range 18720is a random floating-point number @expr{N} in the range
18728@texline @tmath{0 \le N < M} 18721@texline @math{0 \le N < M}
18729@infoline @expr{0 <= N < M} 18722@infoline @expr{0 <= N < M}
18730or 18723or
18731@texline @tmath{M < N \le 0}, 18724@texline @math{M < N \le 0},
18732@infoline @expr{M < N <= 0}, 18725@infoline @expr{M < N <= 0},
18733according to the sign of @expr{M}. 18726according to the sign of @expr{M}.
18734 18727
@@ -18738,14 +18731,14 @@ of one. The algorithm used generates random numbers in pairs; thus,
18738every other call to this function will be especially fast. 18731every other call to this function will be especially fast.
18739 18732
18740If @expr{M} is an error form 18733If @expr{M} is an error form
18741@texline @tmath{m} @code{+/-} @tmath{\sigma} 18734@texline @math{m} @code{+/-} @math{\sigma}
18742@infoline @samp{m +/- s} 18735@infoline @samp{m +/- s}
18743where @var{m} and 18736where @var{m} and
18744@texline @tmath{\sigma} 18737@texline @math{\sigma}
18745@infoline @var{s} 18738@infoline @var{s}
18746are both real numbers, the result uses a Gaussian distribution with mean 18739are both real numbers, the result uses a Gaussian distribution with mean
18747@var{m} and standard deviation 18740@var{m} and standard deviation
18748@texline @tmath{\sigma}. 18741@texline @math{\sigma}.
18749@var{s}. 18742@var{s}.
18750 18743
18751If @expr{M} is an interval form, the lower and upper bounds specify the 18744If @expr{M} is an interval form, the lower and upper bounds specify the
@@ -18858,7 +18851,7 @@ generators that are typically used to implement @code{random}.
18858If @code{RandSeed} contains an integer, Calc uses this integer to 18851If @code{RandSeed} contains an integer, Calc uses this integer to
18859seed an ``additive congruential'' method (Knuth's algorithm 3.2.2A, 18852seed an ``additive congruential'' method (Knuth's algorithm 3.2.2A,
18860computing 18853computing
18861@texline @tmath{X_{n-55} - X_{n-24}}. 18854@texline @math{X_{n-55} - X_{n-24}}.
18862@infoline @expr{X_n-55 - X_n-24}). 18855@infoline @expr{X_n-55 - X_n-24}).
18863This method expands the seed 18856This method expands the seed
18864value into a large table which is maintained internally; the variable 18857value into a large table which is maintained internally; the variable
@@ -18894,20 +18887,20 @@ value.
18894 18887
18895To create a random floating-point number with precision @var{p}, Calc 18888To create a random floating-point number with precision @var{p}, Calc
18896simply creates a random @var{p}-digit integer and multiplies by 18889simply creates a random @var{p}-digit integer and multiplies by
18897@texline @tmath{10^{-p}}. 18890@texline @math{10^{-p}}.
18898@infoline @expr{10^-p}. 18891@infoline @expr{10^-p}.
18899The resulting random numbers should be very clean, but note 18892The resulting random numbers should be very clean, but note
18900that relatively small numbers will have few significant random digits. 18893that relatively small numbers will have few significant random digits.
18901In other words, with a precision of 12, you will occasionally get 18894In other words, with a precision of 12, you will occasionally get
18902numbers on the order of 18895numbers on the order of
18903@texline @tmath{10^{-9}} 18896@texline @math{10^{-9}}
18904@infoline @expr{10^-9} 18897@infoline @expr{10^-9}
18905or 18898or
18906@texline @tmath{10^{-10}}, 18899@texline @math{10^{-10}},
18907@infoline @expr{10^-10}, 18900@infoline @expr{10^-10},
18908but those numbers will only have two or three random digits since they 18901but those numbers will only have two or three random digits since they
18909correspond to small integers times 18902correspond to small integers times
18910@texline @tmath{10^{-12}}. 18903@texline @math{10^{-12}}.
18911@infoline @expr{10^-12}. 18904@infoline @expr{10^-12}.
18912 18905
18913To create a random integer in the interval @samp{[0 .. @var{m})}, Calc 18906To create a random integer in the interval @samp{[0 .. @var{m})}, Calc
@@ -18958,7 +18951,7 @@ numbers.
18958The @kbd{k E} (@code{calc-extended-gcd}) [@code{egcd}] command computes 18951The @kbd{k E} (@code{calc-extended-gcd}) [@code{egcd}] command computes
18959the GCD of two integers @expr{x} and @expr{y} and returns a vector 18952the GCD of two integers @expr{x} and @expr{y} and returns a vector
18960@expr{[g, a, b]} where 18953@expr{[g, a, b]} where
18961@texline @tmath{g = \gcd(x,y) = a x + b y}. 18954@texline @math{g = \gcd(x,y) = a x + b y}.
18962@infoline @expr{g = gcd(x,y) = a x + b y}. 18955@infoline @expr{g = gcd(x,y) = a x + b y}.
18963 18956
18964@kindex ! 18957@kindex !
@@ -19002,7 +18995,7 @@ on the top of the stack and @expr{N} is second-to-top. If both arguments
19002are integers, the result is an exact integer. Otherwise, the result is a 18995are integers, the result is an exact integer. Otherwise, the result is a
19003floating-point approximation. The binomial coefficient is defined for all 18996floating-point approximation. The binomial coefficient is defined for all
19004real numbers by 18997real numbers by
19005@texline @tmath{N! \over M! (N-M)!\,}. 18998@texline @math{N! \over M! (N-M)!\,}.
19006@infoline @expr{N! / M! (N-M)!}. 18999@infoline @expr{N! / M! (N-M)!}.
19007 19000
19008@kindex H k c 19001@kindex H k c
@@ -19045,11 +19038,11 @@ functions.
19045@tindex stir2 19038@tindex stir2
19046The @kbd{k s} (@code{calc-stirling-number}) [@code{stir1}] command 19039The @kbd{k s} (@code{calc-stirling-number}) [@code{stir1}] command
19047computes a Stirling number of the first 19040computes a Stirling number of the first
19048@texline kind@tie{}@tmath{n \brack m}, 19041@texline kind@tie{}@math{n \brack m},
19049@infoline kind, 19042@infoline kind,
19050given two integers @expr{n} and @expr{m} on the stack. The @kbd{H k s} 19043given two integers @expr{n} and @expr{m} on the stack. The @kbd{H k s}
19051[@code{stir2}] command computes a Stirling number of the second 19044[@code{stir2}] command computes a Stirling number of the second
19052@texline kind@tie{}@tmath{n \brace m}. 19045@texline kind@tie{}@math{n \brace m}.
19053@infoline kind. 19046@infoline kind.
19054These are the number of @expr{m}-cycle permutations of @expr{n} objects, 19047These are the number of @expr{m}-cycle permutations of @expr{n} objects,
19055and the number of ways to partition @expr{n} objects into @expr{m} 19048and the number of ways to partition @expr{n} objects into @expr{m}
@@ -19093,8 +19086,8 @@ result is a vector of the prime factors in increasing order. For larger
19093inputs, prime factors above 5000 may not be found, in which case the 19086inputs, prime factors above 5000 may not be found, in which case the
19094last number in the vector will be an unfactored integer greater than 25 19087last number in the vector will be an unfactored integer greater than 25
19095million (with a warning message). For negative integers, the first 19088million (with a warning message). For negative integers, the first
19096element of the list will be @i{-1}. For inputs @i{-1}, @i{0}, and 19089element of the list will be @mathit{-1}. For inputs @mathit{-1}, @mathit{0}, and
19097@i{1}, the result is a list of the same number. 19090@mathit{1}, the result is a list of the same number.
19098 19091
19099@kindex k n 19092@kindex k n
19100@pindex calc-next-prime 19093@pindex calc-next-prime
@@ -19128,7 +19121,7 @@ analogously finds the next prime less than a given number.
19128@tindex totient 19121@tindex totient
19129The @kbd{k t} (@code{calc-totient}) [@code{totient}] command computes the 19122The @kbd{k t} (@code{calc-totient}) [@code{totient}] command computes the
19130Euler ``totient'' 19123Euler ``totient''
19131@texline function@tie{}@tmath{\phi(n)}, 19124@texline function@tie{}@math{\phi(n)},
19132@infoline function, 19125@infoline function,
19133the number of integers less than @expr{n} which 19126the number of integers less than @expr{n} which
19134are relatively prime to @expr{n}. 19127are relatively prime to @expr{n}.
@@ -19137,7 +19130,7 @@ are relatively prime to @expr{n}.
19137@pindex calc-moebius 19130@pindex calc-moebius
19138@tindex moebius 19131@tindex moebius
19139The @kbd{k m} (@code{calc-moebius}) [@code{moebius}] command computes the 19132The @kbd{k m} (@code{calc-moebius}) [@code{moebius}] command computes the
19140@texline M@"obius @tmath{\mu} 19133@texline M@"obius @math{\mu}
19141@infoline Moebius ``mu'' 19134@infoline Moebius ``mu''
19142function. If the input number is a product of @expr{k} 19135function. If the input number is a product of @expr{k}
19143distinct factors, this is @expr{(-1)^k}. If the input number has any 19136distinct factors, this is @expr{(-1)^k}. If the input number has any
@@ -19201,7 +19194,7 @@ recover the original arguments but substitute a new value for @expr{x}.)
19201@end ignore 19194@end ignore
19202@tindex ltpc 19195@tindex ltpc
19203The @samp{utpc(x,v)} function uses the chi-square distribution with 19196The @samp{utpc(x,v)} function uses the chi-square distribution with
19204@texline @tmath{\nu} 19197@texline @math{\nu}
19205@infoline @expr{v} 19198@infoline @expr{v}
19206degrees of freedom. It is the probability that a model is 19199degrees of freedom. It is the probability that a model is
19207correct if its chi-square statistic is @expr{x}. 19200correct if its chi-square statistic is @expr{x}.
@@ -19219,10 +19212,10 @@ correct if its chi-square statistic is @expr{x}.
19219@tindex ltpf 19212@tindex ltpf
19220The @samp{utpf(F,v1,v2)} function uses the F distribution, used in 19213The @samp{utpf(F,v1,v2)} function uses the F distribution, used in
19221various statistical tests. The parameters 19214various statistical tests. The parameters
19222@texline @tmath{\nu_1} 19215@texline @math{\nu_1}
19223@infoline @expr{v1} 19216@infoline @expr{v1}
19224and 19217and
19225@texline @tmath{\nu_2} 19218@texline @math{\nu_2}
19226@infoline @expr{v2} 19219@infoline @expr{v2}
19227are the degrees of freedom in the numerator and denominator, 19220are the degrees of freedom in the numerator and denominator,
19228respectively, used in computing the statistic @expr{F}. 19221respectively, used in computing the statistic @expr{F}.
@@ -19240,7 +19233,7 @@ respectively, used in computing the statistic @expr{F}.
19240@tindex ltpn 19233@tindex ltpn
19241The @samp{utpn(x,m,s)} function uses a normal (Gaussian) distribution 19234The @samp{utpn(x,m,s)} function uses a normal (Gaussian) distribution
19242with mean @expr{m} and standard deviation 19235with mean @expr{m} and standard deviation
19243@texline @tmath{\sigma}. 19236@texline @math{\sigma}.
19244@infoline @expr{s}. 19237@infoline @expr{s}.
19245It is the probability that such a normal-distributed random variable 19238It is the probability that such a normal-distributed random variable
19246would exceed @expr{x}. 19239would exceed @expr{x}.
@@ -19273,18 +19266,18 @@ Poisson random events will occur.
19273@tindex ltpt 19266@tindex ltpt
19274The @samp{utpt(t,v)} function uses the Student's ``t'' distribution 19267The @samp{utpt(t,v)} function uses the Student's ``t'' distribution
19275with 19268with
19276@texline @tmath{\nu} 19269@texline @math{\nu}
19277@infoline @expr{v} 19270@infoline @expr{v}
19278degrees of freedom. It is the probability that a 19271degrees of freedom. It is the probability that a
19279t-distributed random variable will be greater than @expr{t}. 19272t-distributed random variable will be greater than @expr{t}.
19280(Note: This computes the distribution function 19273(Note: This computes the distribution function
19281@texline @tmath{A(t|\nu)} 19274@texline @math{A(t|\nu)}
19282@infoline @expr{A(t|v)} 19275@infoline @expr{A(t|v)}
19283where 19276where
19284@texline @tmath{A(0|\nu) = 1} 19277@texline @math{A(0|\nu) = 1}
19285@infoline @expr{A(0|v) = 1} 19278@infoline @expr{A(0|v) = 1}
19286and 19279and
19287@texline @tmath{A(\infty|\nu) \to 0}. 19280@texline @math{A(\infty|\nu) \to 0}.
19288@infoline @expr{A(inf|v) -> 0}. 19281@infoline @expr{A(inf|v) -> 0}.
19289The @code{UTPT} operation on the HP-48 uses a different definition which 19282The @code{UTPT} operation on the HP-48 uses a different definition which
19290returns half of Calc's value: @samp{UTPT(t,v) = .5*utpt(t,v)}.) 19283returns half of Calc's value: @samp{UTPT(t,v) = .5*utpt(t,v)}.)
@@ -19404,8 +19397,8 @@ integer, is the exponent. The result is the mantissa
19404times ten to the power of the exponent. 19397times ten to the power of the exponent.
19405 19398
19406@item -12 19399@item -12
19407This is treated the same as @i{-11} by the @kbd{v p} command. 19400This is treated the same as @mathit{-11} by the @kbd{v p} command.
19408When unpacking, @i{-12} specifies that a floating-point mantissa 19401When unpacking, @mathit{-12} specifies that a floating-point mantissa
19409is desired. 19402is desired.
19410 19403
19411@item -13 19404@item -13
@@ -19444,7 +19437,7 @@ returned in the form @samp{[@w{[a, b, c]}, [d, e, f]]}.
19444If any elements of the vector are negative, other kinds of 19437If any elements of the vector are negative, other kinds of
19445packing are done at that level as described above. For 19438packing are done at that level as described above. For
19446example, @samp{[2, 3, -4]} takes 12 objects and creates a 19439example, @samp{[2, 3, -4]} takes 12 objects and creates a
19447@texline @tmath{2\times3} 19440@texline @math{2\times3}
19448@infoline 2x3 19441@infoline 2x3
19449matrix of error forms: @samp{[[a +/- b, c +/- d ... ]]}. 19442matrix of error forms: @samp{[[a +/- b, c +/- d ... ]]}.
19450Also, @samp{[-4, -10]} will convert four integers into an 19443Also, @samp{[-4, -10]} will convert four integers into an
@@ -19482,18 +19475,18 @@ the result of @kbd{C-u -4 v u} will be the two vectors
19482@samp{[a, c^2, d]} and @w{@samp{[b, 0, 7]}}. 19475@samp{[a, c^2, d]} and @w{@samp{[b, 0, 7]}}.
19483 19476
19484Note that the prefix argument can have an effect even when the input is 19477Note that the prefix argument can have an effect even when the input is
19485not a vector. For example, if the input is the number @i{-5}, then 19478not a vector. For example, if the input is the number @mathit{-5}, then
19486@kbd{c-u -1 v u} yields @i{-5} and 0 (the components of @i{-5} 19479@kbd{c-u -1 v u} yields @mathit{-5} and 0 (the components of @mathit{-5}
19487when viewed as a rectangular complex number); @kbd{C-u -2 v u} yields 5 19480when viewed as a rectangular complex number); @kbd{C-u -2 v u} yields 5
19488and 180 (assuming degrees mode); and @kbd{C-u -10 v u} yields @i{-5} 19481and 180 (assuming degrees mode); and @kbd{C-u -10 v u} yields @mathit{-5}
19489and 1 (the numerator and denominator of @i{-5}, viewed as a rational 19482and 1 (the numerator and denominator of @mathit{-5}, viewed as a rational
19490number). Plain @kbd{v u} with this input would complain that the input 19483number). Plain @kbd{v u} with this input would complain that the input
19491is not a composite object. 19484is not a composite object.
19492 19485
19493Unpacking mode @i{-11} converts a float into an integer mantissa and 19486Unpacking mode @mathit{-11} converts a float into an integer mantissa and
19494an integer exponent, where the mantissa is not divisible by 10 19487an integer exponent, where the mantissa is not divisible by 10
19495(except that 0.0 is represented by a mantissa and exponent of 0). 19488(except that 0.0 is represented by a mantissa and exponent of 0).
19496Unpacking mode @i{-12} converts a float into a floating-point mantissa 19489Unpacking mode @mathit{-12} converts a float into a floating-point mantissa
19497and integer exponent, where the mantissa (for non-zero numbers) 19490and integer exponent, where the mantissa (for non-zero numbers)
19498is guaranteed to lie in the range [1 .. 10). In both cases, 19491is guaranteed to lie in the range [1 .. 10). In both cases,
19499the mantissa is shifted left or right (and the exponent adjusted 19492the mantissa is shifted left or right (and the exponent adjusted
@@ -19593,7 +19586,7 @@ the stack is a scalar, it is used for each element on the diagonal, and
19593the prefix argument is required. 19586the prefix argument is required.
19594 19587
19595To build a constant square matrix, e.g., a 19588To build a constant square matrix, e.g., a
19596@texline @tmath{3\times3} 19589@texline @math{3\times3}
19597@infoline 3x3 19590@infoline 3x3
19598matrix filled with ones, use @kbd{0 M-3 v d 1 +}, i.e., build a zero 19591matrix filled with ones, use @kbd{0 M-3 v d 1 +}, i.e., build a zero
19599matrix first and then add a constant value to that matrix. (Another 19592matrix first and then add a constant value to that matrix. (Another
@@ -19626,7 +19619,7 @@ The @kbd{v x} (@code{calc-index}) [@code{index}] function builds a vector
19626of consecutive integers from 1 to @var{n}, where @var{n} is the numeric 19619of consecutive integers from 1 to @var{n}, where @var{n} is the numeric
19627prefix argument. If you do not provide a prefix argument, you will be 19620prefix argument. If you do not provide a prefix argument, you will be
19628prompted to enter a suitable number. If @var{n} is negative, the result 19621prompted to enter a suitable number. If @var{n} is negative, the result
19629is a vector of negative integers from @var{n} to @i{-1}. 19622is a vector of negative integers from @var{n} to @mathit{-1}.
19630 19623
19631With a prefix argument of just @kbd{C-u}, the @kbd{v x} command takes 19624With a prefix argument of just @kbd{C-u}, the @kbd{v x} command takes
19632three values from the stack: @var{n}, @var{start}, and @var{incr} (with 19625three values from the stack: @var{n}, @var{start}, and @var{incr} (with
@@ -19819,7 +19812,7 @@ With the Hyperbolic flag, @kbd{H v l} [@code{mdims}] computes a vector
19819of the dimensions of a vector, matrix, or higher-order object. For 19812of the dimensions of a vector, matrix, or higher-order object. For
19820example, @samp{mdims([[a,b,c],[d,e,f]])} returns @samp{[2, 3]} since 19813example, @samp{mdims([[a,b,c],[d,e,f]])} returns @samp{[2, 3]} since
19821its argument is a 19814its argument is a
19822@texline @tmath{2\times3} 19815@texline @math{2\times3}
19823@infoline 2x3 19816@infoline 2x3
19824matrix. 19817matrix.
19825 19818
@@ -19851,13 +19844,13 @@ in the vector, the last row will be short and the result will not be
19851suitable for use as a matrix. For example, with the matrix 19844suitable for use as a matrix. For example, with the matrix
19852@samp{[[1, 2], @w{[3, 4]}]} on the stack, @kbd{v a 4} produces 19845@samp{[[1, 2], @w{[3, 4]}]} on the stack, @kbd{v a 4} produces
19853@samp{[[1, 2, 3, 4]]} (a 19846@samp{[[1, 2, 3, 4]]} (a
19854@texline @tmath{1\times4} 19847@texline @math{1\times4}
19855@infoline 1x4 19848@infoline 1x4
19856matrix), @kbd{v a 1} produces @samp{[[1], [2], [3], [4]]} (a 19849matrix), @kbd{v a 1} produces @samp{[[1], [2], [3], [4]]} (a
19857@texline @tmath{4\times1} 19850@texline @math{4\times1}
19858@infoline 4x1 19851@infoline 4x1
19859matrix), @kbd{v a 2} produces @samp{[[1, 2], [3, 4]]} (the original 19852matrix), @kbd{v a 2} produces @samp{[[1, 2], [3, 4]]} (the original
19860@texline @tmath{2\times2} 19853@texline @math{2\times2}
19861@infoline 2x2 19854@infoline 2x2
19862matrix), @w{@kbd{v a 3}} produces @samp{[[1, 2, 3], [4]]} (not a 19855matrix), @w{@kbd{v a 3}} produces @samp{[[1, 2, 3], [4]]} (not a
19863matrix), and @kbd{v a 0} produces the flattened list 19856matrix), and @kbd{v a 0} produces the flattened list
@@ -20177,10 +20170,10 @@ sets are disjoint, i.e., if they share no common elements, the result
20177will be the empty vector @samp{[]}. Note that the characters @kbd{V} 20170will be the empty vector @samp{[]}. Note that the characters @kbd{V}
20178and @kbd{^} were chosen to be close to the conventional mathematical 20171and @kbd{^} were chosen to be close to the conventional mathematical
20179notation for set 20172notation for set
20180@texline union@tie{}(@tmath{A \cup B}) 20173@texline union@tie{}(@math{A \cup B})
20181@infoline union 20174@infoline union
20182and 20175and
20183@texline intersection@tie{}(@tmath{A \cap B}). 20176@texline intersection@tie{}(@math{A \cap B}).
20184@infoline intersection. 20177@infoline intersection.
20185 20178
20186@kindex V - 20179@kindex V -
@@ -20289,7 +20282,7 @@ not include any negative numbers. The input is interpreted as a
20289set of integers in the sense of @kbd{V F} (@code{vfloor}). Beware 20282set of integers in the sense of @kbd{V F} (@code{vfloor}). Beware
20290that a simple input like @samp{[100]} can result in a huge integer 20283that a simple input like @samp{[100]} can result in a huge integer
20291representation 20284representation
20292@texline (@tmath{2^{100}}, a 31-digit integer, in this case). 20285@texline (@math{2^{100}}, a 31-digit integer, in this case).
20293@infoline (@expr{2^100}, a 31-digit integer, in this case). 20286@infoline (@expr{2^100}, a 31-digit integer, in this case).
20294 20287
20295@node Statistical Operations, Reducing and Mapping, Set Operations, Matrix Functions 20288@node Statistical Operations, Reducing and Mapping, Set Operations, Matrix Functions
@@ -20401,10 +20394,10 @@ plus or minus infinity.
20401The @kbd{u M} (@code{calc-vector-mean}) [@code{vmean}] command 20394The @kbd{u M} (@code{calc-vector-mean}) [@code{vmean}] command
20402computes the average (arithmetic mean) of the data values. 20395computes the average (arithmetic mean) of the data values.
20403If the inputs are error forms 20396If the inputs are error forms
20404@texline @tmath{x \pm \sigma}, 20397@texline @math{x \pm \sigma},
20405@infoline @samp{x +/- s}, 20398@infoline @samp{x +/- s},
20406this is the weighted mean of the @expr{x} values with weights 20399this is the weighted mean of the @expr{x} values with weights
20407@texline @tmath{1 /\sigma^2}. 20400@texline @math{1 /\sigma^2}.
20408@infoline @expr{1 / s^2}. 20401@infoline @expr{1 / s^2}.
20409@tex 20402@tex
20410\turnoffactive 20403\turnoffactive
@@ -20416,7 +20409,7 @@ values divided by the count of the values.
20416 20409
20417Note that a plain number can be considered an error form with 20410Note that a plain number can be considered an error form with
20418error 20411error
20419@texline @tmath{\sigma = 0}. 20412@texline @math{\sigma = 0}.
20420@infoline @expr{s = 0}. 20413@infoline @expr{s = 0}.
20421If the input to @kbd{u M} is a mixture of 20414If the input to @kbd{u M} is a mixture of
20422plain numbers and error forms, the result is the mean of the 20415plain numbers and error forms, the result is the mean of the
@@ -20525,7 +20518,7 @@ for a vector of numbers simply by using the @kbd{A} command.
20525@cindex Sample statistics 20518@cindex Sample statistics
20526The @kbd{u S} (@code{calc-vector-sdev}) [@code{vsdev}] command 20519The @kbd{u S} (@code{calc-vector-sdev}) [@code{vsdev}] command
20527computes the standard 20520computes the standard
20528@texline deviation@tie{}@tmath{\sigma} 20521@texline deviation@tie{}@math{\sigma}
20529@infoline deviation 20522@infoline deviation
20530of the data values. If the values are error forms, the errors are used 20523of the data values. If the values are error forms, the errors are used
20531as weights just as for @kbd{u M}. This is the @emph{sample} standard 20524as weights just as for @kbd{u M}. This is the @emph{sample} standard
@@ -20541,7 +20534,7 @@ This function also applies to distributions. The standard deviation
20541of a single error form is simply the error part. The standard deviation 20534of a single error form is simply the error part. The standard deviation
20542of a continuous interval happens to equal the difference between the 20535of a continuous interval happens to equal the difference between the
20543limits, divided by 20536limits, divided by
20544@texline @tmath{\sqrt{12}}. 20537@texline @math{\sqrt{12}}.
20545@infoline @expr{sqrt(12)}. 20538@infoline @expr{sqrt(12)}.
20546The standard deviation of an integer interval is the same as the 20539The standard deviation of an integer interval is the same as the
20547standard deviation of a vector of those integers. 20540standard deviation of a vector of those integers.
@@ -20579,7 +20572,7 @@ The @kbd{H u S} (@code{calc-vector-variance}) [@code{vvar}] and
20579@kbd{H I u S} (@code{calc-vector-pop-variance}) [@code{vpvar}] 20572@kbd{H I u S} (@code{calc-vector-pop-variance}) [@code{vpvar}]
20580commands compute the variance of the data values. The variance 20573commands compute the variance of the data values. The variance
20581is the 20574is the
20582@texline square@tie{}@tmath{\sigma^2} 20575@texline square@tie{}@math{\sigma^2}
20583@infoline square 20576@infoline square
20584of the standard deviation, i.e., the sum of the 20577of the standard deviation, i.e., the sum of the
20585squares of the deviations of the data values from the mean. 20578squares of the deviations of the data values from the mean.
@@ -20603,7 +20596,7 @@ vectors of equal size. The vectors are each flattened in the same
20603way as by the single-variable statistical functions. Given a numeric 20596way as by the single-variable statistical functions. Given a numeric
20604prefix argument of 1, these functions instead take one object from 20597prefix argument of 1, these functions instead take one object from
20605the stack, which must be an 20598the stack, which must be an
20606@texline @tmath{N\times2} 20599@texline @math{N\times2}
20607@infoline Nx2 20600@infoline Nx2
20608matrix of data values. Once again, variable names can be used in place 20601matrix of data values. Once again, variable names can be used in place
20609of actual vectors and matrices. 20602of actual vectors and matrices.
@@ -20861,7 +20854,7 @@ If any argument to @kbd{V M} is a matrix, the operator is normally mapped
20861across all elements of the matrix. For example, given the matrix 20854across all elements of the matrix. For example, given the matrix
20862@expr{[[1, -2, 3], [-4, 5, -6]]}, @kbd{V M A} takes six absolute values to 20855@expr{[[1, -2, 3], [-4, 5, -6]]}, @kbd{V M A} takes six absolute values to
20863produce another 20856produce another
20864@texline @tmath{3\times2} 20857@texline @math{3\times2}
20865@infoline 3x2 20858@infoline 3x2
20866matrix, @expr{[[1, 2, 3], [4, 5, 6]]}. 20859matrix, @expr{[[1, 2, 3], [4, 5, 6]]}.
20867 20860
@@ -22014,7 +22007,7 @@ as if in algebraic simplification mode. This is equivalent to typing
22014@kbd{a s}; @pxref{Simplifying Formulas}. If you give a numeric prefix 22007@kbd{a s}; @pxref{Simplifying Formulas}. If you give a numeric prefix
22015of 3 or more, it uses extended simplification mode (@kbd{a e}). 22008of 3 or more, it uses extended simplification mode (@kbd{a e}).
22016 22009
22017If you give a negative prefix argument @i{-1}, @i{-2}, or @i{-3}, 22010If you give a negative prefix argument @mathit{-1}, @mathit{-2}, or @mathit{-3},
22018it simplifies in the corresponding mode but only works on the top-level 22011it simplifies in the corresponding mode but only works on the top-level
22019function call of the formula. For example, @samp{(2 + 3) * (2 + 3)} will 22012function call of the formula. For example, @samp{(2 + 3) * (2 + 3)} will
22020simplify to @samp{(2 + 3)^2}, without simplifying the sub-formulas 22013simplify to @samp{(2 + 3)^2}, without simplifying the sub-formulas
@@ -22286,7 +22279,7 @@ simplifications.)
22286 22279
22287The distributive law is used to simplify sums in some cases: 22280The distributive law is used to simplify sums in some cases:
22288@expr{a x + b x} to @expr{(a + b) x}, where @expr{a} represents 22281@expr{a x + b x} to @expr{(a + b) x}, where @expr{a} represents
22289a number or an implicit 1 or @i{-1} (as in @expr{x} or @expr{-x}) 22282a number or an implicit 1 or @mathit{-1} (as in @expr{x} or @expr{-x})
22290and similarly for @expr{b}. Use the @kbd{a c}, @w{@kbd{a f}}, or 22283and similarly for @expr{b}. Use the @kbd{a c}, @w{@kbd{a f}}, or
22291@kbd{j M} commands to merge sums with non-numeric coefficients 22284@kbd{j M} commands to merge sums with non-numeric coefficients
22292using the distributive law. 22285using the distributive law.
@@ -22330,7 +22323,7 @@ rewritten to @expr{a (c - b)}.
22330 22323
22331The distributive law of products and powers is used for adjacent 22324The distributive law of products and powers is used for adjacent
22332terms of the product: @expr{x^a x^b} goes to 22325terms of the product: @expr{x^a x^b} goes to
22333@texline @tmath{x^{a+b}} 22326@texline @math{x^{a+b}}
22334@infoline @expr{x^(a+b)} 22327@infoline @expr{x^(a+b)}
22335where @expr{a} is a number, or an implicit 1 (as in @expr{x}), 22328where @expr{a} is a number, or an implicit 1 (as in @expr{x}),
22336or the implicit one-half of @expr{@t{sqrt}(x)}, and similarly for 22329or the implicit one-half of @expr{@t{sqrt}(x)}, and similarly for
@@ -22341,7 +22334,7 @@ If the sum of the powers is zero, the product is simplified to
22341 22334
22342The product of a negative power times anything but another negative 22335The product of a negative power times anything but another negative
22343power is changed to use division: 22336power is changed to use division:
22344@texline @tmath{x^{-2} y} 22337@texline @math{x^{-2} y}
22345@infoline @expr{x^(-2) y} 22338@infoline @expr{x^(-2) y}
22346goes to @expr{y / x^2} unless matrix mode is 22339goes to @expr{y / x^2} unless matrix mode is
22347in effect and neither @expr{x} nor @expr{y} are scalar (in which 22340in effect and neither @expr{x} nor @expr{y} are scalar (in which
@@ -22365,11 +22358,11 @@ infinite quantity, as directed by the current infinite mode.
22365@xref{Infinite Mode}. 22358@xref{Infinite Mode}.
22366 22359
22367The expression 22360The expression
22368@texline @tmath{a / b^{-c}} 22361@texline @math{a / b^{-c}}
22369@infoline @expr{a / b^(-c)} 22362@infoline @expr{a / b^(-c)}
22370is changed to @expr{a b^c}, where @expr{-c} is any negative-looking 22363is changed to @expr{a b^c}, where @expr{-c} is any negative-looking
22371power. Also, @expr{1 / b^c} is changed to 22364power. Also, @expr{1 / b^c} is changed to
22372@texline @tmath{b^{-c}} 22365@texline @math{b^{-c}}
22373@infoline @expr{b^(-c)} 22366@infoline @expr{b^(-c)}
22374for any power @expr{c}. 22367for any power @expr{c}.
22375 22368
@@ -22410,22 +22403,22 @@ Powers of products or quotients @expr{(a b)^c}, @expr{(a/b)^c}
22410are distributed to @expr{a^c b^c}, @expr{a^c / b^c} only if @expr{c} 22403are distributed to @expr{a^c b^c}, @expr{a^c / b^c} only if @expr{c}
22411is an integer, or if either @expr{a} or @expr{b} are nonnegative 22404is an integer, or if either @expr{a} or @expr{b} are nonnegative
22412real numbers. Powers of powers @expr{(a^b)^c} are simplified to 22405real numbers. Powers of powers @expr{(a^b)^c} are simplified to
22413@texline @tmath{a^{b c}} 22406@texline @math{a^{b c}}
22414@infoline @expr{a^(b c)} 22407@infoline @expr{a^(b c)}
22415only when @expr{c} is an integer and @expr{b c} also 22408only when @expr{c} is an integer and @expr{b c} also
22416evaluates to an integer. Without these restrictions these simplifications 22409evaluates to an integer. Without these restrictions these simplifications
22417would not be safe because of problems with principal values. 22410would not be safe because of problems with principal values.
22418(In other words, 22411(In other words,
22419@texline @tmath{((-3)^{1/2})^2} 22412@texline @math{((-3)^{1/2})^2}
22420@infoline @expr{((-3)^1:2)^2} 22413@infoline @expr{((-3)^1:2)^2}
22421is safe to simplify, but 22414is safe to simplify, but
22422@texline @tmath{((-3)^2)^{1/2}} 22415@texline @math{((-3)^2)^{1/2}}
22423@infoline @expr{((-3)^2)^1:2} 22416@infoline @expr{((-3)^2)^1:2}
22424is not.) @xref{Declarations}, for ways to inform Calc that your 22417is not.) @xref{Declarations}, for ways to inform Calc that your
22425variables satisfy these requirements. 22418variables satisfy these requirements.
22426 22419
22427As a special case of this rule, @expr{@t{sqrt}(x)^n} is simplified to 22420As a special case of this rule, @expr{@t{sqrt}(x)^n} is simplified to
22428@texline @tmath{x^{n/2}} 22421@texline @math{x^{n/2}}
22429@infoline @expr{x^(n/2)} 22422@infoline @expr{x^(n/2)}
22430only for even integers @expr{n}. 22423only for even integers @expr{n}.
22431 22424
@@ -22438,15 +22431,15 @@ even integer, or to @expr{-(a^b)} if @expr{b} is an odd integer,
22438for any negative-looking expression @expr{-a}. 22431for any negative-looking expression @expr{-a}.
22439 22432
22440Square roots @expr{@t{sqrt}(x)} generally act like one-half powers 22433Square roots @expr{@t{sqrt}(x)} generally act like one-half powers
22441@texline @tmath{x^{1:2}} 22434@texline @math{x^{1:2}}
22442@infoline @expr{x^1:2} 22435@infoline @expr{x^1:2}
22443for the purposes of the above-listed simplifications. 22436for the purposes of the above-listed simplifications.
22444 22437
22445Also, note that 22438Also, note that
22446@texline @tmath{1 / x^{1:2}} 22439@texline @math{1 / x^{1:2}}
22447@infoline @expr{1 / x^1:2} 22440@infoline @expr{1 / x^1:2}
22448is changed to 22441is changed to
22449@texline @tmath{x^{-1:2}}, 22442@texline @math{x^{-1:2}},
22450@infoline @expr{x^(-1:2)}, 22443@infoline @expr{x^(-1:2)},
22451but @expr{1 / @t{sqrt}(x)} is left alone. 22444but @expr{1 / @t{sqrt}(x)} is left alone.
22452 22445
@@ -22589,7 +22582,7 @@ Thus @expr{(x + y) (y + x)} will be simplified to @expr{(x + y)^2}.
22589A subtle point is that @expr{(x - y) (y - x)} will @emph{not} 22582A subtle point is that @expr{(x - y) (y - x)} will @emph{not}
22590be simplified to @expr{-(x - y)^2}; Calc does not notice that 22583be simplified to @expr{-(x - y)^2}; Calc does not notice that
22591one term can be written as a constant times the other, even if 22584one term can be written as a constant times the other, even if
22592that constant is @i{-1}. 22585that constant is @mathit{-1}.
22593 22586
22594A fraction times any expression, @expr{(a:b) x}, is changed to 22587A fraction times any expression, @expr{(a:b) x}, is changed to
22595a quotient involving integers: @expr{a x / b}. This is not 22588a quotient involving integers: @expr{a x / b}. This is not
@@ -22632,7 +22625,7 @@ Square roots of integer or rational arguments are simplified in
22632several ways. (Note that these will be left unevaluated only in 22625several ways. (Note that these will be left unevaluated only in
22633Symbolic mode.) First, square integer or rational factors are 22626Symbolic mode.) First, square integer or rational factors are
22634pulled out so that @expr{@t{sqrt}(8)} is rewritten as 22627pulled out so that @expr{@t{sqrt}(8)} is rewritten as
22635@texline @tmath{$2\,\t{sqrt}(2)$}. 22628@texline @math{2\,\t{sqrt}(2)}.
22636@infoline @expr{2 sqrt(2)}. 22629@infoline @expr{2 sqrt(2)}.
22637Conceptually speaking this implies factoring the argument into primes 22630Conceptually speaking this implies factoring the argument into primes
22638and moving pairs of primes out of the square root, but for reasons of 22631and moving pairs of primes out of the square root, but for reasons of
@@ -22694,23 +22687,23 @@ functions are known, except for negative arguments of @code{arcsin},
22694@code{arctan}, @code{arcsinh}, and @code{arctanh}. Note that 22687@code{arctan}, @code{arcsinh}, and @code{arctanh}. Note that
22695@expr{@t{arcsin}(@t{sin}(x))} can @emph{not} safely change to 22688@expr{@t{arcsin}(@t{sin}(x))} can @emph{not} safely change to
22696@expr{x}, since this only correct within an integer multiple of 22689@expr{x}, since this only correct within an integer multiple of
22697@texline @tmath{2 \pi} 22690@texline @math{2 \pi}
22698@infoline @expr{2 pi} 22691@infoline @expr{2 pi}
22699radians or 360 degrees. However, @expr{@t{arcsinh}(@t{sinh}(x))} is 22692radians or 360 degrees. However, @expr{@t{arcsinh}(@t{sinh}(x))} is
22700simplified to @expr{x} if @expr{x} is known to be real. 22693simplified to @expr{x} if @expr{x} is known to be real.
22701 22694
22702Several simplifications that apply to logarithms and exponentials 22695Several simplifications that apply to logarithms and exponentials
22703are that @expr{@t{exp}(@t{ln}(x))}, 22696are that @expr{@t{exp}(@t{ln}(x))},
22704@texline @t{e}@tmath{^{\ln(x)}}, 22697@texline @t{e}@math{^{\ln(x)}},
22705@infoline @expr{e^@t{ln}(x)}, 22698@infoline @expr{e^@t{ln}(x)},
22706and 22699and
22707@texline @tmath{10^{{\rm log10}(x)}} 22700@texline @math{10^{{\rm log10}(x)}}
22708@infoline @expr{10^@t{log10}(x)} 22701@infoline @expr{10^@t{log10}(x)}
22709all reduce to @expr{x}. Also, @expr{@t{ln}(@t{exp}(x))}, etc., can 22702all reduce to @expr{x}. Also, @expr{@t{ln}(@t{exp}(x))}, etc., can
22710reduce to @expr{x} if @expr{x} is provably real. The form 22703reduce to @expr{x} if @expr{x} is provably real. The form
22711@expr{@t{exp}(x)^y} is simplified to @expr{@t{exp}(x y)}. If @expr{x} 22704@expr{@t{exp}(x)^y} is simplified to @expr{@t{exp}(x y)}. If @expr{x}
22712is a suitable multiple of 22705is a suitable multiple of
22713@texline @tmath{\pi i} 22706@texline @math{\pi i}
22714@infoline @expr{pi i} 22707@infoline @expr{pi i}
22715(as described above for the trigonometric functions), then 22708(as described above for the trigonometric functions), then
22716@expr{@t{exp}(x)} or @expr{e^x} will be expanded. Finally, 22709@expr{@t{exp}(x)} or @expr{e^x} will be expanded. Finally,
@@ -22795,18 +22788,18 @@ are folded down to the 360-degree range that the inverse trigonometric
22795functions always produce. 22788functions always produce.
22796 22789
22797Powers of powers @expr{(x^a)^b} are simplified to 22790Powers of powers @expr{(x^a)^b} are simplified to
22798@texline @tmath{x^{a b}} 22791@texline @math{x^{a b}}
22799@infoline @expr{x^(a b)} 22792@infoline @expr{x^(a b)}
22800for all @expr{a} and @expr{b}. These results will be valid only 22793for all @expr{a} and @expr{b}. These results will be valid only
22801in a restricted range of @expr{x}; for example, in 22794in a restricted range of @expr{x}; for example, in
22802@texline @tmath{(x^2)^{1:2}} 22795@texline @math{(x^2)^{1:2}}
22803@infoline @expr{(x^2)^1:2} 22796@infoline @expr{(x^2)^1:2}
22804the powers cancel to get @expr{x}, which is valid for positive values 22797the powers cancel to get @expr{x}, which is valid for positive values
22805of @expr{x} but not for negative or complex values. 22798of @expr{x} but not for negative or complex values.
22806 22799
22807Similarly, @expr{@t{sqrt}(x^a)} and @expr{@t{sqrt}(x)^a} are both 22800Similarly, @expr{@t{sqrt}(x^a)} and @expr{@t{sqrt}(x)^a} are both
22808simplified (possibly unsafely) to 22801simplified (possibly unsafely) to
22809@texline @tmath{x^{a/2}}. 22802@texline @math{x^{a/2}}.
22810@infoline @expr{x^(a/2)}. 22803@infoline @expr{x^(a/2)}.
22811 22804
22812Forms like @expr{@t{sqrt}(1 - sin(x)^2)} are simplified to, e.g., 22805Forms like @expr{@t{sqrt}(1 - sin(x)^2)} are simplified to, e.g.,
@@ -22882,7 +22875,7 @@ number for an answer, then the quotient simplifies to that number.
22882For powers and square roots, the ``unsafe'' simplifications 22875For powers and square roots, the ``unsafe'' simplifications
22883@expr{(a b)^c} to @expr{a^c b^c}, @expr{(a/b)^c} to @expr{a^c / b^c}, 22876@expr{(a b)^c} to @expr{a^c b^c}, @expr{(a/b)^c} to @expr{a^c / b^c},
22884and @expr{(a^b)^c} to 22877and @expr{(a^b)^c} to
22885@texline @tmath{a^{b c}} 22878@texline @math{a^{b c}}
22886@infoline @expr{a^(b c)} 22879@infoline @expr{a^(b c)}
22887are done if the powers are real numbers. (These are safe in the context 22880are done if the powers are real numbers. (These are safe in the context
22888of units because all numbers involved can reasonably be assumed to be 22881of units because all numbers involved can reasonably be assumed to be
@@ -22897,10 +22890,10 @@ is simplified by noting that @expr{1.5 = 3:2}, that @samp{acre}
22897is defined in terms of @samp{m^2}, and that the 2 in the power of 22890is defined in terms of @samp{m^2}, and that the 2 in the power of
22898@code{m} is a multiple of 2 in @expr{3:2}. Thus, @code{acre^1.5} is 22891@code{m} is a multiple of 2 in @expr{3:2}. Thus, @code{acre^1.5} is
22899replaced by approximately 22892replaced by approximately
22900@texline @tmath{(4046 m^2)^{1.5}} 22893@texline @math{(4046 m^2)^{1.5}}
22901@infoline @expr{(4046 m^2)^1.5}, 22894@infoline @expr{(4046 m^2)^1.5},
22902which is then changed to 22895which is then changed to
22903@texline @tmath{4046^{1.5} \, (m^2)^{1.5}}, 22896@texline @math{4046^{1.5} \, (m^2)^{1.5}},
22904@infoline @expr{4046^1.5 (m^2)^1.5}, 22897@infoline @expr{4046^1.5 (m^2)^1.5},
22905then to @expr{257440 m^3}. 22898then to @expr{257440 m^3}.
22906 22899
@@ -23190,7 +23183,7 @@ answer!
23190If you use the @code{deriv} function directly in an algebraic formula, 23183If you use the @code{deriv} function directly in an algebraic formula,
23191you can write @samp{deriv(f,x,x0)} which represents the derivative 23184you can write @samp{deriv(f,x,x0)} which represents the derivative
23192of @expr{f} with respect to @expr{x}, evaluated at the point 23185of @expr{f} with respect to @expr{x}, evaluated at the point
23193@texline @tmath{x=x_0}. 23186@texline @math{x=x_0}.
23194@infoline @expr{x=x0}. 23187@infoline @expr{x=x0}.
23195 23188
23196If the formula being differentiated contains functions which Calc does 23189If the formula being differentiated contains functions which Calc does
@@ -23230,7 +23223,7 @@ all integrable functions, but it is able to integrate several large
23230classes of formulas. In particular, any polynomial or rational function 23223classes of formulas. In particular, any polynomial or rational function
23231(a polynomial divided by a polynomial) is acceptable. (Rational functions 23224(a polynomial divided by a polynomial) is acceptable. (Rational functions
23232don't have to be in explicit quotient form, however; 23225don't have to be in explicit quotient form, however;
23233@texline @tmath{x/(1+x^{-2})} 23226@texline @math{x/(1+x^{-2})}
23234@infoline @expr{x/(1+x^-2)} 23227@infoline @expr{x/(1+x^-2)}
23235is not strictly a quotient of polynomials, but it is equivalent to 23228is not strictly a quotient of polynomials, but it is equivalent to
23236@expr{x^3/(x^2+1)}, which is.) Also, square roots of terms involving 23229@expr{x^3/(x^2+1)}, which is.) Also, square roots of terms involving
@@ -23256,7 +23249,7 @@ integral $\int_a^b f(x) \, dx$.
23256Please note that the current implementation of Calc's integrator sometimes 23249Please note that the current implementation of Calc's integrator sometimes
23257produces results that are significantly more complex than they need to 23250produces results that are significantly more complex than they need to
23258be. For example, the integral Calc finds for 23251be. For example, the integral Calc finds for
23259@texline @tmath{1/(x+\sqrt{x^2+1})} 23252@texline @math{1/(x+\sqrt{x^2+1})}
23260@infoline @expr{1/(x+sqrt(x^2+1))} 23253@infoline @expr{1/(x+sqrt(x^2+1))}
23261is several times more complicated than the answer Mathematica 23254is several times more complicated than the answer Mathematica
23262returns for the same input, although the two forms are numerically 23255returns for the same input, although the two forms are numerically
@@ -23264,11 +23257,11 @@ equivalent. Also, any indefinite integral should be considered to have
23264an arbitrary constant of integration added to it, although Calc does not 23257an arbitrary constant of integration added to it, although Calc does not
23265write an explicit constant of integration in its result. For example, 23258write an explicit constant of integration in its result. For example,
23266Calc's solution for 23259Calc's solution for
23267@texline @tmath{1/(1+\tan x)} 23260@texline @math{1/(1+\tan x)}
23268@infoline @expr{1/(1+tan(x))} 23261@infoline @expr{1/(1+tan(x))}
23269differs from the solution given in the @emph{CRC Math Tables} by a 23262differs from the solution given in the @emph{CRC Math Tables} by a
23270constant factor of 23263constant factor of
23271@texline @tmath{\pi i / 2} 23264@texline @math{\pi i / 2}
23272@infoline @expr{pi i / 2}, 23265@infoline @expr{pi i / 2},
23273due to a different choice of constant of integration. 23266due to a different choice of constant of integration.
23274 23267
@@ -23328,7 +23321,7 @@ in your @code{IntegRules}.
23328As a more serious example, the expression @samp{exp(x)/x} cannot be 23321As a more serious example, the expression @samp{exp(x)/x} cannot be
23329integrated in terms of the standard functions, so the ``exponential 23322integrated in terms of the standard functions, so the ``exponential
23330integral'' function 23323integral'' function
23331@texline @tmath{{\rm Ei}(x)} 23324@texline @math{{\rm Ei}(x)}
23332@infoline @expr{Ei(x)} 23325@infoline @expr{Ei(x)}
23333was invented to describe it. 23326was invented to describe it.
23334We can get Calc to do this integral in terms of a made-up @code{Ei} 23327We can get Calc to do this integral in terms of a made-up @code{Ei}
@@ -23501,16 +23494,16 @@ form @expr{X = 0}.
23501This command also works for inequalities, as in @expr{y < 3x + 6}. 23494This command also works for inequalities, as in @expr{y < 3x + 6}.
23502Some inequalities cannot be solved where the analogous equation could 23495Some inequalities cannot be solved where the analogous equation could
23503be; for example, solving 23496be; for example, solving
23504@texline @tmath{a < b \, c} 23497@texline @math{a < b \, c}
23505@infoline @expr{a < b c} 23498@infoline @expr{a < b c}
23506for @expr{b} is impossible 23499for @expr{b} is impossible
23507without knowing the sign of @expr{c}. In this case, @kbd{a S} will 23500without knowing the sign of @expr{c}. In this case, @kbd{a S} will
23508produce the result 23501produce the result
23509@texline @tmath{b \mathbin{\hbox{\code{!=}}} a/c} 23502@texline @math{b \mathbin{\hbox{\code{!=}}} a/c}
23510@infoline @expr{b != a/c} 23503@infoline @expr{b != a/c}
23511(using the not-equal-to operator) to signify that the direction of the 23504(using the not-equal-to operator) to signify that the direction of the
23512inequality is now unknown. The inequality 23505inequality is now unknown. The inequality
23513@texline @tmath{a \le b \, c} 23506@texline @math{a \le b \, c}
23514@infoline @expr{a <= b c} 23507@infoline @expr{a <= b c}
23515is not even partially solved. @xref{Declarations}, for a way to tell 23508is not even partially solved. @xref{Declarations}, for a way to tell
23516Calc that the signs of the variables in a formula are in fact known. 23509Calc that the signs of the variables in a formula are in fact known.
@@ -23537,7 +23530,7 @@ Some equations have more than one solution. The Hyperbolic flag
23537general family of solutions. It will invent variables @code{n1}, 23530general family of solutions. It will invent variables @code{n1},
23538@code{n2}, @dots{}, which represent independent arbitrary integers, and 23531@code{n2}, @dots{}, which represent independent arbitrary integers, and
23539@code{s1}, @code{s2}, @dots{}, which represent independent arbitrary 23532@code{s1}, @code{s2}, @dots{}, which represent independent arbitrary
23540signs (either @i{+1} or @i{-1}). If you don't use the Hyperbolic 23533signs (either @mathit{+1} or @mathit{-1}). If you don't use the Hyperbolic
23541flag, Calc will use zero in place of all arbitrary integers, and plus 23534flag, Calc will use zero in place of all arbitrary integers, and plus
23542one in place of all arbitrary signs. Note that variables like @code{n1} 23535one in place of all arbitrary signs. Note that variables like @code{n1}
23543and @code{s1} are not given any special interpretation in Calc except by 23536and @code{s1} are not given any special interpretation in Calc except by
@@ -23970,11 +23963,11 @@ with the minimum value itself.
23970 23963
23971Note that this command looks for a @emph{local} minimum. Many functions 23964Note that this command looks for a @emph{local} minimum. Many functions
23972have more than one minimum; some, like 23965have more than one minimum; some, like
23973@texline @tmath{x \sin x}, 23966@texline @math{x \sin x},
23974@infoline @expr{x sin(x)}, 23967@infoline @expr{x sin(x)},
23975have infinitely many. In fact, there is no easy way to define the 23968have infinitely many. In fact, there is no easy way to define the
23976``global'' minimum of 23969``global'' minimum of
23977@texline @tmath{x \sin x} 23970@texline @math{x \sin x}
23978@infoline @expr{x sin(x)} 23971@infoline @expr{x sin(x)}
23979but Calc can still locate any particular local minimum 23972but Calc can still locate any particular local minimum
23980for you. Calc basically goes downhill from the initial guess until it 23973for you. Calc basically goes downhill from the initial guess until it
@@ -24097,7 +24090,7 @@ the @dfn{parameters} of the model.
24097The @kbd{a F} command takes the data set to be fitted from the stack. 24090The @kbd{a F} command takes the data set to be fitted from the stack.
24098By default, it expects the data in the form of a matrix. For example, 24091By default, it expects the data in the form of a matrix. For example,
24099for a linear or polynomial fit, this would be a 24092for a linear or polynomial fit, this would be a
24100@texline @tmath{2\times N} 24093@texline @math{2\times N}
24101@infoline 2xN 24094@infoline 2xN
24102matrix where the first row is a list of @expr{x} values and the second 24095matrix where the first row is a list of @expr{x} values and the second
24103row has the corresponding @expr{y} values. For the multilinear fit 24096row has the corresponding @expr{y} values. For the multilinear fit
@@ -24105,10 +24098,10 @@ shown above, the matrix would have four rows (@expr{x_1}, @expr{x_2},
24105@expr{x_3}, and @expr{y}, respectively). 24098@expr{x_3}, and @expr{y}, respectively).
24106 24099
24107If you happen to have an 24100If you happen to have an
24108@texline @tmath{N\times2} 24101@texline @math{N\times2}
24109@infoline Nx2 24102@infoline Nx2
24110matrix instead of a 24103matrix instead of a
24111@texline @tmath{2\times N} 24104@texline @math{2\times N}
24112@infoline 2xN 24105@infoline 2xN
24113matrix, just press @kbd{v t} first to transpose the matrix. 24106matrix, just press @kbd{v t} first to transpose the matrix.
24114 24107
@@ -24206,11 +24199,11 @@ which is clearly zero if @expr{a + b x} exactly fits all data points,
24206and increases as various @expr{a + b x_i} values fail to match the 24199and increases as various @expr{a + b x_i} values fail to match the
24207corresponding @expr{y_i} values. There are several reasons why the 24200corresponding @expr{y_i} values. There are several reasons why the
24208summand is squared, one of them being to ensure that 24201summand is squared, one of them being to ensure that
24209@texline @tmath{\chi^2 \ge 0}. 24202@texline @math{\chi^2 \ge 0}.
24210@infoline @expr{chi^2 >= 0}. 24203@infoline @expr{chi^2 >= 0}.
24211Least-squares fitting simply chooses the values of @expr{a} and @expr{b} 24204Least-squares fitting simply chooses the values of @expr{a} and @expr{b}
24212for which the error 24205for which the error
24213@texline @tmath{\chi^2} 24206@texline @math{\chi^2}
24214@infoline @expr{chi^2} 24207@infoline @expr{chi^2}
24215is as small as possible. 24208is as small as possible.
24216 24209
@@ -24266,7 +24259,7 @@ line slightly to improve the fit.
24266 24259
24267An important result from the theory of polynomial fitting is that it 24260An important result from the theory of polynomial fitting is that it
24268is always possible to fit @var{n} data points exactly using a polynomial 24261is always possible to fit @var{n} data points exactly using a polynomial
24269of degree @i{@var{n}-1}, sometimes called an @dfn{interpolating polynomial}. 24262of degree @mathit{@var{n}-1}, sometimes called an @dfn{interpolating polynomial}.
24270Using the modified (14) data matrix, a model number of 4 gives 24263Using the modified (14) data matrix, a model number of 4 gives
24271a polynomial that exactly matches all five data points: 24264a polynomial that exactly matches all five data points:
24272 24265
@@ -24371,10 +24364,10 @@ contain error forms. The data values must either all include errors
24371or all be plain numbers. Error forms can go anywhere but generally 24364or all be plain numbers. Error forms can go anywhere but generally
24372go on the numbers in the last row of the data matrix. If the last 24365go on the numbers in the last row of the data matrix. If the last
24373row contains error forms 24366row contains error forms
24374@texline `@var{y_i}@w{ @t{+/-} }@tmath{\sigma_i}', 24367@texline `@var{y_i}@w{ @t{+/-} }@math{\sigma_i}',
24375@infoline `@var{y_i}@w{ @t{+/-} }@var{sigma_i}', 24368@infoline `@var{y_i}@w{ @t{+/-} }@var{sigma_i}',
24376then the 24369then the
24377@texline @tmath{\chi^2} 24370@texline @math{\chi^2}
24378@infoline @expr{chi^2} 24371@infoline @expr{chi^2}
24379statistic is now, 24372statistic is now,
24380 24373
@@ -24397,7 +24390,7 @@ the fitting operation.
24397If there are error forms on other rows of the data matrix, all the 24390If there are error forms on other rows of the data matrix, all the
24398errors for a given data point are combined; the square root of the 24391errors for a given data point are combined; the square root of the
24399sum of the squares of the errors forms the 24392sum of the squares of the errors forms the
24400@texline @tmath{\sigma_i} 24393@texline @math{\sigma_i}
24401@infoline @expr{sigma_i} 24394@infoline @expr{sigma_i}
24402used for the data point. 24395used for the data point.
24403 24396
@@ -24407,14 +24400,14 @@ probably use @kbd{H a F} so that the output also contains error
24407estimates. 24400estimates.
24408 24401
24409If the input contains error forms but all the 24402If the input contains error forms but all the
24410@texline @tmath{\sigma_i} 24403@texline @math{\sigma_i}
24411@infoline @expr{sigma_i} 24404@infoline @expr{sigma_i}
24412values are the same, it is easy to see that the resulting fitted model 24405values are the same, it is easy to see that the resulting fitted model
24413will be the same as if the input did not have error forms at all 24406will be the same as if the input did not have error forms at all
24414@texline (@tmath{\chi^2} 24407@texline (@math{\chi^2}
24415@infoline (@expr{chi^2} 24408@infoline (@expr{chi^2}
24416is simply scaled uniformly by 24409is simply scaled uniformly by
24417@texline @tmath{1 / \sigma^2}, 24410@texline @math{1 / \sigma^2},
24418@infoline @expr{1 / sigma^2}, 24411@infoline @expr{1 / sigma^2},
24419which doesn't affect where it has a minimum). But there @emph{will} be 24412which doesn't affect where it has a minimum). But there @emph{will} be
24420a difference in the estimated errors of the coefficients reported by 24413a difference in the estimated errors of the coefficients reported by
@@ -24449,20 +24442,20 @@ will have length @expr{M = d+1} with the constant term first.
24449@item 24442@item
24450The covariance matrix @expr{C} computed from the fit. This is 24443The covariance matrix @expr{C} computed from the fit. This is
24451an @var{m}x@var{m} symmetric matrix; the diagonal elements 24444an @var{m}x@var{m} symmetric matrix; the diagonal elements
24452@texline @tmath{C_{jj}} 24445@texline @math{C_{jj}}
24453@infoline @expr{C_j_j} 24446@infoline @expr{C_j_j}
24454are the variances 24447are the variances
24455@texline @tmath{\sigma_j^2} 24448@texline @math{\sigma_j^2}
24456@infoline @expr{sigma_j^2} 24449@infoline @expr{sigma_j^2}
24457of the parameters. The other elements are covariances 24450of the parameters. The other elements are covariances
24458@texline @tmath{\sigma_{ij}^2} 24451@texline @math{\sigma_{ij}^2}
24459@infoline @expr{sigma_i_j^2} 24452@infoline @expr{sigma_i_j^2}
24460that describe the correlation between pairs of parameters. (A related 24453that describe the correlation between pairs of parameters. (A related
24461set of numbers, the @dfn{linear correlation coefficients} 24454set of numbers, the @dfn{linear correlation coefficients}
24462@texline @tmath{r_{ij}}, 24455@texline @math{r_{ij}},
24463@infoline @expr{r_i_j}, 24456@infoline @expr{r_i_j},
24464are defined as 24457are defined as
24465@texline @tmath{\sigma_{ij}^2 / \sigma_i \, \sigma_j}.) 24458@texline @math{\sigma_{ij}^2 / \sigma_i \, \sigma_j}.)
24466@infoline @expr{sigma_i_j^2 / sigma_i sigma_j}.) 24459@infoline @expr{sigma_i_j^2 / sigma_i sigma_j}.)
24467 24460
24468@item 24461@item
@@ -24473,11 +24466,11 @@ polynomial and multilinear fits described so far.
24473 24466
24474@item 24467@item
24475The value of 24468The value of
24476@texline @tmath{\chi^2} 24469@texline @math{\chi^2}
24477@infoline @expr{chi^2} 24470@infoline @expr{chi^2}
24478for the fit, calculated by the formulas shown above. This gives a 24471for the fit, calculated by the formulas shown above. This gives a
24479measure of the quality of the fit; statisticians consider 24472measure of the quality of the fit; statisticians consider
24480@texline @tmath{\chi^2 \approx N - M} 24473@texline @math{\chi^2 \approx N - M}
24481@infoline @expr{chi^2 = N - M} 24474@infoline @expr{chi^2 = N - M}
24482to indicate a moderately good fit (where again @expr{N} is the number of 24475to indicate a moderately good fit (where again @expr{N} is the number of
24483data points and @expr{M} is the number of parameters). 24476data points and @expr{M} is the number of parameters).
@@ -24486,13 +24479,13 @@ data points and @expr{M} is the number of parameters).
24486A measure of goodness of fit expressed as a probability @expr{Q}. 24479A measure of goodness of fit expressed as a probability @expr{Q}.
24487This is computed from the @code{utpc} probability distribution 24480This is computed from the @code{utpc} probability distribution
24488function using 24481function using
24489@texline @tmath{\chi^2} 24482@texline @math{\chi^2}
24490@infoline @expr{chi^2} 24483@infoline @expr{chi^2}
24491with @expr{N - M} degrees of freedom. A 24484with @expr{N - M} degrees of freedom. A
24492value of 0.5 implies a good fit; some texts recommend that often 24485value of 0.5 implies a good fit; some texts recommend that often
24493@expr{Q = 0.1} or even 0.001 can signify an acceptable fit. In 24486@expr{Q = 0.1} or even 0.001 can signify an acceptable fit. In
24494particular, 24487particular,
24495@texline @tmath{\chi^2} 24488@texline @math{\chi^2}
24496@infoline @expr{chi^2} 24489@infoline @expr{chi^2}
24497statistics assume the errors in your inputs 24490statistics assume the errors in your inputs
24498follow a normal (Gaussian) distribution; if they don't, you may 24491follow a normal (Gaussian) distribution; if they don't, you may
@@ -24501,7 +24494,7 @@ have to accept smaller values of @expr{Q}.
24501The @expr{Q} value is computed only if the input included error 24494The @expr{Q} value is computed only if the input included error
24502estimates. Otherwise, Calc will report the symbol @code{nan} 24495estimates. Otherwise, Calc will report the symbol @code{nan}
24503for @expr{Q}. The reason is that in this case the 24496for @expr{Q}. The reason is that in this case the
24504@texline @tmath{\chi^2} 24497@texline @math{\chi^2}
24505@infoline @expr{chi^2} 24498@infoline @expr{chi^2}
24506value has effectively been used to estimate the original errors 24499value has effectively been used to estimate the original errors
24507in the input, and thus there is no redundant information left 24500in the input, and thus there is no redundant information left
@@ -24520,31 +24513,31 @@ Here is a complete list of the standard models recognized by @kbd{a F}:
24520 24513
24521@table @kbd 24514@table @kbd
24522@item 1 24515@item 1
24523Linear or multilinear. @i{a + b x + c y + d z}. 24516Linear or multilinear. @mathit{a + b x + c y + d z}.
24524@item 2-9 24517@item 2-9
24525Polynomials. @i{a + b x + c x^2 + d x^3}. 24518Polynomials. @mathit{a + b x + c x^2 + d x^3}.
24526@item e 24519@item e
24527Exponential. @i{a} @t{exp}@i{(b x)} @t{exp}@i{(c y)}. 24520Exponential. @mathit{a} @t{exp}@mathit{(b x)} @t{exp}@mathit{(c y)}.
24528@item E 24521@item E
24529Base-10 exponential. @i{a} @t{10^}@i{(b x)} @t{10^}@i{(c y)}. 24522Base-10 exponential. @mathit{a} @t{10^}@mathit{(b x)} @t{10^}@mathit{(c y)}.
24530@item x 24523@item x
24531Exponential (alternate notation). @t{exp}@i{(a + b x + c y)}. 24524Exponential (alternate notation). @t{exp}@mathit{(a + b x + c y)}.
24532@item X 24525@item X
24533Base-10 exponential (alternate). @t{10^}@i{(a + b x + c y)}. 24526Base-10 exponential (alternate). @t{10^}@mathit{(a + b x + c y)}.
24534@item l 24527@item l
24535Logarithmic. @i{a + b} @t{ln}@i{(x) + c} @t{ln}@i{(y)}. 24528Logarithmic. @mathit{a + b} @t{ln}@mathit{(x) + c} @t{ln}@mathit{(y)}.
24536@item L 24529@item L
24537Base-10 logarithmic. @i{a + b} @t{log10}@i{(x) + c} @t{log10}@i{(y)}. 24530Base-10 logarithmic. @mathit{a + b} @t{log10}@mathit{(x) + c} @t{log10}@mathit{(y)}.
24538@item ^ 24531@item ^
24539General exponential. @i{a b^x c^y}. 24532General exponential. @mathit{a b^x c^y}.
24540@item p 24533@item p
24541Power law. @i{a x^b y^c}. 24534Power law. @mathit{a x^b y^c}.
24542@item q 24535@item q
24543Quadratic. @i{a + b (x-c)^2 + d (x-e)^2}. 24536Quadratic. @mathit{a + b (x-c)^2 + d (x-e)^2}.
24544@item g 24537@item g
24545Gaussian. 24538Gaussian.
24546@texline @tmath{{a \over b \sqrt{2 \pi}} \exp\left( -{1 \over 2} \left( x - c \over b \right)^2 \right)}. 24539@texline @math{{a \over b \sqrt{2 \pi}} \exp\left( -{1 \over 2} \left( x - c \over b \right)^2 \right)}.
24547@infoline @i{(a / b sqrt(2 pi)) exp(-0.5*((x-c)/b)^2)}. 24540@infoline @mathit{(a / b sqrt(2 pi)) exp(-0.5*((x-c)/b)^2)}.
24548@end table 24541@end table
24549 24542
24550All of these models are used in the usual way; just press the appropriate 24543All of these models are used in the usual way; just press the appropriate
@@ -24656,18 +24649,18 @@ Calc uses the principal values of inverse functions like @code{ln}
24656and @code{arcsin} when doing fits. For example, when you enter 24649and @code{arcsin} when doing fits. For example, when you enter
24657the model @samp{y = sin(a t + b)} Calc actually uses the easier 24650the model @samp{y = sin(a t + b)} Calc actually uses the easier
24658form @samp{arcsin(y) = a t + b}. The @code{arcsin} function always 24651form @samp{arcsin(y) = a t + b}. The @code{arcsin} function always
24659returns results in the range from @i{-90} to 90 degrees (or the 24652returns results in the range from @mathit{-90} to 90 degrees (or the
24660equivalent range in radians). Suppose you had data that you 24653equivalent range in radians). Suppose you had data that you
24661believed to represent roughly three oscillations of a sine wave, 24654believed to represent roughly three oscillations of a sine wave,
24662so that the argument of the sine might go from zero to 24655so that the argument of the sine might go from zero to
24663@texline @tmath{3\times360} 24656@texline @math{3\times360}
24664@infoline @i{3*360} 24657@infoline @mathit{3*360}
24665degrees. 24658degrees.
24666The above model would appear to be a good way to determine the 24659The above model would appear to be a good way to determine the
24667true frequency and phase of the sine wave, but in practice it 24660true frequency and phase of the sine wave, but in practice it
24668would fail utterly. The righthand side of the actual model 24661would fail utterly. The righthand side of the actual model
24669@samp{arcsin(y) = a t + b} will grow smoothly with @expr{t}, but 24662@samp{arcsin(y) = a t + b} will grow smoothly with @expr{t}, but
24670the lefthand side will bounce back and forth between @i{-90} and 90. 24663the lefthand side will bounce back and forth between @mathit{-90} and 90.
24671No values of @expr{a} and @expr{b} can make the two sides match, 24664No values of @expr{a} and @expr{b} can make the two sides match,
24672even approximately. 24665even approximately.
24673 24666
@@ -24722,16 +24715,16 @@ ln(y) = ln(a) + b ln(x)
24722 24715
24723@noindent 24716@noindent
24724which matches the desired form with 24717which matches the desired form with
24725@texline @tmath{Y = \ln(y)}, 24718@texline @math{Y = \ln(y)},
24726@infoline @expr{Y = ln(y)}, 24719@infoline @expr{Y = ln(y)},
24727@texline @tmath{A = \ln(a)}, 24720@texline @math{A = \ln(a)},
24728@infoline @expr{A = ln(a)}, 24721@infoline @expr{A = ln(a)},
24729@expr{F = 1}, @expr{B = b}, and 24722@expr{F = 1}, @expr{B = b}, and
24730@texline @tmath{G = \ln(x)}. 24723@texline @math{G = \ln(x)}.
24731@infoline @expr{G = ln(x)}. 24724@infoline @expr{G = ln(x)}.
24732Calc thus computes the logarithms of your @expr{y} and @expr{x} values, 24725Calc thus computes the logarithms of your @expr{y} and @expr{x} values,
24733does a linear fit for @expr{A} and @expr{B}, then solves to get 24726does a linear fit for @expr{A} and @expr{B}, then solves to get
24734@texline @tmath{a = \exp(A)} 24727@texline @math{a = \exp(A)}
24735@infoline @expr{a = exp(A)} 24728@infoline @expr{a = exp(A)}
24736and @expr{b = B}. 24729and @expr{b = B}.
24737 24730
@@ -24745,7 +24738,7 @@ y = a + b c^2 - 2 b c x + b x^2
24745 24738
24746@noindent 24739@noindent
24747which matches with @expr{Y = y}, @expr{A = a + b c^2}, @expr{F = 1}, 24740which matches with @expr{Y = y}, @expr{A = a + b c^2}, @expr{F = 1},
24748@expr{B = -2 b c}, @expr{G = x} (the @i{-2} factor could just as easily 24741@expr{B = -2 b c}, @expr{G = x} (the @mathit{-2} factor could just as easily
24749have been put into @expr{G} instead of @expr{B}), @expr{C = b}, and 24742have been put into @expr{G} instead of @expr{B}), @expr{C = b}, and
24750@expr{H = x^2}. 24743@expr{H = x^2}.
24751 24744
@@ -24777,7 +24770,7 @@ from the list of parameters when you answer the variables prompt.
24777A last desperate step would be to use the general-purpose 24770A last desperate step would be to use the general-purpose
24778@code{minimize} function rather than @code{fit}. After all, both 24771@code{minimize} function rather than @code{fit}. After all, both
24779functions solve the problem of minimizing an expression (the 24772functions solve the problem of minimizing an expression (the
24780@texline @tmath{\chi^2} 24773@texline @math{\chi^2}
24781@infoline @expr{chi^2} 24774@infoline @expr{chi^2}
24782sum) by adjusting certain parameters in the expression. The @kbd{a F} 24775sum) by adjusting certain parameters in the expression. The @kbd{a F}
24783command is able to use a vastly more efficient algorithm due to its 24776command is able to use a vastly more efficient algorithm due to its
@@ -24788,7 +24781,7 @@ A compromise would be to pick out a few parameters without which the
24788fit is linearizable, and use @code{minimize} on a call to @code{fit} 24781fit is linearizable, and use @code{minimize} on a call to @code{fit}
24789which efficiently takes care of the rest of the parameters. The thing 24782which efficiently takes care of the rest of the parameters. The thing
24790to be minimized would be the value of 24783to be minimized would be the value of
24791@texline @tmath{\chi^2} 24784@texline @math{\chi^2}
24792@infoline @expr{chi^2} 24785@infoline @expr{chi^2}
24793returned as the fifth result of the @code{xfit} function: 24786returned as the fifth result of the @code{xfit} function:
24794 24787
@@ -24848,11 +24841,11 @@ and @expr{y} to be plain numbers, and makes @expr{z} into an error
24848form with this combined error. The @expr{Y(x,y,z)} part of the 24841form with this combined error. The @expr{Y(x,y,z)} part of the
24849linearized model is evaluated, and the result should be an error 24842linearized model is evaluated, and the result should be an error
24850form. The error part of that result is used for 24843form. The error part of that result is used for
24851@texline @tmath{\sigma_i} 24844@texline @math{\sigma_i}
24852@infoline @expr{sigma_i} 24845@infoline @expr{sigma_i}
24853for the data point. If for some reason @expr{Y(x,y,z)} does not return 24846for the data point. If for some reason @expr{Y(x,y,z)} does not return
24854an error form, the combined error from @expr{z} is used directly for 24847an error form, the combined error from @expr{z} is used directly for
24855@texline @tmath{\sigma_i}. 24848@texline @math{\sigma_i}.
24856@infoline @expr{sigma_i}. 24849@infoline @expr{sigma_i}.
24857Finally, @expr{z} is also stripped of its error 24850Finally, @expr{z} is also stripped of its error
24858for use in computing @expr{F(x,y,z)}, @expr{G(x,y,z)} and so on; 24851for use in computing @expr{F(x,y,z)}, @expr{G(x,y,z)} and so on;
@@ -24864,7 +24857,7 @@ the most reasonable thing in the typical case that @expr{Y(x,y,z)}
24864depends only on the dependent variable @expr{z}, and in fact is 24857depends only on the dependent variable @expr{z}, and in fact is
24865often simply equal to @expr{z}. For common cases like polynomials 24858often simply equal to @expr{z}. For common cases like polynomials
24866and multilinear models, the combined error is simply used as the 24859and multilinear models, the combined error is simply used as the
24867@texline @tmath{\sigma} 24860@texline @math{\sigma}
24868@infoline @expr{sigma} 24861@infoline @expr{sigma}
24869for the data point with no further ado.) 24862for the data point with no further ado.)
24870 24863
@@ -25218,7 +25211,7 @@ If the lower limit is greater than the upper limit (assuming a
25218positive step size), the result is generally zero. However, 25211positive step size), the result is generally zero. However,
25219Calc only guarantees a zero result when the upper limit is 25212Calc only guarantees a zero result when the upper limit is
25220exactly one step less than the lower limit, i.e., if the number 25213exactly one step less than the lower limit, i.e., if the number
25221of iterations is @i{-1}. Thus @samp{sum(f(k), k, n, n-1)} is zero 25214of iterations is @mathit{-1}. Thus @samp{sum(f(k), k, n, n-1)} is zero
25222but the sum from @samp{n} to @samp{n-2} may report a nonzero value 25215but the sum from @samp{n} to @samp{n-2} may report a nonzero value
25223if Calc used a closed form solution. 25216if Calc used a closed form solution.
25224 25217
@@ -25244,7 +25237,7 @@ formula works out to the indeterminate form @expr{0 / 0}, which
25244Calc will not assume is zero. Better would be to use 25237Calc will not assume is zero. Better would be to use
25245@samp{(k != k_0) ? 1/(k-k_0) : 0}; the @samp{? :} operator does 25238@samp{(k != k_0) ? 1/(k-k_0) : 0}; the @samp{? :} operator does
25246an ``if-then-else'' test: This expression says, ``if 25239an ``if-then-else'' test: This expression says, ``if
25247@texline @tmath{k \ne k_0}, 25240@texline @math{k \ne k_0},
25248@infoline @expr{k != k_0}, 25241@infoline @expr{k != k_0},
25249then @expr{1/(k-k_0)}, else zero.'' Now the formula @expr{1/(k-k_0)} 25242then @expr{1/(k-k_0)}, else zero.'' Now the formula @expr{1/(k-k_0)}
25250will not even be evaluated by Calc when @expr{k = k_0}. 25243will not even be evaluated by Calc when @expr{k = k_0}.
@@ -26259,16 +26252,16 @@ then the rule set @samp{[f(0) := 0, import(linearF)]} will apply
26259all three rules. It is possible to modify the imported rules 26252all three rules. It is possible to modify the imported rules
26260slightly: @samp{import(x, v1, x1, v2, x2, @dots{})} imports 26253slightly: @samp{import(x, v1, x1, v2, x2, @dots{})} imports
26261the rule set @expr{x} with all occurrences of 26254the rule set @expr{x} with all occurrences of
26262@texline @tmath{v_1}, 26255@texline @math{v_1},
26263@infoline @expr{v1}, 26256@infoline @expr{v1},
26264as either a variable name or a function name, replaced with 26257as either a variable name or a function name, replaced with
26265@texline @tmath{x_1} 26258@texline @math{x_1}
26266@infoline @expr{x1} 26259@infoline @expr{x1}
26267and so on. (If 26260and so on. (If
26268@texline @tmath{v_1} 26261@texline @math{v_1}
26269@infoline @expr{v1} 26262@infoline @expr{v1}
26270is used as a function name, then 26263is used as a function name, then
26271@texline @tmath{x_1} 26264@texline @math{x_1}
26272@infoline @expr{x1} 26265@infoline @expr{x1}
26273must be either a function name itself or a @w{@samp{< >}} nameless 26266must be either a function name itself or a @w{@samp{< >}} nameless
26274function; @pxref{Specifying Operators}.) For example, @samp{[g(0) := 0, 26267function; @pxref{Specifying Operators}.) For example, @samp{[g(0) := 0,
@@ -27734,7 +27727,7 @@ in its normal terms, and @kbd{u b} expresses the definition in base
27734units. 27727units.
27735 27728
27736Two units, @code{pi} and @code{fsc} (the fine structure constant, 27729Two units, @code{pi} and @code{fsc} (the fine structure constant,
27737approximately @i{1/137}) are dimensionless. The units simplification 27730approximately @mathit{1/137}) are dimensionless. The units simplification
27738commands simply treat these names as equivalent to their corresponding 27731commands simply treat these names as equivalent to their corresponding
27739values. However you can, for example, use @kbd{u c} to convert a pure 27732values. However you can, for example, use @kbd{u c} to convert a pure
27740number into multiples of the fine structure constant, or @kbd{u b} to 27733number into multiples of the fine structure constant, or @kbd{u b} to
@@ -27951,10 +27944,10 @@ All the arithmetic stores accept the Inverse prefix to reverse the
27951order of the operands. If @expr{v} represents the contents of the 27944order of the operands. If @expr{v} represents the contents of the
27952variable, and @expr{a} is the value drawn from the stack, then regular 27945variable, and @expr{a} is the value drawn from the stack, then regular
27953@w{@kbd{s -}} assigns 27946@w{@kbd{s -}} assigns
27954@texline @tmath{v \coloneq v - a}, 27947@texline @math{v \coloneq v - a},
27955@infoline @expr{v := v - a}, 27948@infoline @expr{v := v - a},
27956but @kbd{I s -} assigns 27949but @kbd{I s -} assigns
27957@texline @tmath{v \coloneq a - v}. 27950@texline @math{v \coloneq a - v}.
27958@infoline @expr{v := a - v}. 27951@infoline @expr{v := a - v}.
27959While @kbd{I s *} might seem pointless, it is 27952While @kbd{I s *} might seem pointless, it is
27960useful if matrix multiplication is involved. Actually, all the 27953useful if matrix multiplication is involved. Actually, all the
@@ -28541,7 +28534,7 @@ the same length); either or both may instead be interval forms. The
28541``z'' value must be a matrix with the same number of rows as elements 28534``z'' value must be a matrix with the same number of rows as elements
28542in ``x'', and the same number of columns as elements in ``y''. The 28535in ``x'', and the same number of columns as elements in ``y''. The
28543result is a surface plot where 28536result is a surface plot where
28544@texline @tmath{z_{ij}} 28537@texline @math{z_{ij}}
28545@infoline @expr{z_ij} 28538@infoline @expr{z_ij}
28546is the height of the point 28539is the height of the point
28547at coordinate @expr{(x_i, y_j)} on the surface. The 3D graph will 28540at coordinate @expr{(x_i, y_j)} on the surface. The 3D graph will
@@ -28652,7 +28645,7 @@ values covered by all the curves ought to be roughly the same if
28652they are to look nice on the same graph.) 28645they are to look nice on the same graph.)
28653 28646
28654For example, to plot 28647For example, to plot
28655@texline @tmath{\sin n x} 28648@texline @math{\sin n x}
28656@infoline @expr{sin(n x)} 28649@infoline @expr{sin(n x)}
28657for integers @expr{n} 28650for integers @expr{n}
28658from 1 to 5, you could use @kbd{v x} to create a vector of integers 28651from 1 to 5, you could use @kbd{v x} to create a vector of integers
@@ -28903,7 +28896,7 @@ values, but if you store a vector of integers in one of these variables,
28903the @kbd{g a} and @kbd{g f} commands will use those style numbers 28896the @kbd{g a} and @kbd{g f} commands will use those style numbers
28904instead of the defaults for new curves that are added to the graph. 28897instead of the defaults for new curves that are added to the graph.
28905An entry should be a positive integer for a specific style, or 0 to let 28898An entry should be a positive integer for a specific style, or 0 to let
28906the style be chosen automatically, or @i{-1} to turn off lines or points 28899the style be chosen automatically, or @mathit{-1} to turn off lines or points
28907altogether. If there are more curves than elements in the vector, the 28900altogether. If there are more curves than elements in the vector, the
28908last few curves will continue to have the default styles. Of course, 28901last few curves will continue to have the default styles. Of course,
28909you can later use @kbd{g s} and @kbd{g S} to change any of these styles. 28902you can later use @kbd{g s} and @kbd{g S} to change any of these styles.
@@ -28942,7 +28935,7 @@ picture of the graph composed of characters like @code{-} and @code{|}
28942to a buffer called @samp{*Gnuplot Trail*}, which Calc then displays. 28935to a buffer called @samp{*Gnuplot Trail*}, which Calc then displays.
28943The graph is made the same size as the Emacs screen, which on most 28936The graph is made the same size as the Emacs screen, which on most
28944dumb terminals will be 28937dumb terminals will be
28945@texline @tmath{80\times24} 28938@texline @math{80\times24}
28946@infoline 80x24 28939@infoline 80x24
28947characters. The graph is displayed in 28940characters. The graph is displayed in
28948an Emacs ``recursive edit''; type @kbd{q} or @kbd{M-# M-#} to exit 28941an Emacs ``recursive edit''; type @kbd{q} or @kbd{M-# M-#} to exit
@@ -29252,7 +29245,7 @@ would correctly split the line into two error forms.
29252 29245
29253@xref{Matrix Functions}, to see how to pull the matrix apart into its 29246@xref{Matrix Functions}, to see how to pull the matrix apart into its
29254constituent rows and columns. (If it is a 29247constituent rows and columns. (If it is a
29255@texline @tmath{1\times1} 29248@texline @math{1\times1}
29256@infoline 1x1 29249@infoline 1x1
29257matrix, just hit @kbd{v u} (@code{calc-unpack}) twice.) 29250matrix, just hit @kbd{v u} (@code{calc-unpack}) twice.)
29258 29251
@@ -29590,7 +29583,7 @@ same limit as last time.
29590@key{INV GCD} computes the LCM (least common multiple) function. 29583@key{INV GCD} computes the LCM (least common multiple) function.
29591 29584
29592@key{INV FACT} is the gamma function. 29585@key{INV FACT} is the gamma function.
29593@texline @tmath{\Gamma(x) = (x-1)!}. 29586@texline @math{\Gamma(x) = (x-1)!}.
29594@infoline @expr{gamma(x) = (x-1)!}. 29587@infoline @expr{gamma(x) = (x-1)!}.
29595 29588
29596@key{PERM} is the number-of-permutations function, which is on the 29589@key{PERM} is the number-of-permutations function, which is on the
@@ -31018,7 +31011,7 @@ forced to use upward-counting conventions. In this case, if @var{initial}
31018is greater than @var{final} the body will not be executed at all. 31011is greater than @var{final} the body will not be executed at all.
31019Note that @var{step} may still be negative in this loop; the prefix 31012Note that @var{step} may still be negative in this loop; the prefix
31020argument merely constrains the loop-finished test. Likewise, a prefix 31013argument merely constrains the loop-finished test. Likewise, a prefix
31021argument of @i{-1} forces downward-counting conventions. 31014argument of @mathit{-1} forces downward-counting conventions.
31022 31015
31023@kindex Z @{ 31016@kindex Z @{
31024@kindex Z @} 31017@kindex Z @}
@@ -31989,7 +31982,7 @@ same thing with a single division by 512.
31989@tindex mysin 31982@tindex mysin
31990A somewhat limited sine function could be defined as follows, using the 31983A somewhat limited sine function could be defined as follows, using the
31991well-known Taylor series expansion for 31984well-known Taylor series expansion for
31992@texline @tmath{\sin x}: 31985@texline @math{\sin x}:
31993@infoline @samp{sin(x)}: 31986@infoline @samp{sin(x)}:
31994 31987
31995@smallexample 31988@smallexample
@@ -32512,10 +32505,10 @@ which is not a Lisp list.
32512Large integers are stored as lists of the form @samp{(bigpos @var{d0} 32505Large integers are stored as lists of the form @samp{(bigpos @var{d0}
32513@var{d1} @var{d2} @dots{})} for positive integers 1000000 or more, or 32506@var{d1} @var{d2} @dots{})} for positive integers 1000000 or more, or
32514@samp{(bigneg @var{d0} @var{d1} @var{d2} @dots{})} for negative integers 32507@samp{(bigneg @var{d0} @var{d1} @var{d2} @dots{})} for negative integers
32515@i{-1000000} or less. Each @var{d} is a base-1000 ``digit,'' a Lisp integer 32508@mathit{-1000000} or less. Each @var{d} is a base-1000 ``digit,'' a Lisp integer
32516from 0 to 999. The least significant digit is @var{d0}; the last digit, 32509from 0 to 999. The least significant digit is @var{d0}; the last digit,
32517@var{dn}, which is always nonzero, is the most significant digit. For 32510@var{dn}, which is always nonzero, is the most significant digit. For
32518example, the integer @i{-12345678} is stored as @samp{(bigneg 678 345 12)}. 32511example, the integer @mathit{-12345678} is stored as @samp{(bigneg 678 345 12)}.
32519 32512
32520The distinction between small and large integers is entirely hidden from 32513The distinction between small and large integers is entirely hidden from
32521the user. In @code{defmath} definitions, the Lisp predicate @code{integerp} 32514the user. In @code{defmath} definitions, the Lisp predicate @code{integerp}
@@ -32536,7 +32529,7 @@ Floating-point numbers are stored in the form, @samp{(float @var{mant}
32536@samp{10^@var{p}} in absolute value (@var{p} represents the current 32529@samp{10^@var{p}} in absolute value (@var{p} represents the current
32537precision), and @var{exp} (the ``exponent'') is a fixnum. The value of 32530precision), and @var{exp} (the ``exponent'') is a fixnum. The value of
32538the float is @samp{@var{mant} * 10^@var{exp}}. For example, the number 32531the float is @samp{@var{mant} * 10^@var{exp}}. For example, the number
32539@i{-3.14} is stored as @samp{(float -314 -2) = -314*10^-2}. Other constraints 32532@mathit{-3.14} is stored as @samp{(float -314 -2) = -314*10^-2}. Other constraints
32540are that the number 0.0 is always stored as @samp{(float 0 0)}, and, 32533are that the number 0.0 is always stored as @samp{(float 0 0)}, and,
32541except for the 0.0 case, the rightmost base-10 digit of @var{mant} is 32534except for the 0.0 case, the rightmost base-10 digit of @var{mant} is
32542always nonzero. (If the rightmost digit is zero, the number is 32535always nonzero. (If the rightmost digit is zero, the number is
@@ -32848,7 +32841,7 @@ is applied to the top stack element, or, if @var{unary} is not
32848specified, nothing happens. When the argument is two or more, 32841specified, nothing happens. When the argument is two or more,
32849the binary function @var{func} is reduced across the top @var{arg} 32842the binary function @var{func} is reduced across the top @var{arg}
32850stack elements; when the argument is negative, the function is 32843stack elements; when the argument is negative, the function is
32851mapped between the next-to-top @i{-@var{arg}} stack elements and the 32844mapped between the next-to-top @mathit{-@var{arg}} stack elements and the
32852top element. 32845top element.
32853@end defun 32846@end defun
32854 32847
@@ -33267,7 +33260,7 @@ or formula, this calls @code{reject-arg}.
33267@end defun 33260@end defun
33268 33261
33269@defun compare x y 33262@defun compare x y
33270Compare the numbers @var{x} and @var{y}, and return @i{-1} if 33263Compare the numbers @var{x} and @var{y}, and return @mathit{-1} if
33271@samp{(lessp @var{x} @var{y})}, 1 if @samp{(lessp @var{y} @var{x})}, 33264@samp{(lessp @var{x} @var{y})}, 1 if @samp{(lessp @var{y} @var{x})},
332720 if @samp{(math-equal @var{x} @var{y})}, or 2 if the order is 332650 if @samp{(math-equal @var{x} @var{y})}, or 2 if the order is
33273undefined or cannot be determined. 33266undefined or cannot be determined.
@@ -33280,7 +33273,7 @@ considered to have zero digits.
33280@end defun 33273@end defun
33281 33274
33282@defun scale-int x n 33275@defun scale-int x n
33283Shift integer @var{x} left @var{n} decimal digits, or right @i{-@var{n}} 33276Shift integer @var{x} left @var{n} decimal digits, or right @mathit{-@var{n}}
33284digits with truncation toward zero. 33277digits with truncation toward zero.
33285@end defun 33278@end defun
33286 33279
@@ -33488,7 +33481,7 @@ function @code{frac}, and can be rather slow.
33488@defun quarter-integer n 33481@defun quarter-integer n
33489If @var{n} is an integer or integer-valued float, this function 33482If @var{n} is an integer or integer-valued float, this function
33490returns zero. If @var{n} is a half-integer (i.e., an integer plus 33483returns zero. If @var{n} is a half-integer (i.e., an integer plus
33491@i{1:2} or 0.5), it returns 2. If @var{n} is a quarter-integer, 33484@mathit{1:2} or 0.5), it returns 2. If @var{n} is a quarter-integer,
33492it returns 1 or 3. If @var{n} is anything else, this function 33485it returns 1 or 3. If @var{n} is anything else, this function
33493returns @code{nil}. 33486returns @code{nil}.
33494@end defun 33487@end defun
@@ -35631,8 +35624,8 @@ input data set. Each entry may be a single value or a vector of values.
35631@c 20 35624@c 20
35632@item 35625@item
35633With a prefix argument of 1, take a single 35626With a prefix argument of 1, take a single
35634@texline @tmath{@var{n}\times2} 35627@texline @var{n}@math{\times2}
35635@infoline @i{@var{N}x2} 35628@infoline @mathit{@var{N}x2}
35636matrix from the stack instead of two separate data vectors. 35629matrix from the stack instead of two separate data vectors.
35637 35630
35638@c 21 35631@c 21
@@ -35834,7 +35827,7 @@ to evaluate variables.
35834The variable is replaced by the formula shown on the right. The 35827The variable is replaced by the formula shown on the right. The
35835Inverse flag reverses the order of the operands, e.g., @kbd{I s - x} 35828Inverse flag reverses the order of the operands, e.g., @kbd{I s - x}
35836assigns 35829assigns
35837@texline @tmath{x \coloneq a-x}. 35830@texline @math{x \coloneq a-x}.
35838@infoline @expr{x := a-x}. 35831@infoline @expr{x := a-x}.
35839 35832
35840@c 48 35833@c 48
@@ -35842,7 +35835,7 @@ assigns
35842Press @kbd{?} repeatedly to see how to choose a model. Answer the 35835Press @kbd{?} repeatedly to see how to choose a model. Answer the
35843variables prompt with @expr{iv} or @expr{iv;pv} to specify 35836variables prompt with @expr{iv} or @expr{iv;pv} to specify
35844independent and parameter variables. A positive prefix argument 35837independent and parameter variables. A positive prefix argument
35845takes @i{@var{n}+1} vectors from the stack; a zero prefix takes a matrix 35838takes @mathit{@var{n}+1} vectors from the stack; a zero prefix takes a matrix
35846and a vector from the stack. 35839and a vector from the stack.
35847 35840
35848@c 49 35841@c 49