[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/man/calc.texi
From: |
Jay Belanger |
Subject: |
[Emacs-diffs] Changes to emacs/man/calc.texi |
Date: |
Tue, 14 Dec 2004 00:02:31 -0500 |
Index: emacs/man/calc.texi
diff -c emacs/man/calc.texi:1.27 emacs/man/calc.texi:1.28
*** emacs/man/calc.texi:1.27 Wed Dec 8 22:47:37 2004
--- emacs/man/calc.texi Tue Dec 14 04:53:56 2004
***************
*** 13,40 ****
@c @infoline foo
@c `foo' will appear only in non-TeX output
! @c In TeX output, @tmath{expr} will typeset expr in math mode.
! @c In any output, @expr{expr} will typeset an expression;
@c $x$ in TeX, @samp{x} otherwise.
@iftex
@macro texline{stuff}
\stuff\
@end macro
- @macro tmath{stuff}
- @tex
- $\stuff\$
- @end tex
- @end macro
@alias infoline=comment
- @c @alias expr=math
@tex
! \gdef\expr#1{\tex
! \let\t\ttfont
! \turnoffactive
! $#1$
! \endgroup}
@end tex
@macro cpi{}
@address@hidden
@end macro
--- 13,32 ----
@c @infoline foo
@c `foo' will appear only in non-TeX output
! @c @expr{expr} will typeset an expression;
@c $x$ in TeX, @samp{x} otherwise.
@iftex
@macro texline{stuff}
\stuff\
@end macro
@alias infoline=comment
@tex
! \gdef\exprsetup{\tex \let\t\ttfont \turnoffactive}
! \gdef\expr{\exprsetup$\exprfinish}
! \gdef\exprfinish#1{#1$\endgroup}
@end tex
+ @alias mathit=expr
@macro cpi{}
@address@hidden
@end macro
***************
*** 49,54 ****
--- 41,47 ----
\stuff\
@end macro
@alias expr=samp
+ @alias mathit=i
@macro cpi{}
@expr{pi}
@end macro
***************
*** 624,635 ****
@noindent
Type @kbd{2 @key{RET} 3 + Q} to compute
! @texline @tmath{\sqrt{2+3} = 2.2360679775}.
@infoline the square root of 2+3, which is 2.2360679775.
@noindent
Type @kbd{P 2 ^} to compute
! @texline @tmath{\pi^2 = 9.86960440109}.
@infoline the value of `pi' squared, 9.86960440109.
@noindent
--- 617,628 ----
@noindent
Type @kbd{2 @key{RET} 3 + Q} to compute
! @texline @math{\sqrt{2+3} = 2.2360679775}.
@infoline the square root of 2+3, which is 2.2360679775.
@noindent
Type @kbd{P 2 ^} to compute
! @texline @math{\pi^2 = 9.86960440109}.
@infoline the value of `pi' squared, 9.86960440109.
@noindent
***************
*** 648,659 ****
@noindent
Type @kbd{' sqrt(2+3) @key{RET}} to compute
! @texline @tmath{\sqrt{2+3}}.
@infoline the square root of 2+3.
@noindent
Type @kbd{' pi^2 @key{RET}} to enter
! @texline @tmath{\pi^2}.
@infoline `pi' squared.
To evaluate this symbolic formula as a number, type @kbd{=}.
--- 641,652 ----
@noindent
Type @kbd{' sqrt(2+3) @key{RET}} to compute
! @texline @math{\sqrt{2+3}}.
@infoline the square root of 2+3.
@noindent
Type @kbd{' pi^2 @key{RET}} to enter
! @texline @math{\pi^2}.
@infoline `pi' squared.
To evaluate this symbolic formula as a number, type @kbd{=}.
***************
*** 713,722 ****
@noindent
Type @kbd{v t} to transpose this
! @texline @tmath{3\times2}
@infoline 3x2
matrix into a
! @texline @tmath{2\times3}
@infoline 2x3
matrix. Type @address@hidden u}} to unpack the rows into two separate
vectors. Now type @address@hidden R + @key{TAB} V R +}} to compute the sums
--- 706,715 ----
@noindent
Type @kbd{v t} to transpose this
! @texline @math{3\times2}
@infoline 3x2
matrix into a
! @texline @math{2\times3}
@infoline 2x3
matrix. Type @address@hidden u}} to unpack the rows into two separate
vectors. Now type @address@hidden R + @key{TAB} V R +}} to compute the sums
***************
*** 867,875 ****
In this case, the trail shows that four numbers (17.3, 3, 2, and 4)
were first entered into the Calculator, then the 2 and 4 were
! multiplied to get 8, then the 3 and 8 were subtracted to get @i{-5}.
(The @samp{>} symbol shows that this was the most recent calculation.)
! The net result is the two numbers 17.3 and @i{-5} sitting on the stack.
Most Calculator commands deal explicitly with the stack only, but
there is a set of commands that allow you to search back through
--- 860,868 ----
In this case, the trail shows that four numbers (17.3, 3, 2, and 4)
were first entered into the Calculator, then the 2 and 4 were
! multiplied to get 8, then the 3 and 8 were subtracted to get @mathit{-5}.
(The @samp{>} symbol shows that this was the most recent calculation.)
! The net result is the two numbers 17.3 and @mathit{-5} sitting on the stack.
Most Calculator commands deal explicitly with the stack only, but
there is a set of commands that allow you to search back through
***************
*** 930,936 ****
Quick Mode is very simple: It prompts you to type any formula in
standard algebraic notation (like @samp{4 - 2/3}) and then displays
! the result at the bottom of the Emacs screen (@i{3.33333333333}
in this case). You are then back in the same editing buffer you
were in before, ready to continue editing or to type @kbd{M-# q}
again to do another quick calculation. The result of the calculation
--- 923,929 ----
Quick Mode is very simple: It prompts you to type any formula in
standard algebraic notation (like @samp{4 - 2/3}) and then displays
! the result at the bottom of the Emacs screen (@mathit{3.33333333333}
in this case). You are then back in the same editing buffer you
were in before, ready to continue editing or to type @kbd{M-# q}
again to do another quick calculation. The result of the calculation
***************
*** 1343,1349 ****
Calc was originally started as a two-week project to occupy a lull
in the author's schedule. Basically, a friend asked if I remembered
the value of
! @texline @tmath{2^{32}}.
@infoline @expr{2^32}.
I didn't offhand, but I said, ``that's easy, just call up an
@code{xcalc}.'' @code{Xcalc} duly reported that the answer to our
--- 1336,1342 ----
Calc was originally started as a two-week project to occupy a lull
in the author's schedule. Basically, a friend asked if I remembered
the value of
! @texline @math{2^{32}}.
@infoline @expr{2^32}.
I didn't offhand, but I said, ``that's easy, just call up an
@code{xcalc}.'' @code{Xcalc} duly reported that the answer to our
***************
*** 1665,1671 ****
if you're right. @xref{RPN Answer 1, 1}. (@bullet{})
(@bullet{}) @strong{Exercise 2.} Compute
! @texline @tmath{(2\times4) + (7\times9.4) + {5\over4}}
@infoline @expr{2*4 + 7*9.5 + 5/4}
using the stack. @xref{RPN Answer 2, 2}. (@bullet{})
--- 1658,1664 ----
if you're right. @xref{RPN Answer 1, 1}. (@bullet{})
(@bullet{}) @strong{Exercise 2.} Compute
! @texline @math{(2\times4) + (7\times9.4) + {5\over4}}
@infoline @expr{2*4 + 7*9.5 + 5/4}
using the stack. @xref{RPN Answer 2, 2}. (@bullet{})
***************
*** 2000,2006 ****
@end tex
@noindent
! The result of this expression will be the number @i{-6.99999826533}.
Calc's order of evaluation is the same as for most computer languages,
except that @samp{*} binds more strongly than @samp{/}, as the above
--- 1993,1999 ----
@end tex
@noindent
! The result of this expression will be the number @mathit{-6.99999826533}.
Calc's order of evaluation is the same as for most computer languages,
except that @samp{*} binds more strongly than @samp{/}, as the above
***************
*** 2009,2015 ****
Operators at the same level are evaluated from left to right, except
that @samp{^} is evaluated from right to left. Thus, @samp{2-3-4} is
! equivalent to @samp{(2-3)-4} or @i{-5}, whereas @samp{2^3^4} is equivalent
to @samp{2^(3^4)} (a very large integer; try it!).
If you tire of typing the apostrophe all the time, there is an
--- 2002,2008 ----
Operators at the same level are evaluated from left to right, except
that @samp{^} is evaluated from right to left. Thus, @samp{2-3-4} is
! equivalent to @samp{(2-3)-4} or @mathit{-5}, whereas @samp{2^3^4} is
equivalent
to @samp{2^(3^4)} (a very large integer; try it!).
If you tire of typing the apostrophe all the time, there is an
***************
*** 2079,2085 ****
of algebraic entries, using the @kbd{$} sign to tie them together.
In an algebraic formula, @kbd{$} represents the number on the top
of the stack. Here, we perform the calculation
! @texline @tmath{\sqrt{2\times4+1}},
@infoline @expr{sqrt(2*4+1)},
which on a traditional calculator would be done by pressing
@kbd{2 * 4 + 1 =} and then the square-root key.
--- 2072,2078 ----
of algebraic entries, using the @kbd{$} sign to tie them together.
In an algebraic formula, @kbd{$} represents the number on the top
of the stack. Here, we perform the calculation
! @texline @math{\sqrt{2\times4+1}},
@infoline @expr{sqrt(2*4+1)},
which on a traditional calculator would be done by pressing
@kbd{2 * 4 + 1 =} and then the square-root key.
***************
*** 2741,2751 ****
@noindent
The address@hidden command computes the sine of an angle. The sine
of 45 degrees is
! @texline @tmath{\sqrt{2}/2};
@infoline @expr{sqrt(2)/2};
squaring this yields @expr{2/4 = 0.5}. However, there has been a slight
roundoff error because the representation of
! @texline @tmath{\sqrt{2}/2}
@infoline @expr{sqrt(2)/2}
wasn't exact. The @kbd{c 1} command is a handy way to clean up numbers
in this case; it temporarily reduces the precision by one digit while it
--- 2734,2744 ----
@noindent
The address@hidden command computes the sine of an angle. The sine
of 45 degrees is
! @texline @math{\sqrt{2}/2};
@infoline @expr{sqrt(2)/2};
squaring this yields @expr{2/4 = 0.5}. However, there has been a slight
roundoff error because the representation of
! @texline @math{\sqrt{2}/2}
@infoline @expr{sqrt(2)/2}
wasn't exact. The @kbd{c 1} command is a handy way to clean up numbers
in this case; it temporarily reduces the precision by one digit while it
***************
*** 2786,2792 ****
@noindent
Here we compute the Inverse Sine of
! @texline @tmath{\sqrt{0.5}},
@infoline @expr{sqrt(0.5)},
first in radians, then in degrees.
--- 2779,2785 ----
@noindent
Here we compute the Inverse Sine of
! @texline @math{\sqrt{0.5}},
@infoline @expr{sqrt(0.5)},
first in radians, then in degrees.
***************
*** 2974,2982 ****
Let's compute the sine and cosine of an angle, and verify the
identity
! @texline @tmath{\sin^2x + \cos^2x = 1}.
@infoline @expr{sin(x)^2 + cos(x)^2 = 1}.
! We'll arbitrarily pick @i{-64} degrees as a good value for @expr{x}.
With the angular mode set to degrees (type @address@hidden d}}), do:
@smallexample
--- 2967,2975 ----
Let's compute the sine and cosine of an angle, and verify the
identity
! @texline @math{\sin^2x + \cos^2x = 1}.
@infoline @expr{sin(x)^2 + cos(x)^2 = 1}.
! We'll arbitrarily pick @mathit{-64} degrees as a good value for @expr{x}.
With the angular mode set to degrees (type @address@hidden d}}), do:
@smallexample
***************
*** 2997,3003 ****
of squares, command.
Another identity is
! @texline @tmath{\displaystyle\tan x = {\sin x \over \cos x}}.
@infoline @expr{tan(x) = sin(x) / cos(x)}.
@smallexample
@group
--- 2990,2996 ----
of squares, command.
Another identity is
! @texline @math{\displaystyle\tan x = {\sin x \over \cos x}}.
@infoline @expr{tan(x) = sin(x) / cos(x)}.
@smallexample
@group
***************
*** 3012,3018 ****
A physical interpretation of this calculation is that if you move
@expr{0.89879} units downward and @expr{0.43837} units to the right,
! your direction of motion is @i{-64} degrees from horizontal. Suppose
we move in the opposite direction, up and to the left:
@smallexample
--- 3005,3011 ----
A physical interpretation of this calculation is that if you move
@expr{0.89879} units downward and @expr{0.43837} units to the right,
! your direction of motion is @mathit{-64} degrees from horizontal. Suppose
we move in the opposite direction, up and to the left:
@smallexample
***************
*** 3060,3066 ****
A similar identity is supposed to hold for hyperbolic sines and cosines,
except that it is the @emph{difference}
! @texline @tmath{\cosh^2x - \sinh^2x}
@infoline @expr{cosh(x)^2 - sinh(x)^2}
that always equals one. Let's try to verify this identity.
--- 3053,3059 ----
A similar identity is supposed to hold for hyperbolic sines and cosines,
except that it is the @emph{difference}
! @texline @math{\cosh^2x - \sinh^2x}
@infoline @expr{cosh(x)^2 - sinh(x)^2}
that always equals one. Let's try to verify this identity.
***************
*** 3167,3173 ****
If you take the factorial of a non-integer, Calc uses a generalized
factorial function defined in terms of Euler's Gamma function
! @texline @tmath{\Gamma(n)}
@infoline @expr{gamma(n)}
(which is itself available as the @kbd{f g} command).
--- 3160,3166 ----
If you take the factorial of a non-integer, Calc uses a generalized
factorial function defined in terms of Euler's Gamma function
! @texline @math{\Gamma(n)}
@infoline @expr{gamma(n)}
(which is itself available as the @kbd{f g} command).
***************
*** 3184,3196 ****
@noindent
Here we verify the identity
! @texline @tmath{n! = \Gamma(n+1)}.
@infoline @address@hidden@: = gamma(@var{n}+1)}.
The binomial coefficient @address@hidden
! @texline or @tmath{\displaystyle {n \choose m}}
is defined by
! @texline @tmath{\displaystyle {n! \over m! \, (n-m)!}}
@infoline @expr{n!@: / m!@: (n-m)!}
for all reals @expr{n} and @expr{m}. The intermediate results in this
formula can become quite large even if the final result is small; the
--- 3177,3189 ----
@noindent
Here we verify the identity
! @texline @math{n! = \Gamma(n+1)}.
@infoline @address@hidden@: = gamma(@var{n}+1)}.
The binomial coefficient @address@hidden
! @texline or @math{\displaystyle {n \choose m}}
is defined by
! @texline @math{\displaystyle {n! \over m! \, (n-m)!}}
@infoline @expr{n!@: / m!@: (n-m)!}
for all reals @expr{n} and @expr{m}. The intermediate results in this
formula can become quite large even if the final result is small; the
***************
*** 3475,3481 ****
(@bullet{}) @strong{Exercise 1.} Use @samp{*} to sum along the rows
of the above
! @texline @tmath{2\times3}
@infoline 2x3
matrix to get @expr{[6, 15]}. Now use @samp{*} to sum along the columns
to get @expr{[5, 7, 9]}.
--- 3468,3474 ----
(@bullet{}) @strong{Exercise 1.} Use @samp{*} to sum along the rows
of the above
! @texline @math{2\times3}
@infoline 2x3
matrix to get @expr{[6, 15]}. Now use @samp{*} to sum along the columns
to get @expr{[5, 7, 9]}.
***************
*** 3626,3635 ****
come out right, and the answer would be incorrect. If you
don't feel safe letting Calc take either interpretation of your
vectors, use explicit
! @texline @tmath{N\times1}
@infoline Nx1
or
! @texline @tmath{1\times N}
@infoline 1xN
matrices instead. In this case, you would enter the original column
vector as @samp{[[6], [2], [3]]} or @samp{[6; 2; 3]}.
--- 3619,3628 ----
come out right, and the answer would be incorrect. If you
don't feel safe letting Calc take either interpretation of your
vectors, use explicit
! @texline @math{N\times1}
@infoline Nx1
or
! @texline @math{1\times N}
@infoline 1xN
matrices instead. In this case, you would enter the original column
vector as @samp{[[6], [2], [3]]} or @samp{[6; 2; 3]}.
***************
*** 3678,3684 ****
$A^T A \, X = A^T B$, where $A^T$ is the transpose \samp{trn(A)}.
@end tex
Now
! @texline @tmath{A^T A}
@infoline @expr{trn(A)*A}
is a square matrix so a solution is possible. It turns out that the
@expr{X} vector you compute in this way will be a ``least-squares''
--- 3671,3677 ----
$A^T A \, X = A^T B$, where $A^T$ is the transpose \samp{trn(A)}.
@end tex
Now
! @texline @math{A^T A}
@infoline @expr{trn(A)*A}
is a square matrix so a solution is possible. It turns out that the
@expr{X} vector you compute in this way will be a ``least-squares''
***************
*** 3774,3780 ****
(@bullet{}) @strong{Exercise 1.} Compute a vector of powers of two
from
! @texline @tmath{2^{-4}}
@infoline @expr{2^-4}
to @expr{2^4}. @xref{List Answer 1, 1}. (@bullet{})
--- 3767,3773 ----
(@bullet{}) @strong{Exercise 1.} Compute a vector of powers of two
from
! @texline @math{2^{-4}}
@infoline @expr{2^-4}
to @expr{2^4}. @xref{List Answer 1, 1}. (@bullet{})
***************
*** 3978,3984 ****
@noindent
where
! @texline @tmath{\sum x}
@infoline @expr{sum(x)}
represents the sum of all the values of @expr{x}. While there is an
actual @code{sum} function in Calc, it's easier to sum a vector using a
--- 3971,3977 ----
@noindent
where
! @texline @math{\sum x}
@infoline @expr{sum(x)}
represents the sum of all the values of @expr{x}. While there is an
actual @code{sum} function in Calc, it's easier to sum a vector using a
***************
*** 4083,4089 ****
@end smallexample
Let's ``plot'' this straight line approximation,
! @texline @tmath{y \approx m x + b},
@infoline @expr{m x + b},
and compare it with the original data.
--- 4076,4082 ----
@end smallexample
Let's ``plot'' this straight line approximation,
! @texline @math{y \approx m x + b},
@infoline @expr{m x + b},
and compare it with the original data.
***************
*** 4336,4342 ****
@cindex Maximizing a function over a list of values
@c [fix-ref Numerical Solutions]
(@bullet{}) @strong{Exercise 8.} Compute a list of values of Bessel's
! @texline @tmath{J_1(x)}
@infoline @expr{J1}
function @samp{besJ(1,x)} for @expr{x} from 0 to 5 in steps of 0.25.
Find the value of @expr{x} (from among the above set of values) for
--- 4329,4335 ----
@cindex Maximizing a function over a list of values
@c [fix-ref Numerical Solutions]
(@bullet{}) @strong{Exercise 8.} Compute a list of values of Bessel's
! @texline @math{J_1(x)}
@infoline @expr{J1}
function @samp{besJ(1,x)} for @expr{x} from 0 to 5 in steps of 0.25.
Find the value of @expr{x} (from among the above set of values) for
***************
*** 4348,4354 ****
@cindex Digits, vectors of
(@bullet{}) @strong{Exercise 9.} You are given an integer in the range
! @texline @tmath{0 \le N < 10^m}
@infoline @expr{0 <= N < 10^m}
for @expr{m=12} (i.e., an integer of less than
twelve digits). Convert this integer into a vector of @expr{m}
--- 4341,4347 ----
@cindex Digits, vectors of
(@bullet{}) @strong{Exercise 9.} You are given an integer in the range
! @texline @math{0 \le N < 10^m}
@infoline @expr{0 <= N < 10^m}
for @expr{m=12} (i.e., an integer of less than
twelve digits). Convert this integer into a vector of @expr{m}
***************
*** 4364,4377 ****
(@bullet{}) @strong{Exercise 11.} The area of a circle of radius one
is @cpi{}. The area of the
! @texline @tmath{2\times2}
@infoline 2x2
square that encloses that circle is 4. So if we throw @var{n} darts at
random points in the square, about @cpiover{4} of them will land inside
the circle. This gives us an entertaining way to estimate the value of
@cpi{}. The @address@hidden r}}
command picks a random number between zero and the value on the stack.
! We could get a random floating-point number between @i{-1} and 1 by typing
@address@hidden k r 1 -}}. Build a vector of 100 random @expr{(x,y)} points
in
this square, then use vector mapping and reduction to count how many
points lie inside the unit circle. Hint: Use the @kbd{v b} command.
--- 4357,4370 ----
(@bullet{}) @strong{Exercise 11.} The area of a circle of radius one
is @cpi{}. The area of the
! @texline @math{2\times2}
@infoline 2x2
square that encloses that circle is 4. So if we throw @var{n} darts at
random points in the square, about @cpiover{4} of them will land inside
the circle. This gives us an entertaining way to estimate the value of
@cpi{}. The @address@hidden r}}
command picks a random number between zero and the value on the stack.
! We could get a random floating-point number between @mathit{-1} and 1 by
typing
@address@hidden k r 1 -}}. Build a vector of 100 random @expr{(x,y)} points
in
this square, then use vector mapping and reduction to count how many
points lie inside the unit circle. Hint: Use the @kbd{v b} command.
***************
*** 4383,4394 ****
of vertical lines with a spacing of one inch. Toss a one-inch matchstick
onto the field. The probability that the matchstick will land crossing
a line turns out to be
! @texline @tmath{2/\pi}.
@infoline @expr{2/pi}.
Toss 100 matchsticks to estimate @cpi{}. (If you want still more fun,
the probability that the GCD (@address@hidden g}}) of two large integers is
one turns out to be
! @texline @tmath{6/\pi^2}.
@infoline @expr{6/pi^2}.
That provides yet another way to estimate @cpi{}.)
@xref{List Answer 12, 12}. (@bullet{})
--- 4376,4387 ----
of vertical lines with a spacing of one inch. Toss a one-inch matchstick
onto the field. The probability that the matchstick will land crossing
a line turns out to be
! @texline @math{2/\pi}.
@infoline @expr{2/pi}.
Toss 100 matchsticks to estimate @cpi{}. (If you want still more fun,
the probability that the GCD (@address@hidden g}}) of two large integers is
one turns out to be
! @texline @math{6/\pi^2}.
@infoline @expr{6/pi^2}.
That provides yet another way to estimate @cpi{}.)
@xref{List Answer 12, 12}. (@bullet{})
***************
*** 4418,4424 ****
function you give to the starting value 0, 1, 2, up to @var{n} times
and returns a vector of the results. Use this command to create a
``random walk'' of 50 steps. Start with the two-dimensional point
! @expr{(0,0)}; then take one step a random distance between @i{-1} and 1
in both @expr{x} and @expr{y}; then take another step, and so on. Use the
@kbd{g f} command to display this random walk. Now modify your random
walk to walk a unit distance, but in a random direction, at each step.
--- 4411,4417 ----
function you give to the starting value 0, 1, 2, up to @var{n} times
and returns a vector of the results. Use this command to create a
``random walk'' of 50 steps. Start with the two-dimensional point
! @expr{(0,0)}; then take one step a random distance between @mathit{-1} and 1
in both @expr{x} and @expr{y}; then take another step, and so on. Use the
@kbd{g f} command to display this random walk. Now modify your random
walk to walk a unit distance, but in a random direction, at each step.
***************
*** 4497,4503 ****
@end smallexample
@noindent
! The square root of @i{-9} is by default rendered in rectangular form
(@address@hidden + 3i}}), but we can convert it to polar form (3 with a
phase angle of 90 degrees). All the usual arithmetic and scientific
operations are defined on both types of complex numbers.
--- 4490,4496 ----
@end smallexample
@noindent
! The square root of @mathit{-9} is by default rendered in rectangular form
(@address@hidden + 3i}}), but we can convert it to polar form (3 with a
phase angle of 90 degrees). All the usual arithmetic and scientific
operations are defined on both types of complex numbers.
***************
*** 4522,4535 ****
@noindent
Since infinity is infinitely large, multiplying it by any finite
! number (like @i{-17}) has no effect, except that since @i{-17}
is negative, it changes a plus infinity to a minus infinity.
! (``A huge positive number, multiplied by @i{-17}, yields a huge
negative number.'') Adding any finite number to infinity also
leaves it unchanged. Taking an absolute value gives us plus
infinity again. Finally, we add this plus infinity to the minus
infinity we had earlier. If you work it out, you might expect
! the answer to be @i{-72} for this. But the 72 has been completely
lost next to the infinities; by the time we compute @address@hidden - inf}}
the finite difference between them, if any, is undetectable.
So we say the result is @dfn{indeterminate}, which Calc writes
--- 4515,4528 ----
@noindent
Since infinity is infinitely large, multiplying it by any finite
! number (like @mathit{-17}) has no effect, except that since @mathit{-17}
is negative, it changes a plus infinity to a minus infinity.
! (``A huge positive number, multiplied by @mathit{-17}, yields a huge
negative number.'') Adding any finite number to infinity also
leaves it unchanged. Taking an absolute value gives us plus
infinity again. Finally, we add this plus infinity to the minus
infinity we had earlier. If you work it out, you might expect
! the answer to be @mathit{-72} for this. But the 72 has been completely
lost next to the infinities; by the time we compute @address@hidden - inf}}
the finite difference between them, if any, is undetectable.
So we say the result is @dfn{indeterminate}, which Calc writes
***************
*** 4686,4692 ****
@cindex Torus, volume of
(@bullet{}) @strong{Exercise 7.} The volume of a torus (a donut shape) is
! @texline @tmath{2 \pi^2 R r^2}
@infoline @address@hidden pi^2 R r^2}}
where @expr{R} is the radius of the circle that
defines the center of the tube and @expr{r} is the radius of the tube
--- 4679,4685 ----
@cindex Torus, volume of
(@bullet{}) @strong{Exercise 7.} The volume of a torus (a donut shape) is
! @texline @math{2 \pi^2 R r^2}
@infoline @address@hidden pi^2 R r^2}}
where @expr{R} is the radius of the circle that
defines the center of the tube and @expr{r} is the radius of the tube
***************
*** 4786,4792 ****
@cindex Fermat, primality test of
(@bullet{}) @strong{Exercise 10.} A theorem of Pierre de Fermat
says that
! @texline @address@hidden \bmod n = 1}}
@infoline @expr{x^(n-1) mod n = 1}
if @expr{n} is a prime number and @expr{x} is an integer less than
@expr{n}. If @expr{n} is @emph{not} a prime number, this will
--- 4779,4785 ----
@cindex Fermat, primality test of
(@bullet{}) @strong{Exercise 10.} A theorem of Pierre de Fermat
says that
! @texline @address@hidden \bmod n = 1}}
@infoline @expr{x^(n-1) mod n = 1}
if @expr{n} is a prime number and @expr{x} is an integer less than
@expr{n}. If @expr{n} is @emph{not} a prime number, this will
***************
*** 4814,4820 ****
(@bullet{}) @strong{Exercise 11.} A rule of thumb is that one year
is about
! @texline @tmath{\pi \times 10^7}
@infoline @address@hidden * 10^7}}
seconds. What time will it be that many seconds from right now?
@xref{Types Answer 11, 11}. (@bullet{})
--- 4807,4813 ----
(@bullet{}) @strong{Exercise 11.} A rule of thumb is that one year
is about
! @texline @math{\pi \times 10^7}
@infoline @address@hidden * 10^7}}
seconds. What time will it be that many seconds from right now?
@xref{Types Answer 11, 11}. (@bullet{})
***************
*** 5121,5127 ****
@noindent
Calc has invented the variable @samp{s1} to represent an unknown sign;
! it is supposed to be either @i{+1} or @i{-1}. Here we have used
the ``let'' command to evaluate the expression when the sign is negative.
If we plugged this into our second derivative we would get the same,
negative, answer, so @expr{x = -1.19023} is also a maximum.
--- 5114,5120 ----
@noindent
Calc has invented the variable @samp{s1} to represent an unknown sign;
! it is supposed to be either @mathit{+1} or @mathit{-1}. Here we have used
the ``let'' command to evaluate the expression when the sign is negative.
If we plugged this into our second derivative we would get the same,
negative, answer, so @expr{x = -1.19023} is also a maximum.
***************
*** 5291,5297 ****
(@bullet{}) @strong{Exercise 3.} Find the integral from 1 to @expr{y}
of
! @texline @tmath{x \sin \pi x}
@infoline @address@hidden sin(pi x)}}
(where the sine is calculated in radians). Find the values of the
integral for integers @expr{y} from 1 to 5. @xref{Algebra Answer 3,
--- 5284,5290 ----
(@bullet{}) @strong{Exercise 3.} Find the integral from 1 to @expr{y}
of
! @texline @math{x \sin \pi x}
@infoline @address@hidden sin(pi x)}}
(where the sine is calculated in radians). Find the values of the
integral for integers @expr{y} from 1 to 5. @xref{Algebra Answer 3,
***************
*** 5300,5306 ****
Calc's integrator can do many simple integrals symbolically, but many
others are beyond its capabilities. Suppose we wish to find the area
under the curve
! @texline @tmath{\sin x \ln x}
@infoline @expr{sin(x) ln(x)}
over the same range of @expr{x}. If you entered this formula and typed
@kbd{a i x @key{RET}} (don't bother to try this), Calc would work for a
--- 5293,5299 ----
Calc's integrator can do many simple integrals symbolically, but many
others are beyond its capabilities. Suppose we wish to find the area
under the curve
! @texline @math{\sin x \ln x}
@infoline @expr{sin(x) ln(x)}
over the same range of @expr{x}. If you entered this formula and typed
@kbd{a i x @key{RET}} (don't bother to try this), Calc would work for a
***************
*** 5442,5448 ****
@end tex
Compute the integral from 1 to 2 of
! @texline @tmath{\sin x \ln x}
@infoline @expr{sin(x) ln(x)}
using Simpson's rule with 10 slices.
@xref{Algebra Answer 4, 4}. (@bullet{})
--- 5435,5441 ----
@end tex
Compute the integral from 1 to 2 of
! @texline @math{\sin x \ln x}
@infoline @expr{sin(x) ln(x)}
using Simpson's rule with 10 slices.
@xref{Algebra Answer 4, 4}. (@bullet{})
***************
*** 5988,5994 ****
@end ignore
@tindex Si
(@bullet{}) @strong{Exercise 1.} The ``sine integral'' function
! @texline @tmath{{\rm Si}(x)}
@infoline @expr{Si(x)}
is defined as the integral of @samp{sin(t)/t} for
@expr{t = 0} to @expr{x} in radians. (It was invented because this
--- 5981,5987 ----
@end ignore
@tindex Si
(@bullet{}) @strong{Exercise 1.} The ``sine integral'' function
! @texline @math{{\rm Si}(x)}
@infoline @expr{Si(x)}
is defined as the integral of @samp{sin(t)/t} for
@expr{t = 0} to @expr{x} in radians. (It was invented because this
***************
*** 6066,6072 ****
@enumerate
@item
Compute
! @texline @tmath{\displaystyle{\sin x \over x}},
@infoline @expr{sin(x) / x},
where @expr{x} is the number on the top of the stack.
--- 6059,6065 ----
@enumerate
@item
Compute
! @texline @math{\displaystyle{\sin x \over x}},
@infoline @expr{sin(x) / x},
where @expr{x} is the number on the top of the stack.
***************
*** 6132,6144 ****
@cindex Phi, golden ratio
A fascinating property of the Fibonacci numbers is that the @expr{n}th
Fibonacci number can be found directly by computing
! @texline @tmath{\phi^n / \sqrt{5}}
@infoline @expr{phi^n / sqrt(5)}
and then rounding to the nearest integer, where
! @texline @tmath{\phi} (``phi''),
@infoline @expr{phi},
the ``golden ratio,'' is
! @texline @tmath{(1 + \sqrt{5}) / 2}.
@infoline @expr{(1 + sqrt(5)) / 2}.
(For convenience, this constant is available from the @code{phi}
variable, or the @kbd{I H P} command.)
--- 6125,6137 ----
@cindex Phi, golden ratio
A fascinating property of the Fibonacci numbers is that the @expr{n}th
Fibonacci number can be found directly by computing
! @texline @math{\phi^n / \sqrt{5}}
@infoline @expr{phi^n / sqrt(5)}
and then rounding to the nearest integer, where
! @texline @math{\phi} (``phi''),
@infoline @expr{phi},
the ``golden ratio,'' is
! @texline @math{(1 + \sqrt{5}) / 2}.
@infoline @expr{(1 + sqrt(5)) / 2}.
(For convenience, this constant is available from the @code{phi}
variable, or the @kbd{I H P} command.)
***************
*** 6155,6171 ****
@cindex Continued fractions
(@bullet{}) @strong{Exercise 5.} The @dfn{continued fraction}
representation of
! @texline @tmath{\phi}
@infoline @expr{phi}
is
! @texline @tmath{1 + 1/(1 + 1/(1 + 1/( \ldots )))}.
@infoline @expr{1 + 1/(1 + 1/(1 + 1/( ...@: )))}.
We can compute an approximate value by carrying this however far
and then replacing the innermost
! @texline @tmath{1/( \ldots )}
@infoline @expr{1/( ...@: )}
by 1. Approximate
! @texline @tmath{\phi}
@infoline @expr{phi}
using a twenty-term continued fraction.
@xref{Programming Answer 5, 5}. (@bullet{})
--- 6148,6164 ----
@cindex Continued fractions
(@bullet{}) @strong{Exercise 5.} The @dfn{continued fraction}
representation of
! @texline @math{\phi}
@infoline @expr{phi}
is
! @texline @math{1 + 1/(1 + 1/(1 + 1/( \ldots )))}.
@infoline @expr{1 + 1/(1 + 1/(1 + 1/( ...@: )))}.
We can compute an approximate value by carrying this however far
and then replacing the innermost
! @texline @math{1/( \ldots )}
@infoline @expr{1/( ...@: )}
by 1. Approximate
! @texline @math{\phi}
@infoline @expr{phi}
using a twenty-term continued fraction.
@xref{Programming Answer 5, 5}. (@bullet{})
***************
*** 6265,6271 ****
property that all of the odd Bernoulli numbers are zero, and the
even ones, while difficult to compute, can be roughly approximated
by the formula
! @texline @tmath{\displaystyle{2 n! \over (2 \pi)^n}}.
@infoline @expr{2 n!@: / (2 pi)^n}.
Let's write a keyboard macro to compute (approximate) Bernoulli numbers.
(Calc has a command, @kbd{k b}, to compute exact Bernoulli numbers, but
--- 6258,6264 ----
property that all of the odd Bernoulli numbers are zero, and the
even ones, while difficult to compute, can be roughly approximated
by the formula
! @texline @math{\displaystyle{2 n! \over (2 \pi)^n}}.
@infoline @expr{2 n!@: / (2 pi)^n}.
Let's write a keyboard macro to compute (approximate) Bernoulli numbers.
(Calc has a command, @kbd{k b}, to compute exact Bernoulli numbers, but
***************
*** 6439,6452 ****
@noindent
where @expr{f'(x)} is the derivative of @expr{f}. The @expr{x}
values will quickly converge to a solution, i.e., eventually
! @texline @tmath{x_{\rm new}}
@infoline @expr{new_x}
and @expr{x} will be equal to within the limits
of the current precision. Write a program which takes a formula
involving the variable @expr{x}, and an initial guess @expr{x_0},
on the stack, and produces a value of @expr{x} for which the formula
is zero. Use it to find a solution of
! @texline @tmath{\sin(\cos x) = 0.5}
@infoline @expr{sin(cos(x)) = 0.5}
near @expr{x = 4.5}. (Use angles measured in radians.) Note that
the built-in @address@hidden R}} (@code{calc-find-root}) command uses Newton's
--- 6432,6445 ----
@noindent
where @expr{f'(x)} is the derivative of @expr{f}. The @expr{x}
values will quickly converge to a solution, i.e., eventually
! @texline @math{x_{\rm new}}
@infoline @expr{new_x}
and @expr{x} will be equal to within the limits
of the current precision. Write a program which takes a formula
involving the variable @expr{x}, and an initial guess @expr{x_0},
on the stack, and produces a value of @expr{x} for which the formula
is zero. Use it to find a solution of
! @texline @math{\sin(\cos x) = 0.5}
@infoline @expr{sin(cos(x)) = 0.5}
near @expr{x = 4.5}. (Use angles measured in radians.) Note that
the built-in @address@hidden R}} (@code{calc-find-root}) command uses Newton's
***************
*** 6456,6465 ****
@cindex Gamma constant, Euler's
@cindex Euler's gamma constant
(@bullet{}) @strong{Exercise 9.} The @dfn{digamma} function
! @texline @tmath{\psi(z) (``psi'')}
@infoline @expr{psi(z)}
is defined as the derivative of
! @texline @tmath{\ln \Gamma(z)}.
@infoline @expr{ln(gamma(z))}.
For large values of @expr{z}, it can be approximated by the infinite sum
--- 6449,6458 ----
@cindex Gamma constant, Euler's
@cindex Euler's gamma constant
(@bullet{}) @strong{Exercise 9.} The @dfn{digamma} function
! @texline @math{\psi(z) (``psi'')}
@infoline @expr{psi(z)}
is defined as the derivative of
! @texline @math{\ln \Gamma(z)}.
@infoline @expr{ln(gamma(z))}.
For large values of @expr{z}, it can be approximated by the infinite sum
***************
*** 6478,6484 ****
@noindent
where
! @texline @tmath{\sum}
@infoline @expr{sum}
represents the sum over @expr{n} from 1 to infinity
(or to some limit high enough to give the desired accuracy), and
--- 6471,6477 ----
@noindent
where
! @texline @math{\sum}
@infoline @expr{sum}
represents the sum over @expr{n} from 1 to infinity
(or to some limit high enough to give the desired accuracy), and
***************
*** 6486,6512 ****
While this sum is not guaranteed to converge, in practice it is safe.
An interesting mathematical constant is Euler's gamma, which is equal
to about 0.5772. One way to compute it is by the formula,
! @texline @tmath{\gamma = -\psi(1)}.
@infoline @expr{gamma = -psi(1)}.
Unfortunately, 1 isn't a large enough argument
for the above formula to work (5 is a much safer value for @expr{z}).
Fortunately, we can compute
! @texline @tmath{\psi(1)}
@infoline @expr{psi(1)}
from
! @texline @tmath{\psi(5)}
@infoline @expr{psi(5)}
using the recurrence
! @texline @tmath{\psi(z+1) = \psi(z) + {1 \over z}}.
@infoline @expr{psi(z+1) = psi(z) + 1/z}.
Your task: Develop a program to compute
! @texline @tmath{\psi(z)};
@infoline @expr{psi(z)};
it should ``pump up'' @expr{z}
if necessary to be greater than 5, then use the above summation
formula. Use looping commands to compute the sum. Use your function
to compute
! @texline @tmath{\gamma}
@infoline @expr{gamma}
to twelve decimal places. (Calc has a built-in command
for Euler's constant, @kbd{I P}, which you can use to check your answer.)
--- 6479,6505 ----
While this sum is not guaranteed to converge, in practice it is safe.
An interesting mathematical constant is Euler's gamma, which is equal
to about 0.5772. One way to compute it is by the formula,
! @texline @math{\gamma = -\psi(1)}.
@infoline @expr{gamma = -psi(1)}.
Unfortunately, 1 isn't a large enough argument
for the above formula to work (5 is a much safer value for @expr{z}).
Fortunately, we can compute
! @texline @math{\psi(1)}
@infoline @expr{psi(1)}
from
! @texline @math{\psi(5)}
@infoline @expr{psi(5)}
using the recurrence
! @texline @math{\psi(z+1) = \psi(z) + {1 \over z}}.
@infoline @expr{psi(z+1) = psi(z) + 1/z}.
Your task: Develop a program to compute
! @texline @math{\psi(z)};
@infoline @expr{psi(z)};
it should ``pump up'' @expr{z}
if necessary to be greater than 5, then use the above summation
formula. Use looping commands to compute the sum. Use your function
to compute
! @texline @math{\gamma}
@infoline @expr{gamma}
to twelve decimal places. (Calc has a built-in command
for Euler's constant, @kbd{I P}, which you can use to check your answer.)
***************
*** 6683,6700 ****
@kbd{1 @key{RET} 2 @key{RET} 3 @key{RET} 4 + * -}
The result is
! @texline @tmath{1 - (2 \times (3 + 4)) = -13}.
@infoline @expr{1 - (2 * (3 + 4)) = -13}.
@node RPN Answer 2, RPN Answer 3, RPN Answer 1, Answers to Exercises
@subsection RPN Tutorial Exercise 2
@noindent
! @texline @tmath{2\times4 + 7\times9.5 + {5\over4} = 75.75}
@infoline @expr{2*4 + 7*9.5 + 5/4 = 75.75}
After computing the intermediate term
! @texline @tmath{2\times4 = 8},
@infoline @expr{2*4 = 8},
you can leave that result on the stack while you compute the second
term. With both of these results waiting on the stack you can then
--- 6676,6693 ----
@kbd{1 @key{RET} 2 @key{RET} 3 @key{RET} 4 + * -}
The result is
! @texline @math{1 - (2 \times (3 + 4)) = -13}.
@infoline @expr{1 - (2 * (3 + 4)) = -13}.
@node RPN Answer 2, RPN Answer 3, RPN Answer 1, Answers to Exercises
@subsection RPN Tutorial Exercise 2
@noindent
! @texline @math{2\times4 + 7\times9.5 + {5\over4} = 75.75}
@infoline @expr{2*4 + 7*9.5 + 5/4 = 75.75}
After computing the intermediate term
! @texline @math{2\times4 = 8},
@infoline @expr{2*4 = 8},
you can leave that result on the stack while you compute the second
term. With both of these results waiting on the stack you can then
***************
*** 7003,7009 ****
down to an integer. Consider @expr{123456789 / 2} when the current
precision is 6 digits. The true answer is @expr{61728394.5}, but
with a precision of 6 this will be rounded to
! @texline @tmath{12345700.0/2.0 = 61728500.0}.
@infoline @expr{12345700.@: / 2.@: = 61728500.}.
The result, when converted to an integer, will be off by 106.
--- 6996,7002 ----
down to an integer. Consider @expr{123456789 / 2} when the current
precision is 6 digits. The true answer is @expr{61728394.5}, but
with a precision of 6 this will be rounded to
! @texline @math{12345700.0/2.0 = 61728500.0}.
@infoline @expr{12345700.@: / 2.@: = 61728500.}.
The result, when converted to an integer, will be off by 106.
***************
*** 7114,7129 ****
@noindent
To solve
! @texline @tmath{A^T A \, X = A^T B},
@infoline @expr{trn(A) * A * X = trn(A) * B},
first we compute
! @texline @tmath{A' = A^T A}
@infoline @expr{A2 = trn(A) * A}
and
! @texline @tmath{B' = A^T B};
@infoline @expr{B2 = trn(A) * B};
now, we have a system
! @texline @tmath{A' X = B'}
@infoline @expr{A2 * X = B2}
which we can solve using Calc's @samp{/} command.
--- 7107,7122 ----
@noindent
To solve
! @texline @math{A^T A \, X = A^T B},
@infoline @expr{trn(A) * A * X = trn(A) * B},
first we compute
! @texline @math{A' = A^T A}
@infoline @expr{A2 = trn(A) * A}
and
! @texline @math{B' = A^T B};
@infoline @expr{B2 = trn(A) * B};
now, we have a system
! @texline @math{A' X = B'}
@infoline @expr{A2 * X = B2}
which we can solve using Calc's @samp{/} command.
***************
*** 7155,7161 ****
The first step is to enter the coefficient matrix. We'll store it in
quick variable number 7 for later reference. Next, we compute the
! @texline @tmath{B'}
@infoline @expr{B2}
vector.
--- 7148,7154 ----
The first step is to enter the coefficient matrix. We'll store it in
quick variable number 7 for later reference. Next, we compute the
! @texline @math{B'}
@infoline @expr{B2}
vector.
***************
*** 7173,7179 ****
@noindent
Now we compute the matrix
! @texline @tmath{A'}
@infoline @expr{A2}
and divide.
--- 7166,7172 ----
@noindent
Now we compute the matrix
! @texline @math{A'}
@infoline @expr{A2}
and divide.
***************
*** 7194,7209 ****
round-off error.)
Notice that the answers are similar to those for the
! @texline @tmath{3\times3}
@infoline 3x3
system solved in the text. That's because the fourth equation that was
added to the system is almost identical to the first one multiplied
by two. (If it were identical, we would have gotten the exact same
answer since the
! @texline @tmath{4\times3}
@infoline 4x3
system would be equivalent to the original
! @texline @tmath{3\times3}
@infoline 3x3
system.)
--- 7187,7202 ----
round-off error.)
Notice that the answers are similar to those for the
! @texline @math{3\times3}
@infoline 3x3
system solved in the text. That's because the fourth equation that was
added to the system is almost identical to the first one multiplied
by two. (If it were identical, we would have gotten the exact same
answer since the
! @texline @math{4\times3}
@infoline 4x3
system would be equivalent to the original
! @texline @math{3\times3}
@infoline 3x3
system.)
***************
*** 7280,7286 ****
@end tex
Thus we want a
! @texline @tmath{19\times2}
@infoline 19x2
matrix with our @expr{x} vector as one column and
ones as the other column. So, first we build the column of ones, then
--- 7273,7279 ----
@end tex
Thus we want a
! @texline @math{19\times2}
@infoline 19x2
matrix with our @expr{x} vector as one column and
ones as the other column. So, first we build the column of ones, then
***************
*** 7299,7308 ****
@noindent
Now we compute
! @texline @tmath{A^T y}
@infoline @expr{trn(A) * y}
and
! @texline @tmath{A^T A}
@infoline @expr{trn(A) * A}
and divide.
--- 7292,7301 ----
@noindent
Now we compute
! @texline @math{A^T y}
@infoline @expr{trn(A) * y}
and
! @texline @math{A^T A}
@infoline @expr{trn(A) * A}
and divide.
***************
*** 7330,7336 ****
@end smallexample
Since we were solving equations of the form
! @texline @tmath{m \times x + b \times 1 = y},
@infoline @expr{m*x + b*1 = y},
these numbers should be @expr{m} and @expr{b}, respectively. Sure
enough, they agree exactly with the result computed using @kbd{V M} and
--- 7323,7329 ----
@end smallexample
Since we were solving equations of the form
! @texline @math{m \times x + b \times 1 = y},
@infoline @expr{m*x + b*1 = y},
these numbers should be @expr{m} and @expr{b}, respectively. Sure
enough, they agree exactly with the result computed using @kbd{V M} and
***************
*** 7393,7399 ****
@noindent
A number @expr{j} is a divisor of @expr{n} if
! @texline @tmath{n \mathbin{\hbox{\code{\%}}} j = 0}.
@infoline @samp{n % j = 0}.
The first step is to get a vector that identifies the divisors.
--- 7386,7392 ----
@noindent
A number @expr{j} is a divisor of @expr{n} if
! @texline @math{n \mathbin{\hbox{\code{\%}}} j = 0}.
@infoline @samp{n % j = 0}.
The first step is to get a vector that identifies the divisors.
***************
*** 7464,7470 ****
the job is pretty straightforward.
Incidentally, Calc provides the
! @texline @dfn{M@"obius} @tmath{\mu}
@infoline @dfn{Moebius mu}
function which is zero if and only if its argument is square-free. It
would be a much more convenient way to do the above test in practice.
--- 7457,7463 ----
the job is pretty straightforward.
Incidentally, Calc provides the
! @texline @dfn{M@"obius} @math{\mu}
@infoline @dfn{Moebius mu}
function which is zero if and only if its argument is square-free. It
would be a much more convenient way to do the above test in practice.
***************
*** 7498,7504 ****
the ``triangular numbers'' (now you know why!). The @expr{n}th
triangular number is the sum of the integers from 1 to @expr{n}, and
can be computed directly by the formula
! @texline @tmath{n (n+1) \over 2}.
@infoline @expr{n * (n+1) / 2}.
@smallexample
--- 7491,7497 ----
the ``triangular numbers'' (now you know why!). The @expr{n}th
triangular number is the sum of the integers from 1 to @expr{n}, and
can be computed directly by the formula
! @texline @math{n (n+1) \over 2}.
@infoline @expr{n * (n+1) / 2}.
@smallexample
***************
*** 7594,7600 ****
@noindent
It's a good idea to verify, as in the last step above, that only
one value is equal to the maximum. (After all, a plot of
! @texline @tmath{\sin x}
@infoline @expr{sin(x)}
might have many points all equal to the maximum value, 1.)
--- 7587,7593 ----
@noindent
It's a good idea to verify, as in the last step above, that only
one value is equal to the maximum. (After all, a plot of
! @texline @math{\sin x}
@infoline @expr{sin(x)}
might have many points all equal to the maximum value, 1.)
***************
*** 7866,7875 ****
symmetries. First of all, after some thought it's clear that the
@expr{y} axis can be ignored altogether. Just pick a random @expr{x}
component for one end of the match, pick a random direction
! @texline @tmath{\theta},
@infoline @expr{theta},
and see if @expr{x} and
! @texline @tmath{x + \cos \theta}
@infoline @expr{x + cos(theta)}
(which is the @expr{x} coordinate of the other endpoint) cross a line.
The lines are at integer coordinates, so this happens when the two
--- 7859,7868 ----
symmetries. First of all, after some thought it's clear that the
@expr{y} axis can be ignored altogether. Just pick a random @expr{x}
component for one end of the match, pick a random direction
! @texline @math{\theta},
@infoline @expr{theta},
and see if @expr{x} and
! @texline @math{x + \cos \theta}
@infoline @expr{x + cos(theta)}
(which is the @expr{x} coordinate of the other endpoint) cross a line.
The lines are at integer coordinates, so this happens when the two
***************
*** 7886,7895 ****
endpoint. The rightmost endpoint will be between 0 and 1 if the
match does not cross a line, or between 1 and 2 if it does. So:
Pick random @expr{x} and
! @texline @tmath{\theta},
@infoline @expr{theta},
compute
! @texline @tmath{x + \cos \theta},
@infoline @expr{x + cos(theta)},
and count how many of the results are greater than one. Simple!
--- 7879,7888 ----
endpoint. The rightmost endpoint will be between 0 and 1 if the
match does not cross a line, or between 1 and 2 if it does. So:
Pick random @expr{x} and
! @texline @math{\theta},
@infoline @expr{theta},
compute
! @texline @math{x + \cos \theta},
@infoline @expr{x + cos(theta)},
and count how many of the results are greater than one. Simple!
***************
*** 8214,8220 ****
@noindent
Aha! It's unlikely that an irrational number would equal a fraction
this simple to within ten digits, so our original number was probably
! @texline @tmath{\sqrt{27 \pi / 53}}.
@infoline @expr{sqrt(27 pi / 53)}.
Notice that we didn't need to re-round the number when we reduced the
--- 8207,8213 ----
@noindent
Aha! It's unlikely that an irrational number would equal a fraction
this simple to within ten digits, so our original number was probably
! @texline @math{\sqrt{27 \pi / 53}}.
@infoline @expr{sqrt(27 pi / 53)}.
Notice that we didn't need to re-round the number when we reduced the
***************
*** 8475,8483 ****
The fourth calculation, @samp{1 / (-10 .. 10)}, has the same problem.
Zero is buried inside the interval, but it's still a possible value.
It's not hard to see that the actual result of @samp{1 / (-10 .. 10)}
! will be either greater than @i{0.1}, or less than @i{-0.1}. Thus
the interval goes from minus infinity to plus infinity, with a ``hole''
! in it from @i{-0.1} to @i{0.1}. Calc doesn't have any way to
represent this, so it just reports @samp{[-inf .. inf]} as the answer.
It may be disappointing to hear ``the answer lies somewhere between
minus infinity and plus infinity, inclusive,'' but that's the best
--- 8468,8476 ----
The fourth calculation, @samp{1 / (-10 .. 10)}, has the same problem.
Zero is buried inside the interval, but it's still a possible value.
It's not hard to see that the actual result of @samp{1 / (-10 .. 10)}
! will be either greater than @mathit{0.1}, or less than @mathit{-0.1}. Thus
the interval goes from minus infinity to plus infinity, with a ``hole''
! in it from @mathit{-0.1} to @mathit{0.1}. Calc doesn't have any way to
represent this, so it just reports @samp{[-inf .. inf]} as the answer.
It may be disappointing to hear ``the answer lies somewhere between
minus infinity and plus infinity, inclusive,'' but that's the best
***************
*** 8497,8505 ****
@end smallexample
@noindent
! In the first case the result says, ``if a number is between @i{-3} and
3, its square is between 0 and 9.'' The second case says, ``the product
! of two numbers each between @i{-3} and 3 is between @i{-9} and 9.''
An interval form is not a number; it is a symbol that can stand for
many different numbers. Two identical-looking interval forms can stand
--- 8490,8498 ----
@end smallexample
@noindent
! In the first case the result says, ``if a number is between @mathit{-3} and
3, its square is between 0 and 9.'' The second case says, ``the product
! of two numbers each between @mathit{-3} and 3 is between @mathit{-9} and 9.''
An interval form is not a number; it is a symbol that can stand for
many different numbers. Two identical-looking interval forms can stand
***************
*** 9255,9261 ****
@noindent
Computing
! @texline @tmath{\displaystyle{\sin x \over x}}:
@infoline @expr{sin(x) / x}:
Using the stack: @kbd{C-x ( @key{RET} S @key{TAB} / C-x )}.
--- 9248,9254 ----
@noindent
Computing
! @texline @math{\displaystyle{\sin x \over x}}:
@infoline @expr{sin(x) / x}:
Using the stack: @kbd{C-x ( @key{RET} S @key{TAB} / C-x )}.
***************
*** 9326,9332 ****
@noindent
This program is quite efficient because Calc knows how to raise a
matrix (or other value) to the power @expr{n} in only
! @texline @tmath{\log_2 n}
@infoline @expr{log(n,2)}
steps. For example, this program can compute the 1000th Fibonacci
number (a 209-digit integer!) in about 10 steps; even though the
--- 9319,9325 ----
@noindent
This program is quite efficient because Calc knows how to raise a
matrix (or other value) to the power @expr{n} in only
! @texline @math{\log_2 n}
@infoline @expr{log(n,2)}
steps. For example, this program can compute the 1000th Fibonacci
number (a 209-digit integer!) in about 10 steps; even though the
***************
*** 9380,9386 ****
@noindent
The first step is to compute the derivative @expr{f'(x)} and thus
the formula
! @texline @tmath{\displaystyle{x - {f(x) \over f'(x)}}}.
@infoline @expr{x - f(x)/f'(x)}.
(Because this definition is long, it will be repeated in concise form
--- 9373,9379 ----
@noindent
The first step is to compute the derivative @expr{f'(x)} and thus
the formula
! @texline @math{\displaystyle{x - {f(x) \over f'(x)}}}.
@infoline @expr{x - f(x)/f'(x)}.
(Because this definition is long, it will be repeated in concise form
***************
*** 9497,9506 ****
The first step is to adjust @expr{z} to be greater than 5. A simple
``for'' loop will do the job here. If @expr{z} is less than 5, we
reduce the problem using
! @texline @tmath{\psi(z) = \psi(z+1) - 1/z}.
@infoline @expr{psi(z) = psi(z+1) - 1/z}. We go
on to compute
! @texline @tmath{\psi(z+1)},
@infoline @expr{psi(z+1)},
and remember to add back a factor of @expr{-1/z} when we're done. This
step is repeated until @expr{z > 5}.
--- 9490,9499 ----
The first step is to adjust @expr{z} to be greater than 5. A simple
``for'' loop will do the job here. If @expr{z} is less than 5, we
reduce the problem using
! @texline @math{\psi(z) = \psi(z+1) - 1/z}.
@infoline @expr{psi(z) = psi(z+1) - 1/z}. We go
on to compute
! @texline @math{\psi(z+1)},
@infoline @expr{psi(z+1)},
and remember to add back a factor of @expr{-1/z} when we're done. This
step is repeated until @expr{z > 5}.
***************
*** 9541,9547 ****
@end smallexample
Now we compute the initial part of the sum:
! @texline @tmath{\ln z - {1 \over 2z}}
@infoline @expr{ln(z) - 1/2z}
minus the adjustment factor.
--- 9534,9540 ----
@end smallexample
Now we compute the initial part of the sum:
! @texline @math{\ln z - {1 \over 2z}}
@infoline @expr{ln(z) - 1/2z}
minus the adjustment factor.
***************
*** 9584,9590 ****
@end smallexample
This is the value of
! @texline @tmath{-\gamma},
@infoline @expr{- gamma},
with a slight bit of roundoff error. To get a full 12 digits, let's use
a higher precision:
--- 9577,9583 ----
@end smallexample
This is the value of
! @texline @math{-\gamma},
@infoline @expr{- gamma},
with a slight bit of roundoff error. To get a full 12 digits, let's use
a higher precision:
***************
*** 9619,9625 ****
@noindent
Taking the derivative of a term of the form @expr{x^n} will produce
a term like
! @texline @tmath{n x^{n-1}}.
@infoline @expr{n x^(n-1)}.
Taking the derivative of a constant
produces zero. From this it is easy to see that the @expr{n}th
--- 9612,9618 ----
@noindent
Taking the derivative of a term of the form @expr{x^n} will produce
a term like
! @texline @math{n x^{n-1}}.
@infoline @expr{n x^(n-1)}.
Taking the derivative of a constant
produces zero. From this it is easy to see that the @expr{n}th
***************
*** 10193,10199 ****
@kbd{+} key always ``pops'' the top two numbers from the stack, adds them,
and pushes the result (3) back onto the stack. This number is ready for
further calculations: @kbd{5 -} pushes 5 onto the stack, then pops the
! 3 and 5, subtracts them, and pushes the result (@i{-2}).
Note that the ``top'' of the stack actually appears at the @emph{bottom}
of the buffer. A line containing a single @samp{.} character signifies
--- 10186,10192 ----
@kbd{+} key always ``pops'' the top two numbers from the stack, adds them,
and pushes the result (3) back onto the stack. This number is ready for
further calculations: @kbd{5 -} pushes 5 onto the stack, then pops the
! 3 and 5, subtracts them, and pushes the result (@mathit{-2}).
Note that the ``top'' of the stack actually appears at the @emph{bottom}
of the buffer. A line containing a single @samp{.} character signifies
***************
*** 10256,10262 ****
of the number on the top of the stack or the number currently being entered.
The @kbd{_} key begins entry of a negative number or changes the sign of
the number currently being entered. The following sequences all enter the
! number @i{-5} onto the stack: @kbd{0 @key{RET} 5 -}, @kbd{5 n @key{RET}},
@kbd{5 @key{RET} n}, @kbd{_ 5 @key{RET}}, @kbd{5 _ @key{RET}}.
Some other keys are active during numeric entry, such as @kbd{#} for
--- 10249,10255 ----
of the number on the top of the stack or the number currently being entered.
The @kbd{_} key begins entry of a negative number or changes the sign of
the number currently being entered. The following sequences all enter the
! number @mathit{-5} onto the stack: @kbd{0 @key{RET} 5 -}, @kbd{5 n
@key{RET}},
@kbd{5 @key{RET} n}, @kbd{_ 5 @key{RET}}, @kbd{5 _ @key{RET}}.
Some other keys are active during numeric entry, such as @kbd{#} for
***************
*** 10277,10283 ****
Calculations can also be entered in algebraic form. This is accomplished
by typing the apostrophe key, @kbd{'}, followed by the expression in
standard format: @address@hidden'} 2+3*4 @key{RET}} computes
! @texline @tmath{2+(3\times4) = 14}
@infoline @expr{2+(3*4) = 14}
and pushes that on the stack. If you wish you can
ignore the RPN aspect of Calc altogether and simply enter algebraic
--- 10270,10276 ----
Calculations can also be entered in algebraic form. This is accomplished
by typing the apostrophe key, @kbd{'}, followed by the expression in
standard format: @address@hidden'} 2+3*4 @key{RET}} computes
! @texline @math{2+(3\times4) = 14}
@infoline @expr{2+(3*4) = 14}
and pushes that on the stack. If you wish you can
ignore the RPN aspect of Calc altogether and simply enter algebraic
***************
*** 10687,10693 ****
unless you raise the precision still further. Many operations such as
logarithms and sines make use of similarly cached values such as
@cpiover{4} and
! @texline @tmath{\ln 2}.
@infoline @expr{ln(2)}.
The visible effect of caching is that
high-precision computations may seem to do extra work the first time.
--- 10680,10686 ----
unless you raise the precision still further. Many operations such as
logarithms and sines make use of similarly cached values such as
@cpiover{4} and
! @texline @math{\ln 2}.
@infoline @expr{ln(2)}.
The visible effect of caching is that
high-precision computations may seem to do extra work the first time.
***************
*** 10846,10855 ****
notation. The number of significant digits in the fractional part is
governed by the current floating precision (@pxref{Precision}). The
range of acceptable values is from
! @texline @tmath{10^{-3999999}}
@infoline @expr{10^-3999999}
(inclusive) to
! @texline @tmath{10^{4000000}}
@infoline @expr{10^4000000}
(exclusive), plus the corresponding negative values and zero.
--- 10839,10848 ----
notation. The number of significant digits in the fractional part is
governed by the current floating precision (@pxref{Precision}). The
range of acceptable values is from
! @texline @math{10^{-3999999}}
@infoline @expr{10^-3999999}
(inclusive) to
! @texline @math{10^{4000000}}
@infoline @expr{10^4000000}
(exclusive), plus the corresponding negative values and zero.
***************
*** 10921,10936 ****
notation; @pxref{Complex Formats}.
Polar complex numbers are displayed in the form
! @texline address@hidden(address@hidden@t{;address@hidden@t{)}'
@infoline address@hidden(address@hidden@t{;address@hidden@t{)}'
where @var{r} is the nonnegative magnitude and
! @texline @tmath{\theta}
@infoline @var{theta}
is the argument or phase angle. The range of
! @texline @tmath{\theta}
@infoline @var{theta}
depends on the current angular mode (@pxref{Angular Modes}); it is
! generally between @i{-180} and @i{+180} degrees or the equivalent range
in radians.
Complex numbers are entered in stages using incomplete objects.
--- 10914,10929 ----
notation; @pxref{Complex Formats}.
Polar complex numbers are displayed in the form
! @texline address@hidden(address@hidden@t{;address@hidden@t{)}'
@infoline address@hidden(address@hidden@t{;address@hidden@t{)}'
where @var{r} is the nonnegative magnitude and
! @texline @math{\theta}
@infoline @var{theta}
is the argument or phase angle. The range of
! @texline @math{\theta}
@infoline @var{theta}
depends on the current angular mode (@pxref{Angular Modes}); it is
! generally between @mathit{-180} and @mathit{+180} degrees or the equivalent
range
in radians.
Complex numbers are entered in stages using incomplete objects.
***************
*** 10973,10979 ****
that if @expr{x} got ``all the way to infinity,'' then @expr{1 / x}
would go all the way to zero. Similarly, when they say that
@samp{exp(inf) = inf}, they mean that
! @texline @tmath{e^x}
@infoline @expr{exp(x)}
grows without bound as @expr{x} grows. The symbol @samp{-inf} likewise
stands for an infinitely negative real value; for example, we say that
--- 10966,10972 ----
that if @expr{x} got ``all the way to infinity,'' then @expr{1 / x}
would go all the way to zero. Similarly, when they say that
@samp{exp(inf) = inf}, they mean that
! @texline @math{e^x}
@infoline @expr{exp(x)}
grows without bound as @expr{x} grows. The symbol @samp{-inf} likewise
stands for an infinitely negative real value; for example, we say that
***************
*** 11070,11076 ****
@tindex vec
Algebraic functions for building vectors include @samp{vec(a, b, c)}
to build @samp{[a, b, c]}, @samp{cvec(a, n, m)} to build an
! @texline @tmath{n\times m}
@infoline @address@hidden
matrix of @samp{a}s, and @samp{index(n)} to build a vector of integers
from 1 to @samp{n}.
--- 11063,11069 ----
@tindex vec
Algebraic functions for building vectors include @samp{vec(a, b, c)}
to build @samp{[a, b, c]}, @samp{cvec(a, n, m)} to build an
! @texline @math{n\times m}
@infoline @address@hidden
matrix of @samp{a}s, and @samp{index(n)} to build a vector of integers
from 1 to @samp{n}.
***************
*** 11201,11207 ****
The @var{secs} value is a real number between 0 (inclusive) and 60
(exclusive). A positive HMS form is interpreted as @var{hours} +
@var{mins}/60 + @var{secs}/3600. A negative HMS form is interpreted
! as @i{- @var{hours}} @i{-} @var{mins}/60 @i{-} @var{secs}/3600.
Display format for HMS forms is quite flexible. @xref{HMS Formats}.
HMS forms can be added and subtracted. When they are added to numbers,
--- 11194,11200 ----
The @var{secs} value is a real number between 0 (inclusive) and 60
(exclusive). A positive HMS form is interpreted as @var{hours} +
@var{mins}/60 + @var{secs}/3600. A negative HMS form is interpreted
! as @mathit{- @var{hours}} @mathit{-} @var{mins}/60 @mathit{-} @var{secs}/3600.
Display format for HMS forms is quite flexible. @xref{HMS Formats}.
HMS forms can be added and subtracted. When they are added to numbers,
***************
*** 11295,11306 ****
Calc uses the Julian calendar for all dates before the year 1752,
including dates BC when the Julian calendar technically had not
! yet been invented. Thus the claim that day number @i{-10000} is
called ``August 16, 28 BC'' should be taken with a grain of salt.
Please note that there is no ``year 0''; the day before
@samp{<Sat Jan 1, +1>} is @samp{<Fri Dec 31, -1>}. These are
! days 0 and @i{-1} respectively in Calc's internal numbering scheme.
@cindex Julian day counting
Another day counting system in common use is, confusingly, also
--- 11288,11299 ----
Calc uses the Julian calendar for all dates before the year 1752,
including dates BC when the Julian calendar technically had not
! yet been invented. Thus the claim that day number @mathit{-10000} is
called ``August 16, 28 BC'' should be taken with a grain of salt.
Please note that there is no ``year 0''; the day before
@samp{<Sat Jan 1, +1>} is @samp{<Fri Dec 31, -1>}. These are
! days 0 and @mathit{-1} respectively in Calc's internal numbering scheme.
@cindex Julian day counting
Another day counting system in common use is, confusingly, also
***************
*** 11308,11314 ****
Scaliger, who named it in honor of his father Julius Caesar
Scaliger. For obscure reasons he chose to start his day
numbering on Jan 1, 4713 BC at noon, which in Calc's scheme
! is @i{-1721423.5} (recall that Calc starts at midnight instead
of noon). Thus to convert a Calc date code obtained by
unpacking a date form into a Julian day number, simply add
1721423.5. The Julian code for @samp{6:00am Jan 9, 1991}
--- 11301,11307 ----
Scaliger, who named it in honor of his father Julius Caesar
Scaliger. For obscure reasons he chose to start his day
numbering on Jan 1, 4713 BC at noon, which in Calc's scheme
! is @mathit{-1721423.5} (recall that Calc starts at midnight instead
of noon). Thus to convert a Calc date code obtained by
unpacking a date form into a Julian day number, simply add
1721423.5. The Julian code for @samp{6:00am Jan 9, 1991}
***************
*** 11341,11347 ****
often arises in number theory. Modulo forms are written
address@hidden @t{mod} @var{M}',
where @var{a} and @var{M} are real numbers or HMS forms, and
! @texline @tmath{0 \le a < M}.
@infoline @expr{0 <= a < @var{M}}.
In many applications @expr{a} and @expr{M} will be
integers but this is not required.
--- 11334,11340 ----
often arises in number theory. Modulo forms are written
address@hidden @t{mod} @var{M}',
where @var{a} and @var{M} are real numbers or HMS forms, and
! @texline @math{0 \le a < M}.
@infoline @expr{0 <= a < @var{M}}.
In many applications @expr{a} and @expr{M} will be
integers but this is not required.
***************
*** 11373,11379 ****
roots, are not yet supported for modulo forms. (Note that, although
@address@hidden(address@hidden @t{mod} @address@hidden)^.5}'} will compute a
``modulo square root''
in the sense of reducing
! @texline @tmath{\sqrt a}
@infoline @expr{sqrt(a)}
modulo @expr{M}, this is not a useful definition from the
number-theoretical point of view.)
--- 11366,11372 ----
roots, are not yet supported for modulo forms. (Note that, although
@address@hidden(address@hidden @t{mod} @address@hidden)^.5}'} will compute a
``modulo square root''
in the sense of reducing
! @texline @math{\sqrt a}
@infoline @expr{sqrt(a)}
modulo @expr{M}, this is not a useful definition from the
number-theoretical point of view.)
***************
*** 11423,11434 ****
@cindex Standard deviations
An @dfn{error form} is a number with an associated standard
deviation, as in @samp{2.3 +/- 0.12}. The notation
! @texline address@hidden @t{+/-} @tmath{\sigma}'
@infoline address@hidden @t{+/-} sigma'
stands for an uncertain value which follows
a normal or Gaussian distribution of mean @expr{x} and standard
deviation or ``error''
! @texline @tmath{\sigma}.
@infoline @expr{sigma}.
Both the mean and the error can be either numbers or
formulas. Generally these are real numbers but the mean may also be
--- 11416,11427 ----
@cindex Standard deviations
An @dfn{error form} is a number with an associated standard
deviation, as in @samp{2.3 +/- 0.12}. The notation
! @texline address@hidden @t{+/-} @math{\sigma}'
@infoline address@hidden @t{+/-} sigma'
stands for an uncertain value which follows
a normal or Gaussian distribution of mean @expr{x} and standard
deviation or ``error''
! @texline @math{\sigma}.
@infoline @expr{sigma}.
Both the mean and the error can be either numbers or
formulas. Generally these are real numbers but the mean may also be
***************
*** 11439,11445 ****
All arithmetic and transcendental functions accept error forms as input.
Operations on the mean-value part work just like operations on regular
numbers. The error part for any function @expr{f(x)} (such as
! @texline @tmath{\sin x}
@infoline @expr{sin(x)})
is defined by the error of @expr{x} times the derivative of @expr{f}
evaluated at the mean value of @expr{x}. For a two-argument function
--- 11432,11438 ----
All arithmetic and transcendental functions accept error forms as input.
Operations on the mean-value part work just like operations on regular
numbers. The error part for any function @expr{f(x)} (such as
! @texline @math{\sin x}
@infoline @expr{sin(x)})
is defined by the error of @expr{x} times the derivative of @expr{f}
evaluated at the mean value of @expr{x}. For a two-argument function
***************
*** 11470,11503 ****
of standard deviations. Actual errors often are neither Gaussian-distributed
nor uncorrelated, and the above formulas are valid only when errors
are small. As an example, the error arising from
! @texline address@hidden(address@hidden @t{+/-} @address@hidden)}'
@infoline address@hidden(address@hidden @t{+/-} @address@hidden)}'
is
! @texline address@hidden @t{abs(cos(address@hidden@t{))}'.
@infoline address@hidden @t{abs(cos(address@hidden@t{))}'.
When @expr{x} is close to zero,
! @texline @tmath{\cos x}
@infoline @expr{cos(x)}
is close to one so the error in the sine is close to
! @texline @tmath{\sigma};
@infoline @expr{sigma};
this makes sense, since
! @texline @tmath{\sin x}
@infoline @expr{sin(x)}
is approximately @expr{x} near zero, so a given error in @expr{x} will
produce about the same error in the sine. Likewise, near 90 degrees
! @texline @tmath{\cos x}
@infoline @expr{cos(x)}
is nearly zero and so the computed error is
small: The sine curve is nearly flat in that region, so an error in @expr{x}
has relatively little effect on the value of
! @texline @tmath{\sin x}.
@infoline @expr{sin(x)}.
However, consider @samp{sin(90 +/- 1000)}. The cosine of 90 is zero, so
Calc will report zero error! We get an obviously wrong result because
we have violated the small-error approximation underlying the error
analysis. If the error in @expr{x} had been small, the error in
! @texline @tmath{\sin x}
@infoline @expr{sin(x)}
would indeed have been negligible.
--- 11463,11496 ----
of standard deviations. Actual errors often are neither Gaussian-distributed
nor uncorrelated, and the above formulas are valid only when errors
are small. As an example, the error arising from
! @texline address@hidden(address@hidden @t{+/-} @address@hidden)}'
@infoline address@hidden(address@hidden @t{+/-} @address@hidden)}'
is
! @texline address@hidden @t{abs(cos(address@hidden@t{))}'.
@infoline address@hidden @t{abs(cos(address@hidden@t{))}'.
When @expr{x} is close to zero,
! @texline @math{\cos x}
@infoline @expr{cos(x)}
is close to one so the error in the sine is close to
! @texline @math{\sigma};
@infoline @expr{sigma};
this makes sense, since
! @texline @math{\sin x}
@infoline @expr{sin(x)}
is approximately @expr{x} near zero, so a given error in @expr{x} will
produce about the same error in the sine. Likewise, near 90 degrees
! @texline @math{\cos x}
@infoline @expr{cos(x)}
is nearly zero and so the computed error is
small: The sine curve is nearly flat in that region, so an error in @expr{x}
has relatively little effect on the value of
! @texline @math{\sin x}.
@infoline @expr{sin(x)}.
However, consider @samp{sin(90 +/- 1000)}. The cosine of 90 is zero, so
Calc will report zero error! We get an obviously wrong result because
we have violated the small-error approximation underlying the error
analysis. If the error in @expr{x} had been small, the error in
! @texline @math{\sin x}
@infoline @expr{sin(x)}
would indeed have been negligible.
***************
*** 11606,11616 ****
While it may seem that intervals and error forms are similar, they are
based on entirely different concepts of inexact quantities. An error
form
! @texline address@hidden @t{+/-} @tmath{\sigma}'
@infoline address@hidden @t{+/-} @var{sigma}'
means a variable is random, and its value could
be anything but is ``probably'' within one
! @texline @tmath{\sigma}
@infoline @var{sigma}
of the mean value @expr{x}. An interval
address@hidden@var{a} @t{..@:} @address@hidden' means a
--- 11599,11609 ----
While it may seem that intervals and error forms are similar, they are
based on entirely different concepts of inexact quantities. An error
form
! @texline address@hidden @t{+/-} @math{\sigma}'
@infoline address@hidden @t{+/-} @var{sigma}'
means a variable is random, and its value could
be anything but is ``probably'' within one
! @texline @math{\sigma}
@infoline @var{sigma}
of the mean value @expr{x}. An interval
address@hidden@var{a} @t{..@:} @address@hidden' means a
***************
*** 11844,11850 ****
Note that, unlike in usual computer notation, multiplication binds more
strongly than division: @samp{a*b/c*d} is equivalent to
! @texline @tmath{a b \over c d}.
@infoline @expr{(a*b)/(c*d)}.
@cindex Multiplication, implicit
--- 11837,11843 ----
Note that, unlike in usual computer notation, multiplication binds more
strongly than division: @samp{a*b/c*d} is equivalent to
! @texline @math{a b \over c d}.
@infoline @expr{(a*b)/(c*d)}.
@cindex Multiplication, implicit
***************
*** 12042,12052 ****
element at level @var{n} up to the top. (Compare with @key{LFD},
which copies instead of moving the element in level @var{n}.)
! With a negative argument @address@hidden, @key{TAB} rotates the stack
to move the object in level @var{n} to the deepest place in the
! stack, and the object in level @address@hidden to the top. @address@hidden
! rotates the deepest stack element to be in level @i{n}, also
! putting the top stack element in level @address@hidden
@xref{Selecting Subformulas}, for a way to apply these commands to
any portion of a vector or formula on the stack.
--- 12035,12045 ----
element at level @var{n} up to the top. (Compare with @key{LFD},
which copies instead of moving the element in level @var{n}.)
! With a negative argument @address@hidden, @key{TAB} rotates the stack
to move the object in level @var{n} to the deepest place in the
! stack, and the object in level @address@hidden to the top. @address@hidden
! rotates the deepest stack element to be in level @mathit{n}, also
! putting the top stack element in level @address@hidden
@xref{Selecting Subformulas}, for a way to apply these commands to
any portion of a vector or formula on the stack.
***************
*** 12341,12348 ****
is because you are presumably switching to your @file{~/.emacs} file,
which may contain other things you don't want to reread. You can give
a numeric prefix argument of 1 to @kbd{m F} to force it to read the
! file no matter what its name. Conversely, an argument of @i{-1} tells
! @kbd{m F} @emph{not} to read the new file. An argument of 2 or @i{-2}
tells @kbd{m F} not to reset the modes to their defaults beforehand,
which is useful if you intend your new file to have a variant of the
modes present in the file you were using before.
--- 12334,12341 ----
is because you are presumably switching to your @file{~/.emacs} file,
which may contain other things you don't want to reread. You can give
a numeric prefix argument of 1 to @kbd{m F} to force it to read the
! file no matter what its name. Conversely, an argument of @mathit{-1} tells
! @kbd{m F} @emph{not} to read the new file. An argument of 2 or @mathit{-2}
tells @kbd{m F} not to reset the modes to their defaults beforehand,
which is useful if you intend your new file to have a variant of the
modes present in the file you were using before.
***************
*** 12447,12453 ****
If both of these flags are set at once, the effect will be
@code{calc-arcsinh}. (The Hyperbolic flag is also used by some
non-trigonometric commands; for example @kbd{H L} computes a base-10,
! instead of address@hidden, logarithm.)
Command names like @code{calc-arcsin} are provided for completeness, and
may be executed with @kbd{x} or @kbd{M-x}. Their effect is simply to
--- 12440,12446 ----
If both of these flags are set at once, the effect will be
@code{calc-arcsinh}. (The Hyperbolic flag is also used by some
non-trigonometric commands; for example @kbd{H L} computes a base-10,
! instead of address@hidden, logarithm.)
Command names like @code{calc-arcsin} are provided for completeness, and
may be executed with @kbd{x} or @kbd{M-x}. Their effect is simply to
***************
*** 12591,12597 ****
which zero is treated as positive instead of being directionless.
Thus, @samp{1 / 0 = inf} and @samp{-1 / 0 = -inf} in this mode.
Note that zero never actually has a sign in Calc; there are no
! separate representations for @i{+0} and @i{-0}. Positive
infinite mode merely changes the interpretation given to the
single symbol, @samp{0}. One consequence of this is that, while
you might expect @samp{1 / -0 = -inf}, actually @samp{1 / -0}
--- 12584,12590 ----
which zero is treated as positive instead of being directionless.
Thus, @samp{1 / 0 = inf} and @samp{-1 / 0 = -inf} in this mode.
Note that zero never actually has a sign in Calc; there are no
! separate representations for @mathit{+0} and @mathit{-0}. Positive
infinite mode merely changes the interpretation given to the
single symbol, @samp{0}. One consequence of this is that, while
you might expect @samp{1 / -0 = -inf}, actually @samp{1 / -0}
***************
*** 12982,12988 ****
Calc uses this information to determine when certain simplifications
of formulas are safe. For example, @samp{(x^y)^z} cannot be
simplified to @samp{x^(y z)} in general; for example,
! @samp{((-3)^2)^1:2} is 3, but @samp{(-3)^(2*1:2) = (-3)^1} is @i{-3}.
However, this simplification @emph{is} safe if @code{z} is known
to be an integer, or if @code{x} is known to be a nonnegative
real number. If you have given declarations that allow Calc to
--- 12975,12981 ----
Calc uses this information to determine when certain simplifications
of formulas are safe. For example, @samp{(x^y)^z} cannot be
simplified to @samp{x^(y z)} in general; for example,
! @samp{((-3)^2)^1:2} is 3, but @samp{(-3)^(2*1:2) = (-3)^1} is @mathit{-3}.
However, this simplification @emph{is} safe if @code{z} is known
to be an integer, or if @code{x} is known to be a nonnegative
real number. If you have given declarations that allow Calc to
***************
*** 13095,13101 ****
@end table
Calc does not check the declarations for a variable when you store
! a value in it. However, storing @i{-3.5} in a variable that has
been declared @code{pos}, @code{int}, or @code{matrix} may have
unexpected effects; Calc may evaluate @samp{sqrt(x^2)} to @expr{3.5}
if it substitutes the value first, or to @expr{-3.5} if @code{x}
--- 13088,13094 ----
@end table
Calc does not check the declarations for a variable when you store
! a value in it. However, storing @mathit{-3.5} in a variable that has
been declared @code{pos}, @code{int}, or @code{matrix} may have
unexpected effects; Calc may evaluate @samp{sqrt(x^2)} to @expr{3.5}
if it substitutes the value first, or to @expr{-3.5} if @code{x}
***************
*** 13330,13336 ****
current binary word size. (@xref{Binary Functions}, for a discussion of
word size.) If the absolute value of the word size is @expr{w}, all integers
are displayed with at least enough digits to represent
! @texline @tmath{2^w-1}
@infoline @expr{(2^w)-1}
in the current radix. (Larger integers will still be displayed in their
entirety.)
--- 13323,13329 ----
current binary word size. (@xref{Binary Functions}, for a discussion of
word size.) If the absolute value of the word size is @expr{w}, all integers
are displayed with at least enough digits to represent
! @texline @math{2^w-1}
@infoline @expr{(2^w)-1}
in the current radix. (Larger integers will still be displayed in their
entirety.)
***************
*** 14231,14240 ****
parentheses for very simple arguments. During input, curly braces and
parentheses work equally well for grouping, but when the document is
formatted the curly braces will be invisible. Thus the printed result is
! @texline @tmath{\sin{2 x}}
@infoline @expr{sin 2x}
but
! @texline @tmath{\sin(2 + x)}.
@infoline @expr{sin(2 + x)}.
Function and variable names not treated specially by @TeX{} are simply
--- 14224,14233 ----
parentheses for very simple arguments. During input, curly braces and
parentheses work equally well for grouping, but when the document is
formatted the curly braces will be invisible. Thus the printed result is
! @texline @math{\sin{2 x}}
@infoline @expr{sin 2x}
but
! @texline @math{\sin(2 + x)}.
@infoline @expr{sin(2 + x)}.
Function and variable names not treated specially by @TeX{} are simply
***************
*** 15728,15746 ****
Command is @kbd{m p}.
@item
! Matrix/scalar mode. Default value is @i{-1}. Value is 0 for scalar
! mode, @i{-2} for matrix mode, or @var{N} for
! @texline @tmath{N\times N}
@infoline @address@hidden
matrix mode. Command is @kbd{m v}.
@item
! Simplification mode. Default is 1. Value is @i{-1} for off (@kbd{m O}),
0 for @kbd{m N}, 2 for @kbd{m B}, 3 for @kbd{m A}, 4 for @kbd{m E},
or 5 for @address@hidden U}}. The @kbd{m D} command accepts these prefixes.
@item
! Infinite mode. Default is @i{-1} (off). Value is 1 if the mode is on,
or 0 if the mode is on with positive zeros. Command is @kbd{m i}.
@end enumerate
--- 15721,15739 ----
Command is @kbd{m p}.
@item
! Matrix/scalar mode. Default value is @mathit{-1}. Value is 0 for scalar
! mode, @mathit{-2} for matrix mode, or @var{N} for
! @texline @math{N\times N}
@infoline @address@hidden
matrix mode. Command is @kbd{m v}.
@item
! Simplification mode. Default is 1. Value is @mathit{-1} for off (@kbd{m O}),
0 for @kbd{m N}, 2 for @kbd{m B}, 3 for @kbd{m A}, 4 for @kbd{m E},
or 5 for @address@hidden U}}. The @kbd{m D} command accepts these prefixes.
@item
! Infinite mode. Default is @mathit{-1} (off). Value is 1 if the mode is on,
or 0 if the mode is on with positive zeros. Command is @kbd{m i}.
@end enumerate
***************
*** 16081,16087 ****
@tindex -
The @kbd{-} (@code{calc-minus}) command subtracts two values. The top
number on the stack is subtracted from the one behind it, so that the
! computation @kbd{5 @key{RET} 2 -} produces 3, not @i{-3}. All options
available for @kbd{+} are available for @kbd{-} as well.
@kindex *
--- 16074,16080 ----
@tindex -
The @kbd{-} (@code{calc-minus}) command subtracts two values. The top
number on the stack is subtracted from the one behind it, so that the
! computation @kbd{5 @key{RET} 2 -} produces 3, not @mathit{-3}. All options
available for @kbd{+} are available for @kbd{-} as well.
@kindex *
***************
*** 16225,16231 ****
@pindex calc-sign
@tindex sign
The @kbd{f s} (@code{calc-sign}) address@hidden command returns 1 if its
! argument is positive, @i{-1} if its argument is negative, or 0 if its
argument is zero. In algebraic form, you can also write @samp{sign(a,x)}
which evaluates to @samp{x * sign(a)}, i.e., either @samp{x}, @samp{-x}, or
zero depending on the sign of @samp{a}.
--- 16218,16224 ----
@pindex calc-sign
@tindex sign
The @kbd{f s} (@code{calc-sign}) address@hidden command returns 1 if its
! argument is positive, @mathit{-1} if its argument is negative, or 0 if its
argument is zero. In algebraic form, you can also write @samp{sign(a,x)}
which evaluates to @samp{x * sign(a)}, i.e., either @samp{x}, @samp{-x}, or
zero depending on the sign of @samp{a}.
***************
*** 16288,16294 ****
the ``mantissa'' part @expr{m} of its floating-point argument; @kbd{f X}
(@code{calc-xpon-part}) address@hidden extracts the ``exponent'' part
@expr{e}. The original number is equal to
! @texline @tmath{m \times 10^e},
@infoline @expr{m * 10^e},
where @expr{m} is in the interval @samp{[1.0 ..@: 10.0)} except that
@expr{m=e=0} if the original number is zero. For integers
--- 16281,16287 ----
the ``mantissa'' part @expr{m} of its floating-point argument; @kbd{f X}
(@code{calc-xpon-part}) address@hidden extracts the ``exponent'' part
@expr{e}. The original number is equal to
! @texline @math{m \times 10^e},
@infoline @expr{m * 10^e},
where @expr{m} is in the interval @samp{[1.0 ..@: 10.0)} except that
@expr{m=e=0} if the original number is zero. For integers
***************
*** 16321,16327 ****
is 6 digits yields @samp{12.3457}. If the current precision had been
8 digits, the result would have been @samp{12.345601}. Incrementing
@samp{0.0} produces
! @texline @tmath{10^{-p}},
@infoline @expr{10^-p},
where @expr{p} is the current
precision. These operations are defined only on integers and floats.
--- 16314,16320 ----
is 6 digits yields @samp{12.3457}. If the current precision had been
8 digits, the result would have been @samp{12.345601}. Incrementing
@samp{0.0} produces
! @texline @math{10^{-p}},
@infoline @expr{10^-p},
where @expr{p} is the current
precision. These operations are defined only on integers and floats.
***************
*** 16362,16368 ****
The @kbd{F} (@code{calc-floor}) address@hidden or @code{ffloor}] command
truncates a real number to the next lower integer, i.e., toward minus
infinity. Thus @kbd{3.6 F} produces 3, but @kbd{_3.6 F} produces
! @i{-4}.
@kindex I F
@pindex calc-ceiling
--- 16355,16361 ----
The @kbd{F} (@code{calc-floor}) address@hidden or @code{ffloor}] command
truncates a real number to the next lower integer, i.e., toward minus
infinity. Thus @kbd{3.6 F} produces 3, but @kbd{_3.6 F} produces
! @mathit{-4}.
@kindex I F
@pindex calc-ceiling
***************
*** 16374,16380 ****
@kindex H I F
The @kbd{I F} (@code{calc-ceiling}) address@hidden or @code{fceil}]
command truncates toward positive infinity. Thus @kbd{3.6 I F} produces
! 4, and @kbd{_3.6 I F} produces @i{-3}.
@kindex R
@pindex calc-round
--- 16367,16373 ----
@kindex H I F
The @kbd{I F} (@code{calc-ceiling}) address@hidden or @code{fceil}]
command truncates toward positive infinity. Thus @kbd{3.6 I F} produces
! 4, and @kbd{_3.6 I F} produces @mathit{-3}.
@kindex R
@pindex calc-round
***************
*** 16388,16394 ****
rounds to the nearest integer. When the fractional part is .5 exactly,
this command rounds away from zero. (All other rounding in the
Calculator uses this convention as well.) Thus @kbd{3.5 R} produces 4
! but @kbd{3.4 R} produces 3; @kbd{_3.5 R} produces @i{-4}.
@kindex I R
@pindex calc-trunc
--- 16381,16387 ----
rounds to the nearest integer. When the fractional part is .5 exactly,
this command rounds away from zero. (All other rounding in the
Calculator uses this convention as well.) Thus @kbd{3.5 R} produces 4
! but @kbd{3.4 R} produces 3; @kbd{_3.5 R} produces @mathit{-4}.
@kindex I R
@pindex calc-trunc
***************
*** 16401,16407 ****
The @kbd{I R} (@code{calc-trunc}) address@hidden or @code{ftrunc}]
command truncates toward zero. In other words, it ``chops off''
everything after the decimal point. Thus @kbd{3.6 I R} produces 3 and
! @kbd{_3.6 I R} produces @i{-3}.
These functions may not be applied meaningfully to error forms, but they
do work for intervals. As a convenience, applying @code{floor} to a
--- 16394,16400 ----
The @kbd{I R} (@code{calc-trunc}) address@hidden or @code{ftrunc}]
command truncates toward zero. In other words, it ``chops off''
everything after the decimal point. Thus @kbd{3.6 I R} produces 3 and
! @kbd{_3.6 I R} produces @mathit{-3}.
These functions may not be applied meaningfully to error forms, but they
do work for intervals. As a convenience, applying @code{floor} to a
***************
*** 16479,16488 ****
The @kbd{G} (@code{calc-argument}) address@hidden command computes the
``argument'' or polar angle of a complex number. For a number in polar
notation, this is simply the second component of the pair
! @texline address@hidden(address@hidden@t{;address@hidden@t{)}'.
@infoline address@hidden(address@hidden@t{;address@hidden@t{)}'.
The result is expressed according to the current angular mode and will
! be in the range @i{-180} degrees (exclusive) to @i{+180} degrees
(inclusive), or the equivalent range in radians.
@pindex calc-imaginary
--- 16472,16481 ----
The @kbd{G} (@code{calc-argument}) address@hidden command computes the
``argument'' or polar angle of a complex number. For a number in polar
notation, this is simply the second component of the pair
! @texline address@hidden(address@hidden@t{;address@hidden@t{)}'.
@infoline address@hidden(address@hidden@t{;address@hidden@t{)}'.
The result is expressed according to the current angular mode and will
! be in the range @mathit{-180} degrees (exclusive) to @mathit{+180} degrees
(inclusive), or the equivalent range in radians.
@pindex calc-imaginary
***************
*** 16513,16520 ****
@pindex calc-pack
The @kbd{v p} (@code{calc-pack}) command can pack the top two numbers on
the stack into a composite object such as a complex number. With
! a prefix argument of @i{-1}, it produces a rectangular complex number;
! with an argument of @i{-2}, it produces a polar complex number.
(Also, @pxref{Building Vectors}.)
@ignore
--- 16506,16513 ----
@pindex calc-pack
The @kbd{v p} (@code{calc-pack}) command can pack the top two numbers on
the stack into a composite object such as a complex number. With
! a prefix argument of @mathit{-1}, it produces a rectangular complex number;
! with an argument of @mathit{-2}, it produces a polar complex number.
(Also, @pxref{Building Vectors}.)
@ignore
***************
*** 16638,16644 ****
The @kbd{c c} (@code{calc-clean}) address@hidden command ``cleans'' the
number on the top of the stack. Floating point numbers are re-rounded
according to the current precision. Polar numbers whose angular
! components have strayed from the @i{-180} to @i{+180} degree range
are normalized. (Note that results will be undesirable if the current
angular mode is different from the one under which the number was
produced!) Integers and fractions are generally unaffected by this
--- 16631,16637 ----
The @kbd{c c} (@code{calc-clean}) address@hidden command ``cleans'' the
number on the top of the stack. Floating point numbers are re-rounded
according to the current precision. Polar numbers whose angular
! components have strayed from the @mathit{-180} to @mathit{+180} degree range
are normalized. (Note that results will be undesirable if the current
angular mode is different from the one under which the number was
produced!) Integers and fractions are generally unaffected by this
***************
*** 16894,16901 ****
@var{n} in the range from 1 to 366, @kbd{t Y} computes the
@var{n}th day of the year (366 is treated as 365 in non-leap
years). A prefix argument of 0 computes the last day of the
! year (December 31). A negative prefix argument from @i{-1} to
! @i{-12} computes the first day of the @var{n}th month of the year.
@kindex t W
@pindex calc-new-week
--- 16887,16894 ----
@var{n} in the range from 1 to 366, @kbd{t Y} computes the
@var{n}th day of the year (366 is treated as 365 in non-leap
years). A prefix argument of 0 computes the last day of the
! year (December 31). A negative prefix argument from @mathit{-1} to
! @mathit{-12} computes the first day of the @var{n}th month of the year.
@kindex t W
@pindex calc-new-week
***************
*** 17264,17270 ****
name of a function that is used to compute the daylight savings
adjustment for a given date. The default is
@code{math-std-daylight-savings}, which computes an adjustment
! (either 0 or @i{-1}) using the North American rules given above.
The daylight savings hook function is called with four arguments:
The date, as a floating-point number in standard Calc format;
--- 17257,17263 ----
name of a function that is used to compute the daylight savings
adjustment for a given date. The default is
@code{math-std-daylight-savings}, which computes an adjustment
! (either 0 or @mathit{-1}) using the North American rules given above.
The daylight savings hook function is called with four arguments:
The date, as a floating-point number in standard Calc format;
***************
*** 17312,17318 ****
@noindent
The @code{bump} parameter is equal to zero when Calc is converting
from a date form in a generalized time zone into a GMT date value.
! It is @i{-1} when Calc is converting in the other direction. The
adjustments shown above ensure that the conversion behaves correctly
and reasonably around the 2 a.m.@: transition in each direction.
--- 17305,17311 ----
@noindent
The @code{bump} parameter is equal to zero when Calc is converting
from a date form in a generalized time zone into a GMT date value.
! It is @mathit{-1} when Calc is converting in the other direction. The
adjustments shown above ensure that the conversion behaves correctly
and reasonably around the 2 a.m.@: transition in each direction.
***************
*** 17939,17948 ****
If the word size is negative, binary operations produce 2's complement
integers from
! @texline @tmath{-2^{-w-1}}
@infoline @expr{-(2^(-w-1))}
to
! @texline @tmath{2^{-w-1}-1}
@infoline @expr{2^(-w-1)-1}
inclusive. Either mode accepts inputs in any range; the sign of
@expr{w} affects only the results produced.
--- 17932,17941 ----
If the word size is negative, binary operations produce 2's complement
integers from
! @texline @math{-2^{-w-1}}
@infoline @expr{-(2^(-w-1))}
to
! @texline @math{2^{-w-1}-1}
@infoline @expr{2^(-w-1)-1}
inclusive. Either mode accepts inputs in any range; the sign of
@expr{w} affects only the results produced.
***************
*** 17958,17964 ****
generally is not ``binary.'' (However, @pxref{Simplification Modes},
@code{calc-bin-simplify-mode}.) For example, with a word size of 8
bits @kbd{b c} converts a number to the range 0 to 255; with a word
! size of @i{-8} @kbd{b c} converts to the range @i{-128} to 127.
@kindex b w
@pindex calc-word-size
--- 17951,17957 ----
generally is not ``binary.'' (However, @pxref{Simplification Modes},
@code{calc-bin-simplify-mode}.) For example, with a word size of 8
bits @kbd{b c} converts a number to the range 0 to 255; with a word
! size of @mathit{-8} @kbd{b c} converts to the range @mathit{-128} to 127.
@kindex b w
@pindex calc-word-size
***************
*** 17974,17980 ****
optional second (or third) word-size parameter. When a formula like
@samp{and(a,b)} is finally evaluated, the word size current at that time
will be used, but when @samp{and(a,b,-8)} is evaluated, a word size of
! @i{-8} will always be used. A symbolic binary function will be left
in symbolic form unless the all of its argument(s) are integers or
integer-valued floats.
--- 17967,17973 ----
optional second (or third) word-size parameter. When a formula like
@samp{and(a,b)} is finally evaluated, the word size current at that time
will be used, but when @samp{and(a,b,-8)} is evaluated, a word size of
! @mathit{-8} will always be used. A symbolic binary function will be left
in symbolic form unless the all of its argument(s) are integers or
integer-valued floats.
***************
*** 18126,18136 ****
the value of @cpi{} (at the current precision) onto the stack. With the
Hyperbolic flag, it pushes the value @expr{e}, the base of natural logarithms.
With the Inverse flag, it pushes Euler's constant
! @texline @tmath{\gamma}
@infoline @expr{gamma}
(about 0.5772). With both Inverse and Hyperbolic, it
pushes the ``golden ratio''
! @texline @tmath{\phi}
@infoline @expr{phi}
(about 1.618). (At present, Euler's constant is not available
to unlimited precision; Calc knows only the first 100 digits.)
--- 18119,18129 ----
the value of @cpi{} (at the current precision) onto the stack. With the
Hyperbolic flag, it pushes the value @expr{e}, the base of natural logarithms.
With the Inverse flag, it pushes Euler's constant
! @texline @math{\gamma}
@infoline @expr{gamma}
(about 0.5772). With both Inverse and Hyperbolic, it
pushes the ``golden ratio''
! @texline @math{\phi}
@infoline @expr{phi}
(about 1.618). (At present, Euler's constant is not available
to unlimited precision; Calc knows only the first 100 digits.)
***************
*** 18210,18216 ****
it raises ten to a given power.) Note that the common logarithm of a
complex number is computed by taking the natural logarithm and dividing
by
! @texline @tmath{\ln10}.
@infoline @expr{ln(10)}.
@kindex B
--- 18203,18209 ----
it raises ten to a given power.) Note that the common logarithm of a
complex number is computed by taking the natural logarithm and dividing
by
! @texline @math{\ln10}.
@infoline @expr{ln(10)}.
@kindex B
***************
*** 18220,18226 ****
@tindex alog
The @kbd{B} (@code{calc-log}) address@hidden command computes a logarithm
to any base. For example, @kbd{1024 @key{RET} 2 B} produces 10, since
! @texline @tmath{2^{10} = 1024}.
@infoline @expr{2^10 = 1024}.
In certain cases like @samp{log(3,9)}, the result
will be either @expr{1:2} or @expr{0.5} depending on the current Fraction
--- 18213,18219 ----
@tindex alog
The @kbd{B} (@code{calc-log}) address@hidden command computes a logarithm
to any base. For example, @kbd{1024 @key{RET} 2 B} produces 10, since
! @texline @math{2^{10} = 1024}.
@infoline @expr{2^10 = 1024}.
In certain cases like @samp{log(3,9)}, the result
will be either @expr{1:2} or @expr{0.5} depending on the current Fraction
***************
*** 18242,18252 ****
@pindex calc-expm1
@tindex expm1
The @kbd{f E} (@code{calc-expm1}) address@hidden command computes
! @texline @tmath{e^x - 1},
@infoline @expr{exp(x)-1},
but using an algorithm that produces a more accurate
answer when the result is close to zero, i.e., when
! @texline @tmath{e^x}
@infoline @expr{exp(x)}
is close to one.
--- 18235,18245 ----
@pindex calc-expm1
@tindex expm1
The @kbd{f E} (@code{calc-expm1}) address@hidden command computes
! @texline @math{e^x - 1},
@infoline @expr{exp(x)-1},
but using an algorithm that produces a more accurate
answer when the result is close to zero, i.e., when
! @texline @math{e^x}
@infoline @expr{exp(x)}
is close to one.
***************
*** 18254,18260 ****
@pindex calc-lnp1
@tindex lnp1
The @kbd{f L} (@code{calc-lnp1}) address@hidden command computes
! @texline @tmath{\ln(x+1)},
@infoline @expr{ln(x+1)},
producing a more accurate answer when @expr{x} is close to zero.
--- 18247,18253 ----
@pindex calc-lnp1
@tindex lnp1
The @kbd{f L} (@code{calc-lnp1}) address@hidden command computes
! @texline @math{\ln(x+1)},
@infoline @expr{ln(x+1)},
producing a more accurate answer when @expr{x} is close to zero.
***************
*** 18388,18397 ****
@tindex arctan2
The @kbd{f T} (@code{calc-arctan2}) address@hidden command takes two
numbers from the stack and computes the arc tangent of their ratio. The
! result is in the full range from @i{-180} (exclusive) to @i{+180}
(inclusive) degrees, or the analogous range in radians. A similar
result would be obtained with @kbd{/} followed by @kbd{I T}, but the
! value would only be in the range from @i{-90} to @i{+90} degrees
since the division loses information about the signs of the two
components, and an error might result from an explicit division by zero
which @code{arctan2} would avoid. By (arbitrary) definition,
--- 18381,18390 ----
@tindex arctan2
The @kbd{f T} (@code{calc-arctan2}) address@hidden command takes two
numbers from the stack and computes the arc tangent of their ratio. The
! result is in the full range from @mathit{-180} (exclusive) to @mathit{+180}
(inclusive) degrees, or the analogous range in radians. A similar
result would be obtained with @kbd{/} followed by @kbd{I T}, but the
! value would only be in the range from @mathit{-90} to @mathit{+90} degrees
since the division loses information about the signs of the two
components, and an error might result from an explicit division by zero
which @code{arctan2} would avoid. By (arbitrary) definition,
***************
*** 18440,18446 ****
factorial function: @samp{gamma(n+1) = fact(n)}. For general complex
arguments the gamma function can be defined by the following definite
integral:
! @texline @tmath{\Gamma(a) = \int_0^\infty t^{a-1} e^t dt}.
@infoline @expr{gamma(a) = integ(t^(a-1) exp(t), t, 0, inf)}.
(The actual implementation uses far more efficient computational methods.)
--- 18433,18439 ----
factorial function: @samp{gamma(n+1) = fact(n)}. For general complex
arguments the gamma function can be defined by the following definite
integral:
! @texline @math{\Gamma(a) = \int_0^\infty t^{a-1} e^t dt}.
@infoline @expr{gamma(a) = integ(t^(a-1) exp(t), t, 0, inf)}.
(The actual implementation uses far more efficient computational methods.)
***************
*** 18474,18480 ****
The @kbd{f G} (@code{calc-inc-gamma}) address@hidden command computes
the incomplete gamma function, denoted @samp{P(a,x)}. This is defined by
the integral,
! @texline @tmath{P(a,x) = \left( \int_0^x t^{a-1} e^t dt \right) / \Gamma(a)}.
@infoline @expr{gammaP(a,x) = integ(t^(a-1) exp(t), t, 0, x) / gamma(a)}.
This implies that @samp{gammaP(a,inf) = 1} for any @expr{a} (see the
definition of the normal gamma function).
--- 18467,18473 ----
The @kbd{f G} (@code{calc-inc-gamma}) address@hidden command computes
the incomplete gamma function, denoted @samp{P(a,x)}. This is defined by
the integral,
! @texline @math{P(a,x) = \left( \int_0^x t^{a-1} e^t dt \right) / \Gamma(a)}.
@infoline @expr{gammaP(a,x) = integ(t^(a-1) exp(t), t, 0, x) / gamma(a)}.
This implies that @samp{gammaP(a,inf) = 1} for any @expr{a} (see the
definition of the normal gamma function).
***************
*** 18507,18516 ****
@tindex beta
The @kbd{f b} (@code{calc-beta}) address@hidden command computes the
Euler beta function, which is defined in terms of the gamma function as
! @texline @tmath{B(a,b) = \Gamma(a) \Gamma(b) / \Gamma(a+b)},
@infoline @expr{beta(a,b) = gamma(a) gamma(b) / gamma(a+b)},
or by
! @texline @tmath{B(a,b) = \int_0^1 t^{a-1} (1-t)^{b-1} dt}.
@infoline @expr{beta(a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, 1)}.
@kindex f B
--- 18500,18509 ----
@tindex beta
The @kbd{f b} (@code{calc-beta}) address@hidden command computes the
Euler beta function, which is defined in terms of the gamma function as
! @texline @math{B(a,b) = \Gamma(a) \Gamma(b) / \Gamma(a+b)},
@infoline @expr{beta(a,b) = gamma(a) gamma(b) / gamma(a+b)},
or by
! @texline @math{B(a,b) = \int_0^1 t^{a-1} (1-t)^{b-1} dt}.
@infoline @expr{beta(a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, 1)}.
@kindex f B
***************
*** 18520,18526 ****
@tindex betaB
The @kbd{f B} (@code{calc-inc-beta}) address@hidden command computes
the incomplete beta function @expr{I(x,a,b)}. It is defined by
! @texline @tmath{I(x,a,b) = \left( \int_0^x t^{a-1} (1-t)^{b-1} dt \right) /
B(a,b)}.
@infoline @expr{betaI(x,a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, x) /
beta(a,b)}.
Once again, the @kbd{H} (hyperbolic) prefix gives the corresponding
un-normalized version address@hidden
--- 18513,18519 ----
@tindex betaB
The @kbd{f B} (@code{calc-inc-beta}) address@hidden command computes
the incomplete beta function @expr{I(x,a,b)}. It is defined by
! @texline @math{I(x,a,b) = \left( \int_0^x t^{a-1} (1-t)^{b-1} dt \right) /
B(a,b)}.
@infoline @expr{betaI(x,a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, x) /
beta(a,b)}.
Once again, the @kbd{H} (hyperbolic) prefix gives the corresponding
un-normalized version address@hidden
***************
*** 18532,18542 ****
@tindex erfc
The @kbd{f e} (@code{calc-erf}) address@hidden command computes the
error function
! @texline @tmath{\hbox{erf}(x) = {2 \over \sqrt{\pi}} \int_0^x e^{-t^2} dt}.
@infoline @expr{erf(x) = 2 integ(exp(-(t^2)), t, 0, x) / sqrt(pi)}.
The complementary error function @kbd{I f e} (@code{calc-erfc}) address@hidden
is the corresponding integral from @samp{x} to infinity; the sum
! @texline @tmath{\hbox{erf}(x) + \hbox{erfc}(x) = 1}.
@infoline @expr{erf(x) + erfc(x) = 1}.
@kindex f j
--- 18525,18535 ----
@tindex erfc
The @kbd{f e} (@code{calc-erf}) address@hidden command computes the
error function
! @texline @math{\hbox{erf}(x) = {2 \over \sqrt{\pi}} \int_0^x e^{-t^2} dt}.
@infoline @expr{erf(x) = 2 integ(exp(-(t^2)), t, 0, x) / sqrt(pi)}.
The complementary error function @kbd{I f e} (@code{calc-erfc}) address@hidden
is the corresponding integral from @samp{x} to infinity; the sum
! @texline @math{\hbox{erf}(x) + \hbox{erfc}(x) = 1}.
@infoline @expr{erf(x) + erfc(x) = 1}.
@kindex f j
***************
*** 18612,18628 ****
For @samp{z1^z2}: This is defined by @samp{exp(ln(z1)*z2)}.
One interesting consequence of this is that @samp{(-8)^1:3} does
! not evaluate to @i{-2} as you might expect, but to the complex
number @expr{(1., 1.732)}. Both of these are valid cube roots
! of @i{-8} (as is @expr{(1., -1.732)}); Calc chooses a perhaps
less-obvious root for the sake of mathematical consistency.
For @samp{arcsin(z)}: This is defined by @samp{-i*ln(i*z + sqrt(1-z^2))}.
! The branch cuts are on the real axis, less than @i{-1} and greater than 1.
For @samp{arccos(z)}: This is defined by @samp{-i*ln(z + i*sqrt(1-z^2))},
or equivalently by @samp{pi/2 - arcsin(z)}. The branch cuts are on
! the real axis, less than @i{-1} and greater than 1.
For @samp{arctan(z)}: This is defined by
@samp{(ln(1+i*z) - ln(1-i*z)) / (2*i)}. The branch cuts are on the
--- 18605,18621 ----
For @samp{z1^z2}: This is defined by @samp{exp(ln(z1)*z2)}.
One interesting consequence of this is that @samp{(-8)^1:3} does
! not evaluate to @mathit{-2} as you might expect, but to the complex
number @expr{(1., 1.732)}. Both of these are valid cube roots
! of @mathit{-8} (as is @expr{(1., -1.732)}); Calc chooses a perhaps
less-obvious root for the sake of mathematical consistency.
For @samp{arcsin(z)}: This is defined by @samp{-i*ln(i*z + sqrt(1-z^2))}.
! The branch cuts are on the real axis, less than @mathit{-1} and greater than
1.
For @samp{arccos(z)}: This is defined by @samp{-i*ln(z + i*sqrt(1-z^2))},
or equivalently by @samp{pi/2 - arcsin(z)}. The branch cuts are on
! the real axis, less than @mathit{-1} and greater than 1.
For @samp{arctan(z)}: This is defined by
@samp{(ln(1+i*z) - ln(1-i*z)) / (2*i)}. The branch cuts are on the
***************
*** 18637,18643 ****
real axis less than 1.
For @samp{arctanh(z)}: This is defined by @samp{(ln(1+z) - ln(1-z)) / 2}.
! The branch cuts are on the real axis, less than @i{-1} and greater than 1.
The following tables for @code{arcsin}, @code{arccos}, and
@code{arctan} assume the current angular mode is radians. The
--- 18630,18636 ----
real axis less than 1.
For @samp{arctanh(z)}: This is defined by @samp{(ln(1+z) - ln(1-z)) / 2}.
! The branch cuts are on the real axis, less than @mathit{-1} and greater than
1.
The following tables for @code{arcsin}, @code{arccos}, and
@code{arctan} assume the current angular mode is radians. The
***************
*** 18710,18716 ****
Given a positive numeric prefix argument @expr{M}, it produces a random
integer @expr{N} in the range
! @texline @tmath{0 \le N < M}.
@infoline @expr{0 <= N < M}.
Each of the @expr{M} values appears with equal probability.
--- 18703,18709 ----
Given a positive numeric prefix argument @expr{M}, it produces a random
integer @expr{N} in the range
! @texline @math{0 \le N < M}.
@infoline @expr{0 <= N < M}.
Each of the @expr{M} values appears with equal probability.
***************
*** 18720,18734 ****
while numeric prefix arguments are limited to six digits or so, an @expr{M}
taken from the stack can be arbitrarily large. If @expr{M} is negative,
the result is a random integer in the range
! @texline @tmath{M < N \le 0}.
@infoline @expr{M < N <= 0}.
If the value on the stack is a floating-point number @expr{M}, the result
is a random floating-point number @expr{N} in the range
! @texline @tmath{0 \le N < M}
@infoline @expr{0 <= N < M}
or
! @texline @tmath{M < N \le 0},
@infoline @expr{M < N <= 0},
according to the sign of @expr{M}.
--- 18713,18727 ----
while numeric prefix arguments are limited to six digits or so, an @expr{M}
taken from the stack can be arbitrarily large. If @expr{M} is negative,
the result is a random integer in the range
! @texline @math{M < N \le 0}.
@infoline @expr{M < N <= 0}.
If the value on the stack is a floating-point number @expr{M}, the result
is a random floating-point number @expr{N} in the range
! @texline @math{0 \le N < M}
@infoline @expr{0 <= N < M}
or
! @texline @math{M < N \le 0},
@infoline @expr{M < N <= 0},
according to the sign of @expr{M}.
***************
*** 18738,18751 ****
every other call to this function will be especially fast.
If @expr{M} is an error form
! @texline @tmath{m} @code{+/-} @tmath{\sigma}
@infoline @samp{m +/- s}
where @var{m} and
! @texline @tmath{\sigma}
@infoline @var{s}
are both real numbers, the result uses a Gaussian distribution with mean
@var{m} and standard deviation
! @texline @tmath{\sigma}.
@var{s}.
If @expr{M} is an interval form, the lower and upper bounds specify the
--- 18731,18744 ----
every other call to this function will be especially fast.
If @expr{M} is an error form
! @texline @math{m} @code{+/-} @math{\sigma}
@infoline @samp{m +/- s}
where @var{m} and
! @texline @math{\sigma}
@infoline @var{s}
are both real numbers, the result uses a Gaussian distribution with mean
@var{m} and standard deviation
! @texline @math{\sigma}.
@var{s}.
If @expr{M} is an interval form, the lower and upper bounds specify the
***************
*** 18858,18864 ****
If @code{RandSeed} contains an integer, Calc uses this integer to
seed an ``additive congruential'' method (Knuth's algorithm 3.2.2A,
computing
! @texline @tmath{X_{n-55} - X_{n-24}}.
@infoline @expr{X_n-55 - X_n-24}).
This method expands the seed
value into a large table which is maintained internally; the variable
--- 18851,18857 ----
If @code{RandSeed} contains an integer, Calc uses this integer to
seed an ``additive congruential'' method (Knuth's algorithm 3.2.2A,
computing
! @texline @math{X_{n-55} - X_{n-24}}.
@infoline @expr{X_n-55 - X_n-24}).
This method expands the seed
value into a large table which is maintained internally; the variable
***************
*** 18894,18913 ****
To create a random floating-point number with precision @var{p}, Calc
simply creates a random @var{p}-digit integer and multiplies by
! @texline @tmath{10^{-p}}.
@infoline @expr{10^-p}.
The resulting random numbers should be very clean, but note
that relatively small numbers will have few significant random digits.
In other words, with a precision of 12, you will occasionally get
numbers on the order of
! @texline @tmath{10^{-9}}
@infoline @expr{10^-9}
or
! @texline @tmath{10^{-10}},
@infoline @expr{10^-10},
but those numbers will only have two or three random digits since they
correspond to small integers times
! @texline @tmath{10^{-12}}.
@infoline @expr{10^-12}.
To create a random integer in the interval @samp{[0 .. @var{m})}, Calc
--- 18887,18906 ----
To create a random floating-point number with precision @var{p}, Calc
simply creates a random @var{p}-digit integer and multiplies by
! @texline @math{10^{-p}}.
@infoline @expr{10^-p}.
The resulting random numbers should be very clean, but note
that relatively small numbers will have few significant random digits.
In other words, with a precision of 12, you will occasionally get
numbers on the order of
! @texline @math{10^{-9}}
@infoline @expr{10^-9}
or
! @texline @math{10^{-10}},
@infoline @expr{10^-10},
but those numbers will only have two or three random digits since they
correspond to small integers times
! @texline @math{10^{-12}}.
@infoline @expr{10^-12}.
To create a random integer in the interval @samp{[0 .. @var{m})}, Calc
***************
*** 18958,18964 ****
The @kbd{k E} (@code{calc-extended-gcd}) address@hidden command computes
the GCD of two integers @expr{x} and @expr{y} and returns a vector
@expr{[g, a, b]} where
! @texline @tmath{g = \gcd(x,y) = a x + b y}.
@infoline @expr{g = gcd(x,y) = a x + b y}.
@kindex !
--- 18951,18957 ----
The @kbd{k E} (@code{calc-extended-gcd}) address@hidden command computes
the GCD of two integers @expr{x} and @expr{y} and returns a vector
@expr{[g, a, b]} where
! @texline @math{g = \gcd(x,y) = a x + b y}.
@infoline @expr{g = gcd(x,y) = a x + b y}.
@kindex !
***************
*** 19002,19008 ****
are integers, the result is an exact integer. Otherwise, the result is a
floating-point approximation. The binomial coefficient is defined for all
real numbers by
! @texline @tmath{N! \over M! (N-M)!\,}.
@infoline @expr{N! / M! (N-M)!}.
@kindex H k c
--- 18995,19001 ----
are integers, the result is an exact integer. Otherwise, the result is a
floating-point approximation. The binomial coefficient is defined for all
real numbers by
! @texline @math{N! \over M! (N-M)!\,}.
@infoline @expr{N! / M! (N-M)!}.
@kindex H k c
***************
*** 19045,19055 ****
@tindex stir2
The @kbd{k s} (@code{calc-stirling-number}) address@hidden command
computes a Stirling number of the first
! @texline address@hidden@tmath{n \brack m},
@infoline kind,
given two integers @expr{n} and @expr{m} on the stack. The @kbd{H k s}
address@hidden command computes a Stirling number of the second
! @texline address@hidden@tmath{n \brace m}.
@infoline kind.
These are the number of @expr{m}-cycle permutations of @expr{n} objects,
and the number of ways to partition @expr{n} objects into @expr{m}
--- 19038,19048 ----
@tindex stir2
The @kbd{k s} (@code{calc-stirling-number}) address@hidden command
computes a Stirling number of the first
! @texline address@hidden@math{n \brack m},
@infoline kind,
given two integers @expr{n} and @expr{m} on the stack. The @kbd{H k s}
address@hidden command computes a Stirling number of the second
! @texline address@hidden@math{n \brace m}.
@infoline kind.
These are the number of @expr{m}-cycle permutations of @expr{n} objects,
and the number of ways to partition @expr{n} objects into @expr{m}
***************
*** 19093,19100 ****
inputs, prime factors above 5000 may not be found, in which case the
last number in the vector will be an unfactored integer greater than 25
million (with a warning message). For negative integers, the first
! element of the list will be @i{-1}. For inputs @i{-1}, @i{0}, and
! @i{1}, the result is a list of the same number.
@kindex k n
@pindex calc-next-prime
--- 19086,19093 ----
inputs, prime factors above 5000 may not be found, in which case the
last number in the vector will be an unfactored integer greater than 25
million (with a warning message). For negative integers, the first
! element of the list will be @mathit{-1}. For inputs @mathit{-1}, @mathit{0},
and
! @mathit{1}, the result is a list of the same number.
@kindex k n
@pindex calc-next-prime
***************
*** 19128,19134 ****
@tindex totient
The @kbd{k t} (@code{calc-totient}) address@hidden command computes the
Euler ``totient''
! @texline address@hidden@tmath{\phi(n)},
@infoline function,
the number of integers less than @expr{n} which
are relatively prime to @expr{n}.
--- 19121,19127 ----
@tindex totient
The @kbd{k t} (@code{calc-totient}) address@hidden command computes the
Euler ``totient''
! @texline address@hidden@math{\phi(n)},
@infoline function,
the number of integers less than @expr{n} which
are relatively prime to @expr{n}.
***************
*** 19137,19143 ****
@pindex calc-moebius
@tindex moebius
The @kbd{k m} (@code{calc-moebius}) address@hidden command computes the
! @texline M@"obius @tmath{\mu}
@infoline Moebius ``mu''
function. If the input number is a product of @expr{k}
distinct factors, this is @expr{(-1)^k}. If the input number has any
--- 19130,19136 ----
@pindex calc-moebius
@tindex moebius
The @kbd{k m} (@code{calc-moebius}) address@hidden command computes the
! @texline M@"obius @math{\mu}
@infoline Moebius ``mu''
function. If the input number is a product of @expr{k}
distinct factors, this is @expr{(-1)^k}. If the input number has any
***************
*** 19201,19207 ****
@end ignore
@tindex ltpc
The @samp{utpc(x,v)} function uses the chi-square distribution with
! @texline @tmath{\nu}
@infoline @expr{v}
degrees of freedom. It is the probability that a model is
correct if its chi-square statistic is @expr{x}.
--- 19194,19200 ----
@end ignore
@tindex ltpc
The @samp{utpc(x,v)} function uses the chi-square distribution with
! @texline @math{\nu}
@infoline @expr{v}
degrees of freedom. It is the probability that a model is
correct if its chi-square statistic is @expr{x}.
***************
*** 19219,19228 ****
@tindex ltpf
The @samp{utpf(F,v1,v2)} function uses the F distribution, used in
various statistical tests. The parameters
! @texline @tmath{\nu_1}
@infoline @expr{v1}
and
! @texline @tmath{\nu_2}
@infoline @expr{v2}
are the degrees of freedom in the numerator and denominator,
respectively, used in computing the statistic @expr{F}.
--- 19212,19221 ----
@tindex ltpf
The @samp{utpf(F,v1,v2)} function uses the F distribution, used in
various statistical tests. The parameters
! @texline @math{\nu_1}
@infoline @expr{v1}
and
! @texline @math{\nu_2}
@infoline @expr{v2}
are the degrees of freedom in the numerator and denominator,
respectively, used in computing the statistic @expr{F}.
***************
*** 19240,19246 ****
@tindex ltpn
The @samp{utpn(x,m,s)} function uses a normal (Gaussian) distribution
with mean @expr{m} and standard deviation
! @texline @tmath{\sigma}.
@infoline @expr{s}.
It is the probability that such a normal-distributed random variable
would exceed @expr{x}.
--- 19233,19239 ----
@tindex ltpn
The @samp{utpn(x,m,s)} function uses a normal (Gaussian) distribution
with mean @expr{m} and standard deviation
! @texline @math{\sigma}.
@infoline @expr{s}.
It is the probability that such a normal-distributed random variable
would exceed @expr{x}.
***************
*** 19273,19290 ****
@tindex ltpt
The @samp{utpt(t,v)} function uses the Student's ``t'' distribution
with
! @texline @tmath{\nu}
@infoline @expr{v}
degrees of freedom. It is the probability that a
t-distributed random variable will be greater than @expr{t}.
(Note: This computes the distribution function
! @texline @tmath{A(t|\nu)}
@infoline @expr{A(t|v)}
where
! @texline @tmath{A(0|\nu) = 1}
@infoline @expr{A(0|v) = 1}
and
! @texline @tmath{A(\infty|\nu) \to 0}.
@infoline @expr{A(inf|v) -> 0}.
The @code{UTPT} operation on the HP-48 uses a different definition which
returns half of Calc's value: @samp{UTPT(t,v) = .5*utpt(t,v)}.)
--- 19266,19283 ----
@tindex ltpt
The @samp{utpt(t,v)} function uses the Student's ``t'' distribution
with
! @texline @math{\nu}
@infoline @expr{v}
degrees of freedom. It is the probability that a
t-distributed random variable will be greater than @expr{t}.
(Note: This computes the distribution function
! @texline @math{A(t|\nu)}
@infoline @expr{A(t|v)}
where
! @texline @math{A(0|\nu) = 1}
@infoline @expr{A(0|v) = 1}
and
! @texline @math{A(\infty|\nu) \to 0}.
@infoline @expr{A(inf|v) -> 0}.
The @code{UTPT} operation on the HP-48 uses a different definition which
returns half of Calc's value: @samp{UTPT(t,v) = .5*utpt(t,v)}.)
***************
*** 19404,19411 ****
times ten to the power of the exponent.
@item -12
! This is treated the same as @i{-11} by the @kbd{v p} command.
! When unpacking, @i{-12} specifies that a floating-point mantissa
is desired.
@item -13
--- 19397,19404 ----
times ten to the power of the exponent.
@item -12
! This is treated the same as @mathit{-11} by the @kbd{v p} command.
! When unpacking, @mathit{-12} specifies that a floating-point mantissa
is desired.
@item -13
***************
*** 19444,19450 ****
If any elements of the vector are negative, other kinds of
packing are done at that level as described above. For
example, @samp{[2, 3, -4]} takes 12 objects and creates a
! @texline @tmath{2\times3}
@infoline 2x3
matrix of error forms: @samp{[[a +/- b, c +/- d ... ]]}.
Also, @samp{[-4, -10]} will convert four integers into an
--- 19437,19443 ----
If any elements of the vector are negative, other kinds of
packing are done at that level as described above. For
example, @samp{[2, 3, -4]} takes 12 objects and creates a
! @texline @math{2\times3}
@infoline 2x3
matrix of error forms: @samp{[[a +/- b, c +/- d ... ]]}.
Also, @samp{[-4, -10]} will convert four integers into an
***************
*** 19482,19499 ****
@samp{[a, c^2, d]} and @address@hidden, 0, 7]}}.
Note that the prefix argument can have an effect even when the input is
! not a vector. For example, if the input is the number @i{-5}, then
! @kbd{c-u -1 v u} yields @i{-5} and 0 (the components of @i{-5}
when viewed as a rectangular complex number); @kbd{C-u -2 v u} yields 5
! and 180 (assuming degrees mode); and @kbd{C-u -10 v u} yields @i{-5}
! and 1 (the numerator and denominator of @i{-5}, viewed as a rational
number). Plain @kbd{v u} with this input would complain that the input
is not a composite object.
! Unpacking mode @i{-11} converts a float into an integer mantissa and
an integer exponent, where the mantissa is not divisible by 10
(except that 0.0 is represented by a mantissa and exponent of 0).
! Unpacking mode @i{-12} converts a float into a floating-point mantissa
and integer exponent, where the mantissa (for non-zero numbers)
is guaranteed to lie in the range [1 .. 10). In both cases,
the mantissa is shifted left or right (and the exponent adjusted
--- 19475,19492 ----
@samp{[a, c^2, d]} and @address@hidden, 0, 7]}}.
Note that the prefix argument can have an effect even when the input is
! not a vector. For example, if the input is the number @mathit{-5}, then
! @kbd{c-u -1 v u} yields @mathit{-5} and 0 (the components of @mathit{-5}
when viewed as a rectangular complex number); @kbd{C-u -2 v u} yields 5
! and 180 (assuming degrees mode); and @kbd{C-u -10 v u} yields @mathit{-5}
! and 1 (the numerator and denominator of @mathit{-5}, viewed as a rational
number). Plain @kbd{v u} with this input would complain that the input
is not a composite object.
! Unpacking mode @mathit{-11} converts a float into an integer mantissa and
an integer exponent, where the mantissa is not divisible by 10
(except that 0.0 is represented by a mantissa and exponent of 0).
! Unpacking mode @mathit{-12} converts a float into a floating-point mantissa
and integer exponent, where the mantissa (for non-zero numbers)
is guaranteed to lie in the range [1 .. 10). In both cases,
the mantissa is shifted left or right (and the exponent adjusted
***************
*** 19593,19599 ****
the prefix argument is required.
To build a constant square matrix, e.g., a
! @texline @tmath{3\times3}
@infoline 3x3
matrix filled with ones, use @kbd{0 M-3 v d 1 +}, i.e., build a zero
matrix first and then add a constant value to that matrix. (Another
--- 19586,19592 ----
the prefix argument is required.
To build a constant square matrix, e.g., a
! @texline @math{3\times3}
@infoline 3x3
matrix filled with ones, use @kbd{0 M-3 v d 1 +}, i.e., build a zero
matrix first and then add a constant value to that matrix. (Another
***************
*** 19626,19632 ****
of consecutive integers from 1 to @var{n}, where @var{n} is the numeric
prefix argument. If you do not provide a prefix argument, you will be
prompted to enter a suitable number. If @var{n} is negative, the result
! is a vector of negative integers from @var{n} to @i{-1}.
With a prefix argument of just @kbd{C-u}, the @kbd{v x} command takes
three values from the stack: @var{n}, @var{start}, and @var{incr} (with
--- 19619,19625 ----
of consecutive integers from 1 to @var{n}, where @var{n} is the numeric
prefix argument. If you do not provide a prefix argument, you will be
prompted to enter a suitable number. If @var{n} is negative, the result
! is a vector of negative integers from @var{n} to @mathit{-1}.
With a prefix argument of just @kbd{C-u}, the @kbd{v x} command takes
three values from the stack: @var{n}, @var{start}, and @var{incr} (with
***************
*** 19819,19825 ****
of the dimensions of a vector, matrix, or higher-order object. For
example, @samp{mdims([[a,b,c],[d,e,f]])} returns @samp{[2, 3]} since
its argument is a
! @texline @tmath{2\times3}
@infoline 2x3
matrix.
--- 19812,19818 ----
of the dimensions of a vector, matrix, or higher-order object. For
example, @samp{mdims([[a,b,c],[d,e,f]])} returns @samp{[2, 3]} since
its argument is a
! @texline @math{2\times3}
@infoline 2x3
matrix.
***************
*** 19851,19863 ****
suitable for use as a matrix. For example, with the matrix
@samp{[[1, 2], @w{[3, 4]}]} on the stack, @kbd{v a 4} produces
@samp{[[1, 2, 3, 4]]} (a
! @texline @tmath{1\times4}
@infoline 1x4
matrix), @kbd{v a 1} produces @samp{[[1], [2], [3], [4]]} (a
! @texline @tmath{4\times1}
@infoline 4x1
matrix), @kbd{v a 2} produces @samp{[[1, 2], [3, 4]]} (the original
! @texline @tmath{2\times2}
@infoline 2x2
matrix), @address@hidden a 3}} produces @samp{[[1, 2, 3], [4]]} (not a
matrix), and @kbd{v a 0} produces the flattened list
--- 19844,19856 ----
suitable for use as a matrix. For example, with the matrix
@samp{[[1, 2], @w{[3, 4]}]} on the stack, @kbd{v a 4} produces
@samp{[[1, 2, 3, 4]]} (a
! @texline @math{1\times4}
@infoline 1x4
matrix), @kbd{v a 1} produces @samp{[[1], [2], [3], [4]]} (a
! @texline @math{4\times1}
@infoline 4x1
matrix), @kbd{v a 2} produces @samp{[[1, 2], [3, 4]]} (the original
! @texline @math{2\times2}
@infoline 2x2
matrix), @address@hidden a 3}} produces @samp{[[1, 2, 3], [4]]} (not a
matrix), and @kbd{v a 0} produces the flattened list
***************
*** 20177,20186 ****
will be the empty vector @samp{[]}. Note that the characters @kbd{V}
and @kbd{^} were chosen to be close to the conventional mathematical
notation for set
! @texline address@hidden(@tmath{A \cup B})
@infoline union
and
! @texline address@hidden(@tmath{A \cap B}).
@infoline intersection.
@kindex V -
--- 20170,20179 ----
will be the empty vector @samp{[]}. Note that the characters @kbd{V}
and @kbd{^} were chosen to be close to the conventional mathematical
notation for set
! @texline address@hidden(@math{A \cup B})
@infoline union
and
! @texline address@hidden(@math{A \cap B}).
@infoline intersection.
@kindex V -
***************
*** 20289,20295 ****
set of integers in the sense of @kbd{V F} (@code{vfloor}). Beware
that a simple input like @samp{[100]} can result in a huge integer
representation
! @texline (@tmath{2^{100}}, a 31-digit integer, in this case).
@infoline (@expr{2^100}, a 31-digit integer, in this case).
@node Statistical Operations, Reducing and Mapping, Set Operations, Matrix
Functions
--- 20282,20288 ----
set of integers in the sense of @kbd{V F} (@code{vfloor}). Beware
that a simple input like @samp{[100]} can result in a huge integer
representation
! @texline (@math{2^{100}}, a 31-digit integer, in this case).
@infoline (@expr{2^100}, a 31-digit integer, in this case).
@node Statistical Operations, Reducing and Mapping, Set Operations, Matrix
Functions
***************
*** 20401,20410 ****
The @kbd{u M} (@code{calc-vector-mean}) address@hidden command
computes the average (arithmetic mean) of the data values.
If the inputs are error forms
! @texline @tmath{x \pm \sigma},
@infoline @samp{x +/- s},
this is the weighted mean of the @expr{x} values with weights
! @texline @tmath{1 /\sigma^2}.
@infoline @expr{1 / s^2}.
@tex
\turnoffactive
--- 20394,20403 ----
The @kbd{u M} (@code{calc-vector-mean}) address@hidden command
computes the average (arithmetic mean) of the data values.
If the inputs are error forms
! @texline @math{x \pm \sigma},
@infoline @samp{x +/- s},
this is the weighted mean of the @expr{x} values with weights
! @texline @math{1 /\sigma^2}.
@infoline @expr{1 / s^2}.
@tex
\turnoffactive
***************
*** 20416,20422 ****
Note that a plain number can be considered an error form with
error
! @texline @tmath{\sigma = 0}.
@infoline @expr{s = 0}.
If the input to @kbd{u M} is a mixture of
plain numbers and error forms, the result is the mean of the
--- 20409,20415 ----
Note that a plain number can be considered an error form with
error
! @texline @math{\sigma = 0}.
@infoline @expr{s = 0}.
If the input to @kbd{u M} is a mixture of
plain numbers and error forms, the result is the mean of the
***************
*** 20525,20531 ****
@cindex Sample statistics
The @kbd{u S} (@code{calc-vector-sdev}) address@hidden command
computes the standard
! @texline address@hidden@tmath{\sigma}
@infoline deviation
of the data values. If the values are error forms, the errors are used
as weights just as for @kbd{u M}. This is the @emph{sample} standard
--- 20518,20524 ----
@cindex Sample statistics
The @kbd{u S} (@code{calc-vector-sdev}) address@hidden command
computes the standard
! @texline address@hidden@math{\sigma}
@infoline deviation
of the data values. If the values are error forms, the errors are used
as weights just as for @kbd{u M}. This is the @emph{sample} standard
***************
*** 20541,20547 ****
of a single error form is simply the error part. The standard deviation
of a continuous interval happens to equal the difference between the
limits, divided by
! @texline @tmath{\sqrt{12}}.
@infoline @expr{sqrt(12)}.
The standard deviation of an integer interval is the same as the
standard deviation of a vector of those integers.
--- 20534,20540 ----
of a single error form is simply the error part. The standard deviation
of a continuous interval happens to equal the difference between the
limits, divided by
! @texline @math{\sqrt{12}}.
@infoline @expr{sqrt(12)}.
The standard deviation of an integer interval is the same as the
standard deviation of a vector of those integers.
***************
*** 20579,20585 ****
@kbd{H I u S} (@code{calc-vector-pop-variance}) address@hidden
commands compute the variance of the data values. The variance
is the
! @texline address@hidden@tmath{\sigma^2}
@infoline square
of the standard deviation, i.e., the sum of the
squares of the deviations of the data values from the mean.
--- 20572,20578 ----
@kbd{H I u S} (@code{calc-vector-pop-variance}) address@hidden
commands compute the variance of the data values. The variance
is the
! @texline address@hidden@math{\sigma^2}
@infoline square
of the standard deviation, i.e., the sum of the
squares of the deviations of the data values from the mean.
***************
*** 20603,20609 ****
way as by the single-variable statistical functions. Given a numeric
prefix argument of 1, these functions instead take one object from
the stack, which must be an
! @texline @tmath{N\times2}
@infoline Nx2
matrix of data values. Once again, variable names can be used in place
of actual vectors and matrices.
--- 20596,20602 ----
way as by the single-variable statistical functions. Given a numeric
prefix argument of 1, these functions instead take one object from
the stack, which must be an
! @texline @math{N\times2}
@infoline Nx2
matrix of data values. Once again, variable names can be used in place
of actual vectors and matrices.
***************
*** 20861,20867 ****
across all elements of the matrix. For example, given the matrix
@expr{[[1, -2, 3], [-4, 5, -6]]}, @kbd{V M A} takes six absolute values to
produce another
! @texline @tmath{3\times2}
@infoline 3x2
matrix, @expr{[[1, 2, 3], [4, 5, 6]]}.
--- 20854,20860 ----
across all elements of the matrix. For example, given the matrix
@expr{[[1, -2, 3], [-4, 5, -6]]}, @kbd{V M A} takes six absolute values to
produce another
! @texline @math{3\times2}
@infoline 3x2
matrix, @expr{[[1, 2, 3], [4, 5, 6]]}.
***************
*** 22014,22020 ****
@kbd{a s}; @pxref{Simplifying Formulas}. If you give a numeric prefix
of 3 or more, it uses extended simplification mode (@kbd{a e}).
! If you give a negative prefix argument @i{-1}, @i{-2}, or @i{-3},
it simplifies in the corresponding mode but only works on the top-level
function call of the formula. For example, @samp{(2 + 3) * (2 + 3)} will
simplify to @samp{(2 + 3)^2}, without simplifying the sub-formulas
--- 22007,22013 ----
@kbd{a s}; @pxref{Simplifying Formulas}. If you give a numeric prefix
of 3 or more, it uses extended simplification mode (@kbd{a e}).
! If you give a negative prefix argument @mathit{-1}, @mathit{-2}, or
@mathit{-3},
it simplifies in the corresponding mode but only works on the top-level
function call of the formula. For example, @samp{(2 + 3) * (2 + 3)} will
simplify to @samp{(2 + 3)^2}, without simplifying the sub-formulas
***************
*** 22286,22292 ****
The distributive law is used to simplify sums in some cases:
@expr{a x + b x} to @expr{(a + b) x}, where @expr{a} represents
! a number or an implicit 1 or @i{-1} (as in @expr{x} or @expr{-x})
and similarly for @expr{b}. Use the @kbd{a c}, @address@hidden f}}, or
@kbd{j M} commands to merge sums with non-numeric coefficients
using the distributive law.
--- 22279,22285 ----
The distributive law is used to simplify sums in some cases:
@expr{a x + b x} to @expr{(a + b) x}, where @expr{a} represents
! a number or an implicit 1 or @mathit{-1} (as in @expr{x} or @expr{-x})
and similarly for @expr{b}. Use the @kbd{a c}, @address@hidden f}}, or
@kbd{j M} commands to merge sums with non-numeric coefficients
using the distributive law.
***************
*** 22330,22336 ****
The distributive law of products and powers is used for adjacent
terms of the product: @expr{x^a x^b} goes to
! @texline @tmath{x^{a+b}}
@infoline @expr{x^(a+b)}
where @expr{a} is a number, or an implicit 1 (as in @expr{x}),
or the implicit one-half of @address@hidden(x)}, and similarly for
--- 22323,22329 ----
The distributive law of products and powers is used for adjacent
terms of the product: @expr{x^a x^b} goes to
! @texline @math{x^{a+b}}
@infoline @expr{x^(a+b)}
where @expr{a} is a number, or an implicit 1 (as in @expr{x}),
or the implicit one-half of @address@hidden(x)}, and similarly for
***************
*** 22341,22347 ****
The product of a negative power times anything but another negative
power is changed to use division:
! @texline @tmath{x^{-2} y}
@infoline @expr{x^(-2) y}
goes to @expr{y / x^2} unless matrix mode is
in effect and neither @expr{x} nor @expr{y} are scalar (in which
--- 22334,22340 ----
The product of a negative power times anything but another negative
power is changed to use division:
! @texline @math{x^{-2} y}
@infoline @expr{x^(-2) y}
goes to @expr{y / x^2} unless matrix mode is
in effect and neither @expr{x} nor @expr{y} are scalar (in which
***************
*** 22365,22375 ****
@xref{Infinite Mode}.
The expression
! @texline @tmath{a / b^{-c}}
@infoline @expr{a / b^(-c)}
is changed to @expr{a b^c}, where @expr{-c} is any negative-looking
power. Also, @expr{1 / b^c} is changed to
! @texline @tmath{b^{-c}}
@infoline @expr{b^(-c)}
for any power @expr{c}.
--- 22358,22368 ----
@xref{Infinite Mode}.
The expression
! @texline @math{a / b^{-c}}
@infoline @expr{a / b^(-c)}
is changed to @expr{a b^c}, where @expr{-c} is any negative-looking
power. Also, @expr{1 / b^c} is changed to
! @texline @math{b^{-c}}
@infoline @expr{b^(-c)}
for any power @expr{c}.
***************
*** 22410,22431 ****
are distributed to @expr{a^c b^c}, @expr{a^c / b^c} only if @expr{c}
is an integer, or if either @expr{a} or @expr{b} are nonnegative
real numbers. Powers of powers @expr{(a^b)^c} are simplified to
! @texline @tmath{a^{b c}}
@infoline @expr{a^(b c)}
only when @expr{c} is an integer and @expr{b c} also
evaluates to an integer. Without these restrictions these simplifications
would not be safe because of problems with principal values.
(In other words,
! @texline @tmath{((-3)^{1/2})^2}
@infoline @expr{((-3)^1:2)^2}
is safe to simplify, but
! @texline @tmath{((-3)^2)^{1/2}}
@infoline @expr{((-3)^2)^1:2}
is not.) @xref{Declarations}, for ways to inform Calc that your
variables satisfy these requirements.
As a special case of this rule, @address@hidden(x)^n} is simplified to
! @texline @tmath{x^{n/2}}
@infoline @expr{x^(n/2)}
only for even integers @expr{n}.
--- 22403,22424 ----
are distributed to @expr{a^c b^c}, @expr{a^c / b^c} only if @expr{c}
is an integer, or if either @expr{a} or @expr{b} are nonnegative
real numbers. Powers of powers @expr{(a^b)^c} are simplified to
! @texline @math{a^{b c}}
@infoline @expr{a^(b c)}
only when @expr{c} is an integer and @expr{b c} also
evaluates to an integer. Without these restrictions these simplifications
would not be safe because of problems with principal values.
(In other words,
! @texline @math{((-3)^{1/2})^2}
@infoline @expr{((-3)^1:2)^2}
is safe to simplify, but
! @texline @math{((-3)^2)^{1/2}}
@infoline @expr{((-3)^2)^1:2}
is not.) @xref{Declarations}, for ways to inform Calc that your
variables satisfy these requirements.
As a special case of this rule, @address@hidden(x)^n} is simplified to
! @texline @math{x^{n/2}}
@infoline @expr{x^(n/2)}
only for even integers @expr{n}.
***************
*** 22438,22452 ****
for any negative-looking expression @expr{-a}.
Square roots @address@hidden(x)} generally act like one-half powers
! @texline @tmath{x^{1:2}}
@infoline @expr{x^1:2}
for the purposes of the above-listed simplifications.
Also, note that
! @texline @tmath{1 / x^{1:2}}
@infoline @expr{1 / x^1:2}
is changed to
! @texline @tmath{x^{-1:2}},
@infoline @expr{x^(-1:2)},
but @expr{1 / @t{sqrt}(x)} is left alone.
--- 22431,22445 ----
for any negative-looking expression @expr{-a}.
Square roots @address@hidden(x)} generally act like one-half powers
! @texline @math{x^{1:2}}
@infoline @expr{x^1:2}
for the purposes of the above-listed simplifications.
Also, note that
! @texline @math{1 / x^{1:2}}
@infoline @expr{1 / x^1:2}
is changed to
! @texline @math{x^{-1:2}},
@infoline @expr{x^(-1:2)},
but @expr{1 / @t{sqrt}(x)} is left alone.
***************
*** 22589,22595 ****
A subtle point is that @expr{(x - y) (y - x)} will @emph{not}
be simplified to @expr{-(x - y)^2}; Calc does not notice that
one term can be written as a constant times the other, even if
! that constant is @i{-1}.
A fraction times any expression, @expr{(a:b) x}, is changed to
a quotient involving integers: @expr{a x / b}. This is not
--- 22582,22588 ----
A subtle point is that @expr{(x - y) (y - x)} will @emph{not}
be simplified to @expr{-(x - y)^2}; Calc does not notice that
one term can be written as a constant times the other, even if
! that constant is @mathit{-1}.
A fraction times any expression, @expr{(a:b) x}, is changed to
a quotient involving integers: @expr{a x / b}. This is not
***************
*** 22632,22638 ****
several ways. (Note that these will be left unevaluated only in
Symbolic mode.) First, square integer or rational factors are
pulled out so that @address@hidden(8)} is rewritten as
! @texline @tmath{$2\,\t{sqrt}(2)$}.
@infoline @expr{2 sqrt(2)}.
Conceptually speaking this implies factoring the argument into primes
and moving pairs of primes out of the square root, but for reasons of
--- 22625,22631 ----
several ways. (Note that these will be left unevaluated only in
Symbolic mode.) First, square integer or rational factors are
pulled out so that @address@hidden(8)} is rewritten as
! @texline @math{2\,\t{sqrt}(2)}.
@infoline @expr{2 sqrt(2)}.
Conceptually speaking this implies factoring the argument into primes
and moving pairs of primes out of the square root, but for reasons of
***************
*** 22694,22716 ****
@code{arctan}, @code{arcsinh}, and @code{arctanh}. Note that
@address@hidden(@t{sin}(x))} can @emph{not} safely change to
@expr{x}, since this only correct within an integer multiple of
! @texline @tmath{2 \pi}
@infoline @expr{2 pi}
radians or 360 degrees. However, @address@hidden(@t{sinh}(x))} is
simplified to @expr{x} if @expr{x} is known to be real.
Several simplifications that apply to logarithms and exponentials
are that @address@hidden(@t{ln}(x))},
! @texline @address@hidden(x)}},
@infoline @address@hidden(x)},
and
! @texline @tmath{10^{{\rm log10}(x)}}
@infoline @address@hidden(x)}
all reduce to @expr{x}. Also, @address@hidden(@t{exp}(x))}, etc., can
reduce to @expr{x} if @expr{x} is provably real. The form
@address@hidden(x)^y} is simplified to @address@hidden(x y)}. If @expr{x}
is a suitable multiple of
! @texline @tmath{\pi i}
@infoline @expr{pi i}
(as described above for the trigonometric functions), then
@address@hidden(x)} or @expr{e^x} will be expanded. Finally,
--- 22687,22709 ----
@code{arctan}, @code{arcsinh}, and @code{arctanh}. Note that
@address@hidden(@t{sin}(x))} can @emph{not} safely change to
@expr{x}, since this only correct within an integer multiple of
! @texline @math{2 \pi}
@infoline @expr{2 pi}
radians or 360 degrees. However, @address@hidden(@t{sinh}(x))} is
simplified to @expr{x} if @expr{x} is known to be real.
Several simplifications that apply to logarithms and exponentials
are that @address@hidden(@t{ln}(x))},
! @texline @address@hidden(x)}},
@infoline @address@hidden(x)},
and
! @texline @math{10^{{\rm log10}(x)}}
@infoline @address@hidden(x)}
all reduce to @expr{x}. Also, @address@hidden(@t{exp}(x))}, etc., can
reduce to @expr{x} if @expr{x} is provably real. The form
@address@hidden(x)^y} is simplified to @address@hidden(x y)}. If @expr{x}
is a suitable multiple of
! @texline @math{\pi i}
@infoline @expr{pi i}
(as described above for the trigonometric functions), then
@address@hidden(x)} or @expr{e^x} will be expanded. Finally,
***************
*** 22795,22812 ****
functions always produce.
Powers of powers @expr{(x^a)^b} are simplified to
! @texline @tmath{x^{a b}}
@infoline @expr{x^(a b)}
for all @expr{a} and @expr{b}. These results will be valid only
in a restricted range of @expr{x}; for example, in
! @texline @tmath{(x^2)^{1:2}}
@infoline @expr{(x^2)^1:2}
the powers cancel to get @expr{x}, which is valid for positive values
of @expr{x} but not for negative or complex values.
Similarly, @address@hidden(x^a)} and @address@hidden(x)^a} are both
simplified (possibly unsafely) to
! @texline @tmath{x^{a/2}}.
@infoline @expr{x^(a/2)}.
Forms like @address@hidden(1 - sin(x)^2)} are simplified to, e.g.,
--- 22788,22805 ----
functions always produce.
Powers of powers @expr{(x^a)^b} are simplified to
! @texline @math{x^{a b}}
@infoline @expr{x^(a b)}
for all @expr{a} and @expr{b}. These results will be valid only
in a restricted range of @expr{x}; for example, in
! @texline @math{(x^2)^{1:2}}
@infoline @expr{(x^2)^1:2}
the powers cancel to get @expr{x}, which is valid for positive values
of @expr{x} but not for negative or complex values.
Similarly, @address@hidden(x^a)} and @address@hidden(x)^a} are both
simplified (possibly unsafely) to
! @texline @math{x^{a/2}}.
@infoline @expr{x^(a/2)}.
Forms like @address@hidden(1 - sin(x)^2)} are simplified to, e.g.,
***************
*** 22882,22888 ****
For powers and square roots, the ``unsafe'' simplifications
@expr{(a b)^c} to @expr{a^c b^c}, @expr{(a/b)^c} to @expr{a^c / b^c},
and @expr{(a^b)^c} to
! @texline @tmath{a^{b c}}
@infoline @expr{a^(b c)}
are done if the powers are real numbers. (These are safe in the context
of units because all numbers involved can reasonably be assumed to be
--- 22875,22881 ----
For powers and square roots, the ``unsafe'' simplifications
@expr{(a b)^c} to @expr{a^c b^c}, @expr{(a/b)^c} to @expr{a^c / b^c},
and @expr{(a^b)^c} to
! @texline @math{a^{b c}}
@infoline @expr{a^(b c)}
are done if the powers are real numbers. (These are safe in the context
of units because all numbers involved can reasonably be assumed to be
***************
*** 22897,22906 ****
is defined in terms of @samp{m^2}, and that the 2 in the power of
@code{m} is a multiple of 2 in @expr{3:2}. Thus, @code{acre^1.5} is
replaced by approximately
! @texline @tmath{(4046 m^2)^{1.5}}
@infoline @expr{(4046 m^2)^1.5},
which is then changed to
! @texline @tmath{4046^{1.5} \, (m^2)^{1.5}},
@infoline @expr{4046^1.5 (m^2)^1.5},
then to @expr{257440 m^3}.
--- 22890,22899 ----
is defined in terms of @samp{m^2}, and that the 2 in the power of
@code{m} is a multiple of 2 in @expr{3:2}. Thus, @code{acre^1.5} is
replaced by approximately
! @texline @math{(4046 m^2)^{1.5}}
@infoline @expr{(4046 m^2)^1.5},
which is then changed to
! @texline @math{4046^{1.5} \, (m^2)^{1.5}},
@infoline @expr{4046^1.5 (m^2)^1.5},
then to @expr{257440 m^3}.
***************
*** 23190,23196 ****
If you use the @code{deriv} function directly in an algebraic formula,
you can write @samp{deriv(f,x,x0)} which represents the derivative
of @expr{f} with respect to @expr{x}, evaluated at the point
! @texline @tmath{x=x_0}.
@infoline @expr{x=x0}.
If the formula being differentiated contains functions which Calc does
--- 23183,23189 ----
If you use the @code{deriv} function directly in an algebraic formula,
you can write @samp{deriv(f,x,x0)} which represents the derivative
of @expr{f} with respect to @expr{x}, evaluated at the point
! @texline @math{x=x_0}.
@infoline @expr{x=x0}.
If the formula being differentiated contains functions which Calc does
***************
*** 23230,23236 ****
classes of formulas. In particular, any polynomial or rational function
(a polynomial divided by a polynomial) is acceptable. (Rational functions
don't have to be in explicit quotient form, however;
! @texline @tmath{x/(1+x^{-2})}
@infoline @expr{x/(1+x^-2)}
is not strictly a quotient of polynomials, but it is equivalent to
@expr{x^3/(x^2+1)}, which is.) Also, square roots of terms involving
--- 23223,23229 ----
classes of formulas. In particular, any polynomial or rational function
(a polynomial divided by a polynomial) is acceptable. (Rational functions
don't have to be in explicit quotient form, however;
! @texline @math{x/(1+x^{-2})}
@infoline @expr{x/(1+x^-2)}
is not strictly a quotient of polynomials, but it is equivalent to
@expr{x^3/(x^2+1)}, which is.) Also, square roots of terms involving
***************
*** 23256,23262 ****
Please note that the current implementation of Calc's integrator sometimes
produces results that are significantly more complex than they need to
be. For example, the integral Calc finds for
! @texline @tmath{1/(x+\sqrt{x^2+1})}
@infoline @expr{1/(x+sqrt(x^2+1))}
is several times more complicated than the answer Mathematica
returns for the same input, although the two forms are numerically
--- 23249,23255 ----
Please note that the current implementation of Calc's integrator sometimes
produces results that are significantly more complex than they need to
be. For example, the integral Calc finds for
! @texline @math{1/(x+\sqrt{x^2+1})}
@infoline @expr{1/(x+sqrt(x^2+1))}
is several times more complicated than the answer Mathematica
returns for the same input, although the two forms are numerically
***************
*** 23264,23274 ****
an arbitrary constant of integration added to it, although Calc does not
write an explicit constant of integration in its result. For example,
Calc's solution for
! @texline @tmath{1/(1+\tan x)}
@infoline @expr{1/(1+tan(x))}
differs from the solution given in the @emph{CRC Math Tables} by a
constant factor of
! @texline @tmath{\pi i / 2}
@infoline @expr{pi i / 2},
due to a different choice of constant of integration.
--- 23257,23267 ----
an arbitrary constant of integration added to it, although Calc does not
write an explicit constant of integration in its result. For example,
Calc's solution for
! @texline @math{1/(1+\tan x)}
@infoline @expr{1/(1+tan(x))}
differs from the solution given in the @emph{CRC Math Tables} by a
constant factor of
! @texline @math{\pi i / 2}
@infoline @expr{pi i / 2},
due to a different choice of constant of integration.
***************
*** 23328,23334 ****
As a more serious example, the expression @samp{exp(x)/x} cannot be
integrated in terms of the standard functions, so the ``exponential
integral'' function
! @texline @tmath{{\rm Ei}(x)}
@infoline @expr{Ei(x)}
was invented to describe it.
We can get Calc to do this integral in terms of a made-up @code{Ei}
--- 23321,23327 ----
As a more serious example, the expression @samp{exp(x)/x} cannot be
integrated in terms of the standard functions, so the ``exponential
integral'' function
! @texline @math{{\rm Ei}(x)}
@infoline @expr{Ei(x)}
was invented to describe it.
We can get Calc to do this integral in terms of a made-up @code{Ei}
***************
*** 23501,23516 ****
This command also works for inequalities, as in @expr{y < 3x + 6}.
Some inequalities cannot be solved where the analogous equation could
be; for example, solving
! @texline @tmath{a < b \, c}
@infoline @expr{a < b c}
for @expr{b} is impossible
without knowing the sign of @expr{c}. In this case, @kbd{a S} will
produce the result
! @texline @tmath{b \mathbin{\hbox{\code{!=}}} a/c}
@infoline @expr{b != a/c}
(using the not-equal-to operator) to signify that the direction of the
inequality is now unknown. The inequality
! @texline @tmath{a \le b \, c}
@infoline @expr{a <= b c}
is not even partially solved. @xref{Declarations}, for a way to tell
Calc that the signs of the variables in a formula are in fact known.
--- 23494,23509 ----
This command also works for inequalities, as in @expr{y < 3x + 6}.
Some inequalities cannot be solved where the analogous equation could
be; for example, solving
! @texline @math{a < b \, c}
@infoline @expr{a < b c}
for @expr{b} is impossible
without knowing the sign of @expr{c}. In this case, @kbd{a S} will
produce the result
! @texline @math{b \mathbin{\hbox{\code{!=}}} a/c}
@infoline @expr{b != a/c}
(using the not-equal-to operator) to signify that the direction of the
inequality is now unknown. The inequality
! @texline @math{a \le b \, c}
@infoline @expr{a <= b c}
is not even partially solved. @xref{Declarations}, for a way to tell
Calc that the signs of the variables in a formula are in fact known.
***************
*** 23537,23543 ****
general family of solutions. It will invent variables @code{n1},
@code{n2}, @dots{}, which represent independent arbitrary integers, and
@code{s1}, @code{s2}, @dots{}, which represent independent arbitrary
! signs (either @i{+1} or @i{-1}). If you don't use the Hyperbolic
flag, Calc will use zero in place of all arbitrary integers, and plus
one in place of all arbitrary signs. Note that variables like @code{n1}
and @code{s1} are not given any special interpretation in Calc except by
--- 23530,23536 ----
general family of solutions. It will invent variables @code{n1},
@code{n2}, @dots{}, which represent independent arbitrary integers, and
@code{s1}, @code{s2}, @dots{}, which represent independent arbitrary
! signs (either @mathit{+1} or @mathit{-1}). If you don't use the Hyperbolic
flag, Calc will use zero in place of all arbitrary integers, and plus
one in place of all arbitrary signs. Note that variables like @code{n1}
and @code{s1} are not given any special interpretation in Calc except by
***************
*** 23970,23980 ****
Note that this command looks for a @emph{local} minimum. Many functions
have more than one minimum; some, like
! @texline @tmath{x \sin x},
@infoline @expr{x sin(x)},
have infinitely many. In fact, there is no easy way to define the
``global'' minimum of
! @texline @tmath{x \sin x}
@infoline @expr{x sin(x)}
but Calc can still locate any particular local minimum
for you. Calc basically goes downhill from the initial guess until it
--- 23963,23973 ----
Note that this command looks for a @emph{local} minimum. Many functions
have more than one minimum; some, like
! @texline @math{x \sin x},
@infoline @expr{x sin(x)},
have infinitely many. In fact, there is no easy way to define the
``global'' minimum of
! @texline @math{x \sin x}
@infoline @expr{x sin(x)}
but Calc can still locate any particular local minimum
for you. Calc basically goes downhill from the initial guess until it
***************
*** 24097,24103 ****
The @kbd{a F} command takes the data set to be fitted from the stack.
By default, it expects the data in the form of a matrix. For example,
for a linear or polynomial fit, this would be a
! @texline @tmath{2\times N}
@infoline 2xN
matrix where the first row is a list of @expr{x} values and the second
row has the corresponding @expr{y} values. For the multilinear fit
--- 24090,24096 ----
The @kbd{a F} command takes the data set to be fitted from the stack.
By default, it expects the data in the form of a matrix. For example,
for a linear or polynomial fit, this would be a
! @texline @math{2\times N}
@infoline 2xN
matrix where the first row is a list of @expr{x} values and the second
row has the corresponding @expr{y} values. For the multilinear fit
***************
*** 24105,24114 ****
@expr{x_3}, and @expr{y}, respectively).
If you happen to have an
! @texline @tmath{N\times2}
@infoline Nx2
matrix instead of a
! @texline @tmath{2\times N}
@infoline 2xN
matrix, just press @kbd{v t} first to transpose the matrix.
--- 24098,24107 ----
@expr{x_3}, and @expr{y}, respectively).
If you happen to have an
! @texline @math{N\times2}
@infoline Nx2
matrix instead of a
! @texline @math{2\times N}
@infoline 2xN
matrix, just press @kbd{v t} first to transpose the matrix.
***************
*** 24206,24216 ****
and increases as various @expr{a + b x_i} values fail to match the
corresponding @expr{y_i} values. There are several reasons why the
summand is squared, one of them being to ensure that
! @texline @tmath{\chi^2 \ge 0}.
@infoline @expr{chi^2 >= 0}.
Least-squares fitting simply chooses the values of @expr{a} and @expr{b}
for which the error
! @texline @tmath{\chi^2}
@infoline @expr{chi^2}
is as small as possible.
--- 24199,24209 ----
and increases as various @expr{a + b x_i} values fail to match the
corresponding @expr{y_i} values. There are several reasons why the
summand is squared, one of them being to ensure that
! @texline @math{\chi^2 \ge 0}.
@infoline @expr{chi^2 >= 0}.
Least-squares fitting simply chooses the values of @expr{a} and @expr{b}
for which the error
! @texline @math{\chi^2}
@infoline @expr{chi^2}
is as small as possible.
***************
*** 24266,24272 ****
An important result from the theory of polynomial fitting is that it
is always possible to fit @var{n} data points exactly using a polynomial
! of degree @address@hidden, sometimes called an @dfn{interpolating polynomial}.
Using the modified (14) data matrix, a model number of 4 gives
a polynomial that exactly matches all five data points:
--- 24259,24265 ----
An important result from the theory of polynomial fitting is that it
is always possible to fit @var{n} data points exactly using a polynomial
! of degree @address@hidden, sometimes called an @dfn{interpolating polynomial}.
Using the modified (14) data matrix, a model number of 4 gives
a polynomial that exactly matches all five data points:
***************
*** 24371,24380 ****
or all be plain numbers. Error forms can go anywhere but generally
go on the numbers in the last row of the data matrix. If the last
row contains error forms
! @texline address@hidden@w{ @t{+/-} address@hidden',
@infoline address@hidden@w{ @t{+/-} address@hidden',
then the
! @texline @tmath{\chi^2}
@infoline @expr{chi^2}
statistic is now,
--- 24364,24373 ----
or all be plain numbers. Error forms can go anywhere but generally
go on the numbers in the last row of the data matrix. If the last
row contains error forms
! @texline address@hidden@w{ @t{+/-} address@hidden',
@infoline address@hidden@w{ @t{+/-} address@hidden',
then the
! @texline @math{\chi^2}
@infoline @expr{chi^2}
statistic is now,
***************
*** 24397,24403 ****
If there are error forms on other rows of the data matrix, all the
errors for a given data point are combined; the square root of the
sum of the squares of the errors forms the
! @texline @tmath{\sigma_i}
@infoline @expr{sigma_i}
used for the data point.
--- 24390,24396 ----
If there are error forms on other rows of the data matrix, all the
errors for a given data point are combined; the square root of the
sum of the squares of the errors forms the
! @texline @math{\sigma_i}
@infoline @expr{sigma_i}
used for the data point.
***************
*** 24407,24420 ****
estimates.
If the input contains error forms but all the
! @texline @tmath{\sigma_i}
@infoline @expr{sigma_i}
values are the same, it is easy to see that the resulting fitted model
will be the same as if the input did not have error forms at all
! @texline (@tmath{\chi^2}
@infoline (@expr{chi^2}
is simply scaled uniformly by
! @texline @tmath{1 / \sigma^2},
@infoline @expr{1 / sigma^2},
which doesn't affect where it has a minimum). But there @emph{will} be
a difference in the estimated errors of the coefficients reported by
--- 24400,24413 ----
estimates.
If the input contains error forms but all the
! @texline @math{\sigma_i}
@infoline @expr{sigma_i}
values are the same, it is easy to see that the resulting fitted model
will be the same as if the input did not have error forms at all
! @texline (@math{\chi^2}
@infoline (@expr{chi^2}
is simply scaled uniformly by
! @texline @math{1 / \sigma^2},
@infoline @expr{1 / sigma^2},
which doesn't affect where it has a minimum). But there @emph{will} be
a difference in the estimated errors of the coefficients reported by
***************
*** 24449,24468 ****
@item
The covariance matrix @expr{C} computed from the fit. This is
an @address@hidden symmetric matrix; the diagonal elements
! @texline @tmath{C_{jj}}
@infoline @expr{C_j_j}
are the variances
! @texline @tmath{\sigma_j^2}
@infoline @expr{sigma_j^2}
of the parameters. The other elements are covariances
! @texline @tmath{\sigma_{ij}^2}
@infoline @expr{sigma_i_j^2}
that describe the correlation between pairs of parameters. (A related
set of numbers, the @dfn{linear correlation coefficients}
! @texline @tmath{r_{ij}},
@infoline @expr{r_i_j},
are defined as
! @texline @tmath{\sigma_{ij}^2 / \sigma_i \, \sigma_j}.)
@infoline @expr{sigma_i_j^2 / sigma_i sigma_j}.)
@item
--- 24442,24461 ----
@item
The covariance matrix @expr{C} computed from the fit. This is
an @address@hidden symmetric matrix; the diagonal elements
! @texline @math{C_{jj}}
@infoline @expr{C_j_j}
are the variances
! @texline @math{\sigma_j^2}
@infoline @expr{sigma_j^2}
of the parameters. The other elements are covariances
! @texline @math{\sigma_{ij}^2}
@infoline @expr{sigma_i_j^2}
that describe the correlation between pairs of parameters. (A related
set of numbers, the @dfn{linear correlation coefficients}
! @texline @math{r_{ij}},
@infoline @expr{r_i_j},
are defined as
! @texline @math{\sigma_{ij}^2 / \sigma_i \, \sigma_j}.)
@infoline @expr{sigma_i_j^2 / sigma_i sigma_j}.)
@item
***************
*** 24473,24483 ****
@item
The value of
! @texline @tmath{\chi^2}
@infoline @expr{chi^2}
for the fit, calculated by the formulas shown above. This gives a
measure of the quality of the fit; statisticians consider
! @texline @tmath{\chi^2 \approx N - M}
@infoline @expr{chi^2 = N - M}
to indicate a moderately good fit (where again @expr{N} is the number of
data points and @expr{M} is the number of parameters).
--- 24466,24476 ----
@item
The value of
! @texline @math{\chi^2}
@infoline @expr{chi^2}
for the fit, calculated by the formulas shown above. This gives a
measure of the quality of the fit; statisticians consider
! @texline @math{\chi^2 \approx N - M}
@infoline @expr{chi^2 = N - M}
to indicate a moderately good fit (where again @expr{N} is the number of
data points and @expr{M} is the number of parameters).
***************
*** 24486,24498 ****
A measure of goodness of fit expressed as a probability @expr{Q}.
This is computed from the @code{utpc} probability distribution
function using
! @texline @tmath{\chi^2}
@infoline @expr{chi^2}
with @expr{N - M} degrees of freedom. A
value of 0.5 implies a good fit; some texts recommend that often
@expr{Q = 0.1} or even 0.001 can signify an acceptable fit. In
particular,
! @texline @tmath{\chi^2}
@infoline @expr{chi^2}
statistics assume the errors in your inputs
follow a normal (Gaussian) distribution; if they don't, you may
--- 24479,24491 ----
A measure of goodness of fit expressed as a probability @expr{Q}.
This is computed from the @code{utpc} probability distribution
function using
! @texline @math{\chi^2}
@infoline @expr{chi^2}
with @expr{N - M} degrees of freedom. A
value of 0.5 implies a good fit; some texts recommend that often
@expr{Q = 0.1} or even 0.001 can signify an acceptable fit. In
particular,
! @texline @math{\chi^2}
@infoline @expr{chi^2}
statistics assume the errors in your inputs
follow a normal (Gaussian) distribution; if they don't, you may
***************
*** 24501,24507 ****
The @expr{Q} value is computed only if the input included error
estimates. Otherwise, Calc will report the symbol @code{nan}
for @expr{Q}. The reason is that in this case the
! @texline @tmath{\chi^2}
@infoline @expr{chi^2}
value has effectively been used to estimate the original errors
in the input, and thus there is no redundant information left
--- 24494,24500 ----
The @expr{Q} value is computed only if the input included error
estimates. Otherwise, Calc will report the symbol @code{nan}
for @expr{Q}. The reason is that in this case the
! @texline @math{\chi^2}
@infoline @expr{chi^2}
value has effectively been used to estimate the original errors
in the input, and thus there is no redundant information left
***************
*** 24520,24550 ****
@table @kbd
@item 1
! Linear or multilinear. @i{a + b x + c y + d z}.
@item 2-9
! Polynomials. @i{a + b x + c x^2 + d x^3}.
@item e
! Exponential. @i{a} @address@hidden(b x)} @address@hidden(c y)}.
@item E
! Base-10 exponential. @i{a} @address@hidden(b x)} @address@hidden(c y)}.
@item x
! Exponential (alternate notation). @address@hidden(a + b x + c y)}.
@item X
! Base-10 exponential (alternate). @address@hidden(a + b x + c y)}.
@item l
! Logarithmic. @i{a + b} @address@hidden(x) + c} @address@hidden(y)}.
@item L
! Base-10 logarithmic. @i{a + b} @address@hidden(x) + c} @address@hidden(y)}.
@item ^
! General exponential. @i{a b^x c^y}.
@item p
! Power law. @i{a x^b y^c}.
@item q
! Quadratic. @i{a + b (x-c)^2 + d (x-e)^2}.
@item g
Gaussian.
! @texline @tmath{{a \over b \sqrt{2 \pi}} \exp\left( -{1 \over 2} \left( x - c
\over b \right)^2 \right)}.
! @infoline @i{(a / b sqrt(2 pi)) exp(-0.5*((x-c)/b)^2)}.
@end table
All of these models are used in the usual way; just press the appropriate
--- 24513,24543 ----
@table @kbd
@item 1
! Linear or multilinear. @mathit{a + b x + c y + d z}.
@item 2-9
! Polynomials. @mathit{a + b x + c x^2 + d x^3}.
@item e
! Exponential. @mathit{a} @address@hidden(b x)} @address@hidden(c y)}.
@item E
! Base-10 exponential. @mathit{a} @address@hidden(b x)} @address@hidden(c y)}.
@item x
! Exponential (alternate notation). @address@hidden(a + b x + c y)}.
@item X
! Base-10 exponential (alternate). @address@hidden(a + b x + c y)}.
@item l
! Logarithmic. @mathit{a + b} @address@hidden(x) + c} @address@hidden(y)}.
@item L
! Base-10 logarithmic. @mathit{a + b} @address@hidden(x) + c}
@address@hidden(y)}.
@item ^
! General exponential. @mathit{a b^x c^y}.
@item p
! Power law. @mathit{a x^b y^c}.
@item q
! Quadratic. @mathit{a + b (x-c)^2 + d (x-e)^2}.
@item g
Gaussian.
! @texline @math{{a \over b \sqrt{2 \pi}} \exp\left( -{1 \over 2} \left( x - c
\over b \right)^2 \right)}.
! @infoline @mathit{(a / b sqrt(2 pi)) exp(-0.5*((x-c)/b)^2)}.
@end table
All of these models are used in the usual way; just press the appropriate
***************
*** 24656,24673 ****
and @code{arcsin} when doing fits. For example, when you enter
the model @samp{y = sin(a t + b)} Calc actually uses the easier
form @samp{arcsin(y) = a t + b}. The @code{arcsin} function always
! returns results in the range from @i{-90} to 90 degrees (or the
equivalent range in radians). Suppose you had data that you
believed to represent roughly three oscillations of a sine wave,
so that the argument of the sine might go from zero to
! @texline @tmath{3\times360}
! @infoline @i{3*360}
degrees.
The above model would appear to be a good way to determine the
true frequency and phase of the sine wave, but in practice it
would fail utterly. The righthand side of the actual model
@samp{arcsin(y) = a t + b} will grow smoothly with @expr{t}, but
! the lefthand side will bounce back and forth between @i{-90} and 90.
No values of @expr{a} and @expr{b} can make the two sides match,
even approximately.
--- 24649,24666 ----
and @code{arcsin} when doing fits. For example, when you enter
the model @samp{y = sin(a t + b)} Calc actually uses the easier
form @samp{arcsin(y) = a t + b}. The @code{arcsin} function always
! returns results in the range from @mathit{-90} to 90 degrees (or the
equivalent range in radians). Suppose you had data that you
believed to represent roughly three oscillations of a sine wave,
so that the argument of the sine might go from zero to
! @texline @math{3\times360}
! @infoline @mathit{3*360}
degrees.
The above model would appear to be a good way to determine the
true frequency and phase of the sine wave, but in practice it
would fail utterly. The righthand side of the actual model
@samp{arcsin(y) = a t + b} will grow smoothly with @expr{t}, but
! the lefthand side will bounce back and forth between @mathit{-90} and 90.
No values of @expr{a} and @expr{b} can make the two sides match,
even approximately.
***************
*** 24722,24737 ****
@noindent
which matches the desired form with
! @texline @tmath{Y = \ln(y)},
@infoline @expr{Y = ln(y)},
! @texline @tmath{A = \ln(a)},
@infoline @expr{A = ln(a)},
@expr{F = 1}, @expr{B = b}, and
! @texline @tmath{G = \ln(x)}.
@infoline @expr{G = ln(x)}.
Calc thus computes the logarithms of your @expr{y} and @expr{x} values,
does a linear fit for @expr{A} and @expr{B}, then solves to get
! @texline @tmath{a = \exp(A)}
@infoline @expr{a = exp(A)}
and @expr{b = B}.
--- 24715,24730 ----
@noindent
which matches the desired form with
! @texline @math{Y = \ln(y)},
@infoline @expr{Y = ln(y)},
! @texline @math{A = \ln(a)},
@infoline @expr{A = ln(a)},
@expr{F = 1}, @expr{B = b}, and
! @texline @math{G = \ln(x)}.
@infoline @expr{G = ln(x)}.
Calc thus computes the logarithms of your @expr{y} and @expr{x} values,
does a linear fit for @expr{A} and @expr{B}, then solves to get
! @texline @math{a = \exp(A)}
@infoline @expr{a = exp(A)}
and @expr{b = B}.
***************
*** 24745,24751 ****
@noindent
which matches with @expr{Y = y}, @expr{A = a + b c^2}, @expr{F = 1},
! @expr{B = -2 b c}, @expr{G = x} (the @i{-2} factor could just as easily
have been put into @expr{G} instead of @expr{B}), @expr{C = b}, and
@expr{H = x^2}.
--- 24738,24744 ----
@noindent
which matches with @expr{Y = y}, @expr{A = a + b c^2}, @expr{F = 1},
! @expr{B = -2 b c}, @expr{G = x} (the @mathit{-2} factor could just as easily
have been put into @expr{G} instead of @expr{B}), @expr{C = b}, and
@expr{H = x^2}.
***************
*** 24777,24783 ****
A last desperate step would be to use the general-purpose
@code{minimize} function rather than @code{fit}. After all, both
functions solve the problem of minimizing an expression (the
! @texline @tmath{\chi^2}
@infoline @expr{chi^2}
sum) by adjusting certain parameters in the expression. The @kbd{a F}
command is able to use a vastly more efficient algorithm due to its
--- 24770,24776 ----
A last desperate step would be to use the general-purpose
@code{minimize} function rather than @code{fit}. After all, both
functions solve the problem of minimizing an expression (the
! @texline @math{\chi^2}
@infoline @expr{chi^2}
sum) by adjusting certain parameters in the expression. The @kbd{a F}
command is able to use a vastly more efficient algorithm due to its
***************
*** 24788,24794 ****
fit is linearizable, and use @code{minimize} on a call to @code{fit}
which efficiently takes care of the rest of the parameters. The thing
to be minimized would be the value of
! @texline @tmath{\chi^2}
@infoline @expr{chi^2}
returned as the fifth result of the @code{xfit} function:
--- 24781,24787 ----
fit is linearizable, and use @code{minimize} on a call to @code{fit}
which efficiently takes care of the rest of the parameters. The thing
to be minimized would be the value of
! @texline @math{\chi^2}
@infoline @expr{chi^2}
returned as the fifth result of the @code{xfit} function:
***************
*** 24848,24858 ****
form with this combined error. The @expr{Y(x,y,z)} part of the
linearized model is evaluated, and the result should be an error
form. The error part of that result is used for
! @texline @tmath{\sigma_i}
@infoline @expr{sigma_i}
for the data point. If for some reason @expr{Y(x,y,z)} does not return
an error form, the combined error from @expr{z} is used directly for
! @texline @tmath{\sigma_i}.
@infoline @expr{sigma_i}.
Finally, @expr{z} is also stripped of its error
for use in computing @expr{F(x,y,z)}, @expr{G(x,y,z)} and so on;
--- 24841,24851 ----
form with this combined error. The @expr{Y(x,y,z)} part of the
linearized model is evaluated, and the result should be an error
form. The error part of that result is used for
! @texline @math{\sigma_i}
@infoline @expr{sigma_i}
for the data point. If for some reason @expr{Y(x,y,z)} does not return
an error form, the combined error from @expr{z} is used directly for
! @texline @math{\sigma_i}.
@infoline @expr{sigma_i}.
Finally, @expr{z} is also stripped of its error
for use in computing @expr{F(x,y,z)}, @expr{G(x,y,z)} and so on;
***************
*** 24864,24870 ****
depends only on the dependent variable @expr{z}, and in fact is
often simply equal to @expr{z}. For common cases like polynomials
and multilinear models, the combined error is simply used as the
! @texline @tmath{\sigma}
@infoline @expr{sigma}
for the data point with no further ado.)
--- 24857,24863 ----
depends only on the dependent variable @expr{z}, and in fact is
often simply equal to @expr{z}. For common cases like polynomials
and multilinear models, the combined error is simply used as the
! @texline @math{\sigma}
@infoline @expr{sigma}
for the data point with no further ado.)
***************
*** 25218,25224 ****
positive step size), the result is generally zero. However,
Calc only guarantees a zero result when the upper limit is
exactly one step less than the lower limit, i.e., if the number
! of iterations is @i{-1}. Thus @samp{sum(f(k), k, n, n-1)} is zero
but the sum from @samp{n} to @samp{n-2} may report a nonzero value
if Calc used a closed form solution.
--- 25211,25217 ----
positive step size), the result is generally zero. However,
Calc only guarantees a zero result when the upper limit is
exactly one step less than the lower limit, i.e., if the number
! of iterations is @mathit{-1}. Thus @samp{sum(f(k), k, n, n-1)} is zero
but the sum from @samp{n} to @samp{n-2} may report a nonzero value
if Calc used a closed form solution.
***************
*** 25244,25250 ****
Calc will not assume is zero. Better would be to use
@samp{(k != k_0) ? 1/(k-k_0) : 0}; the @samp{? :} operator does
an ``if-then-else'' test: This expression says, ``if
! @texline @tmath{k \ne k_0},
@infoline @expr{k != k_0},
then @expr{1/(k-k_0)}, else zero.'' Now the formula @expr{1/(k-k_0)}
will not even be evaluated by Calc when @expr{k = k_0}.
--- 25237,25243 ----
Calc will not assume is zero. Better would be to use
@samp{(k != k_0) ? 1/(k-k_0) : 0}; the @samp{? :} operator does
an ``if-then-else'' test: This expression says, ``if
! @texline @math{k \ne k_0},
@infoline @expr{k != k_0},
then @expr{1/(k-k_0)}, else zero.'' Now the formula @expr{1/(k-k_0)}
will not even be evaluated by Calc when @expr{k = k_0}.
***************
*** 26259,26274 ****
all three rules. It is possible to modify the imported rules
slightly: @samp{import(x, v1, x1, v2, x2, @dots{})} imports
the rule set @expr{x} with all occurrences of
! @texline @tmath{v_1},
@infoline @expr{v1},
as either a variable name or a function name, replaced with
! @texline @tmath{x_1}
@infoline @expr{x1}
and so on. (If
! @texline @tmath{v_1}
@infoline @expr{v1}
is used as a function name, then
! @texline @tmath{x_1}
@infoline @expr{x1}
must be either a function name itself or a @address@hidden< >}} nameless
function; @pxref{Specifying Operators}.) For example, @samp{[g(0) := 0,
--- 26252,26267 ----
all three rules. It is possible to modify the imported rules
slightly: @samp{import(x, v1, x1, v2, x2, @dots{})} imports
the rule set @expr{x} with all occurrences of
! @texline @math{v_1},
@infoline @expr{v1},
as either a variable name or a function name, replaced with
! @texline @math{x_1}
@infoline @expr{x1}
and so on. (If
! @texline @math{v_1}
@infoline @expr{v1}
is used as a function name, then
! @texline @math{x_1}
@infoline @expr{x1}
must be either a function name itself or a @address@hidden< >}} nameless
function; @pxref{Specifying Operators}.) For example, @samp{[g(0) := 0,
***************
*** 27734,27740 ****
units.
Two units, @code{pi} and @code{fsc} (the fine structure constant,
! approximately @i{1/137}) are dimensionless. The units simplification
commands simply treat these names as equivalent to their corresponding
values. However you can, for example, use @kbd{u c} to convert a pure
number into multiples of the fine structure constant, or @kbd{u b} to
--- 27727,27733 ----
units.
Two units, @code{pi} and @code{fsc} (the fine structure constant,
! approximately @mathit{1/137}) are dimensionless. The units simplification
commands simply treat these names as equivalent to their corresponding
values. However you can, for example, use @kbd{u c} to convert a pure
number into multiples of the fine structure constant, or @kbd{u b} to
***************
*** 27951,27960 ****
order of the operands. If @expr{v} represents the contents of the
variable, and @expr{a} is the value drawn from the stack, then regular
@address@hidden -}} assigns
! @texline @tmath{v \coloneq v - a},
@infoline @expr{v := v - a},
but @kbd{I s -} assigns
! @texline @tmath{v \coloneq a - v}.
@infoline @expr{v := a - v}.
While @kbd{I s *} might seem pointless, it is
useful if matrix multiplication is involved. Actually, all the
--- 27944,27953 ----
order of the operands. If @expr{v} represents the contents of the
variable, and @expr{a} is the value drawn from the stack, then regular
@address@hidden -}} assigns
! @texline @math{v \coloneq v - a},
@infoline @expr{v := v - a},
but @kbd{I s -} assigns
! @texline @math{v \coloneq a - v}.
@infoline @expr{v := a - v}.
While @kbd{I s *} might seem pointless, it is
useful if matrix multiplication is involved. Actually, all the
***************
*** 28541,28547 ****
``z'' value must be a matrix with the same number of rows as elements
in ``x'', and the same number of columns as elements in ``y''. The
result is a surface plot where
! @texline @tmath{z_{ij}}
@infoline @expr{z_ij}
is the height of the point
at coordinate @expr{(x_i, y_j)} on the surface. The 3D graph will
--- 28534,28540 ----
``z'' value must be a matrix with the same number of rows as elements
in ``x'', and the same number of columns as elements in ``y''. The
result is a surface plot where
! @texline @math{z_{ij}}
@infoline @expr{z_ij}
is the height of the point
at coordinate @expr{(x_i, y_j)} on the surface. The 3D graph will
***************
*** 28652,28658 ****
they are to look nice on the same graph.)
For example, to plot
! @texline @tmath{\sin n x}
@infoline @expr{sin(n x)}
for integers @expr{n}
from 1 to 5, you could use @kbd{v x} to create a vector of integers
--- 28645,28651 ----
they are to look nice on the same graph.)
For example, to plot
! @texline @math{\sin n x}
@infoline @expr{sin(n x)}
for integers @expr{n}
from 1 to 5, you could use @kbd{v x} to create a vector of integers
***************
*** 28903,28909 ****
the @kbd{g a} and @kbd{g f} commands will use those style numbers
instead of the defaults for new curves that are added to the graph.
An entry should be a positive integer for a specific style, or 0 to let
! the style be chosen automatically, or @i{-1} to turn off lines or points
altogether. If there are more curves than elements in the vector, the
last few curves will continue to have the default styles. Of course,
you can later use @kbd{g s} and @kbd{g S} to change any of these styles.
--- 28896,28902 ----
the @kbd{g a} and @kbd{g f} commands will use those style numbers
instead of the defaults for new curves that are added to the graph.
An entry should be a positive integer for a specific style, or 0 to let
! the style be chosen automatically, or @mathit{-1} to turn off lines or points
altogether. If there are more curves than elements in the vector, the
last few curves will continue to have the default styles. Of course,
you can later use @kbd{g s} and @kbd{g S} to change any of these styles.
***************
*** 28942,28948 ****
to a buffer called @samp{*Gnuplot Trail*}, which Calc then displays.
The graph is made the same size as the Emacs screen, which on most
dumb terminals will be
! @texline @tmath{80\times24}
@infoline 80x24
characters. The graph is displayed in
an Emacs ``recursive edit''; type @kbd{q} or @kbd{M-# M-#} to exit
--- 28935,28941 ----
to a buffer called @samp{*Gnuplot Trail*}, which Calc then displays.
The graph is made the same size as the Emacs screen, which on most
dumb terminals will be
! @texline @math{80\times24}
@infoline 80x24
characters. The graph is displayed in
an Emacs ``recursive edit''; type @kbd{q} or @kbd{M-# M-#} to exit
***************
*** 29252,29258 ****
@xref{Matrix Functions}, to see how to pull the matrix apart into its
constituent rows and columns. (If it is a
! @texline @tmath{1\times1}
@infoline 1x1
matrix, just hit @kbd{v u} (@code{calc-unpack}) twice.)
--- 29245,29251 ----
@xref{Matrix Functions}, to see how to pull the matrix apart into its
constituent rows and columns. (If it is a
! @texline @math{1\times1}
@infoline 1x1
matrix, just hit @kbd{v u} (@code{calc-unpack}) twice.)
***************
*** 29590,29596 ****
@key{INV GCD} computes the LCM (least common multiple) function.
@key{INV FACT} is the gamma function.
! @texline @tmath{\Gamma(x) = (x-1)!}.
@infoline @expr{gamma(x) = (x-1)!}.
@key{PERM} is the number-of-permutations function, which is on the
--- 29583,29589 ----
@key{INV GCD} computes the LCM (least common multiple) function.
@key{INV FACT} is the gamma function.
! @texline @math{\Gamma(x) = (x-1)!}.
@infoline @expr{gamma(x) = (x-1)!}.
@key{PERM} is the number-of-permutations function, which is on the
***************
*** 31018,31024 ****
is greater than @var{final} the body will not be executed at all.
Note that @var{step} may still be negative in this loop; the prefix
argument merely constrains the loop-finished test. Likewise, a prefix
! argument of @i{-1} forces downward-counting conventions.
@kindex Z @{
@kindex Z @}
--- 31011,31017 ----
is greater than @var{final} the body will not be executed at all.
Note that @var{step} may still be negative in this loop; the prefix
argument merely constrains the loop-finished test. Likewise, a prefix
! argument of @mathit{-1} forces downward-counting conventions.
@kindex Z @{
@kindex Z @}
***************
*** 31989,31995 ****
@tindex mysin
A somewhat limited sine function could be defined as follows, using the
well-known Taylor series expansion for
! @texline @tmath{\sin x}:
@infoline @samp{sin(x)}:
@smallexample
--- 31982,31988 ----
@tindex mysin
A somewhat limited sine function could be defined as follows, using the
well-known Taylor series expansion for
! @texline @math{\sin x}:
@infoline @samp{sin(x)}:
@smallexample
***************
*** 32512,32521 ****
Large integers are stored as lists of the form @samp{(bigpos @var{d0}
@var{d1} @var{d2} @dots{})} for positive integers 1000000 or more, or
@samp{(bigneg @var{d0} @var{d1} @var{d2} @dots{})} for negative integers
! @i{-1000000} or less. Each @var{d} is a base-1000 ``digit,'' a Lisp integer
from 0 to 999. The least significant digit is @var{d0}; the last digit,
@var{dn}, which is always nonzero, is the most significant digit. For
! example, the integer @i{-12345678} is stored as @samp{(bigneg 678 345 12)}.
The distinction between small and large integers is entirely hidden from
the user. In @code{defmath} definitions, the Lisp predicate @code{integerp}
--- 32505,32514 ----
Large integers are stored as lists of the form @samp{(bigpos @var{d0}
@var{d1} @var{d2} @dots{})} for positive integers 1000000 or more, or
@samp{(bigneg @var{d0} @var{d1} @var{d2} @dots{})} for negative integers
! @mathit{-1000000} or less. Each @var{d} is a base-1000 ``digit,'' a Lisp
integer
from 0 to 999. The least significant digit is @var{d0}; the last digit,
@var{dn}, which is always nonzero, is the most significant digit. For
! example, the integer @mathit{-12345678} is stored as @samp{(bigneg 678 345
12)}.
The distinction between small and large integers is entirely hidden from
the user. In @code{defmath} definitions, the Lisp predicate @code{integerp}
***************
*** 32536,32542 ****
@address@hidden in absolute value (@var{p} represents the current
precision), and @var{exp} (the ``exponent'') is a fixnum. The value of
the float is @address@hidden * address@hidden For example, the number
! @i{-3.14} is stored as @samp{(float -314 -2) = -314*10^-2}. Other constraints
are that the number 0.0 is always stored as @samp{(float 0 0)}, and,
except for the 0.0 case, the rightmost base-10 digit of @var{mant} is
always nonzero. (If the rightmost digit is zero, the number is
--- 32529,32535 ----
@address@hidden in absolute value (@var{p} represents the current
precision), and @var{exp} (the ``exponent'') is a fixnum. The value of
the float is @address@hidden * address@hidden For example, the number
! @mathit{-3.14} is stored as @samp{(float -314 -2) = -314*10^-2}. Other
constraints
are that the number 0.0 is always stored as @samp{(float 0 0)}, and,
except for the 0.0 case, the rightmost base-10 digit of @var{mant} is
always nonzero. (If the rightmost digit is zero, the number is
***************
*** 32848,32854 ****
specified, nothing happens. When the argument is two or more,
the binary function @var{func} is reduced across the top @var{arg}
stack elements; when the argument is negative, the function is
! mapped between the next-to-top @address@hidden stack elements and the
top element.
@end defun
--- 32841,32847 ----
specified, nothing happens. When the argument is two or more,
the binary function @var{func} is reduced across the top @var{arg}
stack elements; when the argument is negative, the function is
! mapped between the next-to-top @address@hidden stack elements and the
top element.
@end defun
***************
*** 33267,33273 ****
@end defun
@defun compare x y
! Compare the numbers @var{x} and @var{y}, and return @i{-1} if
@samp{(lessp @var{x} @var{y})}, 1 if @samp{(lessp @var{y} @var{x})},
0 if @samp{(math-equal @var{x} @var{y})}, or 2 if the order is
undefined or cannot be determined.
--- 33260,33266 ----
@end defun
@defun compare x y
! Compare the numbers @var{x} and @var{y}, and return @mathit{-1} if
@samp{(lessp @var{x} @var{y})}, 1 if @samp{(lessp @var{y} @var{x})},
0 if @samp{(math-equal @var{x} @var{y})}, or 2 if the order is
undefined or cannot be determined.
***************
*** 33280,33286 ****
@end defun
@defun scale-int x n
! Shift integer @var{x} left @var{n} decimal digits, or right @address@hidden
digits with truncation toward zero.
@end defun
--- 33273,33279 ----
@end defun
@defun scale-int x n
! Shift integer @var{x} left @var{n} decimal digits, or right @address@hidden
digits with truncation toward zero.
@end defun
***************
*** 33488,33494 ****
@defun quarter-integer n
If @var{n} is an integer or integer-valued float, this function
returns zero. If @var{n} is a half-integer (i.e., an integer plus
! @i{1:2} or 0.5), it returns 2. If @var{n} is a quarter-integer,
it returns 1 or 3. If @var{n} is anything else, this function
returns @code{nil}.
@end defun
--- 33481,33487 ----
@defun quarter-integer n
If @var{n} is an integer or integer-valued float, this function
returns zero. If @var{n} is a half-integer (i.e., an integer plus
! @mathit{1:2} or 0.5), it returns 2. If @var{n} is a quarter-integer,
it returns 1 or 3. If @var{n} is anything else, this function
returns @code{nil}.
@end defun
***************
*** 35631,35638 ****
@c 20
@item
With a prefix argument of 1, take a single
! @texline @address@hidden
! @infoline @address@hidden
matrix from the stack instead of two separate data vectors.
@c 21
--- 35624,35631 ----
@c 20
@item
With a prefix argument of 1, take a single
! @texline @address@hidden
! @infoline @address@hidden
matrix from the stack instead of two separate data vectors.
@c 21
***************
*** 35834,35840 ****
The variable is replaced by the formula shown on the right. The
Inverse flag reverses the order of the operands, e.g., @kbd{I s - x}
assigns
! @texline @tmath{x \coloneq a-x}.
@infoline @expr{x := a-x}.
@c 48
--- 35827,35833 ----
The variable is replaced by the formula shown on the right. The
Inverse flag reverses the order of the operands, e.g., @kbd{I s - x}
assigns
! @texline @math{x \coloneq a-x}.
@infoline @expr{x := a-x}.
@c 48
***************
*** 35842,35848 ****
Press @kbd{?} repeatedly to see how to choose a model. Answer the
variables prompt with @expr{iv} or @expr{iv;pv} to specify
independent and parameter variables. A positive prefix argument
! takes @address@hidden vectors from the stack; a zero prefix takes a matrix
and a vector from the stack.
@c 49
--- 35835,35841 ----
Press @kbd{?} repeatedly to see how to choose a model. Answer the
variables prompt with @expr{iv} or @expr{iv;pv} to specify
independent and parameter variables. A positive prefix argument
! takes @address@hidden vectors from the stack; a zero prefix takes a matrix
and a vector from the stack.
@c 49
- [Emacs-diffs] Changes to emacs/man/calc.texi, Jay Belanger, 2004/12/06
- [Emacs-diffs] Changes to emacs/man/calc.texi, Jay Belanger, 2004/12/07
- [Emacs-diffs] Changes to emacs/man/calc.texi, Jay Belanger, 2004/12/08
- [Emacs-diffs] Changes to emacs/man/calc.texi,
Jay Belanger <=
- [Emacs-diffs] Changes to emacs/man/calc.texi, Jay Belanger, 2004/12/15
- [Emacs-diffs] Changes to emacs/man/calc.texi, Jay Belanger, 2004/12/20
- [Emacs-diffs] Changes to emacs/man/calc.texi, Jay Belanger, 2004/12/27
- [Emacs-diffs] Changes to emacs/man/calc.texi, Jay Belanger, 2004/12/29
- [Emacs-diffs] Changes to emacs/man/calc.texi, Jay Belanger, 2004/12/31