This file documents Calc, the GNU Emacs calculator.
@end ifinfo
@ifnotinfo
-This file documents Calc, the GNU Emacs calculator, included with
+This file documents Calc, the GNU Emacs calculator, included with
GNU Emacs @value{EMACSVER}.
@end ifnotinfo
-Copyright @copyright{} 1990-1991, 2001-2011 Free Software Foundation, Inc.
+Copyright @copyright{} 1990--1991, 2001--2013 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
entitled ``GNU Free Documentation License.''
(a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
-modify this GNU manual. Buying copies from the FSF supports it in
-developing GNU and promoting software freedom.''
+modify this GNU manual.''
@end quotation
@end copying
* Notations Used in This Manual::
* Demonstration of Calc::
* Using Calc::
-* History and Acknowledgements::
+* History and Acknowledgments::
@end menu
@node What is Calc, About This Manual, Getting Started, Getting Started
this manual ought to be readable even if you don't know or use Emacs
regularly.
-This manual is divided into three major parts:@: the ``Getting
+This manual is divided into three major parts: the ``Getting
Started'' chapter you are reading now, the Calc tutorial, and the Calc
reference manual.
@c [when-split]
@c @cindex Marginal notes
Every Calc keyboard command is listed in the Calc Summary, and also
in the Key Index. Algebraic functions, @kbd{M-x} commands, and
-variables also have their own indices.
+variables also have their own indices.
@c @texline Each
@c @infoline In the printed manual, each
@c paragraph that is referenced in the Key or Function Index is marked
command @kbd{C-x * t} will jump to the Tutorial and start Calc if
necessary. Pressing @kbd{h s} or @kbd{C-x * s} will take you directly
to the Calc Summary. Within Calc, you can also go to the part of the
-manual describing any Calc key, function, or variable using
+manual describing any Calc key, function, or variable using
@w{@kbd{h k}}, @kbd{h f}, or @kbd{h v}, respectively. @xref{Help Commands}.
@ifnottex
then the command to operate on the numbers.
@noindent
-Type @kbd{2 @key{RET} 3 + Q} to compute
+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
+Type @kbd{P 2 ^} to compute
@texline @math{\pi^2 = 9.86960440109}.
@infoline the value of `pi' squared, 9.86960440109.
use the apostrophe key.
@noindent
-Type @kbd{' sqrt(2+3) @key{RET}} to compute
+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
+Type @kbd{' pi^2 @key{RET}} to enter
@texline @math{\pi^2}.
-@infoline `pi' squared.
+@infoline `pi' squared.
To evaluate this symbolic formula as a number, type @kbd{=}.
@noindent
the lower-right @samp{8} and press @kbd{C-x * r}.
@noindent
-Type @kbd{v t} to transpose this
+Type @kbd{v t} to transpose this
@texline @math{3\times2}
-@infoline 3x2
-matrix into a
+@infoline 3x2
+matrix into a
@texline @math{2\times3}
@infoline 2x3
matrix. Type @w{@kbd{v u}} to unpack the rows into two separate
Type @kbd{d B} to view the solutions in more readable notation.
Type @w{@kbd{d C}} to view them in C language notation, @kbd{d T}
to view them in the notation for the @TeX{} typesetting system,
-and @kbd{d L} to view them in the notation for the La@TeX{} typesetting
+and @kbd{d L} to view them in the notation for the @LaTeX{} typesetting
system. Type @kbd{d N} to return to normal notation.
@noindent
Press @key{DEL} repeatedly to remove any leftover results from the stack.
To exit from Calc, press @kbd{q} or @kbd{C-x * c} again.
-@node Using Calc, History and Acknowledgements, Demonstration of Calc, Getting Started
+@node Using Calc, History and Acknowledgments, Demonstration of Calc, Getting Started
@section Using Calc
@noindent
@noindent
On most systems, you can type @kbd{C-x *} to start the Calculator.
-The key sequence @kbd{C-x *} is bound to the command @code{calc-dispatch},
+The key sequence @kbd{C-x *} is bound to the command @code{calc-dispatch},
which can be rebound if convenient (@pxref{Customizing Calc}).
When you press @kbd{C-x *}, Emacs waits for you to press a second key to
is
-1 / ln(x) x
+1 / x ln(x)
@end group
@end smallexample
(Note that by default, Calc gives division lower precedence than multiplication,
-so that @samp{1 / ln(x) x} is equivalent to @samp{1 / (ln(x) x)}.)
+so that @samp{1 / x ln(x)} is equivalent to @samp{1 / (x ln(x))}.)
To make this look nicer, you might want to press @kbd{d =} to center
the formula, and even @kbd{d B} to use Big display mode.
1
-------
- ln(x) x
+ x ln(x)
@end group
@end smallexample
Calc has added annotations to the file to help it remember the modes
that were used for this formula. They are formatted like comments
in the @TeX{} typesetting language, just in case you are using @TeX{} or
-La@TeX{}. (In this example @TeX{} is not being used, so you might want
+@LaTeX{}. (In this example @TeX{} is not being used, so you might want
to move these comments up to the top of the file or otherwise put them
out of the way.)
The related command @kbd{C-x * w} operates on a single word, which
generally means a single number, inside text. It searches for an
expression which ``looks'' like a number containing the point.
-Here's an example of its use:
+Here's an example of its use (before you try this, remove the Calc
+annotations or use a new buffer so that the extra settings in the
+annotations don't take effect):
@smallexample
A slope of one-third corresponds to an angle of 1 degrees.
its initial state: Empty stack, and initial mode settings.
@end table
-@node History and Acknowledgements, , Using Calc, Getting Started
-@section History and Acknowledgements
+@node History and Acknowledgments, , Using Calc, Getting Started
+@section History and Acknowledgments
@noindent
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
+the value of
@texline @math{2^{32}}.
-@infoline @expr{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
question was @samp{4.294967e+09}---with no way to see the full ten
Emacs Lisp didn't have built-in floating point math (now it does), so
this had to be simulated in software. In fact, Emacs integers would
-only comfortably fit six decimal digits or so---not enough for a decent
-calculator. So I had to write my own high-precision integer code as
-well, and once I had this I figured that arbitrary-size integers were
-just as easy as large integers. Arbitrary floating-point precision was
-the logical next step. Also, since the large integer arithmetic was
-there anyway it seemed only fair to give the user direct access to it,
-which in turn made it practical to support fractions as well as floats.
-All these features inspired me to look around for other data types that
-might be worth having.
+only comfortably fit six decimal digits or so (at the time)---not
+enough for a decent calculator. So I had to write my own
+high-precision integer code as well, and once I had this I figured
+that arbitrary-size integers were just as easy as large integers.
+Arbitrary floating-point precision was the logical next step. Also,
+since the large integer arithmetic was there anyway it seemed only
+fair to give the user direct access to it, which in turn made it
+practical to support fractions as well as floats. All these features
+inspired me to look around for other data types that might be worth
+having.
Around this time, my friend Rick Koshi showed me his nifty new HP-28
calculator. It allowed the user to manipulate formulas as well as
Many people have contributed to Calc by reporting bugs and suggesting
features, large and small. A few deserve special mention: Tim Peters,
who helped develop the ideas that led to the selection commands, rewrite
-rules, and many other algebra features;
+rules, and many other algebra features;
@texline Fran\c{c}ois
@infoline Francois
Pinard, who contributed an early prototype of the Calc Summary appendix
Sarlin, who first worked out how to split Calc into quickly-loading
parts; Bob Weiner, who helped immensely with the Lucid Emacs port; and
Robert J. Chassell, who suggested the Calc Tutorial and exercises as
-well as many other things.
+well as many other things.
@cindex Bibliography
@cindex Knuth, Art of Computer Programming
@subsection RPN Calculations and the Stack
@cindex RPN notation
-@ifnottex
@noindent
+@ifnottex
Calc normally uses RPN notation. You may be familiar with the RPN
system from Hewlett-Packard calculators, FORTH, or PostScript.
(Reverse Polish Notation, RPN, is named after the Polish mathematician
Jan Lukasiewicz.)
@end ifnottex
@tex
-\noindent
Calc normally uses RPN notation. You may be familiar with the RPN
system from Hewlett-Packard calculators, FORTH, or PostScript.
(Reverse Polish Notation, RPN, is named after the Polish mathematician
multiplication.) Figure it out by hand, then try it with Calc to see
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}
+(@bullet{}) @strong{Exercise 2.} Compute
+@texline @math{(2\times4) + (7\times9.5) + {5\over4}}
+@infoline @expr{2*4 + 7*9.5 + 5/4}
using the stack. @xref{RPN Answer 2, 2}. (@bullet{})
The @key{DEL} key is called Backspace on some keyboards. It is
accomplish this in Calc by performing your calculation as a series
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
+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
@smallexample
@group
-1: 2 a + 2 b 1: 34 + 2 b
+1: 2 a + 2 b 1: 2 b + 34
. .
' 2a+2b @key{RET} =
@smallexample
@group
-1: 2 + log10(0) + log10(x) + log10(5, 6) + foo(3)
+1: log10(0) + log10(x) + log10(5, 6) + foo(3) + 2
.
' log10(100) + log10(0) + log10(x) + log10(5,6) + foo(3) @key{RET}
to cancel it. (In fact, you can press @kbd{C-g} to cancel almost
anything in Emacs.) To get help on a prefix key, press that key
followed by @kbd{?}. Some prefixes have several lines of help,
-so you need to press @kbd{?} repeatedly to see them all.
+so you need to press @kbd{?} repeatedly to see them all.
You can also type @kbd{h h} to see all the help at once.
Try pressing @kbd{t ?} now. You will see a line of the form,
@noindent
The shift-@kbd{S} command computes the sine of an angle. The sine
-of 45 degrees is
+of 45 degrees is
@texline @math{\sqrt{2}/2};
-@infoline @expr{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
+roundoff error because the representation of
@texline @math{\sqrt{2}/2}
-@infoline @expr{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
re-rounds the number on the top of the stack.
@end smallexample
@noindent
-Here we compute the Inverse Sine of
+Here we compute the Inverse Sine of
@texline @math{\sqrt{0.5}},
-@infoline @expr{sqrt(0.5)},
+@infoline @expr{sqrt(0.5)},
first in radians, then in degrees.
Use @kbd{c d} and @kbd{c r} to convert a number from radians to degrees
@kbd{H} (hyperbolic) prefix keys.
Let's compute the sine and cosine of an angle, and verify the
-identity
+identity
@texline @math{\sin^2x + \cos^2x = 1}.
-@infoline @expr{sin(x)^2 + cos(x)^2 = 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 @w{@kbd{m d}}), do:
Remember, @kbd{f h} is the @code{calc-hypot}, or square-root of sum
of squares, command.
-Another identity is
+Another identity is
@texline @math{\displaystyle\tan x = {\sin x \over \cos x}}.
@infoline @expr{tan(x) = sin(x) / cos(x)}.
@smallexample
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}
+@infoline @expr{cosh(x)^2 - sinh(x)^2}
that always equals one. Let's try to verify this identity.
@smallexample
@end smallexample
@noindent
-Here we verify the identity
+Here we verify the identity
@texline @math{n! = \Gamma(n+1)}.
@infoline @expr{@var{n}!@: = gamma(@var{n}+1)}.
vector.
(@bullet{}) @strong{Exercise 1.} Use @samp{*} to sum along the rows
-of the above
+of the above
@texline @math{2\times3}
-@infoline 2x3
+@infoline 2x3
matrix to get @expr{[6, 15]}. Now use @samp{*} to sum along the columns
-to get @expr{[5, 7, 9]}.
+to get @expr{[5, 7, 9]}.
@xref{Matrix Answer 1, 1}. (@bullet{})
@cindex Identity matrix
assume the vector was a row vector in order to make the dimensions
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
+vectors, use explicit
@texline @math{N\times1}
@infoline Nx1
or
@tex
$A^T A \, X = A^T B$, where $A^T$ is the transpose \samp{trn(A)}.
@end tex
-Now
+Now
@texline @math{A^T A}
-@infoline @expr{trn(A)*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''
solution, which can be regarded as the ``closest'' solution to the set
of each element.
(@bullet{}) @strong{Exercise 1.} Compute a vector of powers of two
-from
+from
@texline @math{2^{-4}}
-@infoline @expr{2^-4}
+@infoline @expr{2^-4}
to @expr{2^4}. @xref{List Answer 1, 1}. (@bullet{})
You can also @dfn{reduce} a binary operator across a vector.
@end tex
@noindent
-where
+where
@texline @math{\sum x}
-@infoline @expr{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
simple reduction. First, let's compute the four different sums that
@end group
@end smallexample
-Let's ``plot'' this straight line approximation,
+Let's ``plot'' this straight line approximation,
@texline @math{y \approx m x + b},
-@infoline @expr{m x + b},
+@infoline @expr{m x + b},
and compare it with the original data.
@smallexample
(If you are reading this tutorial on-line while running Calc, typing
@kbd{g a} may cause the tutorial to disappear from its window and be
replaced by a buffer named @samp{*Gnuplot Commands*}. The tutorial
-will reappear when you terminate GNUPLOT by typing @kbd{g q}.)
+will reappear when you terminate GNUPLOT by typing @kbd{g q}.)
@end ifinfo
@smallexample
@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}
+@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
which @samp{besJ(1,x)} is a maximum. Use an ``automatic'' method,
@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}
+@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}
digits, each in the range from 0 to 9. In vector-of-digits notation,
happened? How would you do this test? @xref{List Answer 10, 10}. (@bullet{})
(@bullet{}) @strong{Exercise 11.} The area of a circle of radius one
-is @cpi{}. The area of the
+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
+the circle. This gives us an entertaining way to estimate the value of
@cpi{}. The @w{@kbd{k 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
another way to calculate @cpi{}. Say you have an infinite field
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
+a line turns out to be
@texline @math{2/\pi}.
-@infoline @expr{2/pi}.
+@infoline @expr{2/pi}.
Toss 100 matchsticks to estimate @cpi{}. (If you want still more fun,
the probability that the GCD (@w{@kbd{k g}}) of two large integers is
-one turns out to be
+one turns out to be
@texline @math{6/\pi^2}.
@infoline @expr{6/pi^2}.
That provides yet another way to estimate @cpi{}.)
Friday the 13th? @xref{Types Answer 5, 5}. (@bullet{})
(@bullet{}) @strong{Exercise 6.} How many leap years will there be
-between now and the year 10001 A.D.? @xref{Types Answer 6, 6}. (@bullet{})
+between now and the year 10001 AD@? @xref{Types Answer 6, 6}. (@bullet{})
@cindex Slope and angle of a line
@cindex Angle and slope of a line
@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 @w{@expr{2 pi^2 R r^2}}
+@infoline @w{@expr{2 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
itself. Suppose @expr{R} is 20 cm and @expr{r} is 4 cm, each known to
new number which, when multiplied by 5 modulo 24, produces the original
number, 21. If @var{m} is prime and the divisor is not a multiple of
@var{m}, it is always possible to find such a number. For non-prime
-@var{m} like 24, it is only sometimes possible.
+@var{m} like 24, it is only sometimes possible.
@smallexample
@group
@cindex Fermat, primality test of
(@bullet{}) @strong{Exercise 10.} A theorem of Pierre de Fermat
-says that
-@texline @w{@math{x^{n-1} \bmod n = 1}}
+says that
+@texline @math{x^{n-1} \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
This calculation tells me it is six hours and 22 minutes until midnight.
(@bullet{}) @strong{Exercise 11.} A rule of thumb is that one year
-is about
+is about
@texline @math{\pi \times 10^7}
-@infoline @w{@expr{pi * 10^7}}
+@infoline @w{@expr{pi * 10^7}}
seconds. What time will it be that many seconds from right now?
@xref{Types Answer 11, 11}. (@bullet{})
@smallexample
@group
-1: 20 degF 1: 11.1111 degC 1: -20:3 degC 1: -6.666 degC
+1: 20 degF 1: 11.1111 degC 1: -6.666 degC
. . . .
- ' 20 degF @key{RET} u c degC @key{RET} U u t degC @key{RET} c f
+ ' 20 degF @key{RET} u c degC @key{RET} U u t degC @key{RET}
@end group
@end smallexample
@noindent
First we convert a change of 20 degrees Fahrenheit into an equivalent
change in degrees Celsius (or Centigrade). Then, we convert the
-absolute temperature 20 degrees Fahrenheit into Celsius. Since
-this comes out as an exact fraction, we then convert to floating-point
-for easier comparison with the other result.
+absolute temperature 20 degrees Fahrenheit into Celsius.
For simple unit conversions, you can put a plain number on the stack.
Then @kbd{u c} and @kbd{u t} will prompt for both old and new units.
@smallexample
@group
-1: 2 x^2 - 6 1: 6 - 2 x^2 1: (6 - 2 x^2) (3 x^2 + y)
+1: 2 x^2 - 6 1: 6 - 2 x^2 1: (3 x^2 + y) (6 - 2 x^2)
. . .
' 2x^2-6 @key{RET} n ' 3x^2+y @key{RET} *
@smallexample
@group
-1: 18 x^2 + 6 y - 6 x^4 - 2 x^2 y 1: (18 - 2 y) x^2 - 6 x^4 + 6 y
+1: 18 x^2 - 6 x^4 + 6 y - 2 y x^2 1: (18 - 2 y) x^2 - 6 x^4 + 6 y
. .
a x a c x @key{RET}
@smallexample
@group
-1: (34 x - 24 x^3) / x 1: 34 x / x - 24 x^3 / x 1: 34 - 24 x^2
- . . .
+1: (34 x - 24 x^3) / x 1: 34 - 24 x^2
+ . .
- ' x @key{RET} / a x a s
+ ' x @key{RET} / a x
@end group
@end smallexample
@noindent
@smallexample
@group
-1: 34 - 24 x^2 = 0 1: x = 1.19023
+1: 0.70588 x^2 = 1 1: x = 1.19023
. .
0 a = s 3 a S x @key{RET}
@end smallexample
@noindent
-Notice the use of @kbd{a s} to ``simplify'' the formula. When the
-default algebraic simplifications don't do enough, you can use
-@kbd{a s} to tell Calc to spend more time on the job.
-
Now we compute the second derivative and plug in our values of @expr{x}:
@smallexample
local @emph{minimum} at @expr{x = 0}.)
When we solved for @expr{x}, we got only one value even though
-@expr{34 - 24 x^2 = 0} is a quadratic equation that ought to have
+@expr{0.70588 x^2 = 1} is a quadratic equation that ought to have
two solutions. The reason is that @w{@kbd{a S}} normally returns a
single ``principal'' solution. If it needs to come up with an
arbitrary sign (as occurs in the quadratic formula) it picks @expr{+}.
@smallexample
@group
-1: 34 - 24 x^2 = 0 1: x = 1.19023 s1 1: x = -1.19023
+1: 0.70588 x^2 = 1 1: x = 1.19023 s1 1: x = -1.19023
. . .
r 3 H a S x @key{RET} s 5 1 n s l s1 @key{RET}
Here things like powers, square roots, and quotients and fractions
are displayed in a two-dimensional pictorial form. Calc has other
language modes as well, such as C mode, FORTRAN mode, @TeX{} mode
-and La@TeX{} mode.
+and @LaTeX{} mode.
@smallexample
@group
@end smallexample
(@bullet{}) @strong{Exercise 3.} Find the integral from 1 to @expr{y}
-of
+of
@texline @math{x \sin \pi x}
-@infoline @w{@expr{x sin(pi x)}}
+@infoline @w{@expr{x 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,
3}. (@bullet{})
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
+under the curve
@texline @math{\sin x \ln x}
-@infoline @expr{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
long time but would be unable to find a solution. In fact, there is no
@smallexample
@group
2: [1, 1.1, ... ] 1: [0., 0.084941, 0.16993, ... ]
-1: sin(x) ln(x) .
+1: ln(x) sin(x) .
.
' sin(x) ln(x) @key{RET} s 1 m r p 5 @key{RET} V M $ @key{RET}
@smallexample
@group
-1: sin(x) ln(x) 1: 0.84147 x - 0.84147 + 0.11957 (x - 1)^2 - ...
+1: ln(x) sin(x) 1: 0.84147 x + 0.11957 (x - 1)^2 - ...
. .
r 1 a t x=1 @key{RET} 4 @key{RET}
\afterdisplay
@end tex
-Compute the integral from 1 to 2 of
+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.
+@infoline @expr{sin(x) ln(x)}
+using Simpson's rule with 10 slices.
@xref{Algebra Answer 4, 4}. (@bullet{})
Calc has a built-in @kbd{a I} command for doing numerical integration.
@smallexample
@group
-1: 2 / cos(x)^2 - 2 tan(x)^2
+1: 2 sec(x)^2 / tan(x)^2 - 2 / tan(x)^2
.
- ' 2/cos(x)^2 - 2tan(x)^2 @key{RET} s 1
+ ' 2sec(x)^2/tan(x)^2 - 2/tan(x)^2 @key{RET} s 1
@end group
@end smallexample
@noindent
-If we were simplifying this by hand, we'd probably replace the
-@samp{tan} with a @samp{sin/cos} first, then combine over a common
-denominator. The @kbd{I a s} command will do the former and the @kbd{a n}
-algebra command will do the latter, but we'll do both with rewrite
-rules just for practice.
+If we were simplifying this by hand, we'd probably combine over the common
+denominator. The @kbd{a n} algebra command will do this, but we'll do
+it with a rewrite rule just for practice.
Rewrite rules are written with the @samp{:=} symbol.
@smallexample
@group
-1: 2 / cos(x)^2 - 2 sin(x)^2 / cos(x)^2
+1: (2 sec(x)^2 - 2) / tan(x)^2
.
- a r tan(a) := sin(a)/cos(a) @key{RET}
+ a r a/x + b/x := (a+b)/x @key{RET}
@end group
@end smallexample
@noindent
(The ``assignment operator'' @samp{:=} has several uses in Calc. All
-by itself the formula @samp{tan(a) := sin(a)/cos(a)} doesn't do anything,
+by itself the formula @samp{a/x + b/x := (a+b)/x} doesn't do anything,
but when it is given to the @kbd{a r} command, that command interprets
it as a rewrite rule.)
-The lefthand side, @samp{tan(a)}, is called the @dfn{pattern} of the
+The lefthand side, @samp{a/x + b/x}, is called the @dfn{pattern} of the
rewrite rule. Calc searches the formula on the stack for parts that
match the pattern. Variables in a rewrite pattern are called
@dfn{meta-variables}, and when matching the pattern each meta-variable
can match any sub-formula. Here, the meta-variable @samp{a} matched
-the actual variable @samp{x}.
-
-When the pattern part of a rewrite rule matches a part of the formula,
-that part is replaced by the righthand side with all the meta-variables
-substituted with the things they matched. So the result is
-@samp{sin(x) / cos(x)}. Calc's normal algebraic simplifications then
-mix this in with the rest of the original formula.
-
-To merge over a common denominator, we can use another simple rule:
-
-@smallexample
-@group
-1: (2 - 2 sin(x)^2) / cos(x)^2
- .
-
- a r a/x + b/x := (a+b)/x @key{RET}
-@end group
-@end smallexample
+the expression @samp{2 sec(x)^2}, the meta-variable @samp{b} matched
+the constant @samp{-2} and the meta-variable @samp{x} matched
+the expression @samp{tan(x)^2}.
This rule points out several interesting features of rewrite patterns.
First, if a meta-variable appears several times in a pattern, it must
Second, meta-variable names are independent from variables in the
target formula. Notice that the meta-variable @samp{x} here matches
-the subformula @samp{cos(x)^2}; Calc never confuses the two meanings of
+the subformula @samp{tan(x)^2}; Calc never confuses the two meanings of
@samp{x}.
And third, rewrite patterns know a little bit about the algebraic
properties of formulas. The pattern called for a sum of two quotients;
Calc was able to match a difference of two quotients by matching
-@samp{a = 2}, @samp{b = -2 sin(x)^2}, and @samp{x = cos(x)^2}.
+@samp{a = 2 sec(x)^2}, @samp{b = -2}, and @samp{x = tan(x)^2}.
+
+When the pattern part of a rewrite rule matches a part of the formula,
+that part is replaced by the righthand side with all the meta-variables
+substituted with the things they matched. So the result is
+@samp{(2 sec(x)^2 - 2) / tan(x)^2}.
@c [fix-ref Algebraic Properties of Rewrite Rules]
We could just as easily have written @samp{a/x - b/x := (a-b)/x} for
of Rewrite Rules}, for some examples of this.)
One more rewrite will complete the job. We want to use the identity
-@samp{sin(x)^2 + cos(x)^2 = 1}, but of course we must first rearrange
+@samp{tan(x)^2 + 1 = sec(x)^2}, but of course we must first rearrange
the identity in a way that matches our formula. The obvious rule
-would be @samp{@w{2 - 2 sin(x)^2} := 2 cos(x)^2}, but a little thought shows
-that the rule @samp{sin(x)^2 := 1 - cos(x)^2} will also work. The
+would be @samp{@w{2 sec(x)^2 - 2} := 2 tan(x)^2}, but a little thought shows
+that the rule @samp{sec(x)^2 := 1 + tan(x)^2} will also work. The
latter rule has a more general pattern so it will work in many other
situations, too.
@smallexample
@group
-1: (2 + 2 cos(x)^2 - 2) / cos(x)^2 1: 2
- . .
+1: 2
+ .
- a r sin(x)^2 := 1 - cos(x)^2 @key{RET} a s
+ a r sec(x)^2 := 1 + tan(x)^2 @key{RET}
@end group
@end smallexample
@smallexample
@group
-' tan(x) := sin(x)/cos(x) @key{RET} s t tsc @key{RET}
-' a/x + b/x := (a+b)/x @key{RET} s t merge @key{RET}
-' sin(x)^2 := 1 - cos(x)^2 @key{RET} s t sinsqr @key{RET}
+' a/x + b/x := (a+b)/x @key{RET} s t merge @key{RET}
+' sec(x)^2 := 1 + tan(x)^2 @key{RET} s t secsqr @key{RET}
-1: 2 / cos(x)^2 - 2 tan(x)^2 1: 2
+1: 2 sec(x)^2 / tan(x)^2 - 2 / tan(x)^2 1: 2
. .
- r 1 a r tsc @key{RET} a r merge @key{RET} a r sinsqr @key{RET} a s
+ r 1 a r merge @key{RET} a r secsqr @key{RET}
@end group
@end smallexample
To edit a variable, type @kbd{s e} and the variable name, use regular
Emacs editing commands as necessary, then type @kbd{C-c C-c} to store
-the edited value back into the variable.
+the edited value back into the variable.
You can also use @w{@kbd{s e}} to create a new variable if you wish.
Notice that the first time you use each rule, Calc puts up a ``compiling''
@smallexample
@group
-1: [tsc, merge, sinsqr] 1: [tan(x) := sin(x) / cos(x), ... ]
+1: [merge, secsqr] 1: [a/x + b/x := (a + b)/x, ... ]
. .
- ' [tsc,merge,sinsqr] @key{RET} =
+ ' [merge,sinsqr] @key{RET} =
@end group
@end smallexample
@noindent
@smallexample
@group
-1: 1 / cos(x) - sin(x) tan(x) 1: cos(x)
+1: 2 sec(x)^2 / tan(x)^2 - 2 / tan(x)^2 1: 2
. .
- s t trig @key{RET} r 1 a r trig @key{RET} a s
+ s t trig @key{RET} r 1 a r trig @key{RET}
@end group
@end smallexample
@smallexample
@group
-1: 1 / cos(x) - sin(x)^2 / cos(x) 1: (1 - sin(x)^2) / cos(x)
- . .
+1: (2 sec(x)^2 - 2) / tan(x)^2 1: 2
+ . .
- r 1 M-1 a r trig @key{RET} M-1 a r trig @key{RET}
+ r 1 M-1 a r trig @key{RET} M-1 a r trig @key{RET}
@end group
@end smallexample
@smallexample
@group
-1: exp(2 pi i) + exp(3 pi i) + exp(4 pi i)
+1: sin(x + 2 pi) + sin(x + 3 pi) + sin(x + 4 pi)
.
- ' exp(2 pi i) + exp(3 pi i) + exp(4 pi i) @key{RET}
+ ' sin(x+2pi) + sin(x+3pi) + sin(x+4pi) @key{RET}
@end group
@end smallexample
@noindent
@smallexample
@group
-1: 1 + exp(3 pi i) + 1
+1: sin(x + 3 pi) + 2 sin(x)
.
- a r exp(k pi i) := 1 :: k % 2 = 0 @key{RET}
+ a r sin(a + k pi) := sin(a) :: k % 2 = 0 @key{RET}
@end group
@end smallexample
(Recall, @samp{k % 2} is the remainder from dividing @samp{k} by 2,
which will be zero only when @samp{k} is an even integer.)
-An interesting point is that the variables @samp{pi} and @samp{i}
-were matched literally rather than acting as meta-variables.
-This is because they are special-constant variables. The special
-constants @samp{e}, @samp{phi}, and so on also match literally.
+An interesting point is that the variable @samp{pi} was matched
+literally rather than acting as a meta-variable.
+This is because it is a special-constant variable. The special
+constants @samp{e}, @samp{i}, @samp{phi}, and so on also match literally.
A common error with rewrite
rules is to write, say, @samp{f(a,b,c,d,e) := g(a+b+c+d+e)}, expecting
to match any @samp{f} with five arguments but in fact matching
@smallexample
@group
-1: fib(6) + fib(x) + fib(0) 1: 8 + fib(x) + fib(0)
+1: fib(6) + fib(x) + fib(0) 1: fib(x) + fib(0) + 8
. .
' fib(6)+fib(x)+fib(0) @key{RET} a r fib @key{RET}
For example, given @samp{1 - x^2 / 2 + O(x^3)} and @samp{x - x^3 / 6 + O(x^4)}
on the stack, we want to be able to type @kbd{*} and get the result
@samp{x - 2:3 x^3 + O(x^4)}. Don't worry if the terms of the sum are
-rearranged or if @kbd{a s} needs to be typed after rewriting. (This one
-is rather tricky; the solution at the end of this chapter uses 6 rewrite
-rules. Hint: The @samp{constant(x)} condition tests whether @samp{x} is
-a number.) @xref{Rewrites Answer 6, 6}. (@bullet{})
+rearranged. (This one is rather tricky; the solution at the end of
+this chapter uses 6 rewrite rules. Hint: The @samp{constant(x)}
+condition tests whether @samp{x} is a number.) @xref{Rewrites Answer
+6, 6}. (@bullet{})
Just for kicks, try adding the rule @code{2+3 := 6} to @code{EvalRules}.
What happens? (Be sure to remove this rule afterward, or you might get
@smallexample
@group
-1: 1 + x + x^2 / 2 + x^3 / 6 1: 1 + x + x^2 / 2 + x^3 / 6
+1: x + x^2 / 2 + x^3 / 6 + 1 1: x + x^2 / 2 + x^3 / 6 + 1
. .
' 1 + x + x^2/2! + x^3/3! @key{RET} Z F e myexp @key{RET} @key{RET} @key{RET} y
@tindex Si
(@bullet{}) @strong{Exercise 1.} The ``sine integral'' function
@texline @math{{\rm Si}(x)}
-@infoline @expr{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
integral has no solution in terms of basic functions; if you give it
' y=sqrt(x) @key{RET} C-x ( H a S x @key{RET} C-x )
-1: y = cos(x) 1: x = s1 arccos(y) + 2 pi n1
+1: y = cos(x) 1: x = s1 arccos(y) + 2 n1 pi
. .
' y=cos(x) @key{RET} X
@enumerate
@item
-Compute
+Compute
@texline @math{\displaystyle{\sin x \over x}},
-@infoline @expr{sin(x) / x},
+@infoline @expr{sin(x) / x},
where @expr{x} is the number on the top of the stack.
@item
@cindex Golden ratio
@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
+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
+and then rounding to the nearest integer, where
@texline @math{\phi} (``phi''),
-@infoline @expr{phi},
-the ``golden ratio,'' is
+@infoline @expr{phi},
+the ``golden ratio,'' is
@texline @math{(1 + \sqrt{5}) / 2}.
-@infoline @expr{(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.)
@cindex Continued fractions
(@bullet{}) @strong{Exercise 5.} The @dfn{continued fraction}
-representation of
+representation of
@texline @math{\phi}
-@infoline @expr{phi}
-is
+@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
+and then replacing the innermost
@texline @math{1/( \ldots )}
-@infoline @expr{1/( ...@: )}
+@infoline @expr{1/( ...@: )}
by 1. Approximate
@texline @math{\phi}
-@infoline @expr{phi}
+@infoline @expr{phi}
using a twenty-term continued fraction.
@xref{Programming Answer 5, 5}. (@bullet{})
The @dfn{Bernoulli numbers} are a sequence with the interesting
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
+by the formula
@texline @math{\displaystyle{2 n! \over (2 \pi)^n}}.
-@infoline @expr{2 n!@: / (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
this command is very slow for large @expr{n} since the higher Bernoulli
0 ;; calc digits (Push a zero onto the stack)
st ;; calc-store-into (Store it in the following variable)
1 ;; calc quick variable (Quick variable q1)
-1 ;; calc digits (Initial value for the loop)
+1 ;; calc digits (Initial value for the loop)
TAB ;; calc-roll-down (Swap initial and final)
Z( ;; calc-kbd-for (Begin the "for" loop)
& ;; calc-inv (Take the reciprocal)
The @file{edmacro} package defines a handy @code{read-kbd-macro} command
which reads the current region of the current buffer as a sequence of
-keystroke names, and defines that sequence on the @kbd{X}
+keystroke names, and defines that sequence on the @kbd{X}
(and @kbd{C-x e}) key. Because this is so useful, Calc puts this
command on the @kbd{C-x * m} key. Try reading in this macro in the
-following form: Press @kbd{C-@@} (or @kbd{C-@key{SPC}}) at
+following form: Press @kbd{C-@@} (or @kbd{C-@key{SPC}}) at
one end of the text below, then type @kbd{C-x * m} at the other.
@example
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}
+@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
+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
@cindex Digamma function
@cindex Gamma constant, Euler's
@cindex Euler's gamma constant
-(@bullet{}) @strong{Exercise 9.} The @dfn{digamma} function
+(@bullet{}) @strong{Exercise 9.} The @dfn{digamma} function
@texline @math{\psi(z) (``psi'')}
@infoline @expr{psi(z)}
-is defined as the derivative of
+is defined as the derivative of
@texline @math{\ln \Gamma(z)}.
-@infoline @expr{ln(gamma(z))}.
+@infoline @expr{ln(gamma(z))}.
For large values of @expr{z}, it can be approximated by the infinite sum
@ifnottex
@end tex
@noindent
-where
+where
@texline @math{\sum}
-@infoline @expr{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
the @code{bern} function produces (exact) Bernoulli numbers.
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)}.
+@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
+Fortunately, we can compute
@texline @math{\psi(1)}
-@infoline @expr{psi(1)}
-from
+@infoline @expr{psi(1)}
+from
@texline @math{\psi(5)}
-@infoline @expr{psi(5)}
-using the recurrence
+@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
+@infoline @expr{psi(z+1) = psi(z) + 1/z}.
+Your task: Develop a program to compute
@texline @math{\psi(z)};
-@infoline @expr{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
+to compute
@texline @math{\gamma}
-@infoline @expr{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.)
@xref{Programming Answer 9, 9}. (@bullet{})
@noindent
@kbd{1 @key{RET} 2 @key{RET} 3 @key{RET} 4 + * -}
-The result is
+The result is
@texline @math{1 - (2 \times (3 + 4)) = -13}.
@infoline @expr{1 - (2 * (3 + 4)) = -13}.
@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
+After computing the intermediate term
@texline @math{2\times4 = 8},
-@infoline @expr{2*4 = 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
compute the final term, then press @kbd{+ +} to add everything up.
give a floating-point result that is inaccurate even when rounded
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
+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.
@smallexample
@group
-1: [6, 10] 2: [6, 10] 1: [6 - 4 a / (b - a), 4 / (b - a) ]
+1: [6, 10] 2: [6, 10] 1: [4 a / (a - b) + 6, 4 / (b - a) ]
. 1: [ [ 1, a ] .
[ 1, b ] ]
.
@smallexample
@group
- 4 a 4
-1: [6 - -----, -----]
- b - a b - a
+ 4 a 4
+1: [----- + 6, -----]
+ a - b b - a
@end group
@end smallexample
@subsection Matrix Tutorial Exercise 3
@noindent
-To solve
+To solve
@texline @math{A^T A \, X = A^T B},
-@infoline @expr{trn(A) * A * X = trn(A) * 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
+@infoline @expr{A2 = trn(A) * A}
+and
@texline @math{B' = A^T B};
-@infoline @expr{B2 = trn(A) * B};
-now, we have a system
+@infoline @expr{B2 = trn(A) * B};
+now, we have a system
@texline @math{A' X = B'}
-@infoline @expr{A2 * X = B2}
+@infoline @expr{A2 * X = B2}
which we can solve using Calc's @samp{/} command.
@ifnottex
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}
+@infoline @expr{B2}
vector.
@smallexample
@end smallexample
@noindent
-Now we compute the matrix
+Now we compute the matrix
@texline @math{A'}
-@infoline @expr{A2}
+@infoline @expr{A2}
and divide.
@smallexample
(The actual computed answer will be slightly inexact due to
round-off error.)
-Notice that the answers are similar to those for the
+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
+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
+answer since the
@texline @math{4\times3}
@infoline 4x3
-system would be equivalent to the original
+system would be equivalent to the original
@texline @math{3\times3}
@infoline 3x3
system.)
\afterdisplay
@end tex
-Thus we want a
+Thus we want a
@texline @math{19\times2}
@infoline 19x2
matrix with our @expr{x} vector as one column and
@end smallexample
@noindent
-Now we compute
+Now we compute
@texline @math{A^T y}
-@infoline @expr{trn(A) * y}
-and
+@infoline @expr{trn(A) * y}
+and
@texline @math{A^T A}
-@infoline @expr{trn(A) * A}
+@infoline @expr{trn(A) * A}
and divide.
@smallexample
@end group
@end smallexample
-Since we were solving equations of the form
+Since we were solving equations of the form
@texline @math{m \times x + b \times 1 = y},
-@infoline @expr{m*x + b*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
@kbd{V R}!
@subsection List Tutorial Exercise 4
@noindent
-A number @expr{j} is a divisor of @expr{n} if
+A number @expr{j} is a divisor of @expr{n} if
@texline @math{n \mathbin{\hbox{\code{\%}}} j = 0}.
-@infoline @samp{n % j = 0}.
+@infoline @samp{n % j = 0}.
The first step is to get a vector that identifies the divisors.
@smallexample
zero, so adding zeros on the left and right is safe. From then on
the job is pretty straightforward.
-Incidentally, Calc provides the
+Incidentally, Calc provides the
@texline @dfn{M@"obius} @math{\mu}
-@infoline @dfn{Moebius 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.
The numbers down the lefthand edge of the list we desire are called
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
+can be computed directly by the formula
@texline @math{n (n+1) \over 2}.
@infoline @expr{n * (n+1) / 2}.
@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
+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.)
This problem can be made a lot easier by taking advantage of some
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
+component for one end of the match, pick a random direction
@texline @math{\theta},
@infoline @expr{theta},
-and see if @expr{x} and
+and see if @expr{x} and
@texline @math{x + \cos \theta}
-@infoline @expr{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
numbers surround an integer.
coordinates 0 and 1 for the lines on either side of the leftmost
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
+Pick random @expr{x} and
@texline @math{\theta},
-@infoline @expr{theta},
+@infoline @expr{theta},
compute
@texline @math{x + \cos \theta},
@infoline @expr{x + cos(theta)},
@smallexample
@group
-1: 3.3356 ns 1: 0.81356 ns / ns 1: 0.81356
-2: 4.1 ns . .
+1: 3.3356 ns 1: 0.81356
+2: 4.1 ns .
.
- ' 4.1 ns @key{RET} / u s
+ ' 4.1 ns @key{RET} /
@end group
@end smallexample
@noindent
@smallexample
@group
-1: [x - 1.19023, x + 1.19023, x] 1: (x - 1.19023) (x + 1.19023) x
+1: [x - 1.19023, x + 1.19023, x] 1: x*(x + 1.19023) (x - 1.19023)
. .
V M ' x-$ @key{RET} V R *
@smallexample
@group
-1: x sin(pi x) 1: (sin(pi x) - pi x cos(pi x)) / pi^2
+1: x sin(pi x) 1: sin(pi x) / pi^2 - x cos(pi x) / pi
. .
' x sin(pi x) @key{RET} m r a i x @key{RET}
@smallexample
@group
1: [y, 1]
-2: (sin(pi x) - pi x cos(pi x)) / pi^2
+2: sin(pi x) / pi^2 - x cos(pi x) / pi
.
' [y,1] @key{RET} @key{TAB}
@noindent
@smallexample
@group
-1: [(sin(pi y) - pi y cos(pi y)) / pi^2, (sin(pi) - pi cos(pi)) / pi^2]
+1: [sin(pi y) / pi^2 - y cos(pi y) / pi, 1 / pi]
.
V M $ @key{RET}
@noindent
@smallexample
@group
-1: (sin(pi y) - pi y cos(pi y)) / pi^2 + (pi cos(pi) - sin(pi)) / pi^2
+1: sin(pi y) / pi^2 - y cos(pi y) / pi - 1 / pi
.
V R -
@noindent
@smallexample
@group
-1: (sin(3.14159 y) - 3.14159 y cos(3.14159 y)) / 9.8696 - 0.3183
+1: sin(3.14159 y) / 9.8696 - y cos(3.14159 y) / 3.14159 - 0.3183
.
=
@smallexample
@group
- ___
- 2 + V 2
-1: (2 + sqrt(2)) / (1 + sqrt(2)) 1: --------
- . ___
- 1 + V 2
+ ___
+ V 2 + 2
+1: (2 + sqrt(2)) / (1 + sqrt(2)) 1: ---------
+ . ___
+ V 2 + 1
.
@noindent
@smallexample
@group
- ___ ___
-1: 2 + V 2 - 2 1: V 2
- . .
+ ___
+1: V 2
+ .
- a r a*(b+c) := a*b + a*c a s
+ a r a*(b+c) := a*b + a*c
@end group
@end smallexample
apply to any product-of-sum it encounters---this rule may surprise
you if you put it into @code{EvalRules}!
-In the second rule, the sum of two O's is changed to the smaller O.
+In the second rule, the sum of two O's is changed to the smaller O@.
The optional constant coefficients are there mostly so that
@samp{O(x^2) - O(x^3)} and @samp{O(x^3) - O(x^2)} are handled
as well as @samp{O(x^2) + O(x^3)}.
algebraic entry, whichever way you prefer:
@noindent
-Computing
+Computing
@texline @math{\displaystyle{\sin x \over x}}:
@infoline @expr{sin(x) / x}:
@noindent
This program is quite efficient because Calc knows how to raise a
-matrix (or other value) to the power @expr{n} in only
+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
@noindent
The first step is to compute the derivative @expr{f'(x)} and thus
-the formula
+the formula
@texline @math{\displaystyle{x - {f(x) \over f'(x)}}}.
@infoline @expr{x - f(x)/f'(x)}.
@noindent
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
+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
+on to compute
@texline @math{\psi(z+1)},
-@infoline @expr{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}.
@end group
@end smallexample
-Now we compute the initial part of the sum:
+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.
@end group
@end smallexample
-This is the value of
+This is the value of
@texline @math{-\gamma},
-@infoline @expr{- gamma},
+@infoline @expr{- gamma},
with a slight bit of roundoff error. To get a full 12 digits, let's use
a higher precision:
@noindent
Taking the derivative of a term of the form @expr{x^n} will produce
-a term like
+a term like
@texline @math{n x^{n-1}}.
-@infoline @expr{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
derivative of a polynomial, evaluated at @expr{x = 0}, will equal the
@mindex @null
@end ignore
In most installations, the @kbd{C-x * c} key sequence is a more
-convenient way to start the Calculator. Also, @kbd{C-x * *}
+convenient way to start the Calculator. Also, @kbd{C-x * *}
is a synonym for @kbd{C-x * c} unless you last used Calc
in its Keypad mode.
@kindex Z ?
@pindex calc-help
The @kbd{?} key (@code{calc-help}) displays a series of brief help messages.
-Some keys (such as @kbd{b} and @kbd{d}) are prefix keys, like Emacs'
+Some keys (such as @kbd{b} and @kbd{d}) are prefix keys, like Emacs's
@key{ESC} and @kbd{C-x} prefixes. You can type
@kbd{?} after a prefix to see a list of commands beginning with that
prefix. (If the message includes @samp{[MORE]}, press @kbd{?} again
The @kbd{h f} (@code{calc-describe-function}) command looks up an
algebraic function or a command name in the Calc manual. Enter an
algebraic function name to look up that function in the Function
-Index or enter a command name beginning with @samp{calc-} to look it
+Index or enter a command name beginning with @samp{calc-} to look it
up in the Command Index. This command will also look up operator
-symbols that can appear in algebraic formulas, like @samp{%} and
+symbols that can appear in algebraic formulas, like @samp{%} and
@samp{=>}.
@kindex h v
@cindex Formulas, entering
The @kbd{'} (@code{calc-algebraic-entry}) command can be used to enter
calculations in algebraic form. This is accomplished by typing the
-apostrophe key, ', followed by the expression in standard format:
+apostrophe key, ', followed by the expression in standard format:
@example
' 2+3*4 @key{RET}.
@noindent
This will compute
@texline @math{2+(3\times4) = 14}
-@infoline @expr{2+(3*4) = 14}
+@infoline @expr{2+(3*4) = 14}
and push it on the stack. If you wish you can
ignore the RPN aspect of Calc altogether and simply enter algebraic
expressions in this way. You may want to use @key{DEL} every so often to
the variable @samp{pi}, but @kbd{' pi M-@key{RET}} pushes 3.1415.)
If you finish your algebraic entry by pressing @key{LFD} (or @kbd{C-j})
-instead of @key{RET}, Calc disables the default simplifications
+instead of @key{RET}, Calc disables simplification
(as if by @kbd{m O}; @pxref{Simplification Modes}) while the entry
is being pushed on the stack. Thus @kbd{' 1+2 @key{RET}} pushes 3
on the stack, but @kbd{' 1+2 @key{LFD}} pushes the formula @expr{1+2};
approximation. This value will not need to be recomputed ever again
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
+@cpiover{4} and
@texline @math{\ln 2}.
-@infoline @expr{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.
Other things cached include powers of two (for the binary arithmetic
numbers. HMS forms also for many purposes act as real numbers. These
types can be combined to form complex numbers, modulo forms, error forms,
or interval forms. (But these last four types cannot be combined
-arbitrarily:@: error forms may not contain modulo forms, for example.)
+arbitrarily: error forms may not contain modulo forms, for example.)
Finally, all these types of numbers may be combined into vectors,
matrices, or algebraic formulas.
A floating-point number or @dfn{float} is a number stored in scientific
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
+range of acceptable values is from
@texline @math{10^{-3999999}}
-@infoline @expr{10^-3999999}
-(inclusive) to
+@infoline @expr{10^-3999999}
+(inclusive) to
@texline @math{10^{4000000}}
@infoline @expr{10^4000000}
(exclusive), plus the corresponding negative values and zero.
float that is entered in a radix other that 10 will be converted to
decimal, the number that Calc stores may not be exactly the number that
was entered, it will be the closest decimal approximation given the
-current precison. The notation @samp{@var{radix}#@var{ddd}.@var{ddd}}
+current precision. The notation @samp{@var{radix}#@var{ddd}.@var{ddd}}
is a floating-point number whose digits are in the specified radix.
Note that the @samp{.} is more aptly referred to as a ``radix point''
than as a decimal point in this case. The number @samp{8#123.4567} is
Rectangular complex numbers can also be displayed in @samp{@var{a}+@var{b}i}
notation; @pxref{Complex Formats}.
-Polar complex numbers are displayed in the form
+Polar complex numbers are displayed in the form
@texline `@tfn{(}@var{r}@tfn{;}@math{\theta}@tfn{)}'
@infoline `@tfn{(}@var{r}@tfn{;}@var{theta}@tfn{)}'
-where @var{r} is the nonnegative magnitude and
+where @var{r} is the nonnegative magnitude and
@texline @math{\theta}
-@infoline @var{theta}
-is the argument or phase angle. The range of
+@infoline @var{theta}
+is the argument or phase angle. The range of
@texline @math{\theta}
-@infoline @var{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.
+in radians.
Complex numbers are entered in stages using incomplete objects.
@xref{Incomplete Objects}.
larger, becomes arbitrarily close to zero. So you can imagine
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
+@samp{exp(inf) = inf}, they mean that
@texline @math{e^x}
-@infoline @expr{exp(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
@samp{exp(-inf) = 0}. You can have an infinity pointing in any
@end ignore
@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
+to build @samp{[a, b, c]}, @samp{cvec(a, n, m)} to build an
@texline @math{n\times m}
@infoline @var{n}x@var{m}
matrix of @samp{a}s, and @samp{index(n)} to build a vector of integers
notations for dates and times. @xref{Date Formats}.
Date forms are stored internally as numbers, specifically the number
-of days since midnight on the morning of January 1 of the year 1 AD.
+of days since midnight on the morning of December 31 of the year 1 BC@.
If the internal number is an integer, the form represents a date only;
if the internal number is a fraction or float, the form represents
-a date and time. For example, @samp{<6:00am Wed Jan 9, 1991>}
+a date and time. For example, @samp{<6:00am Thu Jan 10, 1991>}
is represented by the number 726842.25. The standard precision of
12 decimal digits is enough to ensure that a (reasonable) date and
time can be stored without roundoff error.
of a date form. @xref{Packing and Unpacking}.
Date forms can go arbitrarily far into the future or past. Negative
-year numbers represent years BC. Calc uses a combination of the
-Gregorian and Julian calendars, following the history of Great
-Britain and the British colonies. This is the same calendar that
-is used by the @code{cal} program in most Unix implementations.
+year numbers represent years BC@. There is no ``year 0''; the day
+before @samp{<Mon Jan 1, +1>} is @samp{<Sun Dec 31, -1>}. These are
+days 1 and 0 respectively in Calc's internal numbering scheme. The
+Gregorian calendar is used for all dates, including dates before the
+Gregorian calendar was invented (although that can be configured; see
+below). Thus Calc's use of the day number @mathit{-10000} to
+represent August 15, 28 BC should be taken with a grain of salt.
@cindex Julian calendar
@cindex Gregorian calendar
Some historical background: The Julian calendar was created by
-Julius Caesar in the year 46 BC as an attempt to fix the gradual
-drift caused by the lack of leap years in the calendar used
-until that time. The Julian calendar introduced an extra day in
-all years divisible by four. After some initial confusion, the
-calendar was adopted around the year we call 8 AD. Some centuries
-later it became apparent that the Julian year of 365.25 days was
-itself not quite right. In 1582 Pope Gregory XIII introduced the
-Gregorian calendar, which added the new rule that years divisible
-by 100, but not by 400, were not to be considered leap years
-despite being divisible by four. Many countries delayed adoption
-of the Gregorian calendar because of religious differences;
-in Britain it was put off until the year 1752, by which time
-the Julian calendar had fallen eleven days behind the true
-seasons. So the switch to the Gregorian calendar in early
-September 1752 introduced a discontinuity: The day after
-Sep 2, 1752 is Sep 14, 1752. Calc follows this convention.
-To take another example, Russia waited until 1918 before
-adopting the new calendar, and thus needed to remove thirteen
-days (between Feb 1, 1918 and Feb 14, 1918). This means that
-Calc's reckoning will be inconsistent with Russian history between
-1752 and 1918, and similarly for various other countries.
-
-Today's timekeepers introduce an occasional ``leap second'' as
-well, but Calc does not take these minor effects into account.
-(If it did, it would have to report a non-integer number of days
-between, say, @samp{<12:00am Mon Jan 1, 1900>} and
+Julius Caesar in the year 46 BC as an attempt to fix the confusion
+caused by the irregular Roman calendar that was used before that time.
+The Julian calendar introduced an extra day in all years divisible by
+four. After some initial confusion, the calendar was adopted around
+the year we call 8 AD@. Some centuries later it became
+apparent that the Julian year of 365.25 days was itself not quite
+right. In 1582 Pope Gregory XIII introduced the Gregorian calendar,
+which added the new rule that years divisible by 100, but not by 400,
+were not to be considered leap years despite being divisible by four.
+Many countries delayed adoption of the Gregorian calendar
+because of religious differences. For example, Great Britain and the
+British colonies switched to the Gregorian calendar in September
+1752, when the Julian calendar was eleven days behind the
+Gregorian calendar. That year in Britain, the day after September 2
+was September 14. To take another example, Russia did not adopt the
+Gregorian calendar until 1918, and that year in Russia the day after
+January 31 was February 14. Calc's reckoning therefore matches English
+practice starting in 1752 and Russian practice starting in 1918, but
+disagrees with earlier dates in both countries.
+
+When the Julian calendar was introduced, it had January 1 as the first
+day of the year. By the Middle Ages, many European countries
+had changed the beginning of a new year to a different date, often to
+a religious festival. Almost all countries reverted to using January 1
+as the beginning of the year by the time they adopted the Gregorian
+calendar.
+
+Some calendars attempt to mimic the historical situation by using the
+Gregorian calendar for recent dates and the Julian calendar for older
+dates. The @code{cal} program in most Unix implementations does this,
+for example. While January 1 wasn't always the beginning of a calendar
+year, these hybrid calendars still use January 1 as the beginning of
+the year even for older dates. The customizable variable
+@code{calc-gregorian-switch} (@pxref{Customizing Calc}) can be set to
+have Calc's date forms switch from the Julian to Gregorian calendar at
+any specified date.
+
+Today's timekeepers introduce an occasional ``leap second''.
+These do not occur regularly and Calc does not take these minor
+effects into account. (If it did, it would have to report a
+non-integer number of days between, say,
+@samp{<12:00am Mon Jan 1, 1900>} and
@samp{<12:00am Sat Jan 1, 2000>}.)
-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 called
-``Julian.'' The Julian day number is the numbers of days since
-12:00 noon (GMT) on Jan 1, 4713 BC, which in Calc's scheme (in GMT)
-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 after
+``Julian.'' Julian days go from noon to noon. The Julian day number
+is the numbers of days since 12:00 noon (GMT) on November 24, 4714 BC
+in the Gregorian calendar (i.e., January 1, 4713 BC in the Julian
+calendar). In Calc's scheme (in GMT) the Julian day origin is
+@mathit{-1721422.5}, because 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 1721422.5 after
compensating for the time zone difference. The built-in @kbd{t J}
command performs this conversion for you.
@texline @math{15\times 19\times 28 = 7980} years.
@infoline 15*19*28 = 7980 years.
This is the length of a Julian cycle. Working backwards, the previous
-year in which all three cycles began was 4713 BC, and so Scalinger
+year in which all three cycles began was 4713 BC, and so Scaliger
chose that year as the beginning of a Julian cycle. Since at the time
there were no historical records from before 4713 BC, using this year
as a starting point had the advantage of avoiding negative year
up by other astronomers. (At the time, noon was the start of the
astronomical day. Herschel originally suggested counting the days
since Jan 1, 4713 BC at noon Alexandria time; this was later amended to
-noon GMT.) Julian day numbering is largely used in astronomy.
+noon GMT@.) Julian day numbering is largely used in astronomy.
@cindex Unix time format
The Unix operating system measures time as an integer number of
division is left in symbolic form. Other operations, such as square
roots, are not yet supported for modulo forms. (Note that, although
@w{`@tfn{(}@var{a} @tfn{mod} @var{M}@tfn{)^.5}'} will compute a ``modulo square root''
-in the sense of reducing
+in the sense of reducing
@texline @math{\sqrt a}
-@infoline @expr{sqrt(a)}
+@infoline @expr{sqrt(a)}
modulo @expr{M}, this is not a useful definition from the
number-theoretical point of view.)
@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 `@var{x} @tfn{+/-} @math{\sigma}'
-@infoline `@var{x} @tfn{+/-} sigma'
+@texline `@var{x} @tfn{+/-} @math{\sigma}'
+@infoline `@var{x} @tfn{+/-} sigma'
stands for an uncertain value which follows
a normal or Gaussian distribution of mean @expr{x} and standard
-deviation or ``error''
+deviation or ``error''
@texline @math{\sigma}.
@infoline @expr{sigma}.
Both the mean and the error can be either numbers or
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
+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}
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 `@tfn{sin(}@var{x} @tfn{+/-} @math{\sigma}@tfn{)}'
-@infoline `@tfn{sin(}@var{x} @tfn{+/-} @var{sigma}@tfn{)}'
-is
-@texline `@math{\sigma} @tfn{abs(cos(}@var{x}@tfn{))}'.
-@infoline `@var{sigma} @tfn{abs(cos(}@var{x}@tfn{))}'.
+@texline `@tfn{sin(}@var{x} @tfn{+/-} @math{\sigma}@tfn{)}'
+@infoline `@tfn{sin(}@var{x} @tfn{+/-} @var{sigma}@tfn{)}'
+is
+@texline `@math{\sigma} @tfn{abs(cos(}@var{x}@tfn{))}'.
+@infoline `@var{sigma} @tfn{abs(cos(}@var{x}@tfn{))}'.
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
+@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
+this makes sense, since
@texline @math{\sin x}
-@infoline @expr{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)}
+@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
+has relatively little effect on the value of
@texline @math{\sin x}.
-@infoline @expr{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)}
+@infoline @expr{sin(x)}
would indeed have been negligible.
@ignore
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 `@var{x} @tfn{+/-} @math{\sigma}'
-@infoline `@var{x} @tfn{+/-} @var{sigma}'
+form
+@texline `@var{x} @tfn{+/-} @math{\sigma}'
+@infoline `@var{x} @tfn{+/-} @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
+be anything but is ``probably'' within one
+@texline @math{\sigma}
+@infoline @var{sigma}
+of the mean value @expr{x}. An interval
`@tfn{[}@var{a} @tfn{..@:} @var{b}@tfn{]}' means a
variable's value is unknown, but guaranteed to lie in the specified
range. Error forms are statistical or ``average case'' approximations;
@samp{=>} [@code{evalto}].
Note that, unlike in usual computer notation, multiplication binds more
-strongly than division: @samp{a*b/c*d} is equivalent to
+strongly than division: @samp{a*b/c*d} is equivalent to
@texline @math{a b \over c d}.
@infoline @expr{(a*b)/(c*d)}.
stack and the point on the line containing @samp{30}, @kbd{C-x C-t}
creates @samp{10 20 40 30 50}. More generally, @kbd{C-x C-t} acts on
the stack objects determined by the current point (and mark) similar
-to how the text-mode command @code{transpose-lines} acts on
+to how the text-mode command @code{transpose-lines} acts on
lines. With argument @var{n}, @kbd{C-x C-t} will move the stack object
at the level above the current point and move it past N other objects;
for example, with @samp{10 20 30 40 50} on the stack and the point on
-the line containing @samp{30}, @kbd{C-u 2 C-x C-t} creates
+the line containing @samp{30}, @kbd{C-u 2 C-x C-t} creates
@samp{10 40 20 30 50}. With an argument of 0, @kbd{C-x C-t} will switch
-the stack objects at the levels determined by the point and the mark.
+the stack objects at the levels determined by the point and the mark.
@node Editing Stack Entries, Trail Commands, Stack Manipulation, Stack and Trail
@section Editing Stack Entries
With the exception of keyboard macros, this works for all commands that
take arguments off the stack. (To avoid potentially unpleasant behavior,
a @kbd{K} prefix before a keyboard macro will be ignored. A @kbd{K}
-prefix called @emph{within} the keyboard macro will still take effect.)
+prefix called @emph{within} the keyboard macro will still take effect.)
As another example, @kbd{K a s} simplifies a formula, pushing the
simplified version of the formula onto the stack after the original
formula (rather than replacing the original formula). Note that you
formula and then simplifying the copy. One difference is that for a very
large formula the time taken to format the intermediate copy in
@kbd{@key{RET} a s} could be noticeable; @kbd{K a s} would avoid this
-extra work.
+extra work.
Even stack manipulation commands are affected. @key{TAB} works by
popping two values and pushing them back in the opposite order,
If the file name you give is your user init file (typically
@file{~/.emacs}), @kbd{m F} will not automatically load the new file. This
is because your user init file may contain other things you don't want
-to reread. You can give
+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. Conversely, an argument of @mathit{-1} tells
@kbd{m F} @emph{not} to read the new file. An argument of 2 or @mathit{-2}
@pindex calc-option
The @kbd{O} key (@code{calc-option}) sets another flag, the
@dfn{Option Flag}, which also can alter the subsequent Calc command in
-various ways.
+various ways.
The Inverse, Hyperbolic and Option flags apply only to the next
Calculator command, after which they are automatically cleared. (They
rather get an exact fractional answer. One way to accomplish this is
to use the @kbd{:} (@code{calc-fdiv}) [@code{fdiv}] command, which
divides the two integers on the top of the stack to produce a fraction:
-@kbd{6 @key{RET} 4 :} produces @expr{3:2} even though
+@kbd{6 @key{RET} 4 :} produces @expr{3:2} even though
@kbd{6 @key{RET} 4 /} produces @expr{1.5}.
@kindex m f
Some normalizations are unavoidable, such as rounding floating-point
results to the current precision, and reducing fractions to simplest
form. Others, such as simplifying a formula like @expr{a+a} (or @expr{2+3}),
-are done by default but can be turned off when necessary.
+are done automatically but can be turned off when necessary.
When you press a key like @kbd{+} when @expr{2} and @expr{3} are on the
stack, Calc pops these numbers, normalizes them, creates the formula
The @kbd{m O} (@code{calc-no-simplify-mode}) command turns off all optional
simplifications. These would leave a formula like @expr{2+3} alone. In
fact, nothing except simple numbers are ever affected by normalization
-in this mode.
+in this mode. Explicit simplification commands, such as @kbd{=} or
+@kbd{a s}, can still be given to simplify any formulas.
+@xref{Algebraic Definitions}, for a sample use of
+No-Simplification mode.
+
@kindex m N
@pindex calc-num-simplify-mode
error form or modulo form), or a vector all of whose
elements are constant.
-@kindex m D
-@pindex calc-default-simplify-mode
-The @kbd{m D} (@code{calc-default-simplify-mode}) command restores the
-default simplifications for all formulas. This includes many easy and
+@kindex m I
+@pindex calc-basic-simplify-mode
+The @kbd{m I} (@code{calc-basic-simplify-mode}) command does some basic
+simplifications for all formulas. This includes many easy and
fast algebraic simplifications such as @expr{a+0} to @expr{a}, and
@expr{a + 2 a} to @expr{3 a}, as well as evaluating functions like
@expr{@tfn{deriv}(x^2, x)} to @expr{2 x}.
@kindex m B
@pindex calc-bin-simplify-mode
-The @kbd{m B} (@code{calc-bin-simplify-mode}) mode applies the default
+The @kbd{m B} (@code{calc-bin-simplify-mode}) mode applies the basic
simplifications to a result and then, if the result is an integer,
uses the @kbd{b c} (@code{calc-clip}) command to clip the integer according
to the current binary word size. @xref{Binary Functions}. Real numbers
are rounded to the nearest integer and then clipped; other kinds of
-results (after the default simplifications) are left alone.
+results (after the basic simplifications) are left alone.
@kindex m A
@pindex calc-alg-simplify-mode
-The @kbd{m A} (@code{calc-alg-simplify-mode}) mode does algebraic
-simplification; it applies all the default simplifications, and also
-the more powerful (and slower) simplifications made by @kbd{a s}
-(@code{calc-simplify}). @xref{Algebraic Simplifications}.
+The @kbd{m A} (@code{calc-alg-simplify-mode}) mode does standard
+algebraic simplifications. @xref{Algebraic Simplifications}.
@kindex m E
@pindex calc-ext-simplify-mode
-The @kbd{m E} (@code{calc-ext-simplify-mode}) mode does ``extended''
-algebraic simplification, as by the @kbd{a e} (@code{calc-simplify-extended})
-command. @xref{Unsafe Simplifications}.
+The @kbd{m E} (@code{calc-ext-simplify-mode}) mode does ``extended'', or
+``unsafe'', algebraic simplification. @xref{Unsafe Simplifications}.
@kindex m U
@pindex calc-units-simplify-mode
The @kbd{m U} (@code{calc-units-simplify-mode}) mode does units
-simplification; it applies the command @kbd{u s}
-(@code{calc-simplify-units}), which in turn
-is a superset of @kbd{a s}. In this mode, variable names which
+simplification. @xref{Simplification of Units}. These include the
+algebraic simplifications, plus variable names which
are identifiable as unit names (like @samp{mm} for ``millimeters'')
are simplified with their unit definitions in mind.
A common technique is to set the simplification mode down to the lowest
amount of simplification you will allow to be applied automatically, then
use manual commands like @kbd{a s} and @kbd{c c} (@code{calc-clean}) to
-perform higher types of simplifications on demand. @xref{Algebraic
-Definitions}, for another sample use of No-Simplification mode.
-
+perform higher types of simplifications on demand.
@node Declarations, Display Modes, Simplification Modes, Mode Settings
@section Declarations
only when certain values are integers (such as @samp{(x^y)^z}
shown above).
-Another command that makes use of declarations is @kbd{a s}, when
-simplifying equations and inequalities. It will cancel @code{x}
+Calc's algebraic simplifications also make use of declarations when
+simplifying equations and inequalities. They will cancel @code{x}
from both sides of @samp{a x = b x} only if it is sure @code{x}
is non-zero, say, because it has a @code{pos} declaration.
To declare specifically that @code{x} is real and non-zero,
use @samp{[[-inf .. 0), (0 .. inf]]}. (There is no way in the
current notation to say that @code{x} is nonzero but not necessarily
real.) The @kbd{a e} command does ``unsafe'' simplifications,
-including cancelling @samp{x} from the equation when @samp{x} is
+including canceling @samp{x} from the equation when @samp{x} is
not known to be nonzero.
Another set of type symbols distinguish between scalars and vectors.
The @code{dpos} function checks for positive (but nonzero) reals.
The @code{dneg} function checks for negative reals. The @code{dnonneg}
function checks for nonnegative reals, i.e., reals greater than or
-equal to zero. Note that the @kbd{a s} command can simplify an
-expression like @expr{x > 0} to 1 or 0 using @code{dpos}, and that
-@kbd{a s} is effectively applied to all conditions in rewrite rules,
-so the actual functions @code{dpos}, @code{dneg}, and @code{dnonneg}
+equal to zero. Note that Calc's algebraic simplifications, which are
+effectively applied to all conditions in rewrite rules, can simplify
+an expression like @expr{x > 0} to 1 or 0 using @code{dpos}.
+So the actual functions @code{dpos}, @code{dneg}, and @code{dnonneg}
are rarely necessary.
@ignore
The @code{deven} function returns 1 if its argument is known to be
an even integer (or integer-valued float); it returns 0 if its argument
is known not to be even (because it is known to be odd or a non-integer).
-The @kbd{a s} command uses this to simplify a test of the form
+Calc's algebraic simplifications use this to simplify a test of the form
@samp{x % 2 = 0}. There is also an analogous @code{dodd} function.
@ignore
command causes integers to be padded out with leading zeros according to the
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
+are displayed with at least enough digits to represent
@texline @math{2^w-1}
-@infoline @expr{(2^w)-1}
+@infoline @expr{(2^w)-1}
in the current radix. (Larger integers will still be displayed in their
-entirety.)
+entirety.)
@cindex Two's complements
Calc can display @expr{w}-bit integers using two's complement
are represented by themselves and the integers from
@texline @math{-2^{w-1}}
@infoline @expr{-2^(w-1)}
-to @expr{-1} are represented by the integers from
+to @expr{-1} are represented by the integers from
@texline @math{2^{w-1}}
@infoline @expr{2^(w-1)}
to @expr{2^w-1} (the integer @expr{k} is represented by @expr{k+2^w}).
representation (including any leading zeros necessary to include all
@expr{w} bits). In a two's complement display mode, numbers that
are not displayed in two's complement notation (i.e., that aren't
-integers from
+integers from
@texline @math{-2^{w-1}}
@infoline @expr{-2^(w-1)}
to
functions, your date formats should avoid using the @samp{#} character.
@menu
+* ISO 8601::
* Date Formatting Codes::
* Free-Form Dates::
* Standard Date Formats::
@end menu
-@node Date Formatting Codes, Free-Form Dates, Date Formats, Date Formats
+@node ISO 8601, Date Formatting Codes, Date Formats, Date Formats
+@subsubsection ISO 8601
+
+@noindent
+@cindex ISO 8601
+The same date can be written down in different formats and Calc tries
+to allow you to choose your preferred format. Some common formats are
+ambiguous, however; for example, 10/11/2012 means October 11,
+2012 in the United States but it means November 10, 2012 in
+Europe. To help avoid such ambiguities, the International Organization
+for Standardization (ISO) provides the ISO 8601 standard, which
+provides three different but easily distinguishable and unambiguous
+ways to represent a date.
+
+The ISO 8601 calendar date representation is
+
+@example
+ @var{YYYY}-@var{MM}-@var{DD}
+@end example
+
+@noindent
+where @var{YYYY} is the four digit year, @var{MM} is the two-digit month
+number (01 for January to 12 for December), and @var{DD} is the
+two-digit day of the month (01 to 31). (Note that @var{YYYY} does not
+correspond to Calc's date formatting code, which will be introduced
+later.) The year, which should be padded with zeros to ensure it has at
+least four digits, is the Gregorian year, except that the year before
+0001 (1 AD) is the year 0000 (1 BC). The date October 11, 2012 is
+written 2012-10-11 in this representation and November 10, 2012 is
+written 2012-11-10.
+
+The ISO 8601 ordinal date representation is
+
+@example
+ @var{YYYY}-@var{DDD}
+@end example
+
+@noindent
+where @var{YYYY} is the year, as above, and @var{DDD} is the day of the year.
+The date December 31, 2011 is written 2011-365 in this representation
+and January 1, 2012 is written 2012-001.
+
+The ISO 8601 week date representation is
+
+@example
+ @var{YYYY}-W@var{ww}-@var{D}
+@end example
+
+@noindent
+where @var{YYYY} is the ISO week-numbering year, @var{ww} is the two
+digit week number (preceded by a literal ``W''), and @var{D} is the day
+of the week (1 for Monday through 7 for Sunday). The ISO week-numbering
+year is based on the Gregorian year but can differ slightly. The first
+week of an ISO week-numbering year is the week with the Gregorian year's
+first Thursday in it (equivalently, the week containing January 4);
+any day of that week (Monday through Sunday) is part of the same ISO
+week-numbering year, any day from the previous week is part of the
+previous year. For example, January 4, 2013 is on a Friday, and so
+the first week for the ISO week-numbering year 2013 starts on
+Monday, December 31, 2012. The day December 31, 2012 is then part of the
+Gregorian year 2012 but ISO week-numbering year 2013. In the week
+date representation, this week goes from 2013-W01-1 (December 31,
+2012) to 2013-W01-7 (January 6, 2013).
+
+All three ISO 8601 representations arrange the numbers from most
+significant to least significant; as well as being unambiguous
+representations, they are easy to sort since chronological order in
+this formats corresponds to lexicographical order. The hyphens are
+sometimes omitted.
+
+The ISO 8601 standard uses a 24 hour clock; a particular time is
+represented by @var{hh}:@var{mm}:@var{ss} where @var{hh} is the
+two-digit hour (from 00 to 24), @var{mm} is the two-digit minute (from
+00 to 59) and @var{ss} is the two-digit second. The seconds or minutes
+and seconds can be omitted, and decimals can be added. If a date with a
+time is represented, they should be separated by a literal ``T'', so noon
+on December 13, 2012 can be represented as 2012-12-13T12:00.
+
+@node Date Formatting Codes, Free-Form Dates, ISO 8601, Date Formats
@subsubsection Date Formatting Codes
@noindent
match exactly; letter fields must correspond to suitable text in
the input. If this doesn't work, Calc checks if the input is a
simple number; if so, the number is interpreted as a number of days
-since Jan 1, 1 AD. Otherwise, Calc tries a much more relaxed and
+since Dec 31, 1 BC@. Otherwise, Calc tries a much more relaxed and
flexible algorithm which is described in the next section.
Weekday names are ignored during reading.
Year: ``1991'' for 1991, ``23'' for 23 AD.
@item YYYY
Year: ``1991'' for 1991, ``+23'' for 23 AD.
+@item ZYYY
+Year: ``1991'' for 1991, ``0023'' for 23 AD, ``0000'' for 1 BC.
+@item IYYY
+Year: ISO 8601 week-numbering year.
@item aa
Year: ``ad'' or blank.
@item AA
@item AAA
Year: ``AD '' or blank.
@item aaaa
-Year: ``a.d.'' or blank.
+Year: ``a.d.@:'' or blank.
@item AAAA
Year: ``A.D.'' or blank.
@item bb
@item BBB
Year: `` BC'' or blank.
@item bbbb
-Year: ``b.c.'' or blank.
+Year: ``b.c.@:'' or blank.
@item BBBB
Year: ``B.C.'' or blank.
@item M
Day: `` 7'' for 7th day of month.
@item W
Weekday: ``0'' for Sunday, ``6'' for Saturday.
+@item w
+Weekday: ``1'' for Monday, ``7'' for Sunday.
@item WWW
Weekday: ``SUN'' for Sunday.
@item Www
Weekday: ``SUNDAY'' for Sunday.
@item Wwww
Weekday: ``Sunday'' for Sunday.
+@item Iww
+Week number: ISO 8601 week number, ``W01'' for week 1.
@item d
Day of year: ``34'' for Feb. 3.
@item ddd
Day of year: ``034'' for Feb. 3.
@item bdd
Day of year: `` 34'' for Feb. 3.
+@item T
+Letter: Literal ``T''.
@item h
Hour: ``5'' for 5 AM; ``17'' for 5 PM.
@item hh
@item PP
AM/PM: ``AM'' or ``PM''.
@item pppp
-AM/PM: ``a.m.'' or ``p.m.''.
+AM/PM: ``a.m.@:'' or ``p.m.''.
@item PPPP
AM/PM: ``A.M.'' or ``P.M.''.
@item m
@samp{p.m.}, and @samp{mid} are also understood. Obviously
@samp{noon} and @samp{midnight} are allowed only on 12:00:00.
The words @samp{noon}, @samp{mid}, and @samp{midnight} are also
-recognized with no number attached.
+recognized with no number attached. Midnight will represent the
+beginning of a day.
If there is no AM/PM indicator, the time is interpreted in 24-hour
format.
-To read the date portion, all words and numbers are isolated
-from the string; other characters are ignored. All words must
-be either month names or day-of-week names (the latter of which
-are ignored). Names can be written in full or as three-letter
+When reading the date portion, Calc first checks to see if it is an
+ISO 8601 week-numbering date; if the string contains an integer
+representing the year, a ``W'' followed by two digits for the week
+number, and an integer from 1 to 7 representing the weekday (in that
+order), then all other characters are ignored and this information
+determines the date. Otherwise, all words and numbers are isolated
+from the string; other characters are ignored. All words must be
+either month names or day-of-week names (the latter of which are
+ignored). Names can be written in full or as three-letter
abbreviations.
Large numbers, or numbers with @samp{+} or @samp{-} signs,
@samp{j<, h:mm:ss>} (Julian day plus time)
@item 9
@samp{YYddd< hh:mm:ss>} (Year-day format)
+@item 10
+@samp{ZYYY-MM-DD Www< hh:mm>} (Org mode format)
+@item 11
+@samp{IYYY-Iww-w<Thh:mm:ss>} (ISO 8601 week numbering format)
@end table
@node Truncating the Stack, Justification, Date Formats, Display Modes
@noindent
The commands in this section change Calc to use a different notation for
entry and display of formulas, corresponding to the conventions of some
-other common language such as Pascal or La@TeX{}. Objects displayed on the
+other common language such as Pascal or @LaTeX{}. Objects displayed on the
stack or yanked from the Calculator to an editing buffer will be formatted
in the current language; objects entered in algebraic entry or yanked from
another buffer will be interpreted according to the current language.
and would have written the formula back with notations (like implicit
multiplication) which would not have been valid for a C program.
-As another example, suppose you are maintaining a C program and a La@TeX{}
+As another example, suppose you are maintaining a C program and a @LaTeX{}
document, each of which needs a copy of the same formula. You can grab the
-formula from the program in C mode, switch to La@TeX{} mode, and yank the
-formula into the document in La@TeX{} math-mode format.
+formula from the program in C mode, switch to @LaTeX{} mode, and yank the
+formula into the document in @LaTeX{} math-mode format.
Language modes are selected by typing the letter @kbd{d} followed by a
shifted letter key.
convert to lower-case for display and input.
@node TeX and LaTeX Language Modes, Eqn Language Mode, C FORTRAN Pascal, Language Modes
-@subsection @TeX{} and La@TeX{} Language Modes
+@subsection @TeX{} and @LaTeX{} Language Modes
@noindent
@kindex d T
The @kbd{d T} (@code{calc-tex-language}) command selects the conventions
of ``math mode'' in Donald Knuth's @TeX{} typesetting language,
and the @kbd{d L} (@code{calc-latex-language}) command selects the
-conventions of ``math mode'' in La@TeX{}, a typesetting language that
-uses @TeX{} as its formatting engine. Calc's La@TeX{} language mode can
-read any formula that the @TeX{} language mode can, although La@TeX{}
+conventions of ``math mode'' in @LaTeX{}, a typesetting language that
+uses @TeX{} as its formatting engine. Calc's @LaTeX{} language mode can
+read any formula that the @TeX{} language mode can, although @LaTeX{}
mode may display it differently.
Formulas are entered and displayed in the appropriate notation;
@texline @math{\sin(a/b)}
@infoline @expr{sin(a/b)}
will appear as @samp{\sin\left( @{a \over b@} \right)} in @TeX{} mode and
-@samp{\sin\left(\frac@{a@}@{b@}\right)} in La@TeX{} mode.
+@samp{\sin\left(\frac@{a@}@{b@}\right)} in @LaTeX{} mode.
Math formulas are often enclosed by @samp{$ $} signs in @TeX{} and
-La@TeX{}; these should be omitted when interfacing with Calc. To Calc,
+@LaTeX{}; these should be omitted when interfacing with Calc. To Calc,
the @samp{$} sign has the same meaning it always does in algebraic
formulas (a reference to an existing entry on the stack).
Complex numbers are displayed as in @samp{3 + 4i}. Fractions and
-quotients are written using @code{\over} in @TeX{} mode (as in
-@code{@{a \over b@}}) and @code{\frac} in La@TeX{} mode (as in
+quotients are written using @code{\over} in @TeX{} mode (as in
+@code{@{a \over b@}}) and @code{\frac} in @LaTeX{} mode (as in
@code{\frac@{a@}@{b@}}); binomial coefficients are written with
@code{\choose} in @TeX{} mode (as in @code{@{a \choose b@}}) and
-@code{\binom} in La@TeX{} mode (as in @code{\binom@{a@}@{b@}}).
+@code{\binom} in @LaTeX{} mode (as in @code{\binom@{a@}@{b@}}).
Interval forms are written with @code{\ldots}, and error forms are
-written with @code{\pm}. Absolute values are written as in
+written with @code{\pm}. Absolute values are written as in
@samp{|x + 1|}, and the floor and ceiling functions are written with
@code{\lfloor}, @code{\rfloor}, etc. The words @code{\left} and
-@code{\right} are ignored when reading formulas in @TeX{} and La@TeX{}
+@code{\right} are ignored when reading formulas in @TeX{} and @LaTeX{}
modes. Both @code{inf} and @code{uinf} are written as @code{\infty};
when read, @code{\infty} always translates to @code{inf}.
Function calls are written the usual way, with the function name followed
by the arguments in parentheses. However, functions for which @TeX{}
-and La@TeX{} have special names (like @code{\sin}) will use curly braces
+and @LaTeX{} have special names (like @code{\sin}) will use curly braces
instead of 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
+printed result is
@texline @math{\sin{2 x}}
-@infoline @expr{sin 2x}
-but
+@infoline @expr{sin 2x}
+but
@texline @math{\sin(2 + x)}.
@infoline @expr{sin(2 + x)}.
the @samp{tex} prefix; the unit name for a @TeX{} point will be
@samp{pt} instead of @samp{texpt}, for example.
-Function and variable names not treated specially by @TeX{} and La@TeX{}
+Function and variable names not treated specially by @TeX{} and @LaTeX{}
are simply written out as-is, which will cause them to come out in
italic letters in the printed document. If you invoke @kbd{d T} or
@kbd{d L} with a positive numeric prefix argument, names of more than
one character will instead be enclosed in a protective commands that
will prevent them from being typeset in the math italics; they will be
-written @samp{\hbox@{@var{name}@}} in @TeX{} mode and
-@samp{\text@{@var{name}@}} in La@TeX{} mode. The
+written @samp{\hbox@{@var{name}@}} in @TeX{} mode and
+@samp{\text@{@var{name}@}} in @LaTeX{} mode. The
@samp{\hbox@{ @}} and @samp{\text@{ @}} notations are ignored during
reading. If you use a negative prefix argument, such function names are
written @samp{\@var{name}}, and function names that begin with @code{\} during
During reading, text of the form @samp{\matrix@{ ...@: @}} is replaced
by @samp{[ ...@: ]}. The same also applies to @code{\pmatrix} and
-@code{\bmatrix}. In La@TeX{} mode this also applies to
+@code{\bmatrix}. In @LaTeX{} mode this also applies to
@samp{\begin@{matrix@} ... \end@{matrix@}},
@samp{\begin@{bmatrix@} ... \end@{bmatrix@}},
@samp{\begin@{pmatrix@} ... \end@{pmatrix@}}, as well as
The symbol @samp{&} is interpreted as a comma,
and the symbols @samp{\cr} and @samp{\\} are interpreted as semicolons.
During output, matrices are displayed in @samp{\matrix@{ a & b \\ c & d@}}
-format in @TeX{} mode and in
+format in @TeX{} mode and in
@samp{\begin@{pmatrix@} a & b \\ c & d \end@{pmatrix@}} format in
-La@TeX{} mode; you may need to edit this afterwards to change to your
+@LaTeX{} mode; you may need to edit this afterwards to change to your
preferred matrix form. If you invoke @kbd{d T} or @kbd{d L} with an
argument of 2 or -2, then matrices will be displayed in two-dimensional
-form, such as
+form, such as
@example
\begin@{pmatrix@}
@end example
@noindent
-While this wouldn't bother Calc, it is incorrect La@TeX{}.
+While this wouldn't bother Calc, it is incorrect @LaTeX{}.
(Similarly for @TeX{}.)
Accents like @code{\tilde} and @code{\bar} translate into function
sequence is treated as an accent. The @code{\vec} accent corresponds
to the function name @code{Vec}, because @code{vec} is the name of
a built-in Calc function. The following table shows the accents
-in Calc, @TeX{}, La@TeX{} and @dfn{eqn} (described in the next section):
+in Calc, @TeX{}, @LaTeX{} and @dfn{eqn} (described in the next section):
@ignore
@iftex
@example
Calc TeX LaTeX eqn
---- --- ----- ---
-acute \acute \acute
-Acute \Acute
+acute \acute \acute
+Acute \Acute
bar \bar \bar bar
Bar \Bar
-breve \breve \breve
-Breve \Breve
-check \check \check
-Check \Check
+breve \breve \breve
+Breve \Breve
+check \check \check
+Check \Check
dddot \dddot
ddddot \ddddot
dot \dot \dot dot
Dot \Dot
dotdot \ddot \ddot dotdot
-DotDot \Ddot
+DotDot \Ddot
dyad dyad
-grave \grave \grave
-Grave \Grave
+grave \grave \grave
+Grave \Grave
hat \hat \hat hat
-Hat \Hat
+Hat \Hat
Prime prime
tilde \tilde \tilde tilde
Tilde \Tilde
@end example
Note that, because these symbols are ignored, reading a @TeX{} or
-La@TeX{} formula into Calc and writing it back out may lose spacing and
-font information.
+@LaTeX{} formula into Calc and writing it back out may lose spacing and
+font information.
Also, the ``discretionary multiplication sign'' @samp{\*} is read
the same as @samp{*}.
symbol (these are used to introduce spaces of various widths into
the typeset output of @dfn{eqn}).
-As in La@TeX{} mode, Calc's formatter omits parentheses around the
+As in @LaTeX{} mode, Calc's formatter omits parentheses around the
arguments of functions like @code{ln} and @code{sin} if they are
``simple-looking''; in this case Calc surrounds the argument with
braces, separated by a @samp{~} from the function name: @samp{sin~@{x@}}.
of quotes in @dfn{eqn}, but it is good enough for most uses.
Accent codes (@samp{@var{x} dot}) are handled by treating them as
-function calls (@samp{dot(@var{x})}) internally.
+function calls (@samp{dot(@var{x})}) internally.
@xref{TeX and LaTeX Language Modes}, for a table of these accent
functions. The @code{prime} accent is treated specially if it occurs on
a variable or function name: @samp{f prime prime @w{( x prime )}} is
The @kbd{d Y} (@code{calc-yacas-language}) command selects the
conventions of Yacas, a free computer algebra system. While the
operators and functions in Yacas are similar to those of Calc, the names
-of built-in functions in Yacas are capitalized. The Calc formula
+of built-in functions in Yacas are capitalized. The Calc formula
@samp{sin(2 x)}, for example, is entered and displayed @samp{Sin(2 x)}
in Yacas mode, and `@samp{arcsin(x^2)} is @samp{ArcSin(x^2)} in Yacas
mode. Complex numbers are written are written @samp{3 + 4 I}.
represents both @code{inf} and @code{uinf}, and @code{Undefined}
represents @code{nan}.
-Certain operators on functions, such as @code{D} for differentiation
+Certain operators on functions, such as @code{D} for differentiation
and @code{Integrate} for integration, take a prefix form in Yacas. For
-example, the derivative of @w{@samp{e^x sin(x)}} can be computed with
+example, the derivative of @w{@samp{e^x sin(x)}} can be computed with
@w{@samp{D(x) Exp(x)*Sin(x)}}.
Other notable differences between Yacas and standard Calc expressions
The @kbd{d X} (@code{calc-maxima-language}) command selects the
conventions of Maxima, another free computer algebra system. The
function names in Maxima are similar, but not always identical, to Calc.
-For example, instead of @samp{arcsin(x)}, Maxima will use
+For example, instead of @samp{arcsin(x)}, Maxima will use
@samp{asin(x)}. Complex numbers are written @samp{3 + 4 %i}. The
standard special constants are written @code{%pi}, @code{%e},
@code{%i}, @code{%phi} and @code{%gamma}. In Maxima, @code{inf} means
Underscores as well as percent signs are allowed in function and
variable names in Maxima mode. The underscore again is equivalent to
-the @samp{#} in Normal mode, and the percent sign is equivalent to
-@samp{o'o}.
+the @samp{#} in Normal mode, and the percent sign is equivalent to
+@samp{o'o}.
Maxima uses square brackets for lists and vectors, and matrices are
written as calls to the function @code{matrix}, given the row vectors of
names in Giac are similar to Maxima. Complex numbers are written
@samp{3 + 4 i}. The standard special constants in Giac are the same as
in Calc, except that @code{infinity} represents both Calc's @code{inf}
-and @code{uinf}.
+and @code{uinf}.
Underscores are allowed in function and variable names in Giac mode.
Brackets are used for subscripts. In Giac, indexing of lists begins at
The @kbd{d W} (@code{calc-maple-language}) command selects the
conventions of Maple.
-Maple's language is much like C. Underscores are allowed in symbol
+Maple's language is much like C@. Underscores are allowed in symbol
names; square brackets are used for subscripts; explicit @samp{*}s for
multiplications are required. Use either @samp{^} or @samp{**} to
denote powers.
rule, it first matches the pattern as usual. It then substitutes
@samp{#1}, @samp{#2}, etc., in the conditions, if any. Next, the
conditions are simplified and evaluated in order from left to right,
-as if by the @w{@kbd{a s}} algebra command (@pxref{Simplifying Formulas}).
+using the algebraic simplifications (@pxref{Simplifying Formulas}).
Each result is true if it is a nonzero number, or an expression
that can be proven to be nonzero (@pxref{Declarations}). If the
results of all conditions are true, the expression (such as
@item
Matrix/Scalar mode. Default value is @mathit{-1}. Value is 0 for Scalar
mode, @mathit{-2} for Matrix mode, @mathit{-3} for square Matrix mode,
-or @var{N} for
+or @var{N} for
@texline @math{N\times N}
-@infoline @var{N}x@var{N}
+@infoline @var{N}x@var{N}
Matrix mode. Command is @kbd{m v}.
@item
@item BinSimp@var{w}
Binary-integer simplification mode; word size @var{w} (@kbd{m B}, @kbd{b w}).
-@item AlgSimp
-Algebraic simplification mode (@kbd{m A}).
+@item BasicSimp
+Basic simplification mode (@kbd{m I}).
@item ExtSimp
Extended algebraic simplification mode (@kbd{m E}).
@TeX{} language mode (@kbd{d T}; @pxref{TeX and LaTeX Language Modes}).
@item LaTeX
-La@TeX{} language mode (@kbd{d L}; @pxref{TeX and LaTeX Language Modes}).
+@LaTeX{} language mode (@kbd{d L}; @pxref{TeX and LaTeX Language Modes}).
@item Eqn
@dfn{Eqn} language mode (@kbd{d E}; @pxref{Eqn Language Mode}).
@mindex @null
@end ignore
@tindex /
-The @kbd{/} (@code{calc-divide}) command divides two numbers.
+The @kbd{/} (@code{calc-divide}) command divides two numbers.
When combining multiplication and division in an algebraic formula, it
is good style to use parentheses to distinguish between possible
parentheses, Calc will interpret @samp{a/b*c} as @samp{a/(b*c)}, since
in algebraic entry Calc gives division a lower precedence than
multiplication. (This is not standard across all computer languages, and
-Calc may change the precedence depending on the language mode being used.
+Calc may change the precedence depending on the language mode being used.
@xref{Language Modes}.) This default ordering can be changed by setting
the customizable variable @code{calc-multiplication-has-precedence} to
@code{nil} (@pxref{Customizing Calc}); this will give multiplication and
The @kbd{f M} (@code{calc-mant-part}) [@code{mant}] function extracts
the ``mantissa'' part @expr{m} of its floating-point argument; @kbd{f X}
(@code{calc-xpon-part}) [@code{xpon}] extracts the ``exponent'' part
-@expr{e}. The original number is equal to
+@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
For example, incrementing @samp{12.3456} when the current precision
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
+@samp{0.0} produces
@texline @math{10^{-p}},
-@infoline @expr{10^-p},
+@infoline @expr{10^-p},
where @expr{p} is the current
precision. These operations are defined only on integers and floats.
With numeric prefix arguments, they change the number by @expr{n} units.
operation. Vectors and formulas are cleaned by cleaning each component
number (i.e., pervasively).
-If the simplification mode is set below the default level, it is raised
-to the default level for the purposes of this command. Thus, @kbd{c c}
-applies the default simplifications even if their automatic application
-is disabled. @xref{Simplification Modes}.
+If the simplification mode is set below basic simplification, it is raised
+for the purposes of this command. Thus, @kbd{c c} applies the basic
+simplifications even if their automatic application is disabled.
+@xref{Simplification Modes}.
@cindex Roundoff errors, correcting
A numeric prefix argument to @kbd{c c} sets the floating-point precision
@pindex calc-date
@tindex date
The @kbd{t D} (@code{calc-date}) [@code{date}] command converts a
-date form into a number, measured in days since Jan 1, 1 AD. The
+date form into a number, measured in days since Jan 1, 1 AD@. The
result will be an integer if @var{date} is a pure date form, or a
fraction or float if @var{date} is a date/time form. Or, if its
argument is a number, it converts this number into a date form.
@cindex Julian day counts, conversions
The @kbd{t J} (@code{calc-julian}) [@code{julian}] command converts
a date form into a Julian day count, which is the number of days
-since noon (GMT) on Jan 1, 4713 BC. A pure date is converted to an
-integer Julian count representing noon of that day. A date/time form
+since noon (GMT) on Jan 1, 4713 BC@. A pure date is converted to an
+integer Julian count representing noon of that day. A date/time form
is converted to an exact floating-point Julian count, adjusted to
interpret the date form in the current time zone but the Julian
day count in Greenwich Mean Time. A numeric prefix argument allows
converts a date form into a Unix time value, which is the number of
seconds since midnight on Jan 1, 1970, or vice-versa. The numeric result
will be an integer if the current precision is 12 or less; for higher
-precisions, the result may be a float with (@var{precision}@minus{}12)
+precision, the result may be a float with (@var{precision}@minus{}12)
digits after the decimal. Just as for @kbd{t J}, the numeric time
is interpreted in the GMT time zone and the date form is interpreted
in the current or specified zone. Some systems use Unix-like
The @kbd{M-6 t P} [@code{second}] function extracts the second
from a date form. If the current precision is 12 or less,
the result is an integer in the range 0 to 59. For higher
-precisions, the result may instead be a floating-point number.
+precision, the result may instead be a floating-point number.
@tindex weekday
The @kbd{M-7 t P} [@code{weekday}] function extracts the weekday
exercise for the reader is to modify this formula to yield the same day
if the input is already a Wednesday. Another interesting exercise is
to preserve the time-of-day portion of the input (@code{newweek} resets
-the time to midnight; hint:@: how can @code{newweek} be defined in terms
+the time to midnight; hint: how can @code{newweek} be defined in terms
of the @code{weekday} function?).
@ignore
default get the time zone and daylight saving information from the
calendar (@pxref{Daylight Saving,Calendar/Diary,The Calendar and the Diary,
emacs,The GNU Emacs Manual}). To use a different time zone, or if the
-calendar does not give the desired result, you can set the Calc variable
+calendar does not give the desired result, you can set the Calc variable
@code{TimeZone} (which is by default @code{nil}) to an appropriate
time zone name. (The easiest way to do this is to edit the
@code{TimeZone} variable using Calc's @kbd{s T} command, then use the
@kbd{s p} (@code{calc-permanent-variable}) command to save the value of
-@code{TimeZone} permanently.)
+@code{TimeZone} permanently.)
If the time zone given by @code{TimeZone} is a generalized time zone,
e.g., @code{EGT}, Calc examines the date being converted to tell whether
to use standard or daylight saving time. But if the current time zone
The @kbd{t J} and @code{t U} commands with no numeric prefix
arguments do the same thing as @samp{tzone()}; namely, use the
-information from the calendar if @code{TimeZone} is @code{nil},
+information from the calendar if @code{TimeZone} is @code{nil},
otherwise use the time zone given by @code{TimeZone}.
@vindex math-daylight-savings-hook
@findex math-std-daylight-savings
-When Calc computes the daylight saving information itself (i.e., when
+When Calc computes the daylight saving information itself (i.e., when
the @code{TimeZone} variable is set), it will by default consider
daylight saving time to begin at 2 a.m.@: on the second Sunday of March
(for years from 2007 on) or on the last Sunday in April (for years
the user-level @code{pwday} function described in the previous
section. It takes four arguments: The floating-point date value,
the corresponding six-element date list, the day-of-month number,
-and the weekday number (0-6).
+and the weekday number (0--6).
The default daylight saving hook ignores the time zone name, but a
more sophisticated hook could use different algorithms for different
from 3 a.m.@: to 4 a.m. At the end of daylight saving time, the
hour from 1 a.m.@: to 2 a.m.@: repeats itself; converting a date/time
form that falls in this hour results in a time value for the first
-manifestation of that time (@emph{not} the one that occurs one hour
+manifestation of that time (@emph{not} the one that occurs one hour
later).
If @code{math-daylight-savings-hook} is @code{nil}, then the
@expr{2^w} by all binary functions.
If the word size is negative, binary operations produce twos-complement
-integers from
+integers from
@texline @math{-2^{-w-1}}
-@infoline @expr{-(2^(-w-1))}
-to
+@infoline @expr{-(2^(-w-1))}
+to
@texline @math{2^{-w-1}-1}
-@infoline @expr{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.
One miscellaneous command is shift-@kbd{P} (@code{calc-pi}), which pushes
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
+With the Inverse flag, it pushes Euler's constant
@texline @math{\gamma}
-@infoline @expr{gamma}
+@infoline @expr{gamma}
(about 0.5772). With both Inverse and Hyperbolic, it
-pushes the ``golden ratio''
+pushes the ``golden ratio''
@texline @math{\phi}
-@infoline @expr{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.)
In Symbolic mode, these commands push the
(base-10) logarithm of a number. (With the Inverse flag [@code{exp10}],
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
+by
@texline @math{\ln10}.
@infoline @expr{ln(10)}.
The @kbd{B} (@code{calc-log}) [@code{log}] 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}.
+@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
mode setting. With the Inverse flag [@code{alog}], this command is
@tindex expm1
The @kbd{f E} (@code{calc-expm1}) [@code{expm1}] command computes
@texline @math{e^x - 1},
-@infoline @expr{exp(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
+answer when the result is close to zero, i.e., when
@texline @math{e^x}
-@infoline @expr{exp(x)}
+@infoline @expr{exp(x)}
is close to one.
@kindex f L
@tindex lnp1
The @kbd{f L} (@code{calc-lnp1}) [@code{lnp1}] command computes
@texline @math{\ln(x+1)},
-@infoline @expr{ln(x+1)},
+@infoline @expr{ln(x+1)},
producing a more accurate answer when @expr{x} is close to zero.
@node Trigonometric and Hyperbolic Functions, Advanced Math Functions, Logarithmic Functions, Scientific Functions
Also, the symbolic variable @code{pi} is not ordinarily recognized in
arguments to trigonometric functions, as in @samp{sin(3 pi / 4)}, but
-the @kbd{a s} (@code{calc-simplify}) command recognizes many such
+the default algebraic simplifications recognize many such
formulas when the current angular mode is Radians @emph{and} Symbolic
mode is enabled; this example would be replaced by @samp{sqrt(2) / 2}.
@xref{Symbolic Mode}. Beware, this simplification occurs even if you
the form @expr{x} plus a multiple of @cpiover{2} are also simplified.
Calc includes similar formulas for @code{cos} and @code{tan}.
-The @kbd{a s} command knows all angles which are integer multiples of
+Calc's algebraic simplifications know all angles which are integer multiples of
@cpiover{12}, @cpiover{10}, or @cpiover{8} radians. In Degrees mode,
analogous simplifications occur for integer multiples of 15 or 18
degrees, and for arguments plus multiples of 90 degrees.
Calc can compute a variety of less common functions that arise in
various branches of mathematics. All of the functions described in
this section allow arbitrary complex arguments and, except as noted,
-will work to arbitrarily large precisions. They can not at present
+will work to arbitrarily large precision. They can not at present
handle error forms or intervals as arguments.
NOTE: These functions are still experimental. In particular, their
gamma function. For positive integer arguments, this is related to the
factorial function: @samp{gamma(n+1) = fact(n)}. For general complex
arguments the gamma function can be defined by the following definite
-integral:
+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)}.
+@infoline @expr{gamma(a) = integ(t^(a-1) exp(t), t, 0, inf)}.
(The actual implementation uses far more efficient computational methods.)
@kindex f G
@tindex gammaG
The @kbd{f G} (@code{calc-inc-gamma}) [@code{gammaP}] command computes
the incomplete gamma function, denoted @samp{P(a,x)}. This is defined by
-the integral,
+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
The @kbd{f b} (@code{calc-beta}) [@code{beta}] 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)},
+@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)}.
@tindex erf
@tindex erfc
The @kbd{f e} (@code{calc-erf}) [@code{erf}] command computes the
-error function
+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}) [@code{erfc}]
random numbers of various sorts.
Given a positive numeric prefix argument @expr{M}, it produces a random
-integer @expr{N} in the range
+integer @expr{N} in the range
@texline @math{0 \le N < M}.
-@infoline @expr{0 <= N < M}.
+@infoline @expr{0 <= N < M}.
Each possible value @expr{N} appears with equal probability.
With no numeric prefix argument, the @kbd{k r} command takes its argument
the result is a random integer less than @expr{M}. However, note that
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
+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
+is a random floating-point number @expr{N} in the range
@texline @math{0 \le N < M}
@infoline @expr{0 <= N < M}
-or
+or
@texline @math{M < N \le 0},
-@infoline @expr{M < N <= 0},
+@infoline @expr{M < N <= 0},
according to the sign of @expr{M}.
If @expr{M} is zero, the result is a Gaussian-distributed random real
of one. The algorithm used generates random numbers in pairs; thus,
every other call to this function will be especially fast.
-If @expr{M} is an error form
+If @expr{M} is an error form
@texline @math{m} @code{+/-} @math{\sigma}
-@infoline @samp{m +/- s}
-where @var{m} and
+@infoline @samp{m +/- s}
+where @var{m} and
@texline @math{\sigma}
-@infoline @var{s}
+@infoline @var{s}
are both real numbers, the result uses a Gaussian distribution with mean
-@var{m} and standard deviation
+@var{m} and standard deviation
@texline @math{\sigma}.
@infoline @var{s}.
of the theory of random number generators and their measurement and
characterization.
-If @code{RandSeed} has no stored value, Calc calls Emacs' built-in
+If @code{RandSeed} has no stored value, Calc calls Emacs's built-in
@code{random} function to get a stream of random numbers, which it
then treats in various ways to avoid problems inherent in the simple
random number generators that many systems use to implement @code{random}.
If @code{RandSeed} contains an integer, Calc uses this integer to
seed an ``additive congruential'' method (Knuth's algorithm 3.2.2A,
-computing
+computing
@texline @math{X_{n-55} - X_{n-24}}.
-@infoline @expr{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
@code{RandSeed} is changed from, e.g., 42 to the vector @expr{[42]}
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}.
+@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
+numbers on the order of
@texline @math{10^{-9}}
-@infoline @expr{10^-9}
-or
+@infoline @expr{10^-9}
+or
@texline @math{10^{-10}},
-@infoline @expr{10^-10},
+@infoline @expr{10^-10},
but those numbers will only have two or three random digits since they
-correspond to small integers times
+correspond to small integers times
@texline @math{10^{-12}}.
@infoline @expr{10^-12}.
ten, however, the numbers should be completely unbiased.
The Gaussian random numbers generated by @samp{random(0.0)} use the
-``polar'' method described in Knuth section 3.4.1C. This method
+``polar'' method described in Knuth section 3.4.1C@. This method
generates a pair of Gaussian random numbers at a time, so only every
other call to @samp{random(0.0)} will require significant calculations.
@tindex egcd
The @kbd{k E} (@code{calc-extended-gcd}) [@code{egcd}] command computes
the GCD of two integers @expr{x} and @expr{y} and returns a vector
-@expr{[g, a, b]} where
+@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}.
@tindex stir1
@tindex stir2
The @kbd{k s} (@code{calc-stirling-number}) [@code{stir1}] command
-computes a Stirling number of the first
+computes a Stirling number of the first
@texline kind@tie{}@math{n \brack m},
@infoline kind,
given two integers @expr{n} and @expr{m} on the stack. The @kbd{H k s}
-[@code{stir2}] command computes a Stirling number of the second
+[@code{stir2}] command computes a Stirling number of the second
@texline kind@tie{}@math{n \brace m}.
@infoline kind.
These are the number of @expr{m}-cycle permutations of @expr{n} objects,
@pindex calc-totient
@tindex totient
The @kbd{k t} (@code{calc-totient}) [@code{totient}] command computes the
-Euler ``totient''
+Euler ``totient''
@texline function@tie{}@math{\phi(n)},
@infoline function,
the number of integers less than @expr{n} which
@tindex ltpc
The @samp{utpc(x,v)} function uses the chi-square distribution with
@texline @math{\nu}
-@infoline @expr{v}
+@infoline @expr{v}
degrees of freedom. It is the probability that a model is
correct if its chi-square statistic is @expr{x}.
@end ignore
@tindex ltpf
The @samp{utpf(F,v1,v2)} function uses the F distribution, used in
-various statistical tests. The parameters
+various statistical tests. The parameters
@texline @math{\nu_1}
-@infoline @expr{v1}
-and
+@infoline @expr{v1}
+and
@texline @math{\nu_2}
@infoline @expr{v2}
are the degrees of freedom in the numerator and denominator,
@end ignore
@tindex ltpn
The @samp{utpn(x,m,s)} function uses a normal (Gaussian) distribution
-with mean @expr{m} and standard deviation
+with mean @expr{m} and standard deviation
@texline @math{\sigma}.
-@infoline @expr{s}.
+@infoline @expr{s}.
It is the probability that such a normal-distributed random variable
would exceed @expr{x}.
@end ignore
@tindex ltpt
The @samp{utpt(t,v)} function uses the Student's ``t'' distribution
-with
+with
@texline @math{\nu}
-@infoline @expr{v}
+@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
+(Note: This computes the distribution function
@texline @math{A(t|\nu)}
@infoline @expr{A(t|v)}
-where
+where
@texline @math{A(0|\nu) = 1}
-@infoline @expr{A(0|v) = 1}
-and
+@infoline @expr{A(0|v) = 1}
+and
@texline @math{A(\infty|\nu) \to 0}.
-@infoline @expr{A(inf|v) -> 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)}.)
the stack is a scalar, it is used for each element on the diagonal, and
the prefix argument is required.
-To build a constant square matrix, e.g., a
+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
With the Hyperbolic flag, @kbd{H v l} [@code{mdims}] computes a vector
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
+its argument is a
@texline @math{2\times3}
@infoline 2x3
matrix.
in the vector, the last row will be short and the result will not be
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
+@samp{[[1, 2, 3, 4]]} (a
@texline @math{1\times4}
@infoline 1x4
-matrix), @kbd{v a 1} produces @samp{[[1], [2], [3], [4]]} (a
+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
+matrix), @kbd{v a 2} produces @samp{[[1, 2], [3, 4]]} (the original
@texline @math{2\times2}
@infoline 2x2
matrix), @w{@kbd{v a 3}} produces @samp{[[1, 2, 3], [4]]} (not a
-matrix), and @kbd{v a 0} produces the flattened list
+matrix), and @kbd{v a 0} produces the flattened list
@samp{[1, 2, @w{3, 4}]}.
@cindex Sorting data
will be used to determine the bins. (If a positive integer is given at
this prompt, it will be still treated as if it were given as a
prefix.) Each bin will consist of the interval of numbers closest to
-the corresponding number of this new vector; if the vector
-@expr{[a, b, c, ...]} is entered at the prompt, the bins will be
-@expr{(-inf, (a+b)/2]}, @expr{((a+b)/2, (b+c)/2]}, etc. The result of
+the corresponding number of this new vector; if the vector
+@expr{[a, b, c, ...]} is entered at the prompt, the bins will be
+@expr{(-inf, (a+b)/2]}, @expr{((a+b)/2, (b+c)/2]}, etc. The result of
this command will be a vector counting how many elements of the
original vector are in each bin.
sets are disjoint, i.e., if they share no common elements, the result
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
+notation for set
@texline union@tie{}(@math{A \cup B})
@infoline union
-and
+and
@texline intersection@tie{}(@math{A \cap B}).
@infoline intersection.
not include any negative numbers. The input is interpreted as a
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
+representation
@texline (@math{2^{100}}, a 31-digit integer, in this case).
@infoline (@expr{2^100}, a 31-digit integer, in this case).
@cindex Mean of data values
The @kbd{u M} (@code{calc-vector-mean}) [@code{vmean}] command
computes the average (arithmetic mean) of the data values.
-If the inputs are error forms
+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
+@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
values divided by the count of the values.
Note that a plain number can be considered an error form with
-error
+error
@texline @math{\sigma = 0}.
-@infoline @expr{s = 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
plain numbers, ignoring all values with non-zero errors. (By the
@cindex Standard deviation
@cindex Sample statistics
The @kbd{u S} (@code{calc-vector-sdev}) [@code{vsdev}] command
-computes the standard
+computes the standard
@texline deviation@tie{}@math{\sigma}
@infoline deviation
of the data values. If the values are error forms, the errors are used
This function also applies to distributions. The standard deviation
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
+limits, divided by
@texline @math{\sqrt{12}}.
-@infoline @expr{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.
The @kbd{H u S} (@code{calc-vector-variance}) [@code{vvar}] and
@kbd{H I u S} (@code{calc-vector-pop-variance}) [@code{vpvar}]
commands compute the variance of the data values. The variance
-is the
+is the
@texline square@tie{}@math{\sigma^2}
@infoline square
of the standard deviation, i.e., the sum of the
vectors of equal size. The vectors are each flattened in the same
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
+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
If any argument to @kbd{V M} is a matrix, the operator is normally mapped
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
+produce another
@texline @math{3\times2}
@infoline 3x2
matrix, @expr{[[1, 2, 3], [4, 5, 6]]}.
@pindex calc-break-selections
The @kbd{j b} (@code{calc-break-selections}) command controls a mode
in which the ``deep structure'' of these associative formulas shows
-through. Calc actually stores the above formulas as
-@samp{((a + b) - c) + d} and @samp{x * (y * z)}. (Note that for certain
+through. Calc actually stores the above formulas as
+@samp{((a + b) - c) + d} and @samp{x * (y * z)}. (Note that for certain
obscure reasons, by default Calc treats multiplication as
right-associative.) Once you have enabled @kbd{j b} mode, selecting
with the cursor on the @samp{-} sign would only select the @samp{a + b -
@end smallexample
Unselecting the sub-formula reveals that the minus sign, which would
-normally have cancelled out with the subtraction automatically, has
+normally have canceled out with the subtraction automatically, has
not been able to do so because the subtraction was not part of the
selected portion. Pressing @kbd{=} (@code{calc-evaluate}) or doing
any other mathematical operation on the whole formula will cause it
@pindex calc-sel-div-both-sides
The @kbd{j *} (@code{calc-sel-mult-both-sides}) command prompts for a
formula using algebraic entry, then multiplies both sides of the
-selected quotient or equation by that formula. It simplifies each
-side with @kbd{a s} (@code{calc-simplify}) before re-forming the
+selected quotient or equation by that formula. It performs the
+default algebraic simplifications before re-forming the
quotient or equation. You can suppress this simplification by
providing a prefix argument: @kbd{C-u j *}. There is also a @kbd{j /}
(@code{calc-sel-div-both-sides}) which is similar to @kbd{j *} but
example, if the formula on the stack is @samp{1 / (sqrt(a) + 1)}, you may
wish to eliminate the square root in the denominator by multiplying
the top and bottom by @samp{sqrt(a) - 1}. If you did this simply by using
-a simple @kbd{j *} command, you would get
+a simple @kbd{j *} command, you would get
@samp{(sqrt(a)-1)/ (sqrt(a) (sqrt(a) - 1) + sqrt(a) - 1)}. Instead,
you would probably want to use @kbd{C-u 0 j *}, which would expand the
bottom and give you the desired result @samp{(sqrt(a)-1)/(a-1)}. More
@kindex j v
@pindex calc-sel-evaluate
The @kbd{j v} (@code{calc-sel-evaluate}) command performs the
-normal default simplifications on the selected sub-formula.
-These are the simplifications that are normally done automatically
-on all results, but which may have been partially inhibited by
+basic simplifications on the selected sub-formula.
+These simplifications would normally be done automatically
+on all results, but may have been partially inhibited by
previous selection-related operations, or turned off altogether
by the @kbd{m O} command. This command is just an auto-selecting
version of the @w{@kbd{a v}} command (@pxref{Algebraic Manipulation}).
With a numeric prefix argument of 2, @kbd{C-u 2 j v} applies
-the @kbd{a s} (@code{calc-simplify}) command to the selected
+the default algebraic simplifications to the selected
sub-formula. With a prefix argument of 3 or more, e.g., @kbd{C-u j v}
applies the @kbd{a e} (@code{calc-simplify-extended}) command.
@xref{Simplifying Formulas}. With a negative prefix argument
Use @kbd{a v} if you want the variables to ignore their stored values.
If you give a numeric prefix argument of 2 to @kbd{a v}, it simplifies
-as if in Algebraic Simplification mode. This is equivalent to typing
-@kbd{a s}; @pxref{Simplifying Formulas}. If you give a numeric prefix
-of 3 or more, it uses Extended Simplification mode (@kbd{a e}).
+using Calc's algebraic simplifications; @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
are mapped, the direction of the second inequality is reversed to
match the first: Using @kbd{a M +} on @samp{a < b} and @samp{a > 2}
reverses the latter to get @samp{2 < a}, which then allows the
-combination @samp{a + 2 < b + a}, which the @kbd{a s} command can
-then simplify to get @samp{2 < b}.
+combination @samp{a + 2 < b + a}, which the algebraic simplifications
+can reduce to @samp{2 < b}.
Using @kbd{a M *}, @kbd{a M /}, @kbd{a M n}, or @kbd{a M &} to negate
or invert an inequality will reverse the direction of the inequality.
@kindex H a s
@pindex calc-simplify
@tindex simplify
-The @kbd{a s} (@code{calc-simplify}) [@code{simplify}] command applies
-various algebraic rules to simplify a formula. This includes rules which
-are not part of the default simplifications because they may be too slow
-to apply all the time, or may not be desirable all of the time. For
-example, non-adjacent terms of sums are combined, as in @samp{a + b + 2 a}
-to @samp{b + 3 a}, and some formulas like @samp{sin(arcsin(x))} are
-simplified to @samp{x}.
-
-The sections below describe all the various kinds of algebraic
+
+The sections below describe all the various kinds of
simplifications Calc provides in full detail. None of Calc's
simplification commands are designed to pull rabbits out of hats;
they simply apply certain specific rules to put formulas into
@xref{Rewrite Rules}.
@xref{Simplification Modes}, for commands to control what level of
-simplification occurs automatically. Normally only the ``default
-simplifications'' occur.
+simplification occurs automatically. Normally the algebraic
+simplifications described below occur. If you have turned on a
+simplification mode which does not do these algebraic simplifications,
+you can still apply them to a formula with the @kbd{a s}
+(@code{calc-simplify}) [@code{simplify}] command.
There are some simplifications that, while sometimes useful, are never
done automatically. For example, the @kbd{I} prefix can be given to
@kbd{a s}; the @kbd{I a s} command will change any trigonometric
function to the appropriate combination of @samp{sin}s and @samp{cos}s
before simplifying. This can be useful in simplifying even mildly
-complicated trigonometric expressions. For example, while @kbd{a s}
-can reduce @samp{sin(x) csc(x)} to @samp{1}, it will not simplify
-@samp{sin(x)^2 csc(x)}. The command @kbd{I a s} can be used to
+complicated trigonometric expressions. For example, while the algebraic
+simplifications can reduce @samp{sin(x) csc(x)} to @samp{1}, they will not
+simplify @samp{sin(x)^2 csc(x)}. The command @kbd{I a s} can be used to
simplify this latter expression; it will transform @samp{sin(x)^2
csc(x)} into @samp{sin(x)}. However, @kbd{I a s} will also perform
some ``simplifications'' which may not be desired; for example, it
@menu
-* Default Simplifications::
+* Basic Simplifications::
* Algebraic Simplifications::
* Unsafe Simplifications::
* Simplification of Units::
@end menu
-@node Default Simplifications, Algebraic Simplifications, Simplifying Formulas, Simplifying Formulas
-@subsection Default Simplifications
+@node Basic Simplifications, Algebraic Simplifications, Simplifying Formulas, Simplifying Formulas
+@subsection Basic Simplifications
@noindent
-@cindex Default simplifications
-This section describes the ``default simplifications,'' those which are
-normally applied to all results. For example, if you enter the variable
-@expr{x} on the stack twice and push @kbd{+}, Calc's default
-simplifications automatically change @expr{x + x} to @expr{2 x}.
+@cindex Basic simplifications
+This section describes basic simplifications which Calc performs in many
+situations. For example, both binary simplifications and algebraic
+simplifications begin by performing these basic simplifications. You
+can type @kbd{m I} to restrict the simplifications done on the stack to
+these simplifications.
-The @kbd{m O} command turns off the default simplifications, so that
-@expr{x + x} will remain in this form unless you give an explicit
-``simplify'' command like @kbd{=} or @kbd{a v}. @xref{Algebraic
-Manipulation}. The @kbd{m D} command turns the default simplifications
-back on.
-
-The most basic default simplification is the evaluation of functions.
+The most basic simplification is the evaluation of functions.
For example, @expr{2 + 3} is evaluated to @expr{5}, and @expr{@tfn{sqrt}(9)}
is evaluated to @expr{3}. Evaluation does not occur if the arguments
to a function are somehow of the wrong type @expr{@tfn{tan}([2,3,4])}),
-range (@expr{@tfn{tan}(90)}), or number (@expr{@tfn{tan}(3,5)}),
+range (@expr{@tfn{tan}(90)}), or number (@expr{@tfn{tan}(3,5)}),
or if the function name is not recognized (@expr{@tfn{f}(5)}), or if
Symbolic mode (@pxref{Symbolic Mode}) prevents evaluation
(@expr{@tfn{sqrt}(2)}).
operator) does not evaluate all of its arguments, and @code{evalto}
does not evaluate its lefthand argument.
-Most commands apply the default simplifications to all arguments they
-take from the stack, perform a particular operation, then simplify
-the result before pushing it back on the stack. In the common special
-case of regular arithmetic commands like @kbd{+} and @kbd{Q} [@code{sqrt}],
-the arguments are simply popped from the stack and collected into a
-suitable function call, which is then simplified (the arguments being
-simplified first as part of the process, as described above).
-
-The default simplifications are too numerous to describe completely
-here, but this section will describe the ones that apply to the
+Most commands apply at least these basic simplifications to all
+arguments they take from the stack, perform a particular operation,
+then simplify the result before pushing it back on the stack. In the
+common special case of regular arithmetic commands like @kbd{+} and
+@kbd{Q} [@code{sqrt}], the arguments are simply popped from the stack
+and collected into a suitable function call, which is then simplified
+(the arguments being simplified first as part of the process, as
+described above).
+
+Even the basic set of simplifications are too numerous to describe
+completely here, but this section will describe the ones that apply to the
major arithmetic operators. This list will be rather technical in
nature, and will probably be interesting to you only if you are
a serious user of Calc's algebra facilities.
As well as the simplifications described here, if you have stored
any rewrite rules in the variable @code{EvalRules} then these rules
-will also be applied before any built-in default simplifications.
+will also be applied before any of the basic simplifications.
@xref{Automatic Rewrites}, for details.
@tex
\bigskip
@end tex
-And now, on with the default simplifications:
+And now, on with the basic simplifications:
Arithmetic operators like @kbd{+} and @kbd{*} always take two
arguments in Calc's internal form. Sums and products of three or
more terms are arranged by the associative law of algebra into
a left-associative form for sums, @expr{((a + b) + c) + d}, and
-(by default) a right-associative form for products,
+(by default) a right-associative form for products,
@expr{a * (b * (c * d))}. Formulas like @expr{(a + b) + (c + d)} are
rearranged to left-associative form, though this rarely matters since
Calc's algebra commands are designed to hide the inner structure of sums
special cases described below. Some algebra programs always
rearrange terms into a canonical order, which enables them to
see that @expr{a b + b a} can be simplified to @expr{2 a b}.
-Calc assumes you have put the terms into the order you want
-and generally leaves that order alone, with the consequence
-that formulas like the above will only be simplified if you
-explicitly give the @kbd{a s} command. @xref{Algebraic
-Simplifications}.
+If you are using Basic Simplification mode, Calc assumes you have put
+the terms into the order you want and generally leaves that order alone,
+with the consequence that formulas like the above will only be
+simplified if you explicitly give the @kbd{a s} command.
+@xref{Algebraic Simplifications}.
Differences @expr{a - b} are treated like sums @expr{a + (-b)}
for purposes of simplification; one of the default simplifications
is simplified to @expr{a + 2 b + c}, but @expr{a + b + c + b}
is not simplified. The reason is that comparing all terms of a
sum with one another would require time proportional to the
-square of the number of terms; Calc relegates potentially slow
-operations like this to commands that have to be invoked
-explicitly, like @kbd{a s}.
+square of the number of terms; Calc omits potentially slow
+operations like this in basic simplification mode.
Finally, @expr{a + 0} and @expr{0 + a} are simplified to @expr{a}.
A consequence of the above rules is that @expr{0 - a} is simplified
rewritten to @expr{a (c - b)}.
The distributive law of products and powers is used for adjacent
-terms of the product: @expr{x^a x^b} goes to
+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}),
@expr{1} or to @samp{idn(1)} if Matrix mode is enabled.
The product of a negative power times anything but another negative
-power is changed to use division:
+power is changed to use division:
@texline @math{x^{-2} y}
-@infoline @expr{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
case it is considered unsafe to rearrange the order of the terms).
infinite quantity, as directed by the current infinite mode.
@xref{Infinite Mode}.
-The expression
+The expression
@texline @math{a / b^{-c}}
-@infoline @expr{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
+power. Also, @expr{1 / b^c} is changed to
@texline @math{b^{-c}}
-@infoline @expr{b^(-c)}
+@infoline @expr{b^(-c)}
for any power @expr{c}.
Also, @expr{(-a) / b} and @expr{a / (-b)} go to @expr{-(a/b)};
Quotients of products cancel only in the leading terms of the
numerator and denominator. In other words, @expr{a x b / a y b}
-is cancelled to @expr{x b / y b} but not to @expr{x / y}. Once
+is canceled to @expr{x b / y b} but not to @expr{x / y}. Once
again this is because full cancellation can be slow; use @kbd{a s}
to cancel all terms of the quotient.
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)}
+@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,
+(In other words,
@texline @math{((-3)^{1/2})^2}
-@infoline @expr{((-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}
+@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, @expr{@tfn{sqrt}(x)^n} is simplified to
@texline @math{x^{n/2}}
-@infoline @expr{x^(n/2)}
+@infoline @expr{x^(n/2)}
only for even integers @expr{n}.
If @expr{a} is known to be real, @expr{b} is an even integer, and
Square roots @expr{@tfn{sqrt}(x)} generally act like one-half powers
@texline @math{x^{1:2}}
-@infoline @expr{x^1:2}
+@infoline @expr{x^1:2}
for the purposes of the above-listed simplifications.
-Also, note that
+Also, note that
@texline @math{1 / x^{1:2}}
-@infoline @expr{1 / x^1:2}
-is changed to
+@infoline @expr{1 / x^1:2}
+is changed to
@texline @math{x^{-1:2}},
@infoline @expr{x^(-1:2)},
but @expr{1 / @tfn{sqrt}(x)} is left alone.
Generic identity matrices (@pxref{Matrix Mode}) are simplified by the
following rules: @expr{@tfn{idn}(a) + b} to @expr{a + b} if @expr{b}
is provably scalar, or expanded out if @expr{b} is a matrix;
-@expr{@tfn{idn}(a) + @tfn{idn}(b)} to @expr{@tfn{idn}(a + b)};
-@expr{-@tfn{idn}(a)} to @expr{@tfn{idn}(-a)}; @expr{a @tfn{idn}(b)} to
-@expr{@tfn{idn}(a b)} if @expr{a} is provably scalar, or to @expr{a b}
+@expr{@tfn{idn}(a) + @tfn{idn}(b)} to @expr{@tfn{idn}(a + b)};
+@expr{-@tfn{idn}(a)} to @expr{@tfn{idn}(-a)}; @expr{a @tfn{idn}(b)} to
+@expr{@tfn{idn}(a b)} if @expr{a} is provably scalar, or to @expr{a b}
if @expr{a} is provably non-scalar; @expr{@tfn{idn}(a) @tfn{idn}(b)} to
@expr{@tfn{idn}(a b)}; analogous simplifications for quotients involving
@code{idn}; and @expr{@tfn{idn}(a)^n} to @expr{@tfn{idn}(a^n)} where
The expression @expr{@tfn{abs}(@tfn{abs}(x))} changes to
@expr{@tfn{abs}(x)}; in fact, @expr{@tfn{abs}(x)} changes to @expr{x} or
@expr{-x} if @expr{x} is provably nonnegative or nonpositive
-(@pxref{Declarations}).
+(@pxref{Declarations}).
While most functions do not recognize the variable @code{i} as an
imaginary number, the @code{arg} function does handle the two cases
Various other expressions involving @code{conj}, @code{re}, and
@code{im} are simplified, especially if some of the arguments are
provably real or involve the constant @code{i}. For example,
-@expr{@tfn{conj}(a + b i)} is changed to
+@expr{@tfn{conj}(a + b i)} is changed to
@expr{@tfn{conj}(a) - @tfn{conj}(b) i}, or to @expr{a - b i} if @expr{a}
and @expr{b} are known to be real.
Functions like @code{sin} and @code{arctan} generally don't have
any default simplifications beyond simply evaluating the functions
-for suitable numeric arguments and infinity. The @kbd{a s} command
-described in the next section does provide some simplifications for
-these functions, though.
+for suitable numeric arguments and infinity. The algebraic
+simplifications described in the next section do provide some
+simplifications for these functions, though.
One important simplification that does occur is that
@expr{@tfn{ln}(@tfn{e})} is simplified to 1, and @expr{@tfn{ln}(@tfn{e}^x)} is
@expr{!!x} to @expr{x}, this would not be valid in general because
@expr{!!2} is 1, not 2.
-Most other Calc functions have few if any default simplifications
+Most other Calc functions have few if any basic simplifications
defined, aside of course from evaluation when the arguments are
suitable numbers.
-@node Algebraic Simplifications, Unsafe Simplifications, Default Simplifications, Simplifying Formulas
+@node Algebraic Simplifications, Unsafe Simplifications, Basic Simplifications, Simplifying Formulas
@subsection Algebraic Simplifications
@noindent
@cindex Algebraic simplifications
-The @kbd{a s} command makes simplifications that may be too slow to
-do all the time, or that may not be desirable all of the time.
-If you find these simplifications are worthwhile, you can type
-@kbd{m A} to have Calc apply them automatically.
-
+@kindex a s
+@kindex m A
This section describes all simplifications that are performed by
-the @kbd{a s} command. Note that these occur in addition to the
-default simplifications; even if the default simplifications have
-been turned off by an @kbd{m O} command, @kbd{a s} will turn them
-back on temporarily while it simplifies the formula.
+the algebraic simplification mode, which is the default simplification
+mode. If you have switched to a different simplification mode, you can
+switch back with the @kbd{m A} command. Even in other simplification
+modes, the @kbd{a s} command will use these algebraic simplifications to
+simplify the formula.
There is a variable, @code{AlgSimpRules}, in which you can put rewrites
-to be applied by @kbd{a s}. Its use is analogous to @code{EvalRules},
+to be applied. Its use is analogous to @code{EvalRules},
but without the special restrictions. Basically, the simplifier does
@samp{@w{a r} AlgSimpRules} with an infinite repeat count on the whole
expression being simplified, then it traverses the expression applying
the built-in rules described below. If the result is different from
-the original expression, the process repeats with the default
+the original expression, the process repeats with the basic
simplifications (including @code{EvalRules}), then @code{AlgSimpRules},
then the built-in simplifications, and so on.
Also, terms of sums are combined by the distributive law, as in
@expr{x + y + 2 x} to @expr{y + 3 x}. This always occurs for
-adjacent terms, but @kbd{a s} compares all pairs of terms including
-non-adjacent ones.
+adjacent terms, but Calc's algebraic simplifications compare all pairs
+of terms including non-adjacent ones.
@tex
\bigskip
Products are sorted into a canonical order using the commutative
law. For example, @expr{b c a} is commuted to @expr{a b c}.
-This allows easier comparison of products; for example, the default
+This allows easier comparison of products; for example, the basic
simplifications will not change @expr{x y + y x} to @expr{2 x y},
-but @kbd{a s} will; it first rewrites the sum to @expr{x y + x y},
-and then the default simplifications are able to recognize a sum
-of identical terms.
+but the algebraic simplifications; it first rewrites the sum to
+@expr{x y + x y} which can then be recognized as a sum of identical
+terms.
The canonical ordering used to sort terms of products has the
property that real-valued numbers, interval forms and infinities
cancel @expr{x^2} from the top and bottom to get @expr{a b / c x d}.
(The terms in the denominator will then be rearranged to @expr{c d x}
as described above.) If there is any common integer or fractional
-factor in the numerator and denominator, it is cancelled out;
+factor in the numerator and denominator, it is canceled out;
for example, @expr{(4 x + 6) / 8 x} simplifies to @expr{(2 x + 3) / 4 x}.
-Non-constant common factors are not found even by @kbd{a s}. To
-cancel the factor @expr{a} in @expr{(a x + a) / a^2} you could first
-use @kbd{j M} on the product @expr{a x} to Merge the numerator to
-@expr{a (1+x)}, which can then be simplified successfully.
+Non-constant common factors are not found even by algebraic
+simplifications. To cancel the factor @expr{a} in
+@expr{(a x + a) / a^2} you could first use @kbd{j M} on the product
+@expr{a x} to Merge the numerator to @expr{a (1+x)}, which can then be
+simplified successfully.
@tex
\bigskip
Integer powers of the variable @code{i} are simplified according
to the identity @expr{i^2 = -1}. If you store a new value other
than the complex number @expr{(0,1)} in @code{i}, this simplification
-will no longer occur. This is done by @kbd{a s} instead of by default
-in case someone (unwisely) uses the name @code{i} for a variable
-unrelated to complex numbers; it would be unfortunate if Calc
-quietly and automatically changed this formula for reasons the
-user might not have been thinking of.
+will no longer occur. This is not done by the basic
+simplifications; in case someone (unwisely) wants to use the name
+@code{i} for a variable unrelated to complex numbers, they can use
+basic simplification mode.
Square roots of integer or rational arguments are simplified in
several ways. (Note that these will be left unevaluated only in
Symbolic mode.) First, square integer or rational factors are
pulled out so that @expr{@tfn{sqrt}(8)} is rewritten as
@texline @math{2\,@tfn{sqrt}(2)}.
-@infoline @expr{2 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
efficiency Calc only looks for primes up to 29.
If the argument is multiplied by a constant, and this constant
has a common integer divisor with the modulus, then this factor is
-cancelled out. For example, @samp{12 x % 15} is changed to
+canceled out. For example, @samp{12 x % 15} is changed to
@samp{3 (4 x % 5)} by factoring out 3. Also, @samp{(12 x + 1) % 15}
is changed to @samp{3 ((4 x + 1:3) % 5)}. While these forms may
not seem ``simpler,'' they allow Calc to discover useful information
Trigonometric functions are simplified in several ways. Whenever a
products of two trigonometric functions can be replaced by a single
function, the replacement is made; for example,
-@expr{@tfn{tan}(x) @tfn{cos}(x)} is simplified to @expr{@tfn{sin}(x)}.
+@expr{@tfn{tan}(x) @tfn{cos}(x)} is simplified to @expr{@tfn{sin}(x)}.
Reciprocals of trigonometric functions are replaced by their reciprocal
function; for example, @expr{1/@tfn{sec}(x)} is simplified to
@expr{@tfn{cos}(x)}. The corresponding simplifications for the
Trigonometric functions of their inverse functions are
simplified. The expression @expr{@tfn{sin}(@tfn{arcsin}(x))} is
-simplified to @expr{x}, and similarly for @code{cos} and @code{tan}.
+simplified to @expr{x}, and similarly for @code{cos} and @code{tan}.
Trigonometric functions of inverses of different trigonometric
functions can also be simplified, as in @expr{@tfn{sin}(@tfn{arccos}(x))}
to @expr{@tfn{sqrt}(1 - x^2)}.
functions are known, except for negative arguments of @code{arcsin},
@code{arctan}, @code{arcsinh}, and @code{arctanh}. Note that
@expr{@tfn{arcsin}(@tfn{sin}(x))} can @emph{not} safely change to
-@expr{x}, since this only correct within an integer multiple of
+@expr{x}, since this only correct within an integer multiple of
@texline @math{2 \pi}
-@infoline @expr{2 pi}
+@infoline @expr{2 pi}
radians or 360 degrees. However, @expr{@tfn{arcsinh}(@tfn{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 @expr{@tfn{exp}(@tfn{ln}(x))},
+are that @expr{@tfn{exp}(@tfn{ln}(x))},
@texline @tfn{e}@math{^{\ln(x)}},
-@infoline @expr{e^@tfn{ln}(x)},
+@infoline @expr{e^@tfn{ln}(x)},
and
@texline @math{10^{{\rm log10}(x)}}
-@infoline @expr{10^@tfn{log10}(x)}
+@infoline @expr{10^@tfn{log10}(x)}
all reduce to @expr{x}. Also, @expr{@tfn{ln}(@tfn{exp}(x))}, etc., can
reduce to @expr{x} if @expr{x} is provably real. The form
@expr{@tfn{exp}(x)^y} is simplified to @expr{@tfn{exp}(x y)}. If @expr{x}
-is a suitable multiple of
-@texline @math{\pi i}
+is a suitable multiple of
+@texline @math{\pi i}
@infoline @expr{pi i}
(as described above for the trigonometric functions), then
@expr{@tfn{exp}(x)} or @expr{e^x} will be expanded. Finally,
@expr{@tfn{ln}(x)} is simplified to a form involving @code{pi} and
@code{i} where @expr{x} is provably negative, positive imaginary, or
-negative imaginary.
+negative imaginary.
The error functions @code{erf} and @code{erfc} are simplified when
their arguments are negative-looking or are calls to the @code{conj}
\bigskip
@end tex
-Equations and inequalities are simplified by cancelling factors
+Equations and inequalities are simplified by canceling factors
of products, quotients, or sums on both sides. Inequalities
-change sign if a negative multiplicative factor is cancelled.
+change sign if a negative multiplicative factor is canceled.
Non-constant multiplicative factors as in @expr{a b = a c} are
-cancelled from equations only if they are provably nonzero (generally
+canceled from equations only if they are provably nonzero (generally
because they were declared so; @pxref{Declarations}). Factors
-are cancelled from inequalities only if they are nonzero and their
+are canceled from inequalities only if they are nonzero and their
sign is known.
Simplification also replaces an equation or inequality with
@cindex Unsafe simplifications
@cindex Extended simplification
@kindex a e
+@kindex m E
@pindex calc-simplify-extended
@ignore
@mindex esimpl@idots
@end ignore
@tindex esimplify
-The @kbd{a e} (@code{calc-simplify-extended}) [@code{esimplify}] command
-is like @kbd{a s}
-except that it applies some additional simplifications which are not
-``safe'' in all cases. Use this only if you know the values in your
-formula lie in the restricted ranges for which these simplifications
-are valid. The symbolic integrator uses @kbd{a e};
-one effect of this is that the integrator's results must be used with
-caution. Where an integral table will often attach conditions like
-``for positive @expr{a} only,'' Calc (like most other symbolic
-integration programs) will simply produce an unqualified result.
+Calc is capable of performing some simplifications which may sometimes
+be desired but which are not ``safe'' in all cases. The @kbd{a e}
+(@code{calc-simplify-extended}) [@code{esimplify}] command
+applies the algebraic simplifications as well as these extended, or
+``unsafe'', simplifications. Use this only if you know the values in
+your formula lie in the restricted ranges for which these
+simplifications are valid. You can use Extended Simplification mode
+(@kbd{m E}) to have these simplifications done automatically.
+
+The symbolic integrator uses these extended simplifications; one effect
+of this is that the integrator's results must be used with caution.
+Where an integral table will often attach conditions like ``for positive
+@expr{a} only,'' Calc (like most other symbolic integration programs)
+will simply produce an unqualified result.
Because @kbd{a e}'s simplifications are unsafe, it is sometimes better
to type @kbd{C-u -3 a v}, which does extended simplification only
In fact, @kbd{C-u -3 j v} allows you to target extended simplification
to any specific part of a formula.
-The variable @code{ExtSimpRules} contains rewrites to be applied by
-the @kbd{a e} command. These are applied in addition to
+The variable @code{ExtSimpRules} contains rewrites to be applied when
+the extended simplifications are used. These are applied in addition to
@code{EvalRules} and @code{AlgSimpRules}. (The @kbd{a r AlgSimpRules}
step described above is simply followed by an @kbd{a r ExtSimpRules} step.)
-Following is a complete list of ``unsafe'' simplifications performed
-by @kbd{a e}.
+Following is a complete list of the ``unsafe'' simplifications.
@tex
\bigskip
@end tex
Inverse trigonometric or hyperbolic functions, called with their
-corresponding non-inverse functions as arguments, are simplified
-by @kbd{a e}. For example, @expr{@tfn{arcsin}(@tfn{sin}(x))} changes
+corresponding non-inverse functions as arguments, are simplified.
+For example, @expr{@tfn{arcsin}(@tfn{sin}(x))} changes
to @expr{x}. Also, @expr{@tfn{arcsin}(@tfn{cos}(x))} and
@expr{@tfn{arccos}(@tfn{sin}(x))} both change to @expr{@tfn{pi}/2 - x}.
These simplifications are unsafe because they are valid only for
are folded down to the 360-degree range that the inverse trigonometric
functions always produce.
-Powers of powers @expr{(x^a)^b} are simplified to
+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
+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, @expr{@tfn{sqrt}(x^a)} and @expr{@tfn{sqrt}(x)^a} are both
-simplified (possibly unsafely) to
+simplified (possibly unsafely) to
@texline @math{x^{a/2}}.
@infoline @expr{x^(a/2)}.
Arguments of square roots are partially factored to look for
squared terms that can be extracted. For example,
-@expr{@tfn{sqrt}(a^2 b^3 + a^3 b^2)} simplifies to
+@expr{@tfn{sqrt}(a^2 b^3 + a^3 b^2)} simplifies to
@expr{a b @tfn{sqrt}(a+b)}.
The simplifications of @expr{@tfn{ln}(@tfn{exp}(x))},
unsafe because of problems with principal values (although these
simplifications are safe if @expr{x} is known to be real).
-Common factors are cancelled from products on both sides of an
+Common factors are canceled from products on both sides of an
equation, even if those factors may be zero: @expr{a x / b x}
-to @expr{a / b}. Such factors are never cancelled from
-inequalities: Even @kbd{a e} is not bold enough to reduce
-@expr{a x < b x} to @expr{a < b} (or @expr{a > b}, depending
+to @expr{a / b}. Such factors are never canceled from
+inequalities: Even the extended simplifications are not bold enough to
+reduce @expr{a x < b x} to @expr{a < b} (or @expr{a > b}, depending
on whether you believe @expr{x} is positive or negative).
The @kbd{a M /} command can be used to divide a factor out of
both sides of an inequality.
@subsection Simplification of Units
@noindent
-The simplifications described in this section are applied by the
-@kbd{u s} (@code{calc-simplify-units}) command. These are in addition
-to the regular @kbd{a s} (but not @kbd{a e}) simplifications described
-earlier. @xref{Basic Operations on Units}.
+The simplifications described in this section (as well as the algebraic
+simplifications) are applied when units need to be simplified. They can
+be applied using the @kbd{u s} (@code{calc-simplify-units}) command, or
+will be done automatically in Units Simplification mode (@kbd{m U}).
+@xref{Basic Operations on Units}.
The variable @code{UnitSimpRules} contains rewrites to be applied by
-the @kbd{u s} command. These are applied in addition to @code{EvalRules}
+units simplifications. These are applied in addition to @code{EvalRules}
and @code{AlgSimpRules}.
Scalar mode is automatically put into effect when simplifying units.
which the first argument is a number which is out of range for the
leading unit are modified accordingly.
-When cancelling and combining units in products and quotients,
+When canceling and combining units in products and quotients,
Calc accounts for unit names that differ only in the prefix letter.
For example, @samp{2 km m} is simplified to @samp{2000 m^2}.
However, compatible but different units like @code{ft} and @code{in}
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
+and @expr{(a^b)^c} to
@texline @math{a^{b c}}
-@infoline @expr{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
real.)
is simplified by noting that @expr{1.5 = 3:2}, that @samp{acre}
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
+replaced by approximately
@texline @math{(4046 m^2)^{1.5}}
-@infoline @expr{(4046 m^2)^1.5},
-which is then changed to
+@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},
+@infoline @expr{4046^1.5 (m^2)^1.5},
then to @expr{257440 m^3}.
The functions @code{float}, @code{frac}, @code{clean}, @code{abs},
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
+of @expr{f} with respect to @expr{x}, evaluated at the point
@texline @math{x=x_0}.
@infoline @expr{x=x0}.
work for all integrable functions, but it is able to integrate several
large 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;
+(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
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
+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
equivalent. Also, any indefinite integral should be considered to have
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
+Calc's solution for
@texline @math{1/(1+\tan x)}
-@infoline @expr{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
+constant factor of
@texline @math{\pi i / 2}
@infoline @expr{pi i / 2},
due to a different choice of constant of integration.
@tindex Ei
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
+integral'' function
@texline @math{{\rm Ei}(x)}
-@infoline @expr{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}
function by adding the rule @samp{[integtry(exp(x)/x, x) := Ei(x)]}
@vindex IntegSimpRules
Another set of rules, stored in @code{IntegSimpRules}, are applied
-every time the integrator uses @kbd{a s} to simplify an intermediate
-result. For example, putting the rule @samp{twice(x) := 2 x} into
-@code{IntegSimpRules} would tell Calc to convert the @code{twice}
-function into a form it knows whenever integration is attempted.
+every time the integrator uses algebraic simplifications to simplify an
+intermediate result. For example, putting the rule
+@samp{twice(x) := 2 x} into @code{IntegSimpRules} would tell Calc to
+convert the @code{twice} function into a form it knows whenever
+integration is attempted.
One more way to influence the integrator is to define a function with
the @kbd{Z F} command (@pxref{Algebraic Definitions}). Calc's
you can use @code{IntegAfterRules}. This is an extra rule set that
runs after the main integrator returns its result; basically, Calc does
an @kbd{a r IntegAfterRules} on the result before showing it to you.
-(It also does an @kbd{a s}, without @code{IntegSimpRules}, after that
-to further simplify the result.) For example, Calc's integrator
+(It also does algebraic simplifications, without @code{IntegSimpRules},
+after that to further simplify the result.) For example, Calc's integrator
sometimes produces expressions of the form @samp{ln(1+x) - ln(1-x)};
the default @code{IntegAfterRules} rewrite this into the more readable
form @samp{2 arctanh(x)}. Note that, unlike @code{IntegRules},
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
+be; for example, solving
@texline @math{a < b \, c}
-@infoline @expr{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
+produce the result
@texline @math{b \mathbin{\hbox{\code{!=}}} a/c}
-@infoline @expr{b != 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
+inequality is now unknown. The inequality
@texline @math{a \le b \, c}
-@infoline @expr{a <= 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.
with the minimum value itself.
Note that this command looks for a @emph{local} minimum. Many functions
-have more than one minimum; some, like
+have more than one minimum; some, like
@texline @math{x \sin x},
-@infoline @expr{x sin(x)},
+@infoline @expr{x sin(x)},
have infinitely many. In fact, there is no easy way to define the
-``global'' minimum of
+``global'' minimum of
@texline @math{x \sin x}
-@infoline @expr{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
finds a point at which the function's value is greater both to the left
no single @expr{m} and @expr{b} that exactly fit the data; in this
case, Calc chooses values of the parameters that provide the closest
possible fit. The model formula can be entered in various ways after
-the key sequence @kbd{a F} is pressed.
+the key sequence @kbd{a F} is pressed.
If the letter @kbd{P} is pressed after @kbd{a F} but before the model
description is entered, the data as well as the model formula will be
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
+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
shown above, the matrix would have four rows (@expr{x_1}, @expr{x_2},
@expr{x_3}, and @expr{y}, respectively).
-If you happen to have an
+If you happen to have an
@texline @math{N\times2}
@infoline Nx2
-matrix instead of a
+matrix instead of a
@texline @math{2\times N}
@infoline 2xN
matrix, just press @kbd{v t} first to transpose the matrix.
which is clearly zero if @expr{a + b x} exactly fits all data points,
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
+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
+for which the error
@texline @math{\chi^2}
-@infoline @expr{chi^2}
+@infoline @expr{chi^2}
is as small as possible.
Other kinds of models do the same thing but with a different model
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 `@var{y_i}@w{ @tfn{+/-} }@math{\sigma_i}',
-@infoline `@var{y_i}@w{ @tfn{+/-} }@var{sigma_i}',
-then the
+@texline `@var{y_i}@w{ @tfn{+/-} }@math{\sigma_i}',
+@infoline `@var{y_i}@w{ @tfn{+/-} }@var{sigma_i}',
+then the
@texline @math{\chi^2}
@infoline @expr{chi^2}
statistic is now,
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
+sum of the squares of the errors forms the
@texline @math{\sigma_i}
-@infoline @expr{sigma_i}
+@infoline @expr{sigma_i}
used for the data point.
Both @kbd{a F} and @kbd{H a F} can accept error forms in the input
probably use @kbd{H a F} so that the output also contains error
estimates.
-If the input contains error forms but all the
+If the input contains error forms but all the
@texline @math{\sigma_i}
-@infoline @expr{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
+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
+is simply scaled uniformly by
@texline @math{1 / \sigma^2},
-@infoline @expr{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
-@kbd{H a F}.
+@kbd{H a F}.
Consult any text on statistical modeling of data for a discussion
of where these error estimates come from and how they should be
The covariance matrix @expr{C} computed from the fit. This is
an @var{m}x@var{m} symmetric matrix; the diagonal elements
@texline @math{C_{jj}}
-@infoline @expr{C_j_j}
-are the variances
+@infoline @expr{C_j_j}
+are the variances
@texline @math{\sigma_j^2}
-@infoline @expr{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}
+@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}
+set of numbers, the @dfn{linear correlation coefficients}
@texline @math{r_{ij}},
@infoline @expr{r_i_j},
-are defined as
+are defined as
@texline @math{\sigma_{ij}^2 / \sigma_i \, \sigma_j}.)
@infoline @expr{sigma_i_j^2 / sigma_i sigma_j}.)
polynomial and multilinear fits described so far.
@item
-The value of
+The value of
@texline @math{\chi^2}
-@infoline @expr{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}
+@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).
@item
A measure of goodness of fit expressed as a probability @expr{Q}.
This is computed from the @code{utpc} probability distribution
-function using
+function using
@texline @math{\chi^2}
-@infoline @expr{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,
+particular,
@texline @math{\chi^2}
-@infoline @expr{chi^2}
+@infoline @expr{chi^2}
statistics assume the errors in your inputs
follow a normal (Gaussian) distribution; if they don't, you may
have to accept smaller values of @expr{Q}.
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
+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
@item q
Quadratic. @mathit{a + b (x-c)^2 + d (x-e)^2}.
@item g
-Gaussian.
+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)}.
@item s
All models except Gaussian, logistics, Hubbert and polynomials can
generalize as shown to any number of independent variables. Also, all
-the built-in models except for the logistic and Hubbert curves have an
+the built-in models except for the logistic and Hubbert curves have an
additive or multiplicative parameter shown as @expr{a} in the above table
which can be replaced by zero or one, as appropriate, by typing @kbd{h}
before the model key.
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
+so that the argument of the sine might go from zero to
@texline @math{3\times360}
-@infoline @mathit{3*360}
+@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
@end example
@noindent
-which matches the desired form with
+which matches the desired form with
@texline @math{Y = \ln(y)},
-@infoline @expr{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
+@expr{F = 1}, @expr{B = b}, and
@texline @math{G = \ln(x)}.
-@infoline @expr{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)}
+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}.
Another interesting example is the ``quadratic'' model, which can
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
+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}
A compromise would be to pick out a few parameters without which the
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
+to be minimized would be the value of
@texline @math{\chi^2}
-@infoline @expr{chi^2}
+@infoline @expr{chi^2}
returned as the fifth result of the @code{xfit} function:
@smallexample
and @expr{y} to be plain numbers, and makes @expr{z} into an error
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
+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
+@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}.
+@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;
the righthand side of the linearized model is computed in regular
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}
+@infoline @expr{sigma}
for the data point with no further ado.)
@tex
@samp{sum(a_k, k, 0, 2 n, n)} produces @samp{a_0 + a_n + a_(2 n)}.
Calc computes the number of iterations using the formula
@samp{1 + (@var{high} - @var{low}) / @var{step}}, which must,
-after simplification as if by @kbd{a s}, evaluate to an integer.
+after algebraic simplification, evaluate to an integer.
If the number of iterations according to the above formula does
not come out to an integer, the sum is invalid and will be left
formula works out to the indeterminate form @expr{0 / 0}, which
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
+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)}
of @samp{<} and @samp{<=} are allowed, or any of the four combinations
of @samp{>} and @samp{>=}. Four-argument constructions like
@samp{a < b < c < d}, and mixtures like @w{@samp{a < b = c}} that
-involve both equalities and inequalities, are not allowed.
+involve both equations and inequalities, are not allowed.
@kindex a .
@pindex calc-remove-equal
the rule is accepted. Once @var{old} has been successfully matched
to the target expression, @var{cond} is evaluated (with all the
meta-variables substituted for the values they matched) and simplified
-with @kbd{a s} (@code{calc-simplify}). If the result is a nonzero
+with Calc's algebraic simplifications. If the result is a nonzero
number or any other object known to be nonzero (@pxref{Declarations}),
the rule is accepted. If the result is zero or if it is a symbolic
formula that is not known to be nonzero, the rule is rejected.
then the rule set @samp{[f(0) := 0, import(linearF)]} will apply
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
+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
+@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
+@infoline @expr{x1}
+and so on. (If
@texline @math{v_1}
-@infoline @expr{v1}
-is used as a function name, then
+@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 @w{@samp{< >}} nameless
@end ignore
@tindex evalsimp
The formula @expr{x} has meta-variables substituted in the usual
-way, then algebraically simplified as if by the @kbd{a s} command.
+way, then algebraically simplified.
@item evalextsimp(x)
@ignore
@end ignore
@tindex let
The expression @expr{x} is evaluated with meta-variables substituted.
-The @kbd{a s} command's simplifications are @emph{not} applied by
+The algebraic simplifications are @emph{not} applied by
default, but @expr{x} can include calls to @code{evalsimp} or
@code{evalextsimp} as described above to invoke higher levels
-of simplification. The
-result of @expr{x} is then bound to the meta-variable @expr{v}. As
-usual, if this meta-variable has already been matched to something
-else the two values must be equal; if the meta-variable is new then
-it is bound to the result of the expression. This variable can then
-appear in later conditions, and on the righthand side of the rule.
+of simplification. The result of @expr{x} is then bound to the
+meta-variable @expr{v}. As usual, if this meta-variable has already
+been matched to something else the two values must be equal; if the
+meta-variable is new then it is bound to the result of the expression.
+This variable can then appear in later conditions, and on the righthand
+side of the rule.
In fact, @expr{v} may be any pattern in which case the result of
evaluating @expr{x} is matched to that pattern, binding any
meta-variables that appear in that pattern. Note that @code{let}
@cindex @code{AlgSimpRules} variable
@vindex AlgSimpRules
Suppose you want @samp{sin(a + b)} to be expanded out not all the time,
-but only when @kbd{a s} is used to simplify the formula. The variable
-@code{AlgSimpRules} holds rules for this purpose. The @kbd{a s} command
-will apply @code{EvalRules} and @code{AlgSimpRules} to the formula, as
-well as all of its built-in simplifications.
+but only when algebraic simplifications are used to simplify the
+formula. The variable @code{AlgSimpRules} holds rules for this purpose.
+The @kbd{a s} command will apply @code{EvalRules} and
+@code{AlgSimpRules} to the formula, as well as all of its built-in
+simplifications.
Most of the special limitations for @code{EvalRules} don't apply to
@code{AlgSimpRules}. Calc simply does an @kbd{a r AlgSimpRules}
-command with an infinite repeat count as the first step of @kbd{a s}.
-It then applies its own built-in simplifications throughout the
-formula, and then repeats these two steps (along with applying the
-default simplifications) until no further changes are possible.
+command with an infinite repeat count as the first step of algebraic
+simplifications. It then applies its own built-in simplifications
+throughout the formula, and then repeats these two steps (along with
+applying the default simplifications) until no further changes are
+possible.
@cindex @code{ExtSimpRules} variable
@cindex @code{UnitSimpRules} variable
@code{tri} to the value on the top of the stack. @xref{Programming}.
@cindex Quaternions
-The following rule set, contributed by
+The following rule set, contributed by
@texline Fran\c cois
@infoline Francois
Pinard, implements @dfn{quaternions}, a generalization of the concept of
@tindex usimplify
The @kbd{u s} (@code{calc-simplify-units}) [@code{usimplify}] command
simplifies a units
-expression. It uses @kbd{a s} (@code{calc-simplify}) to simplify the
+expression. It uses Calc's algebraic simplifications to simplify the
expression first as a regular algebraic formula; it then looks for
features that can be further simplified by converting one object's units
to be compatible with another's. For example, @samp{5 m + 23 mm} will
While many of Calc's conversion factors are exact, some are necessarily
approximate. If Calc is in fraction mode (@pxref{Fraction Mode}), then
unit conversions will try to give exact, rational conversions, but it
-isn't always possible. Given @samp{55 mph} in fraction mode, typing
-@kbd{u c m/s @key{RET}} produces @samp{15367:625 m/s}, for example,
-while typing @kbd{u c au/yr @key{RET}} produces
+isn't always possible. Given @samp{55 mph} in fraction mode, typing
+@kbd{u c m/s @key{RET}} produces @samp{15367:625 m/s}, for example,
+while typing @kbd{u c au/yr @key{RET}} produces
@samp{5.18665819999e-3 au/yr}.
If the units you request are inconsistent with the original units, the
``fundamental'' units like @samp{m} and @samp{s}, regardless of the
input units.
+If you want to disallow using inconsistent units, you can set the customizable variable
+@code{calc-ensure-consistent-units} to @code{t} (@pxref{Customizing Calc}). In this case,
+if you request units which are inconsistent with the original units, you will be warned about
+it and no conversion will occur.
+
One special exception is that if you specify a single unit name, and
a compatible unit appears somewhere in the units expression, then
that compatible unit will be converted to the new unit and the
Other units used by @TeX{} are available; they are @code{texpc} (a pica),
@code{texbp} (a ``big point'', equal to a standard point which is larger
than the point used by @TeX{}), @code{texdd} (a Didot point),
-@code{texcc} (a Cicero) and @code{texsp} (a scaled @TeX{} point,
+@code{texcc} (a Cicero) and @code{texsp} (a scaled @TeX{} point,
all dimensions representable in @TeX{} are multiples of this value).
-When Calc is using the @TeX{} or La@TeX{} language mode (@pxref{TeX
+When Calc is using the @TeX{} or @LaTeX{} language mode (@pxref{TeX
and LaTeX Language Modes}), the @TeX{} specific unit names will not
use the @samp{tex} prefix; the unit name for a @TeX{} point will be
@samp{pt} instead of @samp{texpt}, for example. To avoid conflicts,
units which are manipulated differently than standard units. Calc
provides commands to work with these logarithmic units.
-Decibels and nepers are used to measure power quantities as well as
+Decibels and nepers are used to measure power quantities as well as
field quantities (quantities whose squares are proportional to power);
these two types of quantities are handled slightly different from each
other. By default the Calc commands work as if power quantities are
being used; with the @kbd{H} prefix the Calc commands work as if field
quantities are being used.
-The decibel level of a power
+The decibel level of a power
@infoline @math{P1},
@texline @math{P_1},
-relative to a reference power
+relative to a reference power
@infoline @math{P0},
@texline @math{P_0},
is defined to be
one-tenth of a bel. The bel, named after Alexander Graham Bell, was
considered to be too large of a unit and was effectively replaced by
the decibel.) If @math{F} is a field quantity with power
-@math{P=k F^2}, then a reference quantity of
+@math{P=k F^2}, then a reference quantity of
@infoline @math{F0}
@texline @math{F_0}
-would correspond to a power of
+would correspond to a power of
@infoline @math{P0=k F0^2}.
@texline @math{P_{0}=kF_{0}^2}.
If
then
@ifnottex
-@example
+@example
10 log10(P1/P0) = 10 log10(F1^2/F0^2) = 20 log10(F1/F0).
@end example
@end ifnottex
@noindent
In order to get the same decibel level regardless of whether a field
quantity or the corresponding power quantity is used, the decibel
-level of a field quantity
+level of a field quantity
@infoline @math{F1},
-@texline @math{F_1},
-relative to a reference
+@texline @math{F_1},
+relative to a reference
@infoline @math{F0},
-@texline @math{F_0},
+@texline @math{F_0},
is defined as
@infoline @math{20 log10(F1/F0) dB}.
@texline @math{20 \log_{10}(F_{1}/F_{0}) {\rm dB}}.
-For example, the decibel value of a sound pressure level of
+For example, the decibel value of a sound pressure level of
@infoline @math{60 uPa}
@texline @math{60 \mu{\rm Pa}}
-relative to
+relative to
@infoline @math{20 uPa}
@texline @math{20 \mu{\rm Pa}}
-(the threshhold of human hearing) is
+(the threshold of human hearing) is
@infoline @math{20 log10(60 uPa/ 20 uPa) dB = 20 log10(3) dB},
@texline @math{20 \log_{10}(60 \mu{\rm Pa}/20 \mu{\rm Pa}) {\rm dB} = 20 \log_{10}(3) {\rm dB}},
-which is about
+which is about
@infoline @math{9.54 dB}.
@texline @math{9.54 {\rm dB}}.
Note that in taking the ratio, the original units cancel and so these
-logarithmic units are dimensionless.
+logarithmic units are dimensionless.
Nepers (named after John Napier, who is credited with inventing the
logarithm) are similar to bels except they use natural logarithms instead
-of common logarithms. The neper level of a power
+of common logarithms. The neper level of a power
@infoline @math{P1},
@texline @math{P_1},
-relative to a reference power
+relative to a reference power
@infoline @math{P0},
@texline @math{P_0},
is
@infoline @math{(1/2) ln(P1/P0) Np}.
@texline @math{(1/2) \ln(P_1/P_0) {\rm Np}}.
-The neper level of a field
+The neper level of a field
@infoline @math{F1},
@texline @math{F_1},
relative to a reference field
@vindex calc-lu-power-reference
@vindex calc-lu-field-reference
For power quantities, Calc uses
-@infoline @math{1 mW}
+@infoline @math{1 mW}
@texline @math{1 {\rm mW}}
-as the default reference quantity; this default can be changed by changing
+as the default reference quantity; this default can be changed by changing
the value of the customizable variable
@code{calc-lu-power-reference} (@pxref{Customizing Calc}).
-For field quantities, Calc uses
-@infoline @math{20 uPa}
+For field quantities, Calc uses
+@infoline @math{20 uPa}
@texline @math{20 \mu{\rm Pa}}
as the default reference quantity; this is the value used in acoustics
which is where decibels are commonly encountered. This default can be
logarithmic units. With the capital @kbd{O} prefix, @kbd{O l q}, the
reference level will be read from the top of the stack. (In an
algebraic formula, @code{lupquant} can be given an optional second
-argument which will be used for the reference level.) For example,
-@code{20 dB @key{RET} l q} will return @code{100 mW};
-@code{20 dB @key{RET} 4 W @key{RET} O l q} will return @code{400 W}.
+argument which will be used for the reference level.) For example,
+@code{20 dB @key{RET} l q} will return @code{100 mW};
+@code{20 dB @key{RET} 4 W @key{RET} O l q} will return @code{400 W}.
The @kbd{H l q} [@code{lufquant}] command behaves like @kbd{l q} but
computes field quantities instead of power quantities.
@tindex lufdiv
The sum of two power or field quantities doesn't correspond to the sum
of the corresponding decibel or neper levels. If the powers
-corresponding to decibel levels
-@infoline @math{D1}
-@texline @math{D_1}
-and
-@infoline @math{D2}
-@texline @math{D_2}
-are added, the corresponding decibel level ``sum'' will be
+corresponding to decibel levels
+@infoline @math{D1}
+@texline @math{D_1}
+and
+@infoline @math{D2}
+@texline @math{D_2}
+are added, the corresponding decibel level ``sum'' will be
@ifnottex
@example
@noindent
if a field quantity is multiplied by @math{N} the corresponding decibel level
-will be
+will be
@ifnottex
@example
Scientific pitch notation refers to a note by giving a letter
A through G, possibly followed by a flat or sharp) with a subscript
indicating an octave number. Each octave starts with C and ends with
-B and
+B and
@c increasing each note by a semitone will result
@c in the sequence @expr{C}, @expr{C} sharp, @expr{D}, @expr{E} flat, @expr{E},
@c @expr{F}, @expr{F} sharp, @expr{G}, @expr{A} flat, @expr{A}, @expr{B}
-@c flat and @expr{B}.
+@c flat and @expr{B}.
the octave numbered 0 was chosen to correspond to the lowest
audible frequency. Using this system, middle C (about 261.625 Hz)
corresponds to the note @expr{C} in octave 4 and is denoted
@expr{C_4}. Any frequency can be described by giving a note plus an
offset in cents (where a cent is a ratio of frequencies so that a
-semitone consists of 100 cents).
+semitone consists of 100 cents).
The midi note number system assigns numbers to notes so that
@expr{C_(-1)} corresponds to the midi note number 0 and @expr{G_9}
corresponds to the midi note number 127. A midi controller can have
up to 128 keys and each midi note number from 0 to 127 corresponds to
-a possible key.
+a possible key.
@kindex l s
@pindex calc-spn
@tindex spn
The @kbd{l s} (@code{calc-spn}) [@code{spn}] command converts either
a frequency or a midi number to scientific pitch notation. For
-example, @code{500 Hz} gets converted to
-@code{B_4 + 21.3094853649 cents} and @code{84} to @code{C_6}.
+example, @code{500 Hz} gets converted to
+@code{B_4 + 21.3094853649 cents} and @code{84} to @code{C_6}.
@kindex l m
the stack into a specified variable. It prompts you to enter the
name of the variable. If you press a single digit, the value is stored
immediately in one of the ``quick'' variables @code{q0} through
-@code{q9}. Or you can enter any variable name.
+@code{q9}. Or you can enter any variable name.
@kindex s t
@pindex calc-store-into
All the arithmetic stores accept the Inverse prefix to reverse the
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
-@w{@kbd{s -}} assigns
+@w{@kbd{s -}} assigns
@texline @math{v \coloneq v - a},
-@infoline @expr{v := v - a},
+@infoline @expr{v := v - a},
but @kbd{I s -} assigns
@texline @math{v \coloneq a - v}.
-@infoline @expr{v := 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
arithmetic stores use formulas designed to behave usefully both
@kindex s k
@pindex calc-copy-special-constant
If one of the ``special constants'' is redefined (or undefined) so that
-it no longer has its magic property, the property can be restored with
+it no longer has its magic property, the property can be restored with
@kbd{s k} (@code{calc-copy-special-constant}). This command will prompt
for a special constant and a variable to store it in, and so a special
constant can be stored in any variable. Here, the special constant that
@item s D
Edit @code{Decls}. @xref{Declarations}.
@item s E
-Edit @code{EvalRules}. @xref{Default Simplifications}.
+Edit @code{EvalRules}. @xref{Basic Simplifications}.
@item s F
Edit @code{FitRules}. @xref{Curve Fitting}.
@item s G
The @kbd{s i} (@code{calc-insert-variables}) command writes
the values of all Calc variables into a specified buffer.
The variables are written with the prefix @code{var-} in the form of
-Lisp @code{setq} commands
+Lisp @code{setq} commands
which store the values in string form. You can place these commands
in your Calc init file (or @file{.emacs}) if you wish, though in this case it
would be easier to use @kbd{s p @key{RET}}. (Note that @kbd{s i}
@cindex @samp{=>} operator
The special algebraic symbol @samp{=>} is known as the @dfn{evaluates-to
operator}. (It will show up as an @code{evalto} function call in
-other language modes like Pascal and La@TeX{}.) This is a binary
+other language modes like Pascal and @LaTeX{}.) This is a binary
operator, that is, it has a lefthand and a righthand argument,
although it can be entered with the righthand argument omitted.
All current modes apply when an @samp{=>} operator is computed,
including the current simplification mode. Recall that the
-formula @samp{x + y + x} is not handled by Calc's default
-simplifications, but the @kbd{a s} command will reduce it to
-the simpler form @samp{y + 2 x}. You can also type @kbd{m A}
-to enable an Algebraic Simplification mode in which the
-equivalent of @kbd{a s} is used on all of Calc's results.
-If you enter @samp{x + y + x =>} normally, the result will
-be @samp{x + y + x => x + y + x}. If you change to
-Algebraic Simplification mode, the result will be
-@samp{x + y + x => y + 2 x}. However, just pressing @kbd{a s}
-once will have no effect on @samp{x + y + x => x + y + x},
+formula @samp{arcsin(sin(x))} will not be handled by Calc's algebraic
+simplifications, but Calc's unsafe simplifications will reduce it to
+@samp{x}. If you enter @samp{arcsin(sin(x)) =>} normally, the result
+will be @samp{arcsin(sin(x)) => arcsin(sin(x))}. If you change to
+Extended Simplification mode, the result will be
+@samp{arcsin(sin(x)) => x}. However, just pressing @kbd{a e}
+once will have no effect on @samp{arcsin(sin(x)) => arcsin(sin(x))},
because the righthand side depends only on the lefthand side
and the current mode settings, and the lefthand side is not
-affected by commands like @kbd{a s}.
+affected by commands like @kbd{a e}.
The ``let'' command (@kbd{s l}) has an interesting interaction
with the @samp{=>} operator. The @kbd{s l} command evaluates the
the same length); either or both may instead be interval forms. The
``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
+result is a surface plot where
@texline @math{z_{ij}}
-@infoline @expr{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
be displayed from a certain default viewpoint; you can change this
values covered by all the curves ought to be roughly the same if
they are to look nice on the same graph.)
-For example, to plot
+For example, to plot
@texline @math{\sin n x}
-@infoline @expr{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
(@expr{n}), then @kbd{V M '} or @kbd{V M $} to map @samp{sin(n x)}
The @kbd{g S} (@code{calc-graph-point-style}) command similarly turns
the symbols at the data points on or off, or sets the point style.
If you turn both lines and points off, the data points will show as
-tiny dots. If the ``y'' values being plotted contain error forms and
-the connecting lines are turned off, then this command will also turn
+tiny dots. If the ``y'' values being plotted contain error forms and
+the connecting lines are turned off, then this command will also turn
the error bars on or off.
@cindex @code{LineStyles} variable
picture of the graph composed of characters like @code{-} and @code{|}
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
+dumb terminals will be
@texline @math{80\times24}
@infoline 80x24
characters. The graph is displayed in
@kindex g O
@pindex calc-graph-output
The @kbd{g O} (@code{calc-graph-output}) command sets the name of the
-output file used by GNUPLOT. For some devices, notably @code{x11} and
+output file used by GNUPLOT@. For some devices, notably @code{x11} and
@code{windows}, there is no output file and this information is not
used. Many other ``devices'' are really file formats like
@code{postscript}; in these cases the output in the desired format
effect if the current device is @code{windows}.
The buffer called @samp{*Gnuplot Trail*} holds a transcript of the
-session with GNUPLOT. This shows the commands Calc has ``typed'' to
+session with GNUPLOT@. This shows the commands Calc has ``typed'' to
GNUPLOT and the responses it has received. Calc tries to notice when an
error message has appeared here and display the buffer for you when
this happens. You can check this buffer yourself if you suspect
@pindex calc-prepend-to-register
@pindex calc-append-to-register
@cindex Registers
-An alternative to killing and yanking stack entries is using
+An alternative to killing and yanking stack entries is using
registers in Calc. Saving stack entries in registers is like
saving text in normal Emacs registers; although, like Calc's kill
commands, register commands always operate on whole stack
would correctly split the line into two error forms.
@xref{Matrix Functions}, to see how to pull the matrix apart into its
-constituent rows and columns. (If it is a
+constituent rows and columns. (If it is a
@texline @math{1\times1}
@infoline 1x1
matrix, just hit @kbd{v u} (@code{calc-unpack}) twice.)
@key{INV GCD} computes the LCM (least common multiple) function.
-@key{INV FACT} is the gamma function.
+@key{INV FACT} is the gamma function.
@texline @math{\Gamma(x) = (x-1)!}.
@infoline @expr{gamma(x) = (x-1)!}.
Calc will try to guess an appropriate language based on the major mode
of the editing buffer. (@xref{Language Modes}.) If the current buffer is
-in @code{latex-mode}, for example, Calc will set its language to La@TeX{}.
+in @code{latex-mode}, for example, Calc will set its language to @LaTeX{}.
Similarly, Calc will use @TeX{} language for @code{tex-mode},
@code{plain-tex-mode} and @code{context-mode}, C language for
@code{c-mode} and @code{c++-mode}, FORTRAN language for
@code{fortran-mode} and @code{f90-mode}, Pascal for @code{pascal-mode},
-and eqn for @code{nroff-mode} (@pxref{Customizing Calc}).
+and eqn for @code{nroff-mode} (@pxref{Customizing Calc}).
These can be overridden with Calc's mode
changing commands (@pxref{Mode Settings in Embedded Mode}). If no
suitable language is available, Calc will continue with its current language.
@enumerate
@item
-The @TeX{} and La@TeX{} math delimiters @samp{$ $}, @samp{$$ $$},
+The @TeX{} and @LaTeX{} math delimiters @samp{$ $}, @samp{$$ $$},
@samp{\[ \]}, and @samp{\( \)};
@item
Lines beginning with @samp{\begin} and @samp{\end} (except matrix delimiters);
When Embedded mode ``activates'' a formula, i.e., when it examines
the formula for the first time since the buffer was created or
loaded, Calc tries to sense the language in which the formula was
-written. If the formula contains any La@TeX{}-like @samp{\} sequences,
-it is parsed (i.e., read) in La@TeX{} mode. If the formula appears to
+written. If the formula contains any @LaTeX{}-like @samp{\} sequences,
+it is parsed (i.e., read) in @LaTeX{} mode. If the formula appears to
be written in multi-line Big mode, it is parsed in Big mode. Otherwise,
it is parsed according to the current language mode.
Note that Calc does not change the current language mode according
-the formula it reads in. Even though it can read a La@TeX{} formula when
-not in La@TeX{} mode, it will immediately rewrite this formula using
+the formula it reads in. Even though it can read a @LaTeX{} formula when
+not in @LaTeX{} mode, it will immediately rewrite this formula using
whatever language mode is in effect.
@tex
Plain formulas are preceded and followed by @samp{%%%} signs
by default. This notation has the advantage that the @samp{%}
-character begins a comment in @TeX{} and La@TeX{}, so if your formula is
-embedded in a @TeX{} or La@TeX{} document its plain version will be
+character begins a comment in @TeX{} and @LaTeX{}, so if your formula is
+embedded in a @TeX{} or @LaTeX{} document its plain version will be
invisible in the final printed copy. Certain major modes have different
-delimiters to ensure that the ``plain'' version will be
-in a comment for those modes, also.
+delimiters to ensure that the ``plain'' version will be
+in a comment for those modes, also.
See @ref{Customizing Embedded Mode} to see how to change the ``plain''
-formula delimiters.
+formula delimiters.
There are several notations which Calc's parser for ``big''
formatted formulas can't yet recognize. In particular, it can't
@noindent
where the leading and trailing @samp{---} can be replaced by
any suitable strings (which must be the same on all three lines)
-or omitted altogether; in a @TeX{} or La@TeX{} file, @samp{%} would be a good
+or omitted altogether; in a @TeX{} or @LaTeX{} file, @samp{%} would be a good
leading string and no trailing string would be necessary. In a
C program, @samp{/*} and @samp{*/} would be good leading and
trailing strings.
on it in order to get it to notice the new annotation.
Two more mode-recording modes selectable by @kbd{m R} are available
-which are also available outside of Embedded mode.
+which are also available outside of Embedded mode.
(@pxref{General Mode Commands}.) They are @code{Save}, in which mode
settings are recorded permanently in your Calc init file (the file given
by the variable @code{calc-settings-file}, typically @file{~/.emacs.d/calc.el})
@noindent
You can modify Embedded mode's behavior by setting various Lisp
-variables described here. These variables are customizable
+variables described here. These variables are customizable
(@pxref{Customizing Calc}), or you can use @kbd{M-x set-variable}
or @kbd{M-x edit-options} to adjust a variable on the fly.
(Another possibility would be to use a file-local variable annotation at
-the end of the file;
+the end of the file;
@pxref{File Variables, , Local Variables in Files, emacs, the Emacs manual}.)
Many of the variables given mentioned here can be set to depend on the
major mode of the editing buffer (@pxref{Customizing Calc}).
annotation itself. But this is the string that is inserted before
the opening bracket when Calc adds an annotation on its own.
The default is @code{"% "}, but may be different for different major
-modes.
+modes.
@vindex calc-embedded-close-mode
The @code{calc-embedded-close-mode} variable is a string which
(If the command you give implies a function, the function will be saved,
and if the function has any display formats, those will be saved, but
not the other way around: Saving a function will not save any commands
-or key bindings associated with the function.)
+or key bindings associated with the function.)
@kindex Z E
@pindex calc-user-define-edit
@cindex Keyboard macros, editing
The @kbd{Z E} (@code{calc-user-define-edit}) command on a key that has
been defined by a keyboard macro tries to use the @code{edmacro} package
-edit the macro. Type @kbd{C-c C-c} to finish editing and update
+edit the macro. Type @kbd{C-c C-c} to finish editing and update
the definition stored on the key, or, to cancel the edit, kill the
buffer with @kbd{C-x k}.
The special characters @code{RET}, @code{LFD}, @code{TAB}, @code{SPC},
copied verbatim into the keyboard macro. Basically, the notation is the
same as is used in all of this manual's examples, except that the manual
takes some liberties with spaces: When we say @kbd{' [1 2 3] @key{RET}},
-we take it for granted that it is clear we really mean
+we take it for granted that it is clear we really mean
@kbd{' [1 @key{SPC} 2 @key{SPC} 3] @key{RET}}.
@kindex C-x * m
subsequent calculations.) This command allows your keyboard macros to
accept numbers or formulas as interactive input.
-As an example,
+As an example,
@kbd{2 @key{RET} "Power: " @key{RET} Z # 3 @key{RET} ^} will prompt for
input with ``Power: '' in the minibuffer, then return 2 to the provided
power. (The response to the prompt that's given, 3 in this example,
use the same name as the command name but without the @samp{calc-}
prefix. (If this is of the form @samp{User-m}, the hyphen is removed so
it won't be taken for a minus sign in algebraic formulas.)
-This is the name you will use if you want to enter your
+This is the name you will use if you want to enter your
new function in an algebraic formula. Suppose we enter @kbd{yow @key{RET}}.
Then the new function can be invoked by pushing two numbers on the
stack and typing @kbd{z m} or @kbd{x spam}, or by entering the algebraic
@end ignore
@tindex mysin
A somewhat limited sine function could be defined as follows, using the
-well-known Taylor series expansion for
+well-known Taylor series expansion for
@texline @math{\sin x}:
@infoline @samp{sin(x)}:
Date forms are stored as @samp{(date @var{n})}, where @var{n} is
a real number that counts days since midnight on the morning of
-January 1, 1 AD. If @var{n} is an integer, this is a pure date
+January 1, 1 AD@. If @var{n} is an integer, this is a pure date
form. If @var{n} is a fraction or float, this is a date/time form.
Modulo forms are stored as @samp{(mod @var{n} @var{m})}, where @var{m} is a
other types of objects to be unordered, @code{beforep} puts any two
objects into a definite, consistent order. The @code{beforep}
function is used by the @kbd{V S} vector-sorting command, and also
-by @kbd{a s} to put the terms of a product into canonical order:
-This allows @samp{x y + y x} to be simplified easily to @samp{2 x y}.
+by Calc's algebraic simplifications to put the terms of a product into
+canonical order: This allows @samp{x y + y x} to be simplified easily to
+@samp{2 x y}.
@end defun
@defun equal x y
@end defun
@defun simplify expr
-Simplify the expression @var{expr} by applying various algebraic rules.
-This is what the @w{@kbd{a s}} (@code{calc-simplify}) command uses. This
-always returns a copy of the expression; the structure @var{expr} points
-to remains unchanged in memory.
+Simplify the expression @var{expr} by applying Calc's algebraic
+simplifications. This always returns a copy of the expression; the
+structure @var{expr} points to remains unchanged in memory.
More precisely, here is what @code{simplify} does: The expression is
first normalized and evaluated by calling @code{normalize}. If any
before the call to @code{normalize}) and, if it has changed,
the entire procedure is repeated (starting with @code{normalize})
until no further changes occur. Usually only two iterations are
-needed:@: one to simplify the formula, and another to verify that no
+needed: one to simplify the formula, and another to verify that no
further simplifications were possible.
@end defun
derivative is left in terms of @var{var}. If the expression contains
functions for which no derivative formula is known, new derivative
functions are invented by adding primes to the names; @pxref{Calculus}.
-However, if @var{symb} is non-@code{nil}, the presence of undifferentiable
+However, if @var{symb} is non-@code{nil}, the presence of nondifferentiable
functions in @var{expr} instead cancels the whole differentiation, and
@code{deriv} returns @code{nil} instead.
@end example
@noindent
-in your .emacs file.
+in your .emacs file.
(@xref{Key Bindings,,Customizing Key Bindings,emacs,
The GNU Emacs Manual}, for more information on binding keys.)
A convenient way to start Calc is with @kbd{C-x * *}; to make it equally
@defvar calc-settings-file
The variable @code{calc-settings-file} holds the file name in
which commands like @kbd{m m} and @kbd{Z P} store ``permanent''
-definitions.
+definitions.
If @code{calc-settings-file} is not your user init file (typically
@file{~/.emacs}) and if the variable @code{calc-loaded-settings-file} is
@code{nil}, then Calc will automatically load your settings file (if it
determine what language should be used. (This can be overridden using
Calc's mode changing commands, @xref{Mode Settings in Embedded Mode}.)
The variable @code{calc-language-alist} consists of a list of pairs of
-the form @code{(@var{MAJOR-MODE} . @var{LANGUAGE})}; for example,
+the form @code{(@var{MAJOR-MODE} . @var{LANGUAGE})}; for example,
@code{(latex-mode . latex)} is one such pair. If Calc embedded is
activated in a buffer whose major mode is @var{MAJOR-MODE}, it will set itself
to use the language @var{LANGUAGE}.
regular expression, and when activating embedded formulas with
@kbd{C-x * a}, it will tell Calc that what follows is a formula to be
activated. (Calc also uses other patterns to find formulas, such as
-@samp{=>} and @samp{:=}.)
+@samp{=>} and @samp{:=}.)
The default pattern is @code{"%Embed\n\\(% .*\n\\)*"}, which checks
for @samp{%Embed} followed by any number of lines beginning with
(texinfo-mode . "@@c Embed\n\\(@@c .*\n\\)*"))
@end example
Any major modes added to @code{calc-embedded-announce-formula-alist}
-should also be added to @code{calc-embedded-open-close-plain-alist}
+should also be added to @code{calc-embedded-open-close-plain-alist}
and @code{calc-embedded-open-close-mode-alist}.
@end defvar
The variables @code{calc-embedded-open-formula} and
@code{calc-embedded-close-formula} control the region that Calc will
activate as a formula when Embedded mode is entered with @kbd{C-x * e}.
-They are regular expressions;
+They are regular expressions;
Calc normally scans backward and forward in the buffer for the
nearest text matching these regular expressions to be the ``formula
delimiters''.
Embedded mode understands by default are:
@enumerate
@item
-The @TeX{} and La@TeX{} math delimiters @samp{$ $}, @samp{$$ $$},
+The @TeX{} and @LaTeX{} math delimiters @samp{$ $}, @samp{$$ $$},
@samp{\[ \]}, and @samp{\( \)};
@item
Lines beginning with @samp{\begin} and @samp{\end} (except matrix delimiters);
set @code{calc-embedded-open-formula} and
@code{calc-embedded-close-formula} to different regular
expressions depending on the major mode of the editing buffer.
-It consists of a list of lists of the form
+It consists of a list of lists of the form
@code{(@var{MAJOR-MODE} @var{OPEN-FORMULA-REGEXP}
@var{CLOSE-FORMULA-REGEXP})}, and its default value is
@code{nil}.
The variable @code{calc-embedded-word-regexp-alist} is used to
set @code{calc-embedded-word-regexp} to a different regular
expression depending on the major mode of the editing buffer.
-It consists of a list of lists of the form
+It consists of a list of lists of the form
@code{(@var{MAJOR-MODE} @var{WORD-REGEXP})}, and its default value is
@code{nil}.
@end defvar
expressions, because Calc must be able to write these string into a
buffer as well as to recognize them.
-The default string for @code{calc-embedded-open-plain} is
-@code{"%%% "}, note the trailing space. The default string for
+The default string for @code{calc-embedded-open-plain} is
+@code{"%%% "}, note the trailing space. The default string for
@code{calc-embedded-close-plain} is @code{" %%%\n"}, without
the trailing newline here, the first line of a Big mode formula
that followed might be shifted over with respect to the other lines.
set @code{calc-embedded-open-plain} and
@code{calc-embedded-close-plain} to different strings
depending on the major mode of the editing buffer.
-It consists of a list of lists of the form
+It consists of a list of lists of the form
@code{(@var{MAJOR-MODE} @var{OPEN-PLAIN-STRING}
@var{CLOSE-PLAIN-STRING})}, and its default value is
@example
set @code{calc-embedded-open-new-formula} and
@code{calc-embedded-close-new-formula} to different strings
depending on the major mode of the editing buffer.
-It consists of a list of lists of the form
+It consists of a list of lists of the form
@code{(@var{MAJOR-MODE} @var{OPEN-NEW-FORMULA-STRING}
@var{CLOSE-NEW-FORMULA-STRING})}, and its default value is
@code{nil}.
The default value of @code{calc-embedded-open-mode} is @code{"% "}
and the default value of @code{calc-embedded-close-mode} is
-@code{"\n"}.
+@code{"\n"}.
If you change the value of @code{calc-embedded-close-mode}, it is a good
idea still to end with a newline so that mode annotations will appear on
lines by themselves.
set @code{calc-embedded-open-mode} and
@code{calc-embedded-close-mode} to different strings
expressions depending on the major mode of the editing buffer.
-It consists of a list of lists of the form
+It consists of a list of lists of the form
@code{(@var{MAJOR-MODE} @var{OPEN-MODE-STRING}
@var{CLOSE-MODE-STRING})}, and its default value is
@example
The default value of @code{calc-lu-power-reference} is @code{"mW"}
and the default value of @code{calc-lu-field-reference} is
-@code{"20 uPa"}.
+@code{"20 uPa"}.
@end defvar
@defvar calc-note-threshold
@defvarx calc-selected-face
@defvarx calc-nonselected-face
See @ref{Displaying Selections}.@*
-The variable @code{calc-highlight-selections-with-faces}
+The variable @code{calc-highlight-selections-with-faces}
determines how selected sub-formulas are distinguished.
-If @code{calc-highlight-selections-with-faces} is nil, then
+If @code{calc-highlight-selections-with-faces} is nil, then
a selected sub-formula is distinguished either by changing every
character not part of the sub-formula with a dot or by changing every
-character in the sub-formula with a @samp{#} sign.
+character in the sub-formula with a @samp{#} sign.
If @code{calc-highlight-selections-with-faces} is t,
then a selected sub-formula is distinguished either by displaying the
-non-selected portion of the formula with @code{calc-nonselected-face}
+non-selected portion of the formula with @code{calc-nonselected-face}
or by displaying the selected sub-formula with
@code{calc-nonselected-face}.
@end defvar
of @code{calc-multiplication-has-precedence} is @code{t}.
@end defvar
+@defvar calc-ensure-consistent-units
+When converting units, the variable @code{calc-ensure-consistent-units}
+determines whether or not the target units need to be consistent with the
+original units. If @code{calc-ensure-consistent-units} is @code{nil}, then
+the target units don't need to have the same dimensions as the original units;
+for example, converting @samp{100 ft/s} to @samp{m} will produce @samp{30.48 m/s}.
+If @code{calc-ensure-consistent-units} is non-@code{nil}, then the target units
+need to have the same dimensions as the original units; for example, converting
+@samp{100 ft/s} to @samp{m} will result in an error, since @samp{ft/s} and @samp{m}
+have different dimensions. The default value of @code{calc-ensure-consistent-units}
+is @code{nil}.
+@end defvar
+
@defvar calc-undo-length
The variable @code{calc-undo-length} determines the number of undo
steps that Calc will keep track of when @code{calc-quit} is called.
be preserved. The default value of @code{calc-undo-length} is @expr{100}.
@end defvar
+@defvar calc-gregorian-switch
+See @ref{Date Forms}.@*
+The variable @code{calc-gregorian-switch} is either a list of integers
+@code{(@var{YEAR} @var{MONTH} @var{DAY})} or @code{nil}.
+If it is @code{nil}, then Calc's date forms always represent Gregorian dates.
+Otherwise, @code{calc-gregorian-switch} represents the date that the
+calendar switches from Julian dates to Gregorian dates;
+@code{(@var{YEAR} @var{MONTH} @var{DAY})} will be the first Gregorian
+date. The customization buffer will offer several standard dates to
+choose from, or the user can enter their own date.
+
+The default value of @code{calc-gregorian-switch} is @code{nil}.
+@end defvar
+
@node Reporting Bugs, Summary, Customizing Calc, Top
@appendix Reporting Bugs
@c 7
@item
A prefix argument specifies simplification level and depth.
-1=Default, 2=like @kbd{a s}, 3=like @kbd{a e}.
+1=Basic simplifications, 2=Algebraic simplifications, 3=Extended simplifications
@c 8
@item
@c 17
@item
-A prefix argument specifies a day number (0-6, 0-31, or 0-366).
+A prefix argument specifies a day number (0--6, 0--31, or 0--366).
@c 18
@item
@c 20
@item
-With a prefix argument of 1, take a single
+With a prefix argument of 1, take a single
@texline @var{n}@math{\times2}
-@infoline @mathit{@var{N}x2}
+@infoline @mathit{@var{N}x2}
matrix from the stack instead of two separate data vectors.
@c 21
@c 30
@item
-Editing occurs in a separate buffer. Press @kbd{C-c C-c} (or
+Editing occurs in a separate buffer. Press @kbd{C-c C-c} (or
@key{LFD}, or in some cases @key{RET}) to finish the edit, or kill the
buffer with @kbd{C-x k} to cancel the edit. The @key{LFD} key prevents evaluation
of the result of the edit.
@item
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
+assigns
@texline @math{x \coloneq a-x}.
@infoline @expr{x := a-x}.