@c smallbook
@setfilename ../../info/calc
@c [title]
-@settitle GNU Emacs Calc 2.1 Manual
+@settitle GNU Emacs Calc Manual
@setchapternewpage odd
@comment %**end of header (This is for running Texinfo on a region.)
@alias expr=math
@alias tfn=code
@alias mathit=expr
+@alias summarykey=key
@macro cpi{}
@math{@pi{}}
@end macro
@alias expr=samp
@alias tfn=t
@alias mathit=i
+@macro summarykey{ky}
+\ky\
+@end macro
@macro cpi{}
@expr{pi}
@end macro
@end iftex
@copying
+@ifinfo
This file documents Calc, the GNU Emacs calculator.
+@end ifinfo
+@ifnotinfo
+This file documents Calc, the GNU Emacs calculator, included with GNU Emacs 23.1.
+@end ifnotinfo
Copyright @copyright{} 1990, 1991, 2001, 2002, 2003, 2004,
-2005, 2006, 2007 Free Software Foundation, Inc.
+2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
+under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being just ``GNU GENERAL PUBLIC LICENSE'', with the
Front-Cover texts being ``A GNU Manual,'' and with the Back-Cover
Texts as in (a) below. A copy of the license is included in the section
entitled ``GNU Free Documentation License.''
-(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
-this GNU Manual, like GNU software. Copies published by the Free
-Software Foundation raise funds for GNU development.''
+(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.''
@end quotation
@end copying
@sp 6
@center @titlefont{Calc Manual}
@sp 4
-@center GNU Emacs Calc Version 2.1
+@center GNU Emacs Calc
@c [volume]
@sp 5
@center Dave Gillespie
@page
@vskip 0pt plus 1filll
-Copyright @copyright{} 1990, 1991, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007 Free Software Foundation, Inc.
@insertcopying
@end titlepage
longer Info tutorial.)
@end ifinfo
+@insertcopying
+
@menu
* Getting Started:: General description and overview.
@ifinfo
@noindent
This document serves as a complete description of the GNU Emacs
-Calculator. It works both as an introduction for novices, and as
+Calculator. It works both as an introduction for novices and as
a reference for experienced users. While it helps to have some
experience with GNU Emacs in order to get the most out of Calc,
this manual ought to be readable even if you don't know or use Emacs
regularly.
-The 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 (chapter 2),
and the Calc reference manual (the remaining chapters and appendices).
@c [when-split]
Index to find the parts of the manual that discuss the things you
need to know.
-@cindex Marginal notes
+@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.
-@texline Each
-@infoline In the printed manual, each
-paragraph that is referenced in the Key or Function Index is marked
-in the margin with its index entry.
+@c @texline Each
+@c @infoline In the printed manual, each
+@c paragraph that is referenced in the Key or Function Index is marked
+@c in the margin with its index entry.
@c [fix-ref Help Commands]
-You can access this manual on-line at any time within Calc by
-pressing the @kbd{h i} key sequence. Outside of the Calc window,
-you can press @kbd{C-x * i} to read the manual on-line. Also, you
-can jump directly to the Tutorial by pressing @kbd{h t} or @kbd{C-x * t},
-or to the Summary by pressing @kbd{h s} or @kbd{C-x * s}. Within Calc,
-you can also go to the part of the manual describing any Calc key,
-function, or variable using @w{@kbd{h k}}, @kbd{h f}, or @kbd{h v},
-respectively. @xref{Help Commands}.
+You can access this manual on-line at any time within Calc by pressing
+the @kbd{h i} key sequence. Outside of the Calc window, you can press
+@kbd{C-x * i} to read the manual on-line. From within Calc the command
+@kbd{h t} will jump directly to the Tutorial; from outside of Calc the
+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
+@w{@kbd{h k}}, @kbd{h f}, or @kbd{h v}, respectively. @xref{Help Commands}.
@ifnottex
The Calc manual can be printed, but because the manual is so large, you
or equations involving variables. Type @kbd{@w{' [x + y} = a, x y = 1] @key{RET}}
to enter a pair of equations involving three variables.
(Note the leading apostrophe in this example; also, note that the space
-between @samp{x y} is required.) Type @w{@kbd{a S x,y @key{RET}}} to solve
+in @samp{x y} is required.) Type @w{@kbd{a S x,y @key{RET}}} to solve
these equations for the variables @expr{x} and @expr{y}.
@noindent
@noindent
Type @kbd{7.5}, then @kbd{s l a @key{RET}} to let @expr{a = 7.5} in these formulas.
-(That's a letter @kbd{l}, not a numeral @kbd{1}.)
+(That's the letter @kbd{l}, not the numeral @kbd{1}.)
@ifnotinfo
@strong{Help functions.} You can read about any command in the on-line
| * 8
| ->-5
|
---%%-Calc: 12 Deg (Calculator)----All----- --%%-Emacs: *Calc Trail*
+--%*-Calc: 12 Deg (Calculator)----All----- --%*- *Calc Trail*
@end group
@end smallexample
Finally, @kbd{C-x * o} (@code{calc-other-window}) is like @kbd{C-x * c}
except that the Calc window is not selected. The buffer you were
-editing before remains selected instead. @kbd{C-x * o} is a handy
-way to switch out of Calc momentarily to edit your file; type
-@kbd{C-x * c} to switch back into Calc when you are done.
+editing before remains selected instead. If you are in a Calc window,
+then @kbd{C-x * o} will switch you out of it, being careful not to
+switch you to the Calc Trail window. So @kbd{C-x * o} is a handy
+way to switch out of Calc momentarily to edit your file; you can then
+type @kbd{C-x * c} to switch back into Calc when you are done.
@node Quick Mode Overview, Keypad Mode Overview, The Standard Interface, Using Calc
@subsection Quick Mode (Overview)
|2: 17.3
|1: -5
| .
-|--%%-Calc: 12 Deg (Calcul
-|----+-----Calc 2.1------+----1
+|--%*-Calc: 12 Deg (Calcul
+|----+----+--Calc---+----+----1
|FLR |CEIL|RND |TRNC|CLN2|FLT |
|----+----+----+----+----+----|
| LN |EXP | |ABS |IDIV|MOD |
and you wish to have Calc compute and format the derivative for
you and store this derivative in the buffer automatically. To
do this with Embedded mode, first copy the formula down to where
-you want the result to be:
+you want the result to be, leaving a blank line before and after the
+formula:
@smallexample
@group
@end smallexample
Now, move the cursor onto this new formula and press @kbd{C-x * e}.
-Calc will read the formula (using the surrounding blank lines to
-tell how much text to read), then push this formula (invisibly)
-onto the Calc stack. The cursor will stay on the formula in the
-editing buffer, but the buffer's mode line will change to look
-like the Calc mode line (with mode indicators like @samp{12 Deg}
-and so on). Even though you are still in your editing buffer,
-the keyboard now acts like the Calc keyboard, and any new result
-you get is copied from the stack back into the buffer. To take
-the derivative, you would type @kbd{a d x @key{RET}}.
+Calc will read the formula (using the surrounding blank lines to tell
+how much text to read), then push this formula (invisibly) onto the Calc
+stack. The cursor will stay on the formula in the editing buffer, but
+the line with the formula will now appear as it would on the Calc stack
+(in this case, it will be left-aligned) and the buffer's mode line will
+change to look like the Calc mode line (with mode indicators like
+@samp{12 Deg} and so on). Even though you are still in your editing
+buffer, the keyboard now acts like the Calc keyboard, and any new result
+you get is copied from the stack back into the buffer. To take the
+derivative, you would type @kbd{a d x @key{RET}}.
@smallexample
@group
@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)}.)
+
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.
and keyboard will revert to the way they were before.
The related command @kbd{C-x * w} operates on a single word, which
-generally means a single number, inside text. It uses any
-non-numeric characters rather than blank lines to delimit the
-formula it reads. Here's an example of its use:
+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:
@smallexample
A slope of one-third corresponds to an angle of 1 degrees.
You can press @kbd{?} at any time for a brief summary of Info commands.
-Press @kbd{1} now to enter the first section of the Tutorial.
+Press the number @kbd{1} now to enter the first section of the Tutorial.
@menu
* Tutorial::
the Embedded mode interface.
The easiest way to read this tutorial on-line is to have two windows on
-your Emacs screen, one with Calc and one with the Info system. (If you
-have a printed copy of the manual you can use that instead.) Press
-@kbd{C-x * c} to turn Calc on or to switch into the Calc window, and
-press @kbd{C-x * i} to start the Info system or to switch into its window.
+your Emacs screen, one with Calc and one with the Info system. Press
+@kbd{C-x * t} to set this up; the on-line tutorial will be opened in the
+current window and Calc will be started in another window. From the
+Info window, the command @kbd{C-x * c} can be used to switch to the Calc
+window and @kbd{C-x * o} can be used to switch back to the Info window.
+(If you have a printed copy of the manual you can use that instead; in
+that case you only need to press @kbd{C-x * c} to start Calc.)
This tutorial is designed to be done in sequence. But the rest of this
manual does not assume you have gone through the tutorial. The tutorial
non-RPN calculators work. In Algebraic mode, you enter formulas
in traditional @expr{2+3} notation.
-@strong{Warning:} Note that @samp{/} has lower precedence than
-@samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}. See
-below for details.
+@strong{Notice:} Calc gives @samp{/} lower precedence than @samp{*}, so
+that @samp{a/b*c} is interpreted as @samp{a/(b*c)}; this is not
+standard across all computer languages. See below for details.
You don't really need any special ``mode'' to enter algebraic formulas.
You can enter a formula at any time by pressing the apostrophe (@kbd{'})
Notice the @samp{12} on the Calc window's mode line:
@smallexample
---%%-Calc: 12 Deg (Calculator)----All------
+--%*-Calc: 12 Deg (Calculator)----All------
@end smallexample
@noindent
@end smallexample
@noindent
-You can verify these prime factors by using @kbd{v u} to ``unpack''
-this vector into 8 separate stack entries, then @kbd{M-8 *} to
-multiply them back together. The result is the original number,
-30045015.
+You can verify these prime factors by using @kbd{V R *} to multiply
+together the elements of this vector. The result is the original
+number, 30045015.
@cindex Hash tables
Suppose a program you are writing needs a hash table with at least
for you. For example, the following key sequences are equivalent:
@kbd{S}, @kbd{M-x calc-sin @key{RET}}, @kbd{x sin @key{RET}}.
+Although Calc is designed to be used from the keyboard, some of
+Calc's more common commands are available from a menu. In the menu, the
+arguments to the functions are given by referring to their stack level
+numbers.
+
@cindex Extensions module
@cindex @file{calc-ext} module
The Calculator exists in many parts. When you type @kbd{C-x * c}, the
negative prefix argument, @kbd{C-x * 0} preserves the contents of the
stack but resets everything else to its default state.
-@pindex calc-version
-The @kbd{M-x calc-version} command displays the current version number
-of Calc and the name of the person who installed it on your system.
-(This information is also present in the @samp{*Calc Trail*} buffer,
-and in the output of the @kbd{h h} command.)
-
@node Help Commands, Stack Basics, Basic Commands, Introduction
@section Help Commands
@pindex calc-algebraic-entry
@cindex Algebraic notation
@cindex Formulas, entering
-Calculations can also be entered in algebraic form. This is accomplished
-by typing the apostrophe key, ', followed by the expression in
-standard format:
+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:
@example
' 2+3*4 @key{RET}.
clear previous results off the stack.
You can press the apostrophe key during normal numeric entry to switch
-the half-entered number into Algebraic entry mode. One reason to do this
-would be to use the full Emacs cursor motion and editing keys, which are
-available during algebraic entry but not during numeric entry.
+the half-entered number into Algebraic entry mode. One reason to do
+this would be to fix a typo, as the full Emacs cursor motion and editing
+keys are available during algebraic entry but not during numeric entry.
In the same vein, during either numeric or algebraic entry you can
press @kbd{`} (backquote) to switch to @code{calc-edit} mode, where
@pindex calc-edit
@pindex calc-edit-finish
@cindex Editing the stack with Emacs
-The backquote, @kbd{`} (@code{calc-edit}) command creates a temporary
-buffer (@samp{*Calc Edit*}) for editing the top-of-stack value using
-regular Emacs commands. With a numeric prefix argument, it edits the
-specified number of stack entries at once. (An argument of zero edits
-the entire stack; a negative argument edits one specific stack entry.)
+The @kbd{`} (@code{calc-edit}) command creates a temporary buffer
+(@samp{*Calc Edit*}) for editing the top-of-stack value using regular
+Emacs commands. Note that @kbd{`} is a backquote, not a quote. With a
+numeric prefix argument, it edits the specified number of stack entries
+at once. (An argument of zero edits the entire stack; a negative
+argument edits one specific stack entry.)
When you are done editing, press @kbd{C-c C-c} to finish and return
to Calc. The @key{RET} and @key{LFD} keys also work to finish most
* C FORTRAN Pascal::
* TeX and LaTeX Language Modes::
* Eqn Language Mode::
+* Yacas Language Mode::
+* Maxima Language Mode::
+* Giac Language Mode::
* Mathematica Language Mode::
* Maple Language Mode::
* Compositions::
parentheses for both function calls and array subscripts, Calc displays
both in the same way; @samp{a(i)} is interpreted as a function call
upon reading, and subscripts must be entered as @samp{subscr(a, i)}.
-Also, if the variable @code{a} has been declared to have type
-@code{vector} or @code{matrix} then @samp{a(i)} will be parsed as a
-subscript. (@xref{Declarations}.) Usually it doesn't matter, though;
-if you enter the subscript expression @samp{a(i)} and Calc interprets
-it as a function call, you'll never know the difference unless you
-switch to another language mode or replace @code{a} with an actual
-vector (or unless @code{a} happens to be the name of a built-in
+If the variable @code{a} has been declared to have type
+@code{vector} or @code{matrix}, however, then @samp{a(i)} will be
+parsed as a subscript. (@xref{Declarations}.) Usually it doesn't
+matter, though; if you enter the subscript expression @samp{a(i)} and
+Calc interprets it as a function call, you'll never know the difference
+unless you switch to another language mode or replace @code{a} with an
+actual vector (or unless @code{a} happens to be the name of a built-in
function!).
Underscores are allowed in variable and function names in all of these
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
+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.
Math formulas are often enclosed by @samp{$ $} signs in @TeX{} and
La@TeX{}; these should be omitted when interfacing with Calc. To Calc,
a built-in Calc function. The following table shows the accents
in Calc, @TeX{}, La@TeX{} and @dfn{eqn} (described in the next section):
+@ignore
@iftex
@begingroup
@let@calcindexershow=@calcindexernoshow @c Suppress marginal notes
@let@calcindexersh=@calcindexernoshow
@end iftex
-@ignore
@starindex
@end ignore
@tindex acute
@starindex
@end ignore
@tindex VEC
+@ignore
@iftex
@endgroup
@end iftex
+@end ignore
@example
Calc TeX LaTeX eqn
---- --- ----- ---
@sp 2
@end iftex
-@node Eqn Language Mode, Mathematica Language Mode, TeX and LaTeX Language Modes, Language Modes
+@node Eqn Language Mode, Yacas Language Mode, TeX and LaTeX Language Modes, Language Modes
@subsection Eqn Language Mode
@noindent
for @code{ccol} during input, and are generated instead of @code{ccol}
if the matrix justification mode so specifies.
-@node Mathematica Language Mode, Maple Language Mode, Eqn Language Mode, Language Modes
+@node Yacas Language Mode, Maxima Language Mode, Eqn Language Mode, Language Modes
+@subsection Yacas Language Mode
+
+@noindent
+@kindex d Y
+@pindex calc-yacas-language
+@cindex Yacas language
+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
+@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}.
+The standard special constants are written @code{Pi}, @code{E},
+@code{I}, @code{GoldenRatio} and @code{Gamma}. @code{Infinity}
+represents both @code{inf} and @code{uinf}, and @code{Undefined}
+represents @code{nan}.
+
+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
+@w{@samp{D(x) Exp(x)*Sin(x)}}.
+
+Other notable differences between Yacas and standard Calc expressions
+are that vectors and matrices use curly braces in Yacas, and subscripts
+use square brackets. If, for example, @samp{A} represents the list
+@samp{@{a,2,c,4@}}, then @samp{A[3]} would equal @samp{c}.
+
+
+@node Maxima Language Mode, Giac Language Mode, Yacas Language Mode, Language Modes
+@subsection Maxima Language Mode
+
+@noindent
+@kindex d X
+@pindex calc-maxima-language
+@cindex Maxima language
+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
+@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
+the same as in Calc, but @code{infinity} represents Calc's @code{uinf}.
+
+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}.
+
+Maxima uses square brackets for lists and vectors, and matrices are
+written as calls to the function @code{matrix}, given the row vectors of
+the matrix as arguments. Square brackets are also used as subscripts.
+
+@node Giac Language Mode, Mathematica Language Mode, Maxima Language Mode, Language Modes
+@subsection Giac Language Mode
+
+@noindent
+@kindex d A
+@pindex calc-giac-language
+@cindex Giac language
+The @kbd{d A} (@code{calc-giac-language}) command selects the
+conventions of Giac, another free computer algebra system. The function
+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}.
+
+Underscores are allowed in function and variable names in Giac mode.
+Brackets are used for subscripts. In Giac, indexing of lists begins at
+0, instead of 1 as in Calc. So if @samp{A} represents the list
+@samp{[a,2,c,4]}, then @samp{A[2]} would equal @samp{c}. In general,
+@samp{A[n]} in Giac mode corresponds to @samp{A_(n+1)} in Normal mode.
+
+The Giac interval notation @samp{2 .. 3} has no surrounding brackets;
+Calc reads @samp{2 .. 3} as the closed interval @samp{[2 .. 3]} and
+writes any kind of interval as @samp{2 .. 3}. This means you cannot see
+the difference between an open and a closed interval while in Giac mode.
+
+@node Mathematica Language Mode, Maple Language Mode, Giac Language Mode, Language Modes
@subsection Mathematica Language Mode
@noindent
to the function @code{matrix}, given a list of lists as the argument,
and can be read in this form or with all-capitals @code{MATRIX}.
-The Maple interval notation @samp{2 .. 3} has no surrounding brackets;
-Calc reads @samp{2 .. 3} as the closed interval @samp{[2 .. 3]}, and
-writes any kind of interval as @samp{2 .. 3}. This means you cannot
-see the difference between an open and a closed interval while in
-Maple display mode.
+The Maple interval notation @samp{2 .. 3} is like Giac's interval
+notation, and is handled the same by Calc.
Maple writes complex numbers as @samp{3 + 4*I}. Its special constants
are @code{Pi}, @code{E}, @code{I}, and @code{infinity} (all three of
The basic mode line format is:
@example
---%%-Calc: 12 Deg @var{other modes} (Calculator)
+--%*-Calc: 12 Deg @var{other modes} (Calculator)
@end example
-The @samp{%%} is the Emacs symbol for ``read-only''; it shows that
+The @samp{%*} indicates that the buffer is ``read-only''; it shows that
regular Emacs commands are not allowed to edit the stack buffer
as if it were text.
diagrams), consult Steele's book.
Note that the branch cuts for @code{arctan} and @code{arctanh} were
-changed between the first and second editions of Steele. Versions of
-Calc starting with 2.00 follow the second edition.
+changed between the first and second editions of Steele. Recent
+versions of Calc follow the second edition.
The new branch cuts exactly match those of the HP-28/48 calculators.
They also match those of Mathematica 1.2, except that Mathematica's
@kindex v n
@pindex calc-rnorm
@tindex rnorm
-The @kbd{v n} (@code{calc-rnorm}) [@code{rnorm}] command computes
-the row norm, or infinity-norm, of a vector or matrix. For a plain
-vector, this is the maximum of the absolute values of the elements.
-For a matrix, this is the maximum of the row-absolute-value-sums,
-i.e., of the sums of the absolute values of the elements along the
-various rows.
+The @kbd{v n} (@code{calc-rnorm}) [@code{rnorm}] command computes the
+infinity-norm of a vector, or the row norm of a matrix. For a plain
+vector, this is the maximum of the absolute values of the elements. For
+a matrix, this is the maximum of the row-absolute-value-sums, i.e., of
+the sums of the absolute values of the elements along the various rows.
@kindex V N
@pindex calc-cnorm
@tindex cnorm
The @kbd{V N} (@code{calc-cnorm}) [@code{cnorm}] command computes
-the column norm, or one-norm, of a vector or matrix. For a plain
+the one-norm of a vector, or column norm of a matrix. For a plain
vector, this is the sum of the absolute values of the elements.
For a matrix, this is the maximum of the column-absolute-value-sums.
General @expr{k}-norms for @expr{k} other than one or infinity are
-not provided.
+not provided. However, the 2-norm (or Frobenius norm) is provided for
+vectors by the @kbd{A} (@code{calc-abs}) command.
@kindex V C
@pindex calc-cross
trace of a square matrix. This is defined as the sum of the diagonal
elements of the matrix.
+@kindex V K
+@pindex calc-kron
+@tindex kron
+The @kbd{V K} (@code{calc-kron}) [@code{kron}] command computes
+the Kronecker product of two matrices.
+
@node Set Operations, Statistical Operations, Vector and Matrix Arithmetic, Matrix Functions
@section Set Operations using Vectors
selected quotient or equation by that formula. It simplifies each
side with @kbd{a s} (@code{calc-simplify}) before re-forming the
quotient or equation. You can suppress this simplification by
-providing any numeric prefix argument. There is also a @kbd{j /}
+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
dividing instead of multiplying by the factor you enter.
-As a special feature, if the numerator of the quotient is 1, then
-the denominator is expanded at the top level using the distributive
-law (i.e., using the @kbd{C-u -1 a x} command). Suppose the
-formula on the stack is @samp{1 / (sqrt(a) + 1)}, and you wish
-to eliminate the square root in the denominator by multiplying both
-sides by @samp{sqrt(a) - 1}. Calc's default simplifications would
-change the result @samp{(sqrt(a) - 1) / (sqrt(a) - 1) (sqrt(a) + 1)}
-right back to the original form by cancellation; Calc expands the
-denominator to @samp{sqrt(a) (sqrt(a) - 1) + sqrt(a) - 1} to prevent
-this. (You would now want to use an @kbd{a x} command to expand
-the rest of the way, whereupon the denominator would cancel out to
-the desired form, @samp{a - 1}.) When the numerator is not 1, this
-initial expansion is not necessary because Calc's default
-simplifications will not notice the potential cancellation.
+If the selection is a quotient with numerator 1, then Calc's default
+simplifications would normally cancel the new factors. To prevent
+this, when the @kbd{j *} command is used on a selection whose numerator is
+1 or -1, the denominator is expanded at the top level using the
+distributive law (as if using the @kbd{C-u 1 a x} command). Suppose the
+formula on the stack is @samp{1 / (a + 1)} and you wish to multiplying the
+top and bottom by @samp{a - 1}. Calc's default simplifications would
+normally change the result @samp{(a - 1) /(a + 1) (a - 1)} back
+to the original form by cancellation; when @kbd{j *} is used, Calc
+expands the denominator to @samp{a (a - 1) + a - 1} to prevent this.
+
+If you wish the @kbd{j *} command to completely expand the denominator
+of a quotient you can call it with a zero prefix: @kbd{C-u 0 j *}. For
+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
+@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
+generally, if @kbd{j *} is called with an argument of a positive
+integer @var{n}, then the denominator of the expression will be
+expanded @var{n} times (as if with the @kbd{C-u @var{n} a x} command).
If the selection is an inequality, @kbd{j *} and @kbd{j /} will
accept any factor, but will warn unless they can prove the factor
16.5 feet. The unit conversion and simplification commands will now
treat @code{rod} just like any other unit of length. You will also be
prompted for an optional English description of the unit, which will
-appear in the Units Table.
+appear in the Units Table. If you wish the definition of this unit to
+be displayed in a special way in the Units Table buffer (such as with an
+asterisk to indicate an approximate value), then you can call this
+command with an argument, @kbd{C-u u d}; you will then also be prompted
+for a string that will be used to display the definition.
@kindex u u
@pindex calc-undefine-unit
@kindex r 0-9
The @kbd{r} prefix may be followed by a digit, so that @kbd{r 9} is
-equivalent to @kbd{s r 9}. (The @kbd{r} prefix is otherwise unused
-in the current version of Calc.)
+equivalent to @kbd{s r 9}.
@node Operations on Variables, Let Command, Recalling Variables, Store and Recall
@section Other Operations on Variables
@menu
* Killing From Stack::
* Yanking Into Stack::
+* Saving Into Registers::
+* Inserting From Registers::
* Grabbing From Buffers::
* Yanking Into Buffers::
* X Cut and Paste::
@pindex calc-kill-region
@kindex M-w
@pindex calc-copy-region-as-kill
+@kindex M-C-w
@cindex Kill ring
-@dfn{Kill} commands are Emacs commands that insert text into the
-``kill ring,'' from which it can later be ``yanked'' by a @kbd{C-y}
-command. Three common kill commands in normal Emacs are @kbd{C-k}, which
-kills one line, @kbd{C-w}, which kills the region between mark and point,
-and @kbd{M-w}, which puts the region into the kill ring without actually
-deleting it. All of these commands work in the Calculator, too. Also,
-@kbd{M-k} has been provided to complete the set; it puts the current line
-into the kill ring without deleting anything.
+@dfn{Kill} commands are Emacs commands that insert text into the ``kill
+ring,'' from which it can later be ``yanked'' by a @kbd{C-y} command.
+Three common kill commands in normal Emacs are @kbd{C-k}, which kills
+one line, @kbd{C-w}, which kills the region between mark and point, and
+@kbd{M-w}, which puts the region into the kill ring without actually
+deleting it. All of these commands work in the Calculator, too,
+although in the Calculator they operate on whole stack entries, so they
+``round up'' the specified region to encompass full lines. (To copy
+only parts of lines, the @kbd{M-C-w} command in the Calculator will copy
+the region to the kill ring without any ``rounding up'', just like the
+@kbd{M-w} command in normal Emacs.) Also, @kbd{M-k} has been provided
+to complete the set; it puts the current line into the kill ring without
+deleting anything.
The kill commands are unusual in that they pay attention to the location
-of the cursor in the Calculator buffer. If the cursor is on or below the
-bottom line, the kill commands operate on the top of the stack. Otherwise,
-they operate on whatever stack element the cursor is on. Calc's kill
-commands always operate on whole stack entries. (They act the same as their
-standard Emacs cousins except they ``round up'' the specified region to
-encompass full lines.) The text is copied into the kill ring exactly as
-it appears on the screen, including line numbers if they are enabled.
+of the cursor in the Calculator buffer. If the cursor is on or below
+the bottom line, the kill commands operate on the top of the stack.
+Otherwise, they operate on whatever stack element the cursor is on. The
+text is copied into the kill ring exactly as it appears on the screen,
+including line numbers if they are enabled.
A numeric prefix argument to @kbd{C-k} or @kbd{M-k} affects the number
of lines killed. A positive argument kills the current line and @expr{n-1}
@kbd{C-k} with a prefix argument of 1 copies the number with its trailing
newline.
-@node Yanking Into Stack, Grabbing From Buffers, Killing From Stack, Kill and Yank
+@node Yanking Into Stack, Saving Into Registers, Killing From Stack, Kill and Yank
@section Yanking into the Stack
@noindent
show all objects to their full precision, this feature normally makes no
difference.)
-@node Grabbing From Buffers, Yanking Into Buffers, Yanking Into Stack, Kill and Yank
+@node Saving Into Registers, Inserting From Registers, Yanking Into Stack, Kill and Yank
+@section Saving into Registers
+
+@noindent
+@kindex r s
+@pindex calc-copy-to-register
+@pindex calc-prepend-to-register
+@pindex calc-append-to-register
+@cindex Registers
+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
+entries.
+
+Registers in Calc are places to store stack entries for later use;
+each register is indexed by a single character. To store the current
+region (rounded up, of course, to include full stack entries) into a
+register, use the command @kbd{r s} (@code{calc-copy-to-register}).
+You will then be prompted for a register to use, the next character
+you type will be the index for the register. To store the region in
+register @var{r}, the full command will be @kbd{r s @var{r}}. With an
+argument, @kbd{C-u r s @var{r}}, the region being copied to the
+register will be deleted from the Calc buffer.
+
+It is possible to add additional stack entries to a register. The
+command @kbd{M-x calc-append-to-register} will prompt for a register,
+then add the stack entries in the region to the end of the register
+contents. The command @kbd{M-x calc-prepend-to-register} will
+similarly prompt for a register and add the stack entries in the
+region to the beginning of the register contents. Both commands take
+@kbd{C-u} arguments, which will cause the region to be deleted after being
+added to the register.
+
+@node Inserting From Registers, Grabbing From Buffers, Saving Into Registers, Kill and Yank
+@section Inserting from Registers
+@noindent
+@kindex r i
+@pindex calc-insert-register
+The command @kbd{r i} (@code{calc-insert-register}) will prompt for a
+register, then insert the contents of that register into the
+Calculator. If the contents of the register were placed there from
+within Calc, then the full internal structure of the contents will be
+inserted into the Calculator, otherwise whatever text is in the
+register is reparsed and then inserted into the Calculator.
+
+@node Grabbing From Buffers, Yanking Into Buffers, Inserting From Registers, Kill and Yank
@section Grabbing from Other Buffers
@noindent
@smallexample
@group
-|----+-----Calc 2.1------+----1
+|----+----+--Calc---+----+----1
|FLR |CEIL|RND |TRNC|CLN2|FLT |
|----+----+----+----+----+----|
| LN |EXP | |ABS |IDIV|MOD |
of describing a blank line that is more appropriate for this
case).
-@vindex calc-embedded-open-word
-@vindex calc-embedded-close-word
-The @code{calc-embedded-open-word} and @code{calc-embedded-close-word}
-variables are similar expressions used when you type @kbd{C-x * w}
-instead of @kbd{C-x * e} to enable Embedded mode.
+@vindex calc-embedded-word-regexp
+The @code{calc-embedded-word-regexp} variable holds a regular expression
+used to define an expression to look for (a ``word'') when you type
+@kbd{C-x * w} to enable Embedded mode.
@vindex calc-embedded-open-plain
The @code{calc-embedded-open-plain} variable is a string which
@defvarx calc-embedded-open-close-formula-alist
See @ref{Customizing Embedded Mode}.@*
The variables @code{calc-embedded-open-formula} and
-@code{calc-embedded-open-formula} control the region that Calc will
+@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;
Calc normally scans backward and forward in the buffer for the
@code{nil}.
@end defvar
-@defvar calc-embedded-open-word
-@defvarx calc-embedded-close-word
-@defvarx calc-embedded-open-close-word-alist
+@defvar calc-embedded-word-regexp
+@defvarx calc-embedded-word-regexp-alist
See @ref{Customizing Embedded Mode}.@*
-The variables @code{calc-embedded-open-word} and
-@code{calc-embedded-close-word} control the region that Calc will
-activate when Embedded mode is entered with @kbd{C-x * w}. They are
-regular expressions.
-
-The default values of @code{calc-embedded-open-word} and
-@code{calc-embedded-close-word} are @code{"^\\|[^-+0-9.eE]"} and
-@code{"$\\|[^-+0-9.eE]"} respectively.
-
-The variable @code{calc-embedded-open-close-word-alist} is used to
-set @code{calc-embedded-open-word} and
-@code{calc-embedded-close-word} to different regular
-expressions depending on the major mode of the editing buffer.
+The variable @code{calc-embedded-word-regexp} determines the expression
+that Calc will activate when Embedded mode is entered with @kbd{C-x *
+w}. It is a regular expressions.
+
+The default value of @code{calc-embedded-word-regexp} is
+@code{"[-+]?[0-9]+\\(\\.[0-9]+\\)?\\([eE][-+]?[0-9]+\\)?"}.
+
+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
-@code{(@var{MAJOR-MODE} @var{OPEN-WORD-REGEXP}
-@var{CLOSE-WORD-REGEXP})}, and its default value is
+@code{(@var{MAJOR-MODE} @var{WORD-REGEXP})}, and its default value is
@code{nil}.
@end defvar
@appendix Calc Summary
@noindent
-This section includes a complete list of Calc 2.1 keystroke commands.
+This section includes a complete list of Calc keystroke commands.
Each line lists the stack entries used by the command (top-of-stack
last), the keystrokes themselves, the prompts asked by the command,
and the result of the command (also with top-of-stack last).
@r{ a@: M-% @: @: @:percent@:(a) a%}
@c
-@r{ ... a@: @key{RET} @: @: 1 @:@:... a a}
-@r{ ... a@: @key{SPC} @: @: 1 @:@:... a a}
-@r{... a b@: @key{TAB} @: @: 3 @:@:... b a}
-@r{. a b c@: M-@key{TAB} @: @: 3 @:@:... b c a}
-@r{... a b@: @key{LFD} @: @: 1 @:@:... a b a}
-@r{ ... a@: @key{DEL} @: @: 1 @:@:...}
-@r{... a b@: M-@key{DEL} @: @: 1 @:@:... b}
-@r{ @: M-@key{RET} @: @: 4 @:calc-last-args@:}
+@r{ ... a@: @summarykey{RET} @: @: 1 @:@:... a a}
+@r{ ... a@: @summarykey{SPC} @: @: 1 @:@:... a a}
+@r{... a b@: @summarykey{TAB} @: @: 3 @:@:... b a}
+@r{. a b c@: M-@summarykey{TAB} @: @: 3 @:@:... b c a}
+@r{... a b@: @summarykey{LFD} @: @: 1 @:@:... a b a}
+@r{ ... a@: @summarykey{DEL} @: @: 1 @:@:...}
+@r{... a b@: M-@summarykey{DEL} @: @: 1 @:@:... b}
+@r{ @: M-@summarykey{RET} @: @: 4 @:calc-last-args@:}
@r{ a@: ` @:editing @: 1,30 @:calc-edit@:}
@c
@r{ @: d [ @: @: 4 @:calc-truncate-up@:}
@r{ @: d ] @: @: 4 @:calc-truncate-down@:}
@r{ @: d " @: @: 12,50 @:calc-display-strings@:}
-@r{ @: d @key{SPC} @: @: @:calc-refresh@:}
-@r{ @: d @key{RET} @: @: 1 @:calc-refresh-top@:}
+@r{ @: d @summarykey{SPC} @: @: @:calc-refresh@:}
+@r{ @: d @summarykey{RET} @: @: 1 @:calc-refresh-top@:}
@c
@r{ @: d 0 @: @: 50 @:calc-decimal-radix@:}
@c
@r{ @: j 1-9 @: @: @:calc-select-part@:}
-@r{ @: j @key{RET} @: @: 27 @:calc-copy-selection@:}
-@r{ @: j @key{DEL} @: @: 27 @:calc-del-selection@:}
+@r{ @: j @summarykey{RET} @: @: 27 @:calc-copy-selection@:}
+@r{ @: j @summarykey{DEL} @: @: 27 @:calc-del-selection@:}
@r{ @: j ' @:formula @: 27 @:calc-enter-selection@:}
@r{ @: j ` @:editing @: 27,30 @:calc-edit-selection@:}
@r{ @: j " @: @: 7,27 @:calc-sel-expand-formula@:}
@r{ @: m S @: @: 12 @:calc-shift-prefix@:}
@r{ @: m U @: @: 12 @:calc-units-simplify-mode@:}
+@c
+@r{ @: r s @:register @: 27 @:calc-copy-to-register@:}
+@r{ @: r i @:register @: @:calc-insert-register@:}
+
@c
@r{ @: s c @:var1, var2 @: 29 @:calc-copy-variable@:}
@r{ @: s d @:var, decl @: @:calc-declare-variable@:}
@r{ v w@: H V H @:n @: 31 @:histogram@:(v,w,n)}
@r{ v1 v2@: V I @:mop aop @: 22 @:inner@:(mop,aop,v1,v2)}
@r{ m@: V J @: @: 1 @:ctrn@:(m)}
+@r{ m1 m2@: V K @: @: @:kron@:(m1,m2)}
@r{ m@: V L @: @: 1 @:lud@:(m)}
@r{ v@: V M @:op @: 22,23 @:map@:(op,v)}
@r{ v@: V N @: @: 1 @:cnorm@:(v)}