@c smallbook
@setfilename ../info/calc
@c [title]
-@settitle GNU Emacs Calc 2.02g Manual
+@settitle GNU Emacs Calc 2.1 Manual
@setchapternewpage odd
@comment %**end of header (This is for running Texinfo on a region.)
+@c The following macros are used for conditional output for single lines.
+@c @texline foo
+@c `foo' will appear only in TeX output
+@c @infoline foo
+@c `foo' will appear only in non-TeX output
+
+@c @expr{expr} will typeset an expression;
+@c $x$ in TeX, @samp{x} otherwise.
+
+@iftex
+@macro texline
+@end macro
+@alias infoline=comment
+@alias expr=math
+@alias tfn=code
+@alias mathit=expr
+@macro cpi{}
+@math{@pi{}}
+@end macro
+@macro cpiover{den}
+@math{@pi/\den\}
+@end macro
+@end iftex
+
+@ifnottex
+@alias texline=comment
+@macro infoline{stuff}
+\stuff\
+@end macro
+@alias expr=samp
+@alias tfn=t
+@alias mathit=i
+@macro cpi{}
+@expr{pi}
+@end macro
+@macro cpiover{den}
+@expr{pi/\den\}
+@end macro
+@end ifnottex
+
+
@tex
-% Some special kludges to make TeX formatting prettier.
-% Because makeinfo.c exists, we can't just define new commands.
-% So instead, we take over little-used existing commands.
-%
% Suggested by Karl Berry <karl@@freefriends.org>
\gdef\!{\mskip-\thinmuskip}
-% Redefine @cite{text} to act like $text$ in regular TeX.
-% Info will typeset this same as @samp{text}.
-\gdef\goodtex{\tex \let\rm\goodrm \let\t\ttfont \turnoffactive}
-\gdef\goodrm{\fam0\tenrm}
-\gdef\cite{\goodtex$\citexxx}
-\gdef\citexxx#1{#1$\Etex}
-\global\let\oldxrefX=\xrefX
-\gdef\xrefX[#1]{\begingroup\let\cite=\dfn\oldxrefX[#1]\endgroup}
-
-% Redefine @c{tex-stuff} \n @whatever{info-stuff}.
-\gdef\c{\futurelet\next\mycxxx}
-\gdef\mycxxx{%
- \ifx\next\bgroup \goodtex\let\next\mycxxy
- \else\ifx\next\mindex \let\next\relax
- \else\ifx\next\kindex \let\next\relax
- \else\ifx\next\starindex \let\next\relax \else \let\next\comment
- \fi\fi\fi\fi \next
-}
-\gdef\mycxxy#1#2{#1\Etex\mycxxz}
-\gdef\mycxxz#1{}
@end tex
@c Fix some other things specifically for this manual.
@copying
This file documents Calc, the GNU Emacs calculator.
-Copyright (C) 1990, 1991, 2001, 2002 Free Software Foundation, Inc.
+Copyright @copyright{} 1990, 1991, 2001, 2002, 2003, 2004,
+2005, 2006 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.1 or
+under the terms of the GNU Free Documentation License, Version 1.2 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
@dircategory Emacs
@direntry
-* Calc: (calc). Advanced desk calculator and mathematical tool.
+* Calc: (calc). Advanced desk calculator and mathematical tool.
@end direntry
@titlepage
@sp 6
@center @titlefont{Calc Manual}
@sp 4
-@center GNU Emacs Calc Version 2.02g
+@center GNU Emacs Calc Version 2.1
@c [volume]
@sp 1
-@center January 2002
+@center March 2005
@sp 5
@center Dave Gillespie
@center daveg@@synaptics.com
@page
@vskip 0pt plus 1filll
-Copyright @copyright{} 1990, 1991, 2001, 2002 Free Software Foundation, Inc.
+Copyright @copyright{} 1990, 1991, 2001, 2002, 2003, 2004,
+ 2005, 2006 Free Software Foundation, Inc.
@insertcopying
@end titlepage
* Store and Recall:: Storing and recalling variables.
* Graphics:: Commands for making graphs of data.
* Kill and Yank:: Moving data into and out of Calc.
+* Keypad Mode:: Operating Calc from a keypad.
* Embedded Mode:: Working with formulas embedded in a file.
* Programming:: Calc as a programmable calculator.
-* Installation:: Installing Calc as a part of GNU Emacs.
+* Customizing Calc:: Customizing Calc.
* Reporting Bugs:: How to report bugs and make suggestions.
* Summary:: Summary of Calc commands and functions.
@node Copying, Getting Started, Top, Top
@unnumbered GNU GENERAL PUBLIC LICENSE
-@center Version 1, February 1989
+@center Version 2, June 1991
+
+@c This file is intended to be included in another file.
@display
-Copyright @copyright{} 1989 Free Software Foundation, Inc.
-675 Mass Ave, Cambridge, MA 02139, USA
+Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@unnumberedsec Preamble
- The license agreements of most software companies try to keep users
-at the mercy of those companies. By contrast, our General Public
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
-software---to make sure the software is free for all its users. The
-General Public License applies to the Free Software Foundation's
-software and to any other program whose authors commit to using it.
-You can use it for your programs, too.
+software---to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
When we speak of free software, we are referring to freedom, not
-price. Specifically, the General Public License is designed to make
-sure that you have the freedom to give away or sell copies of free
-software, that you receive source code or can get it if you want it,
-that you can change the software or use pieces of it in new free
-programs; and that you know you can do these things.
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
- For example, if you distribute copies of a such a program, whether
+ For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
-source code. And you must tell them their rights.
+source code. And you must show them these terms so they know their
+rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
that any problems introduced by others will not reflect on the original
authors' reputations.
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
The precise terms and conditions for copying, distribution and
modification follow.
@iftex
-@unnumberedsec TERMS AND CONDITIONS
+@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@end iftex
@ifinfo
-@center TERMS AND CONDITIONS
+@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@end ifinfo
-@enumerate
+@enumerate 0
@item
-This License Agreement applies to any program or other work which
-contains a notice placed by the copyright holder saying it may be
-distributed under the terms of this General Public License. The
-``Program'', below, refers to any such program or work, and a ``work based
-on the Program'' means either the Program or any work containing the
-Program or a portion of it, either verbatim or with modifications. Each
-licensee is addressed as ``you''.
+This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The ``Program'', below,
+refers to any such program or work, and a ``work based on the Program''
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term ``modification''.) Each licensee is addressed as ``you''.
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
@item
-You may copy and distribute verbatim copies of the Program's source
-code as you receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice and
-disclaimer of warranty; keep intact all the notices that refer to this
-General Public License and to the absence of any warranty; and give any
-other recipients of the Program a copy of this General Public License
-along with the Program. You may charge a fee for the physical act of
-transferring a copy.
+You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
-@item
-You may modify your copy or copies of the Program or any portion of
-it, and copy and distribute such modifications under the terms of Paragraph
-1 above, provided that you also do the following:
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
-@itemize @bullet
@item
-cause the modified files to carry prominent notices stating that
-you changed the files and the date of any change; and
+You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+@enumerate a
@item
-cause the whole of any work that you distribute or publish, that
-in whole or in part contains the Program or any part thereof, either
-with or without modifications, to be licensed at no charge to all
-third parties under the terms of this General Public License (except
-that you may choose to grant warranty protection to some or all
-third parties, at your option).
+You must cause the modified files to carry prominent notices
+stating that you changed the files and the date of any change.
@item
-If the modified program normally reads commands interactively when
-run, you must cause it, when started running for such interactive use
-in the simplest and most usual way, to print or display an
-announcement including an appropriate copyright notice and a notice
-that there is no warranty (or else, saying that you provide a
-warranty) and that users may redistribute the program under these
-conditions, and telling the user how to view a copy of this General
-Public License.
+You must cause any work that you distribute or publish, that in
+whole or in part contains or is derived from the Program or any
+part thereof, to be licensed as a whole at no charge to all third
+parties under the terms of this License.
@item
-You may charge a fee for the physical act of transferring a
-copy, and you may at your option offer warranty protection in
-exchange for a fee.
-@end itemize
+If the modified program normally reads commands interactively
+when run, you must cause it, when started running for such
+interactive use in the most ordinary way, to print or display an
+announcement including an appropriate copyright notice and a
+notice that there is no warranty (or else, saying that you provide
+a warranty) and that users may redistribute the program under
+these conditions, and telling the user how to view a copy of this
+License. (Exception: if the Program itself is interactive but
+does not normally print such an announcement, your work based on
+the Program is not required to print an announcement.)
+@end enumerate
-Mere aggregation of another independent work with the Program (or its
-derivative) on a volume of a storage or distribution medium does not bring
-the other work under the scope of these terms.
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
@item
-You may copy and distribute the Program (or a portion or derivative of
-it, under Paragraph 2) in object code or executable form under the terms of
-Paragraphs 1 and 2 above provided that you also do one of the following:
+You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
-@itemize @bullet
+@enumerate a
@item
-accompany it with the complete corresponding machine-readable
-source code, which must be distributed under the terms of
-Paragraphs 1 and 2 above; or,
+Accompany it with the complete corresponding machine-readable
+source code, which must be distributed under the terms of Sections
+1 and 2 above on a medium customarily used for software interchange; or,
@item
-accompany it with a written offer, valid for at least three
-years, to give any third party free (except for a nominal charge
-for the cost of distribution) a complete machine-readable copy of the
-corresponding source code, to be distributed under the terms of
-Paragraphs 1 and 2 above; or,
+Accompany it with a written offer, valid for at least three
+years, to give any third party, for a charge no more than your
+cost of physically performing source distribution, a complete
+machine-readable copy of the corresponding source code, to be
+distributed under the terms of Sections 1 and 2 above on a medium
+customarily used for software interchange; or,
@item
-accompany it with the information you received as to where the
-corresponding source code may be obtained. (This alternative is
+Accompany it with the information you received as to the offer
+to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
-received the program in object code or executable form alone.)
-@end itemize
+received the program in object code or executable form with such
+an offer, in accord with Subsection b above.)
+@end enumerate
-Source code for a work means the preferred form of the work for making
-modifications to it. For an executable file, complete source code means
-all the source code for all modules it contains; but, as a special
-exception, it need not include source code for modules which are standard
-libraries that accompany the operating system on which the executable
-file runs, or for standard header files or definitions files that
-accompany that operating system.
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
@item
-You may not copy, modify, sublicense, distribute or transfer the
-Program except as expressly provided under this General Public License.
-Any attempt otherwise to copy, modify, sublicense, distribute or transfer
-the Program is void, and will automatically terminate your rights to use
-the Program under this License. However, parties who have received
-copies, or rights to use copies, from you under this General Public
-License will not have their licenses terminated so long as such parties
-remain in full compliance.
+You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
@item
-By copying, distributing or modifying the Program (or any work based
-on the Program) you indicate your acceptance of this license to do so,
-and all its terms and conditions.
+You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
@item
Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the original
-licensor to copy, distribute or modify the Program subject to these
-terms and conditions. You may not impose any further restrictions on the
-recipients' exercise of the rights granted herein.
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+@item
+If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+@item
+If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
@item
The Free Software Foundation may publish revised and/or new versions
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
-specifies a version number of the license which applies to it and ``any
+specifies a version number of this License which applies to it and ``any
later version'', you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
-the license, you may choose any version ever published by the Free Software
+this License, you may choose any version ever published by the Free Software
Foundation.
@item
REPAIR OR CORRECTION.
@item
-IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
-ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
-ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT
-LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES
-SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE
-WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
@end enumerate
+@iftex
+@heading END OF TERMS AND CONDITIONS
+@end iftex
+@ifinfo
+@center END OF TERMS AND CONDITIONS
+@end ifinfo
+
+@page
+@unnumberedsec Appendix: How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the ``copyright'' line and a pointer to where the full notice is found.
+
+@smallexample
+@var{one line to give the program's name and a brief idea of what it does.}
+Copyright (C) @var{yyyy} @var{name of author}
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+@end smallexample
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+@smallexample
+Gnomovision version 69, Copyright (C) @var{yyyy} @var{name of author}
+Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+This is free software, and you are welcome to redistribute it
+under certain conditions; type `show c' for details.
+@end smallexample
+
+The hypothetical commands @samp{show w} and @samp{show c} should show
+the appropriate parts of the General Public License. Of course, the
+commands you use may be called something other than @samp{show w} and
+@samp{show c}; they could even be mouse-clicks or menu items---whatever
+suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a ``copyright disclaimer'' for the program, if
+necessary. Here is a sample; alter the names:
+
+@example
+Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+`Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+@var{signature of Ty Coon}, 1 April 1989
+Ty Coon, President of Vice
+@end example
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
+
@node Getting Started, Tutorial, Copying, Top
@chapter Getting Started
@noindent
* What is Calc::
* About This Manual::
* Notations Used in This Manual::
-* Using Calc::
* Demonstration of Calc::
+* Using Calc::
* History and Acknowledgements::
@end menu
Moving data to and from regular editing buffers.
@item
-``Embedded mode'' for manipulating Calc formulas and data directly
+Embedded mode for manipulating Calc formulas and data directly
inside any editing buffer.
@item
use Calc only as a traditional desk calculator, all you really need to
read is the ``Getting Started'' chapter of this manual and possibly the
first few sections of the tutorial. As you become more comfortable with
-the program you can learn its additional features. In terms of efficiency,
-scope and depth, Calc cannot replace a powerful tool like Mathematica.
-But Calc has the advantages of convenience, portability, and availability
-of the source code. And, of course, it's free!
+the program you can learn its additional features. Calc does not
+have the scope and depth of a fully-functional symbolic math package,
+but Calc has the advantages of convenience, portability, and freedom.
@node About This Manual, Notations Used in This Manual, What is Calc, Getting Started
@section About This Manual
@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. @c{Each}
-@asis{In the printed manual, each}
+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 [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{M-# i} to read the manual on-line. Also, you
-can jump directly to the Tutorial by pressing @kbd{h t} or @kbd{M-# t},
-or to the Summary by pressing @kbd{h s} or @kbd{M-# s}. Within Calc,
+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}.
-Printed copies of this manual are also available from the Free Software
-Foundation.
+The Calc manual can be printed, but because the manual is so large, you
+should only make a printed copy if you really need it. To print the
+manual, you will need the @TeX{} typesetting program (this is a free
+program by Donald Knuth at Stanford University) as well as the
+@file{texindex} program and @file{texinfo.tex} file, both of which can
+be obtained from the FSF as part of the @code{texinfo} package.
+To print the Calc manual in one huge tome, you will need the
+source code to this manual, @file{calc.texi}, available as part of the
+Emacs source. Once you have this file, type @kbd{texi2dvi calc.texi}.
+Alternatively, change to the @file{man} subdirectory of the Emacs
+source distribution, and type @kbd{make calc.dvi}. (Don't worry if you
+get some ``overfull box'' warnings while @TeX{} runs.)
+The result will be a device-independent output file called
+@file{calc.dvi}, which you must print in whatever way is right
+for your system. On many systems, the command is
+
+@example
+lpr -d calc.dvi
+@end example
+
+@noindent
+or
+
+@example
+dvips calc.dvi
+@end example
+
+@c Printed copies of this manual are also available from the Free Software
+@c Foundation.
@node Notations Used in This Manual, Demonstration of Calc, About This Manual, Getting Started
@section Notations Used in This Manual
(If you don't have the @key{LFD} or @key{TAB} keys on your keyboard,
the @kbd{C-j} and @kbd{C-i} keys are equivalent to them, respectively.
If you don't have a Meta key, look for Alt or Extend Char. You can
-also press @key{ESC} or @key{C-[} first to get the same effect, so
+also press @key{ESC} or @kbd{C-[} first to get the same effect, so
that @kbd{M-x}, @kbd{@key{ESC} x}, and @kbd{C-[ x} are all equivalent.)
Sometimes the @key{RET} key is not shown when it is ``obvious''
is usually omitted in key sequences like @kbd{M-x calc-keypad @key{RET}}.
Commands are generally shown like this: @kbd{p} (@code{calc-precision})
-or @kbd{M-# k} (@code{calc-keypad}). This means that the command is
-normally used by pressing the @kbd{p} key or @kbd{M-# k} key sequence,
+or @kbd{C-x * k} (@code{calc-keypad}). This means that the command is
+normally used by pressing the @kbd{p} key or @kbd{C-x * k} key sequence,
but it also has the full-name equivalent shown, e.g., @kbd{M-x calc-precision}.
Commands that correspond to functions in algebraic notation
be @samp{cos(@var{x})}.
A few commands don't have key equivalents: @code{calc-sincos}
-[@code{sincos}].@refill
+[@code{sincos}].
@node Demonstration of Calc, Using Calc, Notations Used in This Manual, Getting Started
@section A Demonstration of Calc
Tutorial.
To begin, start Emacs if necessary (usually the command @code{emacs}
-does this), and type @kbd{M-# c} (or @kbd{@key{ESC} # c}) to start the
-Calculator. (@xref{Starting Calc}, if this doesn't work for you.)
+does this), and type @kbd{C-x * c} to start the
+Calculator. (You can also use @kbd{M-x calc} if this doesn't work.
+@xref{Starting Calc}, for various ways of starting the Calculator.)
Be sure to type all the sample input exactly, especially noting the
difference between lower-case and upper-case letters. Remember,
then the command to operate on the numbers.
@noindent
-Type @kbd{2 @key{RET} 3 + Q} to compute @c{$\sqrt{2+3} = 2.2360679775$}
-@asis{the square root of 2+3, which is 2.2360679775}.
+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 @c{$\pi^2 = 9.86960440109$}
-@asis{the value of `pi' squared, 9.86960440109}.
+Type @kbd{P 2 ^} to compute
+@texline @math{\pi^2 = 9.86960440109}.
+@infoline the value of `pi' squared, 9.86960440109.
@noindent
Type @key{TAB} to exchange the order of these two results.
use the apostrophe key.
@noindent
-Type @kbd{' sqrt(2+3) @key{RET}} to compute @c{$\sqrt{2+3}$}
-@asis{the square root of 2+3}.
+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 @c{$\pi^2$}
-@asis{`pi' squared}. To evaluate this symbolic
-formula as a number, type @kbd{=}.
+Type @kbd{' pi^2 @key{RET}} to enter
+@texline @math{\pi^2}.
+@infoline `pi' squared.
+To evaluate this symbolic formula as a number, type @kbd{=}.
@noindent
Type @kbd{' arcsinh($ - $$) @key{RET}} to subtract the second-most-recent
result from the most-recent and compute the Inverse Hyperbolic sine.
@strong{Keypad mode.} If you are using the X window system, press
-@w{@kbd{M-# k}} to get Keypad mode. (If you don't use X, skip to
+@w{@kbd{C-x * k}} to get Keypad mode. (If you don't use X, skip to
the next section.)
@noindent
``buttons'' using your left mouse button.
@noindent
-Click on @key{PI}, @key{2}, and @t{y^x}.
+Click on @key{PI}, @key{2}, and @tfn{y^x}.
@noindent
Click on @key{INV}, then @key{ENTER} to swap the two results.
Click on @key{<-} to erase the result, then click @key{OFF} to turn
the Keypad Calculator off.
-@strong{Grabbing data.} Type @kbd{M-# x} if necessary to exit Calc.
+@strong{Grabbing data.} Type @kbd{C-x * x} if necessary to exit Calc.
Now select the following numbers as an Emacs region: ``Mark'' the
front of the list by typing @kbd{C-@key{SPC}} or @kbd{C-@@} there,
then move to the other end of the list. (Either get this list from
-the on-line copy of this manual, accessed by @w{@kbd{M-# i}}, or just
-type these numbers into a scratch file.) Now type @kbd{M-# g} to
+the on-line copy of this manual, accessed by @w{@kbd{C-x * i}}, or just
+type these numbers into a scratch file.) Now type @kbd{C-x * g} to
``grab'' these numbers into Calc.
@example
@noindent
You can also grab data as a rectangular matrix. Place the cursor on
the upper-leftmost @samp{1} and set the mark, then move to just after
-the lower-right @samp{8} and press @kbd{M-# r}.
+the lower-right @samp{8} and press @kbd{C-x * r}.
@noindent
-Type @kbd{v t} to transpose this @c{$3\times2$}
-@asis{3x2} matrix into a @c{$2\times3$}
-@asis{2x3} matrix. Type
-@w{@kbd{v u}} to unpack the rows into two separate vectors. Now type
-@w{@kbd{V R + @key{TAB} V R +}} to compute the sums of the two original columns.
-(There is also a special grab-and-sum-columns command, @kbd{M-# :}.)
+Type @kbd{v t} to transpose this
+@texline @math{3\times2}
+@infoline 3x2
+matrix into a
+@texline @math{2\times3}
+@infoline 2x3
+matrix. Type @w{@kbd{v u}} to unpack the rows into two separate
+vectors. Now type @w{@kbd{V R + @key{TAB} V R +}} to compute the sums
+of the two original columns. (There is also a special
+grab-and-sum-columns command, @kbd{C-x * :}.)
@strong{Units conversion.} Units are entered algebraically.
Type @w{@kbd{' 43 mi/hr @key{RET}}} to enter the quantity 43 miles-per-hour.
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
-these equations for the variables @cite{x} and @cite{y}.@refill
+these equations for the variables @expr{x} and @expr{y}.
@noindent
Type @kbd{d B} to view the solutions in more readable notation.
-Type @w{@kbd{d C}} to view them in C language notation, and @kbd{d T}
-to view them in the notation for the @TeX{} typesetting system.
-Type @kbd{d N} to return to normal 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
+system. Type @kbd{d N} to return to normal notation.
@noindent
-Type @kbd{7.5}, then @kbd{s l a @key{RET}} to let @cite{a = 7.5} in these formulas.
+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}.)
@iftex
@strong{Help functions.} You can read about any command in the on-line
-manual. Type @kbd{M-# c} to return to Calc after each of these
+manual. Type @kbd{C-x * c} to return to Calc after each of these
commands: @kbd{h k t N} to read about the @kbd{t N} command,
@kbd{h f sqrt @key{RET}} to read about the @code{sqrt} function, and
@kbd{h s} to read the Calc summary.
@end iftex
@ifinfo
@strong{Help functions.} You can read about any command in the on-line
-manual. Remember to type the letter @kbd{l}, then @kbd{M-# c}, to
+manual. Remember to type the letter @kbd{l}, then @kbd{C-x * c}, to
return here after each of these commands: @w{@kbd{h k t N}} to read
about the @w{@kbd{t N}} command, @kbd{h f sqrt @key{RET}} to read about the
@code{sqrt} function, and @kbd{h s} to read the Calc summary.
@end ifinfo
Press @key{DEL} repeatedly to remove any leftover results from the stack.
-To exit from Calc, press @kbd{q} or @kbd{M-# c} again.
+To exit from Calc, press @kbd{q} or @kbd{C-x * c} again.
@node Using Calc, History and Acknowledgements, Demonstration of Calc, Getting Started
@section Using Calc
@noindent
Calc has several user interfaces that are specialized for
different kinds of tasks. As well as Calc's standard interface,
-there are Quick Mode, Keypad Mode, and Embedded Mode.
-
-@c [fix-ref Installation]
-Calc must be @dfn{installed} before it can be used. @xref{Installation},
-for instructions on setting up and installing Calc. We will assume
-you or someone on your system has already installed Calc as described
-there.
+there are Quick mode, Keypad mode, and Embedded mode.
@menu
* Starting Calc::
* Keypad Mode Overview::
* Standalone Operation::
* Embedded Mode Overview::
-* Other M-# Commands::
+* Other C-x * Commands::
@end menu
@node Starting Calc, The Standard Interface, Using Calc, Using Calc
@subsection Starting Calc
@noindent
-On most systems, you can type @kbd{M-#} to start the Calculator.
-The notation @kbd{M-#} is short for Meta-@kbd{#}. On most
-keyboards this means holding down the Meta (or Alt) and
-Shift keys while typing @kbd{3}.
+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},
+which can be rebound if convenient (@pxref{Customizing Calc}).
-@cindex META key
-Once again, if you don't have a Meta key on your keyboard you can type
-@key{ESC} first, then @kbd{#}, to accomplish the same thing. If you
-don't even have an @key{ESC} key, you can fake it by holding down
-Control or @key{CTRL} while typing a left square bracket
-(that's @kbd{C-[} in Emacs notation).@refill
+When you press @kbd{C-x *}, Emacs waits for you to press a second key to
+complete the command. In this case, you will follow @kbd{C-x *} with a
+letter (upper- or lower-case, it doesn't matter for @kbd{C-x *}) that says
+which Calc interface you want to use.
-@kbd{M-#} is a @dfn{prefix key}; when you press it, Emacs waits for
-you to press a second key to complete the command. In this case,
-you will follow @kbd{M-#} with a letter (upper- or lower-case, it
-doesn't matter for @kbd{M-#}) that says which Calc interface you
-want to use.
-
-To get Calc's standard interface, type @kbd{M-# c}. To get
-Keypad Mode, type @kbd{M-# k}. Type @kbd{M-# ?} to get a brief
+To get Calc's standard interface, type @kbd{C-x * c}. To get
+Keypad mode, type @kbd{C-x * k}. Type @kbd{C-x * ?} to get a brief
list of the available options, and type a second @kbd{?} to get
a complete list.
-To ease typing, @kbd{M-# M-#} (or @kbd{M-# #} if that's easier)
-also works to start Calc. It starts the same interface (either
-@kbd{M-# c} or @w{@kbd{M-# k}}) that you last used, selecting the
-@kbd{M-# c} interface by default. (If your installation has
-a special function key set up to act like @kbd{M-#}, hitting that
-function key twice is just like hitting @kbd{M-# M-#}.)
+To ease typing, @kbd{C-x * *} also works to start Calc. It starts the
+same interface (either @kbd{C-x * c} or @w{@kbd{C-x * k}}) that you last
+used, selecting the @kbd{C-x * c} interface by default.
-If @kbd{M-#} doesn't work for you, you can always type explicit
+If @kbd{C-x *} doesn't work for you, you can always type explicit
commands like @kbd{M-x calc} (for the standard user interface) or
-@w{@kbd{M-x calc-keypad}} (for Keypad Mode). First type @kbd{M-x}
+@w{@kbd{M-x calc-keypad}} (for Keypad mode). First type @kbd{M-x}
(that's Meta with the letter @kbd{x}), then, at the prompt,
type the full command (like @kbd{calc-keypad}) and press Return.
-If you type @kbd{M-x calc} and Emacs still doesn't recognize the
-command (it will say @samp{[No match]} when you try to press
-@key{RET}), then Calc has not been properly installed.
-
-The same commands (like @kbd{M-# c} or @kbd{M-# M-#}) that start
+The same commands (like @kbd{C-x * c} or @kbd{C-x * *}) that start
the Calculator also turn it off if it is already on.
@node The Standard Interface, Quick Mode Overview, Starting Calc, Using Calc
@noindent
@cindex Standard user interface
Calc's standard interface acts like a traditional RPN calculator,
-operated by the normal Emacs keyboard. When you type @kbd{M-# c}
+operated by the normal Emacs keyboard. When you type @kbd{C-x * c}
to start the Calculator, the Emacs screen splits into two windows
with the file you were editing on top and Calc on the bottom.
...
--**-Emacs: myfile (Fundamental)----All----------------------
---- Emacs Calculator Mode --- |Emacs Calc Mode v2.00...
+--- Emacs Calculator Mode --- |Emacs Calc Mode v2.1 ...
2: 17.3 | 17.3
1: -5 | 3
. | 2
In this case, the trail shows that four numbers (17.3, 3, 2, and 4)
were first entered into the Calculator, then the 2 and 4 were
-multiplied to get 8, then the 3 and 8 were subtracted to get @i{-5}.
+multiplied to get 8, then the 3 and 8 were subtracted to get @mathit{-5}.
(The @samp{>} symbol shows that this was the most recent calculation.)
-The net result is the two numbers 17.3 and @i{-5} sitting on the stack.
+The net result is the two numbers 17.3 and @mathit{-5} sitting on the stack.
Most Calculator commands deal explicitly with the stack only, but
there is a set of commands that allow you to search back through
Shifted (i.e., upper-case) letters are different from lowercase
letters. Some letters are @dfn{prefix} keys that begin two-letter
commands. For example, @kbd{e} means ``enter exponent'' and shifted
-@kbd{E} means @cite{e^x}. With the @kbd{d} (``display modes'') prefix
+@kbd{E} means @expr{e^x}. With the @kbd{d} (``display modes'') prefix
the letter ``e'' takes on very different meanings: @kbd{d e} means
``engineering notation'' and @kbd{d E} means ``@dfn{eqn} language mode.''
cursor is in the Calc stack or trail windows, keys are interpreted
as Calc commands.
-When you quit by pressing @kbd{M-# c} a second time, the Calculator
+When you quit by pressing @kbd{C-x * c} a second time, the Calculator
windows go away but the actual Stack and Trail are not gone, just
-hidden. When you press @kbd{M-# c} once again you will get the
+hidden. When you press @kbd{C-x * c} once again you will get the
same stack and trail contents you had when you last used the
Calculator.
The Calculator does not remember its state between Emacs sessions.
-Thus if you quit Emacs and start it again, @kbd{M-# c} will give you
+Thus if you quit Emacs and start it again, @kbd{C-x * c} will give you
a fresh stack and trail. There is a command (@kbd{m m}) that lets
you save your favorite mode settings between sessions, though.
One of the things it saves is which user interface (standard or
Keypad) you last used; otherwise, a freshly started Emacs will
-always treat @kbd{M-# M-#} the same as @kbd{M-# c}.
+always treat @kbd{C-x * *} the same as @kbd{C-x * c}.
The @kbd{q} key is another equivalent way to turn the Calculator off.
-If you type @kbd{M-# b} first and then @kbd{M-# c}, you get a
+If you type @kbd{C-x * b} first and then @kbd{C-x * c}, you get a
full-screen version of Calc (@code{full-calc}) in which the stack and
trail windows are still side-by-side but are now as tall as the whole
-Emacs screen. When you press @kbd{q} or @kbd{M-# c} again to quit,
-the file you were editing before reappears. The @kbd{M-# b} key
+Emacs screen. When you press @kbd{q} or @kbd{C-x * c} again to quit,
+the file you were editing before reappears. The @kbd{C-x * b} key
switches back and forth between ``big'' full-screen mode and the
normal partial-screen mode.
-Finally, @kbd{M-# o} (@code{calc-other-window}) is like @kbd{M-# c}
+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{M-# o} is a handy
+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{M-# c} to switch back into Calc when you are done.
+@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)
@noindent
-@dfn{Quick Mode} is a quick way to use Calc when you don't need the
-full complexity of the stack and trail. To use it, type @kbd{M-# q}
+@dfn{Quick mode} is a quick way to use Calc when you don't need the
+full complexity of the stack and trail. To use it, type @kbd{C-x * q}
(@code{quick-calc}) in any regular editing buffer.
-Quick Mode is very simple: It prompts you to type any formula in
+Quick mode is very simple: It prompts you to type any formula in
standard algebraic notation (like @samp{4 - 2/3}) and then displays
-the result at the bottom of the Emacs screen (@i{3.33333333333}
+the result at the bottom of the Emacs screen (@mathit{3.33333333333}
in this case). You are then back in the same editing buffer you
-were in before, ready to continue editing or to type @kbd{M-# q}
+were in before, ready to continue editing or to type @kbd{C-x * q}
again to do another quick calculation. The result of the calculation
will also be in the Emacs ``kill ring'' so that a @kbd{C-y} command
at this point will yank the result into your editing buffer.
-Calc mode settings affect Quick Mode, too, though you will have to
-go into regular Calc (with @kbd{M-# c}) to change the mode settings.
+Calc mode settings affect Quick mode, too, though you will have to
+go into regular Calc (with @kbd{C-x * c}) to change the mode settings.
@c [fix-ref Quick Calculator mode]
@xref{Quick Calculator}, for further information.
@subsection Keypad Mode (Overview)
@noindent
-@dfn{Keypad Mode} is a mouse-based interface to the Calculator.
+@dfn{Keypad mode} is a mouse-based interface to the Calculator.
It is designed for use with terminals that support a mouse. If you
-don't have a mouse, you will have to operate keypad mode with your
-arrow keys (which is probably more trouble than it's worth). Keypad
-mode is currently not supported under Emacs 19.
+don't have a mouse, you will have to operate Keypad mode with your
+arrow keys (which is probably more trouble than it's worth).
-Type @kbd{M-# k} to turn Keypad Mode on or off. Once again you
+Type @kbd{C-x * k} to turn Keypad mode on or off. Once again you
get two new windows, this time on the righthand side of the screen
instead of at the bottom. The upper window is the familiar Calc
Stack; the lower window is a picture of a typical calculator keypad.
\medskip
@end tex
@smallexample
- |--- Emacs Calculator Mode ---
- |2: 17.3
- |1: -5
- | .
- |--%%-Calc: 12 Deg (Calcul
- |----+-----Calc 2.00-----+----1
- |FLR |CEIL|RND |TRNC|CLN2|FLT |
- |----+----+----+----+----+----|
- | LN |EXP | |ABS |IDIV|MOD |
- |----+----+----+----+----+----|
- |SIN |COS |TAN |SQRT|y^x |1/x |
- |----+----+----+----+----+----|
- | ENTER |+/- |EEX |UNDO| <- |
- |-----+---+-+--+--+-+---++----|
- | INV | 7 | 8 | 9 | / |
- |-----+-----+-----+-----+-----|
- | HYP | 4 | 5 | 6 | * |
- |-----+-----+-----+-----+-----|
- |EXEC | 1 | 2 | 3 | - |
- |-----+-----+-----+-----+-----|
- | OFF | 0 | . | PI | + |
- |-----+-----+-----+-----+-----+
-@end smallexample
-
-Keypad Mode is much easier for beginners to learn, because there
+@group
+|--- Emacs Calculator Mode ---
+|2: 17.3
+|1: -5
+| .
+|--%%-Calc: 12 Deg (Calcul
+|----+-----Calc 2.1------+----1
+|FLR |CEIL|RND |TRNC|CLN2|FLT |
+|----+----+----+----+----+----|
+| LN |EXP | |ABS |IDIV|MOD |
+|----+----+----+----+----+----|
+|SIN |COS |TAN |SQRT|y^x |1/x |
+|----+----+----+----+----+----|
+| ENTER |+/- |EEX |UNDO| <- |
+|-----+---+-+--+--+-+---++----|
+| INV | 7 | 8 | 9 | / |
+|-----+-----+-----+-----+-----|
+| HYP | 4 | 5 | 6 | * |
+|-----+-----+-----+-----+-----|
+|EXEC | 1 | 2 | 3 | - |
+|-----+-----+-----+-----+-----|
+| OFF | 0 | . | PI | + |
+|-----+-----+-----+-----+-----+
+@end group
+@end smallexample
+
+Keypad mode is much easier for beginners to learn, because there
is no need to memorize lots of obscure key sequences. But not all
commands in regular Calc are available on the Keypad. You can
always switch the cursor into the Calc stack window to use
standard Calc commands if you need. Serious Calc users, though,
-often find they prefer the standard interface over Keypad Mode.
+often find they prefer the standard interface over Keypad mode.
To operate the Calculator, just click on the ``buttons'' of the
keypad using your left mouse button. To enter the two numbers
math functions, vector operations, and operations on binary
numbers.
-Because Keypad Mode doesn't use the regular keyboard, Calc leaves
+Because Keypad mode doesn't use the regular keyboard, Calc leaves
the cursor in your original editing buffer. You can type in
this buffer in the usual way while also clicking on the Calculator
-keypad. One advantage of Keypad Mode is that you don't need an
+keypad. One advantage of Keypad mode is that you don't need an
explicit command to switch between editing and calculating.
-If you press @kbd{M-# b} first, you get a full-screen Keypad Mode
+If you press @kbd{C-x * b} first, you get a full-screen Keypad mode
(@code{full-calc-keypad}) with three windows: The keypad in the lower
left, the stack in the lower right, and the trail on top.
@end example
@noindent
-which run a full-screen Calculator (as if by @kbd{M-# b M-# c}) or
-a full-screen X-based Calculator (as if by @kbd{M-# b M-# k}).
+which run a full-screen Calculator (as if by @kbd{C-x * b C-x * c}) or
+a full-screen X-based Calculator (as if by @kbd{C-x * b C-x * k}).
In standalone operation, quitting the Calculator (by pressing
@kbd{q} or clicking on the keypad @key{EXIT} button) quits Emacs
itself.
-@node Embedded Mode Overview, Other M-# Commands, Standalone Operation, Using Calc
+@node Embedded Mode Overview, Other C-x * Commands, Standalone Operation, Using Calc
@subsection Embedded Mode (Overview)
@noindent
-@dfn{Embedded Mode} is a way to use Calc directly from inside an
+@dfn{Embedded mode} is a way to use Calc directly from inside an
editing buffer. Suppose you have a formula written as part of a
document like this:
@noindent
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
+do this with Embedded mode, first copy the formula down to where
you want the result to be:
@smallexample
@end group
@end smallexample
-Now, move the cursor onto this new formula and press @kbd{M-# e}.
+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
@end smallexample
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.
+the formula, and even @kbd{d B} to use Big display mode.
@smallexample
@group
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{}.
-(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.)
+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
+to move these comments up to the top of the file or otherwise put them
+out of the way.)
As an extra flourish, we can add an equation number using a
righthand label: Type @kbd{d @} (1) @key{RET}}.
@end group
@end smallexample
-To leave Embedded Mode, type @kbd{M-# e} again. The mode line
-and keyboard will revert to the way they were before. (If you have
-actually been trying this as you read along, you'll want to press
-@kbd{M-# 0} [with the digit zero] now to reset the modes you changed.)
+To leave Embedded mode, type @kbd{C-x * e} again. The mode line
+and keyboard will revert to the way they were before.
-The related command @kbd{M-# w} operates on a single word, which
+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:
A slope of one-third corresponds to an angle of 1 degrees.
@end smallexample
-Place the cursor on the @samp{1}, then type @kbd{M-# w} to enable
-Embedded Mode on that number. Now type @kbd{3 /} (to get one-third),
+Place the cursor on the @samp{1}, then type @kbd{C-x * w} to enable
+Embedded mode on that number. Now type @kbd{3 /} (to get one-third),
and @kbd{I T} (the Inverse Tangent converts a slope into an angle),
-then @w{@kbd{M-# w}} again to exit Embedded mode.
+then @w{@kbd{C-x * w}} again to exit Embedded mode.
@smallexample
A slope of one-third corresponds to an angle of 18.4349488229 degrees.
@c [fix-ref Embedded Mode]
@xref{Embedded Mode}, for full details.
-@node Other M-# Commands, , Embedded Mode Overview, Using Calc
-@subsection Other @kbd{M-#} Commands
+@node Other C-x * Commands, , Embedded Mode Overview, Using Calc
+@subsection Other @kbd{C-x *} Commands
@noindent
-Two more Calc-related commands are @kbd{M-# g} and @kbd{M-# r},
+Two more Calc-related commands are @kbd{C-x * g} and @kbd{C-x * r},
which ``grab'' data from a selected region of a buffer into the
Calculator. The region is defined in the usual Emacs way, by
a ``mark'' placed at one end of the region, and the Emacs
cursor or ``point'' placed at the other.
-The @kbd{M-# g} command reads the region in the usual left-to-right,
+The @kbd{C-x * g} command reads the region in the usual left-to-right,
top-to-bottom order. The result is packaged into a Calc vector
of numbers and placed on the stack. Calc (in its standard
user interface) is then started. Type @kbd{v u} if you want
to unpack this vector into separate numbers on the stack. Also,
-@kbd{C-u M-# g} interprets the region as a single number or
+@kbd{C-u C-x * g} interprets the region as a single number or
formula.
-The @kbd{M-# r} command reads a rectangle, with the point and
+The @kbd{C-x * r} command reads a rectangle, with the point and
mark defining opposite corners of the rectangle. The result
is a matrix of numbers on the Calculator stack.
-Complementary to these is @kbd{M-# y}, which ``yanks'' the
+Complementary to these is @kbd{C-x * y}, which ``yanks'' the
value at the top of the Calc stack back into an editing buffer.
-If you type @w{@kbd{M-# y}} while in such a buffer, the value is
-yanked at the current position. If you type @kbd{M-# y} while
+If you type @w{@kbd{C-x * y}} while in such a buffer, the value is
+yanked at the current position. If you type @kbd{C-x * y} while
in the Calc buffer, Calc makes an educated guess as to which
editing buffer you want to use. The Calc window does not have
to be visible in order to use this command, as long as there
is something on the Calc stack.
-Here, for reference, is the complete list of @kbd{M-#} commands.
+Here, for reference, is the complete list of @kbd{C-x *} commands.
The shift, control, and meta keys are ignored for the keystroke
-following @kbd{M-#}.
+following @kbd{C-x *}.
@noindent
Commands for turning Calc on and off:
@table @kbd
-@item #
+@item *
Turn Calc on or off, employing the same user interface as last time.
+@item =, +, -, /, \, &, #
+Alternatives for @kbd{*}.
+
@item C
Turn Calc on or off using its standard bottom-of-the-screen
interface. If Calc is already turned on but the cursor is not
move it out of that window.
@item B
-Control whether @kbd{M-# c} and @kbd{M-# k} use the full screen.
+Control whether @kbd{C-x * c} and @kbd{C-x * k} use the full screen.
@item Q
-Use Quick Mode for a single short calculation.
+Use Quick mode for a single short calculation.
@item K
Turn Calc Keypad mode on or off.
@end iftex
@noindent
-Commands for use with Embedded Mode:
+Commands for use with Embedded mode:
@table @kbd
@item A
@item 0
(This is the ``zero'' digit key.) Reset the Calculator to
-its default state: Empty stack, and default mode settings.
-With any prefix argument, reset everything but the stack.
+its initial state: Empty stack, and initial mode settings.
@end table
@node History and Acknowledgements, , Using Calc, Getting Started
@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 @c{$2^{32}$}
-@cite{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 digits even though we knew they were there in the
-program's memory! I was so annoyed, I vowed to write a calculator
-of my own, once and for all.
+the value of
+@texline @math{2^{32}}.
+@infoline @expr{2^32}.
+I didn't offhand, but I said, ``that's easy, just call up an
+@code{xcalc}.'' @code{Xcalc} duly reported that the answer to our
+question was @samp{4.294967e+09}---with no way to see the full ten
+digits even though we knew they were there in the program's memory! I
+was so annoyed, I vowed to write a calculator of my own, once and for
+all.
I chose Emacs Lisp, a) because I had always been curious about it
and b) because, being only a text editor extension language after
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
-numerical quantities, and it could also operate on matrices. I decided
-that these would be good for Calc to have, too. And once things had
-gone this far, I figured I might as well take a look at serious algebra
-systems like Mathematica, Macsyma, and Maple for further ideas. Since
-these systems did far more than I could ever hope to implement, I decided
-to focus on rewrite rules and other programming features so that users
-could implement what they needed for themselves.
+numerical quantities, and it could also operate on matrices. I
+decided that these would be good for Calc to have, too. And once
+things had gone this far, I figured I might as well take a look at
+serious algebra systems for further ideas. Since these systems did
+far more than I could ever hope to implement, I decided to focus on
+rewrite rules and other programming features so that users could
+implement what they needed for themselves.
Rick complained that matrices were hard to read, so I put in code to
format them in a 2D style. Once these routines were in place, Big mode
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; @c{Fran\c cois}
-@asis{Francois} Pinard, who contributed
-an early prototype of the Calc Summary appendix as well as providing
-valuable suggestions in many other areas of Calc; Carl Witty, whose eagle
-eyes discovered many typographical and factual errors in the Calc manual;
-Tim Kay, who drove the development of Embedded mode; Ove Ewerlid, who
-made many suggestions relating to the algebra commands and contributed
-some code for polynomial operations; Randal Schwartz, who suggested the
-@code{calc-eval} function; Robert J. Chassell, who suggested the Calc
-Tutorial and exercises; and Juha Sarlin, who first worked out how to split
-Calc into quickly-loading parts. Bob Weiner helped immensely with the
-Lucid Emacs port.
+rules, and many other algebra features;
+@texline Fran\c{c}ois
+@infoline Francois
+Pinard, who contributed an early prototype of the Calc Summary appendix
+as well as providing valuable suggestions in many other areas of Calc;
+Carl Witty, whose eagle eyes discovered many typographical and factual
+errors in the Calc manual; Tim Kay, who drove the development of
+Embedded mode; Ove Ewerlid, who made many suggestions relating to the
+algebra commands and contributed some code for polynomial operations;
+Randal Schwartz, who suggested the @code{calc-eval} function; Robert
+J. Chassell, who suggested the Calc Tutorial and exercises; and Juha
+Sarlin, who first worked out how to split Calc into quickly-loading
+parts. Bob Weiner helped immensely with the Lucid Emacs port.
@cindex Bibliography
@cindex Knuth, Art of Computer Programming
Among the books used in the development of Calc were Knuth's @emph{Art
of Computer Programming} (especially volume II, @emph{Seminumerical
Algorithms}); @emph{Numerical Recipes} by Press, Flannery, Teukolsky,
-and Vetterling; Bevington's @emph{Data Reduction and Error Analysis for
-the Physical Sciences}; @emph{Concrete Mathematics} by Graham, Knuth,
-and Patashnik; Steele's @emph{Common Lisp, the Language}; the @emph{CRC
-Standard Math Tables} (William H. Beyer, ed.); and Abramowitz and
-Stegun's venerable @emph{Handbook of Mathematical Functions}. I
-consulted the user's manuals for the HP-28 and HP-48 calculators, as
-well as for the programs Mathematica, SMP, Macsyma, Maple, MathCAD,
-Gnuplot, and others. Also, of course, Calc could not have been written
-without the excellent @emph{GNU Emacs Lisp Reference Manual}, by Bil
-Lewis and Dan LaLiberte.
+and Vetterling; Bevington's @emph{Data Reduction and Error Analysis
+for the Physical Sciences}; @emph{Concrete Mathematics} by Graham,
+Knuth, and Patashnik; Steele's @emph{Common Lisp, the Language}; the
+@emph{CRC Standard Math Tables} (William H. Beyer, ed.); and
+Abramowitz and Stegun's venerable @emph{Handbook of Mathematical
+Functions}. Also, of course, Calc could not have been written without
+the excellent @emph{GNU Emacs Lisp Reference Manual}, by Bil Lewis and
+Dan LaLiberte.
Final thanks go to Richard Stallman, without whose fine implementations
of the Emacs editor, language, and environment, Calc would have been
@c [tutorial]
@ifinfo
-@c This node is accessed by the `M-# t' command.
+@c This node is accessed by the `C-x * t' command.
@node Interactive Tutorial, , , Top
@chapter Tutorial
@c [fix-ref Embedded Mode]
This tutorial describes the standard user interface of Calc only.
-The ``Quick Mode'' and ``Keypad Mode'' interfaces are fairly
+The Quick mode and Keypad mode interfaces are fairly
self-explanatory. @xref{Embedded Mode}, for a description of
-the ``Embedded Mode'' interface.
+the Embedded mode interface.
@ifinfo
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{M-# c} to turn Calc on or to switch into the Calc window, and
-press @kbd{M-# i} to start the Info system or to switch into its window.
+@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.
Or, you may prefer to use the tutorial in printed form.
@end ifinfo
@iftex
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{M-# c} to turn Calc on or to switch into the Calc window, and
-press @kbd{M-# i} to start the Info system or to switch into its window.
+@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.
@end iftex
This tutorial is designed to be done in sequence. But the rest of this
@ifinfo
You may wish to print out a copy of the Calc Summary and keep notes on
-it as you learn Calc. @xref{Installation}, to see how to make a printed
-summary. @xref{Summary}.
+it as you learn Calc. @xref{About This Manual}, to see how to make a
+printed summary. @xref{Summary}.
@end ifinfo
@iftex
The Calc Summary at the end of the reference manual includes some blank
@cindex Operators
@cindex Operands
-In an operation like @cite{2+3}, the 2 and 3 are called the @dfn{operands}
-and the @cite{+} is the @dfn{operator}. In an RPN calculator you always
+In an operation like @expr{2+3}, the 2 and 3 are called the @dfn{operands}
+and the @expr{+} is the @dfn{operator}. In an RPN calculator you always
enter the operands first, then the operator. Each time you type a
number, Calc adds or @dfn{pushes} it onto the top of the Stack.
When you press an operator key like @kbd{+}, Calc @dfn{pops} the appropriate
Thus we could add the numbers 2 and 3 in an RPN calculator by typing:
@kbd{2 @key{RET} 3 @key{RET} +}. (The @key{RET} key, Return, corresponds to
the @key{ENTER} key on traditional RPN calculators.) Try this now if
-you wish; type @kbd{M-# c} to switch into the Calc window (you can type
-@kbd{M-# c} again or @kbd{M-# o} to switch back to the Tutorial window).
+you wish; type @kbd{C-x * c} to switch into the Calc window (you can type
+@kbd{C-x * c} again or @kbd{C-x * o} to switch back to the Tutorial window).
The first four keystrokes ``push'' the numbers 2 and 3 onto the stack.
The @kbd{+} key ``pops'' the top two numbers from the stack, adds them,
and pushes the result (5) back onto the stack. Here's how the stack
-will look at various points throughout the calculation:@refill
+will look at various points throughout the calculation:
@smallexample
@group
. 1: 3 .
.
- M-# c 2 @key{RET} 3 @key{RET} + @key{DEL}
+ C-x * c 2 @key{RET} 3 @key{RET} + @key{DEL}
@end group
@end smallexample
@cindex Levels of stack
The numbers @samp{1:} and @samp{2:} on the left are @dfn{stack level
numbers}. Old RPN calculators always had four stack levels called
-@cite{x}, @cite{y}, @cite{z}, and @cite{t}. Calc's stack can grow
+@expr{x}, @expr{y}, @expr{z}, and @expr{t}. Calc's stack can grow
as large as you like, so it uses numbers instead of letters. Some
stack-manipulation commands accept a numeric argument that says
which stack level to work on. Normal commands like @kbd{+} always
-work on the top few levels of the stack.@refill
+work on the top few levels of the stack.
@c [fix-ref Truncating the Stack]
The Stack buffer is just an Emacs buffer, and you can move around in
@key{RET} +}. That's because if you type any operator name or
other non-numeric key when you are entering a number, the Calculator
automatically enters that number and then does the requested command.
-Thus @kbd{2 @key{RET} 3 +} will work just as well.@refill
+Thus @kbd{2 @key{RET} 3 +} will work just as well.
Examples in this tutorial will often omit @key{RET} even when the
stack displays shown would only happen if you did press @key{RET}:
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 @c{$(2\times4) + (7\times9.4) + {5\over4}$}
-@cite{2*4 + 7*9.5 + 5/4} using the
-stack. @xref{RPN Answer 2, 2}. (@bullet{})
+(@bullet{}) @strong{Exercise 2.} Compute
+@texline @math{(2\times4) + (7\times9.4) + {5\over4}}
+@infoline @expr{2*4 + 7*9.5 + 5/4}
+using the stack. @xref{RPN Answer 2, 2}. (@bullet{})
The @key{DEL} key is called Backspace on some keyboards. It is
whatever key you would use to correct a simple typing error when
Another stack manipulation key is @key{TAB}. This exchanges the top
two stack entries. Suppose you have computed @kbd{2 @key{RET} 3 +}
to get 5, and then you realize what you really wanted to compute
-was @cite{20 / (2+3)}.
+was @expr{20 / (2+3)}.
@smallexample
@group
@end smallexample
@noindent
-The notation @cite{(a, b)} represents a complex number.
-Complex numbers are more traditionally written @c{$a + b i$}
-@cite{a + b i};
+The notation @expr{(a, b)} represents a complex number.
+Complex numbers are more traditionally written @expr{a + b i};
Calc can display in this format, too, but for now we'll stick to the
-@cite{(a, b)} notation.
+@expr{(a, b)} notation.
If you don't know how complex numbers work, you can safely ignore this
feature. Complex numbers only arise from operations that would be
entry and the top are collected, so there's never really a reason
to use the comma. It's up to you.
-(@bullet{}) @strong{Exercise 4.} To enter the complex number @cite{(2, 3)},
+(@bullet{}) @strong{Exercise 4.} To enter the complex number @expr{(2, 3)},
your friend Joe typed @kbd{( 2 , @key{SPC} 3 )}. What happened?
(Joe thought of a clever way to correct his mistake in only two
keystrokes, but it didn't quite work. Try it to find out why.)
@noindent
If you are not used to RPN notation, you may prefer to operate the
-Calculator in ``algebraic mode,'' which is closer to the way
-non-RPN calculators work. In algebraic mode, you enter formulas
-in traditional @cite{2+3} notation.
+Calculator in Algebraic mode, which is closer to the way
+non-RPN calculators work. In Algebraic mode, you enter formulas
+in traditional @expr{2+3} notation.
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{'})
@end tex
@noindent
-The result of this expression will be the number @i{-6.99999826533}.
+The result of this expression will be the number @mathit{-6.99999826533}.
Calc's order of evaluation is the same as for most computer languages,
except that @samp{*} binds more strongly than @samp{/}, as the above
Operators at the same level are evaluated from left to right, except
that @samp{^} is evaluated from right to left. Thus, @samp{2-3-4} is
-equivalent to @samp{(2-3)-4} or @i{-5}, whereas @samp{2^3^4} is equivalent
+equivalent to @samp{(2-3)-4} or @mathit{-5}, whereas @samp{2^3^4} is equivalent
to @samp{2^(3^4)} (a very large integer; try it!).
-If you tire of typing the apostrophe all the time, there is an
-``algebraic mode'' you can select in which Calc automatically senses
+If you tire of typing the apostrophe all the time, there is
+Algebraic mode, where Calc automatically senses
when you are about to type an algebraic expression. To enter this
mode, press the two letters @w{@kbd{m a}}. (An @samp{Alg} indicator
should appear in the Calc window's mode line.)
Press @kbd{m a}, then @kbd{2+3+4} with no apostrophe, then @key{RET}.
-In algebraic mode, when you press any key that would normally begin
+In Algebraic mode, when you press any key that would normally begin
entering a number (such as a digit, a decimal point, or the @kbd{_}
key), or if you press @kbd{(} or @kbd{[}, Calc automatically begins
an algebraic entry.
the notation @samp{sqrt(@var{x})}.
Press the apostrophe, then type @kbd{sqrt(5*2) - 3}. The result should
-be @cite{0.16227766017}.
+be @expr{0.16227766017}.
Note that if the formula begins with a function name, you need to use
-the apostrophe even if you are in algebraic mode. If you type @kbd{arcsin}
+the apostrophe even if you are in Algebraic mode. If you type @kbd{arcsin}
out of the blue, the @kbd{a r} will be taken as an Algebraic Rewrite
command, and the @kbd{csin} will be taken as the name of the rewrite
rule to use!
form because they find RPN entry with incomplete objects to be too
distracting, even though they otherwise use Calc as an RPN calculator.
-Still in algebraic mode, type:
+Still in Algebraic mode, type:
@smallexample
@group
Algebraic mode allows us to enter complex numbers without pressing
an apostrophe first, but it also means we need to press @key{RET}
-after every entry, even for a simple number like @cite{1}.
+after every entry, even for a simple number like @expr{1}.
-(You can type @kbd{C-u m a} to enable a special ``incomplete algebraic
-mode'' in which the @kbd{(} and @kbd{[} keys use algebraic entry even
+(You can type @kbd{C-u m a} to enable a special Incomplete Algebraic
+mode in which the @kbd{(} and @kbd{[} keys use algebraic entry even
though regular numeric keys still use RPN numeric entry. There is also
-a ``total algebraic mode,'' started by typing @kbd{m t}, in which all
+Total Algebraic mode, started by typing @kbd{m t}, in which all
normal keys begin algebraic entry. You must then use the @key{META} key
-to type Calc commands: @kbd{M-m t} to get back out of total algebraic
-mode, @kbd{M-q} to quit, etc. Total algebraic mode is not supported
-under Emacs 19.)
+to type Calc commands: @kbd{M-m t} to get back out of Total Algebraic
+mode, @kbd{M-q} to quit, etc.)
-If you're still in algebraic mode, press @kbd{m a} again to turn it off.
+If you're still in Algebraic mode, press @kbd{m a} again to turn it off.
Actual non-RPN calculators use a mixture of algebraic and RPN styles.
In general, operators of two numbers (like @kbd{+} and @kbd{*})
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 @c{$\sqrt{2\times4+1}$}
-@cite{sqrt(2*4+1)},
+of the stack. Here, we perform the calculation
+@texline @math{\sqrt{2\times4+1}},
+@infoline @expr{sqrt(2*4+1)},
which on a traditional calculator would be done by pressing
@kbd{2 * 4 + 1 =} and then the square-root key.
@noindent
Notice that the instant we stored a new value in @code{a}, all
-@samp{=>} operators already on the stack that referred to @cite{a}
+@samp{=>} operators already on the stack that referred to @expr{a}
were updated to use the new value. With @samp{=>}, you can push a
set of formulas on the stack, then change the variables experimentally
to see the effects on the formulas' values.
@noindent
If you make a mistake, you can usually correct it by pressing shift-@kbd{U},
the ``undo'' command. First, clear the stack (@kbd{M-0 @key{DEL}}) and exit
-and restart Calc (@kbd{M-# M-# M-# M-#}) to make sure things start off
+and restart Calc (@kbd{C-x * * C-x * *}) to make sure things start off
with a clean slate. Now:
@smallexample
@end smallexample
@noindent
-It was not possible to redo past the @cite{6}, since that was placed there
+It was not possible to redo past the @expr{6}, since that was placed there
by something other than an undo command.
@cindex Time travel
@kbd{U} to go backward in time, @kbd{D} to go forward. If you go
backward and do something (like @kbd{*}) then, as any science fiction
reader knows, you have changed your future and you cannot go forward
-again. Thus, the inability to redo past the @cite{6} even though there
+again. Thus, the inability to redo past the @expr{6} even though there
was an earlier undo command.
You can always recall an earlier result using the Trail. We've ignored
did since we loaded the Calculator. If the Trail is not displayed,
press @kbd{t d} now to turn it on.
-Let's try grabbing an earlier result. The @cite{8} we computed was
+Let's try grabbing an earlier result. The @expr{8} we computed was
undone by a @kbd{U} command, and was lost even to Redo when we pressed
@kbd{*}, but it's still there in the trail. There should be a little
@samp{>} arrow (the @dfn{trail pointer}) resting on the last trail
entry. If there isn't, press @kbd{t ]} to reset the trail pointer.
Now, press @w{@kbd{t p}} to move the arrow onto the line containing
-@cite{8}, and press @w{@kbd{t y}} to ``yank'' that number back onto the
+@expr{8}, and press @w{@kbd{t y}} to ``yank'' that number back onto the
stack.
If you press @kbd{t ]} again, you will see that even our Yank command
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. This may
-not work under Lucid Emacs, but you can also type @kbd{h h} to
-see all the help at once.
+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,
to edit a stack entry.
Try entering @samp{3.141439} now. If this is supposed to represent
-@c{$\pi$}
-@cite{pi}, it's got several errors. Press @kbd{`} to edit this number.
+@cpi{}, it's got several errors. Press @kbd{`} to edit this number.
Now use the normal Emacs cursor motion and editing keys to change
the second 4 to a 5, and to transpose the 3 and the 9. When you
press @key{RET}, the number on the stack will be replaced by your
@noindent
Calc has many types of @dfn{modes} that affect the way it interprets
your commands or the way it displays data. We have already seen one
-mode, namely algebraic mode. There are many others, too; we'll
+mode, namely Algebraic mode. There are many others, too; we'll
try some of the most common ones here.
Perhaps the most fundamental mode in Calc is the current @dfn{precision}.
about, but the @samp{12} and the @samp{Deg} are mode indicators.
The @samp{12} means that calculations should always be carried to
12 significant figures. That is why, when we type @kbd{1 @key{RET} 7 /},
-we get @cite{0.142857142857} with exactly 12 digits, not counting
+we get @expr{0.142857142857} with exactly 12 digits, not counting
leading and trailing zeros.
You can set the precision to anything you like by pressing @kbd{p},
Although the precision can be set arbitrarily high, Calc always
has to have @emph{some} value for the current precision. After
-all, the true value @cite{1/7} is an infinitely repeating decimal;
+all, the true value @expr{1/7} is an infinitely repeating decimal;
Calc has to stop somewhere.
Of course, calculations are slower the more digits you request.
Press @w{@kbd{p 12}} now to set the precision back down to the default.
Calculations always use the current precision. For example, even
-though we have a 30-digit value for @cite{1/7} on the stack, if
+though we have a 30-digit value for @expr{1/7} on the stack, if
we use it in a calculation in 12-digit mode it will be rounded
down to 12 digits before it is used. Try it; press @key{RET} to
duplicate the number, then @w{@kbd{1 +}}. Notice that the @key{RET}
@noindent
In fact, since we added a digit on the left, we had to lose one
-digit on the right from even the 12-digit value of @cite{1/7}.
+digit on the right from even the 12-digit value of @expr{1/7}.
How did we get more than 12 digits when we computed @samp{2^3^4}? The
answer is that Calc makes a distinction between @dfn{integers} and
@noindent
Hey, the answer is different! Look closely at the middle columns
of the two examples. In the first, the stack contained the
-exact integer @cite{10000}, but in the second it contained
+exact integer @expr{10000}, but in the second it contained
a floating-point value with a decimal point. When you raise a
number to an integer power, Calc uses repeated squaring and
multiplication to get the answer. When you use a floating-point
format; since it doesn't have an @kbd{H} prefix, it also updates all
the stack entries to be in @kbd{d n} format.
-Notice that the integer @cite{12345} was not affected by any
+Notice that the integer @expr{12345} was not affected by any
of the float formats. Integers are integers, and are always
displayed exactly.
scrolling to see them all. Press @kbd{<} and @kbd{>} to scroll the
stack window left and right by half its width. Another way to view
something large is to press @kbd{`} (back-quote) to edit the top of
-stack in a separate window. (Press @kbd{M-# M-#} when you are done.)
+stack in a separate window. (Press @kbd{C-c C-c} when you are done.)
You can enter non-decimal numbers using the @kbd{#} symbol, too.
Let's see what the hexadecimal number @samp{5FE} looks like in
@noindent
The shift-@kbd{S} command computes the sine of an angle. The sine
-of 45 degrees is @c{$\sqrt{2}/2$}
-@cite{sqrt(2)/2}; squaring this yields @cite{2/4 = 0.5}.
-However, there has been a slight roundoff error because the
-representation of @c{$\sqrt{2}/2$}
-@cite{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
+of 45 degrees is
+@texline @math{\sqrt{2}/2};
+@infoline @expr{sqrt(2)/2};
+squaring this yields @expr{2/4 = 0.5}. However, there has been a slight
+roundoff error because the representation of
+@texline @math{\sqrt{2}/2}
+@infoline @expr{sqrt(2)/2}
+wasn't exact. The @kbd{c 1} command is a handy way to clean up numbers
+in this case; it temporarily reduces the precision by one digit while it
re-rounds the number on the top of the stack.
@cindex Roundoff errors, examples
To do this calculation in radians, we would type @kbd{m r} first.
(The indicator changes to @samp{Rad}.) 45 degrees corresponds to
-@c{$\pi\over4$}
-@cite{pi/4} radians. To get @c{$\pi$}
-@cite{pi}, press the @kbd{P} key. (Once
+@cpiover{4} radians. To get @cpi{}, press the @kbd{P} key. (Once
again, this is a shifted capital @kbd{P}. Remember, unshifted
@kbd{p} sets the precision.)
@end smallexample
@noindent
-Here we compute the Inverse Sine of @c{$\sqrt{0.5}$}
-@cite{sqrt(0.5)}, first in
-radians, then in degrees.
+Here we compute the Inverse Sine of
+@texline @math{\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
and vice-versa.
@end group
@end smallexample
-Another interesting mode is @dfn{fraction mode}. Normally,
+Another interesting mode is @dfn{Fraction mode}. Normally,
dividing two integers produces a floating-point result if the
quotient can't be expressed as an exact integer. Fraction mode
causes integer division to produce a fraction, i.e., a rational
(Calc uses @kbd{:} instead of @kbd{/} as the fraction separator
because @kbd{/} is already used to divide the top two stack
elements.) Calculations involving fractions will always
-produce exact fractional results; fraction mode only says
+produce exact fractional results; Fraction mode only says
what to do when dividing two integers.
@cindex Fractions vs. floats
Typing @kbd{m f} doesn't change any existing values in the stack.
In the above example, we had to Undo the division and do it over
-again when we changed to fraction mode. But if you use the
+again when we changed to Fraction mode. But if you use the
evaluates-to operator you can get commands like @kbd{m f} to
recompute for you.
@noindent
In this example, the righthand side of the @samp{=>} operator
on the stack is recomputed when we change the precision, then
-again when we change to fraction mode. All @samp{=>} expressions
+again when we change to Fraction mode. All @samp{=>} expressions
on the stack are recomputed every time you change any mode that
might affect their values.
We've already seen the @kbd{Q} (square root) and @kbd{S} (sine)
commands. Other commands along those lines are @kbd{C} (cosine),
-@kbd{T} (tangent), @kbd{E} (@cite{e^x}) and @kbd{L} (natural
+@kbd{T} (tangent), @kbd{E} (@expr{e^x}) and @kbd{L} (natural
logarithm). These can be modified by the @kbd{I} (inverse) and
@kbd{H} (hyperbolic) prefix keys.
Let's compute the sine and cosine of an angle, and verify the
-identity @c{$\sin^2x + \cos^2x = 1$}
-@cite{sin(x)^2 + cos(x)^2 = 1}. We'll
-arbitrarily pick @i{-64} degrees as a good value for @cite{x}. With
-the angular mode set to degrees (type @w{@kbd{m d}}), do:
+identity
+@texline @math{\sin^2x + \cos^2x = 1}.
+@infoline @expr{sin(x)^2 + cos(x)^2 = 1}.
+We'll arbitrarily pick @mathit{-64} degrees as a good value for @expr{x}.
+With the angular mode set to degrees (type @w{@kbd{m d}}), do:
@smallexample
@group
Remember, @kbd{f h} is the @code{calc-hypot}, or square-root of sum
of squares, command.
-Another identity is @c{$\displaystyle\tan x = {\sin x \over \cos x}$}
-@cite{tan(x) = sin(x) / cos(x)}.
+Another identity is
+@texline @math{\displaystyle\tan x = {\sin x \over \cos x}}.
+@infoline @expr{tan(x) = sin(x) / cos(x)}.
@smallexample
@group
@end smallexample
A physical interpretation of this calculation is that if you move
-@cite{0.89879} units downward and @cite{0.43837} units to the right,
-your direction of motion is @i{-64} degrees from horizontal. Suppose
+@expr{0.89879} units downward and @expr{0.43837} units to the right,
+your direction of motion is @mathit{-64} degrees from horizontal. Suppose
we move in the opposite direction, up and to the left:
@smallexample
A similar identity is supposed to hold for hyperbolic sines and cosines,
except that it is the @emph{difference}
-@c{$\cosh^2x - \sinh^2x$}
-@cite{cosh(x)^2 - sinh(x)^2} that always equals one.
-Let's try to verify this identity.@refill
+@texline @math{\cosh^2x - \sinh^2x}
+@infoline @expr{cosh(x)^2 - sinh(x)^2}
+that always equals one. Let's try to verify this identity.
@smallexample
@group
0.99999, reasonably close to 1.
Of course, a more reasonable way to verify the identity is to use
-a more reasonable value for @cite{x}!
+a more reasonable value for @expr{x}!
@cindex Common logarithm
Some Calculator commands use the Hyperbolic prefix for other purposes.
The logarithm and exponential functions, for example, work to the base
-@cite{e} normally but use base-10 instead if you use the Hyperbolic
+@expr{e} normally but use base-10 instead if you use the Hyperbolic
prefix.
@smallexample
Here we first use @kbd{B} to compute the base-10 logarithm, then use
the ``hyperbolic'' exponential as a cheap hack to recover the number
1000, then use @kbd{B} again to compute the natural logarithm. Note
-that @kbd{P} with the hyperbolic prefix pushes the constant @cite{e}
+that @kbd{P} with the hyperbolic prefix pushes the constant @expr{e}
onto the stack.
You may have noticed that both times we took the base-10 logarithm
If you take the factorial of a non-integer, Calc uses a generalized
factorial function defined in terms of Euler's Gamma function
-@c{$\Gamma(n)$}
-@cite{gamma(n)}
+@texline @math{\Gamma(n)}
+@infoline @expr{gamma(n)}
(which is itself available as the @kbd{f g} command).
@smallexample
@end smallexample
@noindent
-Here we verify the identity @c{$n! = \Gamma(n+1)$}
-@cite{@var{n}!@: = gamma(@var{n}+1)}.
+Here we verify the identity
+@texline @math{n! = \Gamma(n+1)}.
+@infoline @expr{@var{n}!@: = gamma(@var{n}+1)}.
-The binomial coefficient @var{n}-choose-@var{m}@c{ or $\displaystyle {n \choose m}$}
-@asis{} is defined by
-@c{$\displaystyle {n! \over m! \, (n-m)!}$}
-@cite{n!@: / m!@: (n-m)!} for all reals @cite{n} and
-@cite{m}. The intermediate results in this formula can become quite
-large even if the final result is small; the @kbd{k c} command computes
-a binomial coefficient in a way that avoids large intermediate
-values.
+The binomial coefficient @var{n}-choose-@var{m}
+@texline or @math{\displaystyle {n \choose m}}
+is defined by
+@texline @math{\displaystyle {n! \over m! \, (n-m)!}}
+@infoline @expr{n!@: / m!@: (n-m)!}
+for all reals @expr{n} and @expr{m}. The intermediate results in this
+formula can become quite large even if the final result is small; the
+@kbd{k c} command computes a binomial coefficient in a way that avoids
+large intermediate values.
The @kbd{k} prefix key defines several common functions out of
combinatorics and number theory. Here we compute the binomial
@cindex Dot product
The dot product of two vectors is equal to the product of their
lengths times the cosine of the angle between them. (Here the vector
-is interpreted as a line from the origin @cite{(0,0,0)} to the
+is interpreted as a line from the origin @expr{(0,0,0)} to the
specified point in three-dimensional space.) The @kbd{A}
(absolute value) command can be used to compute the length of a
vector.
When two matrices are multiplied, the lefthand matrix must have
the same number of columns as the righthand matrix has rows.
-Row @cite{i}, column @cite{j} of the result is effectively the
-dot product of row @cite{i} of the left matrix by column @cite{j}
+Row @expr{i}, column @expr{j} of the result is effectively the
+dot product of row @expr{i} of the left matrix by column @expr{j}
of the right matrix.
If we try to duplicate this matrix and multiply it by itself,
vector.
(@bullet{}) @strong{Exercise 1.} Use @samp{*} to sum along the rows
-of the above @c{$2\times3$}
-@asis{2x3} matrix to get @cite{[6, 15]}. Now use @samp{*} to
-sum along the columns to get @cite{[5, 7, 9]}.
+of the above
+@texline @math{2\times3}
+@infoline 2x3
+matrix to get @expr{[6, 15]}. Now use @samp{*} to sum along the columns
+to get @expr{[5, 7, 9]}.
@xref{Matrix Answer 1, 1}. (@bullet{})
@cindex Identity matrix
@end smallexample
@noindent
-The result is the @cite{[a, b, c]} vector that solves the equations.
+The result is the @expr{[a, b, c]} vector that solves the equations.
(Dividing by a square matrix is equivalent to multiplying by its
inverse.)
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 @c{$N\times1$}
-@asis{Nx1} or @c{$1\times N$}
-@asis{1xN} matrices instead.
-In this case, you would enter the original column vector as
-@samp{[[6], [2], [3]]} or @samp{[6; 2; 3]}.
+vectors, use explicit
+@texline @math{N\times1}
+@infoline Nx1
+or
+@texline @math{1\times N}
+@infoline 1xN
+matrices instead. In this case, you would enter the original column
+vector as @samp{[[6], [2], [3]]} or @samp{[6; 2; 3]}.
(@bullet{}) @strong{Exercise 2.} Algebraic entry allows you to make
vectors and matrices that include variables. Solve the following
-system of equations to get expressions for @cite{x} and @cite{y}
-in terms of @cite{a} and @cite{b}.
+system of equations to get expressions for @expr{x} and @expr{y}
+in terms of @expr{a} and @expr{b}.
@ifinfo
@group
there are no values for the variables that will satisfy all the
equations at once, but it is still useful to find a set of values
which ``nearly'' satisfy all the equations. In terms of matrix equations,
-you can't solve @cite{A X = B} directly because the matrix @cite{A}
+you can't solve @expr{A X = B} directly because the matrix @expr{A}
is not square for an over-determined system. Matrix inversion works
only for square matrices. One common trick is to multiply both sides
-on the left by the transpose of @cite{A}:
+on the left by the transpose of @expr{A}:
@ifinfo
@samp{trn(A)*A*X = trn(A)*B}.
@end ifinfo
\turnoffactive
$A^T A \, X = A^T B$, where $A^T$ is the transpose \samp{trn(A)}.
@end tex
-Now @c{$A^T A$}
-@cite{trn(A)*A} is a square matrix so a solution is possible. It
-turns out that the @cite{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 equations. Use Calc to solve the following
-over-determined system:@refill
+Now
+@texline @math{A^T A}
+@infoline @expr{trn(A)*A}
+is a square matrix so a solution is possible. It turns out that the
+@expr{X} vector you compute in this way will be a ``least-squares''
+solution, which can be regarded as the ``closest'' solution to the set
+of equations. Use Calc to solve the following over-determined
+system:
@ifinfo
@group
of each element.
(@bullet{}) @strong{Exercise 1.} Compute a vector of powers of two
-from @c{$2^{-4}$}
-@cite{2^-4} to @cite{2^4}. @xref{List Answer 1, 1}. (@bullet{})
+from
+@texline @math{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.
For example, reducing @samp{*} computes the product of all the
@noindent
If you are reading this tutorial in printed form, you will find it
-easiest to press @kbd{M-# i} to enter the on-line Info version of
+easiest to press @kbd{C-x * i} to enter the on-line Info version of
the manual and find this table there. (Press @kbd{g}, then type
@kbd{List Tutorial}, to jump straight to this section.)
Position the cursor at the upper-left corner of this table, just
-to the left of the @cite{1.34}. Press @kbd{C-@@} to set the mark.
+to the left of the @expr{1.34}. Press @kbd{C-@@} to set the mark.
(On your system this may be @kbd{C-2}, @kbd{C-@key{SPC}}, or @kbd{NUL}.)
-Now position the cursor to the lower-right, just after the @cite{1.354}.
+Now position the cursor to the lower-right, just after the @expr{1.354}.
You have now defined this region as an Emacs ``rectangle.'' Still
-in the Info buffer, type @kbd{M-# r}. This command
+in the Info buffer, type @kbd{C-x * r}. This command
(@code{calc-grab-rectangle}) will pop you back into the Calculator, with
-the contents of the rectangle you specified in the form of a matrix.@refill
+the contents of the rectangle you specified in the form of a matrix.
@smallexample
@group
(Recall that @kbd{t 2} is a variant of @kbd{s 2} that removes the
stored value from the stack.)
-In a least squares fit, the slope @cite{m} is given by the formula
+In a least squares fit, the slope @expr{m} is given by the formula
@ifinfo
@example
@end tex
@noindent
-where @c{$\sum x$}
-@cite{sum(x)} represents the sum of all the values of @cite{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 this formula uses.
+where
+@texline @math{\sum x}
+@infoline @expr{sum(x)}
+represents the sum of all the values of @expr{x}. While there is an
+actual @code{sum} function in Calc, it's easier to sum a vector using a
+simple reduction. First, let's compute the four different sums that
+this formula uses.
@smallexample
@group
$\sum x y$.)
@end tex
-Finally, we also need @cite{N}, the number of data points. This is just
+Finally, we also need @expr{N}, the number of data points. This is just
the length of either of our lists.
@smallexample
@end group
@end smallexample
-That gives us the slope @cite{m}. The y-intercept @cite{b} can now
+That gives us the slope @expr{m}. The y-intercept @expr{b} can now
be found with the simple formula,
@ifinfo
@end group
@end smallexample
-Let's ``plot'' this straight line approximation, @c{$y \approx m x + b$}
-@cite{m x + b}, and compare it with the original data.@refill
+Let's ``plot'' this straight line approximation,
+@texline @math{y \approx m x + b},
+@infoline @expr{m x + b},
+and compare it with the original data.
@smallexample
@group
common operations from vector algebra. As far as Calc is concerned,
we've just been doing geometry in 19-dimensional space!
-We can subtract this vector from our original @cite{y} vector to get
+We can subtract this vector from our original @expr{y} vector to get
a feel for the error of our fit. Let's find the maximum error:
@smallexample
If your system has the GNUPLOT program, you can see graphs of your
data and your straight line to see how well they match. (If you have
-GNUPLOT 3.0, the following instructions will work regardless of the
-kind of display you have. Some GNUPLOT 2.0, non-X-windows systems
+GNUPLOT 3.0 or higher, the following instructions will work regardless
+of the kind of display you have. Some GNUPLOT 2.0, non-X-windows systems
may require additional steps to view the graphs.)
Let's start by plotting the original data. Recall the ``@var{x}'' and ``@var{y}''
display the graph in Emacs itself using rough character graphics.
Press @kbd{q} when you are done viewing the character graphics.
-Next, let's add the line we got from our least-squares fit:
+Next, let's add the line we got from our least-squares fit.
+@ifinfo
+(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}.)
+@end ifinfo
@smallexample
@group
(@bullet{}) @strong{Exercise 2.} An earlier exercise showed how to do
least squares fitting to a general system of equations. Our 19 data
-points are really 19 equations of the form @cite{y_i = m x_i + b} for
-different pairs of @cite{(x_i,y_i)}. Use the matrix-transpose method
-to solve for @cite{m} and @cite{b}, duplicating the above result.
+points are really 19 equations of the form @expr{y_i = m x_i + b} for
+different pairs of @expr{(x_i,y_i)}. Use the matrix-transpose method
+to solve for @expr{m} and @expr{b}, duplicating the above result.
@xref{List Answer 2, 2}. (@bullet{})
@cindex Geometric mean
(@bullet{}) @strong{Exercise 3.} If the input data do not form a
-rectangle, you can use @w{@kbd{M-# g}} (@code{calc-grab-region})
+rectangle, you can use @w{@kbd{C-x * g}} (@code{calc-grab-region})
to grab the data the way Emacs normally works with regions---it reads
left-to-right, top-to-bottom, treating line breaks the same as spaces.
Use this command to find the geometric mean of the following numbers.
@end example
@noindent
-The @kbd{M-# g} command accepts numbers separated by spaces or commas,
+The @kbd{C-x * g} command accepts numbers separated by spaces or commas,
with or without surrounding vector brackets.
@xref{List Answer 3, 3}. (@bullet{})
@var{n}-choose-0 minus @var{n}-choose-1 plus @var{n}-choose-2, and so
on up to @var{n}-choose-@var{n},
always comes out to zero. Let's verify this
-for @cite{n=6}.@refill
+for @expr{n=6}.
@end ifinfo
@tex
As another example, a theorem about binomial coefficients tells
and @kbd{v c} instead delete one row, column, or vector element.
@cindex Divisor functions
-(@bullet{}) @strong{Exercise 4.} The @cite{k}th @dfn{divisor function}
+(@bullet{}) @strong{Exercise 4.} The @expr{k}th @dfn{divisor function}
@tex
$\sigma_k(n)$
@end tex
-is the sum of the @cite{k}th powers of all the divisors of an
-integer @cite{n}. Figure out a method for computing the divisor
-function for reasonably small values of @cite{n}. As a test,
+is the sum of the @expr{k}th powers of all the divisors of an
+integer @expr{n}. Figure out a method for computing the divisor
+function for reasonably small values of @expr{n}. As a test,
the 0th and 1st divisor functions of 30 are 8 and 72, respectively.
@xref{List Answer 4, 4}. (@bullet{})
@cindex Maximizing a function over a list of values
@c [fix-ref Numerical Solutions]
(@bullet{}) @strong{Exercise 8.} Compute a list of values of Bessel's
-@c{$J_1(x)$}
-@cite{J1} function @samp{besJ(1,x)} for @cite{x} from 0 to 5
-in steps of 0.25.
-Find the value of @cite{x} (from among the above set of values) for
+@texline @math{J_1(x)}
+@infoline @expr{J1}
+function @samp{besJ(1,x)} for @expr{x} from 0 to 5 in steps of 0.25.
+Find the value of @expr{x} (from among the above set of values) for
which @samp{besJ(1,x)} is a maximum. Use an ``automatic'' method,
i.e., just reading along the list by hand to find the largest value
is not allowed! (There is an @kbd{a X} command which does this kind
of thing automatically; @pxref{Numerical Solutions}.)
-@xref{List Answer 8, 8}. (@bullet{})@refill
+@xref{List Answer 8, 8}. (@bullet{})
@cindex Digits, vectors of
(@bullet{}) @strong{Exercise 9.} You are given an integer in the range
-@c{$0 \le N < 10^m$}
-@cite{0 <= N < 10^m} for @cite{m=12} (i.e., an integer of less than
-twelve digits). Convert this integer into a vector of @cite{m}
+@texline @math{0 \le N < 10^m}
+@infoline @expr{0 <= N < 10^m}
+for @expr{m=12} (i.e., an integer of less than
+twelve digits). Convert this integer into a vector of @expr{m}
digits, each in the range from 0 to 9. In vector-of-digits notation,
-add one to this integer to produce a vector of @cite{m+1} digits
+add one to this integer to produce a vector of @expr{m+1} digits
(since there could be a carry out of the most significant digit).
Convert this vector back into a regular integer. A good integer
to try is 25129925999. @xref{List Answer 9, 9}. (@bullet{})
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 @c{$\pi$}
-@cite{pi}. The area of the @c{$2\times2$}
-@asis{2x2} square that encloses that
-circle is 4. So if we throw @var{n} darts at random points in the square,
-about @c{$\pi/4$}
-@cite{pi/4} of them will land inside the circle. This gives us
-an entertaining way to estimate the value of @c{$\pi$}
-@cite{pi}. The @w{@kbd{k r}}
+is @cpi{}. The area of the
+@texline @math{2\times2}
+@infoline 2x2
+square that encloses that circle is 4. So if we throw @var{n} darts at
+random points in the square, about @cpiover{4} of them will land inside
+the circle. This gives us an entertaining way to estimate the value of
+@cpi{}. The @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 @i{-1} and 1 by typing
-@w{@kbd{2.0 k r 1 -}}. Build a vector of 100 random @cite{(x,y)} points in
+We could get a random floating-point number between @mathit{-1} and 1 by typing
+@w{@kbd{2.0 k r 1 -}}. Build a vector of 100 random @expr{(x,y)} points in
this square, then use vector mapping and reduction to count how many
points lie inside the unit circle. Hint: Use the @kbd{v b} command.
@xref{List Answer 11, 11}. (@bullet{})
@cindex Matchstick problem
(@bullet{}) @strong{Exercise 12.} The @dfn{matchstick problem} provides
-another way to calculate @c{$\pi$}
-@cite{pi}. Say you have an infinite field
+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 @c{$2/\pi$}
-@cite{2/pi}. Toss 100 matchsticks to estimate
-@c{$\pi$}
-@cite{pi}. (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 @c{$6/\pi^2$}
-@cite{6/pi^2}.
-That provides yet another way to estimate @c{$\pi$}
-@cite{pi}.)
+a line turns out to be
+@texline @math{2/\pi}.
+@infoline @expr{2/pi}.
+Toss 100 matchsticks to estimate @cpi{}. (If you want still more fun,
+the probability that the GCD (@w{@kbd{k g}}) of two large integers is
+one turns out to be
+@texline @math{6/\pi^2}.
+@infoline @expr{6/pi^2}.
+That provides yet another way to estimate @cpi{}.)
@xref{List Answer 12, 12}. (@bullet{})
(@bullet{}) @strong{Exercise 13.} An algebraic entry of a string in
double-quote marks, @samp{"hello"}, creates a vector of the numerical
-(ASCII) codes of the characters (here, @cite{[104, 101, 108, 108, 111]}).
+(ASCII) codes of the characters (here, @expr{[104, 101, 108, 108, 111]}).
Sometimes it is convenient to compute a @dfn{hash code} of a string,
which is just an integer that represents the value of that string.
Two equal strings have the same hash code; two different strings
any given name because it has sorted the functions into ``buckets'' by
their hash codes. Sometimes a few names will hash into the same bucket,
but it is easier to search among a few names than among all the names.)
-One popular hash function is computed as follows: First set @cite{h = 0}.
-Then, for each character from the string in turn, set @cite{h = 3h + c_i}
-where @cite{c_i} is the character's ASCII code. If we have 511 buckets,
+One popular hash function is computed as follows: First set @expr{h = 0}.
+Then, for each character from the string in turn, set @expr{h = 3h + c_i}
+where @expr{c_i} is the character's ASCII code. If we have 511 buckets,
we then take the hash code modulo 511 to get the bucket number. Develop a
simple command or commands for converting string vectors into hash codes.
The hash code for @samp{"Testing, 1, 2, 3"} is 1960915098, which modulo
function you give to the starting value 0, 1, 2, up to @var{n} times
and returns a vector of the results. Use this command to create a
``random walk'' of 50 steps. Start with the two-dimensional point
-@cite{(0,0)}; then take one step a random distance between @i{-1} and 1
-in both @cite{x} and @cite{y}; then take another step, and so on. Use the
+@expr{(0,0)}; then take one step a random distance between @mathit{-1} and 1
+in both @expr{x} and @expr{y}; then take another step, and so on. Use the
@kbd{g f} command to display this random walk. Now modify your random
walk to walk a unit distance, but in a random direction, at each step.
(Hint: The @code{sincos} function returns a vector of the cosine and
(@bullet{}) @strong{Exercise 1.} A calculation has produced the
result 1.26508260337. You suspect it is the square root of the
-product of @c{$\pi$}
-@cite{pi} and some rational number. Is it? (Be sure
+product of @cpi{} and some rational number. Is it? (Be sure
to allow for roundoff error!) @xref{Types Answer 1, 1}. (@bullet{})
@dfn{Complex numbers} can be stored in both rectangular and polar form.
@end smallexample
@noindent
-The square root of @i{-9} is by default rendered in rectangular form
-(@w{@cite{0 + 3i}}), but we can convert it to polar form (3 with a
+The square root of @mathit{-9} is by default rendered in rectangular form
+(@w{@expr{0 + 3i}}), but we can convert it to polar form (3 with a
phase angle of 90 degrees). All the usual arithmetic and scientific
operations are defined on both types of complex numbers.
@noindent
Since infinity is infinitely large, multiplying it by any finite
-number (like @i{-17}) has no effect, except that since @i{-17}
+number (like @mathit{-17}) has no effect, except that since @mathit{-17}
is negative, it changes a plus infinity to a minus infinity.
-(``A huge positive number, multiplied by @i{-17}, yields a huge
+(``A huge positive number, multiplied by @mathit{-17}, yields a huge
negative number.'') Adding any finite number to infinity also
leaves it unchanged. Taking an absolute value gives us plus
infinity again. Finally, we add this plus infinity to the minus
infinity we had earlier. If you work it out, you might expect
-the answer to be @i{-72} for this. But the 72 has been completely
+the answer to be @mathit{-72} for this. But the 72 has been completely
lost next to the infinities; by the time we compute @w{@samp{inf - inf}}
the finite difference between them, if any, is undetectable.
So we say the result is @dfn{indeterminate}, which Calc writes
Dividing by zero is normally treated as an error, but you can get
Calc to write an answer in terms of infinity by pressing @kbd{m i}
-to turn on ``infinite mode.''
+to turn on Infinite mode.
@smallexample
@group
Dividing by zero normally is left unevaluated, but after @kbd{m i}
it instead gives an infinite result. The answer is actually
@code{uinf}, ``undirected infinity.'' If you look at a graph of
-@cite{1 / x} around @w{@cite{x = 0}}, you'll see that it goes toward
+@expr{1 / x} around @w{@expr{x = 0}}, you'll see that it goes toward
plus infinity as you approach zero from above, but toward minus
-infinity as you approach from below. Since we said only @cite{1 / 0},
+infinity as you approach from below. Since we said only @expr{1 / 0},
Calc knows that the answer is infinite but not in which direction.
That's what @code{uinf} means. Notice that multiplying @code{uinf}
by a negative number still leaves plain @code{uinf}; there's no
@cindex Torus, volume of
(@bullet{}) @strong{Exercise 7.} The volume of a torus (a donut shape) is
-@c{$2 \pi^2 R r^2$}
-@w{@cite{2 pi^2 R r^2}} where @cite{R} is the radius of the circle that
-defines the center of the tube and @cite{r} is the radius of the tube
-itself. Suppose @cite{R} is 20 cm and @cite{r} is 4 cm, each known to
+@texline @math{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
within 5 percent. What is the volume and the relative uncertainty of
the volume? @xref{Types Answer 7, 7}. (@bullet{})
@end smallexample
@noindent
-In this last step, Calc has found a new number which, when multiplied
-by 5 modulo 24, produces the original number, 21. If @var{m} is prime
-it is always possible to find such a number. For non-prime @var{m}
-like 24, it is only sometimes possible.
+In this last step, Calc has divided by 5 modulo 24; i.e., it has found a
+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.
@smallexample
@group
@cindex Fermat, primality test of
(@bullet{}) @strong{Exercise 10.} A theorem of Pierre de Fermat
-says that @c{\w{$x^{n-1} \bmod n = 1$}}
-@cite{x^(n-1) mod n = 1} if @cite{n} is a prime number
-and @cite{x} is an integer less than @cite{n}. If @cite{n} is
-@emph{not} a prime number, this will @emph{not} be true for most
-values of @cite{x}. Thus we can test informally if a number is
-prime by trying this formula for several values of @cite{x}.
-Use this test to tell whether the following numbers are prime:
-811749613, 15485863. @xref{Types Answer 10, 10}. (@bullet{})
+says that
+@texline @w{@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
+@emph{not} be true for most values of @expr{x}. Thus we can test
+informally if a number is prime by trying this formula for several
+values of @expr{x}. Use this test to tell whether the following numbers
+are prime: 811749613, 15485863. @xref{Types Answer 10, 10}. (@bullet{})
It is possible to use HMS forms as parts of error forms, intervals,
modulo forms, or as the phase part of a polar complex number.
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 @c{$\pi \times 10^7$}
-@w{@cite{pi * 10^7}} seconds. What time will it be that
-many seconds from right now? @xref{Types Answer 11, 11}. (@bullet{})
+is about
+@texline @math{\pi \times 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{})
(@bullet{}) @strong{Exercise 12.} You are preparing to order packaging
for the CD release of the Extended Disco Version of @emph{Abbey Road}.
@end smallexample
To see a complete list of built-in units, type @kbd{u v}. Press
-@w{@kbd{M-# c}} again to re-enter the Calculator when you're done looking
+@w{@kbd{C-x * c}} again to re-enter the Calculator when you're done looking
at the units table.
(@bullet{}) @strong{Exercise 13.} How many seconds are there really
@subsection Basic Algebra
@noindent
-If you enter a formula in algebraic mode that refers to variables,
+If you enter a formula in Algebraic mode that refers to variables,
the formula itself is pushed onto the stack. You can manipulate
formulas as regular data objects.
@noindent
First we ``expand'' using the distributive law, then we ``collect''
-terms involving like powers of @cite{x}.
+terms involving like powers of @expr{x}.
-Let's find the value of this expression when @cite{x} is 2 and @cite{y}
+Let's find the value of this expression when @expr{x} is 2 and @expr{y}
is one-half.
@smallexample
properly.)
@cindex Maximum of a function using Calculus
-Let's find the maximum value of our original expression when @cite{y}
-is one-half and @cite{x} ranges over all possible values. We can
-do this by taking the derivative with respect to @cite{x} and examining
-values of @cite{x} for which the derivative is zero. If the second
-derivative of the function at that value of @cite{x} is negative,
+Let's find the maximum value of our original expression when @expr{y}
+is one-half and @expr{x} ranges over all possible values. We can
+do this by taking the derivative with respect to @expr{x} and examining
+values of @expr{x} for which the derivative is zero. If the second
+derivative of the function at that value of @expr{x} is negative,
the function has a local maximum there.
@smallexample
@end smallexample
@noindent
-Well, the derivative is clearly zero when @cite{x} is zero. To find
-the other root(s), let's divide through by @cite{x} and then solve:
+Well, the derivative is clearly zero when @expr{x} is zero. To find
+the other root(s), let's divide through by @expr{x} and then solve:
@smallexample
@group
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 @cite{x}:
+Now we compute the second derivative and plug in our values of @expr{x}:
@smallexample
@group
@noindent
The first of these second derivatives is negative, so we know the function
-has a maximum value at @cite{x = 1.19023}. (The function also has a
-local @emph{minimum} at @cite{x = 0}.)
+has a maximum value at @expr{x = 1.19023}. (The function also has a
+local @emph{minimum} at @expr{x = 0}.)
-When we solved for @cite{x}, we got only one value even though
-@cite{34 - 24 x^2 = 0} is a quadratic equation that ought to have
+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
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 @cite{+}.
+arbitrary sign (as occurs in the quadratic formula) it picks @expr{+}.
If it needs an arbitrary integer, it picks zero. We can get a full
solution by pressing @kbd{H} (the Hyperbolic flag) before @kbd{a S}.
@noindent
Calc has invented the variable @samp{s1} to represent an unknown sign;
-it is supposed to be either @i{+1} or @i{-1}. Here we have used
+it is supposed to be either @mathit{+1} or @mathit{-1}. Here we have used
the ``let'' command to evaluate the expression when the sign is negative.
If we plugged this into our second derivative we would get the same,
-negative, answer, so @cite{x = -1.19023} is also a maximum.
+negative, answer, so @expr{x = -1.19023} is also a maximum.
-To find the actual maximum value, we must plug our two values of @cite{x}
+To find the actual maximum value, we must plug our two values of @expr{x}
into the original formula.
@smallexample
@w{@kbd{H a S}} and returns a vector of all the solutions. It simply
automates the job we just did by hand. Applied to our original
cubic polynomial, it would produce the vector of solutions
-@cite{[1.19023, -1.19023, 0]}. (There is also an @kbd{a X} command
+@expr{[1.19023, -1.19023, 0]}. (There is also an @kbd{a X} command
which finds a local maximum of a function. It uses a numerical search
method rather than examining the derivatives, and thus requires you
to provide some kind of initial guess to show it where to look.)
multiple; choose the solution where the leading coefficient is one.)
@xref{Algebra Answer 2, 2}. (@bullet{})
-The @kbd{m s} command enables ``symbolic mode,'' in which formulas
+The @kbd{m s} command enables Symbolic mode, in which formulas
like @samp{sqrt(5)} that can't be evaluated exactly are left in
symbolic form rather than giving a floating-point approximate answer.
Fraction mode (@kbd{m f}) is also useful when doing algebra.
@end group
@end smallexample
-One more mode that makes reading formulas easier is ``Big mode.''
+One more mode that makes reading formulas easier is Big mode.
@smallexample
@group
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, and @TeX{} mode.
+language modes as well, such as C mode, FORTRAN mode, @TeX{} mode
+and La@TeX{} mode.
@smallexample
@group
are shown in normal mode.)
@cindex Area under a curve
-What is the area under the portion of this curve from @cite{x = 1} to @cite{2}?
+What is the area under the portion of this curve from @expr{x = 1} to @expr{2}?
This is simply the integral of the function:
@smallexample
@end smallexample
@noindent
-We want to evaluate this at our two values for @cite{x} and subtract.
+We want to evaluate this at our two values for @expr{x} and subtract.
One way to do it is again with vector mapping and reduction:
@smallexample
@end group
@end smallexample
-(@bullet{}) @strong{Exercise 3.} Find the integral from 1 to @cite{y}
-of @c{$x \sin \pi x$}
-@w{@cite{x sin(pi x)}} (where the sine is calculated in radians).
-Find the values of the integral for integers @cite{y} from 1 to 5.
-@xref{Algebra Answer 3, 3}. (@bullet{})
+(@bullet{}) @strong{Exercise 3.} Find the integral from 1 to @expr{y}
+of
+@texline @math{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 @c{$\sin x \ln x$}
-@cite{sin(x) ln(x)} over the same range of @cite{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 closed-form solution to this integral.
-Now what do we do?
+under the curve
+@texline @math{\sin x \ln x}
+@infoline @expr{sin(x) ln(x)}
+over the same range of @expr{x}. If you entered this formula and typed
+@kbd{a i x @key{RET}} (don't bother to try this), Calc would work for a
+long time but would be unable to find a solution. In fact, there is no
+closed-form solution to this integral. Now what do we do?
@cindex Integration, numerical
@cindex Numerical integration
@noindent
(If you got wildly different results, did you remember to switch
-to radians mode?)
+to Radians mode?)
Here we have divided the curve into ten segments of equal width;
approximating these segments as rectangular boxes (i.e., assuming
@noindent
Here we have computed the Taylor series expansion of the function
-about the point @cite{x=1}. We can now integrate this polynomial
+about the point @expr{x=1}. We can now integrate this polynomial
approximation, since polynomials are easy to integrate.
@smallexample
in the Taylor series, we can get a result as accurate as we like.
(Taylor series converge better away from singularities in the
function such as the one at @code{ln(0)}, so it would also help to
-expand the series about the points @cite{x=2} or @cite{x=1.5} instead
-of @cite{x=1}.)
+expand the series about the points @expr{x=2} or @expr{x=1.5} instead
+of @expr{x=1}.)
@cindex Simpson's rule
@cindex Integration by Simpson's rule
@end tex
@noindent
-where @cite{n} (which must be even) is the number of slices and @cite{h}
+where @expr{n} (which must be even) is the number of slices and @expr{h}
is the width of each slice. These are 10 and 0.1 in our example.
For reference, here is the corresponding formula for the stairstep
method:
\afterdisplay
@end tex
-Compute the integral from 1 to 2 of @c{$\sin x \ln x$}
-@cite{sin(x) ln(x)} using
-Simpson's rule with 10 slices. @xref{Algebra Answer 4, 4}. (@bullet{})
+Compute the integral from 1 to 2 of
+@texline @math{\sin x \ln x}
+@infoline @expr{sin(x) ln(x)}
+using Simpson's rule with 10 slices.
+@xref{Algebra Answer 4, 4}. (@bullet{})
Calc has a built-in @kbd{a I} command for doing numerical integration.
It uses @dfn{Romberg's method}, which is a more sophisticated cousin
@end smallexample
To edit a variable, type @kbd{s e} and the variable name, use regular
-Emacs editing commands as necessary, then type @kbd{M-# M-#} or
-@kbd{C-c C-c} to store the edited value back into the variable.
+Emacs editing commands as necessary, then type @kbd{C-c C-c} to store
+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''
another good reason to store your rules in variables rather than
entering them on the fly.
-(@bullet{}) @strong{Exercise 1.} Type @kbd{m s} to get symbolic
+(@bullet{}) @strong{Exercise 1.} Type @kbd{m s} to get Symbolic
mode, then enter the formula @samp{@w{(2 + sqrt(2))} / @w{(1 + sqrt(2))}}.
-Using a rewrite rule, simplify this formula by multiplying both
-sides by the conjugate @w{@samp{1 - sqrt(2)}}. The result will have
+Using a rewrite rule, simplify this formula by multiplying the top and
+bottom by the conjugate @w{@samp{1 - sqrt(2)}}. The result will have
to be expanded by the distributive law; do this with another
rewrite. @xref{Rewrites Answer 1, 1}. (@bullet{})
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
-only when the fifth argument is literally @samp{e}!@refill
+only when the fifth argument is literally @samp{e}!
@cindex Fibonacci numbers
@ignore
@samp{opt(a) + opt(b) x := f(a, b, x)}. What happened?
@xref{Rewrites Answer 3, 3}. (@bullet{})
-(@bullet{}) @strong{Exercise 4.} Starting with a positive integer @cite{a},
-divide @cite{a} by two if it is even, otherwise compute @cite{3 a + 1}.
+(@bullet{}) @strong{Exercise 4.} Starting with a positive integer @expr{a},
+divide @expr{a} by two if it is even, otherwise compute @expr{3 a + 1}.
Now repeat this step over and over. A famous unproved conjecture
-is that for any starting @cite{a}, the sequence always eventually
+is that for any starting @expr{a}, the sequence always eventually
reaches 1. Given the formula @samp{seq(@var{a}, 0)}, write a set of
rules that convert this into @samp{seq(1, @var{n})} where @var{n}
is the number of steps it took the sequence to reach the value 1.
Now make the result be a vector of values in the sequence, from @var{a}
to 1. (The formula @samp{@var{x}|@var{y}} appends the vectors @var{x}
and @var{y}.) For example, rewriting @samp{seq(6)} should yield the
-vector @cite{[6, 3, 10, 5, 16, 8, 4, 2, 1]}.
+vector @expr{[6, 3, 10, 5, 16, 8, 4, 2, 1]}.
@xref{Rewrites Answer 4, 4}. (@bullet{})
(@bullet{}) @strong{Exercise 5.} Define, using rewrite rules, a function
@samp{nterms(@var{x})} that returns the number of terms in the sum
@var{x}, or 1 if @var{x} is not a sum. (A @dfn{sum} for our purposes
is one or more non-sum terms separated by @samp{+} or @samp{-} signs,
-so that @cite{2 - 3 (x + y) + x y} is a sum of three terms.)
+so that @expr{2 - 3 (x + y) + x y} is a sum of three terms.)
@xref{Rewrites Answer 5, 5}. (@bullet{})
-(@bullet{}) @strong{Exercise 6.} Calc considers the form @cite{0^0}
-to be ``indeterminate,'' and leaves it unevaluated (assuming infinite
-mode is not enabled). Some people prefer to define @cite{0^0 = 1},
-so that the identity @cite{x^0 = 1} can safely be used for all @cite{x}.
-Find a way to make Calc follow this convention. What happens if you
-now type @kbd{m i} to turn on infinite mode?
-@xref{Rewrites Answer 6, 6}. (@bullet{})
-
-(@bullet{}) @strong{Exercise 7.} A Taylor series for a function is an
+(@bullet{}) @strong{Exercise 6.} A Taylor series for a function is an
infinite series that exactly equals the value of that function at
-values of @cite{x} near zero.
+values of @expr{x} near zero.
@ifinfo
@example
@end example
@end ifinfo
@tex
-\turnoffactive \let\rm\goodrm
+\turnoffactive
\beforedisplay
$$ \cos x = 1 - {x^2 \over 2!} + {x^4 \over 4!} - {x^6 \over 6!} + \cdots $$
\afterdisplay
@end tex
The @kbd{a t} command produces a @dfn{truncated Taylor series} which
-is obtained by dropping all the terms higher than, say, @cite{x^2}.
-Calc represents the truncated Taylor series as a polynomial in @cite{x}.
+is obtained by dropping all the terms higher than, say, @expr{x^2}.
+Calc represents the truncated Taylor series as a polynomial in @expr{x}.
Mathematicians often write a truncated series using a ``big-O'' notation
that records what was the lowest term that was truncated.
@end example
@end ifinfo
@tex
-\turnoffactive \let\rm\goodrm
+\turnoffactive
\beforedisplay
$$ \cos x = 1 - {x^2 \over 2!} + O(x^3) $$
\afterdisplay
@end tex
@noindent
-The meaning of @cite{O(x^3)} is ``a quantity which is negligibly small
-if @cite{x^3} is considered negligibly small as @cite{x} goes to zero.''
+The meaning of @expr{O(x^3)} is ``a quantity which is negligibly small
+if @expr{x^3} is considered negligibly small as @expr{x} goes to zero.''
The exercise is to create rewrite rules that simplify sums and products of
power series represented as @samp{@var{polynomial} + O(@var{var}^@var{n})}.
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 7, 7}. (@bullet{})
+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
+a nasty surprise when you use Calc to balance your checkbook!)
-@c [fix-ref Rewrite Rules]
@xref{Rewrite Rules}, for the whole story on rewrite rules.
@node Programming Tutorial, Answers to Exercises, Algebra Tutorial, Tutorial
all you want to do is define a new function or repeat a command a few
times. Calc has features that allow you to do these things easily.
-(Note that the programming commands relating to user-defined keys
-are not yet supported under Lucid Emacs 19.)
-
One very limited form of programming is defining your own functions.
Calc's @kbd{Z F} command allows you to define a function name and
key sequence to correspond to any formula. Programming commands use
@end ignore
@tindex Si
(@bullet{}) @strong{Exercise 1.} The ``sine integral'' function
-@c{${\rm Si}(x)$}
-@cite{Si(x)} is defined as the integral of @samp{sin(t)/t} for
-@cite{t = 0} to @cite{x} in radians. (It was invented because this
+@texline @math{{\rm Si}(x)}
+@infoline @expr{Si(x)}
+is defined as the integral of @samp{sin(t)/t} for
+@expr{t = 0} to @expr{x} in radians. (It was invented because this
integral has no solution in terms of basic functions; if you give it
to Calc's @kbd{a i} command, it will ponder it for a long time and then
give up.) We can use the numerical integration command, however,
with any integrand @samp{f(t)}. Define a @kbd{z s} command and
@code{Si} function that implement this. You will need to edit the
default argument list a bit. As a test, @samp{Si(1)} should return
-0.946083. (Hint: @code{ninteg} will run a lot faster if you reduce
-the precision to, say, six digits beforehand.)
+0.946083. (If you don't get this answer, you might want to check that
+Calc is in Radians mode. Also, @code{ninteg} will run a lot faster if
+you reduce the precision to, say, six digits beforehand.)
@xref{Programming Answer 1, 1}. (@bullet{})
The simplest way to do real ``programming'' of Emacs is to define a
@enumerate
@item
-Compute @c{$\displaystyle{\sin x \over x}$}
-@cite{sin(x) / x}, where @cite{x} is the number on the
-top of the stack.
+Compute
+@texline @math{\displaystyle{\sin x \over x}},
+@infoline @expr{sin(x) / x},
+where @expr{x} is the number on the top of the stack.
@item
-Compute the base-@cite{b} logarithm, just like the @kbd{B} key except
+Compute the base-@expr{b} logarithm, just like the @kbd{B} key except
the arguments are taken in the opposite order.
@item
@end smallexample
@noindent
-Here we have computed the fourth derivative of @cite{x^6} by
+Here we have computed the fourth derivative of @expr{x^6} by
enclosing a derivative command in a ``repeat loop'' structure.
This structure pops a repeat count from the stack, then
executes the body of the loop that many times.
@cindex Golden ratio
@cindex Phi, golden ratio
-A fascinating property of the Fibonacci numbers is that the @cite{n}th
-Fibonacci number can be found directly by computing @c{$\phi^n / \sqrt{5}$}
-@cite{phi^n / sqrt(5)}
-and then rounding to the nearest integer, where @c{$\phi$ (``phi'')}
-@cite{phi}, the
-``golden ratio,'' is @c{$(1 + \sqrt{5}) / 2$}
-@cite{(1 + sqrt(5)) / 2}. (For convenience, this constant is available
-from the @code{phi} variable, or the @kbd{I H P} command.)
+A fascinating property of the Fibonacci numbers is that the @expr{n}th
+Fibonacci number can be found directly by computing
+@texline @math{\phi^n / \sqrt{5}}
+@infoline @expr{phi^n / sqrt(5)}
+and then rounding to the nearest integer, where
+@texline @math{\phi} (``phi''),
+@infoline @expr{phi},
+the ``golden ratio,'' is
+@texline @math{(1 + \sqrt{5}) / 2}.
+@infoline @expr{(1 + sqrt(5)) / 2}.
+(For convenience, this constant is available from the @code{phi}
+variable, or the @kbd{I H P} command.)
@smallexample
@group
@cindex Continued fractions
(@bullet{}) @strong{Exercise 5.} The @dfn{continued fraction}
-representation of @c{$\phi$}
-@cite{phi} is @c{$1 + 1/(1 + 1/(1 + 1/( \ldots )))$}
-@cite{1 + 1/(1 + 1/(1 + 1/( ...@: )))}.
+representation of
+@texline @math{\phi}
+@infoline @expr{phi}
+is
+@texline @math{1 + 1/(1 + 1/(1 + 1/( \ldots )))}.
+@infoline @expr{1 + 1/(1 + 1/(1 + 1/( ...@: )))}.
We can compute an approximate value by carrying this however far
-and then replacing the innermost @c{$1/( \ldots )$}
-@cite{1/( ...@: )} by 1. Approximate
-@c{$\phi$}
-@cite{phi} using a twenty-term continued fraction.
+and then replacing the innermost
+@texline @math{1/( \ldots )}
+@infoline @expr{1/( ...@: )}
+by 1. Approximate
+@texline @math{\phi}
+@infoline @expr{phi}
+using a twenty-term continued fraction.
@xref{Programming Answer 5, 5}. (@bullet{})
(@bullet{}) @strong{Exercise 6.} Linear recurrences like the one for
Fibonacci numbers can be expressed in terms of matrices. Given a
-vector @w{@cite{[a, b]}} determine a matrix which, when multiplied by this
-vector, produces the vector @cite{[b, c]}, where @cite{a}, @cite{b} and
-@cite{c} are three successive Fibonacci numbers. Now write a program
-that, given an integer @cite{n}, computes the @cite{n}th Fibonacci number
+vector @w{@expr{[a, b]}} determine a matrix which, when multiplied by this
+vector, produces the vector @expr{[b, c]}, where @expr{a}, @expr{b} and
+@expr{c} are three successive Fibonacci numbers. Now write a program
+that, given an integer @expr{n}, computes the @expr{n}th Fibonacci number
using matrix arithmetic. @xref{Programming Answer 6, 6}. (@bullet{})
@cindex Harmonic numbers
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 @c{$\displaystyle{2 n! \over (2 \pi)^n}$}
-@cite{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 @cite{n} since the higher
-Bernoulli numbers are very large fractions.)
+by the formula
+@texline @math{\displaystyle{2 n! \over (2 \pi)^n}}.
+@infoline @expr{2 n!@: / (2 pi)^n}.
+Let's write a keyboard macro to compute (approximate) Bernoulli numbers.
+(Calc has a command, @kbd{k b}, to compute exact Bernoulli numbers, but
+this command is very slow for large @expr{n} since the higher Bernoulli
+numbers are very large fractions.)
@smallexample
@group
Here we take our integer argument modulo 2; this will be nonzero
if we're asking for an odd Bernoulli number.
-The actual tenth Bernoulli number is @cite{5/66}.
+The actual tenth Bernoulli number is @expr{5/66}.
@smallexample
@group
@smallexample
@group
-1: 3 1: 3 Keyboard Macro Editor.
- . . Original keys: 1 @key{RET} 2 +
+1: 3 1: 3 Calc Macro Edit Mode.
+ . . Original keys: 1 <return> 2 +
- type "1\r"
- type "2"
- calc-plus
+ 1 ;; calc digits
+ RET ;; calc-enter
+ 2 ;; calc digits
+ + ;; calc-plus
C-x ( 1 @key{RET} 2 + C-x ) Z K h @key{RET} Z E h
@end group
@end smallexample
@noindent
-This shows the screen display assuming you have the @file{macedit}
-keyboard macro editing package installed, which is usually the case
-since a copy of @file{macedit} comes bundled with Calc.
-
A keyboard macro is stored as a pure keystroke sequence. The
-@file{macedit} package (invoked by @kbd{Z E}) scans along the
+@file{edmacro} package (invoked by @kbd{Z E}) scans along the
macro and tries to decode it back into human-readable steps.
-If a key or keys are simply shorthand for some command with a
-@kbd{M-x} name, that name is shown. Anything that doesn't correspond
-to a @kbd{M-x} command is written as a @samp{type} command.
+Descriptions of the keystrokes are given as comments, which begin with
+@samp{;;}, and which are ignored when the edited macro is saved.
+Spaces and line breaks are also ignored when the edited macro is saved.
+To enter a space into the macro, type @code{SPC}. All the special
+characters @code{RET}, @code{LFD}, @code{TAB}, @code{SPC}, @code{DEL},
+and @code{NUL} must be written in all uppercase, as must the prefixes
+@code{C-} and @code{M-}.
Let's edit in a new definition, for computing harmonic numbers.
-First, erase the three lines of the old definition. Then, type
+First, erase the four lines of the old definition. Then, type
in the new definition (or use Emacs @kbd{M-w} and @kbd{C-y} commands
-to copy it from this page of the Info file; you can skip typing
-the comments that begin with @samp{#}).
+to copy it from this page of the Info file; you can of course skip
+typing the comments, which begin with @samp{;;}).
@smallexample
-calc-kbd-push # Save local values (Z `)
-type "0" # Push a zero
-calc-store-into # Store it in variable 1
-type "1"
-type "1" # Initial value for loop
-calc-roll-down # This is the @key{TAB} key; swap initial & final
-calc-kbd-for # Begin "for" loop...
-calc-inv # Take reciprocal
-calc-store-plus # Add to accumulator
-type "1"
-type "1" # Loop step is 1
-calc-kbd-end-for # End "for" loop
-calc-recall # Now recall final accumulated value
-type "1"
-calc-kbd-pop # Restore values (Z ')
+Z` ;; calc-kbd-push (Save local values)
+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)
+TAB ;; calc-roll-down (Swap initial and final)
+Z( ;; calc-kbd-for (Begin the "for" loop)
+& ;; calc-inv (Take the reciprocal)
+s+ ;; calc-store-plus (Add to the following variable)
+1 ;; calc quick variable (Quick variable q1)
+1 ;; calc digits (The loop step is 1)
+Z) ;; calc-kbd-end-for (End the "for" loop)
+sr ;; calc-recall (Recall the final accumulated value)
+1 ;; calc quick variable (Quick variable q1)
+Z' ;; calc-kbd-pop (Restore values)
@end smallexample
@noindent
-Press @kbd{M-# M-#} to finish editing and return to the Calculator.
+Press @kbd{C-c C-c} to finish editing and return to the Calculator.
@smallexample
@group
@end group
@end smallexample
-If you don't know how to write a particular command in @file{macedit}
-format, you can always write it as keystrokes in a @code{type} command.
-There is also a @code{keys} command which interprets the rest of the
-line as standard Emacs keystroke names. In fact, @file{macedit} 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} (and @kbd{C-x e}) key. Because this is so
-useful, Calc puts this command on the @kbd{M-# m} key. Try reading in
-this macro in the following form: Press @kbd{C-@@} (or @kbd{C-@key{SPC}}) at
-one end of the text below, then type @kbd{M-# m} at the other.
+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}
+(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
+one end of the text below, then type @kbd{C-x * m} at the other.
@example
@group
Z ` 0 t 1
- 1 @key{TAB}
+ 1 TAB
Z ( & s + 1 1 Z )
r 1
Z '
(@bullet{}) @strong{Exercise 8.} A general algorithm for solving
equations numerically is @dfn{Newton's Method}. Given the equation
-@cite{f(x) = 0} for any function @cite{f}, and an initial guess
-@cite{x_0} which is reasonably close to the desired solution, apply
+@expr{f(x) = 0} for any function @expr{f}, and an initial guess
+@expr{x_0} which is reasonably close to the desired solution, apply
this formula over and over:
@ifinfo
@end ifinfo
@tex
\beforedisplay
-$$ x_{\goodrm new} = x - {f(x) \over f'(x)} $$
+$$ x_{\rm new} = x - {f(x) \over f'(x)} $$
\afterdisplay
@end tex
@noindent
-where @cite{f'(x)} is the derivative of @cite{f}. The @cite{x}
+where @expr{f'(x)} is the derivative of @expr{f}. The @expr{x}
values will quickly converge to a solution, i.e., eventually
-@c{$x_{\rm new}$}
-@cite{new_x} and @cite{x} will be equal to within the limits
+@texline @math{x_{\rm new}}
+@infoline @expr{new_x}
+and @expr{x} will be equal to within the limits
of the current precision. Write a program which takes a formula
-involving the variable @cite{x}, and an initial guess @cite{x_0},
-on the stack, and produces a value of @cite{x} for which the formula
-is zero. Use it to find a solution of @c{$\sin(\cos x) = 0.5$}
-@cite{sin(cos(x)) = 0.5}
-near @cite{x = 4.5}. (Use angles measured in radians.) Note that
+involving the variable @expr{x}, and an initial guess @expr{x_0},
+on the stack, and produces a value of @expr{x} for which the formula
+is zero. Use it to find a solution of
+@texline @math{\sin(\cos x) = 0.5}
+@infoline @expr{sin(cos(x)) = 0.5}
+near @expr{x = 4.5}. (Use angles measured in radians.) Note that
the built-in @w{@kbd{a R}} (@code{calc-find-root}) command uses Newton's
method when it is able. @xref{Programming Answer 8, 8}. (@bullet{})
@cindex Digamma function
@cindex Gamma constant, Euler's
@cindex Euler's gamma constant
-(@bullet{}) @strong{Exercise 9.} The @dfn{digamma} function @c{$\psi(z)$ (``psi'')}
-@cite{psi(z)}
-is defined as the derivative of @c{$\ln \Gamma(z)$}
-@cite{ln(gamma(z))}. For large
-values of @cite{z}, it can be approximated by the infinite sum
+(@bullet{}) @strong{Exercise 9.} The @dfn{digamma} function
+@texline @math{\psi(z) (``psi'')}
+@infoline @expr{psi(z)}
+is defined as the derivative of
+@texline @math{\ln \Gamma(z)}.
+@infoline @expr{ln(gamma(z))}.
+For large values of @expr{z}, it can be approximated by the infinite sum
@ifinfo
@example
@end example
@end ifinfo
@tex
-\let\rm\goodrm
\beforedisplay
$$ \psi(z) \approx \ln z - {1\over2z} -
\sum_{n=1}^\infty {\code{bern}(2 n) \over 2 n z^{2n}}
@end tex
@noindent
-where @c{$\sum$}
-@cite{sum} represents the sum over @cite{n} from 1 to infinity
+where
+@texline @math{\sum}
+@infoline @expr{sum}
+represents the sum over @expr{n} from 1 to infinity
(or to some limit high enough to give the desired accuracy), and
the @code{bern} function produces (exact) Bernoulli numbers.
While this sum is not guaranteed to converge, in practice it is safe.
An interesting mathematical constant is Euler's gamma, which is equal
to about 0.5772. One way to compute it is by the formula,
-@c{$\gamma = -\psi(1)$}
-@cite{gamma = -psi(1)}. Unfortunately, 1 isn't a large enough argument
-for the above formula to work (5 is a much safer value for @cite{z}).
-Fortunately, we can compute @c{$\psi(1)$}
-@cite{psi(1)} from @c{$\psi(5)$}
-@cite{psi(5)} using
-the recurrence @c{$\psi(z+1) = \psi(z) + {1 \over z}$}
-@cite{psi(z+1) = psi(z) + 1/z}. Your task: Develop
-a program to compute @c{$\psi(z)$}
-@cite{psi(z)}; it should ``pump up'' @cite{z}
+@texline @math{\gamma = -\psi(1)}.
+@infoline @expr{gamma = -psi(1)}.
+Unfortunately, 1 isn't a large enough argument
+for the above formula to work (5 is a much safer value for @expr{z}).
+Fortunately, we can compute
+@texline @math{\psi(1)}
+@infoline @expr{psi(1)}
+from
+@texline @math{\psi(5)}
+@infoline @expr{psi(5)}
+using the recurrence
+@texline @math{\psi(z+1) = \psi(z) + {1 \over z}}.
+@infoline @expr{psi(z+1) = psi(z) + 1/z}.
+Your task: Develop a program to compute
+@texline @math{\psi(z)};
+@infoline @expr{psi(z)};
+it should ``pump up'' @expr{z}
if necessary to be greater than 5, then use the above summation
formula. Use looping commands to compute the sum. Use your function
-to compute @c{$\gamma$}
-@cite{gamma} to twelve decimal places. (Calc has a built-in command
+to compute
+@texline @math{\gamma}
+@infoline @expr{gamma}
+to twelve decimal places. (Calc has a built-in command
for Euler's constant, @kbd{I P}, which you can use to check your answer.)
@xref{Programming Answer 9, 9}. (@bullet{})
@cindex Polynomial, list of coefficients
-(@bullet{}) @strong{Exercise 10.} Given a polynomial in @cite{x} and
-a number @cite{m} on the stack, where the polynomial is of degree
-@cite{m} or less (i.e., does not have any terms higher than @cite{x^m}),
+(@bullet{}) @strong{Exercise 10.} Given a polynomial in @expr{x} and
+a number @expr{m} on the stack, where the polynomial is of degree
+@expr{m} or less (i.e., does not have any terms higher than @expr{x^m}),
write a program to convert the polynomial into a list-of-coefficients
-notation. For example, @cite{5 x^4 + (x + 1)^2} with @cite{m = 6}
-should produce the list @cite{[1, 2, 1, 0, 5, 0, 0]}. Also develop
+notation. For example, @expr{5 x^4 + (x + 1)^2} with @expr{m = 6}
+should produce the list @expr{[1, 2, 1, 0, 5, 0, 0]}. Also develop
a way to convert from this form back to the standard algebraic form.
@xref{Programming Answer 10, 10}. (@bullet{})
using the @kbd{z s} command to call itself recursively, then assign it
to the same key with @kbd{Z K s}. Now the @kbd{z s} command will run
the complete recursive program. (Another way is to use @w{@kbd{Z E}}
-or @kbd{M-# m} (@code{read-kbd-macro}) to read the whole macro at once,
+or @kbd{C-x * m} (@code{read-kbd-macro}) to read the whole macro at once,
thus avoiding the ``training'' phase.) The task: Write a program
-that computes Stirling numbers of the first kind, given @cite{n} and
-@cite{m} on the stack. Test it with @emph{small} inputs like
-@cite{s(4,2)}. (There is a built-in command for Stirling numbers,
+that computes Stirling numbers of the first kind, given @expr{n} and
+@expr{m} on the stack. Test it with @emph{small} inputs like
+@expr{s(4,2)}. (There is a built-in command for Stirling numbers,
@kbd{k s}, which you can use to check your answers.)
@xref{Programming Answer 11, 11}. (@bullet{})
(@bullet{}) @strong{Exercise 12.} Write another program for
computing Stirling numbers of the first kind, this time using
-rewrite rules. Once again, @cite{n} and @cite{m} should be taken
+rewrite rules. Once again, @expr{n} and @expr{m} should be taken
from the stack. @xref{Programming Answer 12, 12}. (@bullet{})
@example
* Rewrites Answer 3:: Rewriting opt(a) + opt(b) x
* Rewrites Answer 4:: Sequence of integers
* Rewrites Answer 5:: Number of terms in sum
-* Rewrites Answer 6:: Defining 0^0 = 1
-* Rewrites Answer 7:: Truncated Taylor series
+* Rewrites Answer 6:: Truncated Taylor series
* Programming Answer 1:: Fresnel's C(x)
* Programming Answer 2:: Negate third stack element
* Programming Answer 3:: Compute sin(x) / x, etc.
@noindent
@kbd{1 @key{RET} 2 @key{RET} 3 @key{RET} 4 + * -}
-The result is @c{$1 - (2 \times (3 + 4)) = -13$}
-@cite{1 - (2 * (3 + 4)) = -13}.
+The result is
+@texline @math{1 - (2 \times (3 + 4)) = -13}.
+@infoline @expr{1 - (2 * (3 + 4)) = -13}.
@node RPN Answer 2, RPN Answer 3, RPN Answer 1, Answers to Exercises
@subsection RPN Tutorial Exercise 2
@noindent
-@c{$2\times4 + 7\times9.5 + {5\over4} = 75.75$}
-@cite{2*4 + 7*9.5 + 5/4 = 75.75}
+@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 @c{$2\times4 = 8$}
-@cite{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.
+After computing the intermediate term
+@texline @math{2\times4 = 8},
+@infoline @expr{2*4 = 8},
+you can leave that result on the stack while you compute the second
+term. With both of these results waiting on the stack you can then
+compute the final term, then press @kbd{+ +} to add everything up.
@smallexample
@group
Or, RPN style, @kbd{0.5 ^}.
(Actually, @samp{$^1:2}, using the fraction one-half as the power, is
-a closer equivalent, since @samp{9^0.5} yields @cite{3.0} whereas
-@samp{sqrt(9)} and @samp{9^1:2} yield the exact integer @cite{3}.)
+a closer equivalent, since @samp{9^0.5} yields @expr{3.0} whereas
+@samp{sqrt(9)} and @samp{9^1:2} yield the exact integer @expr{3}.)
@node Algebraic Answer 2, Algebraic Answer 3, Algebraic Answer 1, Answers to Exercises
@subsection Algebraic Entry Tutorial Exercise 2
@subsection Algebraic Entry Tutorial Exercise 3
@noindent
-The result from @kbd{1 @key{RET} 0 /} will be the formula @cite{1 / 0}.
+The result from @kbd{1 @key{RET} 0 /} will be the formula @expr{1 / 0}.
The ``function'' @samp{/} cannot be evaluated when its second argument
is zero, so it is left in symbolic form. When you now type @kbd{0 *},
the result will be zero because Calc uses the general rule that ``zero
times anything is zero.''
@c [fix-ref Infinities]
-The @kbd{m i} command enables an @dfn{infinite mode} in which @cite{1 / 0}
+The @kbd{m i} command enables an @dfn{Infinite mode} in which @expr{1 / 0}
results in a special symbol that represents ``infinity.'' If you
multiply infinity by zero, Calc uses another special new symbol to
show that the answer is ``indeterminate.'' @xref{Infinities}, for
@subsection Modes Tutorial Exercise 3
@noindent
-The answer he got was @cite{0.5000000000006399}.
+The answer he got was @expr{0.5000000000006399}.
The problem is not that the square operation is inexact, but that the
sine of 45 that was already on the stack was accurate to only 12 places.
@noindent
Dividing two integers that are larger than the current precision may
give a floating-point result that is inaccurate even when rounded
-down to an integer. Consider @cite{123456789 / 2} when the current
-precision is 6 digits. The true answer is @cite{61728394.5}, but
-with a precision of 6 this will be rounded to @c{$12345700.0/2.0 = 61728500.0$}
-@cite{12345700.@: / 2.@: = 61728500.}.
+down to an integer. Consider @expr{123456789 / 2} when the current
+precision is 6 digits. The true answer is @expr{61728394.5}, but
+with a precision of 6 this will be rounded to
+@texline @math{12345700.0/2.0 = 61728500.0}.
+@infoline @expr{12345700.@: / 2.@: = 61728500.}.
The result, when converted to an integer, will be off by 106.
Here are two solutions: Raise the precision enough that the
floating-point round-off error is strictly to the right of the
-decimal point. Or, convert to fraction mode so that @cite{123456789 / 2}
-produces the exact fraction @cite{123456789:2}, which can be rounded
+decimal point. Or, convert to Fraction mode so that @expr{123456789 / 2}
+produces the exact fraction @expr{123456789:2}, which can be rounded
down by the @kbd{F} command without ever switching to floating-point
format.
@subsection Arithmetic Tutorial Exercise 2
@noindent
-@kbd{27 @key{RET} 9 B} could give the exact result @cite{3:2}, but it
-does a floating-point calculation instead and produces @cite{1.5}.
+@kbd{27 @key{RET} 9 B} could give the exact result @expr{3:2}, but it
+does a floating-point calculation instead and produces @expr{1.5}.
Calc will find an exact result for a logarithm if the result is an integer
-or the reciprocal of an integer. But there is no efficient way to search
-the space of all possible rational numbers for an exact answer, so Calc
-doesn't try.
+or (when in Fraction mode) the reciprocal of an integer. But there is
+no efficient way to search the space of all possible rational numbers
+for an exact answer, so Calc doesn't try.
@node Vector Answer 1, Vector Answer 2, Arithmetic Answer 2, Answers to Exercises
@subsection Vector Tutorial Exercise 1
@end group
@end smallexample
-This can be made more readable using @kbd{d B} to enable ``big'' display
+This can be made more readable using @kbd{d B} to enable Big display
mode:
@smallexample
@end group
@end smallexample
-Type @kbd{d N} to return to ``normal'' display mode afterwards.
+Type @kbd{d N} to return to Normal display mode afterwards.
@node Matrix Answer 3, List Answer 1, Matrix Answer 2, Answers to Exercises
@subsection Matrix Tutorial Exercise 3
@noindent
-To solve @c{$A^T A \, X = A^T B$}
-@cite{trn(A) * A * X = trn(A) * B}, first we compute
-@c{$A' = A^T A$}
-@cite{A2 = trn(A) * A} and @c{$B' = A^T B$}
-@cite{B2 = trn(A) * B}; now, we have a
-system @c{$A' X = B'$}
-@cite{A2 * X = B2} which we can solve using Calc's @samp{/}
-command.
+To solve
+@texline @math{A^T A \, X = A^T B},
+@infoline @expr{trn(A) * A * X = trn(A) * B},
+first we compute
+@texline @math{A' = A^T A}
+@infoline @expr{A2 = trn(A) * A}
+and
+@texline @math{B' = A^T B};
+@infoline @expr{B2 = trn(A) * B};
+now, we have a system
+@texline @math{A' X = B'}
+@infoline @expr{A2 * X = B2}
+which we can solve using Calc's @samp{/} command.
@ifinfo
@example
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
-@c{$B'$}
-@cite{B2} vector.
+@texline @math{B'}
+@infoline @expr{B2}
+vector.
@smallexample
@group
@end smallexample
@noindent
-Now we compute the matrix @c{$A'$}
-@cite{A2} and divide.
+Now we compute the matrix
+@texline @math{A'}
+@infoline @expr{A2}
+and divide.
@smallexample
@group
(The actual computed answer will be slightly inexact due to
round-off error.)
-Notice that the answers are similar to those for the @c{$3\times3$}
-@asis{3x3} system
-solved in the text. That's because the fourth equation that was
+Notice that the answers are similar to those for the
+@texline @math{3\times3}
+@infoline 3x3
+system solved in the text. That's because the fourth equation that was
added to the system is almost identical to the first one multiplied
by two. (If it were identical, we would have gotten the exact same
-answer since the @c{$4\times3$}
-@asis{4x3} system would be equivalent to the original @c{$3\times3$}
-@asis{3x3}
+answer since the
+@texline @math{4\times3}
+@infoline 4x3
+system would be equivalent to the original
+@texline @math{3\times3}
+@infoline 3x3
system.)
Since the first and fourth equations aren't quite equivalent, they
@end smallexample
@noindent
-This is reasonably close to our original @cite{B} vector,
-@cite{[6, 2, 3, 11]}.
+This is reasonably close to our original @expr{B} vector,
+@expr{[6, 2, 3, 11]}.
@node List Answer 1, List Answer 2, Matrix Answer 3, Answers to Exercises
@subsection List Tutorial Exercise 1
@subsection List Tutorial Exercise 2
@noindent
-Given @cite{x} and @cite{y} vectors in quick variables 1 and 2 as before,
+Given @expr{x} and @expr{y} vectors in quick variables 1 and 2 as before,
the first job is to form the matrix that describes the problem.
@ifinfo
\afterdisplay
@end tex
-Thus we want a @c{$19\times2$}
-@asis{19x2} matrix with our @cite{x} vector as one column and
+Thus we want a
+@texline @math{19\times2}
+@infoline 19x2
+matrix with our @expr{x} vector as one column and
ones as the other column. So, first we build the column of ones, then
-we combine the two columns to form our @cite{A} matrix.
+we combine the two columns to form our @expr{A} matrix.
@smallexample
@group
@end smallexample
@noindent
-Now we compute @c{$A^T y$}
-@cite{trn(A) * y} and @c{$A^T A$}
-@cite{trn(A) * A} and divide.
+Now we compute
+@texline @math{A^T y}
+@infoline @expr{trn(A) * y}
+and
+@texline @math{A^T A}
+@infoline @expr{trn(A) * A}
+and divide.
@smallexample
@group
@end group
@end smallexample
-Since we were solving equations of the form @c{$m \times x + b \times 1 = y$}
-@cite{m*x + b*1 = y}, these
-numbers should be @cite{m} and @cite{b}, respectively. Sure enough, they
-agree exactly with the result computed using @kbd{V M} and @kbd{V R}!
+Since we were solving equations of the form
+@texline @math{m \times x + b \times 1 = y},
+@infoline @expr{m*x + b*1 = y},
+these numbers should be @expr{m} and @expr{b}, respectively. Sure
+enough, they agree exactly with the result computed using @kbd{V M} and
+@kbd{V R}!
The moral of this story: @kbd{V M} and @kbd{V R} will probably solve
your problem, but there is often an easier way using the higher-level
@noindent
Move to one end of the list and press @kbd{C-@@} (or @kbd{C-@key{SPC}} or
whatever) to set the mark, then move to the other end of the list
-and type @w{@kbd{M-# g}}.
+and type @w{@kbd{C-x * g}}.
@smallexample
@group
@subsection List Tutorial Exercise 4
@noindent
-A number @cite{j} is a divisor of @cite{n} if @c{$n \mathbin{\hbox{\code{\%}}} j = 0$}
-@samp{n % j = 0}. The first
-step is to get a vector that identifies the divisors.
+A number @expr{j} is a divisor of @expr{n} if
+@texline @math{n \mathbin{\hbox{\code{\%}}} j = 0}.
+@infoline @samp{n % j = 0}.
+The first step is to get a vector that identifies the divisors.
@smallexample
@group
zero, so adding zeros on the left and right is safe. From then on
the job is pretty straightforward.
-Incidentally, Calc provides the @c{\dfn{M\"obius} $\mu$}
-@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.
+Incidentally, Calc provides the
+@texline @dfn{M@"obius} @math{\mu}
+@infoline @dfn{Moebius mu}
+function which is zero if and only if its argument is square-free. It
+would be a much more convenient way to do the above test in practice.
@node List Answer 6, List Answer 7, List Answer 5, Answers to Exercises
@subsection List Tutorial Exercise 6
@end smallexample
The numbers down the lefthand edge of the list we desire are called
-the ``triangular numbers'' (now you know why!). The @cite{n}th
-triangular number is the sum of the integers from 1 to @cite{n}, and
-can be computed directly by the formula @c{$n (n+1) \over 2$}
-@cite{n * (n+1) / 2}.
+the ``triangular numbers'' (now you know why!). The @expr{n}th
+triangular number is the sum of the integers from 1 to @expr{n}, and
+can be computed directly by the formula
+@texline @math{n (n+1) \over 2}.
+@infoline @expr{n * (n+1) / 2}.
@smallexample
@group
@subsection List Tutorial Exercise 8
@noindent
-The first step is to build a list of values of @cite{x}.
+The first step is to build a list of values of @expr{x}.
@smallexample
@group
@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 @c{$\sin x$}
-@cite{sin(x)}
+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.)
The vector we have now has a single 1 in the position that indicates
-the maximum value of @cite{x}. Now it is a simple matter to convert
+the maximum value of @expr{x}. Now it is a simple matter to convert
this back into the corresponding value itself.
@smallexample
@end group
@end smallexample
-If @kbd{a =} had produced more than one @cite{1} value, this method
-would have given the sum of all maximum @cite{x} values; not very
+If @kbd{a =} had produced more than one @expr{1} value, this method
+would have given the sum of all maximum @expr{x} values; not very
useful! In this case we could have used @kbd{v m} (@code{calc-mask-vector})
instead. This command deletes all elements of a ``data'' vector that
correspond to zeros in a ``mask'' vector, leaving us with, in this
-example, a vector of maximum @cite{x} values.
+example, a vector of maximum @expr{x} values.
The built-in @kbd{a X} command maximizes a function using more
efficient methods. Just for illustration, let's use @kbd{a X}
@end smallexample
@noindent
-The output from @kbd{a X} is a vector containing the value of @cite{x}
+The output from @kbd{a X} is a vector containing the value of @expr{x}
that maximizes the function, and the function's value at that maximum.
As you can see, our simple search got quite close to the right answer.
@subsection List Tutorial Exercise 10
@noindent
-For the list @cite{[a, b, c, d]}, the result is @cite{((a = b) = c) = d},
-which will compare @cite{a} and @cite{b} to produce a 1 or 0, which is
-then compared with @cite{c} to produce another 1 or 0, which is then
-compared with @cite{d}. This is not at all what Joe wanted.
+For the list @expr{[a, b, c, d]}, the result is @expr{((a = b) = c) = d},
+which will compare @expr{a} and @expr{b} to produce a 1 or 0, which is
+then compared with @expr{c} to produce another 1 or 0, which is then
+compared with @expr{d}. This is not at all what Joe wanted.
Here's a more correct method:
@subsection List Tutorial Exercise 11
@noindent
-The circle of unit radius consists of those points @cite{(x,y)} for which
-@cite{x^2 + y^2 < 1}. We start by generating a vector of @cite{x^2}
-and a vector of @cite{y^2}.
+The circle of unit radius consists of those points @expr{(x,y)} for which
+@expr{x^2 + y^2 < 1}. We start by generating a vector of @expr{x^2}
+and a vector of @expr{y^2}.
We can make this go a bit faster by using the @kbd{v .} and @kbd{t .}
commands.
@end group
@end smallexample
-Now we sum the @cite{x^2} and @cite{y^2} values, compare with 1 to
+Now we sum the @expr{x^2} and @expr{y^2} values, compare with 1 to
get a vector of 1/0 truth values, then sum the truth values.
@smallexample
@end smallexample
@noindent
-The ratio @cite{84/100} should approximate the ratio @c{$\pi/4$}
-@cite{pi/4}.
+The ratio @expr{84/100} should approximate the ratio @cpiover{4}.
@smallexample
@group
@noindent
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
-@cite{y} axis can be ignored altogether. Just pick a random @cite{x}
-component for one end of the match, pick a random direction @c{$\theta$}
-@cite{theta},
-and see if @cite{x} and @c{$x + \cos \theta$}
-@cite{x + cos(theta)} (which is the @cite{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.
+@expr{y} axis can be ignored altogether. Just pick a random @expr{x}
+component for one end of the match, pick a random direction
+@texline @math{\theta},
+@infoline @expr{theta},
+and see if @expr{x} and
+@texline @math{x + \cos \theta}
+@infoline @expr{x + cos(theta)}
+(which is the @expr{x} coordinate of the other endpoint) cross a line.
+The lines are at integer coordinates, so this happens when the two
+numbers surround an integer.
Since the two endpoints are equivalent, we may as well choose the leftmost
-of the two endpoints as @cite{x}. Then @cite{theta} is an angle pointing
+of the two endpoints as @expr{x}. Then @expr{theta} is an angle pointing
to the right, in the range -90 to 90 degrees. (We could use radians, but
-it would feel like cheating to refer to @c{$\pi/2$}
-@cite{pi/2} radians while trying
-to estimate @c{$\pi$}
-@cite{pi}!)
+it would feel like cheating to refer to @cpiover{2} radians while trying
+to estimate @cpi{}!)
In fact, since the field of lines is infinite we can choose the
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 @cite{x} and @c{$\theta$}
-@cite{theta}, compute @c{$x + \cos \theta$}
-@cite{x + cos(theta)},
+Pick random @expr{x} and
+@texline @math{\theta},
+@infoline @expr{theta},
+compute
+@texline @math{x + \cos \theta},
+@infoline @expr{x + cos(theta)},
and count how many of the results are greater than one. Simple!
We can make this go a bit faster by using the @kbd{v .} and @kbd{t .}
like @kbd{)} and @kbd{]} at the end of a formula.
We'll show two different approaches here. In the first, we note that
-if the input vector is @cite{[a, b, c, d]}, then the hash code is
-@cite{3 (3 (3a + b) + c) + d = 27a + 9b + 3c + d}. In other words,
+if the input vector is @expr{[a, b, c, d]}, then the hash code is
+@expr{3 (3 (3a + b) + c) + d = 27a + 9b + 3c + d}. In other words,
it's a sum of descending powers of three times the ASCII codes.
@smallexample
@end smallexample
Why does this work? Think about a two-step computation:
-@w{@cite{3 (3a + b) + c}}. Taking a result modulo 511 basically means
+@w{@expr{3 (3a + b) + c}}. Taking a result modulo 511 basically means
subtracting off enough 511's to put the result in the desired range.
So the result when we take the modulo after every step is,
@end tex
@noindent
-for some suitable integers @cite{m} and @cite{n}. Expanding out by
+for some suitable integers @expr{m} and @expr{n}. Expanding out by
the distributive law yields
@ifinfo
@end tex
@noindent
-The @cite{m} term in the latter formula is redundant because any
-contribution it makes could just as easily be made by the @cite{n}
+The @expr{m} term in the latter formula is redundant because any
+contribution it makes could just as easily be made by the @expr{n}
term. So we can take it out to get an equivalent formula with
-@cite{n' = 3m + n},
+@expr{n' = 3m + n},
@ifinfo
@example
@subsection List Tutorial Exercise 14
We want to use @kbd{H V U} to nest a function which adds a random
-step to an @cite{(x,y)} coordinate. The function is a bit long, but
+step to an @expr{(x,y)} coordinate. The function is a bit long, but
otherwise the problem is quite straightforward.
@smallexample
notation to keep the two @code{random} calls from being evaluated
before nesting even begins.
-We now have a vector of @cite{[x, y]} sub-vectors, which by Calc's
+We now have a vector of @expr{[x, y]} sub-vectors, which by Calc's
rules acts like a matrix. We can transpose this matrix and unpack
-to get a pair of vectors, @cite{x} and @cite{y}, suitable for graphing.
+to get a pair of vectors, @expr{x} and @expr{y}, suitable for graphing.
@smallexample
@group
@end group
@end smallexample
-Incidentally, because the @cite{x} and @cite{y} are completely
+Incidentally, because the @expr{x} and @expr{y} are completely
independent in this case, we could have done two separate commands
-to create our @cite{x} and @cite{y} vectors of numbers directly.
+to create our @expr{x} and @expr{y} vectors of numbers directly.
To make a random walk of unit steps, we note that @code{sincos} of
-a random direction exactly gives us an @cite{[x, y]} step of unit
+a random direction exactly gives us an @expr{[x, y]} step of unit
length; in fact, the new nesting function is even briefer, though
we might want to lower the precision a bit for it.
@subsection Types Tutorial Exercise 1
@noindent
-If the number is the square root of @c{$\pi$}
-@cite{pi} times a rational number,
-then its square, divided by @c{$\pi$}
-@cite{pi}, should be a rational number.
+If the number is the square root of @cpi{} times a rational number,
+then its square, divided by @cpi{}, should be a rational number.
@smallexample
@group
@noindent
Aha! It's unlikely that an irrational number would equal a fraction
this simple to within ten digits, so our original number was probably
-@c{$\sqrt{27 \pi / 53}$}
-@cite{sqrt(27 pi / 53)}.
+@texline @math{\sqrt{27 \pi / 53}}.
+@infoline @expr{sqrt(27 pi / 53)}.
Notice that we didn't need to re-round the number when we reduced the
precision. Remember, arithmetic operations always round their inputs
@samp{exp(inf) = inf}. It's tempting to say that the exponential
of infinity must be ``bigger'' than ``regular'' infinity, but as
far as Calc is concerned all infinities are as just as big.
-In other words, as @cite{x} goes to infinity, @cite{e^x} also goes
-to infinity, but the fact the @cite{e^x} grows much faster than
-@cite{x} is not relevant here.
+In other words, as @expr{x} goes to infinity, @expr{e^x} also goes
+to infinity, but the fact the @expr{e^x} grows much faster than
+@expr{x} is not relevant here.
@samp{exp(-inf) = 0}. Here we have a finite answer even though
the input is infinite.
-@samp{sqrt(-inf) = (0, 1) inf}. Remember that @cite{(0, 1)}
-represents the imaginary number @cite{i}. Here's a derivation:
+@samp{sqrt(-inf) = (0, 1) inf}. Remember that @expr{(0, 1)}
+represents the imaginary number @expr{i}. Here's a derivation:
@samp{sqrt(-inf) = @w{sqrt((-1) * inf)} = sqrt(-1) * sqrt(inf)}.
-The first part is, by definition, @cite{i}; the second is @code{inf}
+The first part is, by definition, @expr{i}; the second is @code{inf}
because, once again, all infinities are the same size.
@samp{sqrt(uinf) = uinf}. In fact, we do know something about the
right half of the complex plane. But Calc has no notation for this,
so it settles for the conservative answer @code{uinf}.
-@samp{abs(uinf) = inf}. No matter which direction @cite{x} points,
+@samp{abs(uinf) = inf}. No matter which direction @expr{x} points,
@samp{abs(x)} always points along the positive real axis.
@samp{ln(0) = -inf}. Here we have an infinite answer to a finite
-input. As in the @cite{1 / 0} case, Calc will only use infinities
-here if you have turned on ``infinite'' mode. Otherwise, it will
+input. As in the @expr{1 / 0} case, Calc will only use infinities
+here if you have turned on Infinite mode. Otherwise, it will
treat @samp{ln(0)} as an error.
@node Types Answer 3, Types Answer 4, Types Answer 2, Answers to Exercises
@noindent
We can make @samp{inf - inf} be any real number we like, say,
-@cite{a}, just by claiming that we added @cite{a} to the first
+@expr{a}, just by claiming that we added @expr{a} to the first
infinity but not to the second. This is just as true for complex
-values of @cite{a}, so @code{nan} can stand for a complex number.
+values of @expr{a}, so @code{nan} can stand for a complex number.
(And, similarly, @code{uinf} can stand for an infinity that points
in any direction in the complex plane, such as @samp{(0, 1) inf}).
@w{@samp{1 / [0 .. 10]}}, also (potentially) divides by zero because zero
is now a member of the interval. So Calc leaves this one unevaluated, too.
-If you turn on ``infinite'' mode by pressing @kbd{m i}, you will
+If you turn on Infinite mode by pressing @kbd{m i}, you will
instead get the answer @samp{[0.1 .. inf]}, which includes infinity
as a possible value.
The fourth calculation, @samp{1 / (-10 .. 10)}, has the same problem.
Zero is buried inside the interval, but it's still a possible value.
It's not hard to see that the actual result of @samp{1 / (-10 .. 10)}
-will be either greater than @i{0.1}, or less than @i{-0.1}. Thus
+will be either greater than @mathit{0.1}, or less than @mathit{-0.1}. Thus
the interval goes from minus infinity to plus infinity, with a ``hole''
-in it from @i{-0.1} to @i{0.1}. Calc doesn't have any way to
+in it from @mathit{-0.1} to @mathit{0.1}. Calc doesn't have any way to
represent this, so it just reports @samp{[-inf .. inf]} as the answer.
It may be disappointing to hear ``the answer lies somewhere between
minus infinity and plus infinity, inclusive,'' but that's the best
@end smallexample
@noindent
-In the first case the result says, ``if a number is between @i{-3} and
+In the first case the result says, ``if a number is between @mathit{-3} and
3, its square is between 0 and 9.'' The second case says, ``the product
-of two numbers each between @i{-3} and 3 is between @i{-9} and 9.''
+of two numbers each between @mathit{-3} and 3 is between @mathit{-9} and 9.''
An interval form is not a number; it is a symbol that can stand for
many different numbers. Two identical-looking interval forms can stand
@subsection Types Tutorial Exercise 10
@noindent
-Testing the first number, we might arbitrarily choose 17 for @cite{x}.
+Testing the first number, we might arbitrarily choose 17 for @expr{x}.
@smallexample
@group
@end smallexample
@noindent
-The result is three ones (modulo @cite{n}), so it's very probable that
+The result is three ones (modulo @expr{n}), so it's very probable that
15485863 is prime. (In fact, this number is the millionth prime.)
Note that the functions @samp{($$^($-1)) mod $} or @samp{$$^($-1) % $}
@noindent
@c [fix-ref Declarations]
-The result @samp{sqrt(x)^2} is simplified back to @cite{x} by the
+The result @samp{sqrt(x)^2} is simplified back to @expr{x} by the
Calculator, but @samp{sqrt(x^2)} is not. (Consider what happens
-if @w{@cite{x = -4}}.) If @cite{x} is real, this formula could be
+if @w{@expr{x = -4}}.) If @expr{x} is real, this formula could be
simplified to @samp{abs(x)}, but for general complex arguments even
that is not safe. (@xref{Declarations}, for a way to tell Calc
-that @cite{x} is known to be real.)
+that @expr{x} is known to be real.)
@node Algebra Answer 2, Algebra Answer 3, Algebra Answer 1, Answers to Exercises
@subsection Algebra Tutorial Exercise 2
@noindent
-Suppose our roots are @cite{[a, b, c]}. We want a polynomial which
-is zero when @cite{x} is any of these values. The trivial polynomial
-@cite{x-a} is zero when @cite{x=a}, so the product @cite{(x-a)(x-b)(x-c)}
+Suppose our roots are @expr{[a, b, c]}. We want a polynomial which
+is zero when @expr{x} is any of these values. The trivial polynomial
+@expr{x-a} is zero when @expr{x=a}, so the product @expr{(x-a)(x-b)(x-c)}
will do the job. We can use @kbd{a c x} to write this in a more
familiar form.
@end smallexample
@noindent
-Multiplying by the conjugate helps because @cite{(a+b) (a-b) = a^2 - b^2}.
+Multiplying by the conjugate helps because @expr{(a+b) (a-b) = a^2 - b^2}.
@smallexample
@group
into a three-argument @code{fib} that makes computation easier. The
second rule converts back from three-argument form once the computation
is done. The third rule does the computation itself. It basically
-says that if @cite{x} and @cite{y} are two consecutive Fibonacci numbers,
-then @cite{y} and @cite{x+y} are the next (overlapping) pair of Fibonacci
+says that if @expr{x} and @expr{y} are two consecutive Fibonacci numbers,
+then @expr{y} and @expr{x+y} are the next (overlapping) pair of Fibonacci
numbers.
-Notice that because the number @cite{n} was ``validated'' by the
+Notice that because the number @expr{n} was ``validated'' by the
conditions on the first rule, there is no need to put conditions on
the other rules because the rule set would never get that far unless
the input were valid. That further speeds computation, since no
@noindent
Given @samp{seq(6)}, the result is @samp{[6, 3, 10, 5, 16, 8, 4, 2, 1]}.
-Notice that the @cite{n > 1} guard is no longer necessary on the last
-rule since the @cite{n = 1} case is now detected by another rule.
+Notice that the @expr{n > 1} guard is no longer necessary on the last
+rule since the @expr{n = 1} case is now detected by another rule.
But a guard has been added to the initial rule to make sure the
initial value is suitable before the computation begins.
@starindex
@end ignore
@tindex nterms
-If @cite{x} is the sum @cite{a + b}, then `@t{nterms(}@var{x}@t{)}' must
-be `@t{nterms(}@var{a}@t{)}' plus `@t{nterms(}@var{b}@t{)}'. If @cite{x}
-is not a sum, then `@t{nterms(}@var{x}@t{)}' = 1.
+If @expr{x} is the sum @expr{a + b}, then `@tfn{nterms(}@var{x}@tfn{)}' must
+be `@tfn{nterms(}@var{a}@tfn{)}' plus `@tfn{nterms(}@var{b}@tfn{)}'. If @expr{x}
+is not a sum, then `@tfn{nterms(}@var{x}@tfn{)}' = 1.
@smallexample
@group
match before later rules; @samp{nterms(x)} will only be tried if we
already know that @samp{x} is not a sum.
-@node Rewrites Answer 6, Rewrites Answer 7, Rewrites Answer 5, Answers to Exercises
+@node Rewrites Answer 6, Programming Answer 1, Rewrites Answer 5, Answers to Exercises
@subsection Rewrites Tutorial Exercise 6
-Just put the rule @samp{0^0 := 1} into @code{EvalRules}. For example,
-before making this definition we have:
-
-@smallexample
-@group
-2: [-2, -1, 0, 1, 2] 1: [1, 1, 0^0, 1, 1]
-1: 0 .
- .
-
- v x 5 @key{RET} 3 - 0 V M ^
-@end group
-@end smallexample
-
-@noindent
-But then:
-
-@smallexample
-@group
-2: [-2, -1, 0, 1, 2] 1: [1, 1, 1, 1, 1]
-1: 0 .
- .
-
- U ' 0^0:=1 @key{RET} s t EvalRules @key{RET} V M ^
-@end group
-@end smallexample
-
-Perhaps more surprisingly, this rule still works with infinite mode
-turned on. Calc tries @code{EvalRules} before any built-in rules for
-a function. This allows you to override the default behavior of any
-Calc feature: Even though Calc now wants to evaluate @cite{0^0} to
-@code{nan}, your rule gets there first and evaluates it to 1 instead.
-
-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
-a nasty surprise when you use Calc to balance your checkbook!)
-
-@node Rewrites Answer 7, Programming Answer 1, Rewrites Answer 6, Answers to Exercises
-@subsection Rewrites Tutorial Exercise 7
-
@noindent
Here is a rule set that will do the job:
Another way to solve this problem would be to create a new ``data type''
that represents truncated power series. We might represent these as
function calls @samp{series(@var{coefs}, @var{x})} where @var{coefs} is
-a vector of coefficients for @cite{x^0}, @cite{x^1}, @cite{x^2}, and so
+a vector of coefficients for @expr{x^0}, @expr{x^1}, @expr{x^2}, and so
on. Rules would exist for sums and products of such @code{series}
objects, and as an optional convenience could also know how to combine a
@code{series} object with a normal polynomial. (With this, and with a
this it would probably be better to write the formatting routine
in Lisp.)
-@node Programming Answer 1, Programming Answer 2, Rewrites Answer 7, Answers to Exercises
+@node Programming Answer 1, Programming Answer 2, Rewrites Answer 6, Answers to Exercises
@subsection Programming Tutorial Exercise 1
@noindent
Just enter the formula @samp{ninteg(sin(t)/t, t, 0, x)}, type
@kbd{Z F}, and answer the questions. Since this formula contains two
variables, the default argument list will be @samp{(t x)}. We want to
-change this to @samp{(x)} since @cite{t} is really a dummy variable
+change this to @samp{(x)} since @expr{t} is really a dummy variable
to be used within @code{ninteg}.
The exact keystrokes are @kbd{Z F s Si @key{RET} @key{RET} C-b C-b @key{DEL} @key{DEL} @key{RET} y}.
algebraic entry, whichever way you prefer:
@noindent
-Computing @c{$\displaystyle{\sin x \over x}$}
-@cite{sin(x) / x}:
+Computing
+@texline @math{\displaystyle{\sin x \over x}}:
+@infoline @expr{sin(x) / x}:
Using the stack: @kbd{C-x ( @key{RET} S @key{TAB} / C-x )}.
@end example
@noindent
-Thus @samp{[0, 1; 1, 1]^n * [1, 1]} computes Fibonacci numbers @cite{n+1}
-and @cite{n+2}. Here's one program that does the job:
+Thus @samp{[0, 1; 1, 1]^n * [1, 1]} computes Fibonacci numbers @expr{n+1}
+and @expr{n+2}. Here's one program that does the job:
@example
C-x ( ' [0, 1; 1, 1] ^ ($-1) * [1, 1] @key{RET} v u @key{DEL} C-x )
@noindent
This program is quite efficient because Calc knows how to raise a
-matrix (or other value) to the power @cite{n} in only @c{$\log_2 n$}
-@cite{log(n,2)}
+matrix (or other value) to the power @expr{n} in only
+@texline @math{\log_2 n}
+@infoline @expr{log(n,2)}
steps. For example, this program can compute the 1000th Fibonacci
number (a 209-digit integer!) in about 10 steps; even though the
@kbd{Z < ... Z >} solution had much simpler steps, it would have
@subsection Programming Tutorial Exercise 8
@noindent
-The first step is to compute the derivative @cite{f'(x)} and thus
-the formula @c{$\displaystyle{x - {f(x) \over f'(x)}}$}
-@cite{x - f(x)/f'(x)}.
+The first step is to compute the derivative @expr{f'(x)} and thus
+the formula
+@texline @math{\displaystyle{x - {f(x) \over f'(x)}}}.
+@infoline @expr{x - f(x)/f'(x)}.
(Because this definition is long, it will be repeated in concise form
-below. You can use @w{@kbd{M-# m}} to load it from there. While you are
+below. You can use @w{@kbd{C-x * m}} to load it from there. While you are
entering a @kbd{Z ` Z '} body in a macro, Calc simply collects
keystrokes without executing them. In the following diagrams we'll
pretend Calc actually executed the keystrokes as you typed them,
@end group
@end smallexample
-This is the new guess for @cite{x}. Now we compare it with the
+This is the new guess for @expr{x}. Now we compare it with the
old one to see if we've converged.
@smallexample
@subsection Programming Tutorial Exercise 9
@noindent
-The first step is to adjust @cite{z} to be greater than 5. A simple
-``for'' loop will do the job here. If @cite{z} is less than 5, we
-reduce the problem using @c{$\psi(z) = \psi(z+1) - 1/z$}
-@cite{psi(z) = psi(z+1) - 1/z}. We go
-on to compute @c{$\psi(z+1)$}
-@cite{psi(z+1)}, and remember to add back a factor of
-@cite{-1/z} when we're done. This step is repeated until @cite{z > 5}.
+The first step is to adjust @expr{z} to be greater than 5. A simple
+``for'' loop will do the job here. If @expr{z} is less than 5, we
+reduce the problem using
+@texline @math{\psi(z) = \psi(z+1) - 1/z}.
+@infoline @expr{psi(z) = psi(z+1) - 1/z}. We go
+on to compute
+@texline @math{\psi(z+1)},
+@infoline @expr{psi(z+1)},
+and remember to add back a factor of @expr{-1/z} when we're done. This
+step is repeated until @expr{z > 5}.
(Because this definition is long, it will be repeated in concise form
-below. You can use @w{@kbd{M-# m}} to load it from there. While you are
+below. You can use @w{@kbd{C-x * m}} to load it from there. While you are
entering a @kbd{Z ` Z '} body in a macro, Calc simply collects
keystrokes without executing them. In the following diagrams we'll
pretend Calc actually executed the keystrokes as you typed them,
@end group
@end smallexample
-Here, variable 1 holds @cite{z} and variable 2 holds the adjustment
-factor. If @cite{z < 5}, we use a loop to increase it.
+Here, variable 1 holds @expr{z} and variable 2 holds the adjustment
+factor. If @expr{z < 5}, we use a loop to increase it.
(By the way, we started with @samp{1.0} instead of the integer 1 because
otherwise the calculation below will try to do exact fractional arithmetic,
@end group
@end smallexample
-Now we compute the initial part of the sum: @c{$\ln z - {1 \over 2z}$}
-@cite{ln(z) - 1/2z}
+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.
@smallexample
@end smallexample
Now we evaluate the series. We'll use another ``for'' loop counting
-up the value of @cite{2 n}. (Calc does have a summation command,
+up the value of @expr{2 n}. (Calc does have a summation command,
@kbd{a +}, but we'll use loops just to get more practice with them.)
@smallexample
@end group
@end smallexample
-This is the value of @c{$-\gamma$}
-@cite{- gamma}, with a slight bit of roundoff error.
-To get a full 12 digits, let's use a higher precision:
+This is the value of
+@texline @math{-\gamma},
+@infoline @expr{- gamma},
+with a slight bit of roundoff error. To get a full 12 digits, let's use
+a higher precision:
@smallexample
@group
@subsection Programming Tutorial Exercise 10
@noindent
-Taking the derivative of a term of the form @cite{x^n} will produce
-a term like @c{$n x^{n-1}$}
-@cite{n x^(n-1)}. Taking the derivative of a constant
-produces zero. From this it is easy to see that the @cite{n}th
-derivative of a polynomial, evaluated at @cite{x = 0}, will equal the
-coefficient on the @cite{x^n} term times @cite{n!}.
+Taking the derivative of a term of the form @expr{x^n} will produce
+a term like
+@texline @math{n x^{n-1}}.
+@infoline @expr{n x^(n-1)}.
+Taking the derivative of a constant
+produces zero. From this it is easy to see that the @expr{n}th
+derivative of a polynomial, evaluated at @expr{x = 0}, will equal the
+coefficient on the @expr{x^n} term times @expr{n!}.
(Because this definition is long, it will be repeated in concise form
-below. You can use @w{@kbd{M-# m}} to load it from there. While you are
+below. You can use @w{@kbd{C-x * m}} to load it from there. While you are
entering a @kbd{Z ` Z '} body in a macro, Calc simply collects
keystrokes without executing them. In the following diagrams we'll
pretend Calc actually executed the keystrokes as you typed them,
@end smallexample
To convert back, a simple method is just to map the coefficients
-against a table of powers of @cite{x}.
+against a table of powers of @expr{x}.
@smallexample
@group
The last step replaces the 2 that was eaten during the creation
of the dummy @kbd{z s} command. Now we move on to the real
definition. The recurrence needs to be rewritten slightly,
-to the form @cite{s(n,m) = s(n-1,m-1) - (n-1) s(n-1,m)}.
+to the form @expr{s(n,m) = s(n-1,m-1) - (n-1) s(n-1,m)}.
(Because this definition is long, it will be repeated in concise form
-below. You can use @kbd{M-# m} to load it from there.)
+below. You can use @kbd{C-x * m} to load it from there.)
@smallexample
@group
@end group
@end example
-You can read this definition using @kbd{M-# m} (@code{read-kbd-macro})
+You can read this definition using @kbd{C-x * m} (@code{read-kbd-macro})
followed by @kbd{Z K s}, without having to make a dummy definition
first, because @code{read-kbd-macro} doesn't need to execute the
-definition as it reads it in. For this reason, @code{M-# m} is often
+definition as it reads it in. For this reason, @code{C-x * m} is often
the easiest way to create recursive programs in Calc.
@node Programming Answer 12, , Programming Answer 11, Answers to Exercises
* Numeric Entry::
* Algebraic Entry::
* Quick Calculator::
-* Keypad Mode::
* Prefix Arguments::
* Undo::
* Error Messages::
and @samp{*Calc Trail*}. The former displays the contents of the
Calculator stack and is manipulated exclusively through Calc commands.
It is possible (though not usually necessary) to create several Calc
-Mode buffers each of which has an independent stack, undo list, and
+mode buffers each of which has an independent stack, undo list, and
mode settings. There is exactly one Calc Trail buffer; it records a
list of the results of all calculations that have been done. The
-Calc Trail buffer uses a variant of Calc Mode, so Calculator commands
+Calc Trail buffer uses a variant of Calc mode, so Calculator commands
still work when the trail buffer's window is selected. It is possible
to turn the trail window off, but the @samp{*Calc Trail*} buffer itself
-still exists and is updated silently. @xref{Trail Commands}.@refill
+still exists and is updated silently. @xref{Trail Commands}.
-@kindex M-# c
-@kindex M-# M-#
+@kindex C-x * c
+@kindex C-x * *
@ignore
@mindex @null
@end ignore
-@kindex M-# #
-In most installations, the @kbd{M-# c} key sequence is a more
-convenient way to start the Calculator. Also, @kbd{M-# M-#} and
-@kbd{M-# #} are synonyms for @kbd{M-# c} unless you last used Calc
-in its ``keypad'' mode.
+In most installations, the @kbd{C-x * c} key sequence is a more
+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 x
@kindex M-x
key (@code{calc-execute-extended-command})
is like @kbd{M-x} except that it enters the initial string @samp{calc-}
for you. For example, the following key sequences are equivalent:
-@kbd{S}, @kbd{M-x calc-sin @key{RET}}, @kbd{x sin @key{RET}}.@refill
+@kbd{S}, @kbd{M-x calc-sin @key{RET}}, @kbd{x sin @key{RET}}.
@cindex Extensions module
@cindex @file{calc-ext} module
-The Calculator exists in many parts. When you type @kbd{M-# c}, the
+The Calculator exists in many parts. When you type @kbd{C-x * c}, the
Emacs ``auto-load'' mechanism will bring in only the first part, which
contains the basic arithmetic functions. The other parts will be
auto-loaded the first time you use the more advanced commands like trig
of the Calculator in the common case when all you need to do is a
little arithmetic. If for some reason the Calculator fails to load an
extension module automatically, you can force it to load all the
-extensions by using the @kbd{M-# L} (@code{calc-load-everything})
-command. @xref{Mode Settings}.@refill
+extensions by using the @kbd{C-x * L} (@code{calc-load-everything})
+command. @xref{Mode Settings}.
-If you type @kbd{M-x calc} or @kbd{M-# c} with any numeric prefix argument,
+If you type @kbd{M-x calc} or @kbd{C-x * c} with any numeric prefix argument,
the Calculator is loaded if necessary, but it is not actually started.
If the argument is positive, the @file{calc-ext} extensions are also
loaded if necessary. User-written Lisp code that wishes to make use
of Calc's arithmetic routines can use @samp{(calc 0)} or @samp{(calc 1)}
-to auto-load the Calculator.@refill
+to auto-load the Calculator.
-@kindex M-# b
+@kindex C-x * b
@pindex full-calc
-If you type @kbd{M-# b}, then next time you use @kbd{M-# c} you
+If you type @kbd{C-x * b}, then next time you use @kbd{C-x * c} you
will get a Calculator that uses the full height of the Emacs screen.
-When full-screen mode is on, @kbd{M-# c} runs the @code{full-calc}
+When full-screen mode is on, @kbd{C-x * c} runs the @code{full-calc}
command instead of @code{calc}. From the Unix shell you can type
@samp{emacs -f full-calc} to start a new Emacs specifically for use
as a calculator. When Calc is started from the Emacs command line
like this, Calc's normal ``quit'' commands actually quit Emacs itself.
-@kindex M-# o
+@kindex C-x * o
@pindex calc-other-window
-The @kbd{M-# o} command is like @kbd{M-# c} except that the Calc
+The @kbd{C-x * o} command is like @kbd{C-x * c} except that the Calc
window is not actually selected. If you are already in the Calc
-window, @kbd{M-# o} switches you out of it. (The regular Emacs
+window, @kbd{C-x * o} switches you out of it. (The regular Emacs
@kbd{C-x o} command would also work for this, but it has a
tendency to drop you into the Calc Trail window instead, which
-@kbd{M-# o} takes care not to do.)
+@kbd{C-x * o} takes care not to do.)
@ignore
-@mindex M-# q
+@mindex C-x * q
@end ignore
-For one quick calculation, you can type @kbd{M-# q} (@code{quick-calc})
+For one quick calculation, you can type @kbd{C-x * q} (@code{quick-calc})
which prompts you for a formula (like @samp{2+3/4}). The result is
displayed at the bottom of the Emacs screen without ever creating
any special Calculator windows. @xref{Quick Calculator}.
@ignore
-@mindex M-# k
+@mindex C-x * k
@end ignore
Finally, if you are using the X window system you may want to try
-@kbd{M-# k} (@code{calc-keypad}) which runs Calc with a
+@kbd{C-x * k} (@code{calc-keypad}) which runs Calc with a
``calculator keypad'' picture as well as a stack display. Click on
the keys with the mouse to operate the calculator. @xref{Keypad Mode}.
@pindex calc-quit
@cindex Quitting the Calculator
@cindex Exiting the Calculator
-The @kbd{q} key (@code{calc-quit}) exits Calc Mode and closes the
+The @kbd{q} key (@code{calc-quit}) exits Calc mode and closes the
Calculator's window(s). It does not delete the Calculator buffers.
If you type @kbd{M-x calc} again, the Calculator will reappear with the
-contents of the stack intact. Typing @kbd{M-# c} or @kbd{M-# M-#}
+contents of the stack intact. Typing @kbd{C-x * c} or @kbd{C-x * *}
again from inside the Calculator buffer is equivalent to executing
-@code{calc-quit}; you can think of @kbd{M-# M-#} as toggling the
-Calculator on and off.@refill
+@code{calc-quit}; you can think of @kbd{C-x * *} as toggling the
+Calculator on and off.
-@kindex M-# x
-The @kbd{M-# x} command also turns the Calculator off, no matter which
+@kindex C-x * x
+The @kbd{C-x * x} command also turns the Calculator off, no matter which
user interface (standard, Keypad, or Embedded) is currently active.
It also cancels @code{calc-edit} mode if used from there.
@code{calc-scroll-right}. These are just like the normal horizontal
scrolling commands except that they scroll one half-screen at a time by
default. (Calc formats its output to fit within the bounds of the
-window whenever it can.)@refill
+window whenever it can.)
@kindex @{
@kindex @}
@cindex Vertical scrolling
The @kbd{@{} and @kbd{@}} keys are bound to @code{calc-scroll-down}
and @code{calc-scroll-up}. They scroll up or down by one-half the
-height of the Calc window.@refill
+height of the Calc window.
-@kindex M-# 0
+@kindex C-x * 0
@pindex calc-reset
-The @kbd{M-# 0} command (@code{calc-reset}; that's @kbd{M-#} followed
-by a zero) resets the Calculator to its default state. This clears
-the stack, resets all the modes, clears the caches (@pxref{Caches}),
-and so on. (It does @emph{not} erase the values of any variables.)
-With a numeric prefix argument, @kbd{M-# 0} preserves the contents
-of the stack but resets everything else.
+The @kbd{C-x * 0} command (@code{calc-reset}; that's @kbd{C-x *} followed
+by a zero) resets the Calculator to its initial state. This clears
+the stack, resets all the modes to their initial values (the values
+that were saved with @kbd{m m} (@code{calc-save-modes})), clears the
+caches (@pxref{Caches}), and so on. (It does @emph{not} erase the
+values of any variables.) With an argument of 0, Calc will be reset to
+its default state; namely, the modes will be given their default values.
+With a positive prefix argument, @kbd{C-x * 0} preserves the contents of
+the stack but resets everything else to its initial state; with a
+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
Calc-specific analogues to the @kbd{C-h} functions for Emacs help.
@kindex h i
-@kindex M-# i
+@kindex C-x * i
@kindex i
@pindex calc-info
The @kbd{h i} (@code{calc-info}) command runs the Emacs Info system
to read this manual on-line. This is basically the same as typing
@kbd{C-h i} (the regular way to run the Info system), then, if Info
is not already in the Calc manual, selecting the beginning of the
-manual. The @kbd{M-# i} command is another way to read the Calc
+manual. The @kbd{C-x * i} command is another way to read the Calc
manual; it is different from @kbd{h i} in that it works any time,
not just inside Calc. The plain @kbd{i} key is also equivalent to
@kbd{h i}, though this key is obsolete and may be replaced with a
different command in a future version of Calc.
@kindex h t
-@kindex M-# t
+@kindex C-x * t
@pindex calc-tutorial
The @kbd{h t} (@code{calc-tutorial}) command runs the Info system on
the Tutorial section of the Calc manual. It is like @kbd{h i},
than the beginning of the whole manual. (It actually selects the
node ``Interactive Tutorial'' which tells a few things about
using the Info system before going on to the actual tutorial.)
-The @kbd{M-# t} key is equivalent to @kbd{h t} (but it works at
+The @kbd{C-x * t} key is equivalent to @kbd{h t} (but it works at
all times).
@kindex h s
-@kindex M-# s
+@kindex C-x * s
@pindex calc-info-summary
The @kbd{h s} (@code{calc-info-summary}) command runs the Info system
-on the Summary node of the Calc manual. @xref{Summary}. The @kbd{M-# s}
+on the Summary node of the Calc manual. @xref{Summary}. The @kbd{C-x * s}
key is equivalent to @kbd{h s}.
@kindex h k
@noindent
which means the command @kbd{H a S} or @kbd{H M-x calc-solve-for}
-takes a value @cite{a} from the stack, prompts for a value @cite{v},
+takes a value @expr{a} from the stack, prompts for a value @expr{v},
then applies the algebraic function @code{fsolve} to these values.
The @samp{?=notes} message means you can now type @kbd{?} to see
additional notes from the summary that apply to this command.
@kindex h f
@pindex calc-describe-function
The @kbd{h f} (@code{calc-describe-function}) command looks up an
-algebraic function or a command name in the Calc manual. The
-prompt initially contains @samp{calcFunc-}; follow this with 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, backspace and 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 @samp{=>}.
+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
+@samp{=>}.
@kindex h v
@pindex calc-describe-variable
The @kbd{h v} (@code{calc-describe-variable}) command looks up a
-variable in the Calc manual. The prompt initially contains the
-@samp{var-} prefix; just add a variable name like @code{pi} or
+variable in the Calc manual. Enter a variable name like @code{pi} or
@code{PlotRejects}.
@kindex h b
@kbd{+} key always ``pops'' the top two numbers from the stack, adds them,
and pushes the result (3) back onto the stack. This number is ready for
further calculations: @kbd{5 -} pushes 5 onto the stack, then pops the
-3 and 5, subtracts them, and pushes the result (@i{-2}).@refill
+3 and 5, subtracts them, and pushes the result (@mathit{-2}).
Note that the ``top'' of the stack actually appears at the @emph{bottom}
of the buffer. A line containing a single @samp{.} character signifies
(After all, if you typed @kbd{1 2} by themselves the Calculator
would enter the number 12.) If you press @key{RET} or @key{SPC} @emph{not}
right after typing a number, the key duplicates the number on the top of
-the stack. @kbd{@key{RET} *} is thus a handy way to square a number.@refill
+the stack. @kbd{@key{RET} *} is thus a handy way to square a number.
The @key{DEL} key pops and throws away the top number on the stack.
The @key{TAB} key swaps the top two objects on the stack.
@xref{Stack and Trail}, for descriptions of these and other stack-related
-commands.@refill
+commands.
@node Numeric Entry, Algebraic Entry, Stack Basics, Introduction
@section Numeric Entry
@cindex Negative numbers, entering
@kindex _
There are three different concepts corresponding to the word ``minus,''
-typified by @cite{a-b} (subtraction), @cite{-x}
-(change-sign), and @cite{-5} (negative number). Calc uses three
+typified by @expr{a-b} (subtraction), @expr{-x}
+(change-sign), and @expr{-5} (negative number). Calc uses three
different keys for these operations, respectively:
@kbd{-}, @kbd{n}, and @kbd{_} (the underscore). The @kbd{-} key subtracts
the two numbers on the top of the stack. The @kbd{n} key changes the sign
of the number on the top of the stack or the number currently being entered.
The @kbd{_} key begins entry of a negative number or changes the sign of
the number currently being entered. The following sequences all enter the
-number @i{-5} onto the stack: @kbd{0 @key{RET} 5 -}, @kbd{5 n @key{RET}},
-@kbd{5 @key{RET} n}, @kbd{_ 5 @key{RET}}, @kbd{5 _ @key{RET}}.@refill
+number @mathit{-5} onto the stack: @kbd{0 @key{RET} 5 -}, @kbd{5 n @key{RET}},
+@kbd{5 @key{RET} n}, @kbd{_ 5 @key{RET}}, @kbd{5 _ @key{RET}}.
Some other keys are active during numeric entry, such as @kbd{#} for
non-decimal numbers, @kbd{:} for fractions, and @kbd{@@} for HMS forms.
Calculations can also be entered in algebraic form. This is accomplished
by typing the apostrophe key, @kbd{'}, followed by the expression in
standard format: @kbd{@key{'} 2+3*4 @key{RET}} computes
-@c{$2+(3\times4) = 14$}
-@cite{2+(3*4) = 14} and pushes that on the stack. If you wish you can
+@texline @math{2+(3\times4) = 14}
+@infoline @expr{2+(3*4) = 14}
+and pushes that on the stack. If you wish you can
ignore the RPN aspect of Calc altogether and simply enter algebraic
expressions in this way. You may want to use @key{DEL} every so often to
-clear previous results off the stack.@refill
+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
+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.
@kindex m a
@pindex calc-algebraic-mode
-@cindex Algebraic mode
+@cindex Algebraic Mode
If you prefer algebraic entry, you can use the command @kbd{m a}
(@code{calc-algebraic-mode}) to set Algebraic mode. In this mode,
digits and other keys that would normally start numeric entry instead
begin algebraic entry. You can still do RPN calculations in this mode,
but you will have to press @key{RET} to terminate every number:
@kbd{2 @key{RET} 3 @key{RET} * 4 @key{RET} +} would accomplish the same
-thing as @kbd{2*3+4 @key{RET}}.@refill
+thing as @kbd{2*3+4 @key{RET}}.
-@cindex Incomplete algebraic mode
+@cindex Incomplete Algebraic Mode
If you give a numeric prefix argument like @kbd{C-u} to the @kbd{m a}
command, it enables Incomplete Algebraic mode; this is like regular
Algebraic mode except that it applies to the @kbd{(} and @kbd{[} keys
@kindex m t
@pindex calc-total-algebraic-mode
-@cindex Total algebraic mode
+@cindex Total Algebraic Mode
The @kbd{m t} (@code{calc-total-algebraic-mode}) gives you an even
stronger algebraic-entry mode, in which @emph{all} regular letter and
punctuation keys begin algebraic entry. Use this if you prefer typing
@w{@kbd{sqrt( )}} instead of @kbd{Q}, @w{@kbd{factor( )}} instead of
@kbd{a f}, and so on. To type regular Calc commands when you are in
-``total'' algebraic mode, hold down the @key{META} key. Thus @kbd{M-q}
+Total Algebraic mode, hold down the @key{META} key. Thus @kbd{M-q}
is the command to quit Calc, @kbd{M-p} sets the precision, and
-@kbd{M-m t} (or @kbd{M-m M-t}, if you prefer) turns total algebraic
+@kbd{M-m t} (or @kbd{M-m M-t}, if you prefer) turns Total Algebraic
mode back off again. Meta keys also terminate algebraic entry, so
that @kbd{2+3 M-S} is equivalent to @kbd{2+3 @key{RET} M-S}. The symbol
@samp{Alg*} will appear in the mode line whenever you are in this mode.
stack. Thus, @kbd{' 1+2 @key{RET}} pushes 3 on the stack, and @kbd{$*2
@key{RET}} replaces it with 6. Note that the @kbd{$} key always
initiates algebraic entry; the @kbd{'} is unnecessary if @kbd{$} is the
-first character in the new formula.@refill
+first character in the new formula.
Higher stack elements can be accessed from an entered formula with the
symbols @kbd{$$}, @kbd{$$$}, and so on. The number of stack elements
signs in the longest such symbol in the formula. For example, @samp{$$+$$$}
adds the second and third stack elements, replacing the top three elements
with the answer. (All information about the top stack element is thus lost
-since no single @samp{$} appears in this formula.)@refill
+since no single @samp{$} appears in this formula.)
A slightly different way to refer to stack elements is with a dollar
sign followed by a number: @samp{$1}, @samp{$2}, and so on are much
instead of @key{RET}, Calc disables the default simplifications
(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 @cite{1+2};
+on the stack, but @kbd{' 1+2 @key{LFD}} pushes the formula @expr{1+2};
you might then press @kbd{=} when it is time to evaluate this formula.
@node Quick Calculator, Prefix Arguments, Algebraic Entry, Introduction
@section ``Quick Calculator'' Mode
@noindent
-@kindex M-# q
+@kindex C-x * q
@pindex quick-calc
@cindex Quick Calculator
There is another way to invoke the Calculator if all you need to do
-is make one or two quick calculations. Type @kbd{M-# q} (or
+is make one or two quick calculations. Type @kbd{C-x * q} (or
@kbd{M-x quick-calc}), then type any formula as an algebraic entry.
The Calculator will compute the result and display it in the echo
area, without ever actually putting up a Calc window.
refer to the previous Quick Calculator result. Older results are
not retained; the Quick Calculator has no effect on the full
Calculator's stack or trail. If you compute a result and then
-forget what it was, just run @code{M-# q} again and enter
+forget what it was, just run @code{C-x * q} again and enter
@samp{$} as the formula.
If this is the first time you have used the Calculator in this Emacs
-session, the @kbd{M-# q} command will create the @code{*Calculator*}
+session, the @kbd{C-x * q} command will create the @code{*Calculator*}
buffer and perform all the usual initializations; it simply will
refrain from putting that buffer up in a new window. The Quick
Calculator refers to the @code{*Calculator*} buffer for all mode
Calculator uses, simply run the full Calculator momentarily and use
the regular @kbd{p} command.
-If you use @code{M-# q} from inside the Calculator buffer, the
+If you use @code{C-x * q} from inside the Calculator buffer, the
effect is the same as pressing the apostrophe key (algebraic entry).
The result of a Quick calculation is placed in the Emacs ``kill ring''
as well as being displayed. A subsequent @kbd{C-y} command will
yank the result into the editing buffer. You can also use this
-to yank the result into the next @kbd{M-# q} input line as a more
+to yank the result into the next @kbd{C-x * q} input line as a more
explicit alternative to @kbd{$} notation, or to yank the result
-into the Calculator stack after typing @kbd{M-# c}.
+into the Calculator stack after typing @kbd{C-x * c}.
If you finish your formula by typing @key{LFD} (or @kbd{C-j}) instead
of @key{RET}, the result is inserted immediately into the current
@kbd{d s} (@code{calc-sci-notation}), set a parameter to the value of
the prefix argument or use a default if you don't use a prefix.
Others (like @kbd{d f} (@code{calc-fix-notation})) require an argument
-and prompt for a number if you don't give one as a prefix.@refill
+and prompt for a number if you don't give one as a prefix.
As a rule, stack-manipulation commands accept a numeric prefix argument
which is interpreted as an index into the stack. A positive argument
Numeric prefixes are specified the same way as always in Emacs: Press
a sequence of @key{META}-digits, or press @key{ESC} followed by digits,
or press @kbd{C-u} followed by digits. Some commands treat plain
-@kbd{C-u} (without any actual digits) specially.@refill
+@kbd{C-u} (without any actual digits) specially.
@kindex ~
@pindex calc-num-prefix
top of the stack and enter it as the numeric prefix for the next command.
For example, @kbd{C-u 16 p} sets the precision to 16 digits; an alternate
(silly) way to do this would be @kbd{2 @key{RET} 4 ^ ~ p}, i.e., compute 2
-to the fourth power and set the precision to that value.@refill
+to the fourth power and set the precision to that value.
Conversely, if you have typed a numeric prefix argument the @kbd{~} key
pushes it onto the stack in the form of an integer.
The @kbd{U} key may be pressed any number of times to undo successively
farther back in time; with a numeric prefix argument it undoes a
specified number of operations. The undo history is cleared only by the
-@kbd{q} (@code{calc-quit}) command. (Recall that @kbd{M-# c} is
+@kbd{q} (@code{calc-quit}) command. (Recall that @kbd{C-x * c} is
synonymous with @code{calc-quit} while inside the Calculator; this
also clears the undo history.)
The @kbd{M-@key{RET}} key (@code{calc-last-args}) is like undo in that
it restores the arguments of the most recent command onto the stack;
however, it does not remove the result of that command. Given a numeric
-prefix argument, this command applies to the @cite{n}th most recent
+prefix argument, this command applies to the @expr{n}th most recent
command which removed items from the stack; it pushes those items back
onto the stack.
@cindex Why did an error occur?
Many situations that would produce an error message in other calculators
simply create unsimplified formulas in the Emacs Calculator. For example,
-@kbd{1 @key{RET} 0 /} pushes the formula @cite{1 / 0}; @w{@kbd{0 L}} pushes
+@kbd{1 @key{RET} 0 /} pushes the formula @expr{1 / 0}; @w{@kbd{0 L}} pushes
the formula @samp{ln(0)}. Floating-point overflow and underflow are also
reasons for this to happen.
@noindent
@pindex another-calc
-It is possible to have any number of Calc Mode buffers at once.
+It is possible to have any number of Calc mode buffers at once.
Usually this is done by executing @kbd{M-x another-calc}, which
-is similar to @kbd{M-# c} except that if a @samp{*Calculator*}
+is similar to @kbd{C-x * c} except that if a @samp{*Calculator*}
buffer already exists, a new, independent one with a name of the
form @samp{*Calculator*<@var{n}>} is created. You can also use the
command @code{calc-mode} to put any buffer into Calculator mode, but
necessary; typically this means you will type a command and it won't
work because some function you've never heard of was undefined.
-@kindex M-# L
+@kindex C-x * L
@pindex calc-load-everything
-If this happens, the easiest workaround is to type @kbd{M-# L}
+If this happens, the easiest workaround is to type @kbd{C-x * L}
(@code{calc-load-everything}) to force all the parts of Calc to be
loaded right away. This will cause Emacs to take up a lot more
memory than it would otherwise, but it's guaranteed to fix the problem.
-If you seem to run into this problem no matter what you do, or if
-even the @kbd{M-# L} command crashes, Calc may have been improperly
-installed. @xref{Installation}, for details of the installation
-process.
-
@node Recursion Depth, Caches, Autoloading Problems, Troubleshooting Commands
@subsection Recursion Depth
ever halts incorrectly with the message ``Computation got stuck or
ran too long,'' use the @kbd{M} command (@code{calc-more-recursion-depth})
to increase this limit. (Of course, this will not help if the
-calculation really did get stuck due to some problem inside Calc.)@refill
+calculation really did get stuck due to some problem inside Calc.)
The limit is always increased (multiplied) by a factor of two. There
is also an @kbd{I M} (@code{calc-less-recursion-depth}) command which
@cindex Flushing caches
Calc saves certain values after they have been computed once. For
example, the @kbd{P} (@code{calc-pi}) command initially ``knows'' the
-constant @c{$\pi$}
-@cite{pi} to about 20 decimal places; if the current precision
-is greater than this, it will recompute @c{$\pi$}
-@cite{pi} using a series
+constant @cpi{} to about 20 decimal places; if the current precision
+is greater than this, it will recompute @cpi{} using a series
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
-@c{$\pi \over 4$}
-@cite{pi/4} and @c{$\ln 2$}
-@cite{ln(2)}. The visible effect of caching is that
+@cpiover{4} and
+@texline @math{\ln 2}.
+@infoline @expr{ln(2)}.
+The visible effect of caching is that
high-precision computations may seem to do extra work the first time.
Other things cached include powers of two (for the binary arithmetic
functions), matrix inverses and determinants, symbolic integrals, and
If you suspect a Calculator cache has become corrupt, you can use the
@code{calc-flush-caches} command to reset all caches to the empty state.
(This should only be necessary in the event of bugs in the Calculator.)
-The @kbd{M-# 0} (with the zero key) command also resets caches along
+The @kbd{C-x * 0} (with the zero key) command also resets caches along
with all other aspects of the Calculator's state.
@node Debugging Calc, , Caches, Troubleshooting Commands
This chapter discusses the various types of objects that can be placed
on the Calculator stack, how they are displayed, and how they are
entered. (@xref{Data Type Formats}, for information on how these data
-types are represented as underlying Lisp objects.)@refill
+types are represented as underlying Lisp objects.)
Integers, fractions, and floats are various ways of describing real
numbers. HMS forms also for many purposes act as real numbers. These
subtraction, and multiplication of integers always yields an exact
integer result. (If the result of a division or exponentiation of
integers is not an integer, it is expressed in fractional or
-floating-point form according to the current Fraction Mode.
+floating-point form according to the current Fraction mode.
@xref{Fraction Mode}.)
A decimal integer is represented as an optional sign followed by a
sequence of digits. Grouping (@pxref{Grouping Digits}) can be used to
insert a comma at every third digit for display purposes, but you
-must not type commas during the entry of numbers.@refill
+must not type commas during the entry of numbers.
@kindex #
A non-decimal integer is represented as an optional sign, a radix
digits and do not terminate numeric entry mode. @xref{Radix Modes}, for how
to set the default radix for display of integers. Numbers of any radix
may be entered at any time. If you press @kbd{#} at the beginning of a
-number, the current display radix is used.@refill
+number, the current display radix is used.
@node Fractions, Floats, Integers, Data Types
@section Fractions
written ``2/3'' but Calc uses the notation @samp{2:3}. (The @kbd{/} key
performs RPN division; the following two sequences push the number
@samp{2:3} on the stack: @kbd{2 :@: 3 @key{RET}}, or @kbd{2 @key{RET} 3 /}
-assuming Fraction Mode has been enabled.)
+assuming Fraction mode has been enabled.)
When the Calculator produces a fractional result it always reduces it to
-simplest form, which may in fact be an integer.@refill
+simplest form, which may in fact be an integer.
Fractions may also be entered in a three-part form, where @samp{2:3:4}
represents two-and-three-quarters. @xref{Fraction Formats}, for fraction
-display formats.@refill
+display formats.
Non-decimal fractions are entered and displayed as
@samp{@var{radix}#@var{num}:@var{denom}} (or in the analogous three-part
-form). The numerator and denominator always use the same radix.@refill
+form). The numerator and denominator always use the same radix.
@node Floats, Complex Numbers, Fractions, Data Types
@section Floats
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 @c{$10^{-3999999}$}
-@cite{10^-3999999} (inclusive)
-to @c{$10^{4000000}$}
-@cite{10^4000000}
-(exclusive), plus the corresponding negative
-values and zero.
+range of acceptable values is from
+@texline @math{10^{-3999999}}
+@infoline @expr{10^-3999999}
+(inclusive) to
+@texline @math{10^{4000000}}
+@infoline @expr{10^4000000}
+(exclusive), plus the corresponding negative values and zero.
Calculations that would exceed the allowable range of values (such
as @samp{exp(exp(20))}) are left in symbolic form by Calc. The
accuracy is not rigorously guaranteed. If you suspect the validity of a
result, try doing the same calculation in a higher precision. The
Calculator's arithmetic is not intended to be IEEE-conformant in any
-way.@refill
+way.
While floats are always @emph{stored} in decimal, they can be entered
and displayed in any radix just like integers and fractions. The
@samp{(@var{real},@var{imag})} where @var{real} is the real part and
@var{imag} is the imaginary part, each of which may be any real number.
Rectangular complex numbers can also be displayed in @samp{@var{a}+@var{b}i}
-notation; @pxref{Complex Formats}.@refill
-
-Polar complex numbers are displayed in the form `@t{(}@var{r}@t{;}@c{$\theta$}
-@var{theta}@t{)}'
-where @var{r} is the nonnegative magnitude and @c{$\theta$}
-@var{theta} is the argument
-or phase angle. The range of @c{$\theta$}
-@var{theta} depends on the current angular
-mode (@pxref{Angular Modes}); it is generally between @i{-180} and
-@i{+180} degrees or the equivalent range in radians.@refill
+notation; @pxref{Complex Formats}.
+
+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
+@texline @math{\theta}
+@infoline @var{theta}
+is the argument or phase angle. The range of
+@texline @math{\theta}
+@infoline @var{theta}
+depends on the current angular mode (@pxref{Angular Modes}); it is
+generally between @mathit{-180} and @mathit{+180} degrees or the equivalent range
+in radians.
Complex numbers are entered in stages using incomplete objects.
@xref{Incomplete Objects}.
Operations on rectangular complex numbers yield rectangular complex
results, and similarly for polar complex numbers. Where the two types
are mixed, or where new complex numbers arise (as for the square root of
-a negative real), the current @dfn{Polar Mode} is used to determine the
+a negative real), the current @dfn{Polar mode} is used to determine the
type. @xref{Polar Mode}.
A complex result in which the imaginary part is zero (or the phase angle
-is 0 or 180 degrees or @c{$\pi$}
-@cite{pi} radians) is automatically converted to a real
+is 0 or 180 degrees or @cpi{} radians) is automatically converted to a real
number.
@node Infinities, Vectors and Matrices, Complex Numbers, Data Types
Mathematically speaking, it is not rigorously correct to treat
``infinity'' as if it were a number, but mathematicians often do
so informally. When they say that @samp{1 / inf = 0}, what they
-really mean is that @cite{1 / x}, as @cite{x} becomes larger and
+really mean is that @expr{1 / x}, as @expr{x} becomes larger and
larger, becomes arbitrarily close to zero. So you can imagine
-that if @cite{x} got ``all the way to infinity,'' then @cite{1 / x}
+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 @c{$e^x$}
-@cite{exp(x)} grows without
-bound as @cite{x} grows. The symbol @samp{-inf} likewise stands
-for an infinitely negative real value; for example, we say that
+@samp{exp(inf) = inf}, they mean that
+@texline @math{e^x}
+@infoline @expr{exp(x)}
+grows without bound as @expr{x} grows. The symbol @samp{-inf} likewise
+stands for an infinitely negative real value; for example, we say that
@samp{exp(-inf) = 0}. You can have an infinity pointing in any
direction on the complex plane: @samp{sqrt(-inf) = i inf}.
-The same concept of limits can be used to define @cite{1 / 0}. We
-really want the value that @cite{1 / x} approaches as @cite{x}
-approaches zero. But if all we have is @cite{1 / 0}, we can't
-tell which direction @cite{x} was coming from. If @cite{x} was
+The same concept of limits can be used to define @expr{1 / 0}. We
+really want the value that @expr{1 / x} approaches as @expr{x}
+approaches zero. But if all we have is @expr{1 / 0}, we can't
+tell which direction @expr{x} was coming from. If @expr{x} was
positive and decreasing toward zero, then we should say that
-@samp{1 / 0 = inf}. But if @cite{x} was negative and increasing
-toward zero, the answer is @samp{1 / 0 = -inf}. In fact, @cite{x}
+@samp{1 / 0 = inf}. But if @expr{x} was negative and increasing
+toward zero, the answer is @samp{1 / 0 = -inf}. In fact, @expr{x}
could be an imaginary number, giving the answer @samp{i inf} or
@samp{-i inf}. Calc uses the special symbol @samp{uinf} to mean
@dfn{undirected infinity}, i.e., a value which is infinitely
Calc actually has three modes that say how infinities are handled.
Normally, infinities never arise from calculations that didn't
-already have them. Thus, @cite{1 / 0} is treated simply as an
+already have them. Thus, @expr{1 / 0} is treated simply as an
error and left unevaluated. The @kbd{m i} (@code{calc-infinite-mode})
command (@pxref{Infinite Mode}) enables a mode in which
-@cite{1 / 0} evaluates to @code{uinf} instead. There is also
+@expr{1 / 0} evaluates to @code{uinf} instead. There is also
an alternative type of infinite mode which says to treat zeros
as if they were positive, so that @samp{1 / 0 = inf}. While this
is less mathematically correct, it may be the answer you want in
It's not so easy to define certain formulas like @samp{0 * inf} and
@samp{inf / inf}. Depending on where these zeros and infinities
came from, the answer could be literally anything. The latter
-formula could be the limit of @cite{x / x} (giving a result of one),
-or @cite{2 x / x} (giving two), or @cite{x^2 / x} (giving @code{inf}),
-or @cite{x / x^2} (giving zero). Calc uses the symbol @code{nan}
+formula could be the limit of @expr{x / x} (giving a result of one),
+or @expr{2 x / x} (giving two), or @expr{x^2 / x} (giving @code{inf}),
+or @expr{x / x^2} (giving zero). Calc uses the symbol @code{nan}
to represent such an @dfn{indeterminate} value. (The name ``nan''
comes from analogy with the ``NAN'' concept of IEEE standard
arithmetic; it stands for ``Not A Number.'' This is somewhat of a
cannot be determined.) In Calc's notation, @samp{0 * inf = nan}
and @samp{inf / inf = nan}. A few other common indeterminate
expressions are @samp{inf - inf} and @samp{inf ^ 0}. Also,
-@samp{0 / 0 = nan} if you have turned on ``infinite mode''
+@samp{0 / 0 = nan} if you have turned on Infinite mode
(as described above).
Infinities are especially useful as parts of @dfn{intervals}.
@pxref{Basic Arithmetic} and @pxref{Matrix Functions}.
Many other operations are applied to vectors element-wise. For example,
the complex conjugate of a vector is a vector of the complex conjugates
-of its elements.@refill
+of its elements.
@ignore
@starindex
@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 @c{$n\times m$}
-@asis{@var{n}x@var{m}}
+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
from 1 to @samp{n}.
The @var{secs} value is a real number between 0 (inclusive) and 60
(exclusive). A positive HMS form is interpreted as @var{hours} +
@var{mins}/60 + @var{secs}/3600. A negative HMS form is interpreted
-as @i{- @var{hours}} @i{-} @var{mins}/60 @i{-} @var{secs}/3600.
-Display format for HMS forms is quite flexible. @xref{HMS Formats}.@refill
+as @mathit{- @var{hours}} @mathit{-} @var{mins}/60 @mathit{-} @var{secs}/3600.
+Display format for HMS forms is quite flexible. @xref{HMS Formats}.
HMS forms can be added and subtracted. When they are added to numbers,
the numbers are interpreted according to the current angular mode. HMS
Calc uses the Julian calendar for all dates before the year 1752,
including dates BC when the Julian calendar technically had not
-yet been invented. Thus the claim that day number @i{-10000} is
+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 @i{-1} respectively in Calc's internal numbering scheme.
+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
Scaliger, who named it in honor of his father Julius Caesar
Scaliger. For obscure reasons he chose to start his day
numbering on Jan 1, 4713 BC at noon, which in Calc's scheme
-is @i{-1721423.5} (recall that Calc starts at midnight instead
+is @mathit{-1721423.5} (recall that Calc starts at midnight instead
of noon). Thus to convert a Calc date code obtained by
unpacking a date form into a Julian day number, simply add
1721423.5. The Julian code for @samp{6:00am Jan 9, 1991}
A @dfn{modulo form} is a real number which is taken modulo (i.e., within
an integer multiple of) some value @var{M}. Arithmetic modulo @var{M}
often arises in number theory. Modulo forms are written
-`@var{a} @t{mod} @var{M}',
+`@var{a} @tfn{mod} @var{M}',
where @var{a} and @var{M} are real numbers or HMS forms, and
-@c{$0 \le a < M$}
-@cite{0 <= a < @var{M}}.
-In many applications @cite{a} and @cite{M} will be
-integers but this is not required.@refill
+@texline @math{0 \le a < M}.
+@infoline @expr{0 <= a < @var{M}}.
+In many applications @expr{a} and @expr{M} will be
+integers but this is not required.
+
+@ignore
+@mindex M
+@end ignore
+@kindex M (modulo forms)
+@ignore
+@mindex mod
+@end ignore
+@tindex mod (operator)
+To create a modulo form during numeric entry, press the shift-@kbd{M}
+key to enter the word @samp{mod}. As a special convenience, pressing
+shift-@kbd{M} a second time automatically enters the value of @expr{M}
+that was most recently used before. During algebraic entry, either
+type @samp{mod} by hand or press @kbd{M-m} (that's @kbd{@key{META}-m}).
+Once again, pressing this a second time enters the current modulo.
Modulo forms are not to be confused with the modulo operator @samp{%}.
The expression @samp{27 % 10} means to compute 27 modulo 10 to produce
further computations with this value are again reduced modulo 10 so that
the result always lies in the desired range.
-When two modulo forms with identical @cite{M}'s are added or multiplied,
+When two modulo forms with identical @expr{M}'s are added or multiplied,
the Calculator simply adds or multiplies the values, then reduces modulo
-@cite{M}. If one argument is a modulo form and the other a plain number,
+@expr{M}. If one argument is a modulo form and the other a plain number,
the plain number is treated like a compatible modulo form. It is also
possible to raise modulo forms to powers; the result is the value raised
-to the power, then reduced modulo @cite{M}. (When all values involved
+to the power, then reduced modulo @expr{M}. (When all values involved
are integers, this calculation is done much more efficiently than
actually computing the power and then reducing.)
@cindex Modulo division
-Two modulo forms `@var{a} @t{mod} @var{M}' and `@var{b} @t{mod} @var{M}'
-can be divided if @cite{a}, @cite{b}, and @cite{M} are all
+Two modulo forms `@var{a} @tfn{mod} @var{M}' and `@var{b} @tfn{mod} @var{M}'
+can be divided if @expr{a}, @expr{b}, and @expr{M} are all
integers. The result is the modulo form which, when multiplied by
-`@var{b} @t{mod} @var{M}', produces `@var{a} @t{mod} @var{M}'. If
+`@var{b} @tfn{mod} @var{M}', produces `@var{a} @tfn{mod} @var{M}'. If
there is no solution to this equation (which can happen only when
-@cite{M} is non-prime), or if any of the arguments are non-integers, the
+@expr{M} is non-prime), or if any of the arguments are non-integers, the
division is left in symbolic form. Other operations, such as square
roots, are not yet supported for modulo forms. (Note that, although
-@w{`@t{(}@var{a} @t{mod} @var{M}@t{)^.5}'} will compute a ``modulo square root''
-in the sense of reducing @c{$\sqrt a$}
-@cite{sqrt(a)} modulo @cite{M}, this is not a
-useful definition from the number-theoretical point of view.)@refill
-
-@ignore
-@mindex M
-@end ignore
-@kindex M (modulo forms)
-@ignore
-@mindex mod
-@end ignore
-@tindex mod (operator)
-To create a modulo form during numeric entry, press the shift-@kbd{M}
-key to enter the word @samp{mod}. As a special convenience, pressing
-shift-@kbd{M} a second time automatically enters the value of @cite{M}
-that was most recently used before. During algebraic entry, either
-type @samp{mod} by hand or press @kbd{M-m} (that's @kbd{@key{META}-m}).
-Once again, pressing this a second time enters the current modulo.@refill
-
-You can also use @kbd{v p} and @kbd{%} to modify modulo forms.
-@xref{Building Vectors}. @xref{Basic Arithmetic}.
+@w{`@tfn{(}@var{a} @tfn{mod} @var{M}@tfn{)^.5}'} will compute a ``modulo square root''
+in the sense of reducing
+@texline @math{\sqrt a}
+@infoline @expr{sqrt(a)}
+modulo @expr{M}, this is not a useful definition from the
+number-theoretical point of view.)
It is possible to mix HMS forms and modulo forms. For example, an
HMS form modulo 24 could be used to manipulate clock times; an HMS
-form modulo 360 would be suitable for angles. Making the modulo @cite{M}
+form modulo 360 would be suitable for angles. Making the modulo @expr{M}
also be an HMS form eliminates troubles that would arise if the angular
mode were inadvertently set to Radians, in which case
@w{@samp{2@@ 0' 0" mod 24}} would be interpreted as two degrees modulo
enter the formula @samp{(x + 2) mod 5}, Calc propagates the modulus
to each of the coefficients: @samp{(1 mod 5) x + (2 mod 5)}.
+You can use @kbd{v p} and @kbd{%} to modify modulo forms.
+@xref{Packing and Unpacking}. @xref{Basic Arithmetic}.
+
@ignore
@starindex
@end ignore
@cindex Standard deviations
An @dfn{error form} is a number with an associated standard
deviation, as in @samp{2.3 +/- 0.12}. The notation
-`@var{x} @t{+/-} @c{$\sigma$}
-@asis{sigma}' stands for an uncertain value which follows a normal or
-Gaussian distribution of mean @cite{x} and standard deviation or
-``error'' @c{$\sigma$}
-@cite{sigma}. Both the mean and the error can be either numbers or
+@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''
+@texline @math{\sigma}.
+@infoline @expr{sigma}.
+Both the mean and the error can be either numbers or
formulas. Generally these are real numbers but the mean may also be
complex. If the error is negative or complex, it is changed to its
absolute value. An error form with zero error is converted to a
-regular number by the Calculator.@refill
+regular number by the Calculator.
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 @cite{f(x)} (such as @c{$\sin x$}
-@cite{sin(x)})
-is defined by the error of @cite{x} times the derivative of @cite{f}
-evaluated at the mean value of @cite{x}. For a two-argument function
-@cite{f(x,y)} (such as addition) the error is the square root of the sum
-of the squares of the errors due to @cite{x} and @cite{y}.
+numbers. The error part for any function @expr{f(x)} (such as
+@texline @math{\sin x}
+@infoline @expr{sin(x)})
+is defined by the error of @expr{x} times the derivative of @expr{f}
+evaluated at the mean value of @expr{x}. For a two-argument function
+@expr{f(x,y)} (such as addition) the error is the square root of the sum
+of the squares of the errors due to @expr{x} and @expr{y}.
@tex
$$ \eqalign{
f(x \hbox{\code{ +/- }} \sigma)
} $$
@end tex
Note that this
-definition assumes the errors in @cite{x} and @cite{y} are uncorrelated.
+definition assumes the errors in @expr{x} and @expr{y} are uncorrelated.
A side effect of this definition is that @samp{(2 +/- 1) * (2 +/- 1)}
is not the same as @samp{(2 +/- 1)^2}; the former represents the product
of two independent values which happen to have the same probability
distributions, and the latter is the product of one random value with itself.
The former will produce an answer with less error, since on the average
-the two independent errors can be expected to cancel out.@refill
+the two independent errors can be expected to cancel out.
Consult a good text on error analysis for a discussion of the proper use
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
-`@t{sin(}@var{x} @t{+/-} @c{$\sigma$}
-@var{sigma}@t{)}' is
-`@c{$\sigma$\nobreak}
-@var{sigma} @t{abs(cos(}@var{x}@t{))}'. When @cite{x} is close to zero,
-@c{$\cos x$}
-@cite{cos(x)} is
-close to one so the error in the sine is close to @c{$\sigma$}
-@cite{sigma}; this makes sense, since @c{$\sin x$}
-@cite{sin(x)} is approximately @cite{x} near zero, so a given
-error in @cite{x} will produce about the same error in the sine. Likewise,
-near 90 degrees @c{$\cos x$}
-@cite{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 @cite{x}
-has relatively little effect on the value of @c{$\sin x$}
-@cite{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 @cite{x} had been small, the error in @c{$\sin x$}
-@cite{sin(x)} would indeed have been negligible.@refill
+@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
+@texline @math{\sigma};
+@infoline @expr{sigma};
+this makes sense, since
+@texline @math{\sin x}
+@infoline @expr{sin(x)}
+is approximately @expr{x} near zero, so a given error in @expr{x} will
+produce about the same error in the sine. Likewise, near 90 degrees
+@texline @math{\cos x}
+@infoline @expr{cos(x)}
+is nearly zero and so the computed error is
+small: The sine curve is nearly flat in that region, so an error in @expr{x}
+has relatively little effect on the value of
+@texline @math{\sin x}.
+@infoline @expr{sin(x)}.
+However, consider @samp{sin(90 +/- 1000)}. The cosine of 90 is zero, so
+Calc will report zero error! We get an obviously wrong result because
+we have violated the small-error approximation underlying the error
+analysis. If the error in @expr{x} had been small, the error in
+@texline @math{\sin x}
+@infoline @expr{sin(x)}
+would indeed have been negligible.
@ignore
@mindex p
To enter an error form during regular numeric entry, use the @kbd{p}
(``plus-or-minus'') key to type the @samp{+/-} symbol. (If you try actually
typing @samp{+/-} the @kbd{+} key will be interpreted as the Calculator's
-@kbd{+} command!) Within an algebraic formula, you can press @kbd{M-p} to
+@kbd{+} command!) Within an algebraic formula, you can press @kbd{M-+} to
type the @samp{+/-} symbol, or type it out by hand.
Error forms and complex numbers can be mixed; the formulas shown above
@emph{exclusive}, and @dfn{semi-open} intervals in which one end
uses a round parenthesis and the other a square bracket. In mathematical
terms,
-@samp{[2 ..@: 4]} means @cite{2 <= x <= 4}, whereas
-@samp{[2 ..@: 4)} represents @cite{2 <= x < 4},
-@samp{(2 ..@: 4]} represents @cite{2 < x <= 4}, and
-@samp{(2 ..@: 4)} represents @cite{2 < x < 4}.@refill
+@samp{[2 ..@: 4]} means @expr{2 <= x <= 4}, whereas
+@samp{[2 ..@: 4)} represents @expr{2 <= x < 4},
+@samp{(2 ..@: 4]} represents @expr{2 < x <= 4}, and
+@samp{(2 ..@: 4)} represents @expr{2 < x < 4}.
@end ifinfo
@tex
Calc supports several varieties of intervals, including \dfn{closed}
get the other interpretation. If you omit the lower or upper limit,
a default of @samp{-inf} or @samp{inf} (respectively) is furnished.
-``Infinite mode'' also affects operations on intervals
+Infinite mode also affects operations on intervals
(@pxref{Infinities}). Calc will always introduce an open infinity,
as in @samp{1 / (0 .. 2] = [0.5 .. inf)}. But closed infinities,
-@w{@samp{1 / [0 .. 2] = [0.5 .. inf]}}, arise only in infinite mode;
+@w{@samp{1 / [0 .. 2] = [0.5 .. inf]}}, arise only in Infinite mode;
otherwise they are left unevaluated. Note that the ``direction'' of
a zero is not an issue in this case since the zero is always assumed
to be continuous with the rest of the interval. For intervals that
While it may seem that intervals and error forms are similar, they are
based on entirely different concepts of inexact quantities. An error
-form `@var{x} @t{+/-} @c{$\sigma$}
-@var{sigma}' means a variable is random, and its value could
-be anything but is ``probably'' within one @c{$\sigma$}
-@var{sigma} of the mean value @cite{x}.
-An interval `@t{[}@var{a} @t{..@:} @var{b}@t{]}' means a variable's value
-is unknown, but guaranteed to lie in the specified range. Error forms
-are statistical or ``average case'' approximations; interval arithmetic
-tends to produce ``worst case'' bounds on an answer.@refill
+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
+`@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;
+interval arithmetic tends to produce ``worst case'' bounds on an
+answer.
Intervals may not contain complex numbers, but they may contain
HMS forms or date forms.
If several values lie on the stack in front of the incomplete object,
all are collected and appended to the object. Thus the @kbd{,} key
is redundant: @kbd{[ 2 @key{RET} 3 @key{RET} 2 * 9 ]}. Some people
-prefer the equivalent @key{SPC} key to @key{RET}.@refill
+prefer the equivalent @key{SPC} key to @key{RET}.
As a special case, typing @kbd{,} immediately after @kbd{(}, @kbd{[}, or
@kbd{,} adds a zero or duplicates the preceding value in the list being
variable is really just an Emacs Lisp variable that contains a Calc number
or formula.) A variable's name is normally composed of letters and digits.
Calc also allows apostrophes and @code{#} signs in variable names.
-The Calc variable @code{foo} corresponds to the Emacs Lisp variable
-@code{var-foo}. Commands like @kbd{s s} (@code{calc-store}) that operate
-on variables can be made to use any arbitrary Lisp variable simply by
-backspacing over the @samp{var-} prefix in the minibuffer.@refill
+(The Calc variable @code{foo} corresponds to the Emacs Lisp variable
+@code{var-foo}, but unless you access the variable from within Emacs
+Lisp, you don't need to worry about it. Variable names in algebraic
+formulas implicitly have @samp{var-} prefixed to their names. The
+@samp{#} character in variable names used in algebraic formulas
+corresponds to a dash @samp{-} in the Lisp variable name. If the name
+contains any dashes, the prefix @samp{var-} is @emph{not} automatically
+added. Thus the two formulas @samp{foo + 1} and @samp{var#foo + 1} both
+refer to the same variable.)
In a command that takes a variable name, you can either type the full
name of a variable, or type a single digit to use one of the special
-convenience variables @code{var-q0} through @code{var-q9}. For example,
-@kbd{3 s s 2} stores the number 3 in variable @code{var-q2}, and
+convenience variables @code{q0} through @code{q9}. For example,
+@kbd{3 s s 2} stores the number 3 in variable @code{q2}, and
@w{@kbd{3 s s foo @key{RET}}} stores that number in variable
-@code{var-foo}.@refill
+@code{foo}.
To push a variable itself (as opposed to the variable's value) on the
stack, enter its name as an algebraic expression using the apostrophe
-(@key{'}) key. Variable names in algebraic formulas implicitly have
-@samp{var-} prefixed to their names. The @samp{#} character in variable
-names used in algebraic formulas corresponds to a dash @samp{-} in the
-Lisp variable name. If the name contains any dashes, the prefix @samp{var-}
-is @emph{not} automatically added. Thus the two formulas @samp{foo + 1}
-and @samp{var#foo + 1} both refer to the same variable.
+(@key{'}) key.
@kindex =
@pindex calc-evaluate
(@xref{Scientific Functions}.) When they are evaluated with @kbd{=},
their values are calculated if necessary according to the current precision
or complex polar mode. If you wish to use these symbols for other purposes,
-simply undefine or redefine them using @code{calc-store}.@refill
+simply undefine or redefine them using @code{calc-store}.
The variables @samp{inf}, @samp{uinf}, and @samp{nan} stand for
infinite or indeterminate values. It's best not to use them as
@samp{=>} [@code{evalto}].
Note that, unlike in usual computer notation, multiplication binds more
-strongly than division: @samp{a*b/c*d} is equivalent to @c{$a b \over c d$}
-@cite{(a*b)/(c*d)}.
+strongly than division: @samp{a*b/c*d} is equivalent to
+@texline @math{a b \over c d}.
+@infoline @expr{(a*b)/(c*d)}.
@cindex Multiplication, implicit
@cindex Implicit multiplication
cases you must use a space if you omit the @samp{*}: @samp{2a} is the
same as @samp{2*a}, and @samp{a b} is the same as @samp{a*b}, but @samp{ab}
is a variable called @code{ab}, @emph{not} the product of @samp{a} and
-@samp{b}! Also note that @samp{f (x)} is still a function call.@refill
+@samp{b}! Also note that @samp{f (x)} is still a function call.
@cindex Implicit comma in vectors
The rules are slightly different for vectors written with square brackets.
ignored. To force spaces to be interpreted as multiplication you can
enclose a formula in parentheses as in @samp{[(a b) 2(c d)]}, which is
interpreted as @samp{[a*b, 2*c*d]}. An implicit comma is also inserted
-between @samp{][}, as in the matrix @samp{[[1 2][3 4]]}.@refill
+between @samp{][}, as in the matrix @samp{[[1 2][3 4]]}.
Vectors that contain commas (not embedded within nested parentheses or
brackets) do not treat spaces specially: @samp{[a b, 2 c d]} is a vector
need to write @samp{(5%)-2} to get the former interpretation.
@cindex Function call notation
-A function call is, e.g., @samp{sin(1+x)}. Function names follow the same
-rules as variable names except that the default prefix @samp{calcFunc-} is
-used (instead of @samp{var-}) for the internal Lisp form.
-Most mathematical Calculator commands like
+A function call is, e.g., @samp{sin(1+x)}. (The Calc algebraic function
+@code{foo} corresponds to the Emacs Lisp function @code{calcFunc-foo},
+but unless you access the function from within Emacs Lisp, you don't
+need to worry about it.) Most mathematical Calculator commands like
@code{calc-sin} have function equivalents like @code{sin}.
If no Lisp function is defined for a function called by a formula, the
call is left as it is during algebraic manipulation: @samp{f(x+y)} is
left alone. Beware that many innocent-looking short names like @code{in}
and @code{re} have predefined meanings which could surprise you; however,
single letters or single letters followed by digits are always safe to
-use for your own function names. @xref{Function Index}.@refill
+use for your own function names. @xref{Function Index}.
In the documentation for particular commands, the notation @kbd{H S}
(@code{calc-sinh}) [@code{sinh}] means that the key sequence @kbd{H S}, the
command @kbd{M-x calc-sinh}, and the algebraic function @code{sinh(x)} all
-represent the same operation.@refill
+represent the same operation.
Commands that interpret (``parse'') text as algebraic formulas include
algebraic entry (@kbd{'}), editing commands like @kbd{`} which parse
-the contents of the editing buffer when you finish, the @kbd{M-# g}
-and @w{@kbd{M-# r}} commands, the @kbd{C-y} command, the X window system
-``paste'' mouse operation, and Embedded Mode. All of these operations
+the contents of the editing buffer when you finish, the @kbd{C-x * g}
+and @w{@kbd{C-x * r}} commands, the @kbd{C-y} command, the X window system
+``paste'' mouse operation, and Embedded mode. All of these operations
use the same rules for parsing formulas; in particular, language modes
(@pxref{Language Modes}) affect them all in the same way.
@key{RET} creates @samp{10 20 30 30},
@kbd{C-u 2 @key{RET}} creates @samp{10 20 30 20 30},
@kbd{C-u - 2 @key{RET}} creates @samp{10 20 30 20}, and
-@kbd{C-u 0 @key{RET}} creates @samp{10 20 30 10 20 30}.@refill
+@kbd{C-u 0 @key{RET}} creates @samp{10 20 30 10 20 30}.
@kindex @key{LFD}
@pindex calc-over
oppositely. Also, with no prefix argument the default argument is 2.
Thus with @samp{10 20 30} on the stack, @key{LFD} and @kbd{C-u 2 @key{LFD}}
are both equivalent to @kbd{C-u - 2 @key{RET}}, producing
-@samp{10 20 30 20}.@refill
+@samp{10 20 30 20}.
@kindex @key{DEL}
@kindex C-d
@key{DEL} leaves @samp{10 20},
@kbd{C-u 2 @key{DEL}} leaves @samp{10},
@kbd{C-u - 2 @key{DEL}} leaves @samp{10 30}, and
-@kbd{C-u 0 @key{DEL}} leaves an empty stack.@refill
+@kbd{C-u 0 @key{DEL}} leaves an empty stack.
@kindex M-@key{DEL}
@pindex calc-pop-above
@key{TAB} creates @samp{10 20 30 50 40},
@kbd{C-u 3 @key{TAB}} creates @samp{10 20 50 30 40},
@kbd{C-u - 2 @key{TAB}} creates @samp{40 50 10 20 30}, and
-@kbd{C-u 0 @key{TAB}} creates @samp{50 40 30 20 10}.@refill
+@kbd{C-u 0 @key{TAB}} creates @samp{50 40 30 20 10}.
@kindex M-@key{TAB}
@pindex calc-roll-up
@kbd{M-@key{TAB}} creates @samp{10 20 40 50 30},
@kbd{C-u 4 M-@key{TAB}} creates @samp{10 30 40 50 20},
@kbd{C-u - 2 M-@key{TAB}} creates @samp{30 40 50 10 20}, and
-@kbd{C-u 0 M-@key{TAB}} creates @samp{50 40 30 20 10}.@refill
+@kbd{C-u 0 M-@key{TAB}} creates @samp{50 40 30 20 10}.
A good way to view the operation of @key{TAB} and @kbd{M-@key{TAB}} is in
terms of moving a particular element to a new position in the stack.
element at level @var{n} up to the top. (Compare with @key{LFD},
which copies instead of moving the element in level @var{n}.)
-With a negative argument @i{-@var{n}}, @key{TAB} rotates the stack
+With a negative argument @mathit{-@var{n}}, @key{TAB} rotates the stack
to move the object in level @var{n} to the deepest place in the
-stack, and the object in level @i{@var{n}+1} to the top. @kbd{M-@key{TAB}}
-rotates the deepest stack element to be in level @i{n}, also
-putting the top stack element in level @i{@var{n}+1}.
+stack, and the object in level @mathit{@var{n}+1} to the top. @kbd{M-@key{TAB}}
+rotates the deepest stack element to be in level @mathit{n}, also
+putting the top stack element in level @mathit{@var{n}+1}.
@xref{Selecting Subformulas}, for a way to apply these commands to
any portion of a vector or formula on the stack.
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{M-# M-#} to finish and return
+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
sorts of editing, though in some cases Calc leaves @key{RET} with its
usual meaning (``insert a newline'') if it's a situation where you
-might want to insert new lines into the editing buffer. The traditional
-Emacs ``finish'' key sequence, @kbd{C-c C-c}, also works to finish
-editing and may be easier to type, depending on your keyboard.
+might want to insert new lines into the editing buffer.
When you finish editing, the Calculator parses the lines of text in
the @samp{*Calc Edit*} buffer as numbers or formulas, replaces the
then kills the @samp{*Calc Edit*} buffer. The original Calculator buffer
continues to exist during editing, but for best results you should be
careful not to change it until you have finished the edit. You can
-also cancel the edit by pressing @kbd{M-# x}.
+also cancel the edit by killing the buffer with @kbd{C-x k}.
The formula is normally reevaluated as it is put onto the stack.
For example, editing @samp{a + 2} to @samp{3 + 2} and pressing
-@kbd{M-# M-#} will push 5 on the stack. If you use @key{LFD} to
+@kbd{C-c C-c} will push 5 on the stack. If you use @key{LFD} to
finish, Calc will put the result on the stack without evaluating it.
-If you give a prefix argument to @kbd{M-# M-#} (or @kbd{C-c C-c}),
+If you give a prefix argument to @kbd{C-c C-c},
Calc will not kill the @samp{*Calc Edit*} buffer. You can switch
back to that buffer and continue editing if you wish. However, you
should understand that if you initiated the edit with @kbd{`}, the
-@kbd{M-# M-#} operation will be programmed to replace the top of the
+@kbd{C-c C-c} operation will be programmed to replace the top of the
stack with the new edited value, and it will do this even if you have
rearranged the stack in the meanwhile. This is not so much of a problem
with other editing commands, though, such as @kbd{s e}
Calc Trail window. In practice they are rarely used, since the commands
shown below are a more convenient way to move around in the
trail, and they work ``by remote control'' when the cursor is still
-in the Calculator window.@refill
+in the Calculator window.
@cindex Trail pointer
There is a @dfn{trail pointer} which selects some entry of the trail at
@pindex calc-trail-scroll-right
The @kbd{t <} (@code{calc-trail-scroll-left}) and @kbd{t >}
(@code{calc-trail-scroll-right}) commands horizontally scroll the trail
-window left or right by one half of its width.@refill
+window left or right by one half of its width.
@kindex t n
@pindex calc-trail-next
one line. The @kbd{t f} (@code{calc-trail-forward}) and @kbd{t b}
(@code{calc-trail-backward}) commands move the trail pointer down or up
one screenful at a time. All of these commands accept numeric prefix
-arguments to move several lines or screenfuls at a time.@refill
+arguments to move several lines or screenfuls at a time.
@kindex t [
@pindex calc-trail-first
(@code{calc-trail-last}) commands move the trail pointer to the first or
last line of the trail. The @kbd{t h} (@code{calc-trail-here}) command
moves the trail pointer to the cursor position; unlike the other trail
-commands, @kbd{t h} works only when Calc Trail is the selected window.@refill
+commands, @kbd{t h} works only when Calc Trail is the selected window.
@kindex t s
@pindex calc-trail-isearch-forward
search forward or backward through the trail. You can press @key{RET}
to terminate the search; the trail pointer moves to the current line.
If you cancel the search with @kbd{C-g}, the trail pointer stays where
-it was when the search began.@refill
+it was when the search began.
@end ifinfo
@tex
The @kbd{t s} (@code{calc-trail-isearch-forward}) and @kbd{t r}
the stack contains the sole number 5, but after @kbd{2 @key{RET} 3 K +},
the stack contains the arguments and the result: @samp{2 3 5}.
-This works for all commands that take arguments off the stack. As
-another example, @kbd{K a s} simplifies a formula, pushing the
+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.)
+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 could get the same effect by typing @kbd{@key{RET} a s},
-copying the 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.
+formula (rather than replacing the original formula). Note that you
+could get the same effect by typing @kbd{@key{RET} a s}, copying the
+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.
Even stack manipulation commands are affected. @key{TAB} works by
popping two values and pushing them back in the opposite order,
@kbd{K ' sin($)}. @xref{Algebraic Entry}. Also, the @kbd{s s}
command is effectively the same as @kbd{K s t}. @xref{Storing Variables}.
-Keyboard macros may interact surprisingly with the @kbd{K} prefix.
-If you have defined a keyboard macro to be, say, @samp{Q +} to add
-one number to the square root of another, then typing @kbd{K X} will
-execute @kbd{K Q +}, probably not what you expected. The @kbd{K}
-prefix will apply to just the first command in the macro rather than
-the whole macro.
-
If you execute a command and then decide you really wanted to keep
the argument, you can press @kbd{M-@key{RET}} (@code{calc-last-args}).
This command pushes the last arguments that were popped by any command
@cindex Continuous memory
@cindex Saving mode settings
@cindex Permanent mode settings
-@cindex @file{.emacs} file, mode settings
-You can save all of the current mode settings in your @file{.emacs} file
-with the @kbd{m m} (@code{calc-save-modes}) command. This will cause
-Emacs to reestablish these modes each time it starts up. The modes saved
-in the file include everything controlled by the @kbd{m} and @kbd{d}
-prefix keys, the current precision and binary word size, whether or not
-the trail is displayed, the current height of the Calc window, and more.
-The current interface (used when you type @kbd{M-# M-#}) is also saved.
-If there were already saved mode settings in the file, they are replaced.
-Otherwise, the new mode information is appended to the end of the file.
+@cindex Calc init file, mode settings
+You can save all of the current mode settings in your Calc init file
+(the file given by the variable @code{calc-settings-file}, typically
+@file{~/.calc.el}) with the @kbd{m m} (@code{calc-save-modes}) command.
+This will cause Emacs to reestablish these modes each time it starts up.
+The modes saved in the file include everything controlled by the @kbd{m}
+and @kbd{d} prefix keys, the current precision and binary word size,
+whether or not the trail is displayed, the current height of the Calc
+window, and more. The current interface (used when you type @kbd{C-x * *})
+is also saved. If there were already saved mode settings in the
+file, they are replaced. Otherwise, the new mode information is
+appended to the end of the file.
@kindex m R
@pindex calc-mode-record-mode
The @kbd{m R} (@code{calc-mode-record-mode}) command tells Calc to
-record the new mode settings (as if by pressing @kbd{m m}) every
-time a mode setting changes. If Embedded Mode is enabled, other
-options are available; @pxref{Mode Settings in Embedded Mode}.
+record all the mode settings (as if by pressing @kbd{m m}) every
+time a mode setting changes. If the modes are saved this way, then this
+``automatic mode recording'' mode is also saved.
+Type @kbd{m R} again to disable this method of recording the mode
+settings. To turn it off permanently, the @kbd{m m} command will also be
+necessary. (If Embedded mode is enabled, other options for recording
+the modes are available; @pxref{Mode Settings in Embedded Mode}.)
@kindex m F
@pindex calc-settings-file-name
The @kbd{m F} (@code{calc-settings-file-name}) command allows you to
-choose a different place than your @file{.emacs} file for @kbd{m m},
-@kbd{Z P}, and similar commands to save permanent information.
+choose a different file than the current value of @code{calc-settings-file}
+for @kbd{m m}, @kbd{Z P}, and similar commands to save permanent information.
You are prompted for a file name. All Calc modes are then reset to
their default values, then settings from the file you named are loaded
if this file exists, and this file becomes the one that Calc will
use in the future for commands like @kbd{m m}. The default settings
-file name is @file{~/.emacs}. You can see the current file name by
+file name is @file{~/.calc.el}. You can see the current file name by
giving a blank response to the @kbd{m F} prompt. See also the
-discussion of the @code{calc-settings-file} variable; @pxref{Installation}.
+discussion of the @code{calc-settings-file} variable; @pxref{Customizing Calc}.
-If the file name you give contains the string @samp{.emacs} anywhere
-inside it, @kbd{m F} will not automatically load the new file. This
-is because you are presumably switching to your @file{~/.emacs} file,
-which may contain other things you don't want to reread. You can give
+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
a numeric prefix argument of 1 to @kbd{m F} to force it to read the
-file no matter what its name. Conversely, an argument of @i{-1} tells
-@kbd{m F} @emph{not} to read the new file. An argument of 2 or @i{-2}
+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}
tells @kbd{m F} not to reset the modes to their defaults beforehand,
which is useful if you intend your new file to have a variant of the
modes present in the file you were using before.
until the various advanced Calc features are used. Since this mode only
has effect when Calc is first loaded, @kbd{m x} is usually followed by
@kbd{m m} to make the mode-setting permanent. To load all of Calc just
-once, rather than always in the future, you can press @kbd{M-# L}.
+once, rather than always in the future, you can press @kbd{C-x * L}.
@kindex m S
@pindex calc-shift-prefix
round values already on the stack, but those values will be rounded
down before being used in any calculation. The @kbd{c 0} through
@kbd{c 9} commands (@pxref{Conversions}) can be used to round an
-existing value to a new precision.@refill
+existing value to a new precision.
@cindex Accuracy of calculations
It is important to distinguish the concepts of @dfn{precision} and
Instead, you must first press @kbd{I} (@code{calc-inverse}) to set
the @dfn{Inverse Flag}, then press @kbd{S} (@code{calc-sin}).
The @kbd{I} key actually toggles the Inverse Flag. When this flag
-is set, the word @samp{Inv} appears in the mode line.@refill
+is set, the word @samp{Inv} appears in the mode line.
@kindex H
@pindex calc-hyperbolic
If both of these flags are set at once, the effect will be
@code{calc-arcsinh}. (The Hyperbolic flag is also used by some
non-trigonometric commands; for example @kbd{H L} computes a base-10,
-instead of base-@i{e}, logarithm.)@refill
+instead of base-@mathit{e}, logarithm.)
Command names like @code{calc-arcsin} are provided for completeness, and
may be executed with @kbd{x} or @kbd{M-x}. Their effect is simply to
degrees, or an HMS form depending on the current angular mode. If the
result is a complex number and the current mode is HMS, the number is
instead expressed in degrees. (Complex-number calculations would
-normally be done in radians mode, though. Complex numbers are converted
+normally be done in Radians mode, though. Complex numbers are converted
to degrees by calculating the complex result in radians and then
-multiplying by 180 over @c{$\pi$}
-@cite{pi}.)
+multiplying by 180 over @cpi{}.)
@kindex m r
@pindex calc-radians-mode
The @kbd{m r} (@code{calc-radians-mode}), @kbd{m d} (@code{calc-degrees-mode}),
and @kbd{m h} (@code{calc-hms-mode}) commands control the angular mode.
The current angular mode is displayed on the Emacs mode line.
-The default angular mode is degrees.@refill
+The default angular mode is Degrees.
@node Polar Mode, Fraction Mode, Angular Modes, Calculation Modes
@subsection Polar Mode
@kindex m p
@pindex calc-polar-mode
The @kbd{m p} (@code{calc-polar-mode}) command toggles complex-number
-preference between rectangular and polar forms. In polar mode, all
+preference between rectangular and polar forms. In Polar mode, all
of the above example situations would produce polar complex numbers.
@node Fraction Mode, Infinite Mode, Polar Mode, Calculation Modes
Division of two integers normally yields a floating-point number if the
result cannot be expressed as an integer. In some cases you would
rather get an exact fractional answer. One way to accomplish this is
-to multiply fractions instead: @kbd{6 @key{RET} 1:4 *} produces @cite{3:2}
-even though @kbd{6 @key{RET} 4 /} produces @cite{1.5}.
+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{1.5}.
@kindex m f
@pindex calc-frac-mode
To set the Calculator to produce fractional results for normal integer
divisions, use the @kbd{m f} (@code{calc-frac-mode}) command.
-For example, @cite{8/4} produces @cite{2} in either mode,
-but @cite{6/4} produces @cite{3:2} in Fraction Mode, @cite{1.5} in
-Float Mode.@refill
+For example, @expr{8/4} produces @expr{2} in either mode,
+but @expr{6/4} produces @expr{3:2} in Fraction mode, @expr{1.5} in
+Float mode.
At any time you can use @kbd{c f} (@code{calc-float}) to convert a
fraction to a float, or @kbd{c F} (@code{calc-fraction}) to convert a
@noindent
@cindex Infinite mode
-The Calculator normally treats results like @cite{1 / 0} as errors;
+The Calculator normally treats results like @expr{1 / 0} as errors;
formulas like this are left in unsimplified form. But Calc can be
put into a mode where such calculations instead produce ``infinite''
results.
in calculations that already had infinities as inputs. (One exception
is that infinite open intervals like @samp{[0 .. inf)} can be
generated; however, intervals closed at infinity (@samp{[0 .. inf]})
-will not be generated when infinite mode is off.)
+will not be generated when Infinite mode is off.)
-With infinite mode turned on, @samp{1 / 0} will generate @code{uinf},
+With Infinite mode turned on, @samp{1 / 0} will generate @code{uinf},
an undirected infinity. @xref{Infinities}, for a discussion of the
-difference between @code{inf} and @code{uinf}. Also, @cite{0 / 0}
+difference between @code{inf} and @code{uinf}. Also, @expr{0 / 0}
evaluates to @code{nan}, the ``indeterminate'' symbol. Various other
functions can also return infinities in this mode; for example,
@samp{ln(0) = -inf}, and @samp{gamma(-7) = uinf}. Once again,
-note that @samp{exp(inf) = inf} regardless of infinite mode because
+note that @samp{exp(inf) = inf} regardless of Infinite mode because
this calculation has infinity as an input.
-@cindex Positive infinite mode
+@cindex Positive Infinite mode
The @kbd{m i} command with a numeric prefix argument of zero,
-i.e., @kbd{C-u 0 m i}, turns on a ``positive infinite mode'' in
+i.e., @kbd{C-u 0 m i}, turns on a Positive Infinite mode in
which zero is treated as positive instead of being directionless.
Thus, @samp{1 / 0 = inf} and @samp{-1 / 0 = -inf} in this mode.
Note that zero never actually has a sign in Calc; there are no
-separate representations for @i{+0} and @i{-0}. Positive
-infinite mode merely changes the interpretation given to the
+separate representations for @mathit{+0} and @mathit{-0}. Positive
+Infinite mode merely changes the interpretation given to the
single symbol, @samp{0}. One consequence of this is that, while
you might expect @samp{1 / -0 = -inf}, actually @samp{1 / -0}
is equivalent to @samp{1 / 0}, which is equal to positive @code{inf}.
@kindex m s
@pindex calc-symbolic-mode
-In @dfn{symbolic mode}, controlled by the @kbd{m s} (@code{calc-symbolic-mode})
+In @dfn{Symbolic mode}, controlled by the @kbd{m s} (@code{calc-symbolic-mode})
command, functions which would produce inexact, irrational results are
left in symbolic form. Thus @kbd{16 Q} pushes 4, but @kbd{2 Q} pushes
@samp{sqrt(2)}.
@code{calc-symbolic-mode} and executing @kbd{=} (@code{calc-evaluate}).
Given a numeric prefix argument, it also
sets the floating-point precision to the specified value for the duration
-of the command.@refill
+of the command.
To evaluate a formula numerically without expanding the variables it
contains, you can use the key sequence @kbd{m s a v m s} (this uses
@cindex Scalar mode
Calc sometimes makes assumptions during algebraic manipulation that
are awkward or incorrect when vectors and matrices are involved.
-Calc has two modes, @dfn{matrix mode} and @dfn{scalar mode}, which
+Calc has two modes, @dfn{Matrix mode} and @dfn{Scalar mode}, which
modify its behavior around vectors in useful ways.
@kindex m v
@pindex calc-matrix-mode
-Press @kbd{m v} (@code{calc-matrix-mode}) once to enter matrix mode.
+Press @kbd{m v} (@code{calc-matrix-mode}) once to enter Matrix mode.
In this mode, all objects are assumed to be matrices unless provably
otherwise. One major effect is that Calc will no longer consider
multiplication to be commutative. (Recall that in matrix arithmetic,
@samp{A*B} is not the same as @samp{B*A}.) This assumption affects
rewrite rules and algebraic simplification. Another effect of this
mode is that calculations that would normally produce constants like
-0 and 1 (e.g., @cite{a - a} and @cite{a / a}, respectively) will now
+0 and 1 (e.g., @expr{a - a} and @expr{a / a}, respectively) will now
produce function calls that represent ``generic'' zero or identity
matrices: @samp{idn(0)}, @samp{idn(1)}. The @code{idn} function
@samp{idn(@var{a},@var{n})} returns @var{a} times an @var{n}x@var{n}
if it is combined with a scalar (as in @samp{idn(1) + 2}), Calc
will assume it really was a scalar after all and produce, e.g., 3.
-Press @kbd{m v} a second time to get scalar mode. Here, objects are
+Press @kbd{m v} a second time to get Scalar mode. Here, objects are
assumed @emph{not} to be vectors or matrices unless provably so.
For example, normally adding a variable to a vector, as in
@samp{[x, y, z] + a}, will leave the sum in symbolic form because
as far as Calc knows, @samp{a} could represent either a number or
-another 3-vector. In scalar mode, @samp{a} is assumed to be a
+another 3-vector. In Scalar mode, @samp{a} is assumed to be a
non-vector, and the addition is evaluated to @samp{[x+a, y+a, z+a]}.
Press @kbd{m v} a third time to return to the normal mode of operation.
If you press @kbd{m v} with a numeric prefix argument @var{n}, you
-get a special ``dimensioned matrix mode'' in which matrices of
+get a special ``dimensioned'' Matrix mode in which matrices of
unknown size are assumed to be @var{n}x@var{n} square matrices.
Then, the function call @samp{idn(1)} will expand into an actual
-matrix rather than representing a ``generic'' matrix.
+matrix rather than representing a ``generic'' matrix. Simply typing
+@kbd{C-u m v} will get you a square Matrix mode, in which matrices of
+unknown size are assumed to be square matrices of unspecified size.
@cindex Declaring scalar variables
Of course these modes are approximations to the true state of
your earlier promise to Calc that @samp{a} would be scalar.
Another way to mix scalars and matrices is to use selections
-(@pxref{Selecting Subformulas}). Use matrix mode when operating on
-your formula normally; then, to apply scalar mode to a certain part
+(@pxref{Selecting Subformulas}). Use Matrix mode when operating on
+your formula normally; then, to apply Scalar mode to a certain part
of the formula without affecting the rest just select that part,
-change into scalar mode and press @kbd{=} to resimplify the part
-under this mode, then change back to matrix mode before deselecting.
+change into Scalar mode and press @kbd{=} to resimplify the part
+under this mode, then change back to Matrix mode before deselecting.
@node Automatic Recomputation, Working Message, Matrix Mode, Calculation Modes
@subsection Automatic Recomputation
The @kbd{m C} (@code{calc-auto-recompute}) command turns this
automatic recomputation on and off. If you turn it off, Calc will
not update @samp{=>} operators on the stack (nor those in the
-attached Embedded Mode buffer, if there is one). They will not
+attached Embedded mode buffer, if there is one). They will not
be updated unless you explicitly do so by pressing @kbd{=} or until
you press @kbd{m C} to turn recomputation back on. (While automatic
recomputation is off, you can think of @kbd{m C m C} as a command
to update all @samp{=>} operators while leaving recomputation off.)
To update @samp{=>} operators in an Embedded buffer while
-automatic recomputation is off, use @w{@kbd{M-# u}}.
+automatic recomputation is off, use @w{@kbd{C-x * u}}.
@xref{Embedded Mode}.
@node Working Message, , Automatic Recomputation, Calculation Modes
disable all ``working'' messages. Use a numeric prefix of 1 to enable
only the plain @samp{Working...} message. Use a numeric prefix of 2 to
see intermediate results as well. With no numeric prefix this displays
-the current mode.@refill
+the current mode.
While it may seem that the ``working'' messages will slow Calc down
considerably, experiments have shown that their impact is actually
are ``normalized'' when being taken from or pushed onto the stack.
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 @cite{a+a} (or @cite{2+3}),
+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.
-When you press a key like @kbd{+} when @cite{2} and @cite{3} are on the
+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
-@cite{2+3}, normalizes it, and pushes the result. Of course the standard
-rules for normalizing @cite{2+3} will produce the result @cite{5}.
+@expr{2+3}, normalizes it, and pushes the result. Of course the standard
+rules for normalizing @expr{2+3} will produce the result @expr{5}.
Simplification mode commands consist of the lower-case @kbd{m} prefix key
followed by a shifted letter.
@kindex m O
@pindex calc-no-simplify-mode
The @kbd{m O} (@code{calc-no-simplify-mode}) command turns off all optional
-simplifications. These would leave a formula like @cite{2+3} alone. In
+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.
@pindex calc-num-simplify-mode
The @kbd{m N} (@code{calc-num-simplify-mode}) command turns off simplification
of any formulas except those for which all arguments are constants. For
-example, @cite{1+2} is simplified to @cite{3}, and @cite{a+(2-2)} is
-simplified to @cite{a+0} but no further, since one argument of the sum
-is not a constant. Unfortunately, @cite{(a+2)-2} is @emph{not} simplified
+example, @expr{1+2} is simplified to @expr{3}, and @expr{a+(2-2)} is
+simplified to @expr{a+0} but no further, since one argument of the sum
+is not a constant. Unfortunately, @expr{(a+2)-2} is @emph{not} simplified
because the top-level @samp{-} operator's arguments are not both
-constant numbers (one of them is the formula @cite{a+2}).
+constant numbers (one of them is the formula @expr{a+2}).
A constant is a number or other numeric object (such as a constant
error form or modulo form), or a vector all of whose
-elements are constant.@refill
+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
-fast algebraic simplifications such as @cite{a+0} to @cite{a}, and
-@cite{a + 2 a} to @cite{3 a}, as well as evaluating functions like
-@cite{@t{deriv}(x^2, x)} to @cite{2 x}.
+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
(@code{calc-simplify-units}), which in turn
is a superset of @kbd{a s}. In this mode, variable names which
are identifiable as unit names (like @samp{mm} for ``millimeters'')
-are simplified with their unit definitions in mind.@refill
+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.@refill
+Definitions}, for another sample use of No-Simplification mode.
@node Declarations, Display Modes, Simplification Modes, Mode Settings
@section Declarations
Calc uses this information to determine when certain simplifications
of formulas are safe. For example, @samp{(x^y)^z} cannot be
simplified to @samp{x^(y z)} in general; for example,
-@samp{((-3)^2)^1:2} is 3, but @samp{(-3)^(2*1:2) = (-3)^1} is @i{-3}.
+@samp{((-3)^2)^1:2} is 3, but @samp{(-3)^(2*1:2) = (-3)^1} is @mathit{-3}.
However, this simplification @emph{is} safe if @code{z} is known
to be an integer, or if @code{x} is known to be a nonnegative
real number. If you have given declarations that allow Calc to
The value is a vector.
@item matrix
The value is a matrix (a rectangular vector of vectors).
+@item sqmatrix
+The value is a square matrix.
@end table
These type symbols can be combined with the other type symbols
never distinguishes between @code{vector} and @code{matrix}
declarations.)
-@xref{Matrix Mode}, for a discussion of ``matrix mode'' and
-``scalar mode,'' which are similar to declaring @samp{[All, matrix]}
+@xref{Matrix Mode}, for a discussion of Matrix mode and
+Scalar mode, which are similar to declaring @samp{[All, matrix]}
or @samp{[All, scalar]} but much more convenient.
One more type symbol that is recognized is used with the @kbd{H a d}
@end table
Calc does not check the declarations for a variable when you store
-a value in it. However, storing @i{-3.5} in a variable that has
+a value in it. However, storing @mathit{-3.5} in a variable that has
been declared @code{pos}, @code{int}, or @code{matrix} may have
-unexpected effects; Calc may evaluate @samp{sqrt(x^2)} to @cite{3.5}
-if it substitutes the value first, or to @cite{-3.5} if @code{x}
+unexpected effects; Calc may evaluate @samp{sqrt(x^2)} to @expr{3.5}
+if it substitutes the value first, or to @expr{-3.5} if @code{x}
was declared @code{pos} and the formula @samp{sqrt(x^2)} is
simplified to @samp{x} before the value is substituted. Before
using a variable for a new purpose, it is best to use @kbd{s d}
@end ignore
@tindex dimag
The @code{dimag} function checks if its argument is imaginary,
-i.e., is mathematically equal to a real number times @cite{i}.
+i.e., is mathematically equal to a real number times @expr{i}.
@ignore
@starindex
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 @cite{x > 0} to 1 or 0 using @code{dpos}, and that
+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}
are rarely necessary.
@tindex dscalar
The @code{dscalar} function returns 1 if its argument is provably
scalar, or 0 if its argument is provably non-scalar. It is left
-unevaluated if this cannot be determined. (If matrix mode or scalar
-mode are in effect, this function returns 1 or 0, respectively,
+unevaluated if this cannot be determined. (If Matrix mode or Scalar
+mode is in effect, this function returns 1 or 0, respectively,
if it has no other information.) When Calc interprets a condition
(say, in a rewrite rule) it considers an unevaluated formula to be
``false.'' Thus, @samp{dscalar(a)} is ``true'' only if @code{a} is
(@code{calc-line-breaking}) commands are described elsewhere;
@pxref{Stack Basics} and @pxref{Normal Language Modes}, respectively.
Display formats for vectors and matrices are also covered elsewhere;
-@pxref{Vector and Matrix Formats}.@refill
+@pxref{Vector and Matrix Formats}.
One thing all display modes have in common is their treatment of the
@kbd{H} prefix. This prefix causes any mode command that would normally
respectively. Numbers can always be entered in any radix, though the
current radix is used as a default if you press @kbd{#} without any initial
digits. A number entered without a @kbd{#} is @emph{always} interpreted
-as decimal.@refill
+as decimal.
@kindex d r
@pindex calc-radix
represent the integer and no more. The @kbd{d z} (@code{calc-leading-zeros})
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 @cite{w}, all integers
-are displayed with at least enough digits to represent @c{$2^w-1$}
-@cite{(2^w)-1} in the
-current radix. (Larger integers will still be displayed in their entirety.)
+word size.) If the absolute value of the word size is @expr{w}, all integers
+are displayed with at least enough digits to represent
+@texline @math{2^w-1}
+@infoline @expr{(2^w)-1}
+in the current radix. (Larger integers will still be displayed in their
+entirety.)
@node Grouping Digits, Float Formats, Radix Modes, Display Modes
@subsection Grouping Digits
@cindex Digit grouping
Long numbers can be hard to read if they have too many digits. For
example, the factorial of 30 is 33 digits long! Press @kbd{d g}
-(@code{calc-group-digits}) to enable @dfn{grouping} mode, in which digits
+(@code{calc-group-digits}) to enable @dfn{Grouping} mode, in which digits
are displayed in clumps of 3 or 4 (depending on the current radix)
separated by commas.
The @kbd{d g} command toggles grouping on and off.
-With a numerix prefix of 0, this command displays the current state of
+With a numeric prefix of 0, this command displays the current state of
the grouping flag; with an argument of minus one it disables grouping;
-with a positive argument @cite{N} it enables grouping on every @cite{N}
+with a positive argument @expr{N} it enables grouping on every @expr{N}
digits. For floating-point numbers, grouping normally occurs only
-before the decimal point. A negative prefix argument @cite{-N} enables
-grouping every @cite{N} digits both before and after the decimal point.@refill
+before the decimal point. A negative prefix argument @expr{-N} enables
+grouping every @expr{N} digits both before and after the decimal point.
@kindex d ,
@pindex calc-group-char
@samp{\,} (@TeX{}'s thin-space symbol) as the digit separator.
Please note that grouped numbers will not generally be parsed correctly
-if re-read in textual form, say by the use of @kbd{M-# y} and @kbd{M-# g}.
+if re-read in textual form, say by the use of @kbd{C-x * y} and @kbd{C-x * g}.
(@xref{Kill and Yank}, for details on these commands.) One exception is
the @samp{\,} separator, which doesn't interfere with parsing because it
is ignored by @TeX{} language mode.
calculations are often carried to one or two more significant figures,
but values placed on the stack will be rounded down to ten figures.)
Numbers are never actually rounded to the display precision for storage,
-except by commands like @kbd{C-k} and @kbd{M-# y} which operate on the
+except by commands like @kbd{C-k} and @kbd{C-x * y} which operate on the
actual displayed text in the Calculator buffer.
@kindex d .
There are three supported notations for complex numbers in rectangular
form. The default is as a pair of real numbers enclosed in parentheses
and separated by a comma: @samp{(a,b)}. The @kbd{d c}
-(@code{calc-complex-notation}) command selects this style.@refill
+(@code{calc-complex-notation}) command selects this style.
@kindex d i
@pindex calc-i-notation
The other notations are @kbd{d i} (@code{calc-i-notation}), in which
numbers are displayed in @samp{a+bi} form, and @kbd{d j}
(@code{calc-j-notation}) which displays the form @samp{a+bj} preferred
-in some disciplines.@refill
+in some disciplines.
@cindex @code{i} variable
@vindex i
will be interpreted as @samp{(0,1)} and the formula will be simplified
to @samp{(2,3)}. Other commands (like @code{calc-sin}) will @emph{not}
interpret the formula @samp{2 + 3 * i} as a complex number.
-@xref{Variables}, under ``special constants.''@refill
+@xref{Variables}, under ``special constants.''
@node Fraction Formats, HMS Formats, Complex Formats, Display Modes
@subsection Fraction Formats
Calc adjusts all fractions that are displayed to have the specified
denominator, if possible. Otherwise it adjusts the denominator to
be a multiple of the specified value. For example, in @samp{:6} mode
-the fraction @cite{1:6} will be unaffected, but @cite{2:3} will be
-displayed as @cite{4:6}, @cite{1:2} will be displayed as @cite{3:6},
-and @cite{1:8} will be displayed as @cite{3:24}. Integers are also
-affected by this mode: 3 is displayed as @cite{18:6}. Note that the
+the fraction @expr{1:6} will be unaffected, but @expr{2:3} will be
+displayed as @expr{4:6}, @expr{1:2} will be displayed as @expr{3:6},
+and @expr{1:8} will be displayed as @expr{3:24}. Integers are also
+affected by this mode: 3 is displayed as @expr{18:6}. Note that the
format @samp{:1} writes fractions the same as @samp{:}, but it writes
-integers as @cite{n:1}.
+integers as @expr{n:1}.
The fraction format does not affect the way fractions or integers are
stored, only the way they appear on the screen. The fraction format
line that marks the top-of-stack up or down in the Calculator buffer.
The number right above that line is considered to the be at the top of
the stack. Any numbers below that line are ``hidden'' from all stack
-operations. This is similar to the Emacs ``narrowing'' feature, except
-that the values below the @samp{.} are @emph{visible}, just temporarily
-frozen. This feature allows you to keep several independent calculations
-running at once in different parts of the stack, or to apply a certain
-command to an element buried deep in the stack.@refill
+operations (although still visible to the user). This is similar to the
+Emacs ``narrowing'' feature, except that the values below the @samp{.}
+are @emph{visible}, just temporarily frozen. This feature allows you to
+keep several independent calculations running at once in different parts
+of the stack, or to apply a certain command to an element buried deep in
+the stack.
Pressing @kbd{d t} by itself moves the @samp{.} to the line the cursor
is on. Thus, this line and all those below it become hidden. To un-hide
these lines, move down to the end of the buffer and press @w{@kbd{d t}}.
-With a positive numeric prefix argument @cite{n}, @kbd{d t} hides the
-bottom @cite{n} values in the buffer. With a negative argument, it hides
-all but the top @cite{n} values. With an argument of zero, it hides zero
-values, i.e., moves the @samp{.} all the way down to the bottom.@refill
+With a positive numeric prefix argument @expr{n}, @kbd{d t} hides the
+bottom @expr{n} values in the buffer. With a negative argument, it hides
+all but the top @expr{n} values. With an argument of zero, it hides zero
+values, i.e., moves the @samp{.} all the way down to the bottom.
@kindex d [
@pindex calc-truncate-up
@pindex calc-truncate-down
The @kbd{d [} (@code{calc-truncate-up}) and @kbd{d ]}
(@code{calc-truncate-down}) commands move the @samp{.} up or down one
-line at a time (or several lines with a prefix argument).@refill
+line at a time (or several lines with a prefix argument).
@node Justification, Labels, Truncating the Stack, Display Modes
@subsection Justification
Values on the stack are normally left-justified in the window. You can
control this arrangement by typing @kbd{d <} (@code{calc-left-justify}),
@kbd{d >} (@code{calc-right-justify}), or @kbd{d =}
-(@code{calc-center-justify}). For example, in right-justification mode,
+(@code{calc-center-justify}). For example, in Right-Justification mode,
stack entries are displayed flush-right against the right edge of the
-window.@refill
+window.
If you change the width of the Calculator window you may have to type
@kbd{d @key{SPC}} (@code{calc-refresh}) to re-align right-justified or centered
origin and line width is slightly different in each justification
mode.
-In left-justified mode, the line is indented by a number of spaces
+In Left-Justified mode, the line is indented by a number of spaces
given by the origin (default zero). If the result is longer than the
maximum line width, if given, or too wide to fit in the Calc window
otherwise, then it is broken into lines which will fit; each broken
line is indented to the origin.
-In right-justified mode, lines are shifted right so that the rightmost
+In Right-Justified mode, lines are shifted right so that the rightmost
character is just before the origin, or just before the current
window width if no origin was specified. If the line is too long
for this, then it is broken; the current line width is used, if
specified, or else the origin is used as a width if that is
specified, or else the line is broken to fit in the window.
-In centering mode, the origin is the column number of the center of
+In Centering mode, the origin is the column number of the center of
each stack entry. If a line width is specified, lines will not be
allowed to go past that width; Calc will either indent less or
break the lines if necessary. If no origin is specified, half the
The @kbd{d @}} (@code{calc-right-label}) command similarly adds a
label on the righthand side. It does not affect positioning of
the stack entries unless they are right-justified. Also, if both
-a line width and an origin are given in right-justified mode, the
+a line width and an origin are given in Right-Justified mode, the
stack entry is justified to the origin and the righthand label is
justified to the line width.
One application of labels would be to add equation numbers to
formulas you are manipulating in Calc and then copying into a
-document (possibly using Embedded Mode). The equations would
+document (possibly using Embedded mode). The equations would
typically be centered, and the equation numbers would be on the
left or right as you prefer.
@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 @TeX{}. Objects displayed on the
+other common language such as Pascal or La@TeX{}. 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.
For example, suppose the formula @samp{2*a[1] + atan(a[2])} occurs in a C
program; elsewhere in the program you need the derivatives of this formula
with respect to @samp{a[1]} and @samp{a[2]}. First, type @kbd{d C}
-to switch to C notation. Now use @code{C-u M-# g} to grab the formula
+to switch to C notation. Now use @code{C-u C-x * g} to grab the formula
into the Calculator, @kbd{a d a[1] @key{RET}} to differentiate with respect
-to the first variable, and @kbd{M-# y} to yank the formula for the derivative
+to the first variable, and @kbd{C-x * y} to yank the formula for the derivative
back into your C program. Press @kbd{U} to undo the differentiation and
repeat with @kbd{a d a[2] @key{RET}} for the other derivative.
the brackets in @samp{a[1]} and @samp{a[2]}, would not have known that
@code{atan} was equivalent to Calc's built-in @code{arctan} function,
and would have written the formula back with notations (like implicit
-multiplication) which would not have been legal for a C program.
+multiplication) which would not have been valid for a C program.
-As another example, suppose you are maintaining a C program and a @TeX{}
+As another example, suppose you are maintaining a C program and a La@TeX{}
document, each of which needs a copy of the same formula. You can grab the
-formula from the program in C mode, switch to @TeX{} mode, and yank the
-formula into the document in @TeX{} math-mode format.
+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.
Language modes are selected by typing the letter @kbd{d} followed by a
shifted letter key.
@menu
* Normal Language Modes::
* C FORTRAN Pascal::
-* TeX Language Mode::
+* TeX and LaTeX Language Modes::
* Eqn Language Mode::
* Mathematica Language Mode::
* Maple Language Mode::
@noindent
in place of @samp{sqrt((a+1)/b + c^2)}.
-Subscripts like @samp{a_i} are displayed as actual subscripts in ``big''
+Subscripts like @samp{a_i} are displayed as actual subscripts in Big
mode. Double subscripts, @samp{a_i_j} (@samp{subscr(subscr(a, i), j)})
are displayed as @samp{a} with subscripts separated by commas:
@samp{i, j}. They must still be entered in the usual underscore
@end example
@noindent
-can represent either the negative rational number @cite{-3:4}, or the
+can represent either the negative rational number @expr{-3:4}, or the
actual expression @samp{-(3/4)}; but the latter formula would normally
never be displayed because it would immediately be evaluated to
-@cite{-3:4} or @cite{-0.75}, so this ambiguity is not a problem in
+@expr{-3:4} or @expr{-0.75}, so this ambiguity is not a problem in
typical use.
Non-decimal numbers are displayed with subscripts. Thus there is no
(except that Mathematica mode expects square brackets instead of
parentheses).
-@node C FORTRAN Pascal, TeX Language Mode, Normal Language Modes, Language Modes
+@node C FORTRAN Pascal, TeX and LaTeX Language Modes, Normal Language Modes, Language Modes
@subsection C, FORTRAN, and Pascal Modes
@noindent
Octal and hexadecimal values are written with leading @samp{0} or @samp{0x}
rather than using the @samp{#} symbol. Array subscripting is
translated into @code{subscr} calls, so that @samp{a[i]} in C
-mode is the same as @samp{a_i} in normal mode. Assignments
+mode is the same as @samp{a_i} in Normal mode. Assignments
turn into the @code{assign} function, which Calc normally displays
using the @samp{:=} symbol.
-The variables @code{var-pi} and @code{var-e} would be displayed @samp{pi}
-and @samp{e} in normal mode, but in C mode they are displayed as
+The variables @code{pi} and @code{e} would be displayed @samp{pi}
+and @samp{e} in Normal mode, but in C mode they are displayed as
@samp{M_PI} and @samp{M_E}, corresponding to the names of constants
typically provided in the @file{<math.h>} header. Functions whose
names are different in C are translated automatically for entry and
Underscores are allowed in variable and function names in all of these
language modes. The underscore here is equivalent to the @samp{#} in
-normal mode, or to hyphens in the underlying Emacs Lisp variable names.
+Normal mode, or to hyphens in the underlying Emacs Lisp variable names.
FORTRAN and Pascal modes normally do not adjust the case of letters in
formulas. Most built-in Calc names use lower-case letters. If you use a
convert to lower-case on input. With a negative prefix, these modes
convert to lower-case for display and input.
-@node TeX Language Mode, Eqn Language Mode, C FORTRAN Pascal, Language Modes
-@subsection @TeX{} Language Mode
+@node TeX and LaTeX Language Modes, Eqn Language Mode, C FORTRAN Pascal, Language Modes
+@subsection @TeX{} and La@TeX{} Language Modes
@noindent
@kindex d T
@pindex calc-tex-language
@cindex TeX language
+@kindex d L
+@pindex calc-latex-language
+@cindex LaTeX language
The @kbd{d T} (@code{calc-tex-language}) command selects the conventions
-of ``math mode'' in the @TeX{} typesetting language, by Donald Knuth.
-Formulas are entered
-and displayed in @TeX{} notation, as in @samp{\sin\left( a \over b \right)}.
-Math formulas are usually enclosed by @samp{$ $} signs in @TeX{}; 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).@refill
+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{}
+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.
+Math formulas are often enclosed by @samp{$ $} signs in @TeX{} and
+La@TeX{}; 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};
-binomial coefficients are written with @code{\choose}.
-Interval forms are written with @code{\ldots}, and
-error forms are 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{} mode. Both @code{inf} and @code{uinf} are written
-as @code{\infty}; when read, @code{\infty} always translates to
-@code{inf}.@refill
+quotients are written using @code{\over} in @TeX{} mode (as in
+@code{@{a \over b@}}) and @code{\frac} in La@TeX{} 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@}}).
+Interval forms are written with @code{\ldots}, and error forms are
+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{}
+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{} has
-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
-@c{$\sin{2 x}$}
-@cite{sin 2x} but @c{$\sin(2 + x)$}
-@cite{sin(2 + x)}.
-
-Function and variable names not treated specially by @TeX{} 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} with a positive numeric
-prefix argument, names of more than one character will instead be written
-@samp{\hbox@{@var{name}@}}. The @samp{\hbox@{ @}} notation is 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 reading have the @code{\} removed. (Note that
-in this mode, long variable names are still written with @code{\hbox}.
-However, you can always make an actual variable name like @code{\bar}
-in any @TeX{} mode.)
+by the arguments in parentheses. However, functions for which @TeX{}
+and La@TeX{} 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
+@texline @math{\sin{2 x}}
+@infoline @expr{sin 2x}
+but
+@texline @math{\sin(2 + x)}.
+@infoline @expr{sin(2 + x)}.
+
+Function and variable names not treated specially by @TeX{} and La@TeX{}
+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
+@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
+reading have the @code{\} removed. (Note that in this mode, long
+variable names are still written with @code{\hbox} or @code{\text}.
+However, you can always make an actual variable name like @code{\bar} in
+any @TeX{} mode.)
During reading, text of the form @samp{\matrix@{ ...@: @}} is replaced
by @samp{[ ...@: ]}. The same also applies to @code{\pmatrix} and
-@code{\bmatrix}. The symbol @samp{&} is interpreted as a comma,
+@code{\bmatrix}. In La@TeX{} mode this also applies to
+@samp{\begin@{matrix@} ... \end@{matrix@}},
+@samp{\begin@{bmatrix@} ... \end@{bmatrix@}},
+@samp{\begin@{pmatrix@} ... \end@{pmatrix@}}, as well as
+@samp{\begin@{smallmatrix@} ... \end@{smallmatrix@}}.
+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; you may need to edit this afterwards to change @code{\matrix}
-to @code{\pmatrix} or @code{\\} to @code{\cr}.
+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
+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
+
+@example
+\begin@{pmatrix@}
+a & b \\
+c & d
+\end@{pmatrix@}
+@end example
+
+@noindent
+This may be convenient for isolated matrices, but could lead to
+expressions being displayed like
+
+@example
+\begin@{pmatrix@} \times x
+a & b \\
+c & d
+\end@{pmatrix@}
+@end example
+
+@noindent
+While this wouldn't bother Calc, it is incorrect La@TeX{}.
+(Similarly for @TeX{}.)
Accents like @code{\tilde} and @code{\bar} translate into function
calls internally (@samp{tilde(x)}, @samp{bar(x)}). The @code{\underline}
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{}, and @dfn{eqn} (described in the next section):
+in Calc, @TeX{}, La@TeX{} and @dfn{eqn} (described in the next section):
@iftex
@begingroup
@ignore
@starindex
@end ignore
+@tindex Acute
+@ignore
+@starindex
+@end ignore
@tindex bar
@ignore
@starindex
@end ignore
+@tindex Bar
+@ignore
+@starindex
+@end ignore
@tindex breve
@ignore
@starindex
@end ignore
+@tindex Breve
+@ignore
+@starindex
+@end ignore
@tindex check
@ignore
@starindex
@end ignore
+@tindex Check
+@ignore
+@starindex
+@end ignore
+@tindex dddot
+@ignore
+@starindex
+@end ignore
+@tindex ddddot
+@ignore
+@starindex
+@end ignore
@tindex dot
@ignore
@starindex
@end ignore
+@tindex Dot
+@ignore
+@starindex
+@end ignore
@tindex dotdot
@ignore
@starindex
@end ignore
+@tindex DotDot
+@ignore
+@starindex
+@end ignore
@tindex dyad
@ignore
@starindex
@ignore
@starindex
@end ignore
+@tindex Grave
+@ignore
+@starindex
+@end ignore
@tindex hat
@ignore
@starindex
@end ignore
+@tindex Hat
+@ignore
+@starindex
+@end ignore
@tindex Prime
@ignore
@starindex
@ignore
@starindex
@end ignore
+@tindex Tilde
+@ignore
+@starindex
+@end ignore
@tindex under
@ignore
@starindex
@end ignore
@tindex Vec
+@ignore
+@starindex
+@end ignore
+@tindex VEC
@iftex
@endgroup
@end iftex
@example
-Calc TeX eqn
----- --- ---
-acute \acute
-bar \bar bar
-breve \breve
-check \check
-dot \dot dot
-dotdot \ddot dotdot
-dyad dyad
-grave \grave
-hat \hat hat
-Prime prime
-tilde \tilde tilde
-under \underline under
-Vec \vec vec
+Calc TeX LaTeX eqn
+---- --- ----- ---
+acute \acute \acute
+Acute \Acute
+bar \bar \bar bar
+Bar \Bar
+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
+dyad dyad
+grave \grave \grave
+Grave \Grave
+hat \hat \hat hat
+Hat \Hat
+Prime prime
+tilde \tilde \tilde tilde
+Tilde \Tilde
+under \underline \underline under
+Vec \vec \vec vec
+VEC \Vec
@end example
The @samp{=>} (evaluates-to) operator appears as a @code{\to} symbol:
\evalto
@end example
-Note that, because these symbols are ignored, reading a @TeX{} formula
-into Calc and writing it back out may lose spacing and font information.
+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.
Also, the ``discretionary multiplication sign'' @samp{\*} is read
the same as @samp{*}.
@end group
@end example
@tex
-\let\rm\goodrm
$$ \sin\left( a^2 \over b_i \right) $$
@end tex
@sp 1
@end group
@end example
@tex
-\turnoffactive\let\rm\goodrm
+\turnoffactive
$$ [\sin{a}, \sin{2 a}, \sin(2 + a), \sin\left( {a \over b} \right)] $$
@end tex
@sp 2
@end group
@end example
@tex
-\let\rm\goodrm
$$ [f(a), foo(bar), \sin{\pi}] $$
$$ [f(a), \hbox{foo}(\hbox{bar}), \sin{\pi}] $$
$$ [f(a), \tilde F(\hbox{bar}), \sin{\pi}] $$
@sp 2
@end iftex
-@node Eqn Language Mode, Mathematica Language Mode, TeX Language Mode, Language Modes
+@node Eqn Language Mode, Mathematica Language Mode, TeX and LaTeX Language Modes, Language Modes
@subsection Eqn Language Mode
@noindent
symbol (these are used to introduce spaces of various widths into
the typeset output of @dfn{eqn}).
-As in @TeX{} mode, Calc's formatter omits parentheses around the
+As in La@TeX{} 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. @xref{TeX Language
-Mode}, 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 stored internally as
-@samp{f'@w{'}(x')}. For example, taking the derivative of @samp{f(2 x)}
-with @kbd{a d x} will produce @samp{2 f'(2 x)}, which @dfn{eqn} mode
-will display as @samp{2 f prime ( 2 x )}.
+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
+stored internally as @samp{f'@w{'}(x')}. For example, taking the
+derivative of @samp{f(2 x)} with @kbd{a d x} will produce @samp{2 f'(2
+x)}, which @dfn{eqn} mode will display as @samp{2 f prime ( 2 x )}.
Assignments are written with the @samp{<-} (left-arrow) symbol,
and @code{evalto} operators are written with @samp{->} or
-@samp{evalto ... ->} (@pxref{TeX Language Mode}, for a discussion
+@samp{evalto ... ->} (@pxref{TeX and LaTeX Language Modes}, for a discussion
of this). The regular Calc symbols @samp{:=} and @samp{=>} are also
recognized for these operators during reading.
@pindex calc-mathematica-language
@cindex Mathematica language
The @kbd{d M} (@code{calc-mathematica-language}) command selects the
-conventions of Mathematica, a powerful and popular mathematical tool
-from Wolfram Research, Inc. Notable differences in Mathematica mode
+conventions of Mathematica. Notable differences in Mathematica mode
are that the names of built-in functions are capitalized, and function
calls use square brackets instead of parentheses. Thus the Calc
formula @samp{sin(2 x)} is entered and displayed @w{@samp{Sin[2 x]}} in
Mathematica mode.
Non-decimal numbers are written, e.g., @samp{16^^7fff}. Floating-point
numbers in scientific notation are written @samp{1.23*10.^3}.
-Subscripts use double square brackets: @samp{a[[i]]}.@refill
+Subscripts use double square brackets: @samp{a[[i]]}.
@node Maple Language Mode, Compositions, Mathematica Language Mode, Language Modes
@subsection Maple Language Mode
@pindex calc-maple-language
@cindex Maple language
The @kbd{d W} (@code{calc-maple-language}) command selects the
-conventions of Maple, another mathematical tool from the University
-of Waterloo.
+conventions of Maple.
Maple's language is much like C. Underscores are allowed in symbol
names; square brackets are used for subscripts; explicit @samp{*}s for
=> 40
@end example
-The general rule is that if an operator with precedence @cite{n}
-occurs as an argument to an operator with precedence @cite{m}, then
-the argument is enclosed in parentheses if @cite{n < m}. Top-level
+The general rule is that if an operator with precedence @expr{n}
+occurs as an argument to an operator with precedence @expr{m}, then
+the argument is enclosed in parentheses if @expr{n < m}. Top-level
expressions and expressions which are function arguments, vector
components, etc., are formatted with precedence zero (so that they
normally never get additional parentheses).
@tindex choriz
The @code{choriz} function takes a vector of objects and composes
them horizontally. For example, @samp{choriz([17, a b/c, d])} formats
-as @w{@samp{17a b / cd}} in normal language mode, or as
+as @w{@samp{17a b / cd}} in Normal language mode, or as
@example
@group
@tindex cwidth
The @code{cwidth} function measures the width, in characters, of a
composition. For example, @samp{cwidth(a + b)} is 5, and
-@samp{cwidth(a / b)} is 5 in normal mode, 1 in Big mode, and 11 in
+@samp{cwidth(a / b)} is 5 in Normal mode, 1 in Big mode, and 11 in
@TeX{} mode (for @samp{@{a \over b@}}). The argument may involve
the composition functions described in this section.
@pindex calc-edit-user-syntax
The @kbd{Z S} (@code{calc-edit-user-syntax}) command edits the
syntax table for the current language mode. If you want your
-syntax to work in any language, define it in the normal language
-mode. Type @kbd{M-# M-#} to finish editing the syntax table, or
-@kbd{M-# x} to cancel the edit. The @kbd{m m} command saves all
+syntax to work in any language, define it in the Normal language
+mode. Type @kbd{C-c C-c} to finish editing the syntax table, or
+@kbd{C-x k} to cancel the edit. The @kbd{m m} command saves all
the syntax tables along with the other mode settings;
@pxref{General Mode Commands}.
A @dfn{syntax table} is a list of user-defined @dfn{syntax rules},
which allow you to specify new patterns to define your own
favorite input notations. Calc's parser always checks the syntax
-table for the current language mode, then the table for the normal
+table for the current language mode, then the table for the Normal
language mode, before it uses its built-in rules to parse an
algebraic formula you have entered. Each syntax rule should go on
its own line; it consists of a @dfn{pattern}, a @samp{:=} symbol,
This will parse @samp{3 bad token 4 /"\ 5} to @samp{silly(3,4,5)}.
The token @kbd{#} has a predefined meaning in Calc's formula parser;
-it is not legal to use @samp{"#"} in a syntax rule. However, longer
+it is not valid to use @samp{"#"} in a syntax rule. However, longer
tokens that include the @samp{#} character are allowed. Also, while
@samp{"$"} and @samp{"\""} are allowed as tokens, their presence in
the syntax table will prevent those characters from working in their
@samp{i=1..10}. Then, we use @code{matches} to break it apart into
its components. If the expression turns out not to match the pattern,
the syntax rule will fail. Note that @kbd{Z S} always uses Calc's
-normal language mode for editing expressions in syntax rules, so we
+Normal language mode for editing expressions in syntax rules, so we
must use regular Calc notation for the interval @samp{[b..c]} that
will correspond to the Maple mode interval @samp{1..10}.
Command is @kbd{m p}.
@item
-Matrix/scalar mode. Default value is @i{-1}. Value is 0 for scalar
-mode, @i{-2} for matrix mode, or @var{N} for @c{$N\times N$}
-@var{N}x@var{N} matrix mode. Command is @kbd{m v}.
+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
+@texline @math{N\times N}
+@infoline @var{N}x@var{N}
+Matrix mode. Command is @kbd{m v}.
@item
-Simplification mode. Default is 1. Value is @i{-1} for off (@kbd{m O}),
+Simplification mode. Default is 1. Value is @mathit{-1} for off (@kbd{m O}),
0 for @kbd{m N}, 2 for @kbd{m B}, 3 for @kbd{m A}, 4 for @kbd{m E},
or 5 for @w{@kbd{m U}}. The @kbd{m D} command accepts these prefixes.
@item
-Infinite mode. Default is @i{-1} (off). Value is 1 if the mode is on,
+Infinite mode. Default is @mathit{-1} (off). Value is 1 if the mode is on,
or 0 if the mode is on with positive zeros. Command is @kbd{m i}.
@end enumerate
@cindex Mode line indicators
This section is a summary of all symbols that can appear on the
Calc mode line, the highlighted bar that appears under the Calc
-stack window (or under an editing window in Embedded Mode).
+stack window (or under an editing window in Embedded mode).
The basic mode line format is:
regular Emacs commands are not allowed to edit the stack buffer
as if it were text.
-The word @samp{Calc:} changes to @samp{CalcEmbed:} if Embedded Mode
+The word @samp{Calc:} changes to @samp{CalcEmbed:} if Embedded mode
is enabled. The words after this describe the various Calc modes
that are in effect.
Matrix mode (@kbd{m v}; @pxref{Matrix Mode}).
@item Matrix@var{n}
-Dimensioned matrix mode (@kbd{C-u @var{n} m v}).
+Dimensioned Matrix mode (@kbd{C-u @var{n} m v}; @pxref{Matrix Mode}).
+
+@item SqMatrix
+Square Matrix mode (@kbd{C-u m v}; @pxref{Matrix Mode}).
@item Scalar
Scalar mode (@kbd{m v}; @pxref{Matrix Mode}).
Infinite mode (@kbd{m i}; @pxref{Infinite Mode}).
@item +Inf
-Positive infinite mode (@kbd{C-u 0 m i}).
+Positive Infinite mode (@kbd{C-u 0 m i}).
@item NoSimp
Default simplifications off (@kbd{m O}; @pxref{Simplification Modes}).
FORTRAN language mode (@kbd{d F}).
@item TeX
-@TeX{} language mode (@kbd{d T}; @pxref{TeX Language Mode}).
+@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}).
@item Eqn
@dfn{Eqn} language mode (@kbd{d E}; @pxref{Eqn Language Mode}).
Selections show deep structure (@kbd{j b}; @pxref{Making Selections}).
@item Save
-Record modes in @file{~/.emacs} (@kbd{m R}; @pxref{General Mode Commands}).
+Record modes in @file{~/.calc.el} (@kbd{m R}; @pxref{General Mode Commands}).
@item Local
Record modes in Embedded buffer (@kbd{m R}).
performing the desired operation, and pushing the result back onto the
stack. If the operation cannot be performed, the result pushed is a
formula instead of a number, such as @samp{2/0} (because division by zero
-is illegal) or @samp{sqrt(x)} (because the argument @samp{x} is a formula).
+is invalid) or @samp{sqrt(x)} (because the argument @samp{x} is a formula).
Most of the commands described here can be invoked by a single keystroke.
Some of the more obscure ones are two-letter sequences beginning with
If either argument of @kbd{+} is a complex number, the result will in general
be complex. If one argument is in rectangular form and the other polar,
-the current Polar Mode determines the form of the result. If Symbolic
-Mode is enabled, the sum may be left as a formula if the necessary
+the current Polar mode determines the form of the result. If Symbolic
+mode is enabled, the sum may be left as a formula if the necessary
conversions for polar addition are non-trivial.
If both arguments of @kbd{+} are HMS forms, the forms are added according to
the usual conventions of hours-minutes-seconds notation. If one argument
is an HMS form and the other is a number, that number is converted from
-degrees or radians (depending on the current Angular Mode) to HMS format
+degrees or radians (depending on the current Angular mode) to HMS format
and then the two HMS forms are added.
If one argument of @kbd{+} is a date form, the other can be either a
work, for the same reasons just mentioned for vectors. Instead you must
write @samp{(a +/- b) + (c +/- 0)}.
-If both arguments of @kbd{+} are modulo forms with equal values of @cite{M},
+If both arguments of @kbd{+} are modulo forms with equal values of @expr{M},
or if one argument is a modulo form and the other a plain number, the
-result is a modulo form which represents the sum, modulo @cite{M}, of
+result is a modulo form which represents the sum, modulo @expr{M}, of
the two values.
If both arguments of @kbd{+} are intervals, the result is an interval
@tindex -
The @kbd{-} (@code{calc-minus}) command subtracts two values. The top
number on the stack is subtracted from the one behind it, so that the
-computation @kbd{5 @key{RET} 2 -} produces 3, not @i{-3}. All options
+computation @kbd{5 @key{RET} 2 -} produces 3, not @mathit{-3}. All options
available for @kbd{+} are available for @kbd{-} as well.
@kindex *
@end ignore
@tindex /
The @kbd{/} (@code{calc-divide}) command divides two numbers. When
-dividing a scalar @cite{B} by a square matrix @cite{A}, the computation
-performed is @cite{B} times the inverse of @cite{A}. This also occurs
-if @cite{B} is itself a vector or matrix, in which case the effect is
-to solve the set of linear equations represented by @cite{B}. If @cite{B}
-is a matrix with the same number of rows as @cite{A}, or a plain vector
+dividing a scalar @expr{B} by a square matrix @expr{A}, the computation
+performed is @expr{B} times the inverse of @expr{A}. This also occurs
+if @expr{B} is itself a vector or matrix, in which case the effect is
+to solve the set of linear equations represented by @expr{B}. If @expr{B}
+is a matrix with the same number of rows as @expr{A}, or a plain vector
(which is interpreted here as a column vector), then the equation
-@cite{A X = B} is solved for the vector or matrix @cite{X}. Otherwise,
-if @cite{B} is a non-square matrix with the same number of @emph{columns}
-as @cite{A}, the equation @cite{X A = B} is solved. If you wish a vector
-@cite{B} to be interpreted as a row vector to be solved as @cite{X A = B},
+@expr{A X = B} is solved for the vector or matrix @expr{X}. Otherwise,
+if @expr{B} is a non-square matrix with the same number of @emph{columns}
+as @expr{A}, the equation @expr{X A = B} is solved. If you wish a vector
+@expr{B} to be interpreted as a row vector to be solved as @expr{X A = B},
make it into a one-row matrix with @kbd{C-u 1 v p} first. To force a
-left-handed solution with a square matrix @cite{B}, transpose @cite{A} and
-@cite{B} before dividing, then transpose the result.
+left-handed solution with a square matrix @expr{B}, transpose @expr{A} and
+@expr{B} before dividing, then transpose the result.
HMS forms can be divided by real numbers or by other HMS forms. Error
forms can be divided in any combination of ways. Modulo forms where both
@tindex %
The @kbd{%} (@code{calc-mod}) command performs a ``modulo'' (or ``remainder'')
operation. Mathematically, @samp{a%b = a - (a\b)*b}, and is defined
-for all real numbers @cite{a} and @cite{b} (except @cite{b=0}). For
-positive @cite{b}, the result will always be between 0 (inclusive) and
-@cite{b} (exclusive). Modulo does not work for HMS forms and error forms.
-If @cite{a} is a modulo form, its modulo is changed to @cite{b}, which
+for all real numbers @expr{a} and @expr{b} (except @expr{b=0}). For
+positive @expr{b}, the result will always be between 0 (inclusive) and
+@expr{b} (exclusive). Modulo does not work for HMS forms and error forms.
+If @expr{a} is a modulo form, its modulo is changed to @expr{b}, which
must be positive real number.
@kindex :
@pindex calc-fdiv
@tindex fdiv
-The @kbd{:} (@code{calc-fdiv}) command [@code{fdiv} function in a formula]
+The @kbd{:} (@code{calc-fdiv}) [@code{fdiv}] command
divides the two integers on the top of the stack to produce a fractional
-result. This is a convenient shorthand for enabling Fraction Mode (with
+result. This is a convenient shorthand for enabling Fraction mode (with
@kbd{m f}) temporarily and using @samp{/}. Note that during numeric entry
the @kbd{:} key is interpreted as a fraction separator, so to divide 8 by 6
you would have to type @kbd{8 @key{RET} 6 @key{RET} :}. (Of course, in
@pindex calc-sign
@tindex sign
The @kbd{f s} (@code{calc-sign}) [@code{sign}] command returns 1 if its
-argument is positive, @i{-1} if its argument is negative, or 0 if its
+argument is positive, @mathit{-1} if its argument is negative, or 0 if its
argument is zero. In algebraic form, you can also write @samp{sign(a,x)}
which evaluates to @samp{x * sign(a)}, i.e., either @samp{x}, @samp{-x}, or
zero depending on the sign of @samp{a}.
@tindex inv
@cindex Reciprocal
The @kbd{&} (@code{calc-inv}) [@code{inv}] command computes the
-reciprocal of a number, i.e., @cite{1 / x}. Operating on a square
+reciprocal of a number, i.e., @expr{1 / x}. Operating on a square
matrix, it computes the inverse of that matrix.
@kindex Q
@tindex sqrt
The @kbd{Q} (@code{calc-sqrt}) [@code{sqrt}] command computes the square
root of a number. For a negative real argument, the result will be a
-complex number whose form is determined by the current Polar Mode.
+complex number whose form is determined by the current Polar mode.
@kindex f h
@pindex calc-hypot
@tindex hypot
The @kbd{f h} (@code{calc-hypot}) [@code{hypot}] command computes the square
root of the sum of the squares of two numbers. That is, @samp{hypot(a,b)}
-is the length of the hypotenuse of a right triangle with sides @cite{a}
-and @cite{b}. If the arguments are complex numbers, their squared
+is the length of the hypotenuse of a right triangle with sides @expr{a}
+and @expr{b}. If the arguments are complex numbers, their squared
magnitudes are used.
@kindex f Q
respectively. These commands also work on HMS forms, date forms,
intervals, and infinities. (In algebraic expressions, these functions
take any number of arguments and return the maximum or minimum among
-all the arguments.)@refill
+all the arguments.)
@kindex f M
@kindex f X
@pindex calc-xpon-part
@tindex xpon
The @kbd{f M} (@code{calc-mant-part}) [@code{mant}] function extracts
-the ``mantissa'' part @cite{m} of its floating-point argument; @kbd{f X}
+the ``mantissa'' part @expr{m} of its floating-point argument; @kbd{f X}
(@code{calc-xpon-part}) [@code{xpon}] extracts the ``exponent'' part
-@cite{e}. The original number is equal to @c{$m \times 10^e$}
-@cite{m * 10^e},
-where @cite{m} is in the interval @samp{[1.0 ..@: 10.0)} except that
-@cite{m=e=0} if the original number is zero. For integers
+@expr{e}. The original number is equal to
+@texline @math{m \times 10^e},
+@infoline @expr{m * 10^e},
+where @expr{m} is in the interval @samp{[1.0 ..@: 10.0)} except that
+@expr{m=e=0} if the original number is zero. For integers
and fractions, @code{mant} returns the number unchanged and @code{xpon}
returns zero. The @kbd{v u} (@code{calc-unpack}) command can also be
used to ``unpack'' a floating-point number; this produces an integer
mantissa and exponent, with the constraint that the mantissa is not
-a multiple of ten (again except for the @cite{m=e=0} case).@refill
+a multiple of ten (again except for the @expr{m=e=0} case).
@kindex f S
@pindex calc-scale-float
by a given power of ten. Thus, @samp{scf(mant(x), xpon(x)) = x} for any
real @samp{x}. The second argument must be an integer, but the first
may actually be any numeric value. For example, @samp{scf(5,-2) = 0.05}
-or @samp{1:20} depending on the current Fraction Mode.@refill
+or @samp{1:20} depending on the current Fraction mode.
@kindex f [
@kindex f ]
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 @c{$10^{-p}$}
-@cite{10^-p}, where @cite{p} is the current
+@samp{0.0} produces
+@texline @math{10^{-p}},
+@infoline @expr{10^-p},
+where @expr{p} is the current
precision. These operations are defined only on integers and floats.
-With numeric prefix arguments, they change the number by @cite{n} units.
+With numeric prefix arguments, they change the number by @expr{n} units.
Note that incrementing followed by decrementing, or vice-versa, will
almost but not quite always cancel out. Suppose the precision is
The @kbd{F} (@code{calc-floor}) [@code{floor} or @code{ffloor}] command
truncates a real number to the next lower integer, i.e., toward minus
infinity. Thus @kbd{3.6 F} produces 3, but @kbd{_3.6 F} produces
-@i{-4}.@refill
+@mathit{-4}.
@kindex I F
@pindex calc-ceiling
@kindex H I F
The @kbd{I F} (@code{calc-ceiling}) [@code{ceil} or @code{fceil}]
command truncates toward positive infinity. Thus @kbd{3.6 I F} produces
-4, and @kbd{_3.6 I F} produces @i{-3}.@refill
+4, and @kbd{_3.6 I F} produces @mathit{-3}.
@kindex R
@pindex calc-round
rounds to the nearest integer. When the fractional part is .5 exactly,
this command rounds away from zero. (All other rounding in the
Calculator uses this convention as well.) Thus @kbd{3.5 R} produces 4
-but @kbd{3.4 R} produces 3; @kbd{_3.5 R} produces @i{-4}.@refill
+but @kbd{3.4 R} produces 3; @kbd{_3.5 R} produces @mathit{-4}.
@kindex I R
@pindex calc-trunc
The @kbd{I R} (@code{calc-trunc}) [@code{trunc} or @code{ftrunc}]
command truncates toward zero. In other words, it ``chops off''
everything after the decimal point. Thus @kbd{3.6 I R} produces 3 and
-@kbd{_3.6 I R} produces @i{-3}.@refill
+@kbd{_3.6 I R} produces @mathit{-3}.
These functions may not be applied meaningfully to error forms, but they
do work for intervals. As a convenience, applying @code{floor} to a
already have been rounded to the current precision before @code{rounde}
begins. For example, @samp{rounde(2.500001)} with a current precision
of 6 will incorrectly, or at least surprisingly, yield 2 because the
-argument will first have been rounded down to @cite{2.5} (which
+argument will first have been rounded down to @expr{2.5} (which
@code{rounde} sees as an exact tie between 2 and 3).
Each of these functions, when written in algebraic formulas, allows
@cindex Fractional part of a number
To compute the fractional part of a number (i.e., the amount which, when
-added to `@t{floor(}@var{n}@t{)}', will produce @var{n}) just take @var{n}
-modulo 1 using the @code{%} command.@refill
+added to `@tfn{floor(}@var{n}@tfn{)}', will produce @var{n}) just take @var{n}
+modulo 1 using the @code{%} command.
Note also the @kbd{\} (integer quotient), @kbd{f I} (integer logarithm),
and @kbd{f Q} (integer square root) commands, which are analogous to
@pindex calc-conj
@tindex conj
The @kbd{J} (@code{calc-conj}) [@code{conj}] command computes the
-complex conjugate of a number. For complex number @cite{a+bi}, the
-complex conjugate is @cite{a-bi}. If the argument is a real number,
+complex conjugate of a number. For complex number @expr{a+bi}, the
+complex conjugate is @expr{a-bi}. If the argument is a real number,
this command leaves it the same. If the argument is a vector or matrix,
this command replaces each element by its complex conjugate.
The @kbd{G} (@code{calc-argument}) [@code{arg}] command computes the
``argument'' or polar angle of a complex number. For a number in polar
notation, this is simply the second component of the pair
-`@t{(}@var{r}@t{;}@c{$\theta$}
-@var{theta}@t{)}'.
+@texline `@tfn{(}@var{r}@tfn{;}@math{\theta}@tfn{)}'.
+@infoline `@tfn{(}@var{r}@tfn{;}@var{theta}@tfn{)}'.
The result is expressed according to the current angular mode and will
-be in the range @i{-180} degrees (exclusive) to @i{+180} degrees
-(inclusive), or the equivalent range in radians.@refill
+be in the range @mathit{-180} degrees (exclusive) to @mathit{+180} degrees
+(inclusive), or the equivalent range in radians.
@pindex calc-imaginary
The @code{calc-imaginary} command multiplies the number on the
-top of the stack by the imaginary number @cite{i = (0,1)}. This
+top of the stack by the imaginary number @expr{i = (0,1)}. This
command is not normally bound to a key in Calc, but it is available
-on the @key{IMAG} button in Keypad Mode.
+on the @key{IMAG} button in Keypad mode.
@kindex f r
@pindex calc-re
The @kbd{f r} (@code{calc-re}) [@code{re}] command replaces a complex number
by its real part. This command has no effect on real numbers. (As an
added convenience, @code{re} applied to a modulo form extracts
-the value part.)@refill
+the value part.)
@kindex f i
@pindex calc-im
@tindex im
The @kbd{f i} (@code{calc-im}) [@code{im}] command replaces a complex number
by its imaginary part; real numbers are converted to zero. With a vector
-or matrix argument, these functions operate element-wise.@refill
+or matrix argument, these functions operate element-wise.
@ignore
@mindex v p
@pindex calc-pack
The @kbd{v p} (@code{calc-pack}) command can pack the top two numbers on
the stack into a composite object such as a complex number. With
-a prefix argument of @i{-1}, it produces a rectangular complex number;
-with an argument of @i{-2}, it produces a polar complex number.
+a prefix argument of @mathit{-1}, it produces a rectangular complex number;
+with an argument of @mathit{-2}, it produces a polar complex number.
(Also, @pxref{Building Vectors}.)
@ignore
@tindex pfloat
The @kbd{c f} (@code{calc-float}) [@code{pfloat}] command converts the
number on the top of the stack to floating-point form. For example,
-@cite{23} is converted to @cite{23.0}, @cite{3:2} is converted to
-@cite{1.5}, and @cite{2.3} is left the same. If the value is a composite
+@expr{23} is converted to @expr{23.0}, @expr{3:2} is converted to
+@expr{1.5}, and @expr{2.3} is left the same. If the value is a composite
object such as a complex number or vector, each of the components is
converted to floating-point. If the value is a formula, all numbers
in the formula are converted to floating-point. Note that depending
on the current floating-point precision, conversion to floating-point
-format may lose information.@refill
+format may lose information.
As a special exception, integers which appear as powers or subscripts
are not floated by @kbd{c f}. If you really want to float a power,
The @kbd{c d} (@code{calc-to-degrees}) [@code{deg}] command converts a
number into degrees form. The value on the top of the stack may be an
HMS form (interpreted as degrees-minutes-seconds), or a real number which
-will be interpreted in radians regardless of the current angular mode.@refill
+will be interpreted in radians regardless of the current angular mode.
@kindex c r
@pindex calc-to-radians
functions in algebraic formulas, depending on the direction of
conversion. (It uses @code{polar}, except that if the argument is
already a polar complex number, it uses @code{rect} instead. The
-@kbd{I c p} command always uses @code{rect}.)@refill
+@kbd{I c p} command always uses @code{rect}.)
@kindex c c
@pindex calc-clean
The @kbd{c c} (@code{calc-clean}) [@code{pclean}] command ``cleans'' the
number on the top of the stack. Floating point numbers are re-rounded
according to the current precision. Polar numbers whose angular
-components have strayed from the @i{-180} to @i{+180} degree range
+components have strayed from the @mathit{-180} to @mathit{+180} degree range
are normalized. (Note that results will be undesirable if the current
angular mode is different from the one under which the number was
produced!) Integers and fractions are generally unaffected by this
operation. Vectors and formulas are cleaned by cleaning each component
-number (i.e., pervasively).@refill
+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}
@var{n} in the range from 1 to 366, @kbd{t Y} computes the
@var{n}th day of the year (366 is treated as 365 in non-leap
years). A prefix argument of 0 computes the last day of the
-year (December 31). A negative prefix argument from @i{-1} to
-@i{-12} computes the first day of the @var{n}th month of the year.
+year (December 31). A negative prefix argument from @mathit{-1} to
+@mathit{-12} computes the first day of the @var{n}th month of the year.
@kindex t W
@pindex calc-new-week
There is no @code{newday} function at all because @kbd{F} [@code{floor}]
serves this purpose. Similarly, instead of @code{incday} and
-@code{incweek} simply use @cite{d + n} or @cite{d + 7 n}.
+@code{incweek} simply use @expr{d + n} or @expr{d + 7 n}.
@xref{Basic Arithmetic}, for the @kbd{f ]} [@code{incr}] command
which can adjust a date/time form by a certain number of seconds.
@item
Any Calc formula which evaluates to one of the above three things.
-If the formula involves the variable @cite{y}, it stands for a
-yearly repeating holiday; @cite{y} will take on various year
+If the formula involves the variable @expr{y}, it stands for a
+yearly repeating holiday; @expr{y} will take on various year
numbers like 1992. For example, @samp{date(y, 12, 25)} specifies
Christmas day, and @samp{newweek(date(y, 11, 7), 4) + 21} specifies
Thanksgiving (which is held on the fourth Thursday of November).
-If the formula involves the variable @cite{m}, that variable
+If the formula involves the variable @expr{m}, that variable
takes on month numbers from 1 to 12: @samp{date(y, m, 15)} is
a holiday that takes place on the 15th of every month.
If your system does not have a suitable @samp{date} command, you
may wish to put a @samp{(setq var-TimeZone ...)} in your Emacs
-initialization file to set the time zone. The easiest way to do
+initialization file to set the time zone. (Since you are interacting
+with the variable @code{TimeZone} directly from Emacs Lisp, the
+@code{var-} prefix needs to be present.) 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.
name of a function that is used to compute the daylight savings
adjustment for a given date. The default is
@code{math-std-daylight-savings}, which computes an adjustment
-(either 0 or @i{-1}) using the North American rules given above.
+(either 0 or @mathit{-1}) using the North American rules given above.
The daylight savings hook function is called with four arguments:
The date, as a floating-point number in standard Calc format;
@noindent
The @code{bump} parameter is equal to zero when Calc is converting
from a date form in a generalized time zone into a GMT date value.
-It is @i{-1} when Calc is converting in the other direction. The
+It is @mathit{-1} when Calc is converting in the other direction. The
adjustments shown above ensure that the conversion behaves correctly
and reasonably around the 2 a.m.@: transition in each direction.
falls in this hour results in a time value for the following hour,
from 3 a.m.@: to 4 a.m. At the end of daylight savings time, the
hour from 1 a.m.@: to 2 a.m.@: repeats itself; converting a date/time
-form that falls in in this hour results in a time value for the first
+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 later).
If @code{math-daylight-savings-hook} is @code{nil}, then the
20% smaller than 50. (The answers are different in magnitude
because, in the first case, we're increasing by 25% of 40, but
in the second case, we're decreasing by 20% of 50.) The effect
-of @kbd{40 @key{RET} 50 b %} is to compute @cite{(50-40)/40}, converting
+of @kbd{40 @key{RET} 50 b %} is to compute @expr{(50-40)/40}, converting
the answer to percentage form as if by @kbd{c %}.
@node Future Value, Present Value, Percentages, Financial Functions
fourth argument, which is used as an initial lump sum in the sense
of @code{fvl}. In other words, @code{fv(@var{rate}, @var{n},
@var{payment}, @var{initial}) = fv(@var{rate}, @var{n}, @var{payment})
-+ fvl(@var{rate}, @var{n}, @var{initial})}.@refill
++ fvl(@var{rate}, @var{n}, @var{initial})}.
To illustrate the relationships between these functions, we could
do the @code{fvb} calculation ``by hand'' using @code{fvl}. The
as the beginning of the next, so what this really means is that we've
lost the payment at year zero (which contributed $1300.78), but we're
now counting the payment at year five (which, since it didn't have
-a chance to earn interest, counts as $1000). Indeed, @cite{5569.96 =
+a chance to earn interest, counts as $1000). Indeed, @expr{5569.96 =
5870.73 - 1300.78 + 1000} (give or take a bit of roundoff error).
@node Present Value, Related Financial Functions, Future Value, Financial Functions
the return from leaving the money in the bank, which is
@code{fvl(9%, 4, @var{x})} where @var{x} is the amount of money
you would have to put up in advance. The @code{pv} function
-finds the break-even point, @cite{x = 6479.44}, at which
+finds the break-even point, @expr{x = 6479.44}, at which
@code{fvl(9%, 4, 6479.44)} is also equal to 9146.26. This is
the largest amount you should be willing to invest.
payment arguments, each either a vector or a plain number, all these
values are collected left-to-right into the complete list of payments.
A numeric prefix argument on the @kbd{b N} command says how many
-payment values or vectors to take from the stack.@refill
+payment values or vectors to take from the stack.
@kindex I b N
@tindex npvb
the amount of periodic payment necessary to amortize a loan.
Thus @code{pmt(@var{rate}, @var{n}, @var{amount})} equals the
value of @var{payment} such that @code{pv(@var{rate}, @var{n},
-@var{payment}) = @var{amount}}.@refill
+@var{payment}) = @var{amount}}.
@kindex I b M
@tindex pmtb
the value of @var{n} such that @code{pv(@var{rate}, @var{n},
@var{payment}) = @var{amount}}. If @var{payment} is too small
ever to amortize a loan for @var{amount} at interest rate @var{rate},
-the @code{nper} function is left in symbolic form.@refill
+the @code{nper} function is left in symbolic form.
@kindex I b #
@tindex nperb
The @kbd{I b #} [@code{nperb}] command does the same computation
but using @code{pvb} instead of @code{pv}. You can give a fourth
lump-sum argument to these functions, but the computation will be
-rather slow in the four-argument case.@refill
+rather slow in the four-argument case.
@kindex H b #
@tindex nperl
using @code{pvl}. By exchanging @var{payment} and @var{amount} you
can also get the solution for @code{fvl}. For example,
@code{nperl(8%, 2000, 1000) = 9.006}, so if you place $1000 in a
-bank account earning 8%, it will take nine years to grow to $2000.@refill
+bank account earning 8%, it will take nine years to grow to $2000.
@kindex b T
@pindex calc-fin-rate
the rate of return on an investment. This is also an inverse of @code{pv}:
@code{rate(@var{n}, @var{payment}, @var{amount})} computes the value of
@var{rate} such that @code{pv(@var{rate}, @var{n}, @var{payment}) =
-@var{amount}}. The result is expressed as a formula like @samp{6.3%}.@refill
+@var{amount}}. The result is expressed as a formula like @samp{6.3%}.
@kindex I b T
@kindex H b T
accept an optional fourth argument just like @code{pv} and @code{pvb}.
To redo the above example from a different perspective,
@code{ratel(9, 2000, 1000) = 8.00597%}, which says you will need an
-interest rate of 8% in order to double your account in nine years.@refill
+interest rate of 8% in order to double your account in nine years.
@kindex b I
@pindex calc-fin-irr
parameter as well, although it will ignore its value except that the
return value will as usual be zero if @var{period} is out of range.
-For example, pushing the vector @cite{[1,2,3,4,5]} (perhaps with @kbd{v x 5})
+For example, pushing the vector @expr{[1,2,3,4,5]} (perhaps with @kbd{v x 5})
and then mapping @kbd{V M ' [sln(12000,2000,5,$), syd(12000,2000,5,$),
ddb(12000,2000,5,$)] @key{RET}} produces a matrix that allows us to compare
the three depreciation methods:
@kbd{syd} depreciates more at the beginning and less at the end,
and @kbd{ddb} weights the depreciation even more toward the beginning.
-Summing columns with @kbd{V R : +} yields @cite{[10000, 10000, 10000]};
+Summing columns with @kbd{V R : +} yields @expr{[10000, 10000, 10000]};
the total depreciation in any method is (by definition) the
difference between the cost and the salvage value.
integrals or solving equations involving the functions.
@ifinfo
-These formulas are shown using the conventions of ``Big'' display
+These formulas are shown using the conventions of Big display
mode (@kbd{d B}); for example, the formula for @code{fv} written
linearly is @samp{pmt * ((1 + rate)^n) - 1) / rate}.
@end tex
@noindent
-In @code{pmt} and @code{pmtb}, @cite{x=0} if omitted.
+In @code{pmt} and @code{pmtb}, @expr{x=0} if omitted.
These functions accept any numeric objects, including error forms,
intervals, and even (though not very usefully) complex numbers. The
function returns the amount the book value decreased in the specified
period.
-The Calc financial function names were borrowed mostly from Microsoft
-Excel and Borland's Quattro. The @code{ratel} function corresponds to
-@samp{@@CGR} in Borland's Reflex. The @code{nper} and @code{nperl}
-functions correspond to @samp{@@TERM} and @samp{@@CTERM} in Quattro,
-respectively. Beware that the Calc functions may take their arguments
-in a different order than the corresponding functions in your favorite
-spreadsheet.
-
@node Binary Functions, , Financial Functions, Arithmetic
@section Binary Number Functions
zeros with @kbd{d z}. @xref{Radix Modes}.
@cindex Word size for binary operations
-The Calculator maintains a current @dfn{word size} @cite{w}, an
+The Calculator maintains a current @dfn{word size} @expr{w}, an
arbitrary positive or negative integer. For a positive word size, all
-of the binary operations described here operate modulo @cite{2^w}. In
+of the binary operations described here operate modulo @expr{2^w}. In
particular, negative arguments are converted to positive integers modulo
-@cite{2^w} by all binary functions.@refill
+@expr{2^w} by all binary functions.
If the word size is negative, binary operations produce 2's complement
-integers from @c{$-2^{-w-1}$}
-@cite{-(2^(-w-1))} to @c{$2^{-w-1}-1$}
-@cite{2^(-w-1)-1} inclusive. Either
-mode accepts inputs in any range; the sign of @cite{w} affects only
-the results produced.
+integers from
+@texline @math{-2^{-w-1}}
+@infoline @expr{-(2^(-w-1))}
+to
+@texline @math{2^{-w-1}-1}
+@infoline @expr{2^(-w-1)-1}
+inclusive. Either mode accepts inputs in any range; the sign of
+@expr{w} affects only the results produced.
@kindex b c
@pindex calc-clip
@tindex clip
The @kbd{b c} (@code{calc-clip})
[@code{clip}] command can be used to clip a number by reducing it modulo
-@cite{2^w}. The commands described in this chapter automatically clip
+@expr{2^w}. The commands described in this chapter automatically clip
their results to the current word size. Note that other operations like
addition do not use the current word size, since integer addition
generally is not ``binary.'' (However, @pxref{Simplification Modes},
@code{calc-bin-simplify-mode}.) For example, with a word size of 8
bits @kbd{b c} converts a number to the range 0 to 255; with a word
-size of @i{-8} @kbd{b c} converts to the range @i{-128} to 127.@refill
+size of @mathit{-8} @kbd{b c} converts to the range @mathit{-128} to 127.
@kindex b w
@pindex calc-word-size
optional second (or third) word-size parameter. When a formula like
@samp{and(a,b)} is finally evaluated, the word size current at that time
will be used, but when @samp{and(a,b,-8)} is evaluated, a word size of
-@i{-8} will always be used. A symbolic binary function will be left
+@mathit{-8} will always be used. A symbolic binary function will be left
in symbolic form unless the all of its argument(s) are integers or
integer-valued floats.
-If either or both arguments are modulo forms for which @cite{M} is a
+If either or both arguments are modulo forms for which @expr{M} is a
power of two, that power of two is taken as the word size unless a
numeric prefix argument overrides it. The current word size is never
consulted when modulo-power-of-two forms are involved.
@tindex and
The @kbd{b a} (@code{calc-and}) [@code{and}] command computes the bitwise
AND of the two numbers on the top of the stack. In other words, for each
-of the @cite{w} binary digits of the two numbers (pairwise), the corresponding
+of the @expr{w} binary digits of the two numbers (pairwise), the corresponding
bit of the result is 1 if and only if both input bits are 1:
@samp{and(2#1100, 2#1010) = 2#1000}.
@cindex Phi, golden ratio
@cindex Golden ratio
One miscellaneous command is shift-@kbd{P} (@code{calc-pi}), which pushes
-the value of @c{$\pi$}
-@cite{pi} (at the current precision) onto the stack. With the
-Hyperbolic flag, it pushes the value @cite{e}, the base of natural logarithms.
-With the Inverse flag, it pushes Euler's constant @c{$\gamma$}
-@cite{gamma} (about 0.5772). With both Inverse and Hyperbolic, it
-pushes the ``golden ratio'' @c{$\phi$}
-@cite{phi} (about 1.618). (At present, Euler's constant is not available
+the value of @cpi{} (at the current precision) onto the stack. With the
+Hyperbolic flag, it pushes the value @expr{e}, the base of natural logarithms.
+With the Inverse flag, it pushes Euler's constant
+@texline @math{\gamma}
+@infoline @expr{gamma}
+(about 0.5772). With both Inverse and Hyperbolic, it
+pushes the ``golden ratio''
+@texline @math{\phi}
+@infoline @expr{phi}
+(about 1.618). (At present, Euler's constant is not available
to unlimited precision; Calc knows only the first 100 digits.)
In Symbolic mode, these commands push the
actual variables @samp{pi}, @samp{e}, @samp{gamma}, and @samp{phi},
-respectively, instead of their values; @pxref{Symbolic Mode}.@refill
+respectively, instead of their values; @pxref{Symbolic Mode}.
@ignore
@mindex Q
@end ignore
@kindex I L
The shift-@kbd{E} (@code{calc-exp}) [@code{exp}] command computes the
-exponential, i.e., @cite{e} raised to the power of the number on the stack.
+exponential, i.e., @expr{e} raised to the power of the number on the stack.
The meanings of the Inverse and Hyperbolic flags follow from those for
the @code{calc-ln} command.
(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 @c{$\ln10$}
-@cite{ln(10)}.
+by
+@texline @math{\ln10}.
+@infoline @expr{ln(10)}.
@kindex B
@kindex I B
@tindex alog
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
-@c{$2^{10} = 1024$}
-@cite{2^10 = 1024}. In certain cases like @samp{log(3,9)}, the result
-will be either @cite{1:2} or @cite{0.5} depending on the current Fraction
-Mode setting. With the Inverse flag [@code{alog}], this command is
+@texline @math{2^{10} = 1024}.
+@infoline @expr{2^10 = 1024}.
+In certain cases like @samp{log(3,9)}, the result
+will be either @expr{1:2} or @expr{0.5} depending on the current Fraction
+mode setting. With the Inverse flag [@code{alog}], this command is
similar to @kbd{^} except that the order of the arguments is reversed.
@kindex f I
The @kbd{f I} (@code{calc-ilog}) [@code{ilog}] command computes the
integer logarithm of a number to any base. The number and the base must
themselves be positive integers. This is the true logarithm, rounded
-down to an integer. Thus @kbd{ilog(x,10)} is 3 for all @cite{x} in the
+down to an integer. Thus @kbd{ilog(x,10)} is 3 for all @expr{x} in the
range from 1000 to 9999. If both arguments are positive integers, exact
integer arithmetic is used; otherwise, this is equivalent to
@samp{floor(log(x,b))}.
@pindex calc-expm1
@tindex expm1
The @kbd{f E} (@code{calc-expm1}) [@code{expm1}] command computes
-@c{$e^x - 1$}
-@cite{exp(x)-1}, but using an algorithm that produces a more accurate
-answer when the result is close to zero, i.e., when @c{$e^x$}
-@cite{exp(x)} is close
-to one.
+@texline @math{e^x - 1},
+@infoline @expr{exp(x)-1},
+but using an algorithm that produces a more accurate
+answer when the result is close to zero, i.e., when
+@texline @math{e^x}
+@infoline @expr{exp(x)}
+is close to one.
@kindex f L
@pindex calc-lnp1
@tindex lnp1
The @kbd{f L} (@code{calc-lnp1}) [@code{lnp1}] command computes
-@c{$\ln(x+1)$}
-@cite{ln(x+1)}, producing a more accurate answer when @cite{x} is close
-to zero.
+@texline @math{\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
@section Trigonometric/Hyperbolic Functions
of an angle or complex number. If the input is an HMS form, it is interpreted
as degrees-minutes-seconds; otherwise, the input is interpreted according
to the current angular mode. It is best to use Radians mode when operating
-on complex numbers.@refill
+on complex numbers.
Calc's ``units'' mechanism includes angular units like @code{deg},
@code{rad}, and @code{grad}. While @samp{sin(45 deg)} is not evaluated
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
-formulas when the current angular mode is radians @emph{and} symbolic
+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
have stored a different value in the variable @samp{pi}; this is one
reason why changing built-in variables is a bad idea. Arguments of
-the form @cite{x} plus a multiple of @c{$\pi/2$}
-@cite{pi/2} are also simplified.
-Calc includes similar formulas for @code{cos} and @code{tan}.@refill
+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
-@c{$\pi/12$}
-@cite{pi/12}, @c{$\pi/10$}
-@cite{pi/10}, or @c{$\pi/8$}
-@cite{pi/8} radians. In degrees mode,
+@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.
@tindex arctan2
The @kbd{f T} (@code{calc-arctan2}) [@code{arctan2}] command takes two
numbers from the stack and computes the arc tangent of their ratio. The
-result is in the full range from @i{-180} (exclusive) to @i{+180}
+result is in the full range from @mathit{-180} (exclusive) to @mathit{+180}
(inclusive) degrees, or the analogous range in radians. A similar
result would be obtained with @kbd{/} followed by @kbd{I T}, but the
-value would only be in the range from @i{-90} to @i{+90} degrees
+value would only be in the range from @mathit{-90} to @mathit{+90} degrees
since the division loses information about the signs of the two
components, and an error might result from an explicit division by zero
which @code{arctan2} would avoid. By (arbitrary) definition,
@samp{[@var{cos}, @var{sin}]}.
With the Inverse flag [@code{arcsincos}], this command takes a two-element
vector as an argument and computes @code{arctan2} of the elements.
-(This command does not accept the Hyperbolic flag.)@refill
+(This command does not accept the Hyperbolic flag.)
+
+@pindex calc-sec
+@tindex sec
+@pindex calc-csc
+@tindex csc
+@pindex calc-cot
+@tindex cot
+@pindex calc-sech
+@tindex sech
+@pindex calc-csch
+@tindex csch
+@pindex calc-coth
+@tindex coth
+The remaining trigonometric functions, @code{calc-sec} [@code{sec}],
+@code{calc-csc} [@code{csc}] and @code{calc-sec} [@code{sec}], are also
+available. With the Hyperbolic flag, these compute their hyperbolic
+counterparts, which are also available separately as @code{calc-sech}
+[@code{sech}], @code{calc-csch} [@code{csch}] and @code{calc-sech}
+[@code{sech}]. (These commmands do not accept the Inverse flag.)
@node Advanced Math Functions, Branch Cuts, Trigonometric and Hyperbolic Functions, Scientific Functions
@section Advanced Mathematical Functions
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: @c{$\Gamma(a) = \int_0^\infty t^{a-1} e^t dt$}
-@cite{gamma(a) = integ(t^(a-1) exp(t), t, 0, inf)}.
+integral:
+@texline @math{\Gamma(a) = \int_0^\infty t^{a-1} e^t dt}.
+@infoline @expr{gamma(a) = integ(t^(a-1) exp(t), t, 0, inf)}.
(The actual implementation uses far more efficient computational methods.)
@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, @c{$P(a,x) = \left( \int_0^x t^{a-1} e^t dt \right) / \Gamma(a)$}
-@cite{gammaP(a,x) = integ(t^(a-1) exp(t), t, 0, x) / gamma(a)}.
-This implies that @samp{gammaP(a,inf) = 1} for any @cite{a} (see the
+the integral,
+@texline @math{P(a,x) = \left( \int_0^x t^{a-1} e^t dt \right) / \Gamma(a)}.
+@infoline @expr{gammaP(a,x) = integ(t^(a-1) exp(t), t, 0, x) / gamma(a)}.
+This implies that @samp{gammaP(a,inf) = 1} for any @expr{a} (see the
definition of the normal gamma function).
Several other varieties of incomplete gamma function are defined.
-The complement of @cite{P(a,x)}, called @cite{Q(a,x) = 1-P(a,x)} by
+The complement of @expr{P(a,x)}, called @expr{Q(a,x) = 1-P(a,x)} by
some authors, is computed by the @kbd{I f G} [@code{gammaQ}] command.
You can think of this as taking the other half of the integral, from
-@cite{x} to infinity.
+@expr{x} to infinity.
@ifinfo
-The functions corresponding to the integrals that define @cite{P(a,x)}
-and @cite{Q(a,x)} but without the normalizing @cite{1/gamma(a)}
-factor are called @cite{g(a,x)} and @cite{G(a,x)}, respectively
-(where @cite{g} and @cite{G} represent the lower- and upper-case Greek
+The functions corresponding to the integrals that define @expr{P(a,x)}
+and @expr{Q(a,x)} but without the normalizing @expr{1/gamma(a)}
+factor are called @expr{g(a,x)} and @expr{G(a,x)}, respectively
+(where @expr{g} and @expr{G} represent the lower- and upper-case Greek
letter gamma). You can obtain these using the @kbd{H f G} [@code{gammag}]
and @kbd{H I f G} [@code{gammaG}] commands.
@end ifinfo
@tindex beta
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
-@c{$B(a,b) = \Gamma(a) \Gamma(b) / \Gamma(a+b)$}
-@cite{beta(a,b) = gamma(a) gamma(b) / gamma(a+b)}, or by
-@c{$B(a,b) = \int_0^1 t^{a-1} (1-t)^{b-1} dt$}
-@cite{beta(a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, 1)}.
+@texline @math{B(a,b) = \Gamma(a) \Gamma(b) / \Gamma(a+b)},
+@infoline @expr{beta(a,b) = gamma(a) gamma(b) / gamma(a+b)},
+or by
+@texline @math{B(a,b) = \int_0^1 t^{a-1} (1-t)^{b-1} dt}.
+@infoline @expr{beta(a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, 1)}.
@kindex f B
@kindex H f B
@tindex betaI
@tindex betaB
The @kbd{f B} (@code{calc-inc-beta}) [@code{betaI}] command computes
-the incomplete beta function @cite{I(x,a,b)}. It is defined by
-@c{$I(x,a,b) = \left( \int_0^x t^{a-1} (1-t)^{b-1} dt \right) / B(a,b)$}
-@cite{betaI(x,a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, x) / beta(a,b)}.
+the incomplete beta function @expr{I(x,a,b)}. It is defined by
+@texline @math{I(x,a,b) = \left( \int_0^x t^{a-1} (1-t)^{b-1} dt \right) / B(a,b)}.
+@infoline @expr{betaI(x,a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, x) / beta(a,b)}.
Once again, the @kbd{H} (hyperbolic) prefix gives the corresponding
un-normalized version [@code{betaB}].
@tindex erf
@tindex erfc
The @kbd{f e} (@code{calc-erf}) [@code{erf}] command computes the
-error function @c{$\hbox{erf}(x) = {2 \over \sqrt{\pi}} \int_0^x e^{-t^2} dt$}
-@cite{erf(x) = 2 integ(exp(-(t^2)), t, 0, x) / sqrt(pi)}.
+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}]
is the corresponding integral from @samp{x} to infinity; the sum
-@c{$\hbox{erf}(x) + \hbox{erfc}(x) = 1$}
-@cite{erf(x) + erfc(x) = 1}.
+@texline @math{\hbox{erf}(x) + \hbox{erfc}(x) = 1}.
+@infoline @expr{erf(x) + erfc(x) = 1}.
@kindex f j
@kindex f y
(@code{calc-bessel-Y}) [@code{besY}] commands compute the Bessel
functions of the first and second kinds, respectively.
In @samp{besJ(n,x)} and @samp{besY(n,x)} the ``order'' parameter
-@cite{n} is often an integer, but is not required to be one.
+@expr{n} is often an integer, but is not required to be one.
Calc's implementation of the Bessel functions currently limits the
precision to 8 digits, and may not be exact even to that precision.
-Use with care!@refill
+Use with care!
@node Branch Cuts, Random Numbers, Advanced Math Functions, Scientific Functions
@section Branch Cuts and Principal Values
efficiency or accuracy. You may need to increase the floating precision
and wait a while to get suitable answers from them.
-For @samp{sqrt(a+bi)}: When @cite{a<0} and @cite{b} is small but positive
-or zero, the result is close to the @cite{+i} axis. For @cite{b} small and
-negative, the result is close to the @cite{-i} axis. The result always lies
+For @samp{sqrt(a+bi)}: When @expr{a<0} and @expr{b} is small but positive
+or zero, the result is close to the @expr{+i} axis. For @expr{b} small and
+negative, the result is close to the @expr{-i} axis. The result always lies
in the right half of the complex plane.
For @samp{ln(a+bi)}: The real part is defined as @samp{ln(abs(a+bi))}.
negative real axis.
The following table describes these branch cuts in another way.
-If the real and imaginary parts of @cite{z} are as shown, then
-the real and imaginary parts of @cite{f(z)} will be as shown.
+If the real and imaginary parts of @expr{z} are as shown, then
+the real and imaginary parts of @expr{f(z)} will be as shown.
Here @code{eps} stands for a small positive value; each
occurrence of @code{eps} may stand for a different small value.
For @samp{z1^z2}: This is defined by @samp{exp(ln(z1)*z2)}.
One interesting consequence of this is that @samp{(-8)^1:3} does
-not evaluate to @i{-2} as you might expect, but to the complex
-number @cite{(1., 1.732)}. Both of these are valid cube roots
-of @i{-8} (as is @cite{(1., -1.732)}); Calc chooses a perhaps
+not evaluate to @mathit{-2} as you might expect, but to the complex
+number @expr{(1., 1.732)}. Both of these are valid cube roots
+of @mathit{-8} (as is @expr{(1., -1.732)}); Calc chooses a perhaps
less-obvious root for the sake of mathematical consistency.
For @samp{arcsin(z)}: This is defined by @samp{-i*ln(i*z + sqrt(1-z^2))}.
-The branch cuts are on the real axis, less than @i{-1} and greater than 1.
+The branch cuts are on the real axis, less than @mathit{-1} and greater than 1.
For @samp{arccos(z)}: This is defined by @samp{-i*ln(z + i*sqrt(1-z^2))},
or equivalently by @samp{pi/2 - arcsin(z)}. The branch cuts are on
-the real axis, less than @i{-1} and greater than 1.
+the real axis, less than @mathit{-1} and greater than 1.
For @samp{arctan(z)}: This is defined by
@samp{(ln(1+i*z) - ln(1-i*z)) / (2*i)}. The branch cuts are on the
-imaginary axis, below @cite{-i} and above @cite{i}.
+imaginary axis, below @expr{-i} and above @expr{i}.
For @samp{arcsinh(z)}: This is defined by @samp{ln(z + sqrt(1+z^2))}.
-The branch cuts are on the imaginary axis, below @cite{-i} and
-above @cite{i}.
+The branch cuts are on the imaginary axis, below @expr{-i} and
+above @expr{i}.
For @samp{arccosh(z)}: This is defined by
@samp{ln(z + (z+1)*sqrt((z-1)/(z+1)))}. The branch cut is on the
real axis less than 1.
For @samp{arctanh(z)}: This is defined by @samp{(ln(1+z) - ln(1-z)) / 2}.
-The branch cuts are on the real axis, less than @i{-1} and greater than 1.
+The branch cuts are on the real axis, less than @mathit{-1} and greater than 1.
The following tables for @code{arcsin}, @code{arccos}, and
-@code{arctan} assume the current angular mode is radians. The
+@code{arctan} assume the current angular mode is Radians. The
hyperbolic functions operate independently of the angular mode.
@smallexample
The @kbd{k r} (@code{calc-random}) [@code{random}] command produces
random numbers of various sorts.
-Given a positive numeric prefix argument @cite{M}, it produces a random
-integer @cite{N} in the range @c{$0 \le N < M$}
-@cite{0 <= N < M}. Each of the @cite{M}
-values appears with equal probability.@refill
+Given a positive numeric prefix argument @expr{M}, it produces a random
+integer @expr{N} in the range
+@texline @math{0 \le N < M}.
+@infoline @expr{0 <= N < M}.
+Each of the @expr{M} values appears with equal probability.
With no numeric prefix argument, the @kbd{k r} command takes its argument
-from the stack instead. Once again, if this is a positive integer @cite{M}
-the result is a random integer less than @cite{M}. However, note that
-while numeric prefix arguments are limited to six digits or so, an @cite{M}
-taken from the stack can be arbitrarily large. If @cite{M} is negative,
-the result is a random integer in the range @c{$M < N \le 0$}
-@cite{M < N <= 0}.
-
-If the value on the stack is a floating-point number @cite{M}, the result
-is a random floating-point number @cite{N} in the range @c{$0 \le N < M$}
-@cite{0 <= N < M}
-or @c{$M < N \le 0$}
-@cite{M < N <= 0}, according to the sign of @cite{M}.
-
-If @cite{M} is zero, the result is a Gaussian-distributed random real
+from the stack instead. Once again, if this is a positive integer @expr{M}
+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
+@texline @math{M < N \le 0}.
+@infoline @expr{M < N <= 0}.
+
+If the value on the stack is a floating-point number @expr{M}, the result
+is a random floating-point number @expr{N} in the range
+@texline @math{0 \le N < M}
+@infoline @expr{0 <= N < M}
+or
+@texline @math{M < N \le 0},
+@infoline @expr{M < N <= 0},
+according to the sign of @expr{M}.
+
+If @expr{M} is zero, the result is a Gaussian-distributed random real
number; the distribution has a mean of zero and a standard deviation
of one. The algorithm used generates random numbers in pairs; thus,
every other call to this function will be especially fast.
-If @cite{M} is an error form @c{$m$ @code{+/-} $\sigma$}
-@samp{m +/- s} where @var{m}
-and @c{$\sigma$}
-@var{s} are both real numbers, the result uses a Gaussian
-distribution with mean @var{m} and standard deviation @c{$\sigma$}
-@var{s}.
-
-If @cite{M} is an interval form, the lower and upper bounds specify the
+If @expr{M} is an error form
+@texline @math{m} @code{+/-} @math{\sigma}
+@infoline @samp{m +/- s}
+where @var{m} and
+@texline @math{\sigma}
+@infoline @var{s}
+are both real numbers, the result uses a Gaussian distribution with mean
+@var{m} and standard deviation
+@texline @math{\sigma}.
+@infoline @var{s}.
+
+If @expr{M} is an interval form, the lower and upper bounds specify the
acceptable limits of the random numbers. If both bounds are integers,
the result is a random integer in the specified range. If either bound
is floating-point, the result is a random real number in the specified
additionally return 2.00000, but the probability of this happening is
extremely small.)
-If @cite{M} is a vector, the result is one element taken at random from
+If @expr{M} is a vector, the result is one element taken at random from
the vector. All elements of the vector are given equal probabilities.
@vindex RandSeed
@kindex k a
@pindex calc-random-again
The @kbd{k a} (@code{calc-random-again}) command produces another random
-number, re-using the most recent value of @cite{M}. With a numeric
+number, re-using the most recent value of @expr{M}. With a numeric
prefix argument @var{n}, it produces @var{n} more random numbers using
-that value of @cite{M}.
+that value of @expr{M}.
@kindex k h
@pindex calc-shuffle
The @kbd{k h} (@code{calc-shuffle}) command produces a vector of several
random values with no duplicates. The value on the top of the stack
specifies the set from which the random values are drawn, and may be any
-of the @cite{M} formats described above. The numeric prefix argument
+of the @expr{M} formats described above. The numeric prefix argument
gives the length of the desired list. (If you do not provide a numeric
prefix argument, the length of the list is taken from the top of the
-stack, and @cite{M} from second-to-top.)
+stack, and @expr{M} from second-to-top.)
-If @cite{M} is a floating-point number, zero, or an error form (so
+If @expr{M} is a floating-point number, zero, or an error form (so
that the random values are being drawn from the set of real numbers)
there is little practical difference between using @kbd{k h} and using
@kbd{k r} several times. But if the set of possible values consists
a very real chance that multiple @kbd{k r}'s will produce the same
number more than once. The @kbd{k h} command produces a vector whose
elements are always distinct. (Actually, there is a slight exception:
-If @cite{M} is a vector, no given vector element will be drawn more
-than once, but if several elements of @cite{M} are equal, they may
+If @expr{M} is a vector, no given vector element will be drawn more
+than once, but if several elements of @expr{M} are equal, they may
each make it into the result vector.)
One use of @kbd{k h} is to rearrange a list at random. This happens
@kbd{[1, 1.5, 2, 2.5, 3] 5 k h} might produce the permuted list
@samp{[2.5, 1, 1.5, 3, 2]}. As a convenient feature, if the argument
@var{n} is negative it is replaced by the size of the set represented
-by @cite{M}. Naturally, this is allowed only when @cite{M} specifies
+by @expr{M}. Naturally, this is allowed only when @expr{M} specifies
a small discrete set of possibilities.
To do the equivalent of @kbd{k h} but with duplications allowed,
-given @cite{M} on the stack and with @var{n} just entered as a numeric
-prefix, use @kbd{v b} to build a vector of copies of @cite{M}, then use
+given @expr{M} on the stack and with @var{n} just entered as a numeric
+prefix, use @kbd{v b} to build a vector of copies of @expr{M}, then use
@kbd{V M k r} to ``map'' the normal @kbd{k r} function over the
elements of this vector. @xref{Matrix Functions}.
If @code{RandSeed} contains an integer, Calc uses this integer to
seed an ``additive congruential'' method (Knuth's algorithm 3.2.2A,
-computing @c{$X_{n-55} - X_{n-24}$}
-@cite{X_n-55 - X_n-24}). This method expands the seed
+computing
+@texline @math{X_{n-55} - X_{n-24}}.
+@infoline @expr{X_n-55 - X_n-24}).
+This method expands the seed
value into a large table which is maintained internally; the variable
-@code{RandSeed} is changed from, e.g., 42 to the vector @cite{[42]}
+@code{RandSeed} is changed from, e.g., 42 to the vector @expr{[42]}
to indicate that the seed has been absorbed into this table. When
@code{RandSeed} contains a vector, @kbd{k r} and related commands
continue to use the same internal table as last time. There is no
To create a random floating-point number with precision @var{p}, Calc
simply creates a random @var{p}-digit integer and multiplies by
-@c{$10^{-p}$}
-@cite{10^-p}. The resulting random numbers should be very clean, but note
+@texline @math{10^{-p}}.
+@infoline @expr{10^-p}.
+The resulting random numbers should be very clean, but note
that relatively small numbers will have few significant random digits.
In other words, with a precision of 12, you will occasionally get
-numbers on the order of @c{$10^{-9}$}
-@cite{10^-9} or @c{$10^{-10}$}
-@cite{10^-10}, but those numbers
-will only have two or three random digits since they correspond to small
-integers times @c{$10^{-12}$}
-@cite{10^-12}.
+numbers on the order of
+@texline @math{10^{-9}}
+@infoline @expr{10^-9}
+or
+@texline @math{10^{-10}},
+@infoline @expr{10^-10},
+but those numbers will only have two or three random digits since they
+correspond to small integers times
+@texline @math{10^{-12}}.
+@infoline @expr{10^-12}.
To create a random integer in the interval @samp{[0 .. @var{m})}, Calc
counts the digits in @var{m}, creates a random integer with three
numerators, and the LCM of the denominators. This definition is
consistent with the idea that @samp{a / gcd(a,x)} should yield an
integer for any @samp{a} and @samp{x}. For other types of arguments,
-the operation is left in symbolic form.@refill
+the operation is left in symbolic form.
@kindex k l
@pindex calc-lcm
The @kbd{k l} (@code{calc-lcm}) [@code{lcm}] command computes the
Least Common Multiple of two integers or fractions. The product of
the LCM and GCD of two numbers is equal to the product of the
-numbers.@refill
+numbers.
@kindex k E
@pindex calc-extended-gcd
@tindex egcd
The @kbd{k E} (@code{calc-extended-gcd}) [@code{egcd}] command computes
-the GCD of two integers @cite{x} and @cite{y} and returns a vector
-@cite{[g, a, b]} where @c{$g = \gcd(x,y) = a x + b y$}
-@cite{g = gcd(x,y) = a x + b y}.
+the GCD of two integers @expr{x} and @expr{y} and returns a vector
+@expr{[g, a, b]} where
+@texline @math{g = \gcd(x,y) = a x + b y}.
+@infoline @expr{g = gcd(x,y) = a x + b y}.
@kindex !
@pindex calc-factorial
as defined by the Euler Gamma function. Please note that computation of
large factorials can be slow; using floating-point format will help
since fewer digits must be maintained. The same is true of many of
-the commands in this section.@refill
+the commands in this section.
@kindex k d
@pindex calc-double-factorial
@tindex !!
The @kbd{k d} (@code{calc-double-factorial}) [@code{dfact}] command
computes the ``double factorial'' of an integer. For an even integer,
-this is the product of even integers from 2 to @cite{N}. For an odd
-integer, this is the product of odd integers from 3 to @cite{N}. If
+this is the product of even integers from 2 to @expr{N}. For an odd
+integer, this is the product of odd integers from 3 to @expr{N}. If
the argument is an integer-valued float, the result is a floating-point
approximation. This function is undefined for negative even integers.
-The notation @cite{N!!} is also recognized for double factorials.@refill
+The notation @expr{N!!} is also recognized for double factorials.
@kindex k c
@pindex calc-choose
@tindex choose
The @kbd{k c} (@code{calc-choose}) [@code{choose}] command computes the
-binomial coefficient @cite{N}-choose-@cite{M}, where @cite{M} is the number
-on the top of the stack and @cite{N} is second-to-top. If both arguments
+binomial coefficient @expr{N}-choose-@expr{M}, where @expr{M} is the number
+on the top of the stack and @expr{N} is second-to-top. If both arguments
are integers, the result is an exact integer. Otherwise, the result is a
floating-point approximation. The binomial coefficient is defined for all
-real numbers by @c{$N! \over M! (N-M)!\,$}
-@cite{N! / M! (N-M)!}.
+real numbers by
+@texline @math{N! \over M! (N-M)!\,}.
+@infoline @expr{N! / M! (N-M)!}.
@kindex H k c
@pindex calc-perm
@tindex perm
@ifinfo
The @kbd{H k c} (@code{calc-perm}) [@code{perm}] command computes the
-number-of-permutations function @cite{N! / (N-M)!}.
+number-of-permutations function @expr{N! / (N-M)!}.
@end ifinfo
@tex
The \kbd{H k c} (\code{calc-perm}) [\code{perm}] command computes the
@tindex bern
The @kbd{k b} (@code{calc-bernoulli-number}) [@code{bern}] command
computes a given Bernoulli number. The value at the top of the stack
-is a nonnegative integer @cite{n} that specifies which Bernoulli number
+is a nonnegative integer @expr{n} that specifies which Bernoulli number
is desired. The @kbd{H k b} command computes a Bernoulli polynomial,
-taking @cite{n} from the second-to-top position and @cite{x} from the
-top of the stack. If @cite{x} is a variable or formula the result is
-a polynomial in @cite{x}; if @cite{x} is a number the result is a number.
+taking @expr{n} from the second-to-top position and @expr{x} from the
+top of the stack. If @expr{x} is a variable or formula the result is
+a polynomial in @expr{x}; if @expr{x} is a number the result is a number.
@kindex k e
@kindex H k e
@tindex stir1
@tindex stir2
The @kbd{k s} (@code{calc-stirling-number}) [@code{stir1}] command
-computes a Stirling number of the first kind@c{ $n \brack m$}
-@asis{}, given two integers
-@cite{n} and @cite{m} on the stack. The @kbd{H k s} [@code{stir2}]
-command computes a Stirling number of the second kind@c{ $n \brace m$}
-@asis{}. These are
-the number of @cite{m}-cycle permutations of @cite{n} objects, and
-the number of ways to partition @cite{n} objects into @cite{m}
+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
+@texline kind@tie{}@math{n \brace m}.
+@infoline kind.
+These are the number of @expr{m}-cycle permutations of @expr{n} objects,
+and the number of ways to partition @expr{n} objects into @expr{m}
non-empty sets, respectively.
@kindex k p
test. Pressing @kbd{k p} repeatedly for the same integer will perform
additional iterations. Also, @kbd{k p} with a numeric prefix performs
the specified number of iterations. There is also an algebraic function
-@samp{prime(n)} or @samp{prime(n,iters)} which returns 1 if @cite{n}
+@samp{prime(n)} or @samp{prime(n,iters)} which returns 1 if @expr{n}
is (probably) prime and 0 if not.
@kindex k f
inputs, prime factors above 5000 may not be found, in which case the
last number in the vector will be an unfactored integer greater than 25
million (with a warning message). For negative integers, the first
-element of the list will be @i{-1}. For inputs @i{-1}, @i{0}, and
-@i{1}, the result is a list of the same number.
+element of the list will be @mathit{-1}. For inputs @mathit{-1}, @mathit{0}, and
+@mathit{1}, the result is a list of the same number.
@kindex k n
@pindex calc-next-prime
@pindex calc-totient
@tindex totient
The @kbd{k t} (@code{calc-totient}) [@code{totient}] command computes the
-Euler ``totient'' function@c{ $\phi(n)$}
-@asis{}, the number of integers less than @cite{n} which
-are relatively prime to @cite{n}.
+Euler ``totient''
+@texline function@tie{}@math{\phi(n)},
+@infoline function,
+the number of integers less than @expr{n} which
+are relatively prime to @expr{n}.
@kindex k m
@pindex calc-moebius
@tindex moebius
The @kbd{k m} (@code{calc-moebius}) [@code{moebius}] command computes the
-@c{M\"obius $\mu$}
-@asis{Moebius ``mu''} function. If the input number is a product of @cite{k}
-distinct factors, this is @cite{(-1)^k}. If the input number has any
+@texline M@"obius @math{\mu}
+@infoline Moebius ``mu''
+function. If the input number is a product of @expr{k}
+distinct factors, this is @expr{(-1)^k}. If the input number has any
duplicate factors (i.e., can be divided by the same prime more than once),
the result is zero.
@noindent
The functions in this section compute various probability distributions.
For continuous distributions, this is the integral of the probability
-density function from @cite{x} to infinity. (These are the ``upper
+density function from @expr{x} to infinity. (These are the ``upper
tail'' distribution functions; there are also corresponding ``lower
-tail'' functions which integrate from minus infinity to @cite{x}.)
+tail'' functions which integrate from minus infinity to @expr{x}.)
For discrete distributions, the upper tail function gives the sum
-from @cite{x} to infinity; the lower tail function gives the sum
-from minus infinity up to, but not including,@w{ }@cite{x}.
+from @expr{x} to infinity; the lower tail function gives the sum
+from minus infinity up to, but not including,@w{ }@expr{x}.
-To integrate from @cite{x} to @cite{y}, just use the distribution
+To integrate from @expr{x} to @expr{y}, just use the distribution
function twice and subtract. For example, the probability that a
Gaussian random variable with mean 2 and standard deviation 1 will
lie in the range from 2.5 to 2.8 is @samp{utpn(2.5,2,1) - utpn(2.8,2,1)}
arguments as found on the stack. (The random variable comes last on
the stack, so that you can type, e.g., @kbd{2 @key{RET} 1 @key{RET} 2.5
k N M-@key{RET} @key{DEL} 2.8 k N -}, using @kbd{M-@key{RET} @key{DEL}} to
-recover the original arguments but substitute a new value for @cite{x}.)
+recover the original arguments but substitute a new value for @expr{x}.)
@kindex k C
@pindex calc-utpc
@end ignore
@tindex ltpc
The @samp{utpc(x,v)} function uses the chi-square distribution with
-@c{$\nu$}
-@cite{v} degrees of freedom. It is the probability that a model is
-correct if its chi-square statistic is @cite{x}.
+@texline @math{\nu}
+@infoline @expr{v}
+degrees of freedom. It is the probability that a model is
+correct if its chi-square statistic is @expr{x}.
@kindex k F
@pindex calc-utpf
@end ignore
@tindex ltpf
The @samp{utpf(F,v1,v2)} function uses the F distribution, used in
-various statistical tests. The parameters @c{$\nu_1$}
-@cite{v1} and @c{$\nu_2$}
-@cite{v2}
+various statistical tests. The parameters
+@texline @math{\nu_1}
+@infoline @expr{v1}
+and
+@texline @math{\nu_2}
+@infoline @expr{v2}
are the degrees of freedom in the numerator and denominator,
-respectively, used in computing the statistic @cite{F}.
+respectively, used in computing the statistic @expr{F}.
@kindex k N
@pindex calc-utpn
@end ignore
@tindex ltpn
The @samp{utpn(x,m,s)} function uses a normal (Gaussian) distribution
-with mean @cite{m} and standard deviation @c{$\sigma$}
-@cite{s}. It is the
-probability that such a normal-distributed random variable would
-exceed @cite{x}.
+with mean @expr{m} and standard deviation
+@texline @math{\sigma}.
+@infoline @expr{s}.
+It is the probability that such a normal-distributed random variable
+would exceed @expr{x}.
@kindex k P
@pindex calc-utpp
@end ignore
@tindex ltpp
The @samp{utpp(n,x)} function uses a Poisson distribution with
-mean @cite{x}. It is the probability that @cite{n} or more such
+mean @expr{x}. It is the probability that @expr{n} or more such
Poisson random events will occur.
@kindex k T
@end ignore
@tindex ltpt
The @samp{utpt(t,v)} function uses the Student's ``t'' distribution
-with @c{$\nu$}
-@cite{v} degrees of freedom. It is the probability that a
-t-distributed random variable will be greater than @cite{t}.
-(Note: This computes the distribution function @c{$A(t|\nu)$}
-@cite{A(t|v)}
-where @c{$A(0|\nu) = 1$}
-@cite{A(0|v) = 1} and @c{$A(\infty|\nu) \to 0$}
-@cite{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)}.)
+with
+@texline @math{\nu}
+@infoline @expr{v}
+degrees of freedom. It is the probability that a
+t-distributed random variable will be greater than @expr{t}.
+(Note: This computes the distribution function
+@texline @math{A(t|\nu)}
+@infoline @expr{A(t|v)}
+where
+@texline @math{A(0|\nu) = 1}
+@infoline @expr{A(0|v) = 1}
+and
+@texline @math{A(\infty|\nu) \to 0}.
+@infoline @expr{A(inf|v) -> 0}.
+The @code{UTPT} operation on the HP-48 uses a different definition which
+returns half of Calc's value: @samp{UTPT(t,v) = .5*utpt(t,v)}.)
While Calc does not provide inverses of the probability distribution
functions, the @kbd{a R} command can be used to solve for the inverse.
@item -1
Two values are collected to build a complex number. For example,
@kbd{5 @key{RET} 7 C-u -1 v p} creates the complex number
-@cite{(5, 7)}. The result is always a rectangular complex
+@expr{(5, 7)}. The result is always a rectangular complex
number. The two input values must both be real numbers,
i.e., integers, fractions, or floats. If they are not, Calc
will instead build a formula like @samp{a + (0, 1) b}. (The
times ten to the power of the exponent.
@item -12
-This is treated the same as @i{-11} by the @kbd{v p} command.
-When unpacking, @i{-12} specifies that a floating-point mantissa
+This is treated the same as @mathit{-11} by the @kbd{v p} command.
+When unpacking, @mathit{-12} specifies that a floating-point mantissa
is desired.
@item -13
If any elements of the vector are negative, other kinds of
packing are done at that level as described above. For
example, @samp{[2, 3, -4]} takes 12 objects and creates a
-@c{$2\times3$}
-@asis{2x3} matrix of error forms: @samp{[[a +/- b, c +/- d ... ]]}.
+@texline @math{2\times3}
+@infoline 2x3
+matrix of error forms: @samp{[[a +/- b, c +/- d ... ]]}.
Also, @samp{[-4, -10]} will convert four integers into an
error form consisting of two fractions: @samp{a:b +/- c:d}.
is a vector of objects to be packed (re-packed, really) according
to that mode. For example, @samp{pack([3, -4], [a,b,c,d,e,f])}
yields @samp{[a +/- b, @w{c +/- d}, e +/- f]}. The function is
-left in symbolic form if the packing mode is illegal, or if the
+left in symbolic form if the packing mode is invalid, or if the
number of data items does not match the number of items required
by the mode.
@samp{[a, c^2, d]} and @w{@samp{[b, 0, 7]}}.
Note that the prefix argument can have an effect even when the input is
-not a vector. For example, if the input is the number @i{-5}, then
-@kbd{c-u -1 v u} yields @i{-5} and 0 (the components of @i{-5}
+not a vector. For example, if the input is the number @mathit{-5}, then
+@kbd{c-u -1 v u} yields @mathit{-5} and 0 (the components of @mathit{-5}
when viewed as a rectangular complex number); @kbd{C-u -2 v u} yields 5
-and 180 (assuming degrees mode); and @kbd{C-u -10 v u} yields @i{-5}
-and 1 (the numerator and denominator of @i{-5}, viewed as a rational
+and 180 (assuming Degrees mode); and @kbd{C-u -10 v u} yields @mathit{-5}
+and 1 (the numerator and denominator of @mathit{-5}, viewed as a rational
number). Plain @kbd{v u} with this input would complain that the input
is not a composite object.
-Unpacking mode @i{-11} converts a float into an integer mantissa and
+Unpacking mode @mathit{-11} converts a float into an integer mantissa and
an integer exponent, where the mantissa is not divisible by 10
(except that 0.0 is represented by a mantissa and exponent of 0).
-Unpacking mode @i{-12} converts a float into a floating-point mantissa
+Unpacking mode @mathit{-12} converts a float into a floating-point mantissa
and integer exponent, where the mantissa (for non-zero numbers)
is guaranteed to lie in the range [1 .. 10). In both cases,
the mantissa is shifted left or right (and the exponent adjusted
@noindent
Vectors and matrices can be added,
-subtracted, multiplied, and divided; @pxref{Basic Arithmetic}.@refill
+subtracted, multiplied, and divided; @pxref{Basic Arithmetic}.
@kindex |
@pindex calc-concat
@mindex @null
@end ignore
@tindex |
-The @kbd{|} (@code{calc-concat}) command ``concatenates'' two vectors
+The @kbd{|} (@code{calc-concat}) [@code{vconcat}] command ``concatenates'' two vectors
into one. For example, after @kbd{@w{[ 1 , 2 ]} [ 3 , 4 ] |}, the stack
will contain the single vector @samp{[1, 2, 3, 4]}. If the arguments
are matrices, the rows of the first matrix are concatenated with the
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 @c{$3\times3$}
-@asis{3x3} matrix filled with ones,
-use @kbd{0 M-3 v d 1 +}, i.e., build a zero matrix first and then add a
-constant value to that matrix. (Another alternative would be to use
-@kbd{v b} and @kbd{v a}; see below.)
+To build a constant square matrix, e.g., a
+@texline @math{3\times3}
+@infoline 3x3
+matrix filled with ones, use @kbd{0 M-3 v d 1 +}, i.e., build a zero
+matrix first and then add a constant value to that matrix. (Another
+alternative would be to use @kbd{v b} and @kbd{v a}; see below.)
@kindex v i
@pindex calc-ident
this command prompts for one.
In algebraic notation, @samp{idn(a,n)} acts much like @samp{diag(a,n)},
-except that @cite{a} is required to be a scalar (non-vector) quantity.
-If @cite{n} is omitted, @samp{idn(a)} represents @cite{a} times an
+except that @expr{a} is required to be a scalar (non-vector) quantity.
+If @expr{n} is omitted, @samp{idn(a)} represents @expr{a} times an
identity matrix of unknown size. Calc can operate algebraically on
such generic identity matrices, and if one is combined with a matrix
whose size is known, it is converted automatically to an identity
matrix of a suitable matching size. The @kbd{v i} command with an
argument of zero creates a generic identity matrix, @samp{idn(1)}.
-Note that in dimensioned matrix mode (@pxref{Matrix Mode}), generic
+Note that in dimensioned Matrix mode (@pxref{Matrix Mode}), generic
identity matrices are immediately expanded to the current default
dimensions.
of consecutive integers from 1 to @var{n}, where @var{n} is the numeric
prefix argument. If you do not provide a prefix argument, you will be
prompted to enter a suitable number. If @var{n} is negative, the result
-is a vector of negative integers from @var{n} to @i{-1}.
+is a vector of negative integers from @var{n} to @mathit{-1}.
With a prefix argument of just @kbd{C-u}, the @kbd{v x} command takes
three values from the stack: @var{n}, @var{start}, and @var{incr} (with
@tindex _
Subscript notation in algebraic formulas (@samp{a_b}) stands for the
Calc function @code{subscr}, which is synonymous with @code{mrow}.
-Thus, @samp{[x, y, z]_k} produces @cite{x}, @cite{y}, or @cite{z} if
-@cite{k} is one, two, or three, respectively. A double subscript
+Thus, @samp{[x, y, z]_k} produces @expr{x}, @expr{y}, or @expr{z} if
+@expr{k} is one, two, or three, respectively. A double subscript
(@samp{M_i_j}, equivalent to @samp{subscr(subscr(M, i), j)}) will
-access the element at row @cite{i}, column @cite{j} of a matrix.
+access the element at row @expr{i}, column @expr{j} of a matrix.
The @kbd{a _} (@code{calc-subscript}) command creates a subscript
formula @samp{a_b} out of two stack entries. (It is on the @kbd{a}
``algebra'' prefix because subscripted variables are often used
it extracts (or removes) one element, just like @kbd{v r}. If the
index in @kbd{C-u v c} is an interval or vector and the argument is a
matrix, the result is a submatrix with only the specified columns
-retained (and possibly permuted in the case of a vector index).@refill
+retained (and possibly permuted in the case of a vector index).
To extract a matrix element at a given row and column, use @kbd{v r} to
extract the row as a vector, then @kbd{v c} to extract the column element
from that vector. In algebraic formulas, it is often more convenient to
-use subscript notation: @samp{m_i_j} gives row @cite{i}, column @cite{j}
-of matrix @cite{m}.
+use subscript notation: @samp{m_i_j} gives row @expr{i}, column @expr{j}
+of matrix @expr{m}.
@kindex v s
@pindex calc-subvector
The @kbd{v l} (@code{calc-vlength}) [@code{vlen}] command computes the
length of a vector. The length of a non-vector is considered to be zero.
Note that matrices are just vectors of vectors for the purposes of this
-command.@refill
+command.
@kindex H v l
@tindex mdims
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 @c{$2\times3$}
-@asis{2x3} matrix.
+its argument is a
+@texline @math{2\times3}
+@infoline 2x3
+matrix.
@kindex v f
@pindex calc-vector-find
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 @c{$1\times4$}
-@asis{1x4} matrix), @kbd{v a 1} produces
-@samp{[[1], [2], [3], [4]]} (a @c{$4\times1$}
-@asis{4x1} matrix), @kbd{v a 2} produces
-@samp{[[1, 2], [3, 4]]} (the original @c{$2\times2$}
-@asis{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 @samp{[1, 2, @w{3, 4}]}.
+@samp{[[1, 2, 3, 4]]} (a
+@texline @math{1\times4}
+@infoline 1x4
+matrix), @kbd{v a 1} produces @samp{[[1], [2], [3], [4]]} (a
+@texline @math{4\times1}
+@infoline 4x1
+matrix), @kbd{v a 2} produces @samp{[[1, 2], [3, 4]]} (the original
+@texline @math{2\times2}
+@infoline 2x2
+matrix), @w{@kbd{v a 3}} produces @samp{[[1, 2, 3], [4]]} (not a
+matrix), and @kbd{v a 0} produces the flattened list
+@samp{[1, 2, @w{3, 4}]}.
@cindex Sorting data
@kindex V S
@kindex v v
@pindex calc-reverse-vector
@tindex rev
-The @kbd{v v} (@code{calc-reverse-vector}) [@code{vec}] command reverses
+The @kbd{v v} (@code{calc-reverse-vector}) [@code{rev}] command reverses
a vector end-for-end. Given a matrix, it reverses the order of the rows.
(To reverse the columns instead, just use @kbd{v t v v v t}. The same
principle can be used to apply other vector commands to the columns of
The following functions are applied element-wise if their arguments are
vectors or matrices: @code{change-sign}, @code{conj}, @code{arg},
@code{re}, @code{im}, @code{polar}, @code{rect}, @code{clean},
-@code{float}, @code{frac}. @xref{Function Index}.@refill
+@code{float}, @code{frac}. @xref{Function Index}.
@kindex V J
@pindex calc-conj-transpose
root of the sum of the squares of the absolute values of the
elements of the vector or matrix. If the vector is interpreted as
a point in two- or three-dimensional space, this is the distance
-from that point to the origin.@refill
+from that point to the origin.
@kindex v n
@pindex calc-rnorm
the column norm, or one-norm, of a vector or 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 @cite{k}-norms for @cite{k} other than one or infinity are
+General @expr{k}-norms for @expr{k} other than one or infinity are
not provided.
@kindex V C
computed, the inverse and determinant of the matrix can be recomputed
quickly in the future.
-If the argument to @kbd{&} is a plain number @cite{x}, this
-command simply computes @cite{1/x}. This is okay, because the
+If the argument to @kbd{&} is a plain number @expr{x}, this
+command simply computes @expr{1/x}. This is okay, because the
@samp{/} operator also does a matrix inversion when dividing one
by a matrix.
single interval, the interval itself is returned instead.
@xref{Logical Operations}, for the @code{in} function which tests if
-a certain value is a member of a given set. To test if the set @cite{A}
-is a subset of the set @cite{B}, use @samp{vdiff(A, B) = []}.
+a certain value is a member of a given set. To test if the set @expr{A}
+is a subset of the set @expr{B}, use @samp{vdiff(A, B) = []}.
@kindex V +
@pindex calc-remove-duplicates
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 union@c{ ($A \cup B$)}
-@asis{} and intersection@c{ ($A \cap B$)}
-@asis{}.
+notation for set
+@texline union@tie{}(@math{A \cup B})
+@infoline union
+and
+@texline intersection@tie{}(@math{A \cap B}).
+@infoline intersection.
@kindex V -
@pindex calc-set-difference
@tindex vdiff
The @kbd{V -} (@code{calc-set-difference}) [@code{vdiff}] command computes
the difference between two sets. An object is in the difference
-@cite{A - B} if and only if it is in @cite{A} but not in @cite{B}.
+@expr{A - B} if and only if it is in @expr{A} but not in @expr{B}.
Thus subtracting @samp{[y,z]} from a set will remove the elements
@samp{y} and @samp{z} if they are present. You can also think of this
-as a general @dfn{set complement} operator; if @cite{A} is the set of
-all possible values, then @cite{A - B} is the ``complement'' of @cite{B}.
+as a general @dfn{set complement} operator; if @expr{A} is the set of
+all possible values, then @expr{A - B} is the ``complement'' of @expr{B}.
Obviously this is only practical if the set of all possible values in
your problem is small enough to list in a Calc vector (or simple
enough to express in a few intervals).
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 (@c{$2^{100}$}
-@cite{2^100}, a 31-digit integer, in this case).
+representation
+@texline (@math{2^{100}}, a 31-digit integer, in this case).
+@infoline (@expr{2^100}, a 31-digit integer, in this case).
@node Statistical Operations, Reducing and Mapping, Set Operations, Matrix Functions
@section Statistical Operations on Vectors
(@code{calc-vector-prod}) [@code{vprod}] command computes the
product of the data values. If the input is a single flat vector,
these are the same as @kbd{V R +} and @kbd{V R *}
-(@pxref{Reducing and Mapping}).@refill
+(@pxref{Reducing and Mapping}).
@kindex u X
@kindex u N
@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 @c{$x$ @code{+/-} $\sigma$}
-@samp{x +/- s}, this is the weighted
-mean of the @cite{x} values with weights @c{$1 / \sigma^2$}
-@cite{1 / s^2}.
+If the inputs are error forms
+@texline @math{x \pm \sigma},
+@infoline @samp{x +/- s},
+this is the weighted mean of the @expr{x} values with weights
+@texline @math{1 /\sigma^2}.
+@infoline @expr{1 / s^2}.
@tex
\turnoffactive
$$ \mu = { \displaystyle \sum { x_i \over \sigma_i^2 } \over
\displaystyle \sum { 1 \over \sigma_i^2 } } $$
@end tex
If the inputs are not error forms, this is simply the sum of the
-values divided by the count of the values.@refill
+values divided by the count of the values.
Note that a plain number can be considered an error form with
-error @c{$\sigma = 0$}
-@cite{s = 0}. If the input to @kbd{u M} is a mixture of
+error
+@texline @math{\sigma = 0}.
+@infoline @expr{s = 0}.
+If the input to @kbd{u M} is a mixture of
plain numbers and error forms, the result is the mean of the
plain numbers, ignoring all values with non-zero errors. (By the
above definitions it's clear that a plain number effectively
weight is completely negligible.)
This function also works for distributions (error forms or
-intervals). The mean of an error form `@var{a} @t{+/-} @var{b}' is simply
-@cite{a}. The mean of an interval is the mean of the minimum
+intervals). The mean of an error form `@var{a} @tfn{+/-} @var{b}' is simply
+@expr{a}. The mean of an interval is the mean of the minimum
and maximum values of the interval.
@kindex I u M
divided by the square root of the number of values. (This works
out to be equivalent to calculating the standard deviation and
then assuming each value's error is equal to this standard
-deviation.)@refill
+deviation.)
@tex
\turnoffactive
$$ \sigma_\mu^2 = {\sigma^2 \over N} $$
@cindex Standard deviation
@cindex Sample statistics
The @kbd{u S} (@code{calc-vector-sdev}) [@code{vsdev}] command
-computes the standard deviation@c{ $\sigma$}
-@asis{} of the data values. If the
-values are error forms, the errors are used as weights just
-as for @kbd{u M}. This is the @emph{sample} standard deviation,
-whose value is the square root of the sum of the squares of the
-differences between the values and the mean of the @cite{N} values,
-divided by @cite{N-1}.
+computes the standard
+@texline deviation@tie{}@math{\sigma}
+@infoline deviation
+of the data values. If the values are error forms, the errors are used
+as weights just as for @kbd{u M}. This is the @emph{sample} standard
+deviation, whose value is the square root of the sum of the squares of
+the differences between the values and the mean of the @expr{N} values,
+divided by @expr{N-1}.
@tex
\turnoffactive
$$ \sigma^2 = {1 \over N - 1} \sum (x_i - \mu)^2 $$
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 @c{$\sqrt{12}$}
-@cite{sqrt(12)}. The standard deviation of an
-integer interval is the same as the standard deviation of a vector
-of those integers.
+limits, divided by
+@texline @math{\sqrt{12}}.
+@infoline @expr{sqrt(12)}.
+The standard deviation of an integer interval is the same as the
+standard deviation of a vector of those integers.
@kindex I u S
@pindex calc-vector-pop-sdev
The @kbd{I u S} (@code{calc-vector-pop-sdev}) [@code{vpsdev}]
command computes the @emph{population} standard deviation.
It is defined by the same formula as above but dividing
-by @cite{N} instead of by @cite{N-1}. The population standard
+by @expr{N} instead of by @expr{N-1}. The population standard
deviation is used when the input represents the entire set of
data values in the distribution; the sample standard deviation
is used when the input represents a sample of the set of all
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 square@c{ $\sigma^2$}
-@asis{} of the standard deviation, i.e., the sum of the
+is the
+@texline square@tie{}@math{\sigma^2}
+@infoline square
+of the standard deviation, i.e., the sum of the
squares of the deviations of the data values from the mean.
(This definition also applies when the argument is a distribution.)
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 @c{$N\times2$}
-@asis{Nx2} matrix of data values. Once
-again, variable names can be used in place of actual vectors and
-matrices.
+the stack, which must be an
+@texline @math{N\times2}
+@infoline Nx2
+matrix of data values. Once again, variable names can be used in place
+of actual vectors and matrices.
@kindex u C
@pindex calc-vector-covariance
of vectors @var{x} and @var{y} is the sum of the products of the
differences between the elements of @var{x} and the mean of @var{x}
times the differences between the corresponding elements of @var{y}
-and the mean of @var{y}, all divided by @cite{N-1}. Note that
+and the mean of @var{y}, all divided by @expr{N-1}. Note that
the variance of a vector is just the covariance of the vector
with itself. Once again, if the inputs are error forms the
errors are used as weight factors. If both @var{x} and @var{y}
@tindex vpcov
The @kbd{I u C} (@code{calc-vector-pop-covariance}) [@code{vpcov}]
command computes the population covariance, which is the same as the
-sample covariance computed by @kbd{u C} except dividing by @cite{N}
-instead of @cite{N-1}.
+sample covariance computed by @kbd{u C} except dividing by @expr{N}
+instead of @expr{N-1}.
@kindex H u C
@pindex calc-vector-correlation
or a nameless function like @samp{<#^3+1>}. Operators that are normally
written as algebraic symbols have the names @code{add}, @code{sub},
@code{mul}, @code{div}, @code{pow}, @code{neg}, @code{mod}, and
-@code{vconcat}.@refill
+@code{vconcat}.
@ignore
@starindex
With the 2 listed first, it would have computed a vector of powers of
two. Mapping a user-defined function pops as many arguments from the
stack as the function requires. If you give an undefined name, you will
-be prompted for the number of arguments to use.@refill
+be prompted for the number of arguments to use.
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
-@cite{[[1, -2, 3], [-4, 5, -6]]}, @kbd{V M A} takes six absolute values to
-produce another @c{$3\times2$}
-@asis{3x2} matrix, @cite{[[1, 2, 3], [4, 5, 6]]}.
+@expr{[[1, -2, 3], [-4, 5, -6]]}, @kbd{V M A} takes six absolute values to
+produce another
+@texline @math{3\times2}
+@infoline 3x2
+matrix, @expr{[[1, 2, 3], [4, 5, 6]]}.
@tindex mapr
The command @kbd{V M _} [@code{mapr}] (i.e., type an underscore at the
operator prompt) maps by rows instead. For example, @kbd{V M _ A} views
the above matrix as a vector of two 3-element row vectors. It produces
a new vector which contains the absolute values of those row vectors,
-namely @cite{[3.74, 8.77]}. (Recall, the absolute value of a vector is
+namely @expr{[3.74, 8.77]}. (Recall, the absolute value of a vector is
defined as the square root of the sum of the squares of the elements.)
Some operators accept vectors and return new vectors; for example,
@kbd{v v} reverses a vector, so @kbd{V M _ v v} would reverse each row
-of the matrix to get a new matrix, @cite{[[3, -2, 1], [-6, 5, -4]]}.
+of the matrix to get a new matrix, @expr{[[3, -2, 1], [-6, 5, -4]]}.
Sometimes a vector of vectors (representing, say, strings, sets, or lists)
happens to look like a matrix. If so, remember to use @kbd{V M _} if you
matrix, transposes again. For example, @kbd{V M : A} takes the absolute
values of the three columns of the matrix, treating each as a 2-vector,
and @kbd{V M : v v} reverses the columns to get the matrix
-@cite{[[-4, 5, -6], [1, -2, 3]]}.
+@expr{[[-4, 5, -6], [1, -2, 3]]}.
(The symbols @kbd{_} and @kbd{:} were chosen because they had row-like
and column-like appearances, and were not already taken by useful
@tindex reduced
@tindex rreduced
As for @kbd{V M}, @kbd{V R} normally reduces a matrix elementwise. For
-example, given the matrix @cite{[[a, b, c], [d, e, f]]}, @kbd{V R +} will
-compute @cite{a + b + c + d + e + f}. You can type @kbd{V R _} or
+example, given the matrix @expr{[[a, b, c], [d, e, f]]}, @kbd{V R +} will
+compute @expr{a + b + c + d + e + f}. You can type @kbd{V R _} or
@kbd{V R :} to modify this behavior. The @kbd{V R _} [@code{reducea}]
command reduces ``across'' the matrix; it reduces each row of the matrix
as a vector, then collects the results. Thus @kbd{V R _ +} of this
-matrix would produce @cite{[a + b + c, d + e + f]}. Similarly, @kbd{V R :}
-[@code{reduced}] reduces down; @kbd{V R : +} would produce @cite{[a + d,
+matrix would produce @expr{[a + b + c, d + e + f]}. Similarly, @kbd{V R :}
+[@code{reduced}] reduces down; @kbd{V R : +} would produce @expr{[a + d,
b + e, c + f]}.
@tindex reducer
The obsolete reduce-by-columns function, @code{reducec}, is still
supported but there is no way to get it through the @kbd{V R} command.
-The commands @kbd{M-# :} and @kbd{M-# _} are equivalent to typing
-@kbd{M-# r} to grab a rectangle of data into Calc, and then typing
+The commands @kbd{C-x * :} and @kbd{C-x * _} are equivalent to typing
+@kbd{C-x * r} to grab a rectangle of data into Calc, and then typing
@kbd{V R : +} or @kbd{V R _ +}, respectively, to sum the columns or
rows of the matrix. @xref{Grabbing From Buffers}.
The commands @kbd{v <} (@code{calc-matrix-left-justify}), @kbd{v >}
(@code{calc-matrix-right-justify}), and @w{@kbd{v =}}
(@code{calc-matrix-center-justify}) control whether matrix elements
-are justified to the left, right, or center of their columns.@refill
+are justified to the left, right, or center of their columns.
@kindex V [
@pindex calc-vector-brackets
Mathematica. (In fact, the Mathematica language mode uses this mode;
@pxref{Mathematica Language Mode}.) Note that, regardless of the
display mode, either brackets or braces may be used to enter vectors,
-and parentheses may never be used for this purpose.@refill
+and parentheses may never be used for this purpose.
@kindex V ]
@pindex calc-matrix-brackets
@kindex V ,
@pindex calc-vector-commas
The @kbd{v ,} (@code{calc-vector-commas}) command turns commas on and
-off in vector and matrix display.@refill
+off in vector and matrix display.
In vectors of length one, and in all vectors when commas have been
turned off, Calc adds extra parentheses around formulas that might
for anything else'') prefix.
@xref{Editing Stack Entries}, to see how to manipulate formulas
-using regular Emacs editing commands.@refill
+using regular Emacs editing commands.
When doing algebraic work, you may find several of the Calculator's
-modes to be helpful, including algebraic-simplification mode (@kbd{m A})
-or no-simplification mode (@kbd{m O}),
-algebraic-entry mode (@kbd{m a}), fraction mode (@kbd{m f}), and
-symbolic mode (@kbd{m s}). @xref{Mode Settings}, for discussions
-of these modes. You may also wish to select ``big'' display mode (@kbd{d B}).
-@xref{Normal Language Modes}.@refill
+modes to be helpful, including Algebraic Simplification mode (@kbd{m A})
+or No-Simplification mode (@kbd{m O}),
+Algebraic entry mode (@kbd{m a}), Fraction mode (@kbd{m f}), and
+Symbolic mode (@kbd{m s}). @xref{Mode Settings}, for discussions
+of these modes. You may also wish to select Big display mode (@kbd{d B}).
+@xref{Normal Language Modes}.
@menu
* Selecting Subformulas::
highlight the smallest portion of the formula that contains that
character. By default the sub-formula is highlighted by blanking out
all of the rest of the formula with dots. Selection works in any
-display mode but is perhaps easiest in ``big'' (@kbd{d B}) mode.
+display mode but is perhaps easiest in Big mode (@kbd{d B}).
Suppose you enter the following formula:
@smallexample
Every character not part of the sub-formula @samp{b} has been changed
to a dot. The @samp{*} next to the line number is to remind you that
the formula has a portion of it selected. (In this case, it's very
-obvious, but it might not always be. If Embedded Mode is enabled,
+obvious, but it might not always be. If Embedded mode is enabled,
the word @samp{Sel} also appears in the mode line because the stack
may not be visible. @pxref{Embedded Mode}.)
behavior of some commands such as @kbd{j r} (@code{calc-rewrite-selection};
@pxref{Selections with Rewrite Rules}) and is mainly intended to be
used in keyboard macros that implement your own selection-oriented
-commands.@refill
+commands.
Selection of sub-formulas normally treats associative terms like
@samp{a + b - c + d} and @samp{x * y * z} as single levels of the formula.
the @var{n}th top-level sub-formula. (In other words, they act as if
the entire stack entry were selected first.) To select the @var{n}th
sub-formula where @var{n} is greater than nine, you must instead invoke
-@w{@kbd{j 1}} with @var{n} as a numeric prefix argument.@refill
+@w{@kbd{j 1}} with @var{n} as a numeric prefix argument.
@kindex j n
@kindex j p
Operations on sub-formulas sometimes leave the formula as a whole
in an ``un-natural'' state. Consider negating the @samp{2 x} term
of our sample formula by selecting it and pressing @kbd{n}
-(@code{calc-change-sign}).@refill
+(@code{calc-change-sign}).
@smallexample
@group
@xref{Selections with Rewrite Rules}. The rules are stored in
the Calc variable @code{DistribRules}. A convenient way to view
these rules is to use @kbd{s e} (@code{calc-edit-variable}) which
-displays and edits the stored value of a variable. Press @kbd{M-# M-#}
+displays and edits the stored value of a variable. Press @kbd{C-c C-c}
to return from editing mode; be careful not to make any actual changes
or else you will affect the behavior of future @kbd{j D} commands!
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
+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}).
+of 3 or more, it uses Extended Simplification mode (@kbd{a e}).
-If you give a negative prefix argument @i{-1}, @i{-2}, or @i{-3},
+If you give a negative prefix argument @mathit{-1}, @mathit{-2}, or @mathit{-3},
it simplifies in the corresponding mode but only works on the top-level
function call of the formula. For example, @samp{(2 + 3) * (2 + 3)} will
simplify to @samp{(2 + 3)^2}, without simplifying the sub-formulas
@samp{2 + 3}. As another example, typing @kbd{V R +} to sum the vector
@samp{[1, 2, 3, 4]} produces the formula @samp{reduce(add, [1, 2, 3, 4])}
-in no-simplify mode. Using @kbd{a v} will evaluate this all the way to
+in No-Simplify mode. Using @kbd{a v} will evaluate this all the way to
10; using @kbd{C-u - a v} will evaluate it only to @samp{1 + 2 + 3 + 4}.
(@xref{Reducing and Mapping}.)
@tindex evalvn
The @kbd{=} command corresponds to the @code{evalv} function, and
the related @kbd{N} command, which is like @kbd{=} but temporarily
-disables symbolic (@kbd{m s}) mode during the evaluation, corresponds
+disables Symbolic mode (@kbd{m s}) during the evaluation, corresponds
to the @code{evalvn} function. (These commands interpret their prefix
arguments differently than @kbd{a v}; @kbd{=} treats the prefix as
the number of stack elements to evaluate at once, and @kbd{N} treats
to @kbd{V M}, which operates on vectors instead of equations.
@pxref{Reducing and Mapping}. For example, @kbd{a M S} changes
@samp{x = y+1} to @samp{sin(x) = sin(y+1)}, and @kbd{a M +} with
-@samp{x = y+1} and @cite{6} on the stack produces @samp{x+6 = y+7}.
+@samp{x = y+1} and @expr{6} on the stack produces @samp{x+6 = y+7}.
With two equations on the stack, @kbd{a M +} would add the lefthand
sides together and the righthand sides together to get the two
respective sides of a new equation.
Note that this is a purely structural substitution; the lone @samp{x} and
the @samp{sin(2 x)} stayed the same because they did not look like
@samp{sin(x)}. @xref{Rewrite Rules}, for a more general method for
-doing substitutions.@refill
+doing substitutions.
The @kbd{a b} command normally prompts for two formulas, the old
one and the new one. If you enter a blank line for the first
@cindex Default simplifications
This section describes the ``default simplifications,'' those which are
normally applied to all results. For example, if you enter the variable
-@cite{x} on the stack twice and push @kbd{+}, Calc's default
-simplifications automatically change @cite{x + x} to @cite{2 x}.
+@expr{x} on the stack twice and push @kbd{+}, Calc's default
+simplifications automatically change @expr{x + x} to @expr{2 x}.
The @kbd{m O} command turns off the default simplifications, so that
-@cite{x + x} will remain in this form unless you give an explicit
+@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.
-For example, @cite{2 + 3} is evaluated to @cite{5}, and @cite{@t{sqrt}(9)}
-is evaluated to @cite{3}. Evaluation does not occur if the arguments
-to a function are somehow of the wrong type (@cite{@t{tan}([2,3,4])},
-range (@cite{@t{tan}(90)}), or number (@cite{@t{tan}(3,5)}), or if the
-function name is not recognized (@cite{@t{f}(5)}), or if ``symbolic''
-mode (@pxref{Symbolic Mode}) prevents evaluation (@cite{@t{sqrt}(2)}).
+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)}),
+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)}).
Calc simplifies (evaluates) the arguments to a function before it
-simplifies the function itself. Thus @cite{@t{sqrt}(5+4)} is
-simplified to @cite{@t{sqrt}(9)} before the @code{sqrt} function
+simplifies the function itself. Thus @expr{@tfn{sqrt}(5+4)} is
+simplified to @expr{@tfn{sqrt}(9)} before the @code{sqrt} function
itself is applied. There are very few exceptions to this rule:
@code{quote}, @code{lambda}, and @code{condition} (the @code{::}
operator) do not evaluate their arguments, @code{if} (the @code{? :}
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, @cite{((a + b) + c) + d}, and
-a right-associative form for products, @cite{a * (b * (c * d))}.
-Formulas like @cite{(a + b) + (c + d)} are rearranged to
+a left-associative form for sums, @expr{((a + b) + c) + d}, and
+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 and products as much as possible. Sums and products in
in the examples below.
Sums and products are @emph{not} rearranged according to the
-commutative law (@cite{a + b} to @cite{b + a}) except in a few
+commutative law (@expr{a + b} to @expr{b + a}) except in a few
special cases described below. Some algebra programs always
rearrange terms into a canonical order, which enables them to
-see that @cite{a b + b a} can be simplified to @cite{2 a b}.
+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}.
-Differences @cite{a - b} are treated like sums @cite{a + (-b)}
+Differences @expr{a - b} are treated like sums @expr{a + (-b)}
for purposes of simplification; one of the default simplifications
-is to rewrite @cite{a + (-b)} or @cite{(-b) + a}, where @cite{-b}
-represents a ``negative-looking'' term, into @cite{a - b} form.
+is to rewrite @expr{a + (-b)} or @expr{(-b) + a}, where @expr{-b}
+represents a ``negative-looking'' term, into @expr{a - b} form.
``Negative-looking'' means negative numbers, negated formulas like
-@cite{-x}, and products or quotients in which either term is
+@expr{-x}, and products or quotients in which either term is
negative-looking.
-Other simplifications involving negation are @cite{-(-x)} to @cite{x};
-@cite{-(a b)} or @cite{-(a/b)} where either @cite{a} or @cite{b} is
+Other simplifications involving negation are @expr{-(-x)} to @expr{x};
+@expr{-(a b)} or @expr{-(a/b)} where either @expr{a} or @expr{b} is
negative-looking, simplified by negating that term, or else where
-@cite{a} or @cite{b} is any number, by negating that number;
-@cite{-(a + b)} to @cite{-a - b}, and @cite{-(b - a)} to @cite{a - b}.
-(This, and rewriting @cite{(-b) + a} to @cite{a - b}, are the only
+@expr{a} or @expr{b} is any number, by negating that number;
+@expr{-(a + b)} to @expr{-a - b}, and @expr{-(b - a)} to @expr{a - b}.
+(This, and rewriting @expr{(-b) + a} to @expr{a - b}, are the only
cases where the order of terms in a sum is changed by the default
simplifications.)
The distributive law is used to simplify sums in some cases:
-@cite{a x + b x} to @cite{(a + b) x}, where @cite{a} represents
-a number or an implicit 1 or @i{-1} (as in @cite{x} or @cite{-x})
-and similarly for @cite{b}. Use the @kbd{a c}, @w{@kbd{a f}}, or
+@expr{a x + b x} to @expr{(a + b) x}, where @expr{a} represents
+a number or an implicit 1 or @mathit{-1} (as in @expr{x} or @expr{-x})
+and similarly for @expr{b}. Use the @kbd{a c}, @w{@kbd{a f}}, or
@kbd{j M} commands to merge sums with non-numeric coefficients
using the distributive law.
The distributive law is only used for sums of two terms, or
-for adjacent terms in a larger sum. Thus @cite{a + b + b + c}
-is simplified to @cite{a + 2 b + c}, but @cite{a + b + c + b}
+for adjacent terms in a larger sum. Thus @expr{a + b + b + c}
+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}.
-Finally, @cite{a + 0} and @cite{0 + a} are simplified to @cite{a}.
-A consequence of the above rules is that @cite{0 - a} is simplified
-to @cite{-a}.
+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
+to @expr{-a}.
@tex
\bigskip
@end tex
-The products @cite{1 a} and @cite{a 1} are simplified to @cite{a};
-@cite{(-1) a} and @cite{a (-1)} are simplified to @cite{-a};
-@cite{0 a} and @cite{a 0} are simplified to @cite{0}, except that
-in matrix mode where @cite{a} is not provably scalar the result
-is the generic zero matrix @samp{idn(0)}, and that if @cite{a} is
+The products @expr{1 a} and @expr{a 1} are simplified to @expr{a};
+@expr{(-1) a} and @expr{a (-1)} are simplified to @expr{-a};
+@expr{0 a} and @expr{a 0} are simplified to @expr{0}, except that
+in Matrix mode where @expr{a} is not provably scalar the result
+is the generic zero matrix @samp{idn(0)}, and that if @expr{a} is
infinite the result is @samp{nan}.
-Also, @cite{(-a) b} and @cite{a (-b)} are simplified to @cite{-(a b)},
+Also, @expr{(-a) b} and @expr{a (-b)} are simplified to @expr{-(a b)},
where this occurs for negated formulas but not for regular negative
numbers.
Products are commuted only to move numbers to the front:
-@cite{a b 2} is commuted to @cite{2 a b}.
+@expr{a b 2} is commuted to @expr{2 a b}.
-The product @cite{a (b + c)} is distributed over the sum only if
-@cite{a} and at least one of @cite{b} and @cite{c} are numbers:
-@cite{2 (x + 3)} goes to @cite{2 x + 6}. The formula
-@cite{(-a) (b - c)}, where @cite{-a} is a negative number, is
-rewritten to @cite{a (c - b)}.
+The product @expr{a (b + c)} is distributed over the sum only if
+@expr{a} and at least one of @expr{b} and @expr{c} are numbers:
+@expr{2 (x + 3)} goes to @expr{2 x + 6}. The formula
+@expr{(-a) (b - c)}, where @expr{-a} is a negative number, is
+rewritten to @expr{a (c - b)}.
The distributive law of products and powers is used for adjacent
-terms of the product: @cite{x^a x^b} goes to @c{$x^{a+b}$}
-@cite{x^(a+b)}
-where @cite{a} is a number, or an implicit 1 (as in @cite{x}),
-or the implicit one-half of @cite{@t{sqrt}(x)}, and similarly for
-@cite{b}. The result is written using @samp{sqrt} or @samp{1/sqrt}
-if the sum of the powers is @cite{1/2} or @cite{-1/2}, respectively.
+terms of the product: @expr{x^a x^b} goes to
+@texline @math{x^{a+b}}
+@infoline @expr{x^(a+b)}
+where @expr{a} is a number, or an implicit 1 (as in @expr{x}),
+or the implicit one-half of @expr{@tfn{sqrt}(x)}, and similarly for
+@expr{b}. The result is written using @samp{sqrt} or @samp{1/sqrt}
+if the sum of the powers is @expr{1/2} or @expr{-1/2}, respectively.
If the sum of the powers is zero, the product is simplified to
-@cite{1} or to @samp{idn(1)} if matrix mode is enabled.
+@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: @c{$x^{-2} y$}
-@cite{x^(-2) y} goes to @cite{y / x^2} unless matrix mode is
-in effect and neither @cite{x} nor @cite{y} are scalar (in which
+power is changed to use division:
+@texline @math{x^{-2} y}
+@infoline @expr{x^(-2) y}
+goes to @expr{y / x^2} unless Matrix mode is
+in effect and neither @expr{x} nor @expr{y} are scalar (in which
case it is considered unsafe to rearrange the order of the terms).
-Finally, @cite{a (b/c)} is rewritten to @cite{(a b)/c}, and also
-@cite{(a/b) c} is changed to @cite{(a c)/b} unless in matrix mode.
+Finally, @expr{a (b/c)} is rewritten to @expr{(a b)/c}, and also
+@expr{(a/b) c} is changed to @expr{(a c)/b} unless in Matrix mode.
@tex
\bigskip
@end tex
Simplifications for quotients are analogous to those for products.
-The quotient @cite{0 / x} is simplified to @cite{0}, with the same
-exceptions that were noted for @cite{0 x}. Likewise, @cite{x / 1}
-and @cite{x / (-1)} are simplified to @cite{x} and @cite{-x},
+The quotient @expr{0 / x} is simplified to @expr{0}, with the same
+exceptions that were noted for @expr{0 x}. Likewise, @expr{x / 1}
+and @expr{x / (-1)} are simplified to @expr{x} and @expr{-x},
respectively.
-The quotient @cite{x / 0} is left unsimplified or changed to an
+The quotient @expr{x / 0} is left unsimplified or changed to an
infinite quantity, as directed by the current infinite mode.
@xref{Infinite Mode}.
-The expression @c{$a / b^{-c}$}
-@cite{a / b^(-c)} is changed to @cite{a b^c},
-where @cite{-c} is any negative-looking power. Also, @cite{1 / b^c}
-is changed to @c{$b^{-c}$}
-@cite{b^(-c)} for any power @cite{c}.
-
-Also, @cite{(-a) / b} and @cite{a / (-b)} go to @cite{-(a/b)};
-@cite{(a/b) / c} goes to @cite{a / (b c)}; and @cite{a / (b/c)}
-goes to @cite{(a c) / b} unless matrix mode prevents this
-rearrangement. Similarly, @cite{a / (b:c)} is simplified to
-@cite{(c:b) a} for any fraction @cite{b:c}.
-
-The distributive law is applied to @cite{(a + b) / c} only if
-@cite{c} and at least one of @cite{a} and @cite{b} are numbers.
+The expression
+@texline @math{a / b^{-c}}
+@infoline @expr{a / b^(-c)}
+is changed to @expr{a b^c}, where @expr{-c} is any negative-looking
+power. Also, @expr{1 / b^c} is changed to
+@texline @math{b^{-c}}
+@infoline @expr{b^(-c)}
+for any power @expr{c}.
+
+Also, @expr{(-a) / b} and @expr{a / (-b)} go to @expr{-(a/b)};
+@expr{(a/b) / c} goes to @expr{a / (b c)}; and @expr{a / (b/c)}
+goes to @expr{(a c) / b} unless Matrix mode prevents this
+rearrangement. Similarly, @expr{a / (b:c)} is simplified to
+@expr{(c:b) a} for any fraction @expr{b:c}.
+
+The distributive law is applied to @expr{(a + b) / c} only if
+@expr{c} and at least one of @expr{a} and @expr{b} are numbers.
Quotients of powers and square roots are distributed just as
described for multiplication.
Quotients of products cancel only in the leading terms of the
-numerator and denominator. In other words, @cite{a x b / a y b}
-is cancelled to @cite{x b / y b} but not to @cite{x / y}. Once
+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
again this is because full cancellation can be slow; use @kbd{a s}
to cancel all terms of the quotient.
Quotients of negative-looking values are simplified according
-to @cite{(-a) / (-b)} to @cite{a / b}, @cite{(-a) / (b - c)}
-to @cite{a / (c - b)}, and @cite{(a - b) / (-c)} to @cite{(b - a) / c}.
+to @expr{(-a) / (-b)} to @expr{a / b}, @expr{(-a) / (b - c)}
+to @expr{a / (c - b)}, and @expr{(a - b) / (-c)} to @expr{(b - a) / c}.
@tex
\bigskip
@end tex
-The formula @cite{x^0} is simplified to @cite{1}, or to @samp{idn(1)}
-in matrix mode. The formula @cite{0^x} is simplified to @cite{0}
-unless @cite{x} is a negative number or complex number, in which
-case the result is an infinity or an unsimplified formula according
-to the current infinite mode. Note that @cite{0^0} is an
-indeterminate form, as evidenced by the fact that the simplifications
-for @cite{x^0} and @cite{0^x} conflict when @cite{x=0}.
-
-Powers of products or quotients @cite{(a b)^c}, @cite{(a/b)^c}
-are distributed to @cite{a^c b^c}, @cite{a^c / b^c} only if @cite{c}
-is an integer, or if either @cite{a} or @cite{b} are nonnegative
-real numbers. Powers of powers @cite{(a^b)^c} are simplified to
-@c{$a^{b c}$}
-@cite{a^(b c)} only when @cite{c} is an integer and @cite{b c} also
+The formula @expr{x^0} is simplified to @expr{1}, or to @samp{idn(1)}
+in Matrix mode. The formula @expr{0^x} is simplified to @expr{0}
+unless @expr{x} is a negative number, complex number or zero.
+If @expr{x} is negative, complex or @expr{0.0}, @expr{0^x} is an
+infinity or an unsimplified formula according to the current infinite
+mode. The expression @expr{0^0} is simplified to @expr{1}.
+
+Powers of products or quotients @expr{(a b)^c}, @expr{(a/b)^c}
+are distributed to @expr{a^c b^c}, @expr{a^c / b^c} only if @expr{c}
+is an integer, or if either @expr{a} or @expr{b} are nonnegative
+real numbers. Powers of powers @expr{(a^b)^c} are simplified to
+@texline @math{a^{b c}}
+@infoline @expr{a^(b c)}
+only when @expr{c} is an integer and @expr{b c} also
evaluates to an integer. Without these restrictions these simplifications
would not be safe because of problems with principal values.
-(In other words, @c{$((-3)^{1/2})^2$}
-@cite{((-3)^1:2)^2} is safe to simplify, but
-@c{$((-3)^2)^{1/2}$}
-@cite{((-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, @cite{@t{sqrt}(x)^n} is simplified to
-@c{$x^{n/2}$}
-@cite{x^(n/2)} only for even integers @cite{n}.
-
-If @cite{a} is known to be real, @cite{b} is an even integer, and
-@cite{c} is a half- or quarter-integer, then @cite{(a^b)^c} is
-simplified to @c{$@t{abs}(a^{b c})$}
-@cite{@t{abs}(a^(b c))}.
-
-Also, @cite{(-a)^b} is simplified to @cite{a^b} if @cite{b} is an
-even integer, or to @cite{-(a^b)} if @cite{b} is an odd integer,
-for any negative-looking expression @cite{-a}.
-
-Square roots @cite{@t{sqrt}(x)} generally act like one-half powers
-@c{$x^{1:2}$}
-@cite{x^1:2} for the purposes of the above-listed simplifications.
-
-Also, note that @c{$1 / x^{1:2}$}
-@cite{1 / x^1:2} is changed to @c{$x^{-1:2}$}
-@cite{x^(-1:2)},
-but @cite{1 / @t{sqrt}(x)} is left alone.
+(In other words,
+@texline @math{((-3)^{1/2})^2}
+@infoline @expr{((-3)^1:2)^2}
+is safe to simplify, but
+@texline @math{((-3)^2)^{1/2}}
+@infoline @expr{((-3)^2)^1:2}
+is not.) @xref{Declarations}, for ways to inform Calc that your
+variables satisfy these requirements.
+
+As a special case of this rule, @expr{@tfn{sqrt}(x)^n} is simplified to
+@texline @math{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
+@expr{c} is a half- or quarter-integer, then @expr{(a^b)^c} is
+simplified to @expr{@tfn{abs}(a^(b c))}.
+
+Also, @expr{(-a)^b} is simplified to @expr{a^b} if @expr{b} is an
+even integer, or to @expr{-(a^b)} if @expr{b} is an odd integer,
+for any negative-looking expression @expr{-a}.
+
+Square roots @expr{@tfn{sqrt}(x)} generally act like one-half powers
+@texline @math{x^{1:2}}
+@infoline @expr{x^1:2}
+for the purposes of the above-listed simplifications.
+
+Also, note that
+@texline @math{1 / x^{1:2}}
+@infoline @expr{1 / x^1:2}
+is changed to
+@texline @math{x^{-1:2}},
+@infoline @expr{x^(-1:2)},
+but @expr{1 / @tfn{sqrt}(x)} is left alone.
@tex
\bigskip
@end tex
Generic identity matrices (@pxref{Matrix Mode}) are simplified by the
-following rules: @cite{@t{idn}(a) + b} to @cite{a + b} if @cite{b}
-is provably scalar, or expanded out if @cite{b} is a matrix;
-@cite{@t{idn}(a) + @t{idn}(b)} to @cite{@t{idn}(a + b)};
-@cite{-@t{idn}(a)} to @cite{@t{idn}(-a)}; @cite{a @t{idn}(b)} to
-@cite{@t{idn}(a b)} if @cite{a} is provably scalar, or to @cite{a b}
-if @cite{a} is provably non-scalar; @cite{@t{idn}(a) @t{idn}(b)}
-to @cite{@t{idn}(a b)}; analogous simplifications for quotients
-involving @code{idn}; and @cite{@t{idn}(a)^n} to @cite{@t{idn}(a^n)}
-where @cite{n} is an integer.
+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}
+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
+@expr{n} is an integer.
@tex
\bigskip
The @code{floor} function and other integer truncation functions
vanish if the argument is provably integer-valued, so that
-@cite{@t{floor}(@t{round}(x))} simplifies to @cite{@t{round}(x)}.
+@expr{@tfn{floor}(@tfn{round}(x))} simplifies to @expr{@tfn{round}(x)}.
Also, combinations of @code{float}, @code{floor} and its friends,
and @code{ffloor} and its friends, are simplified in appropriate
ways. @xref{Integer Truncation}.
-The expression @cite{@t{abs}(-x)} changes to @cite{@t{abs}(x)}.
-The expression @cite{@t{abs}(@t{abs}(x))} changes to @cite{@t{abs}(x)};
-in fact, @cite{@t{abs}(x)} changes to @cite{x} or @cite{-x} if @cite{x}
-is provably nonnegative or nonpositive (@pxref{Declarations}).
+The expression @expr{@tfn{abs}(-x)} changes to @expr{@tfn{abs}(x)}.
+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}).
While most functions do not recognize the variable @code{i} as an
imaginary number, the @code{arg} function does handle the two cases
-@cite{@t{arg}(@t{i})} and @cite{@t{arg}(-@t{i})} just for convenience.
+@expr{@tfn{arg}(@tfn{i})} and @expr{@tfn{arg}(-@tfn{i})} just for convenience.
-The expression @cite{@t{conj}(@t{conj}(x))} simplifies to @cite{x}.
+The expression @expr{@tfn{conj}(@tfn{conj}(x))} simplifies to @expr{x}.
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,
-@cite{@t{conj}(a + b i)} is changed to @cite{@t{conj}(a) - @t{conj}(b) i},
-or to @cite{a - b i} if @cite{a} and @cite{b} are known to be real.
+@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
described in the next section does provide some simplifications for
these functions, though.
-One important simplification that does occur is that @cite{@t{ln}(@t{e})}
-is simplified to 1, and @cite{@t{ln}(@t{e}^x)} is simplified to @cite{x}
-for any @cite{x}. This occurs even if you have stored a different
-value in the Calc variable @samp{e}; but this would be a bad idea
-in any case if you were also using natural logarithms!
+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
+simplified to @expr{x} for any @expr{x}. This occurs even if you have
+stored a different value in the Calc variable @samp{e}; but this would
+be a bad idea in any case if you were also using natural logarithms!
-Among the logical functions, @t{(@var{a} <= @var{b})} changes to
-@t{@var{a} > @var{b}} and so on. Equations and inequalities where both sides
+Among the logical functions, @tfn{!(@var{a} <= @var{b})} changes to
+@tfn{@var{a} > @var{b}} and so on. Equations and inequalities where both sides
are either negative-looking or zero are simplified by negating both sides
and reversing the inequality. While it might seem reasonable to simplify
-@cite{!!x} to @cite{x}, this would not be valid in general because
-@cite{!!2} is 1, not 2.
+@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
defined, aside of course from evaluation when the arguments are
@end tex
Sums are simplified in two ways. Constant terms are commuted to the
-end of the sum, so that @cite{a + 2 + b} changes to @cite{a + b + 2}.
+end of the sum, so that @expr{a + 2 + b} changes to @expr{a + b + 2}.
The only exception is that a constant will not be commuted away
-from the first position of a difference, i.e., @cite{2 - x} is not
-commuted to @cite{-x + 2}.
+from the first position of a difference, i.e., @expr{2 - x} is not
+commuted to @expr{-x + 2}.
Also, terms of sums are combined by the distributive law, as in
-@cite{x + y + 2 x} to @cite{y + 3 x}. This always occurs for
+@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.
@end tex
Products are sorted into a canonical order using the commutative
-law. For example, @cite{b c a} is commuted to @cite{a b c}.
+law. For example, @expr{b c a} is commuted to @expr{a b c}.
This allows easier comparison of products; for example, the default
-simplifications will not change @cite{x y + y x} to @cite{2 x y},
-but @kbd{a s} will; it first rewrites the sum to @cite{x y + x y},
+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.
come first, and are sorted into increasing order. The @kbd{V S}
command uses the same ordering when sorting a vector.
-Sorting of terms of products is inhibited when matrix mode is
+Sorting of terms of products is inhibited when Matrix mode is
turned on; in this case, Calc will never exchange the order of
two terms unless it knows at least one of the terms is a scalar.
Even though sums are not sorted, the commutative law is still
taken into account when terms of a product are being compared.
-Thus @cite{(x + y) (y + x)} will be simplified to @cite{(x + y)^2}.
-A subtle point is that @cite{(x - y) (y - x)} will @emph{not}
-be simplified to @cite{-(x - y)^2}; Calc does not notice that
+Thus @expr{(x + y) (y + x)} will be simplified to @expr{(x + y)^2}.
+A subtle point is that @expr{(x - y) (y - x)} will @emph{not}
+be simplified to @expr{-(x - y)^2}; Calc does not notice that
one term can be written as a constant times the other, even if
-that constant is @i{-1}.
+that constant is @mathit{-1}.
-A fraction times any expression, @cite{(a:b) x}, is changed to
-a quotient involving integers: @cite{a x / b}. This is not
-done for floating-point numbers like @cite{0.5}, however. This
+A fraction times any expression, @expr{(a:b) x}, is changed to
+a quotient involving integers: @expr{a x / b}. This is not
+done for floating-point numbers like @expr{0.5}, however. This
is one reason why you may find it convenient to turn Fraction mode
on while doing algebra; @pxref{Fraction Mode}.
Quotients are simplified by comparing all terms in the numerator
with all terms in the denominator for possible cancellation using
-the distributive law. For example, @cite{a x^2 b / c x^3 d} will
-cancel @cite{x^2} from both sides to get @cite{a b / c x d}.
-(The terms in the denominator will then be rearranged to @cite{c d x}
+the distributive law. For example, @expr{a x^2 b / c x^3 d} will
+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;
-for example, @cite{(4 x + 6) / 8 x} simplifies to @cite{(2 x + 3) / 4 x}.
+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 @cite{a} in @cite{(a x + a) / a^2} you could first
-use @kbd{j M} on the product @cite{a x} to Merge the numerator to
-@cite{a (1+x)}, which can then be simplified successfully.
+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
@end tex
Integer powers of the variable @code{i} are simplified according
-to the identity @cite{i^2 = -1}. If you store a new value other
-than the complex number @cite{(0,1)} in @code{i}, this simplification
+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
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 @cite{@t{sqrt}(8)} is rewritten as
-@c{$2\,\t{sqrt}(2)$}
-@cite{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.
+pulled out so that @expr{@tfn{sqrt}(8)} is rewritten as
+@texline @math{2\,@tfn{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.
Square roots in the denominator of a quotient are moved to the
-numerator: @cite{1 / @t{sqrt}(3)} changes to @cite{@t{sqrt}(3) / 3}.
+numerator: @expr{1 / @tfn{sqrt}(3)} changes to @expr{@tfn{sqrt}(3) / 3}.
The same effect occurs for the square root of a fraction:
-@cite{@t{sqrt}(2:3)} changes to @cite{@t{sqrt}(6) / 3}.
+@expr{@tfn{sqrt}(2:3)} changes to @expr{@tfn{sqrt}(6) / 3}.
@tex
\bigskip
@end tex
The @code{%} (modulo) operator is simplified in several ways
-when the modulus @cite{M} is a positive real number. First, if
-the argument is of the form @cite{x + n} for some real number
-@cite{n}, then @cite{n} is itself reduced modulo @cite{M}. For
+when the modulus @expr{M} is a positive real number. First, if
+the argument is of the form @expr{x + n} for some real number
+@expr{n}, then @expr{n} is itself reduced modulo @expr{M}. For
example, @samp{(x - 23) % 10} is simplified to @samp{(x + 7) % 10}.
If the argument is multiplied by a constant, and this constant
\bigskip
@end tex
-Trigonometric functions are simplified in several ways. First,
-@cite{@t{sin}(@t{arcsin}(x))} is simplified to @cite{x}, and
-similarly for @code{cos} and @code{tan}. If the argument to
-@code{sin} is negative-looking, it is simplified to @cite{-@t{sin}(x)},
-and similarly for @code{cos} and @code{tan}. Finally, certain
-special values of the argument are recognized;
-@pxref{Trigonometric and Hyperbolic Functions}.
-
+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)}.
+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
+hyperbolic functions are also handled.
+
+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}.
Trigonometric functions of inverses of different trigonometric
-functions can also be simplified, as in @cite{@t{sin}(@t{arccos}(x))}
-to @cite{@t{sqrt}(1 - x^2)}.
+functions can also be simplified, as in @expr{@tfn{sin}(@tfn{arccos}(x))}
+to @expr{@tfn{sqrt}(1 - x^2)}.
+
+If the argument to @code{sin} is negative-looking, it is simplified to
+@expr{-@tfn{sin}(x)}, and similarly for @code{cos} and @code{tan}.
+Finally, certain special values of the argument are recognized;
+@pxref{Trigonometric and Hyperbolic Functions}.
Hyperbolic functions of their inverses and of negative-looking
arguments are also handled, as are exponentials of inverse
No simplifications for inverse trigonometric and hyperbolic
functions are known, except for negative arguments of @code{arcsin},
@code{arctan}, @code{arcsinh}, and @code{arctanh}. Note that
-@cite{@t{arcsin}(@t{sin}(x))} can @emph{not} safely change to
-@cite{x}, since this only correct within an integer multiple
-of @c{$2 \pi$}
-@cite{2 pi} radians or 360 degrees. However,
-@cite{@t{arcsinh}(@t{sinh}(x))} is simplified to @cite{x} if
-@cite{x} is known to be real.
+@expr{@tfn{arcsin}(@tfn{sin}(x))} can @emph{not} safely change to
+@expr{x}, since this only correct within an integer multiple of
+@texline @math{2 \pi}
+@infoline @expr{2 pi}
+radians or 360 degrees. However, @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 @cite{@t{exp}(@t{ln}(x))}, @c{$@t{e}^{\ln(x)}$}
-@cite{e^@t{ln}(x)}, and
-@c{$10^{{\rm log10}(x)}$}
-@cite{10^@t{log10}(x)} all reduce to @cite{x}.
-Also, @cite{@t{ln}(@t{exp}(x))}, etc., can reduce to @cite{x} if
-@cite{x} is provably real. The form @cite{@t{exp}(x)^y} is simplified
-to @cite{@t{exp}(x y)}. If @cite{x} is a suitable multiple of @c{$\pi i$}
-@cite{pi i}
-(as described above for the trigonometric functions), then @cite{@t{exp}(x)}
-or @cite{e^x} will be expanded. Finally, @cite{@t{ln}(x)} is simplified
-to a form involving @code{pi} and @code{i} where @cite{x} is provably
-negative, positive imaginary, or negative imaginary.
+are that @expr{@tfn{exp}(@tfn{ln}(x))},
+@texline @tfn{e}@math{^{\ln(x)}},
+@infoline @expr{e^@tfn{ln}(x)},
+and
+@texline @math{10^{{\rm 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}
+@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.
The error functions @code{erf} and @code{erfc} are simplified when
their arguments are negative-looking or are calls to the @code{conj}
Equations and inequalities are simplified by cancelling factors
of products, quotients, or sums on both sides. Inequalities
change sign if a negative multiplicative factor is cancelled.
-Non-constant multiplicative factors as in @cite{a b = a c} are
+Non-constant multiplicative factors as in @expr{a b = a c} are
cancelled 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
Simplification also replaces an equation or inequality with
1 or 0 (``true'' or ``false'') if it can through the use of
-declarations. If @cite{x} is declared to be an integer greater
-than 5, then @cite{x < 3}, @cite{x = 3}, and @cite{x = 7.5} are
-all simplified to 0, but @cite{x > 3} is simplified to 1.
-By a similar analysis, @cite{abs(x) >= 0} is simplified to 1,
-as is @cite{x^2 >= 0} if @cite{x} is known to be real.
+declarations. If @expr{x} is declared to be an integer greater
+than 5, then @expr{x < 3}, @expr{x = 3}, and @expr{x = 7.5} are
+all simplified to 0, but @expr{x > 3} is simplified to 1.
+By a similar analysis, @expr{abs(x) >= 0} is simplified to 1,
+as is @expr{x^2 >= 0} if @expr{x} is known to be real.
@node Unsafe Simplifications, Simplification of Units, Algebraic Simplifications, Simplifying Formulas
@subsection ``Unsafe'' 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 @cite{a} only,'' Calc (like most other symbolic
-integration programs) will simply produce an unqualified result.@refill
+``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
Inverse trigonometric or hyperbolic functions, called with their
corresponding non-inverse functions as arguments, are simplified
-by @kbd{a e}. For example, @cite{@t{arcsin}(@t{sin}(x))} changes
-to @cite{x}. Also, @cite{@t{arcsin}(@t{cos}(x))} and
-@cite{@t{arccos}(@t{sin}(x))} both change to @cite{@t{pi}/2 - x}.
+by @kbd{a e}. 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
-values of @cite{x} in a certain range; outside that range, values
+values of @expr{x} in a certain range; outside that range, values
are folded down to the 360-degree range that the inverse trigonometric
functions always produce.
-Powers of powers @cite{(x^a)^b} are simplified to @c{$x^{a b}$}
-@cite{x^(a b)}
-for all @cite{a} and @cite{b}. These results will be valid only
-in a restricted range of @cite{x}; for example, in @c{$(x^2)^{1:2}$}
-@cite{(x^2)^1:2}
-the powers cancel to get @cite{x}, which is valid for positive values
-of @cite{x} but not for negative or complex values.
-
-Similarly, @cite{@t{sqrt}(x^a)} and @cite{@t{sqrt}(x)^a} are both
-simplified (possibly unsafely) to @c{$x^{a/2}$}
-@cite{x^(a/2)}.
-
-Forms like @cite{@t{sqrt}(1 - @t{sin}(x)^2)} are simplified to, e.g.,
-@cite{@t{cos}(x)}. Calc has identities of this sort for @code{sin},
+Powers of powers @expr{(x^a)^b} are simplified to
+@texline @math{x^{a b}}
+@infoline @expr{x^(a b)}
+for all @expr{a} and @expr{b}. These results will be valid only
+in a restricted range of @expr{x}; for example, in
+@texline @math{(x^2)^{1:2}}
+@infoline @expr{(x^2)^1:2}
+the powers cancel to get @expr{x}, which is valid for positive values
+of @expr{x} but not for negative or complex values.
+
+Similarly, @expr{@tfn{sqrt}(x^a)} and @expr{@tfn{sqrt}(x)^a} are both
+simplified (possibly unsafely) to
+@texline @math{x^{a/2}}.
+@infoline @expr{x^(a/2)}.
+
+Forms like @expr{@tfn{sqrt}(1 - sin(x)^2)} are simplified to, e.g.,
+@expr{@tfn{cos}(x)}. Calc has identities of this sort for @code{sin},
@code{cos}, @code{tan}, @code{sinh}, and @code{cosh}.
Arguments of square roots are partially factored to look for
squared terms that can be extracted. For example,
-@cite{@t{sqrt}(a^2 b^3 + a^3 b^2)} simplifies to @cite{a b @t{sqrt}(a+b)}.
+@expr{@tfn{sqrt}(a^2 b^3 + a^3 b^2)} simplifies to
+@expr{a b @tfn{sqrt}(a+b)}.
-The simplifications of @cite{@t{ln}(@t{exp}(x))}, @cite{@t{ln}(@t{e}^x)},
-and @cite{@t{log10}(10^x)} to @cite{x} are also unsafe because
-of problems with principal values (although these simplifications
-are safe if @cite{x} is known to be real).
+The simplifications of @expr{@tfn{ln}(@tfn{exp}(x))},
+@expr{@tfn{ln}(@tfn{e}^x)}, and @expr{@tfn{log10}(10^x)} to @expr{x} are also
+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
-equation, even if those factors may be zero: @cite{a x / b x}
-to @cite{a / b}. Such factors are never cancelled from
+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
-@cite{a x < b x} to @cite{a < b} (or @cite{a > b}, depending
-on whether you believe @cite{x} is positive or negative).
+@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.
Scalar mode is automatically put into effect when simplifying units.
@xref{Matrix Mode}.
-Sums @cite{a + b} involving units are simplified by extracting the
-units of @cite{a} as if by the @kbd{u x} command (call the result
-@cite{u_a}), then simplifying the expression @cite{b / u_a}
+Sums @expr{a + b} involving units are simplified by extracting the
+units of @expr{a} as if by the @kbd{u x} command (call the result
+@expr{u_a}), then simplifying the expression @expr{b / u_a}
using @kbd{u b} and @kbd{u s}. If the result has units then the sum
is inconsistent and is left alone. Otherwise, it is rewritten
-in terms of the units @cite{u_a}.
+in terms of the units @expr{u_a}.
If units auto-ranging mode is enabled, products or quotients in
which the first argument is a number which is out of range for the
However, compatible but different units like @code{ft} and @code{in}
are not combined in this way.
-Quotients @cite{a / b} are simplified in three additional ways. First,
-if @cite{b} is a number or a product beginning with a number, Calc
+Quotients @expr{a / b} are simplified in three additional ways. First,
+if @expr{b} is a number or a product beginning with a number, Calc
computes the reciprocal of this number and moves it to the numerator.
Second, for each pair of unit names from the numerator and denominator
of a quotient, if the units are compatible (e.g., they are both
units of area) then they are replaced by the ratio between those
units. For example, in @samp{3 s in N / kg cm} the units
-@samp{in / cm} will be replaced by @cite{2.54}.
+@samp{in / cm} will be replaced by @expr{2.54}.
Third, if the units in the quotient exactly cancel out, so that
a @kbd{u b} command on the quotient would produce a dimensionless
number for an answer, then the quotient simplifies to that number.
For powers and square roots, the ``unsafe'' simplifications
-@cite{(a b)^c} to @cite{a^c b^c}, @cite{(a/b)^c} to @cite{a^c / b^c},
-and @cite{(a^b)^c} to @c{$a^{b c}$}
-@cite{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.)
+@expr{(a b)^c} to @expr{a^c b^c}, @expr{(a/b)^c} to @expr{a^c / b^c},
+and @expr{(a^b)^c} to
+@texline @math{a^{b c}}
+@infoline @expr{a^(b c)}
+are done if the powers are real numbers. (These are safe in the context
+of units because all numbers involved can reasonably be assumed to be
+real.)
Also, if a unit name is raised to a fractional power, and the
base units in that unit name all occur to powers which are a
multiple of the denominator of the power, then the unit name
is expanded out into its base units, which can then be simplified
according to the previous paragraph. For example, @samp{acre^1.5}
-is simplified by noting that @cite{1.5 = 3:2}, that @samp{acre}
+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 @cite{3:2}. Thus, @code{acre^1.5} is
-replaced by approximately @c{$(4046 m^2)^{1.5}$}
-@cite{(4046 m^2)^1.5}, which is then
-changed to @c{$4046^{1.5} \, (m^2)^{1.5}$}
-@cite{4046^1.5 (m^2)^1.5}, then to @cite{257440 m^3}.
+@code{m} is a multiple of 2 in @expr{3:2}. Thus, @code{acre^1.5} is
+replaced by approximately
+@texline @math{(4046 m^2)^{1.5}}
+@infoline @expr{(4046 m^2)^1.5},
+which is then changed to
+@texline @math{4046^{1.5} \, (m^2)^{1.5}},
+@infoline @expr{4046^1.5 (m^2)^1.5},
+then to @expr{257440 m^3}.
The functions @code{float}, @code{frac}, @code{clean}, @code{abs},
as well as @code{floor} and the other integer truncation functions,
@section Polynomials
A @dfn{polynomial} is a sum of terms which are coefficients times
-various powers of a ``base'' variable. For example, @cite{2 x^2 + 3 x - 4}
-is a polynomial in @cite{x}. Some formulas can be considered
-polynomials in several different variables: @cite{1 + 2 x + 3 y + 4 x y^2}
-is a polynomial in both @cite{x} and @cite{y}. Polynomial coefficients
+various powers of a ``base'' variable. For example, @expr{2 x^2 + 3 x - 4}
+is a polynomial in @expr{x}. Some formulas can be considered
+polynomials in several different variables: @expr{1 + 2 x + 3 y + 4 x y^2}
+is a polynomial in both @expr{x} and @expr{y}. Polynomial coefficients
are often numbers, but they may in general be any formulas not
involving the base variable.
@tindex factor
The @kbd{a f} (@code{calc-factor}) [@code{factor}] command factors a
polynomial into a product of terms. For example, the polynomial
-@cite{x^3 + 2 x^2 + x} is factored into @samp{x*(x+1)^2}. As another
-example, @cite{a c + b d + b c + a d} is factored into the product
-@cite{(a + b) (c + d)}.
+@expr{x^3 + 2 x^2 + x} is factored into @samp{x*(x+1)^2}. As another
+example, @expr{a c + b d + b c + a d} is factored into the product
+@expr{(a + b) (c + d)}.
Calc currently has three algorithms for factoring. Formulas which are
linear in several variables, such as the second example above, are
polynomials in a single variable, with constant integer or fractional
coefficients, are factored into irreducible linear and/or quadratic
terms. The first example above factors into three linear terms
-(@cite{x}, @cite{x+1}, and @cite{x+1} again). Finally, formulas
+(@expr{x}, @expr{x+1}, and @expr{x+1} again). Finally, formulas
which do not fit the above criteria are handled by the algebraic
rewrite mechanism.
@code{FactorRules}. @xref{Rewrite Rules}, for a discussion of the
operation of rewrite rules. The default @code{FactorRules} are able
to factor quadratic forms symbolically into two linear terms,
-@cite{(a x + b) (c x + d)}. You can edit these rules to include other
+@expr{(a x + b) (c x + d)}. You can edit these rules to include other
cases if you wish. To use the rules, Calc builds the formula
@samp{thecoefs(x, [a, b, c, ...])} where @code{x} is the polynomial
base variable and @code{a}, @code{b}, etc., are polynomial coefficients
but it returns a list of factors instead of an expression which is the
product of the factors. Each factor is represented by a sub-vector
of the factor, and the power with which it appears. For example,
-@cite{x^5 + x^4 - 33 x^3 + 63 x^2} factors to @cite{(x + 7) x^2 (x - 3)^2}
-in @kbd{a f}, or to @cite{[ [x, 2], [x+7, 1], [x-3, 2] ]} in @kbd{H a f}.
+@expr{x^5 + x^4 - 33 x^3 + 63 x^2} factors to @expr{(x + 7) x^2 (x - 3)^2}
+in @kbd{a f}, or to @expr{[ [x, 2], [x+7, 1], [x-3, 2] ]} in @kbd{H a f}.
If there is an overall numeric factor, it always comes first in the list.
The functions @code{factor} and @code{factors} allow a second argument
-when written in algebraic form; @samp{factor(x,v)} factors @cite{x} with
-respect to the specific variable @cite{v}. The default is to factor with
-respect to all the variables that appear in @cite{x}.
+when written in algebraic form; @samp{factor(x,v)} factors @expr{x} with
+respect to the specific variable @expr{v}. The default is to factor with
+respect to all the variables that appear in @expr{x}.
@kindex a c
@pindex calc-collect
The @kbd{a c} (@code{calc-collect}) [@code{collect}] command rearranges a
formula as a
polynomial in a given variable, ordered in decreasing powers of that
-variable. For example, given @cite{1 + 2 x + 3 y + 4 x y^2} on
-the stack, @kbd{a c x} would produce @cite{(2 + 4 y^2) x + (1 + 3 y)},
-and @kbd{a c y} would produce @cite{(4 x) y^2 + 3 y + (1 + 2 x)}.
+variable. For example, given @expr{1 + 2 x + 3 y + 4 x y^2} on
+the stack, @kbd{a c x} would produce @expr{(2 + 4 y^2) x + (1 + 3 y)},
+and @kbd{a c y} would produce @expr{(4 x) y^2 + 3 y + (1 + 2 x)}.
The polynomial will be expanded out using the distributive law as
-necessary: Collecting @cite{x} in @cite{(x - 1)^3} produces
-@cite{x^3 - 3 x^2 + 3 x - 1}. Terms not involving @cite{x} will
+necessary: Collecting @expr{x} in @expr{(x - 1)^3} produces
+@expr{x^3 - 3 x^2 + 3 x - 1}. Terms not involving @expr{x} will
not be expanded.
The ``variable'' you specify at the prompt can actually be any
do not do.)
Calc's automatic simplifications will sometimes reverse a partial
-expansion. For example, the first step in expanding @cite{(x+1)^3} is
-to write @cite{(x+1) (x+1)^2}. If @kbd{a x} stops there and tries
+expansion. For example, the first step in expanding @expr{(x+1)^3} is
+to write @expr{(x+1) (x+1)^2}. If @kbd{a x} stops there and tries
to put this formula onto the stack, though, Calc will automatically
-simplify it back to @cite{(x+1)^3} form. The solution is to turn
+simplify it back to @expr{(x+1)^3} form. The solution is to turn
simplification off first (@pxref{Simplification Modes}), or to run
@kbd{a x} without a numeric prefix argument so that it expands all
the way in one step.
@tindex nrat
The @kbd{a n} (@code{calc-normalize-rat}) [@code{nrat}] command
attempts to arrange a formula into a quotient of two polynomials.
-For example, given @cite{1 + (a + b/c) / d}, the result would be
-@cite{(b + a c + c d) / c d}. The quotient is reduced, so that
-@kbd{a n} will simplify @cite{(x^2 + 2x + 1) / (x^2 - 1)} by dividing
-out the common factor @cite{x + 1}, yielding @cite{(x + 1) / (x - 1)}.
+For example, given @expr{1 + (a + b/c) / d}, the result would be
+@expr{(b + a c + c d) / c d}. The quotient is reduced, so that
+@kbd{a n} will simplify @expr{(x^2 + 2x + 1) / (x^2 - 1)} by dividing
+out the common factor @expr{x + 1}, yielding @expr{(x + 1) / (x - 1)}.
@kindex a \
@pindex calc-poly-div
@tindex pdiv
The @kbd{a \} (@code{calc-poly-div}) [@code{pdiv}] command divides
-two polynomials @cite{u} and @cite{v}, yielding a new polynomial
-@cite{q}. If several variables occur in the inputs, the inputs are
+two polynomials @expr{u} and @expr{v}, yielding a new polynomial
+@expr{q}. If several variables occur in the inputs, the inputs are
considered multivariate polynomials. (Calc divides by the variable
-with the largest power in @cite{u} first, or, in the case of equal
+with the largest power in @expr{u} first, or, in the case of equal
powers, chooses the variables in alphabetical order.) For example,
-dividing @cite{x^2 + 3 x + 2} by @cite{x + 2} yields @cite{x + 1}.
+dividing @expr{x^2 + 3 x + 2} by @expr{x + 2} yields @expr{x + 1}.
The remainder from the division, if any, is reported at the bottom
of the screen and is also placed in the Trail along with the quotient.
@pindex calc-poly-rem
@tindex prem
The @kbd{a %} (@code{calc-poly-rem}) [@code{prem}] command divides
-two polynomials and keeps the remainder @cite{r}. The quotient
-@cite{q} is discarded. For any formulas @cite{a} and @cite{b}, the
-results of @kbd{a \} and @kbd{a %} satisfy @cite{a = q b + r}.
+two polynomials and keeps the remainder @expr{r}. The quotient
+@expr{q} is discarded. For any formulas @expr{a} and @expr{b}, the
+results of @kbd{a \} and @kbd{a %} satisfy @expr{a = q b + r}.
(This is analogous to plain @kbd{\} and @kbd{%}, which compute the
integer quotient and remainder from dividing two numbers.)
@tindex pdivide
The @kbd{a /} (@code{calc-poly-div-rem}) [@code{pdivrem}] command
divides two polynomials and reports both the quotient and the
-remainder as a vector @cite{[q, r]}. The @kbd{H a /} [@code{pdivide}]
+remainder as a vector @expr{[q, r]}. The @kbd{H a /} [@code{pdivide}]
command divides two polynomials and constructs the formula
-@cite{q + r/b} on the stack. (Naturally if the remainder is zero,
-this will immediately simplify to @cite{q}.)
+@expr{q + r/b} on the stack. (Naturally if the remainder is zero,
+this will immediately simplify to @expr{q}.)
@kindex a g
@pindex calc-poly-gcd
@var{n}th derivative.
When working with trigonometric functions, it is best to switch to
-radians mode first (with @w{@kbd{m r}}). The derivative of @samp{sin(x)}
+Radians mode first (with @w{@kbd{m r}}). The derivative of @samp{sin(x)}
in degrees is @samp{(pi/180) cos(x)}, probably not the expected
answer!
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 @cite{f} with respect to @cite{x}, evaluated at the point @c{$x=x_0$}
-@cite{x=x0}.
+of @expr{f} with respect to @expr{x}, evaluated at the point
+@texline @math{x=x_0}.
+@infoline @expr{x=x0}.
If the formula being differentiated contains functions which Calc does
not know, the derivatives of those functions are produced by adding
Various higher-order derivatives can be formed in the obvious way, e.g.,
@samp{f'@var{}'(x)} (the second derivative of @code{f}) or
@samp{f'@var{}'2'3(x,y,z)} (@code{f} differentiated with respect to each
-argument once).@refill
+argument once).
@node Integration, Customizing the Integrator, Differentiation, Calculus
@subsection Integration
@tindex integ
The @kbd{a i} (@code{calc-integral}) [@code{integ}] command computes the
indefinite integral of the expression on the top of the stack with
-respect to a variable. The integrator is not guaranteed to 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; @c{$x/(1+x^{-2})$}
-@cite{x/(1+x^-2)}
+respect to a prompted-for variable. The integrator is not guaranteed to
+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;
+@texline @math{x/(1+x^{-2})}
+@infoline @expr{x/(1+x^-2)}
is not strictly a quotient of polynomials, but it is equivalent to
-@cite{x^3/(x^2+1)}, which is.) Also, square roots of terms involving
-@cite{x} and @cite{x^2} may appear in rational functions being
+@expr{x^3/(x^2+1)}, which is.) Also, square roots of terms involving
+@expr{x} and @expr{x^2} may appear in rational functions being
integrated. Finally, rational functions involving trigonometric or
hyperbolic functions can be integrated.
+With an argument (@kbd{C-u a i}), this command will compute the definite
+integral of the expression on top of the stack. In this case, the
+command will again prompt for an integration variable, then prompt for a
+lower limit and an upper limit.
+
@ifinfo
If you use the @code{integ} function directly in an algebraic formula,
you can also write @samp{integ(f,x,v)} which expresses the resulting
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 @c{$1/(x+\sqrt{x^2+1})$}
-@cite{1/(x+sqrt(x^2+1))}
+be. For example, the integral Calc finds for
+@texline @math{1/(x+\sqrt{x^2+1})}
+@infoline @expr{1/(x+sqrt(x^2+1))}
is several times more complicated than the answer Mathematica
returns for the same input, although the two forms are numerically
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 @c{$1/(1+\tan x)$}
-@cite{1/(1+tan(x))} differs from the solution given
-in the @emph{CRC Math Tables} by a constant factor of @c{$\pi i / 2$}
-@cite{pi i / 2},
+Calc's solution for
+@texline @math{1/(1+\tan x)}
+@infoline @expr{1/(1+tan(x))}
+differs from the solution given in the @emph{CRC Math Tables} by a
+constant factor of
+@texline @math{\pi i / 2}
+@infoline @expr{pi i / 2},
due to a different choice of constant of integration.
The Calculator remembers all the integrals it has done. If conditions
change in a way that would invalidate the old integrals, say, a switch
-from degrees to radians mode, then they will be thrown out. If you
+from Degrees to Radians mode, then they will be thrown out. If you
suspect this is not happening when it should, use the
@code{calc-flush-caches} command; @pxref{Caches}.
@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 @c{${\rm Ei}(x)$}
-@cite{Ei(x)} was invented to describe it.
+integral'' function
+@texline @math{{\rm Ei}(x)}
+@infoline @expr{Ei(x)}
+was invented to describe it.
We can get Calc to do this integral in terms of a made-up @code{Ei}
function by adding the rule @samp{[integtry(exp(x)/x, x) := Ei(x)]}
to @code{IntegRules}. Now entering @samp{exp(2x)/x} on the stack
with respect to the same integration variable.'' If Calc is unable
to integrate @code{u}, the integration that invoked @code{IntegRules}
also fails. Thus integrating @samp{twice(f(x))} fails, returning the
-unevaluated integral @samp{integ(twice(f(x)), x)}. It is still legal
+unevaluated integral @samp{integ(twice(f(x)), x)}. It is still valid
to call @code{integ} with two or more arguments, however; in this case,
if @code{u} is not integrable, @code{twice} itself will still be
integrated: If the above rule is changed to @samp{... := twice(integ(u,x))},
You may specify the number of terms with a numeric prefix argument;
otherwise the command will prompt you for the number of terms. Note that
many series expansions have coefficients of zero for some terms, so you
-may appear to get fewer terms than you asked for.@refill
+may appear to get fewer terms than you asked for.
If the @kbd{a i} command is unable to find a symbolic integral for a
function, you can get an approximation by integrating the function's
@cindex Solving equations
The @kbd{a S} (@code{calc-solve-for}) [@code{solve}] command rearranges
an equation to solve for a specific variable. An equation is an
-expression of the form @cite{L = R}. For example, the command @kbd{a S x}
-will rearrange @cite{y = 3x + 6} to the form, @cite{x = y/3 - 2}. If the
+expression of the form @expr{L = R}. For example, the command @kbd{a S x}
+will rearrange @expr{y = 3x + 6} to the form, @expr{x = y/3 - 2}. If the
input is not an equation, it is treated like an equation of the
-form @cite{X = 0}.
+form @expr{X = 0}.
-This command also works for inequalities, as in @cite{y < 3x + 6}.
+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 @c{$a < b \, c$}
-@cite{a < b c} for @cite{b} is impossible
-without knowing the sign of @cite{c}. In this case, @kbd{a S} will
-produce the result @c{$b \mathbin{\hbox{\code{!=}}} a/c$}
-@cite{b != a/c} (using the not-equal-to operator)
-to signify that the direction of the inequality is now unknown. The
-inequality @c{$a \le b \, c$}
-@cite{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.
+be; for example, solving
+@texline @math{a < b \, c}
+@infoline @expr{a < b c}
+for @expr{b} is impossible
+without knowing the sign of @expr{c}. In this case, @kbd{a S} will
+produce the result
+@texline @math{b \mathbin{\hbox{\code{!=}}} a/c}
+@infoline @expr{b != a/c}
+(using the not-equal-to operator) to signify that the direction of the
+inequality is now unknown. The inequality
+@texline @math{a \le b \, c}
+@infoline @expr{a <= b c}
+is not even partially solved. @xref{Declarations}, for a way to tell
+Calc that the signs of the variables in a formula are in fact known.
Two useful commands for working with the result of @kbd{a S} are
-@kbd{a .} (@pxref{Logical Operations}), which converts @cite{x = y/3 - 2}
-to @cite{y/3 - 2}, and @kbd{s l} (@pxref{Let Command}) which evaluates
-another formula with @cite{x} set equal to @cite{y/3 - 2}.
+@kbd{a .} (@pxref{Logical Operations}), which converts @expr{x = y/3 - 2}
+to @expr{y/3 - 2}, and @kbd{s l} (@pxref{Let Command}) which evaluates
+another formula with @expr{x} set equal to @expr{y/3 - 2}.
@menu
* Multiple Solutions::
general family of solutions. It will invent variables @code{n1},
@code{n2}, @dots{}, which represent independent arbitrary integers, and
@code{s1}, @code{s2}, @dots{}, which represent independent arbitrary
-signs (either @i{+1} or @i{-1}). If you don't use the Hyperbolic
+signs (either @mathit{+1} or @mathit{-1}). If you don't use the Hyperbolic
flag, Calc will use zero in place of all arbitrary integers, and plus
one in place of all arbitrary signs. Note that variables like @code{n1}
and @code{s1} are not given any special interpretation in Calc except by
we solve @samp{sqrt(y) = x} for @code{y}. Calc squares both sides
to get @samp{y = x^2}. This is correct, except that it introduces
some dubious solutions. Consider solving @samp{sqrt(y) = -3}:
-Calc will report @cite{y = 9} as a valid solution, which is true
+Calc will report @expr{y = 9} as a valid solution, which is true
in the mathematical sense of square-root, but false (there is no
solution) for the actual Calc positive-valued @code{sqrt}. This
happens for both @kbd{a S} and @kbd{H a S}.
command to substitute actual values for function calls like @samp{as(3)}.
The @kbd{s G} (@code{calc-edit-GenCount}) command is a convenient
-way to create or edit this variable. Press @kbd{M-# M-#} to finish.
+way to create or edit this variable. Press @kbd{C-c C-c} to finish.
If you have not stored a value in @code{GenCount}, or if the value
in that variable is not a positive integer, the regular
With the Inverse flag, @kbd{I a S} [@code{finv}] treats the expression
on top of the stack as a function of the specified variable and solves
to find the inverse function, written in terms of the same variable.
-For example, @kbd{I a S x} inverts @cite{2x + 6} to @cite{x/2 - 3}.
+For example, @kbd{I a S x} inverts @expr{2x + 6} to @expr{x/2 - 3}.
You can use both Inverse and Hyperbolic [@code{ffinv}] to obtain a
fully general inverse, as described above.
Note that because @kbd{a P} uses @kbd{H a S}, it is able to deliver
symbolic solutions if the polynomial has symbolic coefficients. Also
note that Calc's solver is not able to get exact symbolic solutions
-to all polynomials. Polynomials containing powers up to @cite{x^4}
+to all polynomials. Polynomials containing powers up to @expr{x^4}
can always be solved exactly; polynomials of higher degree sometimes
-can be: @cite{x^6 + x^3 + 1} is converted to @cite{(x^3)^2 + (x^3) + 1},
-which can be solved for @cite{x^3} using the quadratic equation, and then
-for @cite{x} by taking cube roots. But in many cases, like
-@cite{x^6 + x + 1}, Calc does not know how to rewrite the polynomial
+can be: @expr{x^6 + x^3 + 1} is converted to @expr{(x^3)^2 + (x^3) + 1},
+which can be solved for @expr{x^3} using the quadratic equation, and then
+for @expr{x} by taking cube roots. But in many cases, like
+@expr{x^6 + x + 1}, Calc does not know how to rewrite the polynomial
into a form it can solve. The @kbd{a P} command can still deliver a
-list of numerical roots, however, provided that symbolic mode (@kbd{m s})
-is not turned on. (If you work with symbolic mode on, recall that the
+list of numerical roots, however, provided that Symbolic mode (@kbd{m s})
+is not turned on. (If you work with Symbolic mode on, recall that the
@kbd{N} (@code{calc-eval-num}) key is a handy way to reevaluate the
-formula on the stack with symbolic mode temporarily off.) Naturally,
+formula on the stack with Symbolic mode temporarily off.) Naturally,
@kbd{a P} can only provide numerical roots if the polynomial coefficients
are all numbers (real or complex).
have the same length as the variables vector, and the variables
will be listed in the same order there. Note that the solutions
are not always simplified as far as possible; the solution for
-@cite{x} here could be improved by an application of the @kbd{a n}
+@expr{x} here could be improved by an application of the @kbd{a n}
command.
Calc's algorithm works by trying to eliminate one variable at a
The @code{poly} function takes a polynomial and a variable as
arguments, and returns a vector of polynomial coefficients (constant
coefficient first). For example, @samp{poly(x^3 + 2 x, x)} returns
-@cite{[0, 2, 0, 1]}. If the input is not a polynomial in @cite{x},
+@expr{[0, 2, 0, 1]}. If the input is not a polynomial in @expr{x},
the call to @code{poly} is left in symbolic form. If the input does
-not involve the variable @cite{x}, the input is returned in a list
+not involve the variable @expr{x}, the input is returned in a list
of length one, representing a polynomial with only a constant
-coefficient. The call @samp{poly(x, x)} returns the vector @cite{[0, 1]}.
+coefficient. The call @samp{poly(x, x)} returns the vector @expr{[0, 1]}.
The last element of the returned vector is guaranteed to be nonzero;
-note that @samp{poly(0, x)} returns the empty vector @cite{[]}.
-Note also that @cite{x} may actually be any formula; for example,
-@samp{poly(sin(x)^2 - sin(x) + 3, sin(x))} returns @cite{[3, -1, 1]}.
+note that @samp{poly(0, x)} returns the empty vector @expr{[]}.
+Note also that @expr{x} may actually be any formula; for example,
+@samp{poly(sin(x)^2 - sin(x) + 3, sin(x))} returns @expr{[3, -1, 1]}.
@cindex Coefficients of polynomial
@cindex Degree of polynomial
-To get the @cite{x^k} coefficient of polynomial @cite{p}, use
-@samp{poly(p, x)_(k+1)}. To get the degree of polynomial @cite{p},
+To get the @expr{x^k} coefficient of polynomial @expr{p}, use
+@samp{poly(p, x)_(k+1)}. To get the degree of polynomial @expr{p},
use @samp{vlen(poly(p, x)) - 1}. For example, @samp{poly((x+1)^4, x)}
returns @samp{[1, 4, 6, 4, 1]}, so @samp{poly((x+1)^4, x)_(2+1)}
-gives the @cite{x^2} coefficient of this polynomial, 6.
+gives the @expr{x^2} coefficient of this polynomial, 6.
@ignore
@starindex
is considered trivial.
For example, @samp{gpoly((x-2)^2, x)} returns @samp{[x, [4, -4, 1], 1]},
-since the expanded form of this polynomial is @cite{4 - 4 x + x^2}.
+since the expanded form of this polynomial is @expr{4 - 4 x + x^2}.
The term @var{x} may itself be a polynomial in @var{var}. This is
done to reduce the size of the @var{c} vector. For example,
@samp{gpoly(x^4 + x^2 - 1, x)} returns @samp{[x^2, [-1, 1, 1], 1]},
-since a quadratic polynomial in @cite{x^2} is easier to solve than
-a quartic polynomial in @cite{x}.
+since a quadratic polynomial in @expr{x^2} is easier to solve than
+a quartic polynomial in @expr{x}.
A few more examples of the kinds of polynomials @code{gpoly} can
discover:
The @code{poly} and @code{gpoly} functions accept a third integer argument
which specifies the largest degree of polynomial that is acceptable.
-If this is @cite{n}, then only @var{c} vectors of length @cite{n+1}
+If this is @expr{n}, then only @var{c} vectors of length @expr{n+1}
or less will be returned. Otherwise, the @code{poly} or @code{gpoly}
call will remain in symbolic form. For example, the equation solver
can handle quartics and smaller polynomials, so it calls
Thus @samp{plead(p,x)} is equivalent to @samp{poly(p,x)_vlen(poly(p,x))},
though again more efficient. In particular, @samp{plead((2x+1)^10, x)}
returns 1024 without expanding out the list of coefficients. The
-value of @code{plead(p,x)} will be zero only if @cite{p = 0}.
+value of @code{plead(p,x)} will be zero only if @expr{p = 0}.
@ignore
@starindex
The @kbd{a R} (@code{calc-find-root}) [@code{root}] command finds a
numerical solution (or @dfn{root}) of an equation. (This command treats
inequalities the same as equations. If the input is any other kind
-of formula, it is interpreted as an equation of the form @cite{X = 0}.)
+of formula, it is interpreted as an equation of the form @expr{X = 0}.)
The @kbd{a R} command requires an initial guess on the top of the
stack, and a formula in the second-to-top position. It prompts for a
with the minimum value itself.
Note that this command looks for a @emph{local} minimum. Many functions
-have more than one minimum; some, like @c{$x \sin x$}
-@cite{x sin(x)}, have infinitely
-many. In fact, there is no easy way to define the ``global'' minimum
-of @c{$x \sin x$}
-@cite{x sin(x)} but Calc can still locate any particular local minimum
+have more than one minimum; some, like
+@texline @math{x \sin x},
+@infoline @expr{x sin(x)},
+have infinitely many. In fact, there is no easy way to define the
+``global'' minimum of
+@texline @math{x \sin x}
+@infoline @expr{x sin(x)}
+but Calc can still locate any particular local minimum
for you. Calc basically goes downhill from the initial guess until it
finds a point at which the function's value is greater both to the left
and to the right. Calc does not use derivatives when minimizing a function.
If your initial guess is an interval and it looks like the minimum
occurs at one or the other endpoint of the interval, Calc will return
-that endpoint only if that endpoint is closed; thus, minimizing @cite{17 x}
-over @cite{[2..3]} will return @cite{[2, 38]}, but minimizing over
-@cite{(2..3]} would report no minimum found. In general, you should
+that endpoint only if that endpoint is closed; thus, minimizing @expr{17 x}
+over @expr{[2..3]} will return @expr{[2, 38]}, but minimizing over
+@expr{(2..3]} would report no minimum found. In general, you should
use closed intervals to find literally the minimum value in that
-range of @cite{x}, or open intervals to find the local minimum, if
+range of @expr{x}, or open intervals to find the local minimum, if
any, that happens to lie in that range.
Most functions are smooth and flat near their minimum values. Because
@noindent
The @kbd{a F} command fits a set of data to a @dfn{model formula},
-such as @cite{y = m x + b} where @cite{m} and @cite{b} are parameters
+such as @expr{y = m x + b} where @expr{m} and @expr{b} are parameters
to be determined. For a typical set of measured data there will be
-no single @cite{m} and @cite{b} that exactly fit the data; in this
+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.
@cindex Linear regression
@cindex Least-squares fits
The @kbd{a F} (@code{calc-curve-fit}) [@code{fit}] command attempts
-to fit a set of data (@cite{x} and @cite{y} vectors of numbers) to a
-straight line, polynomial, or other function of @cite{x}. For the
+to fit a set of data (@expr{x} and @expr{y} vectors of numbers) to a
+straight line, polynomial, or other function of @expr{x}. For the
moment we will consider only the case of fitting to a line, and we
will ignore the issue of whether or not the model was in fact a good
fit for the data.
-In a standard linear least-squares fit, we have a set of @cite{(x,y)}
-data points that we wish to fit to the model @cite{y = m x + b}
-by adjusting the parameters @cite{m} and @cite{b} to make the @cite{y}
+In a standard linear least-squares fit, we have a set of @expr{(x,y)}
+data points that we wish to fit to the model @expr{y = m x + b}
+by adjusting the parameters @expr{m} and @expr{b} to make the @expr{y}
values calculated from the formula be as close as possible to the actual
-@cite{y} values in the data set. (In a polynomial fit, the model is
-instead, say, @cite{y = a x^3 + b x^2 + c x + d}. In a multilinear fit,
-we have data points of the form @cite{(x_1,x_2,x_3,y)} and our model is
-@cite{y = a x_1 + b x_2 + c x_3 + d}. These will be discussed later.)
-
-In the model formula, variables like @cite{x} and @cite{x_2} are called
-the @dfn{independent variables}, and @cite{y} is the @dfn{dependent
-variable}. Variables like @cite{m}, @cite{a}, and @cite{b} are called
+@expr{y} values in the data set. (In a polynomial fit, the model is
+instead, say, @expr{y = a x^3 + b x^2 + c x + d}. In a multilinear fit,
+we have data points of the form @expr{(x_1,x_2,x_3,y)} and our model is
+@expr{y = a x_1 + b x_2 + c x_3 + d}. These will be discussed later.)
+
+In the model formula, variables like @expr{x} and @expr{x_2} are called
+the @dfn{independent variables}, and @expr{y} is the @dfn{dependent
+variable}. Variables like @expr{m}, @expr{a}, and @expr{b} are called
the @dfn{parameters} of the model.
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 @c{$2\times N$}
-@asis{2xN} matrix where
-the first row is a list of @cite{x} values and the second row has the
-corresponding @cite{y} values. For the multilinear fit shown above,
-the matrix would have four rows (@cite{x_1}, @cite{x_2}, @cite{x_3}, and
-@cite{y}, respectively).
-
-If you happen to have an @c{$N\times2$}
-@asis{Nx2} matrix instead of a @c{$2\times N$}
-@asis{2xN} matrix,
-just press @kbd{v t} first to transpose the matrix.
+for a linear or polynomial fit, this would be a
+@texline @math{2\times N}
+@infoline 2xN
+matrix where the first row is a list of @expr{x} values and the second
+row has the corresponding @expr{y} values. For the multilinear fit
+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
+@texline @math{N\times2}
+@infoline Nx2
+matrix instead of a
+@texline @math{2\times N}
+@infoline 2xN
+matrix, just press @kbd{v t} first to transpose the matrix.
After you type @kbd{a F}, Calc prompts you to select a model. For a
linear fit, press the digit @kbd{1}.
Calc then prompts for you to name the variables. By default it chooses
-high letters like @cite{x} and @cite{y} for independent variables and
-low letters like @cite{a} and @cite{b} for parameters. (The dependent
+high letters like @expr{x} and @expr{y} for independent variables and
+low letters like @expr{a} and @expr{b} for parameters. (The dependent
variable doesn't need a name.) The two kinds of variables are separated
by a semicolon. Since you generally care more about the names of the
independent variables than of the parameters, Calc also allows you to
@noindent
is on the stack and we wish to do a simple linear fit. Type
@kbd{a F}, then @kbd{1} for the model, then @key{RET} to use
-the default names. The result will be the formula @cite{3 + 2 x}
+the default names. The result will be the formula @expr{3 + 2 x}
on the stack. Calc has created the model expression @kbd{a + b x},
-then found the optimal values of @cite{a} and @cite{b} to fit the
+then found the optimal values of @expr{a} and @expr{b} to fit the
data. (In this case, it was able to find an exact fit.) Calc then
-substituted those values for @cite{a} and @cite{b} in the model
+substituted those values for @expr{a} and @expr{b} in the model
formula.
The @kbd{a F} command puts two entries in the trail. One is, as
always, a copy of the result that went to the stack; the other is
a vector of the actual parameter values, written as equations:
-@cite{[a = 3, b = 2]}, in case you'd rather read them in a list
+@expr{[a = 3, b = 2]}, in case you'd rather read them in a list
than pick them out of the formula. (You can type @kbd{t y}
to move this vector to the stack; see @ref{Trail Commands}.
@end tex
@noindent
-which is clearly zero if @cite{a + b x} exactly fits all data points,
-and increases as various @cite{a + b x_i} values fail to match the
-corresponding @cite{y_i} values. There are several reasons why the
-summand is squared, one of them being to ensure that @c{$\chi^2 \ge 0$}
-@cite{chi^2 >= 0}.
-Least-squares fitting simply chooses the values of @cite{a} and @cite{b}
-for which the error @c{$\chi^2$}
-@cite{chi^2} is as small as possible.
+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
+@texline @math{\chi^2 \ge 0}.
+@infoline @expr{chi^2 >= 0}.
+Least-squares fitting simply chooses the values of @expr{a} and @expr{b}
+for which the error
+@texline @math{\chi^2}
+@infoline @expr{chi^2}
+is as small as possible.
Other kinds of models do the same thing but with a different model
-formula in place of @cite{a + b x_i}.
+formula in place of @expr{a + b x_i}.
@tex
\bigskip
is always one independent variable and one dependent variable.
A prefix of zero or plain @kbd{C-u} is a compromise; Calc takes two
-items from the stack, an @var{n}-row matrix of @cite{x} values, and a
-vector of @cite{y} values. If there is only one independent variable,
-the @cite{x} values can be either a one-row matrix or a plain vector,
+items from the stack, an @var{n}-row matrix of @expr{x} values, and a
+vector of @expr{y} values. If there is only one independent variable,
+the @expr{x} values can be either a one-row matrix or a plain vector,
in which case the @kbd{C-u} prefix is the same as a @w{@kbd{C-u 2}} prefix.
@node Polynomial and Multilinear Fits, Error Estimates for Fits, Linear Fits, Curve Fitting
Note that since the constant and linear terms are enough to fit the
data exactly, it's no surprise that Calc chose a tiny contribution
-for @cite{x^2}. (The fact that it's not exactly zero is due only
+for @expr{x^2}. (The fact that it's not exactly zero is due only
to roundoff error. Since our data are exact integers, we could get
-an exact answer by typing @kbd{m f} first to get fraction mode.
-Then the @cite{x^2} term would vanish altogether. Usually, though,
-the data being fitted will be approximate floats so fraction mode
+an exact answer by typing @kbd{m f} first to get Fraction mode.
+Then the @expr{x^2} term would vanish altogether. Usually, though,
+the data being fitted will be approximate floats so Fraction mode
won't help.)
Doing the @kbd{a F 2} fit on the data set with 14 instead of 13
-gives a much larger @cite{x^2} contribution, as Calc bends the
+gives a much larger @expr{x^2} contribution, as Calc bends the
line slightly to improve the fit.
@example
An important result from the theory of polynomial fitting is that it
is always possible to fit @var{n} data points exactly using a polynomial
-of degree @i{@var{n}-1}, sometimes called an @dfn{interpolating polynomial}.
+of degree @mathit{@var{n}-1}, sometimes called an @dfn{interpolating polynomial}.
Using the modified (14) data matrix, a model number of 4 gives
a polynomial that exactly matches all five data points:
@end example
The actual coefficients we get with a precision of 12, like
-@cite{0.0416666663588}, clearly suffer from loss of precision.
+@expr{0.0416666663588}, clearly suffer from loss of precision.
It is a good idea to increase the working precision to several
digits beyond what you need when you do a fitting operation.
-Or, if your data are exact, use fraction mode to get exact
+Or, if your data are exact, use Fraction mode to get exact
results.
You can type @kbd{i} instead of a digit at the model prompt to fit
@end tex
Another generalization of the linear model is to assume the
-@cite{y} values are a sum of linear contributions from several
-@cite{x} values. This is a @dfn{multilinear} fit, and it is also
+@expr{y} values are a sum of linear contributions from several
+@expr{x} values. This is a @dfn{multilinear} fit, and it is also
selected by the @kbd{1} digit key. (Calc decides whether the fit
is linear or multilinear by counting the rows in the data matrix.)
@end example
@noindent
-the command @kbd{a F 1 @key{RET}} will call the first row @cite{x} and the
-second row @cite{y}, and will fit the values in the third row to the
-model @cite{a + b x + c y}.
+the command @kbd{a F 1 @key{RET}} will call the first row @expr{x} and the
+second row @expr{y}, and will fit the values in the third row to the
+model @expr{a + b x + c y}.
@example
8. + 3. x + 0.5 y
Yet another variation is @dfn{homogeneous} linear models, in which
the constant term is known to be zero. In the linear case, this
-means the model formula is simply @cite{a x}; in the multilinear
-case, the model might be @cite{a x + b y + c z}; and in the polynomial
-case, the model could be @cite{a x + b x^2 + c x^3}. You can get
+means the model formula is simply @expr{a x}; in the multilinear
+case, the model might be @expr{a x + b y + c z}; and in the polynomial
+case, the model could be @expr{a x + b x^2 + c x^3}. You can get
a homogeneous linear or multilinear model by pressing the letter
@kbd{h} followed by a regular model key, like @kbd{1} or @kbd{2}.
It is certainly possible to have other constrained linear models,
-like @cite{2.3 + a x} or @cite{a - 4 x}. While there is no single
+like @expr{2.3 + a x} or @expr{a - 4 x}. While there is no single
key to select models like these, a later section shows how to enter
any desired model by hand. In the first case, for example, you
would enter @kbd{a F ' 2.3 + a x}.
Another class of models that will work but must be entered by hand
-are multinomial fits, e.g., @cite{a + b x + c y + d x^2 + e y^2 + f x y}.
+are multinomial fits, e.g., @expr{a + b x + c y + d x^2 + e y^2 + f x y}.
@node Error Estimates for Fits, Standard Nonlinear Models, Polynomial and Multilinear Fits, Curve Fitting
@subsection Error Estimates for Fits
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
-`@var{y_i}@w{ @t{+/-} }@c{$\sigma_i$}
-@var{sigma_i}', then the @c{$\chi^2$}
-@cite{chi^2}
+@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,
@ifinfo
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 @c{$\sigma_i$}
-@cite{sigma_i} used for
-the data point.
+sum of the squares of the errors forms the
+@texline @math{\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
matrix, although if you are concerned about error analysis you will
probably use @kbd{H a F} so that the output also contains error
estimates.
-If the input contains error forms but all the @c{$\sigma_i$}
-@cite{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 (@c{$\chi^2$}
-@cite{chi^2}
-is simply scaled uniformly by @c{$1 / \sigma^2$}
-@cite{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}.
+If the input contains error forms but all the
+@texline @math{\sigma_i}
+@infoline @expr{sigma_i}
+values are the same, it is easy to see that the resulting fitted model
+will be the same as if the input did not have error forms at all
+@texline (@math{\chi^2}
+@infoline (@expr{chi^2}
+is simply scaled uniformly by
+@texline @math{1 / \sigma^2},
+@infoline @expr{1 / sigma^2},
+which doesn't affect where it has a minimum). But there @emph{will} be
+a difference in the estimated errors of the coefficients reported by
+@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
A vector of ``raw'' parameter values for the model. These are the
polynomial coefficients or other parameters as plain numbers, in the
same order as the parameters appeared in the final prompt of the
-@kbd{I a F} command. For polynomials of degree @cite{d}, this vector
-will have length @cite{M = d+1} with the constant term first.
+@kbd{I a F} command. For polynomials of degree @expr{d}, this vector
+will have length @expr{M = d+1} with the constant term first.
@item
-The covariance matrix @cite{C} computed from the fit. This is
+The covariance matrix @expr{C} computed from the fit. This is
an @var{m}x@var{m} symmetric matrix; the diagonal elements
-@c{$C_{jj}$}
-@cite{C_j_j} are the variances @c{$\sigma_j^2$}
-@cite{sigma_j^2} of the parameters.
-The other elements are covariances @c{$\sigma_{ij}^2$}
-@cite{sigma_i_j^2} that describe the
-correlation between pairs of parameters. (A related set of
-numbers, the @dfn{linear correlation coefficients} @c{$r_{ij}$}
-@cite{r_i_j},
-are defined as @c{$\sigma_{ij}^2 / \sigma_i \, \sigma_j$}
-@cite{sigma_i_j^2 / sigma_i sigma_j}.)
+@texline @math{C_{jj}}
+@infoline @expr{C_j_j}
+are the variances
+@texline @math{\sigma_j^2}
+@infoline @expr{sigma_j^2}
+of the parameters. The other elements are covariances
+@texline @math{\sigma_{ij}^2}
+@infoline @expr{sigma_i_j^2}
+that describe the correlation between pairs of parameters. (A related
+set of numbers, the @dfn{linear correlation coefficients}
+@texline @math{r_{ij}},
+@infoline @expr{r_i_j},
+are defined as
+@texline @math{\sigma_{ij}^2 / \sigma_i \, \sigma_j}.)
+@infoline @expr{sigma_i_j^2 / sigma_i sigma_j}.)
@item
-A vector of @cite{M} ``parameter filter'' functions whose
+A vector of @expr{M} ``parameter filter'' functions whose
meanings are described below. If no filters are necessary this
will instead be an empty vector; this is always the case for the
polynomial and multilinear fits described so far.
@item
-The value of @c{$\chi^2$}
-@cite{chi^2} for the fit, calculated by the formulas
-shown above. This gives a measure of the quality of the fit;
-statisticians consider @c{$\chi^2 \approx N - M$}
-@cite{chi^2 = N - M} to indicate a moderately good fit
-(where again @cite{N} is the number of data points and @cite{M}
-is the number of parameters).
+The value of
+@texline @math{\chi^2}
+@infoline @expr{chi^2}
+for the fit, calculated by the formulas shown above. This gives a
+measure of the quality of the fit; statisticians consider
+@texline @math{\chi^2 \approx N - M}
+@infoline @expr{chi^2 = N - M}
+to indicate a moderately good fit (where again @expr{N} is the number of
+data points and @expr{M} is the number of parameters).
@item
-A measure of goodness of fit expressed as a probability @cite{Q}.
+A measure of goodness of fit expressed as a probability @expr{Q}.
This is computed from the @code{utpc} probability distribution
-function using @c{$\chi^2$}
-@cite{chi^2} with @cite{N - M} degrees of freedom. A
+function using
+@texline @math{\chi^2}
+@infoline @expr{chi^2}
+with @expr{N - M} degrees of freedom. A
value of 0.5 implies a good fit; some texts recommend that often
-@cite{Q = 0.1} or even 0.001 can signify an acceptable fit. In
-particular, @c{$\chi^2$}
-@cite{chi^2} statistics assume the errors in your inputs
+@expr{Q = 0.1} or even 0.001 can signify an acceptable fit. In
+particular,
+@texline @math{\chi^2}
+@infoline @expr{chi^2}
+statistics assume the errors in your inputs
follow a normal (Gaussian) distribution; if they don't, you may
-have to accept smaller values of @cite{Q}.
+have to accept smaller values of @expr{Q}.
-The @cite{Q} value is computed only if the input included error
+The @expr{Q} value is computed only if the input included error
estimates. Otherwise, Calc will report the symbol @code{nan}
-for @cite{Q}. The reason is that in this case the @c{$\chi^2$}
-@cite{chi^2}
+for @expr{Q}. The reason is that in this case the
+@texline @math{\chi^2}
+@infoline @expr{chi^2}
value has effectively been used to estimate the original errors
in the input, and thus there is no redundant information left
over to use for a confidence test.
@table @kbd
@item 1
-Linear or multilinear. @i{a + b x + c y + d z}.
+Linear or multilinear. @mathit{a + b x + c y + d z}.
@item 2-9
-Polynomials. @i{a + b x + c x^2 + d x^3}.
+Polynomials. @mathit{a + b x + c x^2 + d x^3}.
@item e
-Exponential. @i{a} @t{exp}@i{(b x)} @t{exp}@i{(c y)}.
+Exponential. @mathit{a} @tfn{exp}@mathit{(b x)} @tfn{exp}@mathit{(c y)}.
@item E
-Base-10 exponential. @i{a} @t{10^}@i{(b x)} @t{10^}@i{(c y)}.
+Base-10 exponential. @mathit{a} @tfn{10^}@mathit{(b x)} @tfn{10^}@mathit{(c y)}.
@item x
-Exponential (alternate notation). @t{exp}@i{(a + b x + c y)}.
+Exponential (alternate notation). @tfn{exp}@mathit{(a + b x + c y)}.
@item X
-Base-10 exponential (alternate). @t{10^}@i{(a + b x + c y)}.
+Base-10 exponential (alternate). @tfn{10^}@mathit{(a + b x + c y)}.
@item l
-Logarithmic. @i{a + b} @t{ln}@i{(x) + c} @t{ln}@i{(y)}.
+Logarithmic. @mathit{a + b} @tfn{ln}@mathit{(x) + c} @tfn{ln}@mathit{(y)}.
@item L
-Base-10 logarithmic. @i{a + b} @t{log10}@i{(x) + c} @t{log10}@i{(y)}.
+Base-10 logarithmic. @mathit{a + b} @tfn{log10}@mathit{(x) + c} @tfn{log10}@mathit{(y)}.
@item ^
-General exponential. @i{a b^x c^y}.
+General exponential. @mathit{a b^x c^y}.
@item p
-Power law. @i{a x^b y^c}.
+Power law. @mathit{a x^b y^c}.
@item q
-Quadratic. @i{a + b (x-c)^2 + d (x-e)^2}.
+Quadratic. @mathit{a + b (x-c)^2 + d (x-e)^2}.
@item g
-Gaussian. @c{${a \over b \sqrt{2 \pi}} \exp\left( -{1 \over 2} \left( x - c \over b \right)^2 \right)$}
-@i{(a / b sqrt(2 pi)) exp(-0.5*((x-c)/b)^2)}.
+Gaussian.
+@texline @math{{a \over b \sqrt{2 \pi}} \exp\left( -{1 \over 2} \left( x - c \over b \right)^2 \right)}.
+@infoline @mathit{(a / b sqrt(2 pi)) exp(-0.5*((x-c)/b)^2)}.
@end table
All of these models are used in the usual way; just press the appropriate
All models except Gaussian and polynomials can generalize as shown to any
number of independent variables. Also, all the built-in models have an
-additive or multiplicative parameter shown as @cite{a} in the above table
+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.
Note that many of these models are essentially equivalent, but express
-the parameters slightly differently. For example, @cite{a b^x} and
+the parameters slightly differently. For example, @expr{a b^x} and
the other two exponential models are all algebraic rearrangements of
each other. Also, the ``quadratic'' model is just a degree-2 polynomial
with the parameters expressed differently. Use whichever form best
fitting, called @code{LIN}, @code{LOG}, @code{EXP}, and @code{PWR}.
These correspond to Calc models @samp{a + b x}, @samp{a + b ln(x)},
@samp{a exp(b x)}, and @samp{a x^b}, respectively. In each case,
-@cite{a} is what the HP-48 identifies as the ``intercept,'' and
-@cite{b} is what it calls the ``slope.''
+@expr{a} is what the HP-48 identifies as the ``intercept,'' and
+@expr{b} is what it calls the ``slope.''
@tex
\bigskip
formula, such as @kbd{m x - b}, as the model. (Not all models
will work, though---see the next section for details.)
-The model can also be an equation like @cite{y = m x + b}.
+The model can also be an equation like @expr{y = m x + b}.
In this case, Calc thinks of all the rows of the data matrix on
equal terms; this model effectively has two parameters
-(@cite{m} and @cite{b}) and two independent variables (@cite{x}
-and @cite{y}), with no ``dependent'' variables. Model equations
-do not need to take this @cite{y =} form. For example, the
-implicit line equation @cite{a x + b y = 1} works fine as a
+(@expr{m} and @expr{b}) and two independent variables (@expr{x}
+and @expr{y}), with no ``dependent'' variables. Model equations
+do not need to take this @expr{y =} form. For example, the
+implicit line equation @expr{a x + b y = 1} works fine as a
model.
When you enter a model, Calc makes an alphabetical list of all
Calc assumes the dependent variable does not appear in the formula
and thus does not need a name.
-For example, if the model formula has the variables @cite{a,mu,sigma,t,x},
+For example, if the model formula has the variables @expr{a,mu,sigma,t,x},
and the data matrix has three rows (meaning two independent variables),
-Calc will use @cite{a,mu,sigma} as the default parameters, and the
-data rows will be named @cite{t} and @cite{x}, respectively. If you
-enter an equation instead of a plain formula, Calc will use @cite{a,mu}
-as the parameters, and @cite{sigma,t,x} as the three independent
+Calc will use @expr{a,mu,sigma} as the default parameters, and the
+data rows will be named @expr{t} and @expr{x}, respectively. If you
+enter an equation instead of a plain formula, Calc will use @expr{a,mu}
+as the parameters, and @expr{sigma,t,x} as the three independent
variables.
You can, of course, override these choices by entering something
which are parameters.
Models taken from the stack can also be expressed as vectors of
-two or three elements, @cite{[@var{model}, @var{vars}]} or
-@cite{[@var{model}, @var{vars}, @var{params}]}. Each of @var{vars}
+two or three elements, @expr{[@var{model}, @var{vars}]} or
+@expr{[@var{model}, @var{vars}, @var{params}]}. Each of @var{vars}
and @var{params} may be either a variable or a vector of variables.
(If @var{params} is omitted, all variables in @var{model} except
-those listed as @var{vars} are parameters.)@refill
+those listed as @var{vars} are parameters.)
When you enter a model manually with @kbd{'}, Calc puts a 3-vector
describing the model in the trail so you can get it back if you wish.
and @code{arcsin} when doing fits. For example, when you enter
the model @samp{y = sin(a t + b)} Calc actually uses the easier
form @samp{arcsin(y) = a t + b}. The @code{arcsin} function always
-returns results in the range from @i{-90} to 90 degrees (or the
+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 @c{$3\times360$}
-@i{3*360} degrees.
+so that the argument of the sine might go from zero to
+@texline @math{3\times360}
+@infoline @mathit{3*360}
+degrees.
The above model would appear to be a good way to determine the
true frequency and phase of the sine wave, but in practice it
would fail utterly. The righthand side of the actual model
-@samp{arcsin(y) = a t + b} will grow smoothly with @cite{t}, but
-the lefthand side will bounce back and forth between @i{-90} and 90.
-No values of @cite{a} and @cite{b} can make the two sides match,
+@samp{arcsin(y) = a t + b} will grow smoothly with @expr{t}, but
+the lefthand side will bounce back and forth between @mathit{-90} and 90.
+No values of @expr{a} and @expr{b} can make the two sides match,
even approximately.
There is no good solution to this problem at present. You could
@noindent
Calc's internal least-squares fitter can only handle multilinear
models. More precisely, it can handle any model of the form
-@cite{a f(x,y,z) + b g(x,y,z) + c h(x,y,z)}, where @cite{a,b,c}
-are the parameters and @cite{x,y,z} are the independent variables
+@expr{a f(x,y,z) + b g(x,y,z) + c h(x,y,z)}, where @expr{a,b,c}
+are the parameters and @expr{x,y,z} are the independent variables
(of course there can be any number of each, not just three).
In a simple multilinear or polynomial fit, it is easy to see how
to convert the model into this form. For example, if the model
-is @cite{a + b x + c x^2}, then @cite{f(x) = 1}, @cite{g(x) = x},
-and @cite{h(x) = x^2} are suitable functions.
+is @expr{a + b x + c x^2}, then @expr{f(x) = 1}, @expr{g(x) = x},
+and @expr{h(x) = x^2} are suitable functions.
For other models, Calc uses a variety of algebraic manipulations
to try to put the problem into the form
@end smallexample
@noindent
-where @cite{Y,A,B,C,F,G,H} are arbitrary functions. It computes
-@cite{Y}, @cite{F}, @cite{G}, and @cite{H} for all the data points,
-does a standard linear fit to find the values of @cite{A}, @cite{B},
-and @cite{C}, then uses the equation solver to solve for @cite{a,b,c}
-in terms of @cite{A,B,C}.
+where @expr{Y,A,B,C,F,G,H} are arbitrary functions. It computes
+@expr{Y}, @expr{F}, @expr{G}, and @expr{H} for all the data points,
+does a standard linear fit to find the values of @expr{A}, @expr{B},
+and @expr{C}, then uses the equation solver to solve for @expr{a,b,c}
+in terms of @expr{A,B,C}.
A remarkable number of models can be cast into this general form.
We'll look at two examples here to see how it works. The power-law
-model @cite{y = a x^b} with two independent variables and two parameters
+model @expr{y = a x^b} with two independent variables and two parameters
can be rewritten as follows:
@example
@end example
@noindent
-which matches the desired form with @c{$Y = \ln(y)$}
-@cite{Y = ln(y)}, @c{$A = \ln(a)$}
-@cite{A = ln(a)},
-@cite{F = 1}, @cite{B = b}, and @c{$G = \ln(x)$}
-@cite{G = ln(x)}. Calc thus computes
-the logarithms of your @cite{y} and @cite{x} values, does a linear fit
-for @cite{A} and @cite{B}, then solves to get @c{$a = \exp(A)$}
-@cite{a = exp(A)} and
-@cite{b = B}.
+which matches the desired form with
+@texline @math{Y = \ln(y)},
+@infoline @expr{Y = ln(y)},
+@texline @math{A = \ln(a)},
+@infoline @expr{A = ln(a)},
+@expr{F = 1}, @expr{B = b}, and
+@texline @math{G = \ln(x)}.
+@infoline @expr{G = ln(x)}.
+Calc thus computes the logarithms of your @expr{y} and @expr{x} values,
+does a linear fit for @expr{A} and @expr{B}, then solves to get
+@texline @math{a = \exp(A)}
+@infoline @expr{a = exp(A)}
+and @expr{b = B}.
Another interesting example is the ``quadratic'' model, which can
be handled by expanding according to the distributive law.
@end example
@noindent
-which matches with @cite{Y = y}, @cite{A = a + b c^2}, @cite{F = 1},
-@cite{B = -2 b c}, @cite{G = x} (the @i{-2} factor could just as easily
-have been put into @cite{G} instead of @cite{B}), @cite{C = b}, and
-@cite{H = x^2}.
+which matches with @expr{Y = y}, @expr{A = a + b c^2}, @expr{F = 1},
+@expr{B = -2 b c}, @expr{G = x} (the @mathit{-2} factor could just as easily
+have been put into @expr{G} instead of @expr{B}), @expr{C = b}, and
+@expr{H = x^2}.
The Gaussian model looks quite complicated, but a closer examination
shows that it's actually similar to the quadratic model but with an
-exponential that can be brought to the top and moved into @cite{Y}.
+exponential that can be brought to the top and moved into @expr{Y}.
An example of a model that cannot be put into general linear
form is a Gaussian with a constant background added on, i.e.,
-@cite{d} + the regular Gaussian formula. If you have a model like
+@expr{d} + the regular Gaussian formula. If you have a model like
this, your best bet is to replace enough of your parameters with
constants to make the model linearizable, then adjust the constants
manually by doing a series of fits. You can compare the fits by
graphing them, by examining the goodness-of-fit measures returned by
@kbd{I a F}, or by some other method suitable to your application.
Note that some models can be linearized in several ways. The
-Gaussian-plus-@var{d} model can be linearized by setting @cite{d}
-(the background) to a constant, or by setting @cite{b} (the standard
-deviation) and @cite{c} (the mean) to constants.
+Gaussian-plus-@var{d} model can be linearized by setting @expr{d}
+(the background) to a constant, or by setting @expr{b} (the standard
+deviation) and @expr{c} (the mean) to constants.
To fit a model with constants substituted for some parameters, just
store suitable values in those parameter variables, then omit them
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 @c{$\chi^2$}
-@cite{chi^2}
+functions solve the problem of minimizing an expression (the
+@texline @math{\chi^2}
+@infoline @expr{chi^2}
sum) by adjusting certain parameters in the expression. The @kbd{a F}
command is able to use a vastly more efficient algorithm due to its
special knowledge about linear chi-square sums, but the @kbd{a N}
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 @c{$\chi^2$}
-@cite{chi^2} returned as
-the fifth result of the @code{xfit} function:
+to be minimized would be the value of
+@texline @math{\chi^2}
+@infoline @expr{chi^2}
+returned as the fifth result of the @code{xfit} function:
@smallexample
minimize(xfit(gaus(a,b,c,d,x), x, [a,b,c], data)_5, d, guess)
@noindent
where @code{gaus} represents the Gaussian model with background,
@code{data} represents the data matrix, and @code{guess} represents
-the initial guess for @cite{d} that @code{minimize} requires.
+the initial guess for @expr{d} that @code{minimize} requires.
This operation will only be, shall we say, extraordinarily slow
rather than astronomically slow (as would be the case if @code{minimize}
were used by itself to solve the problem).
The @kbd{I a F} [@code{xfit}] command is somewhat trickier when
nonlinear models are used. The second item in the result is the
-vector of ``raw'' parameters @cite{A}, @cite{B}, @cite{C}. The
+vector of ``raw'' parameters @expr{A}, @expr{B}, @expr{C}. The
covariance matrix is written in terms of those raw parameters.
The fifth item is a vector of @dfn{filter} expressions. This
is the empty vector @samp{[]} if the raw parameters were the same
-as the requested parameters, i.e., if @cite{A = a}, @cite{B = b},
+as the requested parameters, i.e., if @expr{A = a}, @expr{B = b},
and so on (which is always true if the model is already linear
in the parameters as written, e.g., for polynomial fits). If the
parameters had to be rearranged, the fifth item is instead a vector
of one formula per parameter in the original model. The raw
parameters are expressed in these ``filter'' formulas as
-@samp{fitdummy(1)} for @cite{A}, @samp{fitdummy(2)} for @cite{B},
+@samp{fitdummy(1)} for @expr{A}, @samp{fitdummy(2)} for @expr{B},
and so on.
When Calc needs to modify the model to return the result, it replaces
nontrivial filter functions.
Things are also complicated when the input contains error forms.
-Suppose there are three independent and dependent variables, @cite{x},
-@cite{y}, and @cite{z}, one or more of which are error forms in the
+Suppose there are three independent and dependent variables, @expr{x},
+@expr{y}, and @expr{z}, one or more of which are error forms in the
data. Calc combines all the error values by taking the square root
-of the sum of the squares of the errors. It then changes @cite{x}
-and @cite{y} to be plain numbers, and makes @cite{z} into an error
-form with this combined error. The @cite{Y(x,y,z)} part of the
+of the sum of the squares of the errors. It then changes @expr{x}
+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 @c{$\sigma_i$}
-@cite{sigma_i} for
-the data point. If for some reason @cite{Y(x,y,z)} does not return
-an error form, the combined error from @cite{z} is used directly
-for @c{$\sigma_i$}
-@cite{sigma_i}. Finally, @cite{z} is also stripped of its error
-for use in computing @cite{F(x,y,z)}, @cite{G(x,y,z)} and so on;
+form. The error part of that result is used for
+@texline @math{\sigma_i}
+@infoline @expr{sigma_i}
+for the data point. If for some reason @expr{Y(x,y,z)} does not return
+an error form, the combined error from @expr{z} is used directly for
+@texline @math{\sigma_i}.
+@infoline @expr{sigma_i}.
+Finally, @expr{z} is also stripped of its error
+for use in computing @expr{F(x,y,z)}, @expr{G(x,y,z)} and so on;
the righthand side of the linearized model is computed in regular
arithmetic with no error forms.
(While these rules may seem complicated, they are designed to do
-the most reasonable thing in the typical case that @cite{Y(x,y,z)}
-depends only on the dependent variable @cite{z}, and in fact is
-often simply equal to @cite{z}. For common cases like polynomials
+the most reasonable thing in the typical case that @expr{Y(x,y,z)}
+depends only on the dependent variable @expr{z}, and in fact is
+often simply equal to @expr{z}. For common cases like polynomials
and multilinear models, the combined error is simply used as the
-@c{$\sigma$}
-@cite{sigma} for the data point with no further ado.)
+@texline @math{\sigma}
+@infoline @expr{sigma}
+for the data point with no further ado.)
@tex
\bigskip
@samp{fitparam(2)}, and so on, and independent variables are renamed
to @samp{fitvar(1)}, @samp{fitvar(2)}, etc. The dependent variable
is the highest-numbered @code{fitvar}. For example, the power law
-model @cite{a x^b} is converted to @cite{y = a x^b}, then to
+model @expr{a x^b} is converted to @expr{y = a x^b}, then to
@smallexample
@group
@end example
@noindent
-where @var{Y} is a formula that describes the function @cite{Y(x,y,z)},
-@var{FGH} is the vector of formulas @cite{[F(x,y,z), G(x,y,z), H(x,y,z)]},
+where @var{Y} is a formula that describes the function @expr{Y(x,y,z)},
+@var{FGH} is the vector of formulas @expr{[F(x,y,z), G(x,y,z), H(x,y,z)]},
and @var{abc} is the vector of parameter filters which refer to the
-raw parameters as @samp{fitdummy(1)} for @cite{A}, @samp{fitdummy(2)}
-for @cite{B}, etc. While the number of raw parameters (the length of
+raw parameters as @samp{fitdummy(1)} for @expr{A}, @samp{fitdummy(2)}
+for @expr{B}, etc. While the number of raw parameters (the length of
the @var{FGH} vector) is usually the same as the number of original
parameters (the length of the @var{abc} vector), this is not required.
non-constant powers are converted to logs-and-exponentials form,
and the distributive law is used to expand products of sums.
Quotients are rewritten to use the @samp{fitinv} function, where
-@samp{fitinv(x)} represents @cite{1/x} while the @code{FitRules}
+@samp{fitinv(x)} represents @expr{1/x} while the @code{FitRules}
are operating. (The use of @code{fitinv} makes recognition of
linear-looking forms easier.) If you modify @code{FitRules}, you
will probably only need to modify the rules for this phase.
Phase two, whose rules can actually also apply during phases one
and three, first rewrites @code{fitmodel} to a two-argument
form @samp{fitmodel(@var{Y}, @var{model})}, where @var{Y} is
-initially zero and @var{model} has been changed from @cite{a=b}
-to @cite{a-b} form. It then tries to peel off invertible functions
+initially zero and @var{model} has been changed from @expr{a=b}
+to @expr{a-b} form. It then tries to peel off invertible functions
from the outside of @var{model} and put them into @var{Y} instead,
calling the equation solver to invert the functions. Finally, when
this is no longer possible, the @code{fitmodel} is changed to a
@tindex hasfitvars
Two functions which are useful in connection with @code{FitRules}
are @samp{hasfitparams(x)} and @samp{hasfitvars(x)}, which check
-whether @cite{x} refers to any parameters or independent variables,
+whether @expr{x} refers to any parameters or independent variables,
respectively. Specifically, these functions return ``true'' if the
argument contains any @code{fitparam} (or @code{fitvar}) function
calls, and ``false'' otherwise. (Recall that ``true'' means a
@pindex calc-poly-interp
@tindex polint
The @kbd{a p} (@code{calc-poly-interp}) [@code{polint}] command does
-a polynomial interpolation at a particular @cite{x} value. It takes
+a polynomial interpolation at a particular @expr{x} value. It takes
two arguments from the stack: A data matrix of the sort used by
-@kbd{a F}, and a single number which represents the desired @cite{x}
+@kbd{a F}, and a single number which represents the desired @expr{x}
value. Calc effectively does an exact polynomial fit as if by @kbd{a F i},
-then substitutes the @cite{x} value into the result in order to get an
-approximate @cite{y} value based on the fit. (Calc does not actually
+then substitutes the @expr{x} value into the result in order to get an
+approximate @expr{y} value based on the fit. (Calc does not actually
use @kbd{a F i}, however; it uses a direct method which is both more
efficient and more numerically stable.)
-The result of @kbd{a p} is actually a vector of two values: The @cite{y}
-value approximation, and an error measure @cite{dy} that reflects Calc's
+The result of @kbd{a p} is actually a vector of two values: The @expr{y}
+value approximation, and an error measure @expr{dy} that reflects Calc's
estimation of the probable error of the approximation at that value of
-@cite{x}. If the input @cite{x} is equal to any of the @cite{x} values
-in the data matrix, the output @cite{y} will be the corresponding @cite{y}
-value from the matrix, and the output @cite{dy} will be exactly zero.
+@expr{x}. If the input @expr{x} is equal to any of the @expr{x} values
+in the data matrix, the output @expr{y} will be the corresponding @expr{y}
+value from the matrix, and the output @expr{dy} will be exactly zero.
A prefix argument of 2 causes @kbd{a p} to take separate x- and
y-vectors from the stack instead of one data matrix.
-If @cite{x} is a vector of numbers, @kbd{a p} will return a matrix of
-interpolated results for each of those @cite{x} values. (The matrix will
-have two columns, the @cite{y} values and the @cite{dy} values.)
-If @cite{x} is a formula instead of a number, the @code{polint} function
+If @expr{x} is a vector of numbers, @kbd{a p} will return a matrix of
+interpolated results for each of those @expr{x} values. (The matrix will
+have two columns, the @expr{y} values and the @expr{dy} values.)
+If @expr{x} is a formula instead of a number, the @code{polint} function
remains in symbolic form; use the @kbd{a "} command to expand it out to
a formula that describes the fit in symbolic terms.
In all cases, the @kbd{a p} command leaves the data vectors or matrix
-on the stack. Only the @cite{x} value is replaced by the result.
+on the stack. Only the @expr{x} value is replaced by the result.
@kindex H a p
@tindex ratint
The @kbd{H a p} [@code{ratint}] command does a rational function
interpolation. It is used exactly like @kbd{a p}, except that it
uses as its model the quotient of two polynomials. If there are
-@cite{N} data points, the numerator and denominator polynomials will
-each have degree @cite{N/2} (if @cite{N} is odd, the denominator will
+@expr{N} data points, the numerator and denominator polynomials will
+each have degree @expr{N/2} (if @expr{N} is odd, the denominator will
have degree one higher than the numerator).
Rational approximations have the advantage that they can accurately
describe functions that have poles (points at which the function's value
goes to infinity, so that the denominator polynomial of the approximation
-goes to zero). If @cite{x} corresponds to a pole of the fitted rational
+goes to zero). If @expr{x} corresponds to a pole of the fitted rational
function, then the result will be a division by zero. If Infinite mode
is enabled, the result will be @samp{[uinf, uinf]}.
The choice of index variable is arbitrary, but it's best not to
use a variable with a stored value. In particular, while
@code{i} is often a favorite index variable, it should be avoided
-in Calc because @code{i} has the imaginary constant @cite{(0, 1)}
+in Calc because @code{i} has the imaginary constant @expr{(0, 1)}
as a value. If you pressed @kbd{=} on a sum over @code{i}, it would
-be changed to a nonsensical sum over the ``variable'' @cite{(0, 1)}!
+be changed to a nonsensical sum over the ``variable'' @expr{(0, 1)}!
If you really want to use @code{i} as an index variable, use
@w{@kbd{s u i @key{RET}}} first to ``unstore'' this variable.
(@xref{Storing Variables}.)
and @samp{inf}, respectively.
Infinite sums can sometimes be evaluated: @samp{sum(.5^k, k, 1, inf)}
-returns @cite{1}. This is done by evaluating the sum in closed
+returns @expr{1}. This is done by evaluating the sum in closed
form (to @samp{1. - 0.5^n} in this case), then evaluating this
formula with @code{n} set to @code{inf}. Calc's usual rules
for ``infinite'' arithmetic can find the answer from there. If
described above) but the formula includes vectors subscripted by
expressions that involve the iteration variable, Calc narrows
the limits to include only the range of integers which result in
-legal subscripts for the vector. For example, the sum
+valid subscripts for the vector. For example, the sum
@samp{sum(k [a,b,c,d,e,f,g]_(2k),k)} evaluates to @samp{b + 2 d + 3 f}.
The limits of a sum do not need to be integers. For example,
after simplification as if by @kbd{a s}, evaluate to an integer.
If the number of iterations according to the above formula does
-not come out to an integer, the sum is illegal and will be left
+not come out to an integer, the sum is invalid and will be left
in symbolic form. However, closed forms are still supplied, and
you are on your honor not to misuse the resulting formulas by
substituting mismatched bounds into them. For example,
positive step size), the result is generally zero. However,
Calc only guarantees a zero result when the upper limit is
exactly one step less than the lower limit, i.e., if the number
-of iterations is @i{-1}. Thus @samp{sum(f(k), k, n, n-1)} is zero
+of iterations is @mathit{-1}. Thus @samp{sum(f(k), k, n, n-1)} is zero
but the sum from @samp{n} to @samp{n-2} may report a nonzero value
if Calc used a closed form solution.
-Calc's logical predicates like @cite{a < b} return 1 for ``true''
+Calc's logical predicates like @expr{a < b} return 1 for ``true''
and 0 for ``false.'' @xref{Logical Operations}. This can be
used to advantage for building conditional sums. For example,
@samp{sum(prime(k)*k^2, k, 1, 20)} is the sum of the squares of all
prime numbers from 1 to 20; the @code{prime} predicate returns 1 if
its argument is prime and 0 otherwise. You can read this expression
-as ``the sum of @cite{k^2}, where @cite{k} is prime.'' Indeed,
+as ``the sum of @expr{k^2}, where @expr{k} is prime.'' Indeed,
@samp{sum(prime(k)*k^2, k)} would represent the sum of @emph{all} primes
squared, since the limits default to plus and minus infinity, but
there are no such sums that Calc's built-in rules can do in
closed form.
As another example, @samp{sum((k != k_0) * f(k), k, 1, n)} is the
-sum of @cite{f(k)} for all @cite{k} from 1 to @cite{n}, excluding
-one value @cite{k_0}. Slightly more tricky is the summand
+sum of @expr{f(k)} for all @expr{k} from 1 to @expr{n}, excluding
+one value @expr{k_0}. Slightly more tricky is the summand
@samp{(k != k_0) / (k - k_0)}, which is an attempt to describe
-the sum of all @cite{1/(k-k_0)} except at @cite{k = k_0}, where
-this would be a division by zero. But at @cite{k = k_0}, this
-formula works out to the indeterminate form @cite{0 / 0}, which
+the sum of all @expr{1/(k-k_0)} except at @expr{k = k_0}, where
+this would be a division by zero. But at @expr{k = k_0}, this
+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 @c{$k \ne k_0$}
-@cite{k != k_0},
-then @cite{1/(k-k_0)}, else zero.'' Now the formula @cite{1/(k-k_0)}
-will not even be evaluated by Calc when @cite{k = k_0}.
+an ``if-then-else'' test: This expression says, ``if
+@texline @math{k \ne k_0},
+@infoline @expr{k != k_0},
+then @expr{1/(k-k_0)}, else zero.'' Now the formula @expr{1/(k-k_0)}
+will not even be evaluated by Calc when @expr{k = k_0}.
@cindex Alternating sums
@kindex a -
which @code{dnonzero} returns 0 or cannot decide is assumed ``false.''
Note that this means that @w{@kbd{Z [ Z ]}} will execute the ``then''
portion if its condition is provably true, but it will execute the
-``else'' portion for any condition like @cite{a = b} that is not
+``else'' portion for any condition like @expr{a = b} that is not
provably true, even if it might be true. Algebraic functions that
have conditions as arguments, like @code{? :} and @code{&&}, remain
unevaluated if the condition is neither provably true nor provably
@tindex ==
The @kbd{a =} (@code{calc-equal-to}) command, or @samp{eq(a,b)} function
(which can also be written @samp{a = b} or @samp{a == b} in an algebraic
-formula) is true if @cite{a} and @cite{b} are equal, either because they
+formula) is true if @expr{a} and @expr{b} are equal, either because they
are identical expressions, or because they are numbers which are
numerically equal. (Thus the integer 1 is considered equal to the float
-1.0.) If the equality of @cite{a} and @cite{b} cannot be determined,
+1.0.) If the equality of @expr{a} and @expr{b} cannot be determined,
the comparison is left in symbolic form. Note that as a command, this
operation pops two values from the stack and pushes back either a 1 or
a 0, or a formula @samp{a = b} if the values' equality cannot be determined.
@tindex neq
@tindex !=
The @kbd{a #} (@code{calc-not-equal-to}) command, or @samp{neq(a,b)} or
-@samp{a != b} function, is true if @cite{a} and @cite{b} are not equal.
+@samp{a != b} function, is true if @expr{a} and @expr{b} are not equal.
This also works with more than two arguments; @samp{a != b != c != d}
-tests that all four of @cite{a}, @cite{b}, @cite{c}, and @cite{d} are
+tests that all four of @expr{a}, @expr{b}, @expr{c}, and @expr{d} are
distinct numbers.
@kindex a <
@end ignore
@tindex >=
The @kbd{a <} (@code{calc-less-than}) [@samp{lt(a,b)} or @samp{a < b}]
-operation is true if @cite{a} is less than @cite{b}. Similar functions
+operation is true if @expr{a} is less than @expr{b}. Similar functions
are @kbd{a >} (@code{calc-greater-than}) [@samp{gt(a,b)} or @samp{a > b}],
@kbd{a [} (@code{calc-less-equal}) [@samp{leq(a,b)} or @samp{a <= b}], and
@kbd{a ]} (@code{calc-greater-equal}) [@samp{geq(a,b)} or @samp{a >= b}].
variable and the lefthand side is a number (as in @samp{2.34 = x}), then
Calc keeps the lefthand side instead. Finally, this command works with
assignments @samp{x := 2.34} as well as equations, always taking the
-the righthand side, and for @samp{=>} (evaluates-to) operators, always
+righthand side, and for @samp{=>} (evaluates-to) operators, always
taking the lefthand side.
@kindex a &
@tindex &&
The @kbd{a &} (@code{calc-logical-and}) [@samp{land(a,b)} or @samp{a && b}]
function is true if both of its arguments are true, i.e., are
-non-zero numbers. In this case, the result will be either @cite{a} or
-@cite{b}, chosen arbitrarily. If either argument is zero, the result is
+non-zero numbers. In this case, the result will be either @expr{a} or
+@expr{b}, chosen arbitrarily. If either argument is zero, the result is
zero. Otherwise, the formula is left in symbolic form.
@kindex a |
The @kbd{a |} (@code{calc-logical-or}) [@samp{lor(a,b)} or @samp{a || b}]
function is true if either or both of its arguments are true (nonzero).
The result is whichever argument was nonzero, choosing arbitrarily if both
-are nonzero. If both @cite{a} and @cite{b} are zero, the result is
+are nonzero. If both @expr{a} and @expr{b} are zero, the result is
zero.
@kindex a !
@tindex lnot
@tindex !
The @kbd{a !} (@code{calc-logical-not}) [@samp{lnot(a)} or @samp{!@: a}]
-function is true if @cite{a} is false (zero), or false if @cite{a} is
-true (nonzero). It is left in symbolic form if @cite{a} is not a
+function is true if @expr{a} is false (zero), or false if @expr{a} is
+true (nonzero). It is left in symbolic form if @expr{a} is not a
number.
@kindex a :
@tindex :
@cindex Arguments, not evaluated
The @kbd{a :} (@code{calc-logical-if}) [@samp{if(a,b,c)} or @samp{a ? b :@: c}]
-function is equal to either @cite{b} or @cite{c} if @cite{a} is a nonzero
-number or zero, respectively. If @cite{a} is not a number, the test is
-left in symbolic form and neither @cite{b} nor @cite{c} is evaluated in
+function is equal to either @expr{b} or @expr{c} if @expr{a} is a nonzero
+number or zero, respectively. If @expr{a} is not a number, the test is
+left in symbolic form and neither @expr{b} nor @expr{c} is evaluated in
any way. In algebraic formulas, this is one of the few Calc functions
whose arguments are not automatically evaluated when the function itself
is evaluated. The others are @code{lambda}, @code{quote}, and
as three separate symbols. Type something like @samp{a ? 3 : 4} or
@samp{a?(3):4} instead.
-As a special case, if @cite{a} evaluates to a vector, then both @cite{b}
-and @cite{c} are evaluated; the result is a vector of the same length
-as @cite{a} whose elements are chosen from corresponding elements of
-@cite{b} and @cite{c} according to whether each element of @cite{a}
-is zero or nonzero. Each of @cite{b} and @cite{c} must be either a
-vector of the same length as @cite{a}, or a non-vector which is matched
-with all elements of @cite{a}.
+As a special case, if @expr{a} evaluates to a vector, then both @expr{b}
+and @expr{c} are evaluated; the result is a vector of the same length
+as @expr{a} whose elements are chosen from corresponding elements of
+@expr{b} and @expr{c} according to whether each element of @expr{a}
+is zero or nonzero. Each of @expr{b} and @expr{c} must be either a
+vector of the same length as @expr{a}, or a non-vector which is matched
+with all elements of @expr{a}.
@kindex a @{
@pindex calc-in-set
@tindex in
The @kbd{a @{} (@code{calc-in-set}) [@samp{in(a,b)}] function is true if
-the number @cite{a} is in the set of numbers represented by @cite{b}.
-If @cite{b} is an interval form, @cite{a} must be one of the values
-encompassed by the interval. If @cite{b} is a vector, @cite{a} must be
+the number @expr{a} is in the set of numbers represented by @expr{b}.
+If @expr{b} is an interval form, @expr{a} must be one of the values
+encompassed by the interval. If @expr{b} is a vector, @expr{a} must be
equal to one of the elements of the vector. (If any vector elements are
-intervals, @cite{a} must be in any of the intervals.) If @cite{b} is a
-plain number, @cite{a} must be numerically equal to @cite{b}.
+intervals, @expr{a} must be in any of the intervals.) If @expr{b} is a
+plain number, @expr{a} must be numerically equal to @expr{b}.
@xref{Set Operations}, for a group of commands that manipulate sets
of this sort.
@end ignore
@tindex typeof
The @samp{typeof(a)} function produces an integer or variable which
-characterizes @cite{a}. If @cite{a} is a number, vector, or variable,
+characterizes @expr{a}. If @expr{a} is a number, vector, or variable,
the result will be one of the following numbers:
@example
102 Matrix
@end example
-Otherwise, @cite{a} is a formula, and the result is a variable which
+Otherwise, @expr{a} is a formula, and the result is a variable which
represents the name of the top-level function call.
@ignore
@starindex
@end ignore
@tindex constant
-The @samp{integer(a)} function returns true if @cite{a} is an integer.
+The @samp{integer(a)} function returns true if @expr{a} is an integer.
The @samp{real(a)} function
-is true if @cite{a} is a real number, either integer, fraction, or
-float. The @samp{constant(a)} function returns true if @cite{a} is
+is true if @expr{a} is a real number, either integer, fraction, or
+float. The @samp{constant(a)} function returns true if @expr{a} is
any of the objects for which @code{typeof} would produce an integer
code result except for variables, and provided that the components of
an object like a vector or error form are themselves constant.
Note that infinities do not satisfy any of these tests, nor do
-special constants like @code{pi} and @code{e}.@refill
+special constants like @code{pi} and @code{e}.
@xref{Declarations}, for a set of similar functions that recognize
formulas as well as actual numbers. For example, @samp{dint(floor(x))}
@end ignore
@tindex refers
The @samp{refers(a,b)} function is true if the variable (or sub-expression)
-@cite{b} appears in @cite{a}, or false otherwise. Unlike the other
+@expr{b} appears in @expr{a}, or false otherwise. Unlike the other
tests described here, this function returns a definite ``no'' answer
even if its arguments are still in symbolic form. The only case where
-@code{refers} will be left unevaluated is if @cite{a} is a plain
-variable (different from @cite{b}).
+@code{refers} will be left unevaluated is if @expr{a} is a plain
+variable (different from @expr{b}).
@ignore
@starindex
@end ignore
@tindex negative
-The @samp{negative(a)} function returns true if @cite{a} ``looks'' negative,
-because it is a negative number, because it is of the form @cite{-x},
+The @samp{negative(a)} function returns true if @expr{a} ``looks'' negative,
+because it is a negative number, because it is of the form @expr{-x},
or because it is a product or quotient with a term that looks negative.
This is most useful in rewrite rules. Beware that @samp{negative(a)}
-evaluates to 1 or 0 for @emph{any} argument @cite{a}, so it can only
+evaluates to 1 or 0 for @emph{any} argument @expr{a}, so it can only
be stored in a formula if the default simplifications are turned off
first with @kbd{m O} (or if it appears in an unevaluated context such
as a rewrite rule condition).
@starindex
@end ignore
@tindex variable
-The @samp{variable(a)} function is true if @cite{a} is a variable,
-or false if not. If @cite{a} is a function call, this test is left
+The @samp{variable(a)} function is true if @expr{a} is a variable,
+or false if not. If @expr{a} is a function call, this test is left
in symbolic form. Built-in variables like @code{pi} and @code{inf}
are considered variables like any others by this test.
@starindex
@end ignore
@tindex nonvar
-The @samp{nonvar(a)} function is true if @cite{a} is a non-variable.
+The @samp{nonvar(a)} function is true if @expr{a} is a non-variable.
If its argument is a variable it is left unsimplified; it never
actually returns zero. However, since Calc's condition-testing
commands consider ``false'' anything not provably true, this is
@cindex Linearity testing
The functions @code{lin}, @code{linnt}, @code{islin}, and @code{islinnt}
check if an expression is ``linear,'' i.e., can be written in the form
-@cite{a + b x} for some constants @cite{a} and @cite{b}, and some
-variable or subformula @cite{x}. The function @samp{islin(f,x)} checks
-if formula @cite{f} is linear in @cite{x}, returning 1 if so. For
+@expr{a + b x} for some constants @expr{a} and @expr{b}, and some
+variable or subformula @expr{x}. The function @samp{islin(f,x)} checks
+if formula @expr{f} is linear in @expr{x}, returning 1 if so. For
example, @samp{islin(x,x)}, @samp{islin(-x,x)}, @samp{islin(3,x)}, and
@samp{islin(x y / 3 - 2, x)} all return 1. The @samp{lin(f,x)} function
is similar, except that instead of returning 1 it returns the vector
-@cite{[a, b, x]}. For the above examples, this vector would be
-@cite{[0, 1, x]}, @cite{[0, -1, x]}, @cite{[3, 0, x]}, and
-@cite{[-2, y/3, x]}, respectively. Both @code{lin} and @code{islin}
+@expr{[a, b, x]}. For the above examples, this vector would be
+@expr{[0, 1, x]}, @expr{[0, -1, x]}, @expr{[3, 0, x]}, and
+@expr{[-2, y/3, x]}, respectively. Both @code{lin} and @code{islin}
generally remain unevaluated for expressions which are not linear,
e.g., @samp{lin(2 x^2, x)} and @samp{lin(sin(x), x)}. The second
argument can also be a formula; @samp{islin(2 + 3 sin(x), sin(x))}
The @code{linnt} and @code{islinnt} functions perform a similar check,
but require a ``non-trivial'' linear form, which means that the
-@cite{b} coefficient must be non-zero. For example, @samp{lin(2,x)}
-returns @cite{[2, 0, x]} and @samp{lin(y,x)} returns @cite{[y, 0, x]},
+@expr{b} coefficient must be non-zero. For example, @samp{lin(2,x)}
+returns @expr{[2, 0, x]} and @samp{lin(y,x)} returns @expr{[y, 0, x]},
but @samp{linnt(2,x)} and @samp{linnt(y,x)} are left unevaluated
(in other words, these formulas are considered to be only ``trivially''
-linear in @cite{x}).
+linear in @expr{x}).
All four linearity-testing functions allow you to omit the second
argument, in which case the input may be linear in any non-constant
-formula. Here, the @cite{a=0}, @cite{b=1} case is also considered
-trivial, and only constant values for @cite{a} and @cite{b} are
-recognized. Thus, @samp{lin(2 x y)} returns @cite{[0, 2, x y]},
-@samp{lin(2 - x y)} returns @cite{[2, -1, x y]}, and @samp{lin(x y)}
-returns @cite{[0, 1, x y]}. The @code{linnt} function would allow the
+formula. Here, the @expr{a=0}, @expr{b=1} case is also considered
+trivial, and only constant values for @expr{a} and @expr{b} are
+recognized. Thus, @samp{lin(2 x y)} returns @expr{[0, 2, x y]},
+@samp{lin(2 - x y)} returns @expr{[2, -1, x y]}, and @samp{lin(x y)}
+returns @expr{[0, 1, x y]}. The @code{linnt} function would allow the
first two cases but not the third. Also, neither @code{lin} nor
@code{linnt} accept plain constants as linear in the one-argument
case: @samp{islin(2,x)} is true, but @samp{islin(2)} is false.
@starindex
@end ignore
@tindex istrue
-The @samp{istrue(a)} function returns 1 if @cite{a} is a nonzero
-number or provably nonzero formula, or 0 if @cite{a} is anything else.
+The @samp{istrue(a)} function returns 1 if @expr{a} is a nonzero
+number or provably nonzero formula, or 0 if @expr{a} is anything else.
Calls to @code{istrue} can only be manipulated if @kbd{m O} mode is
used to make sure they are not evaluated prematurely. (Note that
declarations are used when deciding whether a formula is true;
The @code{assign} function is undefined by itself in Calc, so an
assignment formula such as a rewrite rule will be left alone by ordinary
Calc commands. But certain commands, like the rewrite system, interpret
-assignments in special ways.@refill
+assignments in special ways.
For example, the rule @samp{sin(x)^2 := 1-cos(x)^2} says to replace
every occurrence of the sine of something, squared, with one minus the
(@code{calc-edit-variable}) command is an easy way to create or edit a
rule set stored in a variable. You may also wish to use @kbd{s p}
(@code{calc-permanent-variable}) to save your rules permanently;
-@pxref{Operations on Variables}.@refill
+@pxref{Operations on Variables}.
Rewrite rules are compiled into a special internal form for faster
matching. If you enter a rule set directly it must be recompiled
@subsection Basic Rewrite Rules
@noindent
-To match a particular formula @cite{x} with a particular rewrite rule
-@samp{@var{old} := @var{new}}, Calc compares the structure of @cite{x} with
+To match a particular formula @expr{x} with a particular rewrite rule
+@samp{@var{old} := @var{new}}, Calc compares the structure of @expr{x} with
the structure of @var{old}. Variables that appear in @var{old} are
-treated as @dfn{meta-variables}; the corresponding positions in @cite{x}
+treated as @dfn{meta-variables}; the corresponding positions in @expr{x}
may contain any sub-formulas. For example, the pattern @samp{f(x,y)}
would match the expression @samp{f(12, a+1)} with the meta-variable
@samp{x} corresponding to 12 and with @samp{y} corresponding to
the pattern is a single meta-variable, it will match any expression.
If a given meta-variable appears more than once in @var{old}, the
-corresponding sub-formulas of @cite{x} must be identical. Thus
+corresponding sub-formulas of @expr{x} must be identical. Thus
the pattern @samp{f(x,x)} would match @samp{f(12, 12)} and
@samp{f(a+1, a+1)} but not @samp{f(12, a+1)} or @samp{f(a+b, b+a)}.
(@xref{Conditional Rewrite Rules}, for a way to match the latter.)
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.
@xref{Logical Operations}, for a number of functions that return
-1 or 0 according to the results of various tests.@refill
+1 or 0 according to the results of various tests.
-For example, the formula @samp{n > 0} simplifies to 1 or 0 if @cite{n}
+For example, the formula @samp{n > 0} simplifies to 1 or 0 if @expr{n}
is replaced by a positive or nonpositive number, respectively (or if
-@cite{n} has been declared to be positive or nonpositive). Thus,
+@expr{n} has been declared to be positive or nonpositive). Thus,
the rule @samp{f(x,y) := g(y+x,x) :: x+y > 0} would apply to
@samp{f(0, 4)} but not to @samp{f(-3, 2)} or @samp{f(12, a+1)}
-(assuming no outstanding declarations for @cite{a}). In the case of
+(assuming no outstanding declarations for @expr{a}). In the case of
@samp{f(-3, 2)}, the condition can be shown not to be satisfied; in
the case of @samp{f(12, a+1)}, the condition merely cannot be shown
to be satisfied, but that is enough to reject the rule.
matched.
Certain conditions are handled as special cases by the rewrite rule
-system and are tested very efficiently: Where @cite{x} is any
+system and are tested very efficiently: Where @expr{x} is any
meta-variable, these conditions are @samp{integer(x)}, @samp{real(x)},
-@samp{constant(x)}, @samp{negative(x)}, @samp{x >= y} where @cite{y}
+@samp{constant(x)}, @samp{negative(x)}, @samp{x >= y} where @expr{y}
is either a constant or another meta-variable and @samp{>=} may be
replaced by any of the six relational operators, and @samp{x % a = b}
-where @cite{a} and @cite{b} are constants. Other conditions, like
+where @expr{a} and @expr{b} are constants. Other conditions, like
@samp{x >= y+1} or @samp{dreal(x)}, will be less efficient to check
since Calc must bring the whole evaluator and simplifier into play.
Note that @samp{*} is not commutative when applied to matrices, but
rewrite rules pretend that it is. If you type @kbd{m v} to enable
-matrix mode (@pxref{Matrix Mode}), rewrite rules will match @samp{*}
+Matrix mode (@pxref{Matrix Mode}), rewrite rules will match @samp{*}
literally, ignoring its usual commutativity property. (In the
current implementation, the associativity also vanishes---it is as
if the pattern had been enclosed in a @code{plain} marker; see below.)
If you are applying rewrites to formulas with matrices, it's best to
-enable matrix mode first to prevent algebraically incorrect rewrites
+enable Matrix mode first to prevent algebraically incorrect rewrites
from occurring.
The pattern @samp{-x} will actually match any expression. For example,
functions with rewrite conditions to test for this; @pxref{Logical
Operations}. These functions are not as convenient to use in rewrite
rules, but they recognize more kinds of formulas as linear:
-@samp{x/z} is considered linear with @cite{b = 1/z} by @code{lin},
+@samp{x/z} is considered linear with @expr{b = 1/z} by @code{lin},
but it will not match the above pattern because that pattern calls
for a multiplication, not a division.
@end example
Note that this rule will @emph{not} match @samp{sin(x)^2 + 6 cos(x)^2}
-because one @cite{a} would have ``matched'' 1 while the other matched 6.
+because one @expr{a} would have ``matched'' 1 while the other matched 6.
Calc automatically converts a rule like
@end ignore
@tindex import
One kind of marker, @samp{import(x)}, takes the place of a whole
-rule. Here @cite{x} is the name of a variable containing another
+rule. Here @expr{x} is the name of a variable containing another
rule set; those rules are ``spliced into'' the rule set that
imports them. For example, if @samp{[f(a+b) := f(a) + f(b),
f(a b) := a f(b) :: real(a)]} is stored in variable @samp{linearF},
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 @cite{x} with all occurrences of @c{$v_1$}
-@cite{v1}, as either
-a variable name or a function name, replaced with @c{$x_1$}
-@cite{x1} and
-so on. (If @c{$v_1$}
-@cite{v1} is used as a function name, then @c{$x_1$}
-@cite{x1}
+the rule set @expr{x} with all occurrences of
+@texline @math{v_1},
+@infoline @expr{v1},
+as either a variable name or a function name, replaced with
+@texline @math{x_1}
+@infoline @expr{x1}
+and so on. (If
+@texline @math{v_1}
+@infoline @expr{v1}
+is used as a function name, then
+@texline @math{x_1}
+@infoline @expr{x1}
must be either a function name itself or a @w{@samp{< >}} nameless
function; @pxref{Specifying Operators}.) For example, @samp{[g(0) := 0,
import(linearF, f, g)]} applies the linearity rules to the function
@starindex
@end ignore
@tindex quote
-This pattern matches exactly @cite{x}; variable names in @cite{x} are
+This pattern matches exactly @expr{x}; variable names in @expr{x} are
not interpreted as meta-variables. The only flexibility is that
numbers are compared for numeric equality, so that the pattern
@samp{f(quote(12))} will match both @samp{f(12)} and @samp{f(12.0)}.
@starindex
@end ignore
@tindex plain
-Here @cite{x} must be a function call @samp{f(x1,x2,@dots{})}. This
-pattern matches a call to function @cite{f} with the specified
+Here @expr{x} must be a function call @samp{f(x1,x2,@dots{})}. This
+pattern matches a call to function @expr{f} with the specified
argument patterns. No special knowledge of the properties of the
-function @cite{f} is used in this case; @samp{+} is not commutative or
+function @expr{f} is used in this case; @samp{+} is not commutative or
associative. Unlike @code{quote}, the arguments @samp{x1,x2,@dots{}}
are treated as patterns. If you wish them to be treated ``plainly''
as well, you must enclose them with more @code{plain} markers:
@starindex
@end ignore
@tindex opt
-Here @cite{x} must be a variable name. This must appear as an
+Here @expr{x} must be a variable name. This must appear as an
argument to a function or an element of a vector; it specifies that
the argument or element is optional.
As an argument to @samp{+}, @samp{-}, @samp{*}, @samp{&&}, or @samp{||},
or as the second argument to @samp{/} or @samp{^}, the value @var{def}
may be omitted. The pattern @samp{x + opt(y)} matches a sum by
-binding one summand to @cite{x} and the other to @cite{y}, and it
-matches anything else by binding the whole expression to @cite{x} and
-zero to @cite{y}. The other operators above work similarly.@refill
+binding one summand to @expr{x} and the other to @expr{y}, and it
+matches anything else by binding the whole expression to @expr{x} and
+zero to @expr{y}. The other operators above work similarly.
For general miscellaneous functions, the default value @code{def}
must be specified. Optional arguments are dropped starting with
the rightmost one during matching. For example, the pattern
@samp{f(opt(a,0), b, opt(c,b))} will match @samp{f(b)}, @samp{f(a,b)},
-or @samp{f(a,b,c)}. Default values of zero and @cite{b} are
+or @samp{f(a,b,c)}. Default values of zero and @expr{b} are
supplied in this example for the omitted arguments. Note that
-the literal variable @cite{b} will be the default in the latter
-case, @emph{not} the value that matched the meta-variable @cite{b}.
+the literal variable @expr{b} will be the default in the latter
+case, @emph{not} the value that matched the meta-variable @expr{b}.
In other words, the default @var{def} is effectively quoted.
@item condition(x,c)
@end ignore
@tindex condition
@tindex ::
-This matches the pattern @cite{x}, with the attached condition
-@cite{c}. It is the same as @samp{x :: c}.
+This matches the pattern @expr{x}, with the attached condition
+@expr{c}. It is the same as @samp{x :: c}.
@item pand(x,y)
@ignore
@end ignore
@tindex pand
@tindex &&&
-This matches anything that matches both pattern @cite{x} and
-pattern @cite{y}. It is the same as @samp{x &&& y}.
+This matches anything that matches both pattern @expr{x} and
+pattern @expr{y}. It is the same as @samp{x &&& y}.
@pxref{Composing Patterns in Rewrite Rules}.
@item por(x,y)
@end ignore
@tindex por
@tindex |||
-This matches anything that matches either pattern @cite{x} or
-pattern @cite{y}. It is the same as @w{@samp{x ||| y}}.
+This matches anything that matches either pattern @expr{x} or
+pattern @expr{y}. It is the same as @w{@samp{x ||| y}}.
@item pnot(x)
@ignore
@end ignore
@tindex pnot
@tindex !!!
-This matches anything that does not match pattern @cite{x}.
+This matches anything that does not match pattern @expr{x}.
It is the same as @samp{!!! x}.
@item cons(h,t)
@end ignore
@tindex cons (rewrites)
This matches any vector of one or more elements. The first
-element is matched to @cite{h}; a vector of the remaining
-elements is matched to @cite{t}. Note that vectors of fixed
+element is matched to @expr{h}; a vector of the remaining
+elements is matched to @expr{t}. Note that vectors of fixed
length can also be matched as actual vectors: The rule
@samp{cons(a,cons(b,[])) := cons(a+b,[])} is equivalent
to the rule @samp{[a,b] := [a+b]}.
@end ignore
@tindex rcons (rewrites)
This is like @code{cons}, except that the @emph{last} element
-is matched to @cite{h}, with the remaining elements matched
-to @cite{t}.
+is matched to @expr{h}, with the remaining elements matched
+to @expr{t}.
@item apply(f,args)
@ignore
@end ignore
@tindex apply (rewrites)
This matches any function call. The name of the function, in
-the form of a variable, is matched to @cite{f}. The arguments
+the form of a variable, is matched to @expr{f}. The arguments
of the function, as a vector of zero or more objects, are
matched to @samp{args}. Constants, variables, and vectors
do @emph{not} match an @code{apply} pattern. For example,
on both sides of a rewrite rule: @samp{apply(f, [x]) := f(x+1)}
is @emph{not} correct, because it rewrites @samp{spam(6)} into
@samp{f(7)}. The righthand side should be @samp{apply(f, [x+1])}.
-Also note that you will have to use no-simplify (@kbd{m O})
-mode when entering this rule so that the @code{apply} isn't
+Also note that you will have to use No-Simplify mode (@kbd{m O})
+when entering this rule so that the @code{apply} isn't
evaluated immediately to get the new rule @samp{f(x) := f(x+1)}.
Or, use @kbd{s e} to enter the rule without going through the stack,
or enter the rule as @samp{apply(f, [x]) := apply(f, [x+1]) @w{:: 1}}.
@item plain(x)
Special properties of and simplifications for the function call
-@cite{x} are not used. One interesting case where @code{plain}
+@expr{x} are not used. One interesting case where @code{plain}
is useful is the rule, @samp{q(x) := quote(x)}, trying to expand a
shorthand notation for the @code{quote} function. This rule will
not work as shown; instead of replacing @samp{q(foo)} with
rule would be @samp{q(x) := plain(quote(x))}.
@item cons(h,t)
-Where @cite{t} is a vector, this is converted into an expanded
+Where @expr{t} is a vector, this is converted into an expanded
vector during rewrite processing. Note that @code{cons} is a regular
Calc function which normally does this anyway; the only way @code{cons}
is treated specially by rewrites is that @code{cons} on the righthand
have been turned off.
@item rcons(t,h)
-Analogous to @code{cons} except putting @cite{h} at the @emph{end} of
-the vector @cite{t}.
+Analogous to @code{cons} except putting @expr{h} at the @emph{end} of
+the vector @expr{t}.
@item apply(f,args)
-Where @cite{f} is a variable and @var{args} is a vector, this
+Where @expr{f} is a variable and @var{args} is a vector, this
is converted to a function call. Once again, note that @code{apply}
is also a regular Calc function.
@starindex
@end ignore
@tindex eval
-The formula @cite{x} is handled in the usual way, then the
+The formula @expr{x} is handled in the usual way, then the
default simplifications are applied to it even if they have
been turned off normally. This allows you to treat any function
similarly to the way @code{cons} and @code{apply} are always
@starindex
@end ignore
@tindex evalsimp
-The formula @cite{x} has meta-variables substituted in the usual
+The formula @expr{x} has meta-variables substituted in the usual
way, then algebraically simplified as if by the @kbd{a s} command.
@item evalextsimp(x)
@starindex
@end ignore
@tindex evalextsimp
-The formula @cite{x} has meta-variables substituted in the normal
+The formula @expr{x} has meta-variables substituted in the normal
way, then ``extendedly'' simplified as if by the @kbd{a e} command.
@item select(x)
@starindex
@end ignore
@tindex let
-The expression @cite{x} is evaluated with meta-variables substituted.
+The expression @expr{x} is evaluated with meta-variables substituted.
The @kbd{a s} command's simplifications are @emph{not} applied by
-default, but @cite{x} can include calls to @code{evalsimp} or
+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 @cite{x} is then bound to the meta-variable @cite{v}. As
+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, @cite{v} may be any pattern in which case the result of
-evaluating @cite{x} is matched to that pattern, binding any
+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}
can only appear by itself as a condition, or as one term of an
@samp{&&} which is a whole condition: It cannot be inside
-an @samp{||} term or otherwise buried.@refill
+an @samp{||} term or otherwise buried.
The alternate, equivalent form @samp{let(v, x)} is also recognized.
Note that the use of @samp{:=} by @code{let}, while still being
Note that, because the meta-variable @samp{ia} is otherwise unbound
in this rule, the @code{let} condition itself always ``succeeds''
because no matter what @samp{1/a} evaluates to, it can successfully
-be bound to @code{ia}.@refill
+be bound to @code{ia}.
Here's another example, for integrating cosines of linear
terms: @samp{myint(cos(y),x) := sin(y)/b :: let([a,b,x] := lin(y,x))}.
the coefficients @code{a} and @code{b} for use elsewhere in the rule.
(It would have been possible to use @samp{sin(a x + b)/b} for the
righthand side instead, but using @samp{sin(y)/b} avoids gratuitous
-rearrangement of the argument of the sine.)@refill
+rearrangement of the argument of the sine.)
@ignore
@starindex
@starindex
@end ignore
@tindex remember
-Remember the match as described above, but only if condition @cite{c}
+Remember the match as described above, but only if condition @expr{c}
is true. For example, @samp{remember(n % 4 = 0)} in the above factorial
rule remembers only every fourth result. Note that @samp{remember(1)}
is equivalent to @samp{remember}, and @samp{remember(0)} has no effect.
to expand trig functions. But if instead you store them in the
variable @code{EvalRules}, they will automatically be applied to all
sines and cosines of sums. Then, with @samp{2 x} and @samp{45} on
-the stack, typing @kbd{+ S} will (assuming degrees mode) result in
+the stack, typing @kbd{+ S} will (assuming Degrees mode) result in
@samp{0.7071 sin(2 x) + 0.7071 cos(2 x)} automatically.
As each level of a formula is evaluated, the rules from
Another subtle difference between @code{EvalRules} and regular rewrites
concerns rules that rewrite a formula into an identical formula. For
-example, @samp{f(n) := f(floor(n))} ``fails to match'' when @cite{n} is
+example, @samp{f(n) := f(floor(n))} ``fails to match'' when @expr{n} is
already an integer. But in @code{EvalRules} this case is detected only
if the righthand side literally becomes the original formula before any
further simplification. This means that @samp{f(n) := f(floor(n))} will
functions directly rather than going through the default simplifications.
When it does this, @code{EvalRules} will not be able to override those
functions. For example, when you take the absolute value of the complex
-number @cite{(2, 3)}, Calc computes @samp{sqrt(2*2 + 3*3)} by calling
+number @expr{(2, 3)}, Calc computes @samp{sqrt(2*2 + 3*3)} by calling
the multiplication, addition, and square root functions directly rather
than applying the default simplifications to this formula. So an
@code{EvalRules} rule that (perversely) rewrites @samp{sqrt(13) := 6}
-would not apply. (However, if you put Calc into symbolic mode so that
+would not apply. (However, if you put Calc into Symbolic mode so that
@samp{sqrt(13)} will be left in symbolic form by the built-in square
root function, your rule will be able to apply. But if the complex
-number were @cite{(3,4)}, so that @samp{sqrt(25)} must be calculated,
-then symbolic mode will not help because @samp{sqrt(25)} can be
+number were @expr{(3,4)}, so that @samp{sqrt(25)} must be calculated,
+then Symbolic mode will not help because @samp{sqrt(25)} can be
evaluated exactly to 5.)
One subtle restriction that normally only manifests itself with
finding suitable cases. Another solution would be to use the rule
@samp{cos(x)^2 := 1 - sin(x)^2}, followed by algebraic simplification
if necessary. This rule will be the most effective way to do the job,
-but at the expense of making some changes that you might not desire.@refill
+but at the expense of making some changes that you might not desire.
Another algebraic rewrite rule is @samp{exp(x+y) := exp(x) exp(y)}.
To make this work with the @w{@kbd{j r}} command so that it can be
you might wish to write the rule as @samp{select(exp(x+y)) :=
select(exp(x) exp(y))}. The @samp{select} markers will be
ignored by the regular @kbd{a r} command
-(@pxref{Selections with Rewrite Rules}).@refill
+(@pxref{Selections with Rewrite Rules}).
A surprisingly useful rewrite rule is @samp{a/(b-c) := a*(b+c)/(b^2-c^2)}.
-This will simplify the formula whenever @cite{b} and/or @cite{c} can
+This will simplify the formula whenever @expr{b} and/or @expr{c} can
be made simpler by squaring. For example, applying this rule to
@samp{2 / (sqrt(2) + 3)} yields @samp{6:7 - 2:7 sqrt(2)} (assuming
-Symbolic Mode has been enabled to keep the square root from being
+Symbolic mode has been enabled to keep the square root from being
evaluated to a floating-point approximation). This rule is also
useful when working with symbolic complex numbers, e.g.,
@samp{(a + b i) / (c + d i)}.
@code{tri} to the value on the top of the stack. @xref{Programming}.
@cindex Quaternions
-The following rule set, contributed by @c{Fran\c cois}
-@asis{Francois} Pinard, implements
-@dfn{quaternions}, a generalization of the concept of complex numbers.
-Quaternions have four components, and are here represented by function
-calls @samp{quat(@var{w}, [@var{x}, @var{y}, @var{z}])} with ``real
-part'' @var{w} and the three ``imaginary'' parts collected into a
-vector. Various arithmetical operations on quaternions are supported.
-To use these rules, either add them to @code{EvalRules}, or create a
-command based on @kbd{a r} for simplifying quaternion formulas.
-A convenient way to enter quaternions would be a command defined by
-a keyboard macro containing: @kbd{' quat($$$$, [$$$, $$, $]) @key{RET}}.
+The following rule set, contributed by
+@texline Fran\c cois
+@infoline Francois
+Pinard, implements @dfn{quaternions}, a generalization of the concept of
+complex numbers. Quaternions have four components, and are here
+represented by function calls @samp{quat(@var{w}, [@var{x}, @var{y},
+@var{z}])} with ``real part'' @var{w} and the three ``imaginary'' parts
+collected into a vector. Various arithmetical operations on quaternions
+are supported. To use these rules, either add them to @code{EvalRules},
+or create a command based on @kbd{a r} for simplifying quaternion
+formulas. A convenient way to enter quaternions would be a command
+defined by a keyboard macro containing: @kbd{' quat($$$$, [$$$, $$, $])
+@key{RET}}.
@smallexample
[ quat(w, x, y, z) := quat(w, [x, y, z]),
@end smallexample
Quaternions, like matrices, have non-commutative multiplication.
-In other words, @cite{q1 * q2 = q2 * q1} is not necessarily true if
-@cite{q1} and @cite{q2} are @code{quat} forms. The @samp{quat*quat}
+In other words, @expr{q1 * q2 = q2 * q1} is not necessarily true if
+@expr{q1} and @expr{q2} are @code{quat} forms. The @samp{quat*quat}
rule above uses @code{plain} to prevent Calc from rearranging the
product. It may also be wise to add the line @samp{[quat(), matrix]}
to the @code{Decls} matrix, to ensure that Calc's other algebraic
or @samp{u} (for ``micro'') followed by a name in the unit table.
A substantial table of built-in units is provided with Calc;
@pxref{Predefined Units}. You can also define your own unit names;
-@pxref{User-Defined Units}.@refill
+@pxref{User-Defined Units}.
Note that if the value part of a units expression is exactly @samp{1},
it will be removed by the Calculator's automatic algebra routines: The
formula @samp{1 mm} is ``simplified'' to @samp{mm}. This is only a
display anomaly, however; @samp{mm} will work just fine as a
-representation of one millimeter.@refill
+representation of one millimeter.
-You may find that Algebraic Mode (@pxref{Algebraic Entry}) makes working
+You may find that Algebraic mode (@pxref{Algebraic Entry}) makes working
with units expressions easier. Otherwise, you will have to remember
to hit the apostrophe key every time you wish to enter units.
simplify to @samp{5.023 m}. When different but compatible units are
added, the righthand term's units are converted to match those of the
lefthand term. @xref{Simplification Modes}, for a way to have this done
-automatically at all times.@refill
+automatically at all times.
Units simplification also handles quotients of two units with the same
dimensionality, as in @w{@samp{2 in s/L cm}} to @samp{5.08 s/L}; fractional
applied to units expressions, in which case
the operation in question is applied only to the numeric part of the
expression. Finally, trigonometric functions of quantities with units
-of angle are evaluated, regardless of the current angular mode.@refill
+of angle are evaluated, regardless of the current angular mode.
@kindex u c
@pindex calc-convert-units
absolute temperatures. The value on the stack must be a simple units
expression with units of temperature only. This command would convert
@samp{10 degC} to @samp{50 degF}, the equivalent temperature on the
-Fahrenheit scale.@refill
+Fahrenheit scale.
@kindex u r
@pindex calc-remove-units
(@code{calc-extract-units}) command extracts only the units portion of a
formula. These commands essentially replace every term of the formula
that does or doesn't (respectively) look like a unit name by the
-constant 1, then resimplify the formula.@refill
+constant 1, then resimplify the formula.
@kindex u a
@pindex calc-autorange-units
The @kbd{u V} (@code{calc-view-units-table}) command is like @kbd{u v} except
that the cursor is not moved into the Units Table buffer. You can
type @kbd{u V} again to remove the Units Table from the display. To
-return from the Units Table buffer after a @kbd{u v}, type @kbd{M-# c}
+return from the Units Table buffer after a @kbd{u v}, type @kbd{C-x * c}
again or use the regular Emacs @w{@kbd{C-x o}} (@code{other-window})
command. You can also kill the buffer with @kbd{C-x k} if you wish;
the actual units table is safely stored inside the Calculator.
@end ifinfo
The unit @code{pt} stands for pints; the name @code{point} stands for
-a typographical point, defined by @samp{72 point = 1 in}. There is
-also @code{tpt}, which stands for a printer's point as defined by the
-@TeX{} typesetting system: @samp{72.27 tpt = 1 in}.
+a typographical point, defined by @samp{72 point = 1 in}. This is
+slightly different than the point defined by the American Typefounder's
+Association in 1886, but the point used by Calc has become standard
+largely due to its use by the PostScript page description language.
+There is also @code{texpt}, which stands for a printer's point as
+defined by the @TeX{} typesetting system: @samp{72.27 texpt = 1 in}.
+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,
+all dimensions representable in @TeX{} are multiples of this value).
The unit @code{e} stands for the elementary (electron) unit of charge;
because algebra command could mistake this for the special constant
-@cite{e}, Calc provides the alternate unit name @code{ech} which is
+@expr{e}, Calc provides the alternate unit name @code{ech} which is
preferable to @code{e}.
The name @code{g} stands for one gram of mass; there is also @code{gf},
one gram of force. (Likewise for @kbd{lb}, pounds, and @kbd{lbf}.)
-Meanwhile, one ``@cite{g}'' of acceleration is denoted @code{ga}.
+Meanwhile, one ``@expr{g}'' of acceleration is denoted @code{ga}.
The unit @code{ton} is a U.S. ton of @samp{2000 lb}, and @code{t} is
a metric ton of @samp{1000 kg}.
in its normal terms, and @kbd{u b} expresses the definition in base
units.
-Two units, @code{pi} and @code{fsc} (the fine structure constant,
-approximately @i{1/137}) are dimensionless. The units simplification
+Two units, @code{pi} and @code{alpha} (the fine structure constant,
+approximately @mathit{1/137}) are dimensionless. The units simplification
commands simply treat these names as equivalent to their corresponding
values. However you can, for example, use @kbd{u c} to convert a pure
number into multiples of the fine structure constant, or @kbd{u b} to
@kindex u p
@pindex calc-permanent-units
-@cindex @file{.emacs} file, user-defined units
+@cindex Calc init file, user-defined units
The @kbd{u p} (@code{calc-permanent-units}) command stores the user-defined
-units in your @file{.emacs} file, so that the units will still be
-available in subsequent Emacs sessions. If there was already a set of
-user-defined units in your @file{.emacs} file, it is replaced by the
-new set. (@xref{General Mode Commands}, for a way to tell Calc to use
-a different file instead of @file{.emacs}.)
+units in your Calc init file (the file given by the variable
+@code{calc-settings-file}, typically @file{~/.calc.el}), so that the
+units will still be available in subsequent Emacs sessions. If there
+was already a set of user-defined units in your Calc init file, it
+is replaced by the new set. (@xref{General Mode Commands}, for a way to
+tell Calc to use a different file for the Calc init file.)
@node Store and Recall, Graphics, Units, Top
@chapter Storing and Recalling
The @kbd{s s} (@code{calc-store}) command stores the value at the top of
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{var-q0} through
-@code{var-q9}. Or you can enter any variable name. The prefix @samp{var-}
-is supplied for you; when a name appears in a formula (as in @samp{a+q2})
-the prefix @samp{var-} is also supplied there, so normally you can simply
-forget about @samp{var-} everywhere. Its only purpose is to enable you to
-use Calc variables without fear of accidentally clobbering some variable in
-another Emacs package. If you really want to store in an arbitrary Lisp
-variable, just backspace over the @samp{var-}.
+immediately in one of the ``quick'' variables @code{q0} through
+@code{q9}. Or you can enter any variable name.
@kindex s t
@pindex calc-store-into
and @kbd{s ]} which decrease or increase a variable by one.
All the arithmetic stores accept the Inverse prefix to reverse the
-order of the operands. If @cite{v} represents the contents of the
-variable, and @cite{a} is the value drawn from the stack, then regular
-@w{@kbd{s -}} assigns @c{$v \coloneq v - a$}
-@cite{v := v - a}, but @kbd{I s -} assigns
-@c{$v \coloneq a - v$}
-@cite{v := a - v}. While @kbd{I s *} might seem pointless, it is
+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
+@texline @math{v \coloneq v - a},
+@infoline @expr{v := v - a},
+but @kbd{I s -} assigns
+@texline @math{v \coloneq a - v}.
+@infoline @expr{v := a - v}.
+While @kbd{I s *} might seem pointless, it is
useful if matrix multiplication is involved. Actually, all the
arithmetic stores use formulas designed to behave usefully both
forwards and backwards:
The first six arithmetic stores can also be typed @kbd{s t +}, @kbd{s t -},
etc. The commands @kbd{s s +}, @kbd{s s -}, and so on are analogous
-arithmetic stores that don't remove the value @cite{a} from the stack.
+arithmetic stores that don't remove the value @expr{a} from the stack.
All arithmetic stores report the new value of the variable in the
Trail for your information. They signal an error if the variable
If the mapping function takes two or more arguments, the additional
arguments are taken from the stack; the old value of the variable
-is provided as the first argument. Thus @kbd{s m -} with @cite{a}
-on the stack computes @cite{v - a}, just like @kbd{s -}. With the
+is provided as the first argument. Thus @kbd{s m -} with @expr{a}
+on the stack computes @expr{v - a}, just like @kbd{s -}. With the
Inverse prefix, the variable's original value becomes the @emph{last}
argument instead of the first. Thus @kbd{I s m -} is also
equivalent to @kbd{I s -}.
@pindex calc-unstore
@cindex Void variables
@cindex Un-storing variables
-Until you store something in them, variables are ``void,'' that is, they
-contain no value at all. If they appear in an algebraic formula they
-will be left alone even if you press @kbd{=} (@code{calc-evaluate}).
+Until you store something in them, most variables are ``void,'' that is,
+they contain no value at all. If they appear in an algebraic formula
+they will be left alone even if you press @kbd{=} (@code{calc-evaluate}).
The @kbd{s u} (@code{calc-unstore}) command returns a variable to the
-void state.@refill
+void state.
+
+@kindex s c
+@pindex calc-copy-variable
+The @kbd{s c} (@code{calc-copy-variable}) command copies the stored
+value of one variable to another. One way it differs from a simple
+@kbd{s r} followed by an @kbd{s t} (aside from saving keystrokes) is
+that the value never goes on the stack and thus is never rounded,
+evaluated, or simplified in any way; it is not even rounded down to the
+current precision.
The only variables with predefined values are the ``special constants''
@code{pi}, @code{e}, @code{i}, @code{phi}, and @code{gamma}. You are free
special variables @code{inf}, @code{uinf}, and @code{nan} (which are
normally void).
-Note that @code{var-pi} doesn't actually have 3.14159265359 stored
-in it, but rather a special magic value that evaluates to @c{$\pi$}
-@cite{pi}
-at the current precision. Likewise @code{var-e}, @code{var-i}, and
-@code{var-phi} evaluate according to the current precision or polar mode.
-If you recall a value from @code{pi} and store it back, this magic
-property will be lost.
-
-@kindex s c
-@pindex calc-copy-variable
-The @kbd{s c} (@code{calc-copy-variable}) command copies the stored
-value of one variable to another. It differs from a simple @kbd{s r}
-followed by an @kbd{s t} in two important ways. First, the value never
-goes on the stack and thus is never rounded, evaluated, or simplified
-in any way; it is not even rounded down to the current precision.
-Second, the ``magic'' contents of a variable like @code{var-e} can
-be copied into another variable with this command, perhaps because
-you need to unstore @code{var-e} right now but you wish to put it
-back when you're done. The @kbd{s c} command is the only way to
-manipulate these magic values intact.
+Note that @code{pi} doesn't actually have 3.14159265359 stored in it,
+but rather a special magic value that evaluates to @cpi{} at the current
+precision. Likewise @code{e}, @code{i}, and @code{phi} evaluate
+according to the current precision or polar mode. If you recall a value
+from @code{pi} and store it back, this magic property will be lost. The
+magic property is preserved, however, when a variable is copied with
+@kbd{s c}.
+
+@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
+@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
+you enter doesn't depend on the value of the corresponding variable;
+@code{pi} will represent 3.14159@dots{} regardless of what is currently
+stored in the Calc variable @code{pi}. If one of the other special
+variables, @code{inf}, @code{uinf} or @code{nan}, is given a value, its
+original behavior can be restored by voiding it with @kbd{s u}.
@node Recalling Variables, Operations on Variables, Storing Variables, Store and Recall
@section Recalling Variables
or simplifying or evaluating the value. It prompts for the name of
the variable to edit. If the variable has no stored value, the
editing buffer will start out empty. If the editing buffer is
-empty when you press @kbd{M-# M-#} to finish, the variable will
+empty when you press @kbd{C-c C-c} to finish, the variable will
be made void. @xref{Editing Stack Entries}, for a general
description of editing.
@pindex calc-permanent-variable
@cindex Storing variables
@cindex Permanent variables
-@cindex @file{.emacs} file, variables
+@cindex Calc init file, variables
The @kbd{s p} (@code{calc-permanent-variable}) command saves a
-variable's value permanently in your @file{.emacs} file, so that its
-value will still be available in future Emacs sessions. You can
-re-execute @w{@kbd{s p}} later on to update the saved value, but the
-only way to remove a saved variable is to edit your @file{.emacs} file
+variable's value permanently in your Calc init file (the file given by
+the variable @code{calc-settings-file}, typically @file{~/.calc.el}), so
+that its value will still be available in future Emacs sessions. You
+can re-execute @w{@kbd{s p}} later on to update the saved value, but the
+only way to remove a saved variable is to edit your calc init file
by hand. (@xref{General Mode Commands}, for a way to tell Calc to
-use a different file instead of @file{.emacs}.)
+use a different file for the Calc init file.)
If you do not specify the name of a variable to save (i.e.,
-@kbd{s p @key{RET}}), all @samp{var-} variables with defined values
+@kbd{s p @key{RET}}), all Calc variables with defined values
are saved except for the special constants @code{pi}, @code{e},
@code{i}, @code{phi}, and @code{gamma}; the variables @code{TimeZone}
and @code{PlotRejects};
@code{FitRules}, @code{DistribRules}, and other built-in rewrite
rules; and @code{PlotData@var{n}} variables generated
by the graphics commands. (You can still save these variables by
-explicitly naming them in an @kbd{s p} command.)@refill
+explicitly naming them in an @kbd{s p} command.)
@kindex s i
@pindex calc-insert-variables
The @kbd{s i} (@code{calc-insert-variables}) command writes
-the values of all @samp{var-} variables into a specified buffer.
-The variables are written in the form of Lisp @code{setq} commands
+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
which store the values in string form. You can place these commands
-in your @file{.emacs} buffer if you wish, though in this case it
+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}
omits the same set of variables as @w{@kbd{s p @key{RET}}}; the difference
is that @kbd{s i} will store the variables in any buffer, and it also
@cindex Variables, temporary assignment
@cindex Temporary assignment to variables
If you have an expression like @samp{a+b^2} on the stack and you wish to
-compute its value where @cite{b=3}, you can simply store 3 in @cite{b} and
+compute its value where @expr{b=3}, you can simply store 3 in @expr{b} and
then press @kbd{=} to reevaluate the formula. This has the side-effect
-of leaving the stored value of 3 in @cite{b} for future operations.
+of leaving the stored value of 3 in @expr{b} for future operations.
The @kbd{s l} (@code{calc-let}) command evaluates a formula under a
@emph{temporary} assignment of a variable. It stores the value on the
The @kbd{a b} (@code{calc-substitute}) command is another way to substitute
a variable with a value in a formula. It does an actual substitution
rather than temporarily assigning the variable and evaluating. For
-example, letting @cite{n=2} in @samp{f(n pi)} with @kbd{a b} will
+example, letting @expr{n=2} in @samp{f(n pi)} with @kbd{a b} will
produce @samp{f(2 pi)}, whereas @kbd{s l} would give @samp{f(6.28)}
since the evaluation step will also evaluate @code{pi}.
@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 @TeX{}.) This is a binary
+other language modes like Pascal and La@TeX{}.) 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.
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
+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
+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},
because the righthand side depends only on the lefthand side
@pindex calc-assign
@tindex assign
@tindex :=
-Embedded Mode also uses @samp{=>} operators. In embedded mode,
+Embedded mode also uses @samp{=>} operators. In Embedded mode,
the lefthand side of an @samp{=>} operator can refer to variables
assigned elsewhere in the file by @samp{:=} operators. The
assignment operator @samp{a := 17} does not actually do anything
-by itself. But Embedded Mode recognizes it and marks it as a sort
+by itself. But Embedded mode recognizes it and marks it as a sort
of file-local definition of the variable. You can enter @samp{:=}
-operators in algebraic mode, or by using the @kbd{s :}
+operators in Algebraic mode, or by using the @kbd{s :}
(@code{calc-assign}) [@code{assign}] command which takes a variable
and value from the stack and replaces them with an assignment.
-@xref{TeX Language Mode}, for the way @samp{=>} appears in
+@xref{TeX and LaTeX Language Modes}, for the way @samp{=>} appears in
@TeX{} language output. The @dfn{eqn} mode gives similar
treatment to @samp{=>}.
@noindent
The commands for graphing data begin with the @kbd{g} prefix key. Calc
-uses GNUPLOT 2.0 or 3.0 to do graphics. These commands will only work
+uses GNUPLOT 2.0 or later to do graphics. These commands will only work
if GNUPLOT is available on your system. (While GNUPLOT sounds like
a relative of GNU Emacs, it is actually completely unrelated.
-However, it is free software and can be obtained from the Free
-Software Foundation's machine @samp{prep.ai.mit.edu}.)
+However, it is free software. It can be obtained from
+@samp{http://www.gnuplot.info}.)
@vindex calc-gnuplot-name
If you have GNUPLOT installed on your system but Calc is unable to
find it, you may need to set the @code{calc-gnuplot-name} variable
-in your @file{.emacs} file. You may also need to set some Lisp
+in your Calc init file or @file{.emacs}. You may also need to set some Lisp
variables to show Calc how to run GNUPLOT on your system; these
are described under @kbd{g D} and @kbd{g O} below. If you are
using the X window system, Calc will configure GNUPLOT for you
-automatically. If you have GNUPLOT 3.0 and you are not using X,
+automatically. If you have GNUPLOT 3.0 or later and you are not using X,
Calc will configure GNUPLOT to display graphs using simple character
graphics that will work on any terminal.
the interval (whether the interval is open or closed is ignored).
The ``x'' entry may also be a number, in which case Calc uses the
-sequence of ``x'' values @cite{x}, @cite{x+1}, @cite{x+2}, etc.
-(Generally the number 0 or 1 would be used for @cite{x} in this case.)
+sequence of ``x'' values @expr{x}, @expr{x+1}, @expr{x+2}, etc.
+(Generally the number 0 or 1 would be used for @expr{x} in this case.)
The ``y'' entry may be any formula instead of a vector. Calc effectively
uses @kbd{N} (@code{calc-eval-num}) to evaluate variables in the formula;
In this case the ``x'' vector or interval you specified is not directly
visible in the graph. For example, if ``x'' is the interval @samp{[0..360]}
and ``y'' is the formula @samp{xy(sin(t), cos(t))}, the resulting graph
-will be a circle.@refill
+will be a circle.
Also, ``x'' and ``y'' may each be variable names, in which case Calc
looks for suitable vectors, intervals, or formulas stored in those
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 @c{$z_{ij}$}
-@cite{z_ij} is the height of the point
-at coordinate @cite{(x_i, y_j)} on the surface. The 3D graph will
+result is a surface plot where
+@texline @math{z_{ij}}
+@infoline @expr{z_ij}
+is the height of the point
+at coordinate @expr{(x_i, y_j)} on the surface. The 3D graph will
be displayed from a certain default viewpoint; you can change this
viewpoint by adding a @samp{set view} to the @samp{*Gnuplot Commands*}
-buffer as described later. See the GNUPLOT 3.0 documentation for a
+buffer as described later. See the GNUPLOT documentation for a
description of the @samp{set view} command.
Each point in the matrix will be displayed as a dot in the graph,
A numeric prefix argument on @kbd{g a} or @kbd{g f} changes the way
stack entries are interpreted as curves. With a positive prefix
-argument @cite{n}, the top @cite{n} stack entries are ``y'' values
-for @cite{n} different curves which share a common ``x'' value in
-the @cite{n+1}st stack entry. (Thus @kbd{g a} with no prefix
+argument @expr{n}, the top @expr{n} stack entries are ``y'' values
+for @expr{n} different curves which share a common ``x'' value in
+the @expr{n+1}st stack entry. (Thus @kbd{g a} with no prefix
argument is equivalent to @kbd{C-u 1 g a}.)
A prefix of zero or plain @kbd{C-u} means to take two stack entries,
``x'' and ``y'' as usual, but to interpret ``y'' as a vector of
``y'' values for several curves that share a common ``x''.
-A negative prefix argument tells Calc to read @cite{n} vectors from
-the stack; each vector @cite{[x, y]} describes an independent curve.
+A negative prefix argument tells Calc to read @expr{n} vectors from
+the stack; each vector @expr{[x, y]} describes an independent curve.
This is the only form of @kbd{g a} that creates several curves at once
that don't have common ``x'' values. (Of course, the range of ``x''
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 @c{$\sin n x$}
-@cite{sin(n x)} for integers @cite{n}
+For example, to plot
+@texline @math{\sin n x}
+@infoline @expr{sin(n x)}
+for integers @expr{n}
from 1 to 5, you could use @kbd{v x} to create a vector of integers
-(@cite{n}), then @kbd{V M '} or @kbd{V M $} to map @samp{sin(n x)}
+(@expr{n}), then @kbd{V M '} or @kbd{V M $} to map @samp{sin(n x)}
across this vector. The resulting vector of formulas is suitable
for use as the ``y'' argument to a @kbd{C-u g a} or @kbd{C-u g f}
command.
@kindex g A
@pindex calc-graph-add-3d
The @kbd{g A} (@code{calc-graph-add-3d}) command adds a 3D curve
-to the graph. It is not legal to intermix 2D and 3D curves in a
+to the graph. It is not valid to intermix 2D and 3D curves in a
single graph. This command takes three arguments, ``x'', ``y'',
-and ``z'', from the stack. With a positive prefix @cite{n}, it
-takes @cite{n+2} arguments (common ``x'' and ``y'', plus @cite{n}
+and ``z'', from the stack. With a positive prefix @expr{n}, it
+takes @expr{n+2} arguments (common ``x'' and ``y'', plus @expr{n}
separate ``z''s). With a zero prefix, it takes three stack entries
but the ``z'' entry is a vector of curve values. With a negative
-prefix @cite{-n}, it takes @cite{n} vectors of the form @cite{[x, y, z]}.
+prefix @expr{-n}, it takes @expr{n} vectors of the form @expr{[x, y, z]}.
The @kbd{g A} command works by adding a @code{splot} (surface-plot)
command to the @samp{*Gnuplot Commands*} buffer.
graphs created by @kbd{g a} that don't specify the resolution explicitly.
With a negative prefix argument, this command changes or displays
the default value (initially 5) used for 3D graphs created by @kbd{g A}.
-Note that a 3D setting of 5 means that a total of @cite{5^2 = 25} points
+Note that a 3D setting of 5 means that a total of @expr{5^2 = 25} points
will be computed for the surface.
Data values in the graph of a function are normally computed to a
precision of five digits, regardless of the current precision at the
time. This is usually more than adequate, but there are cases where
-it will not be. For example, plotting @cite{1 + x} with @cite{x} in the
+it will not be. For example, plotting @expr{1 + x} with @expr{x} in the
interval @samp{[0 ..@: 1e-6]} will round all the data points down
to 1.0! Putting the command @samp{set precision @var{n}} in the
@samp{*Gnuplot Commands*} buffer will cause the data to be computed
the @kbd{g a} and @kbd{g f} commands will use those style numbers
instead of the defaults for new curves that are added to the graph.
An entry should be a positive integer for a specific style, or 0 to let
-the style be chosen automatically, or @i{-1} to turn off lines or points
+the style be chosen automatically, or @mathit{-1} to turn off lines or points
altogether. If there are more curves than elements in the vector, the
last few curves will continue to have the default styles. Of course,
you can later use @kbd{g s} and @kbd{g S} to change any of these styles.
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 @c{$80\times24$}
-@asis{80x24} characters. The graph is displayed in
-an Emacs ``recursive edit''; type @kbd{q} or @kbd{M-# M-#} to exit
+dumb terminals will be
+@texline @math{80\times24}
+@infoline 80x24
+characters. The graph is displayed in
+an Emacs ``recursive edit''; type @kbd{q} or @kbd{C-c C-c} to exit
the recursive edit and return to Calc. Note that the @code{dumb}
device is present only in GNUPLOT 3.0 and later versions.
@vindex calc-gnuplot-print-command
@vindex calc-gnuplot-print-device
@vindex calc-gnuplot-print-output
-If you are installing Calc you may wish to configure the default and
+You may wish to configure the default and
printer devices and output files for the whole system. The relevant
Lisp variables are @code{calc-gnuplot-default-device} and @code{-output},
and @code{calc-gnuplot-print-device} and @code{-output}. The output
@code{nil} if no command is necessary, or strings which can include
@samp{%s} to signify the name of the file to be displayed or printed.
Or, these variables may contain Lisp expressions which are evaluated
-to display or print the output.
+to display or print the output. These variables are customizable
+(@pxref{Customizing Calc}).
@kindex g x
@pindex calc-graph-display
The commands in this chapter move information between the Calculator and
other Emacs editing buffers.
-In many cases Embedded Mode is an easier and more natural way to
+In many cases Embedded mode is an easier and more natural way to
work with Calc from a regular editing buffer. @xref{Embedded Mode}.
@menu
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 @cite{n-1}
-lines below it. A negative argument kills the @cite{-n} lines above the
+of lines killed. A positive argument kills the current line and @expr{n-1}
+lines below it. A negative argument kills the @expr{-n} lines above the
current line. Again this mirrors the behavior of the standard Emacs
@kbd{C-k} command. Although a whole line is always deleted, @kbd{C-k}
with no argument copies only the number itself into the kill ring, whereas
@section Grabbing from Other Buffers
@noindent
-@kindex M-# g
+@kindex C-x * g
@pindex calc-grab-region
-The @kbd{M-# g} (@code{calc-grab-region}) command takes the text between
+The @kbd{C-x * g} (@code{calc-grab-region}) command takes the text between
point and mark in the current buffer and attempts to parse it as a
vector of values. Basically, it wraps the text in vector brackets
@samp{[ ]} unless the text already is enclosed in vector brackets,
then reads the text as if it were an algebraic entry. The contents
of the vector may be numbers, formulas, or any other Calc objects.
-If the @kbd{M-# g} command works successfully, it does an automatic
-@kbd{M-# c} to enter the Calculator buffer.
+If the @kbd{C-x * g} command works successfully, it does an automatic
+@kbd{C-x * c} to enter the Calculator buffer.
A numeric prefix argument grabs the specified number of lines around
point, ignoring the mark. A positive prefix grabs from point to the
-@cite{n}th following newline (so that @kbd{M-1 M-# g} grabs from point
+@expr{n}th following newline (so that @kbd{M-1 C-x * g} grabs from point
to the end of the current line); a negative prefix grabs from point
-back to the @cite{n+1}st preceding newline. In these cases the text
+back to the @expr{n+1}st preceding newline. In these cases the text
that is grabbed is exactly the same as the text that @kbd{C-k} would
delete given that prefix argument.
A plain @kbd{C-u} prefix interprets the region between point and mark
as a single number or formula rather than a vector. For example,
-@kbd{M-# g} on the text @samp{2 a b} produces the vector of three
-values @samp{[2, a, b]}, but @kbd{C-u M-# g} on the same region
+@kbd{C-x * g} on the text @samp{2 a b} produces the vector of three
+values @samp{[2, a, b]}, but @kbd{C-u C-x * g} on the same region
reads a formula which is a product of three things: @samp{2 a b}.
(The text @samp{a + b}, on the other hand, will be grabbed as a
-vector of one element by plain @kbd{M-# g} because the interpretation
+vector of one element by plain @kbd{C-x * g} because the interpretation
@samp{[a, +, b]} would be a syntax error.)
If a different language has been specified (@pxref{Language Modes}),
the grabbed text will be interpreted according to that language.
-@kindex M-# r
+@kindex C-x * r
@pindex calc-grab-rectangle
-The @kbd{M-# r} (@code{calc-grab-rectangle}) command takes the text between
+The @kbd{C-x * r} (@code{calc-grab-rectangle}) command takes the text between
point and mark and attempts to parse it as a matrix. If point and mark
are both in the leftmost column, the lines in between are parsed in their
entirety. Otherwise, point and mark define the corners of a rectangle
format used in the Calc stack buffer) are ignored. If you wish to
force this interpretation (even if the line contains bracketed
portions), give a negative numeric prefix argument to the
-@kbd{M-# r} command.
+@kbd{C-x * r} command.
If you give a numeric prefix argument of zero or plain @kbd{C-u}, each
line is instead interpreted as a single formula which is converted into
-a one-element vector. Thus the result of @kbd{C-u M-# r} will be a
+a one-element vector. Thus the result of @kbd{C-u C-x * r} will be a
one-column matrix. For example, suppose one line of the data is the
-expression @samp{2 a}. A plain @w{@kbd{M-# r}} will interpret this as
+expression @samp{2 a}. A plain @w{@kbd{C-x * r}} will interpret this as
@samp{[2 a]}, which in turn is read as a two-element vector that forms
-one row of the matrix. But a @kbd{C-u M-# r} will interpret this row
+one row of the matrix. But a @kbd{C-u C-x * r} will interpret this row
as @samp{[2*a]}.
If you give a positive numeric prefix argument @var{n}, then each line
will be split up into columns of width @var{n}; each column is parsed
separately as a matrix element. If a line contained
@w{@samp{2 +/- 3 4 +/- 5}}, then grabbing with a prefix argument of 8
-would correctly split the line into two error forms.@refill
+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 @c{$1\times1$}
-@asis{1x1} matrix, just hit @kbd{v u}
-(@code{calc-unpack}) twice.)
+constituent rows and columns. (If it is a
+@texline @math{1\times1}
+@infoline 1x1
+matrix, just hit @kbd{v u} (@code{calc-unpack}) twice.)
-@kindex M-# :
-@kindex M-# _
+@kindex C-x * :
+@kindex C-x * _
@pindex calc-grab-sum-across
@pindex calc-grab-sum-down
@cindex Summing rows and columns of data
-The @kbd{M-# :} (@code{calc-grab-sum-down}) command is a handy way to
+The @kbd{C-x * :} (@code{calc-grab-sum-down}) command is a handy way to
grab a rectangle of data and sum its columns. It is equivalent to
-typing @kbd{M-# r}, followed by @kbd{V R : +} (the vector reduction
+typing @kbd{C-x * r}, followed by @kbd{V R : +} (the vector reduction
command that sums the columns of a matrix; @pxref{Reducing}). The
result of the command will be a vector of numbers, one for each column
-in the input data. The @kbd{M-# _} (@code{calc-grab-sum-across}) command
+in the input data. The @kbd{C-x * _} (@code{calc-grab-sum-across}) command
similarly grabs a rectangle and sums its rows by executing @w{@kbd{V R _ +}}.
-As well as being more convenient, @kbd{M-# :} and @kbd{M-# _} are also
+As well as being more convenient, @kbd{C-x * :} and @kbd{C-x * _} are also
much faster because they don't actually place the grabbed vector on
-the stack. In a @kbd{M-# r V R : +} sequence, formatting the vector
+the stack. In a @kbd{C-x * r V R : +} sequence, formatting the vector
for display on the stack takes a large fraction of the total time
(unless you have planned ahead and used @kbd{v .} and @kbd{t .} modes).
For example, suppose we have a column of numbers in a file which we
wish to sum. Go to one corner of the column and press @kbd{C-@@} to
-set the mark; go to the other corner and type @kbd{M-# :}. Since there
+set the mark; go to the other corner and type @kbd{C-x * :}. Since there
is only one column, the result will be a vector of one number, the sum.
(You can type @kbd{v u} to unpack this vector into a plain number if
you want to do further arithmetic with it.)
To compute the product of the column of numbers, we would have to do
it ``by hand'' since there's no special grab-and-multiply command.
-Use @kbd{M-# r} to grab the column of numbers into the calculator in
+Use @kbd{C-x * r} to grab the column of numbers into the calculator in
the form of a column matrix. The statistics command @kbd{u *} is a
handy way to find the product of a vector or matrix of numbers.
@xref{Statistical Operations}. Another approach would be to use
With a prefix argument, @kbd{y} inserts several numbers, one per line.
A positive argument inserts the specified number of values from the top
-of the stack. A negative argument inserts the @cite{n}th value from the
+of the stack. A negative argument inserts the @expr{n}th value from the
top of the stack. An argument of zero inserts the entire stack. Note
that @kbd{y} with an argument of 1 is slightly different from @kbd{y}
with no argument; the former always copies full lines, whereas the
With a lone @kbd{C-u} as a prefix argument, @kbd{y} @emph{replaces} the
region in the other buffer with the yanked text, then quits the
Calculator, leaving you in that buffer. A typical use would be to use
-@kbd{M-# g} to read a region of data into the Calculator, operate on the
+@kbd{C-x * g} to read a region of data into the Calculator, operate on the
data to produce a new matrix, then type @kbd{C-u y} to replace the
original data with the new data. One might wish to alter the matrix
display style (@pxref{Vector and Matrix Formats}) or change the current
display language (@pxref{Language Modes}) before doing this. Also, note
that this command replaces a linear region of text (as grabbed by
-@kbd{M-# g}), not a rectangle (as grabbed by @kbd{M-# r}).@refill
+@kbd{C-x * g}), not a rectangle (as grabbed by @kbd{C-x * r}).
If the editing buffer is in overwrite (as opposed to insert) mode,
and the @kbd{C-u} prefix was not used, then the yanked number will
``overwrite mode'' has thus been generalized from overwriting characters
to overwriting one complete number with another.
-@kindex M-# y
-The @kbd{M-# y} key sequence is equivalent to @kbd{y} except that
+@kindex C-x * y
+The @kbd{C-x * y} key sequence is equivalent to @kbd{y} except that
it can be typed anywhere, not just in Calc. This provides an easy
way to guarantee that Calc knows which editing buffer you want to use!
just by double-clicking on it in the shell, then middle-clicking
in the Calc window.
-@node Keypad Mode, Embedded Mode, Kill and Yank, Introduction
-@chapter ``Keypad'' Mode
+@node Keypad Mode, Embedded Mode, Kill and Yank, Top
+@chapter Keypad Mode
@noindent
-@kindex M-# k
+@kindex C-x * k
@pindex calc-keypad
-The @kbd{M-# k} (@code{calc-keypad}) command starts the Calculator
+The @kbd{C-x * k} (@code{calc-keypad}) command starts the Calculator
and displays a picture of a calculator-style keypad. If you are using
the X window system, you can click on any of the ``keys'' in the
keypad using the left mouse button to operate the calculator.
-The original window remains the selected window; in keypad mode
+The original window remains the selected window; in Keypad mode
you can type in your file while simultaneously performing
calculations with the mouse.
@pindex full-calc-keypad
-If you have used @kbd{M-# b} first, @kbd{M-# k} instead invokes
+If you have used @kbd{C-x * b} first, @kbd{C-x * k} instead invokes
the @code{full-calc-keypad} command, which takes over the whole
Emacs screen and displays the keypad, the Calc stack, and the Calc
trail all at once. This mode would normally be used when running
``key,'' and type @key{SPC} or @key{RET}. If you think this
is easier than using Calc normally, go right ahead.
-Calc commands are more or less the same in keypad mode. Certain
+Calc commands are more or less the same in Keypad mode. Certain
keypad keys differ slightly from the corresponding normal Calc
keystrokes; all such deviations are described below.
-Keypad Mode includes many more commands than will fit on the keypad
+Keypad mode includes many more commands than will fit on the keypad
at once. Click the right mouse button [@code{calc-keypad-menu}]
to switch to the next menu. The bottom five rows of the keypad
stay the same; the top three rows change to a new set of commands.
@smallexample
@group
-|----+-----Calc 2.00-----+----1
+|----+-----Calc 2.1------+----1
|FLR |CEIL|RND |TRNC|CLN2|FLT |
|----+----+----+----+----+----|
| LN |EXP | |ABS |IDIV|MOD |
@end smallexample
@noindent
-This is the menu that appears the first time you start Keypad Mode.
+This is the menu that appears the first time you start Keypad mode.
It will show up in a vertical window on the right side of your screen.
Above this menu is the traditional Calc stack display. On a 24-line
screen you will be able to see the top three stack entries.
stack.
The @key{INV} and @key{HYP} keys modify other keys. As well as
-having the effects described elsewhere in this manual, Keypad Mode
+having the effects described elsewhere in this manual, Keypad mode
defines several other ``inverse'' operations. These are described
below and in the following sections.
that would normally work in Calc mode. This can include a
numeric prefix if you wish. It is also possible simply to
switch into the Calc window and type commands in it; there is
-nothing ``magic'' about this window when Keypad Mode is active.
+nothing ``magic'' about this window when Keypad mode is active.
The other keys in this display perform their obvious calculator
functions. @key{CLN2} rounds the top-of-stack by temporarily
@item INV *
is the same as @key{y^x}.
@item INV /
-is the same as @key{INV y^x} (the @cite{x}th root of @cite{y}).
+is the same as @key{INV y^x} (the @expr{x}th root of @expr{y}).
@item HYP/INV 1
are the same as @key{SIN} / @kbd{INV SIN}.
@item HYP/INV 2
by the two limits of the interval.
@end table
-The @kbd{OFF} key turns Calc off; typing @kbd{M-# k} or @kbd{M-# M-#}
+The @kbd{OFF} key turns Calc off; typing @kbd{C-x * k} or @kbd{C-x * *}
again has the same effect. This is analogous to typing @kbd{q} or
-hitting @kbd{M-# c} again in the normal calculator. If Calc is
+hitting @kbd{C-x * c} again in the normal calculator. If Calc is
running standalone (the @code{full-calc-keypad} command appeared in the
command line that started Emacs), then @kbd{OFF} is replaced with
@kbd{EXIT}; clicking on this actually exits Emacs itself.
prefix keys.
@key{IMAG} multiplies the number on the stack by the imaginary
-number @cite{i = (0, 1)}.
+number @expr{i = (0, 1)}.
@key{RE} extracts the real part a complex number. @kbd{INV RE}
extracts the imaginary part.
@key{INV GCD} computes the LCM (least common multiple) function.
-@key{INV FACT} is the gamma function. @c{$\Gamma(x) = (x-1)!$}
-@cite{gamma(x) = (x-1)!}.
+@key{INV FACT} is the gamma function.
+@texline @math{\Gamma(x) = (x-1)!}.
+@infoline @expr{gamma(x) = (x-1)!}.
@key{PERM} is the number-of-permutations function, which is on the
@kbd{H k c} key in normal Calc.
For example, you could simulate @key{MAP^} using @key{MAP$} with
the formula @samp{x^y}.
-The @kbd{"x"} key pushes the variable name @cite{x} onto the
-stack. To build the formula @cite{x^2 + 6}, you would use the
+The @kbd{"x"} key pushes the variable name @expr{x} onto the
+stack. To build the formula @expr{x^2 + 6}, you would use the
key sequence @kbd{"x" 2 y^x 6 +}. This formula would then be
suitable for use with the @key{MAP$} key described above.
With @key{INV}, @key{HYP}, or @key{INV} and @key{HYP}, the
-@kbd{"x"} key pushes the variable names @cite{y}, @cite{z}, and
-@cite{t}, respectively.
+@kbd{"x"} key pushes the variable names @expr{y}, @expr{z}, and
+@expr{t}, respectively.
@node Keypad Modes Menu, , Keypad Vectors Menu, Keypad Mode
@section Modes Menu
The @key{STO} and @key{RCL} keys are analogous to @kbd{s t} and
@kbd{s r} in regular Calc. @xref{Store and Recall}. Click the
@key{STO} or @key{RCL} key, then one of the ten digits. (Named
-variables are not available in Keypad Mode.) You can also use,
+variables are not available in Keypad mode.) You can also use,
for example, @kbd{STO + 3} to add to register 3.
@node Embedded Mode, Programming, Keypad Mode, Top
@chapter Embedded Mode
@noindent
-Embedded Mode in Calc provides an alternative to copying numbers
+Embedded mode in Calc provides an alternative to copying numbers
and formulas back and forth between editing buffers and the Calc
-stack. In Embedded Mode, your editing buffer becomes temporarily
+stack. In Embedded mode, your editing buffer becomes temporarily
linked to the stack and this copying is taken care of automatically.
@menu
@section Basic Embedded Mode
@noindent
-@kindex M-# e
+@kindex C-x * e
@pindex calc-embedded
To enter Embedded mode, position the Emacs point (cursor) on a
-formula in any buffer and press @kbd{M-# e} (@code{calc-embedded}).
-Note that @kbd{M-# e} is not to be used in the Calc stack buffer
+formula in any buffer and press @kbd{C-x * e} (@code{calc-embedded}).
+Note that @kbd{C-x * e} is not to be used in the Calc stack buffer
like most Calc commands, but rather in regular editing buffers that
are visiting your own files.
+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{}.
+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}).
+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.
+
Calc normally scans backward and forward in the buffer for the
nearest opening and closing @dfn{formula delimiters}. The simplest
-delimiters are blank lines. Other delimiters that Embedded Mode
+delimiters are blank lines. Other delimiters that Embedded mode
understands are:
@enumerate
The @TeX{} and La@TeX{} math delimiters @samp{$ $}, @samp{$$ $$},
@samp{\[ \]}, and @samp{\( \)};
@item
-Lines beginning with @samp{\begin} and @samp{\end};
+Lines beginning with @samp{\begin} and @samp{\end} (except matrix delimiters);
@item
Lines beginning with @samp{@@} (Texinfo delimiters).
@item
on their own separate lines or in-line with the formula.
If you give a positive or negative numeric prefix argument, Calc
-instead uses the current point as one end of the formula, and moves
-forward or backward (respectively) by that many lines to find the
-other end. Explicit delimiters are not necessary in this case.
+instead uses the current point as one end of the formula, and includes
+that many lines forward or backward (respectively, including the current
+line). Explicit delimiters are not necessary in this case.
-With a prefix argument of zero, Calc uses the current region
-(delimited by point and mark) instead of formula delimiters.
+With a prefix argument of zero, Calc uses the current region (delimited
+by point and mark) instead of formula delimiters. With a prefix
+argument of @kbd{C-u} only, Calc uses the current line as the formula.
-@kindex M-# w
+@kindex C-x * w
@pindex calc-embedded-word
-With a prefix argument of @kbd{C-u} only, Calc scans for the first
-non-numeric character (i.e., the first character that is not a
-digit, sign, decimal point, or upper- or lower-case @samp{e})
-forward and backward to delimit the formula. @kbd{M-# w}
-(@code{calc-embedded-word}) is equivalent to @kbd{C-u M-# e}.
+The @kbd{C-x * w} (@code{calc-embedded-word}) command will start Embedded
+mode on the current ``word''; in this case Calc will scan for the first
+non-numeric character (i.e., the first character that is not a digit,
+sign, decimal point, or upper- or lower-case @samp{e}) forward and
+backward to delimit the formula.
When you enable Embedded mode for a formula, Calc reads the text
between the delimiters and tries to interpret it as a Calc formula.
-It's best if the current Calc language mode is correct for the
-formula, but Calc can generally identify @TeX{} formulas and
+Calc can generally identify @TeX{} formulas and
Big-style formulas even if the language mode is wrong. If Calc
can't make sense of the formula, it beeps and refuses to enter
Embedded mode. But if the current language is wrong, Calc can
the built-in @code{arctan} function, and the @samp{a[1]} will be
interpreted as @samp{a} times the vector @samp{[1]}!
-If you press @kbd{M-# e} or @kbd{M-# w} to activate an embedded
+If you press @kbd{C-x * e} or @kbd{C-x * w} to activate an embedded
formula which is blank, say with the cursor on the space between
the two delimiters @samp{$ $}, Calc will immediately prompt for
an algebraic entry.
When Embedded mode begins, Calc pushes the current formula onto
the stack. No Calc stack window is created; however, Calc copies
the top-of-stack position into the original buffer at all times.
-You can create a Calc window by hand with @kbd{M-# o} if you
+You can create a Calc window by hand with @kbd{C-x * o} if you
find you need to see the entire stack.
-For example, typing @kbd{M-# e} while somewhere in the formula
+For example, typing @kbd{C-x * e} while somewhere in the formula
@samp{n>2} in the following line enables Embedded mode on that
inequality:
@end example
@noindent
-The formula @cite{n>2} will be pushed onto the Calc stack, and
+The formula @expr{n>2} will be pushed onto the Calc stack, and
the top of stack will be copied back into the editing buffer.
This means that spaces will appear around the @samp{>} symbol
to match Calc's usual display style:
We define $F_n = F_(n-1)+F_(n-2)$ for all $2 < n$.
@end example
-The @kbd{M-# o} command is a useful way to open a Calc window
+The @kbd{C-x * o} command is a useful way to open a Calc window
without actually selecting that window. Giving this command
verifies that @samp{2 < n} is also on the Calc stack. Typing
@kbd{17 @key{RET}} would produce:
normally see the stack in Embedded mode, it is still there and
it still operates in the same way. But, as with old-fashioned
RPN calculators, you can only see the value at the top of the
-stack at any given time (unless you use @kbd{M-# o}).
+stack at any given time (unless you use @kbd{C-x * o}).
-Typing @kbd{M-# e} again turns Embedded mode off. The Calc
+Typing @kbd{C-x * e} again turns Embedded mode off. The Calc
window reveals that the formula @w{@samp{2 < n}} is automatically
removed from the stack, but the @samp{17} is not. Entering
Embedded mode always pushes one thing onto the stack, and
that happens on the stack is entirely your business as far as
Embedded mode is concerned.
-If you press @kbd{M-# e} in the wrong place by accident, it is
+If you press @kbd{C-x * e} in the wrong place by accident, it is
possible that Calc will be able to parse the nearby text as a
formula and will mangle that text in an attempt to redisplay it
``properly'' in the current language mode. If this happens,
-press @kbd{M-# e} again to exit Embedded mode, then give the
+press @kbd{C-x * e} again to exit Embedded mode, then give the
regular Emacs ``undo'' command (@kbd{C-_} or @kbd{C-x u}) to put
the text back the way it was before Calc edited it. Note that Calc's
own Undo command (typed before you turn Embedded mode back off)
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 @TeX{}-like @samp{\} sequences,
-it is parsed (i.e., read) in @TeX{} mode. If the formula appears to
+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
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
-to what it finds. Even though it can read a @TeX{} formula when
-not in @TeX{} mode, it will immediately rewrite this formula using
-whatever language mode is in effect. You must then type @kbd{d T}
-to switch Calc permanently into @TeX{} mode if that is what you
-desire.
+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
+whatever language mode is in effect.
@tex
\bigskip
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{}, so if your formula is
-embedded in a @TeX{} document its plain version will be
-invisible in the final printed copy. @xref{Customizing
-Embedded Mode}, to see how to change the ``plain'' formula
-delimiters, say to something that @dfn{eqn} or some other
-formatter will treat as a comment.
+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
+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.
+See @ref{Customizing Embedded Mode} to see how to change the ``plain''
+formula delimiters.
There are several notations which Calc's parser for ``big''
formatted formulas can't yet recognize. In particular, it can't
Embedded buffers remember active formulas for as long as they
exist in Emacs memory. Suppose you have an embedded formula
-which is @c{$\pi$}
-@cite{pi} to the normal 12 decimal places, and then
+which is @cpi{} to the normal 12 decimal places, and then
type @w{@kbd{C-u 5 d n}} to display only five decimal places.
If you then type @kbd{d n}, all 12 places reappear because the
full number is still there on the Calc stack. More surprisingly,
@r{(the value)}
@end smallexample
-@kindex M-# d
+@kindex C-x * d
@pindex calc-embedded-duplicate
-The @kbd{M-# d} (@code{calc-embedded-duplicate}) command is a
-handy way to make sequences like this. If you type @kbd{M-# d},
+The @kbd{C-x * d} (@code{calc-embedded-duplicate}) command is a
+handy way to make sequences like this. If you type @kbd{C-x * d},
the formula under the cursor (which may or may not have Embedded
mode enabled for it at the time) is copied immediately below and
Embedded mode is then enabled for that copy.
@end smallexample
@noindent
-and press @kbd{M-# d} with the cursor on this formula. The result
+and press @kbd{C-x * d} with the cursor on this formula. The result
is
@smallexample
@noindent
with the second copy of the formula enabled in Embedded mode.
You can now press @kbd{a d x @key{RET}} to take the derivative, and
-@kbd{M-# d M-# d} to make two more copies of the derivative.
+@kbd{C-x * d C-x * d} to make two more copies of the derivative.
To complete the computations, type @kbd{3 s l x @key{RET}} to evaluate
the last formula, then move up to the second-to-last formula
and type @kbd{2 s l x @key{RET}}.
-Finally, you would want to press @kbd{M-# e} to exit Embedded
+Finally, you would want to press @kbd{C-x * e} to exit Embedded
mode, then go up and insert the necessary text in between the
various formulas and numbers.
\bigskip
@end tex
-@kindex M-# f
-@kindex M-# '
+@kindex C-x * f
+@kindex C-x * '
@pindex calc-embedded-new-formula
-The @kbd{M-# f} (@code{calc-embedded-new-formula}) command
+The @kbd{C-x * f} (@code{calc-embedded-new-formula}) command
creates a new embedded formula at the current point. It inserts
some default delimiters, which are usually just blank lines,
and then does an algebraic entry to get the formula (which is
then enabled for Embedded mode). This is just shorthand for
typing the delimiters yourself, positioning the cursor between
-the new delimiters, and pressing @kbd{M-# e}. The key sequence
-@kbd{M-# '} is equivalent to @kbd{M-# f}.
+the new delimiters, and pressing @kbd{C-x * e}. The key sequence
+@kbd{C-x * '} is equivalent to @kbd{C-x * f}.
-@kindex M-# n
-@kindex M-# p
+@kindex C-x * n
+@kindex C-x * p
@pindex calc-embedded-next
@pindex calc-embedded-previous
-The @kbd{M-# n} (@code{calc-embedded-next}) and @kbd{M-# p}
+The @kbd{C-x * n} (@code{calc-embedded-next}) and @kbd{C-x * p}
(@code{calc-embedded-previous}) commands move the cursor to the
next or previous active embedded formula in the buffer. They
can take positive or negative prefix arguments to move by several
formulas. Note that these commands do not actually examine the
text of the buffer looking for formulas; they only see formulas
which have previously been activated in Embedded mode. In fact,
-@kbd{M-# n} and @kbd{M-# p} are a useful way to tell which
+@kbd{C-x * n} and @kbd{C-x * p} are a useful way to tell which
embedded formulas are currently active. Also, note that these
commands do not enable Embedded mode on the next or previous
-formula, they just move the cursor. (By the way, @kbd{M-# n} is
-not as awkward to type as it may seem, because @kbd{M-#} ignores
-Shift and Meta on the second keystroke: @kbd{M-# M-N} can be typed
-by holding down Shift and Meta and alternately typing two keys.)
+formula, they just move the cursor.
-@kindex M-# `
+@kindex C-x * `
@pindex calc-embedded-edit
-The @kbd{M-# `} (@code{calc-embedded-edit}) command edits the
+The @kbd{C-x * `} (@code{calc-embedded-edit}) command edits the
embedded formula at the current point as if by @kbd{`} (@code{calc-edit}).
Embedded mode does not have to be enabled for this to work. Press
-@kbd{M-# M-#} to finish the edit, or @kbd{M-# x} to cancel.
+@kbd{C-c C-c} to finish the edit, or @kbd{C-x k} to cancel.
@node Assignments in Embedded Mode, Mode Settings in Embedded Mode, More About Embedded Mode, Embedded Mode
@section Assignments in Embedded Mode
@end example
@noindent
-records @cite{5} as the stored value of @code{foo} for the
+records @expr{5} as the stored value of @code{foo} for the
purposes of Embedded mode operations in the current buffer. It
-does @emph{not} actually store @cite{5} as the ``global'' value
+does @emph{not} actually store @expr{5} as the ``global'' value
of @code{foo}, however. Regular Calc operations, and Embedded
formulas in other buffers, will not see this assignment.
Then, @kbd{17 @key{TAB} @key{DEL}} will swap the 17 into place (@pxref{Selecting
Subformulas}, to see how this works).
-@kindex M-# j
+@kindex C-x * j
@pindex calc-embedded-select
-The @kbd{M-# j} (@code{calc-embedded-select}) command provides an
-easy way to operate on assignments. It is just like @kbd{M-# e},
+The @kbd{C-x * j} (@code{calc-embedded-select}) command provides an
+easy way to operate on assignments. It is just like @kbd{C-x * e},
except that if the enabled formula is an assignment, it uses
@kbd{j 2} to select the righthand side. If the enabled formula
is an evaluates-to, it uses @kbd{j 1} to select the lefthand side.
@end example
@noindent
-in which case @kbd{M-# j} will select the middle part (@samp{foo + 3}).
+in which case @kbd{C-x * j} will select the middle part (@samp{foo + 3}).
The formula is automatically deselected when you leave Embedded
mode.
-@kindex M-# u
-@kindex M-# =
-@pindex calc-embedded-update
+@kindex C-x * u
+@pindex calc-embedded-update-formula
Another way to change the assignment to @code{foo} would simply be
to edit the number using regular Emacs editing rather than Embedded
mode. Then, we have to find a way to get Embedded mode to notice
-the change. The @kbd{M-# u} or @kbd{M-# =}
-(@code{calc-embedded-update-formula}) command is a convenient way
-to do this.@refill
+the change. The @kbd{C-x * u} (@code{calc-embedded-update-formula})
+command is a convenient way to do this.
@example
foo := 6
foo + 7 => 13
@end example
-Pressing @kbd{M-# u} is much like pressing @kbd{M-# e = M-# e}, that
+Pressing @kbd{C-x * u} is much like pressing @kbd{C-x * e = C-x * e}, that
is, temporarily enabling Embedded mode for the formula under the
-cursor and then evaluating it with @kbd{=}. But @kbd{M-# u} does
-not actually use @kbd{M-# e}, and in fact another formula somewhere
-else can be enabled in Embedded mode while you use @kbd{M-# u} and
+cursor and then evaluating it with @kbd{=}. But @kbd{C-x * u} does
+not actually use @kbd{C-x * e}, and in fact another formula somewhere
+else can be enabled in Embedded mode while you use @kbd{C-x * u} and
that formula will not be disturbed.
-With a numeric prefix argument, @kbd{M-# u} updates all active
+With a numeric prefix argument, @kbd{C-x * u} updates all active
@samp{=>} formulas in the buffer. Formulas which have not yet
been activated in Embedded mode, and formulas which do not have
@samp{=>} as their top-level operator, are not affected by this.
(This is useful only if you have used @kbd{m C}; see below.)
-With a plain @kbd{C-u} prefix, @kbd{C-u M-# u} updates only in the
+With a plain @kbd{C-u} prefix, @kbd{C-u C-x * u} updates only in the
region between mark and point rather than in the whole buffer.
-@kbd{M-# u} is also a handy way to activate a formula, such as an
+@kbd{C-x * u} is also a handy way to activate a formula, such as an
@samp{=>} formula that has freshly been typed in or loaded from a
file.
-@kindex M-# a
+@kindex C-x * a
@pindex calc-embedded-activate
-The @kbd{M-# a} (@code{calc-embedded-activate}) command scans
+The @kbd{C-x * a} (@code{calc-embedded-activate}) command scans
through the current buffer and activates all embedded formulas
that contain @samp{:=} or @samp{=>} symbols. This does not mean
that Embedded mode is actually turned on, but only that the
the @samp{=>} values can be properly updated as assignments are
changed.
-It is a good idea to type @kbd{M-# a} right after loading a file
+It is a good idea to type @kbd{C-x * a} right after loading a file
that uses embedded @samp{=>} operators. Emacs includes a nifty
``buffer-local variables'' feature that you can use to do this
automatically. The idea is to place near the end of your file
@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{} file, @samp{%} would be a good
+or omitted altogether; in a @TeX{} or La@TeX{} 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.
When Emacs loads a file into memory, it checks for a Local Variables
section like this one at the end of the file. If it finds this
section, it does the specified things (in this case, running
-@kbd{M-# a} automatically) before editing of the file begins.
+@kbd{C-x * a} automatically) before editing of the file begins.
The Local Variables section must be within 3000 characters of the
end of the file for Emacs to find it, and it must be in the last
page of the file if the file has any page separators.
@xref{File Variables, , Local Variables in Files, emacs, the
Emacs manual}.
-Note that @kbd{M-# a} does not update the formulas it finds.
-To do this, type, say, @kbd{M-1 M-# u} after @w{@kbd{M-# a}}.
+Note that @kbd{C-x * a} does not update the formulas it finds.
+To do this, type, say, @kbd{M-1 C-x * u} after @w{@kbd{C-x * a}}.
Generally this should not be a problem, though, because the
formulas will have been up-to-date already when the file was
saved.
-Normally, @kbd{M-# a} activates all the formulas it finds, but
+Normally, @kbd{C-x * a} activates all the formulas it finds, but
any previous active formulas remain active as well. With a
-positive numeric prefix argument, @kbd{M-# a} first deactivates
+positive numeric prefix argument, @kbd{C-x * a} first deactivates
all current active formulas, then actives the ones it finds in
its scan of the buffer. With a negative prefix argument,
-@kbd{M-# a} simply deactivates all formulas.
+@kbd{C-x * a} simply deactivates all formulas.
Embedded mode has two symbols, @samp{Active} and @samp{~Active},
which it puts next to the major mode name in a buffer's mode line.
It puts @samp{Active} if it has reason to believe that all
-formulas in the buffer are active, because you have typed @kbd{M-# a}
+formulas in the buffer are active, because you have typed @kbd{C-x * a}
and Calc has not since had to deactivate any formulas (which can
happen if Calc goes to update an @samp{=>} formula somewhere because
a variable changed, and finds that the formula is no longer there
due to some kind of editing outside of Embedded mode). Calc puts
@samp{~Active} in the mode line if some, but probably not all,
formulas in the buffer are active. This happens if you activate
-a few formulas one at a time but never use @kbd{M-# a}, or if you
-used @kbd{M-# a} but then Calc had to deactivate a formula
+a few formulas one at a time but never use @kbd{C-x * a}, or if you
+used @kbd{C-x * a} but then Calc had to deactivate a formula
because it lost track of it. If neither of these symbols appears
in the mode line, no embedded formulas are active in the buffer
-(e.g., before Embedded mode has been used, or after a @kbd{M-- M-# a}).
+(e.g., before Embedded mode has been used, or after a @kbd{M-- C-x * a}).
Embedded formulas can refer to assignments both before and after them
in the buffer. If there are several assignments to a variable, the
The @kbd{m C} (@code{calc-auto-recompute}) command turns automatic
recomputation of @samp{=>} forms on and off. If you turn automatic
-recomputation off, you will have to use @kbd{M-# u} to update these
+recomputation off, you will have to use @kbd{C-x * u} to update these
formulas manually after an assignment has been changed. If you
plan to change several assignments at once, it may be more efficient
-to type @kbd{m C}, change all the assignments, then use @kbd{M-1 M-# u}
+to type @kbd{m C}, change all the assignments, then use @kbd{M-1 C-x * u}
to update the entire buffer afterwards. The @kbd{m C} command also
controls @samp{=>} formulas on the stack; @pxref{Evaluates-To
Operator}. When you turn automatic recomputation back on, the
stack will be updated but the Embedded buffer will not; you must
-use @kbd{M-# u} to update the buffer by hand.
+use @kbd{C-x * u} to update the buffer by hand.
@node Mode Settings in Embedded Mode, Customizing Embedded Mode, Assignments in Embedded Mode, Embedded Mode
@section Mode Settings in Embedded Mode
+@kindex m e
+@pindex calc-embedded-preserve-modes
@noindent
-Embedded Mode has a rather complicated mechanism for handling mode
+The mode settings can be changed while Calc is in embedded mode, but
+by default they will revert to their original values when embedded mode
+is ended. However, the modes saved when the mode-recording mode is
+@code{Save} (see below) and the modes in effect when the @kbd{m e}
+(@code{calc-embedded-preserve-modes}) command is given
+will be preserved when embedded mode is ended.
+
+Embedded mode has a rather complicated mechanism for handling mode
settings in Embedded formulas. It is possible to put annotations
in the file that specify mode settings either global to the entire
file or local to a particular formula or formulas. In the latter
case, different modes can be specified for use when a formula
-is the enabled Embedded Mode formula.
+is the enabled Embedded mode formula.
-When you give any mode-setting command, like @kbd{m f} (for fraction
-mode) or @kbd{d s} (for scientific notation), Embedded Mode adds
+When you give any mode-setting command, like @kbd{m f} (for Fraction
+mode) or @kbd{d s} (for scientific notation), Embedded mode adds
a line like the following one to the file just before the opening
delimiter of the formula.
below).
The scan does not look for the leading @samp{% }, only for the
-square brackets and the text they enclose. You can edit the mode
-annotations to a style that works better in context if you wish.
+square brackets and the text they enclose. In fact, the leading
+characters are different for different major modes. You can edit the
+mode annotations to a style that works better in context if you wish.
@xref{Customizing Embedded Mode}, to see how to change the style
that Calc uses when it generates the annotations. You can write
mode annotations into the file yourself if you know the syntax;
the third is the value in the form of a Lisp symbol, number,
or list. Annotations with unrecognizable text in the first or
second parts are ignored. The third part is not checked to make
-sure the value is of a legal type or range; if you write an
+sure the value is of a valid type or range; if you write an
annotation by hand, be sure to give a proper value or results
will be unpredictable. Mode-setting annotations are case-sensitive.
-While Embedded Mode is enabled, the word @code{Local} appears in
+While Embedded mode is enabled, the word @code{Local} appears in
the mode line. This is to show that mode setting commands generate
annotations that are ``local'' to the current formula or set of
formulas. The @kbd{m R} (@code{calc-mode-record-mode}) command
@end example
The first kind of annotation will be used only while a formula
-is enabled in Embedded Mode. The second kind will be used only
+is enabled in Embedded mode. The second kind will be used only
when the formula is @emph{not} enabled. (Whether the formula
is ``active'' or not, i.e., whether Calc has seen this formula
yet, is not relevant here.)
the file, as long as those mode settings are suitable for all
formulas in the file.
-Enabling a formula with @kbd{M-# e} causes a fresh scan for local
+Enabling a formula with @kbd{C-x * e} causes a fresh scan for local
mode annotations; you will have to use this after adding annotations
above a formula by hand to get the formula to notice them. Updating
-a formula with @kbd{M-# u} will also re-scan the local modes, but
-global modes are only re-scanned by @kbd{M-# a}.
+a formula with @kbd{C-x * u} will also re-scan the local modes, but
+global modes are only re-scanned by @kbd{C-x * a}.
Another way that modes can get out of date is if you add a local
mode annotation to a formula that has another formula after it.
456.
@end example
-We would have to go down to the other formula and press @kbd{M-# u}
+We would have to go down to the other formula and press @kbd{C-x * u}
on it in order to get it to notice the new annotation.
-Two more mode-recording modes selectable by @kbd{m R} are @code{Save}
-(which works even outside of Embedded Mode), in which mode settings
-are recorded permanently in your Emacs startup file @file{~/.emacs}
+Two more mode-recording modes selectable by @kbd{m R} are available
+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{~/.calc.el})
rather than by annotating the current document, and no-recording
mode (where there is no symbol like @code{Save} or @code{Local} in
the mode line), in which mode-changing commands do not leave any
annotations at all.
-When Embedded Mode is not enabled, mode-recording modes except
+When Embedded mode is not enabled, mode-recording modes except
for @code{Save} have no effect.
@node Customizing Embedded Mode, , Mode Settings in Embedded Mode, Embedded Mode
@section Customizing Embedded Mode
@noindent
-You can modify Embedded Mode's behavior by setting various Lisp
-variables described here. Use @kbd{M-x set-variable} or
-@kbd{M-x edit-options} to adjust a variable on the fly, or
-put a suitable @code{setq} statement in your @file{~/.emacs}
-file to set a variable permanently. (Another possibility would
-be to use a file-local variable annotation at the end of the
-file; @pxref{File Variables, , Local Variables in Files, emacs, the
-Emacs manual}.)
-
-While none of these variables will be buffer-local by default, you
-can make any of them local to any embedded-mode buffer. (Their
-values in the @samp{*Calculator*} buffer are never used.)
+You can modify Embedded mode's behavior by setting various Lisp
+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;
+@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}).
@vindex calc-embedded-open-formula
The @code{calc-embedded-open-formula} variable holds a regular
@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{M-# w}
-instead of @kbd{M-# e} to enable Embedded mode.
+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-open-plain
The @code{calc-embedded-open-plain} variable is a string which
formula when @kbd{d p} mode is turned on. Note that this is an
actual string, not a regular expression, because Calc must be able
to write this string into a buffer as well as to recognize it.
-The default string is @code{"%%% "} (note the trailing space).
+The default string is @code{"%%% "} (note the trailing space), but may
+be different for certain major modes.
@vindex calc-embedded-close-plain
The @code{calc-embedded-close-plain} variable is a string which
-ends a ``plain'' formula. The default is @code{" %%%\n"}. Without
-the trailing newline here, the first line of a ``big'' mode formula
+ends a ``plain'' formula. The default is @code{" %%%\n"}, but may be
+different for different major modes. 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.
@vindex calc-embedded-open-new-formula
The @code{calc-embedded-open-new-formula} variable is a string
which is inserted at the front of a new formula when you type
-@kbd{M-# f}. Its default value is @code{"\n\n"}. If this
-string begins with a newline character and the @kbd{M-# f} is
-typed at the beginning of a line, @kbd{M-# f} will skip this
+@kbd{C-x * f}. Its default value is @code{"\n\n"}. If this
+string begins with a newline character and the @kbd{C-x * f} is
+typed at the beginning of a line, @kbd{C-x * f} will skip this
first newline to avoid introducing unnecessary blank lines in
the file.
The @code{calc-embedded-close-new-formula} variable is the corresponding
string which is inserted at the end of a new formula. Its default
value is also @code{"\n\n"}. The final newline is omitted by
-@w{@kbd{M-# f}} if typed at the end of a line. (It follows that if
-@kbd{M-# f} is typed on a blank line, both a leading opening
+@w{@kbd{C-x * f}} if typed at the end of a line. (It follows that if
+@kbd{C-x * f} is typed on a blank line, both a leading opening
newline and a trailing closing newline are omitted.)
@vindex calc-embedded-announce-formula
The @code{calc-embedded-announce-formula} variable is a regular
expression which is sure to be followed by an embedded formula.
-The @kbd{M-# a} command searches for this pattern as well as for
-@samp{=>} and @samp{:=} operators. Note that @kbd{M-# a} will
+The @kbd{C-x * a} command searches for this pattern as well as for
+@samp{=>} and @samp{:=} operators. Note that @kbd{C-x * a} will
not activate just anything surrounded by formula delimiters; after
all, blank lines are considered formula delimiters by default!
But if your language includes a delimiter which can only occur
actually in front of a formula, you can take advantage of it here.
-The default pattern is @code{"%Embed\n\\(% .*\n\\)*"}, which
-checks for @samp{%Embed} followed by any number of lines beginning
-with @samp{%} and a space. This last is important to make Calc
-consider mode annotations part of the pattern, so that the formula's
-opening delimiter really is sure to follow the pattern.
+The default pattern is @code{"%Embed\n\\(% .*\n\\)*"}, but may be
+different for different major modes.
+This pattern will check for @samp{%Embed} followed by any number of
+lines beginning with @samp{%} and a space. This last is important to
+make Calc consider mode annotations part of the pattern, so that the
+formula's opening delimiter really is sure to follow the pattern.
@vindex calc-embedded-open-mode
The @code{calc-embedded-open-mode} variable is a string (not a
Calc never scans for this string; Calc always looks for the
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{"% "}.
+The default is @code{"% "}, but may be different for different major
+modes.
@vindex calc-embedded-close-mode
The @code{calc-embedded-close-mode} variable is a string which
follows a mode annotation written by Calc. Its default value
-is simply a newline, @code{"\n"}. If you change this, it is a
-good idea still to end with a newline so that mode annotations
-will appear on lines by themselves.
+is simply a newline, @code{"\n"}, but may be different for different
+major modes. If you change this, it is a good idea still to end with a
+newline so that mode annotations will appear on lines by themselves.
-@node Programming, Installation, Embedded Mode, Top
+@node Programming, Customizing Calc, Embedded Mode, Top
@chapter Programming
@noindent
@pindex calc-user-define-permanent
@cindex Storing user definitions
@cindex Permanent user definitions
-@cindex @file{.emacs} file, user-defined commands
+@cindex Calc init file, user-defined commands
The @kbd{Z P} (@code{calc-user-define-permanent}) command makes a key
binding permanent so that it will remain in effect even in future Emacs
sessions. (It does this by adding a suitable bit of Lisp code into
-your @file{.emacs} file.) For example, @kbd{Z P s} would register
-our @code{sincos} command permanently. If you later wish to unregister
-this command you must edit your @file{.emacs} file by hand.
-(@xref{General Mode Commands}, for a way to tell Calc to use a
-different file instead of @file{.emacs}.)
+your Calc init file; that is, the file given by the variable
+@code{calc-settings-file}, typically @file{~/.calc.el}.) For example,
+@kbd{Z P s} would register our @code{sincos} command permanently. If
+you later wish to unregister this command you must edit your Calc init
+file by hand. (@xref{General Mode Commands}, for a way to tell Calc to
+use a different file for the Calc init file.)
The @kbd{Z P} command also saves the user definition, if any, for the
command bound to the key. After @kbd{Z F} and @kbd{Z C}, a given user
key could invoke a command, which in turn calls an algebraic function,
which might have one or more special display formats. A single @kbd{Z P}
command will save all of these definitions.
-
-To save a command or function without its key binding (or if there is
-no key binding for the command or function), type @kbd{'} (the apostrophe)
-when prompted for a key. Then, type the function name, or backspace
-to change the @samp{calcFunc-} prefix to @samp{calc-} and enter a
-command name. (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.)
+To save an algebraic function, type @kbd{'} (the apostrophe)
+when prompted for a key, and type the function name. To save a command
+without its key binding, type @kbd{M-x} and enter a function name. (The
+@samp{calc-} prefix will automatically be inserted for you.)
+(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.)
@kindex Z E
@pindex calc-user-define-edit
Press shift-@kbd{X} (or the standard Emacs key sequence @kbd{C-x e}) to
execute your keyboard macro by replaying the recorded keystrokes.
@xref{Keyboard Macros, , , emacs, the Emacs Manual}, for further
-information.@refill
+information.
When you use @kbd{X} to invoke a keyboard macro, the entire macro is
treated as a single command by the undo and trail features. The stack
just the @key{RET} key as in this example) will be something like
@samp{calc-User-n}. The keyboard macro will now be available as both
@kbd{z n} and @kbd{M-x calc-User-n}. You can backspace and enter a more
-descriptive command name if you wish.@refill
+descriptive command name if you wish.
Macros defined by @kbd{Z K} act like single commands; they are executed
in the same way as by the @kbd{X} key. If you wish to define the macro
@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{edit-kbd-macro}
-command to edit the macro. This command may be found in the
-@file{macedit} package, a copy of which comes with Calc. It decomposes
-the macro definition into full Emacs command names, like @code{calc-pop}
-and @code{calc-add}. Type @kbd{M-# M-#} to finish editing and update
-the definition stored on the key, or, to cancel the edit, type
-@kbd{M-# x}.@refill
-
-If you give a negative numeric prefix argument to @kbd{Z E}, the keyboard
-macro is edited in spelled-out keystroke form. For example, the editing
-buffer might contain the nine characters @w{@samp{1 @key{RET} 2 +}}. When you press
-@kbd{M-# M-#}, the @code{read-kbd-macro} feature of the @file{macedit}
-package is used to reinterpret these key names. The
-notations @code{RET}, @code{LFD}, @code{TAB}, @code{SPC}, @code{DEL}, and
-@code{NUL} must be written in all uppercase, as must the prefixes @code{C-}
-and @code{M-}. Spaces and line breaks are ignored. Other characters are
+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
+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},
+@code{DEL}, and @code{NUL} must be entered as these three character
+sequences, written in all uppercase, as must the prefixes @code{C-} and
+@code{M-}. Spaces and line breaks are ignored. Other characters are
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 @kbd{' [1 @key{SPC} 2 @key{SPC} 3] @key{RET}},
-which is what @code{read-kbd-macro} wants to see.@refill
-
-If @file{macedit} is not available, @kbd{Z E} edits the keyboard macro
-in ``raw'' form; the editing buffer simply contains characters like
-@samp{1^M2+} (here @samp{^M} represents the carriage-return character).
-Editing in this mode, you will have to use @kbd{C-q} to enter new
-control characters into the buffer.@refill
+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
+@kbd{' [1 @key{SPC} 2 @key{SPC} 3] @key{RET}}.
-@kindex M-# m
+@kindex C-x * m
@pindex read-kbd-macro
-The @kbd{M-# m} (@code{read-kbd-macro}) command reads an Emacs ``region''
+The @kbd{C-x * m} (@code{read-kbd-macro}) command reads an Emacs ``region''
of spelled-out keystrokes and defines it as the current keyboard macro.
It is a convenient way to define a keyboard macro that has been stored
in a file, or to define a macro without executing it at the same time.
-The @kbd{M-# m} command works only if @file{macedit} is present.
@node Conditionals in Macros, Loops in Macros, Naming Keyboard Macros, Keyboard Macros
@subsection Conditionals in Keyboard Macros
computes two to a nonnegative integer power. First, we push 1 on the
stack and then swap the integer argument back to the top. The @kbd{Z <}
pops that argument leaving the 1 back on top of the stack. Then, we
-repeat a multiply-by-two step however many times.@refill
+repeat a multiply-by-two step however many times.
Once again, the keyboard macro is executed as it is being entered.
In this case it is especially important to set up reasonable initial
Another approach is to enter a harmless dummy definition for the macro,
then go back and edit in the real one with a @kbd{Z E} command. Yet
another approach is to type the macro as written-out keystroke names
-in a buffer, then use @kbd{M-# m} (@code{read-kbd-macro}) to read the
+in a buffer, then use @kbd{C-x * m} (@code{read-kbd-macro}) to read the
macro.
@kindex Z /
innermost enclosing @kbd{Z <} @dots{} @kbd{Z >} loop and continues
after the @kbd{Z >}. If the object is false, the @kbd{Z /} has no
effect. Thus @kbd{@var{cond} Z /} is similar to @samp{if (@var{cond}) break;}
-in the C language.@refill
+in the C language.
@kindex Z (
@kindex Z )
a temporary internal counter and initializes it with the value @var{init}.
The @kbd{Z (} command then repeatedly pushes the counter value onto the
stack and executes @var{body} and @var{step}, adding @var{step} to the
-counter each time until the loop finishes.@refill
+counter each time until the loop finishes.
@cindex Summations (by keyboard macros)
By default, the loop finishes when the counter becomes greater than (or
is greater than @var{final} the body will not be executed at all.
Note that @var{step} may still be negative in this loop; the prefix
argument merely constrains the loop-finished test. Likewise, a prefix
-argument of @i{-1} forces downward-counting conventions.
+argument of @mathit{-1} forces downward-counting conventions.
@kindex Z @{
@kindex Z @}
@cindex Restoring saved modes
Keyboard macros sometimes want to operate under known conditions
without affecting surrounding conditions. For example, a keyboard
-macro may wish to turn on Fraction Mode, or set a particular
+macro may wish to turn on Fraction mode, or set a particular
precision, independent of the user's normal setting for those
modes.
In fact, @kbd{C-u Z `} is like @kbd{Z `} except that it sets the modes
listed above to their default values. As usual, the matching @kbd{Z '}
will restore the modes to their settings from before the @kbd{C-u Z `}.
-Also, @w{@kbd{Z `}} with a negative prefix argument resets algebraic mode
+Also, @w{@kbd{Z `}} with a negative prefix argument resets the algebraic mode
to its default (off) but leaves the other modes the same as they were
outside the construct.
@node Queries in Macros, , Local Values in Macros, Keyboard Macros
@subsection Queries in Keyboard Macros
-@noindent
-@kindex Z =
-@pindex calc-kbd-report
-The @kbd{Z =} (@code{calc-kbd-report}) command displays an informative
-message including the value on the top of the stack. You are prompted
-to enter a string. That string, along with the top-of-stack value,
-is displayed unless @kbd{m w} (@code{calc-working}) has been used
-to turn such messages off.
+@c @noindent
+@c @kindex Z =
+@c @pindex calc-kbd-report
+@c The @kbd{Z =} (@code{calc-kbd-report}) command displays an informative
+@c message including the value on the top of the stack. You are prompted
+@c to enter a string. That string, along with the top-of-stack value,
+@c is displayed unless @kbd{m w} (@code{calc-working}) has been used
+@c to turn such messages off.
+@noindent
@kindex Z #
@pindex calc-kbd-query
-The @kbd{Z #} (@code{calc-kbd-query}) command displays a prompt message
-(which you enter during macro definition), then does an algebraic entry
-which takes its input from the keyboard, even during macro execution.
-This command allows your keyboard macros to accept numbers or formulas
-as interactive input. All the normal conventions of algebraic input,
-including the use of @kbd{$} characters, are supported.
+The @kbd{Z #} (@code{calc-kbd-query}) command prompts for an algebraic
+entry which takes its input from the keyboard, even during macro
+execution. All the normal conventions of algebraic input, including the
+use of @kbd{$} characters, are supported. The prompt message itself is
+taken from the top of the stack, and so must be entered (as a string)
+before the @kbd{Z #} command. (Recall, as a string it can be entered by
+pressing the @kbd{"} key and will appear as a vector when it is put on
+the stack. The prompt message is only put on the stack to provide a
+prompt for the @kbd{Z #} command; it will not play any role in any
+subsequent calculations.) This command allows your keyboard macros to
+accept numbers or formulas as interactive input.
+
+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,
+will not be part of the macro.)
@xref{Keyboard Macro Query, , , emacs, the Emacs Manual}, for a description of
@kbd{C-x q} (@code{kbd-macro-query}), the standard Emacs way to accept
@node Invocation Macros, Algebraic Definitions, Keyboard Macros, Programming
@section Invocation Macros
-@kindex M-# z
+@kindex C-x * z
@kindex Z I
@pindex calc-user-invocation
@pindex calc-user-define-invocation
-Calc provides one special keyboard macro, called up by @kbd{M-# z}
+Calc provides one special keyboard macro, called up by @kbd{C-x * z}
(@code{calc-user-invocation}), that is intended to allow you to define
your own special way of starting Calc. To define this ``invocation
macro,'' create the macro in the usual way with @kbd{C-x (} and
@kbd{C-x )}, then type @kbd{Z I} (@code{calc-user-define-invocation}).
There is only one invocation macro, so you don't need to type any
additional letters after @kbd{Z I}. From now on, you can type
-@kbd{M-# z} at any time to execute your invocation macro.
+@kbd{C-x * z} at any time to execute your invocation macro.
For example, suppose you find yourself often grabbing rectangles of
numbers into Calc and multiplying their columns. You can do this
-by typing @kbd{M-# r} to grab, and @kbd{V R : *} to multiply columns.
-To make this into an invocation macro, just type @kbd{C-x ( M-# r
+by typing @kbd{C-x * r} to grab, and @kbd{V R : *} to multiply columns.
+To make this into an invocation macro, just type @kbd{C-x ( C-x * r
V R : * C-x )}, then @kbd{Z I}. Then, to multiply a rectangle of data,
-just mark the data in its buffer in the usual way and type @kbd{M-# z}.
+just mark the data in its buffer in the usual way and type @kbd{C-x * z}.
Invocation macros are treated like regular Emacs keyboard macros;
all the special features described above for @kbd{Z K}-style macros
-do not apply. @kbd{M-# z} is just like @kbd{C-x e}, except that it
+do not apply. @kbd{C-x * z} is just like @kbd{C-x e}, except that it
uses the macro that was last stored by @kbd{Z I}. (In fact, the
macro does not even have to have anything to do with Calc!)
@kbd{Z F @key{RET} spam @key{RET}} defines the new command as
@kbd{M-x calc-spam}, with no keyboard equivalent.
-The third prompt is for a function name. The default is to use the same
-name as the command name but with @samp{calcFunc-} in place of
-@samp{calc-}. This is the name you will use if you want to enter your
+The third prompt is for an algebraic function name. The default is to
+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
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
-formula @samp{yow(x,y)}.@refill
+formula @samp{yow(x,y)}.
The fourth prompt is for the function's argument list. This is used to
associate values on the stack with the variables that appear in the formula.
@samp{b} (respectively) in the formula, then simplify the formula and
push the result on the stack. In other words, @kbd{10 @key{RET} 100 z m}
would replace the 10 and 100 on the stack with the number 210, which is
-@cite{a + 2 b} with @cite{a=10} and @cite{b=100}. Likewise, the formula
-@samp{yow(10, 100)} will be evaluated by substituting @cite{a=10} and
-@cite{b=100} in the definition.
+@expr{a + 2 b} with @expr{a=10} and @expr{b=100}. Likewise, the formula
+@samp{yow(10, 100)} will be evaluated by substituting @expr{a=10} and
+@expr{b=100} in the definition.
You can rearrange the order of the names before pressing @key{RET} to
control which stack positions go to which variables in the formula. If
The final prompt is a y-or-n question concerning what to do if symbolic
arguments are given to your function. If you answer @kbd{y}, then
executing @kbd{z m} (using the original argument list @samp{(a b)}) with
-arguments @cite{10} and @cite{x} will leave the function in symbolic
+arguments @expr{10} and @expr{x} will leave the function in symbolic
form, i.e., @samp{yow(10,x)}. On the other hand, if you answer @kbd{n},
then the formula will always be expanded, even for non-constant
arguments: @samp{10 + 2 x}. If you never plan to feed algebraic
formulas to your new function, it doesn't matter how you answer this
-question.@refill
+question.
If you answered @kbd{y} to this question you can still cause a function
call to be expanded by typing @kbd{a "} (@code{calc-expand-formula}).
key onto the stack. Actually, it pushes a nameless function that
specifies both the argument list and the defining formula. You will get
an error message if the key is undefined, or if the key was not defined
-by a @kbd{Z F} command.@refill
+by a @kbd{Z F} command.
The @kbd{Z E} (@code{calc-user-define-edit}) command on a key that has
been defined by a formula uses a variant of the @code{calc-edit} command
-to edit the defining formula. Press @kbd{M-# M-#} to finish editing and
-store the new formula back in the definition, or @kbd{M-# x} to
+to edit the defining formula. Press @kbd{C-c C-c} to finish editing and
+store the new formula back in the definition, or kill the buffer with
+@kbd{C-x k} to
cancel the edit. (The argument list and other properties of the
definition are unchanged; to adjust the argument list, you can use
@kbd{Z G} to grab the function onto the stack, edit with @kbd{`}, and
used as a function definition. For example, the formula @samp{deriv(a^2,v)}
which might be used to define a new function @samp{dsqr(a,v)} will be
``simplified'' to 0 immediately upon entry since @code{deriv} considers
-@cite{a} to be constant with respect to @cite{v}. Turning off
+@expr{a} to be constant with respect to @expr{v}. Turning off
default simplifications cures this problem: The definition will be stored
in symbolic form without ever activating the @code{deriv} function. Press
@kbd{m D} to turn the default simplifications back on afterwards.
@code{expt}, @code{=}, @code{<}, @code{>}, @code{<=}, @code{>=},
@code{/=}, @code{1+}, @code{1-}, @code{logand}, @code{logior}, @code{logxor},
@code{logandc2}, @code{lognot}. Also, @code{~=} is an abbreviation for
-@code{math-nearly-equal}, which is useful in implementing Taylor series.@refill
+@code{math-nearly-equal}, which is useful in implementing Taylor series.
For other functions @var{func}, if a function by the name
@samp{calcFunc-@var{func}} exists it is used, otherwise if a function by the
is defined as a function it is used, otherwise @samp{calcFunc-@var{func}} is
used on the assumption that this is a to-be-defined math function. Also, if
the function name is quoted as in @samp{('integerp a)} the function name is
-always used exactly as written (but not quoted).@refill
+always used exactly as written (but not quoted).
Variable names have @samp{var-} prepended to them unless they appear in
the function's argument list or in an enclosing @code{let}, @code{let*},
@code{for}, or @code{foreach} form,
or their names already contain a @samp{-} character. Thus a reference to
-@samp{foo} is the same as a reference to @samp{var-foo}.@refill
+@samp{foo} is the same as a reference to @samp{var-foo}.
A few other Lisp extensions are available in @code{defmath} definitions:
a synonym of @code{setq}.) Specifically, the first argument of
@code{setq} can be an @code{nth}, @code{elt}, @code{car}, or @code{cdr} form,
in which case the effect is to store into the specified
-element of a list. Thus, @samp{(setq (elt m i j) x)} stores @cite{x}
+element of a list. Thus, @samp{(setq (elt m i j) x)} stores @expr{x}
into one element of a matrix.
@item
A @code{for} looping construct is available. For example,
@samp{(for ((i 0 10)) body)} executes @code{body} once for each
-binding of @cite{i} from zero to 10. This is like a @code{let}
-form in that @cite{i} is temporarily bound to the loop count
+binding of @expr{i} from zero to 10. This is like a @code{let}
+form in that @expr{i} is temporarily bound to the loop count
without disturbing its value outside the @code{for} construct.
Nested loops, as in @samp{(for ((i 0 10) (j 0 (1- i) 2)) body)},
-are also available. For each value of @cite{i} from zero to 10,
-@cite{j} counts from 0 to @cite{i-1} in steps of two. Note that
+are also available. For each value of @expr{i} from zero to 10,
+@expr{j} counts from 0 to @expr{i-1} in steps of two. Note that
@code{for} has the same general outline as @code{let*}, except
that each element of the header is a list of three or four
things, not just two.
@item
The @code{foreach} construct loops over elements of a list.
For example, @samp{(foreach ((x (cdr v))) body)} executes
-@code{body} with @cite{x} bound to each element of Calc vector
-@cite{v} in turn. The purpose of @code{cdr} here is to skip over
+@code{body} with @expr{x} bound to each element of Calc vector
+@expr{v} in turn. The purpose of @code{cdr} here is to skip over
the initial @code{vec} symbol in the vector.
@item
@item
The @code{return} function prematurely returns from the enclosing
-function. For example, @samp{(return (+ x y))} returns @cite{x+y}
+function. For example, @samp{(return (+ x y))} returns @expr{x+y}
as the value of a function. You can use @code{return} anywhere
inside the body of the function.
@end itemize
:"n * myfact(n-1)"
@end example
+A good place to put your @code{defmath} commands is your Calc init file
+(the file given by @code{calc-settings-file}, typically
+@file{~/.calc.el}), which will not be loaded until Calc starts.
If a file named @file{.emacs} exists in your home directory, Emacs reads
and executes the Lisp forms in this file as it starts up. While it may
-seem like a good idea to put your favorite @code{defmath} commands here,
+seem reasonable to put your favorite @code{defmath} commands there,
this has the unfortunate side-effect that parts of the Calculator must be
loaded in to process the @code{defmath} commands whether or not you will
-actually use the Calculator! A better effect can be had by writing
+actually use the Calculator! If you want to put the @code{defmath}
+commands there (for example, if you redefine @code{calc-settings-file}
+to be @file{.emacs}), a better effect can be had by writing
@example
(put 'calc-define 'thing '(progn
@smallexample
;;; Increase and decrease Calc precision. Dave Gillespie, 5/31/91.
-;;; (Include copyright or copyleft stuff here.)
+;; (Include copyright or copyleft stuff here.)
(defvar inc-prec-base-key "P"
"Base key for inc-prec.el commands.")
@code{calc-normalize}, and hand them to your function according to the
function's argument list. Your function may include @code{&optional} and
@code{&rest} parameters, so long as calling the function with @var{num}
-parameters is legal.
+parameters is valid.
Your function must return either a number or a formula in a form
acceptable to Calc, or a list of such numbers or formulas. These value(s)
In this example, the command @code{calc-foo} will evaluate the expression
@samp{foo(a,b)} if executed with no argument, or @samp{foo(a,b,n)} if
-executed with a numeric prefix argument of @cite{n}.
+executed with a numeric prefix argument of @expr{n}.
The other code string allowed is @samp{"m"} (unrelated to the usual @samp{"m"}
code as used with @code{defun}). It uses the numeric prefix argument as the
The argument must not be an incomplete vector, interval, or complex number.
(This is rarely needed since the Calculator itself will never call your
function with an incomplete argument. But there is nothing stopping your
-own Lisp code from calling your function with an incomplete argument.)@refill
+own Lisp code from calling your function with an incomplete argument.)
@item integer
@findex integer
@end ignore
@tindex mysin
A somewhat limited sine function could be defined as follows, using the
-well-known Taylor series expansion for @c{$\sin x$}
-@samp{sin(x)}:
+well-known Taylor series expansion for
+@texline @math{\sin x}:
+@infoline @samp{sin(x)}:
@smallexample
(defmath mysin ((float (anglep x)))
@end smallexample
The actual @code{sin} function in Calc works by first reducing the problem
-to a sine or cosine of a nonnegative number less than @c{$\pi \over 4$}
-@cite{pi/4}. This
+to a sine or cosine of a nonnegative number less than @cpiover{4}. This
ensures that the Taylor series will converge quickly. Also, the calculation
is carried out with two extra digits of precision to guard against cumulative
round-off in @samp{sum}. Finally, complex arguments are allowed and handled
series as before, and @code{mycos-raw} is a function analogous to
@code{mysin-raw} for cosines.
-The strategy is to ensure that @cite{x} is nonnegative before calling
+The strategy is to ensure that @expr{x} is nonnegative before calling
@code{mysin-raw}. This function then recursively reduces its argument
-to a suitable range, namely, plus-or-minus @c{$\pi \over 4$}
-@cite{pi/4}. Note that each
+to a suitable range, namely, plus-or-minus @cpiover{4}. Note that each
test, and particularly the first comparison against 7, is designed so
that small roundoff errors cannot produce an infinite loop. (Suppose
we compared with @samp{(two-pi)} instead; if due to roundoff problems
element is a formula string, then @code{calc-eval} sets all the
various Calc modes to their default values while the formula is
evaluated and formatted. For example, the precision is set to 12
-digits, digit grouping is turned off, and the normal language
+digits, digit grouping is turned off, and the Normal language
mode is used.
This same principle applies to the other options discussed below.
program actually considers the interaction with Calc's mode settings
to be a feature. This will avoid all sorts of potential ``gotchas'';
consider what happens with @samp{(calc-eval "sqrt(2)" 'num)}
-when the user has left Calc in symbolic mode or no-simplify mode.
+when the user has left Calc in Symbolic mode or No-Simplify mode.
As another example, @samp{(equal (calc-eval '("$<$$") nil a b) "1")}
-checks if the number in string @cite{a} is less than the one in
-string @cite{b}. Without using a list, the integer 1 might
+checks if the number in string @expr{a} is less than the one in
+string @expr{b}. Without using a list, the integer 1 might
come out in a variety of formats which would be hard to test for
conveniently: @code{"1"}, @code{"8#1"}, @code{"00001"}. (But
see ``Predicates'' mode, below.)
Large integers are stored as lists of the form @samp{(bigpos @var{d0}
@var{d1} @var{d2} @dots{})} for positive integers 1000000 or more, or
@samp{(bigneg @var{d0} @var{d1} @var{d2} @dots{})} for negative integers
-@i{-1000000} or less. Each @var{d} is a base-1000 ``digit,'' a Lisp integer
+@mathit{-1000000} or less. Each @var{d} is a base-1000 ``digit,'' a Lisp integer
from 0 to 999. The least significant digit is @var{d0}; the last digit,
@var{dn}, which is always nonzero, is the most significant digit. For
-example, the integer @i{-12345678} is stored as @samp{(bigneg 678 345 12)}.
+example, the integer @mathit{-12345678} is stored as @samp{(bigneg 678 345 12)}.
The distinction between small and large integers is entirely hidden from
the user. In @code{defmath} definitions, the Lisp predicate @code{integerp}
@samp{10^@var{p}} in absolute value (@var{p} represents the current
precision), and @var{exp} (the ``exponent'') is a fixnum. The value of
the float is @samp{@var{mant} * 10^@var{exp}}. For example, the number
-@i{-3.14} is stored as @samp{(float -314 -2) = -314*10^-2}. Other constraints
+@mathit{-3.14} is stored as @samp{(float -314 -2) = -314*10^-2}. Other constraints
are that the number 0.0 is always stored as @samp{(float 0 0)}, and,
except for the 0.0 case, the rightmost base-10 digit of @var{mant} is
always nonzero. (If the rightmost digit is zero, the number is
-rearranged by dividing @var{mant} by ten and incrementing @var{exp}.)@refill
+rearranged by dividing @var{mant} by ten and incrementing @var{exp}.)
Rectangular complex numbers are stored in the form @samp{(cplx @var{re}
@var{im})}, where @var{re} and @var{im} are each real numbers, either
integers, fractions, or floats. The value is @samp{@var{re} + @var{im}i}.
The @var{im} part is nonzero; complex numbers with zero imaginary
-components are converted to real numbers automatically.@refill
+components are converted to real numbers automatically.
Polar complex numbers are stored in the form @samp{(polar @var{r}
@var{theta})}, where @var{r} is a positive real value and @var{theta}
or @samp{(-pi ..@: pi)} radians, according to the current angular mode.
If the angle is 0 the value is converted to a real number automatically.
(If the angle is 180 degrees, the value is usually also converted to a
-negative real number.)@refill
+negative real number.)
Hours-minutes-seconds forms are stored as @samp{(hms @var{h} @var{m}
@var{s})}, where @var{h} is an integer or an integer-valued float (i.e.,
a float with @samp{@var{exp} >= 0}), @var{m} is an integer or integer-valued
float in the range @w{@samp{[0 ..@: 60)}}, and @var{s} is any real number
-in the range @samp{[0 ..@: 60)}.@refill
+in the range @samp{[0 ..@: 60)}.
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
which represent units are not stored in any special way; they are units
only because their names appear in the units table. If the value
cell contains a string, it is parsed to get the variable's value when
-the variable is used.@refill
+the variable is used.
A Lisp list with any other symbol as the first element is a function call.
The symbols @code{+}, @code{-}, @code{*}, @code{/}, @code{%}, @code{^},
wish to return multiple values. (The latter case is allowed only for
functions which are the outer-level call in an expression whose value is
about to be pushed on the stack; this feature is considered obsolete
-and is not used by any built-in Calc functions.)@refill
+and is not used by any built-in Calc functions.)
@node Interactive Lisp Functions, Stack Lisp Functions, Data Type Formats, Internals
@subsubsection Interactive Functions
previously void); or @samp{(eval @var{undo} @var{redo} @var{args} @dots{})},
which means that to undo requires calling the function @samp{(@var{undo}
@var{args} @dots{})} and, if the undo is later redone, calling
-@samp{(@var{redo} @var{args} @dots{})}.@refill
+@samp{(@var{redo} @var{args} @dots{})}.
@end defun
@defun calc-record-why msg args
(such as @code{integerp} or @code{numvecp}) which the arguments did not
satisfy; it is expanded to a suitable string such as ``Expected an
integer.'' The @code{reject-arg} function calls @code{calc-record-why}
-automatically; @pxref{Predicates}.@refill
+automatically; @pxref{Predicates}.
@end defun
@defun calc-is-inverse
end up at level @var{n}, the next-to-last at level @var{n}+1, etc.
The elements of @var{vals} are assumed to be valid Calc objects, and
are not evaluated, rounded, or renormalized in any way. If @var{vals}
-is an empty list, nothing happens.@refill
+is an empty list, nothing happens.
The stack elements are pushed without any sub-formula selections.
You can give an optional third argument to this function, which must
element will be next-to-last, etc. If @var{n} or @var{m} are out of
range, the command is aborted with a suitable error message. If @var{n}
is zero, the function returns an empty list. The stack elements are not
-evaluated, rounded, or renormalized.@refill
+evaluated, rounded, or renormalized.
If any stack elements contain selections, and selections have not
been disabled by the @kbd{j e} (@code{calc-enable-selections}) command,
stack elements. It can be given a third ``selection-mode'' argument
which selects other behaviors. If it is the symbol @code{t}, then
a selection in any of the requested stack elements produces an
-``illegal operation on selections'' error. If it is the symbol @code{full},
+``invalid operation on selections'' error. If it is the symbol @code{full},
the whole stack entry is always returned regardless of selections.
If it is the symbol @code{sel}, the selected portion is always returned,
or @code{nil} if there is no selection. (This mode ignores the @kbd{j e}
This function takes a Calc object and ``normalizes'' it. At the very
least this involves re-rounding floating-point values according to the
current precision and other similar jobs. Also, unless the user has
-selected no-simplify mode (@pxref{Simplification Modes}), this involves
+selected No-Simplify mode (@pxref{Simplification Modes}), this involves
actually evaluating a formula object by executing the function calls
it contains, and possibly also doing algebraic simplification, etc.
@end defun
argument to apply the operator over many stack entries. If the prefix
argument @var{arg} is @code{nil}, this uses @code{calc-enter-result}
as outlined above. Otherwise, it maps the function over several stack
-elements; @pxref{Prefix Arguments}. For example,@refill
+elements; @pxref{Prefix Arguments}. For example,
@smallexample
(defun calc-zeta (arg)
specified, nothing happens. When the argument is two or more,
the binary function @var{func} is reduced across the top @var{arg}
stack elements; when the argument is negative, the function is
-mapped between the next-to-top @i{-@var{arg}} stack elements and the
-top element.@refill
+mapped between the next-to-top @mathit{-@var{arg}} stack elements and the
+top element.
@end defun
@defun calc-stack-size
will be the @samp{.} line. If @var{n} is from 1 to the current stack size,
this will be the beginning of the first line of that stack entry's display.
If line numbers are enabled, this will move to the first character of the
-line number, not the stack entry itself.@refill
+line number, not the stack entry itself.
@end defun
@defun calc-substack-height n
one line long (i.e., no matrices are displayed), the return value will
be equal @var{n}+1 as long as @var{n} is in range. (Note that in Big
mode, the return value includes the blank lines that separate stack
-entries.)@refill
+entries.)
@end defun
@defun calc-refresh
display radix, which might change the appearance of existing stack
entries. (During a keyboard macro invoked by the @kbd{X} key, refreshing
is suppressed, but a flag is set so that the entire stack will be refreshed
-rather than just the top few elements when the macro finishes.)@refill
+rather than just the top few elements when the macro finishes.)
@end defun
@node Predicates, Computational Lisp Functions, Stack Lisp Functions, Internals
by checking whether @samp{@var{x} - @var{y}} is @code{negp}. In
@code{defmath}, the expression @samp{(< x y)} will automatically be
converted to @samp{(lessp x y)}; expressions involving @code{>}, @code{<=},
-and @code{>=} are similarly converted in terms of @code{lessp}.@refill
+and @code{>=} are similarly converted in terms of @code{lessp}.
@end defun
@defun beforep x y
Returns true if @var{x} and @var{n} are numerically equal, where @var{n}
is a fixnum which is not a multiple of 10. This will automatically be
used by @code{defmath} in place of the more general @code{math-equal}
-whenever possible.@refill
+whenever possible.
@end defun
@defun nearly-equal x y
Abort the current function evaluation due to unacceptable argument values.
This calls @samp{(calc-record-why @var{pred} @var{val})}, then signals a
Lisp error which @code{normalize} will trap. The net effect is that the
-function call which led here will be left in symbolic form.@refill
+function call which led here will be left in symbolic form.
@end defun
@defun inexact-value
-If Symbolic Mode is enabled, this will signal an error that causes
+If Symbolic mode is enabled, this will signal an error that causes
@code{normalize} to leave the formula in symbolic form, with the message
-``Inexact result.'' (This function has no effect when not in Symbolic Mode.)
-Note that if your function calls @samp{(sin 5)} in Symbolic Mode, the
+``Inexact result.'' (This function has no effect when not in Symbolic mode.)
+Note that if your function calls @samp{(sin 5)} in Symbolic mode, the
@code{sin} function will call @code{inexact-value}, which will cause your
function to be left unsimplified. You may instead wish to call
-@samp{(normalize (list 'calcFunc-sin 5))}, which in Symbolic Mode will
-return the formula @samp{sin(5)} to your function.@refill
+@samp{(normalize (list 'calcFunc-sin 5))}, which in Symbolic mode will
+return the formula @samp{sin(5)} to your function.
@end defun
@defun overflow
the documentation refers to the @code{calc-sqrt} [@code{sqrt}] command,
this means @code{calc-sqrt} is an interactive stack-based square-root
command and @code{sqrt} (which @code{defmath} expands to @code{calcFunc-sqrt})
-is the actual Lisp function for taking square roots.@refill
+is the actual Lisp function for taking square roots.
The functions @code{math-add}, @code{math-sub}, @code{math-mul},
@code{math-div}, @code{math-mod}, and @code{math-neg} are not included
in this list, since @code{defmath} allows you to write native Lisp
@code{+}, @code{-}, @code{*}, @code{/}, @code{%}, and unary @code{-},
-respectively, instead.@refill
+respectively, instead.
@defun normalize val
(Full form: @code{math-normalize}.)
small. All the various data types are similarly converted to their standard
forms. Variables are left alone, but function calls are actually evaluated
in formulas. For example, normalizing @samp{(+ 2 (calcFunc-abs -4))} will
-return 6.@refill
+return 6.
If a function call fails, because the function is void or has the wrong
number of parameters, or because it returns @code{nil} or calls
@code{reject-arg} or @code{inexact-result}, @code{normalize} returns
-the formula still in symbolic form.@refill
+the formula still in symbolic form.
-If the current Simplification Mode is ``none'' or ``numeric arguments
+If the current simplification mode is ``none'' or ``numeric arguments
only,'' @code{normalize} will act appropriately. However, the more
-powerful simplification modes (like algebraic simplification) are
+powerful simplification modes (like Algebraic Simplification) are
not handled by @code{normalize}. They are handled by @code{calc-normalize},
which calls @code{normalize} and possibly some other routines, such
as @code{simplify} or @code{simplify-units}. Programs generally will
never call @code{calc-normalize} except when popping or pushing values
-on the stack.@refill
+on the stack.
@end defun
@defun evaluate-expr expr
Replace all variables in @var{expr} that have values with their values,
then use @code{normalize} to simplify the result. This is what happens
-when you press the @kbd{=} key interactively.@refill
+when you press the @kbd{=} key interactively.
@end defun
@defmac with-extra-prec n body
@end defun
@defun compare x y
-Compare the numbers @var{x} and @var{y}, and return @i{-1} if
+Compare the numbers @var{x} and @var{y}, and return @mathit{-1} if
@samp{(lessp @var{x} @var{y})}, 1 if @samp{(lessp @var{y} @var{x})},
0 if @samp{(math-equal @var{x} @var{y})}, or 2 if the order is
-undefined or cannot be determined.@refill
+undefined or cannot be determined.
@end defun
@defun numdigs n
@end defun
@defun scale-int x n
-Shift integer @var{x} left @var{n} decimal digits, or right @i{-@var{n}}
+Shift integer @var{x} left @var{n} decimal digits, or right @mathit{-@var{n}}
digits with truncation toward zero.
@end defun
@defun idivmod x y
Divide integer @var{x} by integer @var{y}; return a cons cell whose
@code{car} is @samp{(quotient @var{x} @var{y})} and whose @code{cdr}
-is @samp{(imod @var{x} @var{y})}.@refill
+is @samp{(imod @var{x} @var{y})}.
@end defun
@defun pow x y
Compute @var{x} to the power @var{y}. In @code{defmath} code, this can
also be written @samp{(^ @var{x} @var{y})} or
-@w{@samp{(expt @var{x} @var{y})}}.@refill
+@w{@samp{(expt @var{x} @var{y})}}.
@end defun
@defun abs-approx x
the absolute values of the components.
@end defun
-@findex two-pi
+@findex e
+@findex gamma-const
+@findex ln-2
+@findex ln-10
+@findex phi
@findex pi-over-2
@findex pi-over-4
@findex pi-over-180
@findex sqrt-two-pi
@findex sqrt-e
-@findex e
-@findex ln-2
-@findex ln-10
+@findex two-pi
@defun pi
The function @samp{(pi)} computes @samp{pi} to the current precision.
Other related constant-generating functions are @code{two-pi},
@code{pi-over-2}, @code{pi-over-4}, @code{pi-over-180}, @code{sqrt-two-pi},
-@code{e}, @code{sqrt-e}, @code{ln-2}, and @code{ln-10}. Each function
-returns a floating-point value in the current precision, and each uses
-caching so that all calls after the first are essentially free.@refill
+@code{e}, @code{sqrt-e}, @code{ln-2}, @code{ln-10}, @code{phi} and
+@code{gamma-const}. Each function returns a floating-point value in the
+current precision, and each uses caching so that all calls after the
+first are essentially free.
@end defun
@defmac math-defcache @var{func} @var{initial} @var{form}
two least significant digits is stored in the cache. For example,
calling @samp{(pi)} with a precision of 30 computes @samp{pi} to 34
digits, rounds it down to 32 digits for future use, then rounds it
-again to 30 digits for use in the present request.@refill
+again to 30 digits for use in the present request.
@end defmac
@findex half-circle
If the current angular mode is Degrees or HMS, this function returns the
integer 360. In Radians mode, this function returns either the
corresponding value in radians to the current precision, or the formula
-@samp{2*pi}, depending on the Symbolic Mode. There are also similar
+@samp{2*pi}, depending on the Symbolic mode. There are also similar
function @code{half-circle} and @code{quarter-circle}.
@end defun
@defun div-mod a b m
Divide @var{a} by @var{b}, modulo @var{m}. This returns @code{nil} if
-there is no solution, or if any of the arguments are not integers.@refill
+there is no solution, or if any of the arguments are not integers.
@end defun
@defun pow-mod a b m
@end defun
@defun to-radians-2 a
-Like @code{to-radians}, except that in Symbolic Mode a degrees to
+Like @code{to-radians}, except that in Symbolic mode a degrees to
radians conversion yields a formula like @samp{@var{a}*pi/180}.
@end defun
@defun from-radians-2 a
-Like @code{from-radians}, except that in Symbolic Mode a radians to
+Like @code{from-radians}, except that in Symbolic mode a radians to
degrees conversion yields a formula like @samp{@var{a}*180/pi}.
@end defun
@var{iters} parameter is the number of Fermat iterations to use, in the
case that this is necessary. If @code{prime-test} returns ``maybe,''
you can call it again with the same @var{n} to get a greater certainty;
-@code{prime-test} remembers where it left off.@refill
+@code{prime-test} remembers where it left off.
@end defun
@defun to-simple-fraction f
@defun quarter-integer n
If @var{n} is an integer or integer-valued float, this function
returns zero. If @var{n} is a half-integer (i.e., an integer plus
-@i{1:2} or 0.5), it returns 2. If @var{n} is a quarter-integer,
+@mathit{1:2} or 0.5), it returns 2. If @var{n} is a quarter-integer,
it returns 1 or 3. If @var{n} is anything else, this function
returns @code{nil}.
@end defun
produce lists of more than two dimensions. Note that the object
@samp{[[1, 2, 3], [4, 5]]} is a vector of vectors not all the same size,
and is treated by this and other Calc routines as a plain vector of two
-elements.@refill
+elements.
@end defun
@defun dimension-error
For example, @samp{(map-vec-2 'math-add v 1)} returns the vector @var{v}
with each element increased by one. Note that using @samp{'+} would not
work here, since @code{defmath} does not expand function names everywhere,
-just where they are in the function position of a Lisp expression.@refill
+just where they are in the function position of a Lisp expression.
@end defun
@defun reduce-vec f v
element of the result matrix will be @code{eq} to the corresponding
element of @var{m}, but none of the @code{cons} cells that make up
the structure of the matrix will be @code{eq}. If @var{m} is a plain
-vector, this is the same as @code{copy-sequence}.@refill
+vector, this is the same as @code{copy-sequence}.
@end defun
@defun swap-rows m r1 r2
function changes @var{m} itself rather than building up a new result
matrix. The return value is @var{m}, i.e., @samp{(eq (swap-rows m 1 2) m)}
is true, with the side effect of exchanging the first two rows of
-@var{m}.@refill
+@var{m}.
@end defun
@node Symbolic Lisp Functions, Formatting Lisp Functions, Vector Lisp Functions, Internals
implemented by temporarily binding the variable @code{math-living-dangerously}
to @code{t} (using a @code{let} form) and calling @code{simplify}.
Dangerous simplification rules are written to check this variable
-before taking any action.@refill
+before taking any action.
@end defun
@defun simplify-units expr
if it returns a result @code{equal} to the original @code{expr}, it is
ignored and Calc goes on to try the next simplification rule that applies.
If the function body returns something different, that new formula is
-substituted for @var{expr} in the original formula.@refill
+substituted for @var{expr} in the original formula.
At each point in the formula, rules are tried in the order of the
original calls to @code{math-defsimplify}; the search stops after the
This is really a pair of rules written with one @code{math-defsimplify}
for convenience; the first replaces @samp{arcsinh(-x)} with
@samp{-arcsinh(x)}, and the second, which is safe only for real @samp{x},
-replaces @samp{arcsinh(sinh(x))} with @samp{x}.@refill
+replaces @samp{arcsinh(sinh(x))} with @samp{x}.
@end defmac
@defun common-constant-factor expr
rational numbers. This is the fraction composed of the GCD of the
numerators of @var{a} and @var{b}, over the GCD of the denominators.
It is used by @code{common-constant-factor}. Note that the standard
-@code{gcd} function uses the LCM to combine the denominators.@refill
+@code{gcd} function uses the LCM to combine the denominators.
@end defun
@defun map-tree func expr many
@var{func} functions may @emph{not} make destructive changes to
@var{expr}. If a third argument @var{many} is provided, it is an
integer which says how many times @var{func} may be applied; the
-default, as described above, is infinitely many times.@refill
+default, as described above, is infinitely many times.
@end defun
@defun compile-rewrites rules
cosines of more complicated arguments. An integration rule should return
@code{nil} if it can't do the integral; if several rules are defined for
the same function, they are tried in order until one returns a non-@code{nil}
-result.@refill
+result.
@end defmac
@defmac math-defintegral-2 funcs body
Define a rule for integrating a function or functions of two arguments.
This is exactly analogous to @code{math-defintegral}, except that @var{body}
is written as the body of a function with two arguments, @var{u} and
-@var{v}.@refill
+@var{v}.
@end defmac
@defun solve-for lhs rhs var full
which return a rearranged equation or a functional inverse, respectively.
If @var{full} is non-@code{nil}, a full solution including dummy signs
and dummy integers will be produced. User-defined inverses are provided
-as properties in a manner similar to derivatives:@refill
+as properties in a manner similar to derivatives:
@smallexample
(put 'calcFunc-ln 'math-inverse
@code{expr-contains} uses @code{equal} to test for matches, whereas
@code{calc-find-sub-formula} uses @code{eq}. In the formula
@samp{f(a, a)}, the two @samp{a}s will be @code{equal} but not
-@code{eq} to each other.@refill
+@code{eq} to each other.
@end defun
@defun expr-contains-count expr var
Returns the number of occurrences of @var{var} as a subexpression
-of @var{expr}, or @code{nil} if there are no occurrences.@refill
+of @var{expr}, or @code{nil} if there are no occurrences.
@end defun
@defun expr-depends expr var
Returns a copy of @var{expr}, with all occurrences of @var{old} replaced
by @var{new}. This treats @code{lambda} forms specially with respect
to the dummy argument variables, so that the effect is always to return
-@var{expr} evaluated at @var{old} = @var{new}.@refill
+@var{expr} evaluated at @var{old} = @var{new}.
@end defun
@defun multi-subst expr old new
@defun expr-height expr
Returns the ``height'' of @var{expr}, which is the deepest level to
which function calls are nested. (Note that @samp{@var{a} + @var{b}}
-counts as a function call.) For primitive objects, this returns zero.@refill
+counts as a function call.) For primitive objects, this returns zero.
@end defun
@defun polynomial-p expr var
(@code{calc-expand}), would consist of a sum of terms in which @var{var}
appears only raised to nonnegative integer powers. Note that if
@var{var} does not occur in @var{expr}, then @var{expr} is considered
-a polynomial of degree 0.@refill
+a polynomial of degree 0.
@end defun
@defun is-polynomial expr var degree loose
themselves. For example, @samp{sin(x) x^2 + cos(x)} is a loose
polynomial with coefficients @samp{((calcFunc-cos x) 0 (calcFunc-sin
x))}. The result will never be @code{nil} in loose mode, since any
-expression can be interpreted as a ``constant'' loose polynomial.@refill
+expression can be interpreted as a ``constant'' loose polynomial.
@end defun
@defun polynomial-base expr pred
The default predicate uses @samp{(polynomial-p mpb-top-expr @var{subexpr})};
you can use @var{pred} to specify additional conditions. Or, you could
have @var{pred} build up a list of every suitable @var{subexpr} that
-is found.@refill
+is found.
@end defun
@defun poly-simplify poly
Mix two polynomial lists @var{a} and @var{b} (in the form returned by
@code{is-polynomial}) in a linear combination with coefficient expressions
@var{ac} and @var{bc}. The result is a (not necessarily simplified)
-polynomial list representing @samp{@var{ac} @var{a} + @var{bc} @var{b}}.@refill
+polynomial list representing @samp{@var{ac} @var{a} + @var{bc} @var{b}}.
@end defun
@defun poly-mul a b
list @var{poly} applied to variable @var{var}. The @kbd{a c}
(@code{calc-collect}) command uses @code{is-polynomial} to turn an
expression into a coefficient list, then @code{build-polynomial-expr}
-to turn the list back into an expression in regular form.@refill
+to turn the list back into an expression in regular form.
@end defun
@defun check-unit-name var
Return true if @var{expr} contains any variables which can be
interpreted as units. If @var{sub-exprs} is @code{t}, the entire
expression is searched. If @var{sub-exprs} is @code{nil}, this
-checks whether @var{expr} is directly a units expression.@refill
+checks whether @var{expr} is directly a units expression.
@end defun
@defun single-units-in-expr-p expr
is @code{nil}, use Calc's native base units. Otherwise, @var{which}
can specify a units system, which is a list of two-element lists,
where the first element is a Calc base symbol name and the second
-is an expression to substitute for it.@refill
+is an expression to substitute for it.
@end defun
@defun remove-units expr
not have the form of a valid expression, return a list of the form
@samp{(error @var{pos} @var{msg})} where @var{pos} is an integer index
into @var{str} of the general location of the error, and @var{msg} is
-a string describing the problem.@refill
+a string describing the problem.
@end defun
@defun read-exprs str
If @var{prompt} is given, it is the prompt string to use; the default
is ``Algebraic:''. If @var{no-norm} is @code{t}, the formulas will
be returned exactly as parsed; otherwise, they will be passed through
-@code{calc-normalize} first.@refill
+@code{calc-normalize} first.
To support the use of @kbd{$} characters in the algebraic entry, use
@code{let} to bind @code{calc-dollar-values} to a list of the values
to be substituted for @kbd{$}, @kbd{$$}, and so on, and bind
@code{calc-dollar-used} to 0. Upon return, @code{calc-dollar-used}
will have been changed to the highest number of consecutive @kbd{$}s
-that actually appeared in the input.@refill
+that actually appeared in the input.
@end defun
@defun format-number a
complex number format, and point character, are ignored to ensure the
result will be re-readable. The @var{prec} parameter is normally 0; if
you pass a large integer like 1000 instead, the expression will be
-surrounded by parentheses unless it is a plain number or variable name.@refill
+surrounded by parentheses unless it is a plain number or variable name.
@end defun
@defun format-nice-expr a width
contain newline characters to separate the lines. The @var{w}
parameter, if given, is the target window size for which to format
the expressions. If @var{w} is omitted, the width of the Calculator
-window is used.@refill
+window is used.
@end defun
@defun compose-expr a prec
@defun comp-first-char c
If composition @var{c} is a ``flat'' composition, return the first
(leftmost) character of the composition as an integer. Otherwise,
-return @code{nil}.@refill
+return @code{nil}.
@end defun
@defun comp-last-char c
@defvar calc-end-hook
This hook is called by @code{calc-quit}, generally because the user
-presses @kbd{q} or @kbd{M-# c} while in Calc. The Calc buffer will
+presses @kbd{q} or @kbd{C-x * c} while in Calc. The Calc buffer will
be the current buffer. The hook is called as the very first
step, before the Calc window is destroyed.
@end defvar
@defvar calc-window-hook
-If this hook exists, it is called to create the Calc window.
+If this hook is non-@code{nil}, it is called to create the Calc window.
Upon return, this new Calc window should be the current window.
(The Calc buffer will already be the current buffer when the
hook is called.) If the hook is not defined, Calc will
@end defvar
@defvar calc-trail-window-hook
-If this hook exists, it is called to create the Calc Trail window.
-The variable @code{calc-trail-buffer} will contain the buffer
-which the window should use. Unlike @code{calc-window-hook},
-this hook must @emph{not} switch into the new window.
+If this hook is non-@code{nil}, it is called to create the Calc Trail
+window. The variable @code{calc-trail-buffer} will contain the buffer
+which the window should use. Unlike @code{calc-window-hook}, this hook
+must @emph{not} switch into the new window.
+@end defvar
+
+@defvar calc-embedded-mode-hook
+This hook is called the first time that Embedded mode is entered.
+@end defvar
+
+@defvar calc-embedded-new-buffer-hook
+This hook is called each time that Embedded mode is entered in a
+new buffer.
+@end defvar
+
+@defvar calc-embedded-new-formula-hook
+This hook is called each time that Embedded mode is enabled for a
+new formula.
@end defvar
@defvar calc-edit-mode-hook
@defvar calc-mode-save-hook
This hook is called by the @code{calc-save-modes} command,
after Calc's own mode features have been inserted into the
-@file{.emacs} buffer and just before the ``End of mode settings''
+Calc init file and just before the ``End of mode settings''
message is inserted.
@end defvar
@defvar calc-reset-hook
-This hook is called after @kbd{M-# 0} (@code{calc-reset}) has
+This hook is called after @kbd{C-x * 0} (@code{calc-reset}) has
reset all modes. The Calc buffer will be the current buffer.
@end defvar
list and also call @code{make-local-variable} itself.
@end defvar
-@node Installation, Reporting Bugs, Programming, Top
-@appendix Installation
-
-@noindent
-As of Calc 2.02g, Calc is integrated with GNU Emacs, and thus requires
-no separate installation of its Lisp files and this manual.
-
-@appendixsec The GNUPLOT Program
+@node Customizing Calc, Reporting Bugs, Programming, Top
+@appendix Customizing Calc
-@noindent
-Calc's graphing commands use the GNUPLOT program. If you have GNUPLOT
-but you must type some command other than @file{gnuplot} to get it,
-you should add a command to set the Lisp variable @code{calc-gnuplot-name}
-to the appropriate file name. You may also need to change the variables
-@code{calc-gnuplot-plot-command} and @code{calc-gnuplot-print-command} in
-order to get correct displays and hardcopies, respectively, of your
-plots.@refill
+The usual prefix for Calc is the key sequence @kbd{C-x *}. If you wish
+to use a different prefix, you can put
-@ifinfo
@example
-
+(global-set-key "NEWPREFIX" 'calc-dispatch)
@end example
-@end ifinfo
-@appendixsec Printed Documentation
@noindent
-Because the Calc manual is so large, you should only make a printed
-copy if you really need it. To print the manual, you will need the
-@TeX{} typesetting program (this is a free program by Donald Knuth
-at Stanford University) as well as the @file{texindex} program and
-@file{texinfo.tex} file, both of which can be obtained from the FSF
-as part of the @code{texinfo} package.@refill
+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
+convenient for users who use a different prefix, the prefix can be
+followed by @kbd{=}, @kbd{&}, @kbd{#}, @kbd{\}, @kbd{/}, @kbd{+} or
+@kbd{-} as well as @kbd{*} to start Calc, and so in many cases the last
+character of the prefix can simply be typed twice.
+
+Calc is controlled by many variables, most of which can be reset
+from within Calc. Some variables are less involved with actual
+calculation, and can be set outside of Calc using Emacs's
+customization facilities. These variables are listed below.
+Typing @kbd{M-x customize-variable RET @var{variable-name} RET}
+will bring up a buffer in which the variable's value can be redefined.
+Typing @kbd{M-x customize-group RET calc RET} will bring up a buffer which
+contains all of Calc's customizable variables. (These variables can
+also be reset by putting the appropriate lines in your .emacs file;
+@xref{Init File, ,Init File, emacs, The GNU Emacs Manual}.)
+
+Some of the customizable variables are regular expressions. A regular
+expression is basically a pattern that Calc can search for.
+See @ref{Regexp Search,, Regular Expression Search, emacs, The GNU Emacs Manual}
+to see how regular expressions work.
+
+@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.
+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
+exists) the first time Calc is invoked.
+
+The default value for this variable is @code{"~/.calc.el"}.
+@end defvar
-To print the Calc manual in one huge 470 page tome, you will need the
-source code to this manual, @file{calc.texi}, available as part of the
-Emacs source. Once you have this file, type @kbd{texi2dvi calc.texi}.
-Alternatively, change to the @file{man} subdirectory of the Emacs
-source distribution, and type @kbd{make calc.dvi}. (Don't worry if you
-get some ``overfull box'' warnings while @TeX{} runs.)
+@defvar calc-gnuplot-name
+See @ref{Graphics}.@*
+The variable @code{calc-gnuplot-name} should be the name of the
+GNUPLOT program (a string). If you have GNUPLOT installed on your
+system but Calc is unable to find it, you may need to set this
+variable. (@pxref{Customizing Calc})
+You may also need to set some Lisp variables to show Calc how to run
+GNUPLOT on your system, see @ref{Devices, ,Graphical Devices} . The default value
+of @code{calc-gnuplot-name} is @code{"gnuplot"}.
+@end defvar
-The result will be a device-independent output file called
-@file{calc.dvi}, which you must print in whatever way is right
-for your system. On many systems, the command is
+@defvar calc-gnuplot-plot-command
+@defvarx calc-gnuplot-print-command
+See @ref{Devices, ,Graphical Devices}.@*
+The variables @code{calc-gnuplot-plot-command} and
+@code{calc-gnuplot-print-command} represent system commands to
+display and print the output of GNUPLOT, respectively. These may be
+@code{nil} if no command is necessary, or strings which can include
+@samp{%s} to signify the name of the file to be displayed or printed.
+Or, these variables may contain Lisp expressions which are evaluated
+to display or print the output.
+
+The default value of @code{calc-gnuplot-plot-command} is @code{nil},
+and the default value of @code{calc-gnuplot-print-command} is
+@code{"lp %s"}.
+@end defvar
+@defvar calc-language-alist
+See @ref{Basic Embedded Mode}.@*
+The variable @code{calc-language-alist} controls the languages that
+Calc will associate with major modes. When Calc embedded mode is
+enabled, it will try to use the current major mode to
+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,
+@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}.
+
+The default value of @code{calc-language-alist} is
@example
-lpr -d calc.dvi
+ ((latex-mode . latex)
+ (tex-mode . tex)
+ (plain-tex-mode . tex)
+ (context-mode . tex)
+ (nroff-mode . eqn)
+ (pascal-mode . pascal)
+ (c-mode . c)
+ (c++-mode . c)
+ (fortran-mode . fortran)
+ (f90-mode . fortran))
@end example
+@end defvar
-@noindent
-or
-
+@defvar calc-embedded-announce-formula
+@defvarx calc-embedded-announce-formula-alist
+See @ref{Customizing Embedded Mode}.@*
+The variable @code{calc-embedded-announce-formula} helps determine
+what formulas @kbd{C-x * a} will activate in a buffer. It is a
+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{:=}.)
+
+The default pattern is @code{"%Embed\n\\(% .*\n\\)*"}, which checks
+for @samp{%Embed} followed by any number of lines beginning with
+@samp{%} and a space.
+
+The variable @code{calc-embedded-announce-formula-alist} is used to
+set @code{calc-embedded-announce-formula} to different regular
+expressions depending on the major mode of the editing buffer.
+It consists of a list of pairs of the form @code{(@var{MAJOR-MODE} .
+@var{REGEXP})}, and its default value is
@example
-dvips calc.dvi
+ ((c++-mode . "//Embed\n\\(// .*\n\\)*")
+ (c-mode . "/\\*Embed\\*/\n\\(/\\* .*\\*/\n\\)*")
+ (f90-mode . "!Embed\n\\(! .*\n\\)*")
+ (fortran-mode . "C Embed\n\\(C .*\n\\)*")
+ (html-helper-mode . "<!-- Embed -->\n\\(<!-- .* -->\n\\)*")
+ (html-mode . "<!-- Embed -->\n\\(<!-- .* -->\n\\)*")
+ (nroff-mode . "\\\\\"Embed\n\\(\\\\\" .*\n\\)*")
+ (pascal-mode . "@{Embed@}\n\\(@{.*@}\n\\)*")
+ (sgml-mode . "<!-- Embed -->\n\\(<!-- .* -->\n\\)*")
+ (xml-mode . "<!-- Embed -->\n\\(<!-- .* -->\n\\)*")
+ (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}
+and @code{calc-embedded-open-close-mode-alist}.
+@end defvar
-@c the bumpoddpages macro was deleted
-@ignore
-@cindex Marginal notes, adjusting
-Marginal notes for each function and key sequence normally alternate
-between the left and right sides of the page, which is correct if the
-manual is going to be bound as double-sided pages. Near the top of
-the file @file{calc.texi} you will find alternate definitions of
-the @code{\bumpoddpages} macro that put the marginal notes always on
-the same side, best if you plan to be binding single-sided pages.
-@end ignore
+@defvar calc-embedded-open-formula
+@defvarx calc-embedded-close-formula
+@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
+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
+nearest text matching these regular expressions to be the ``formula
+delimiters''.
-@appendixsec Settings File
+The simplest delimiters are blank lines. Other delimiters that
+Embedded mode understands by default are:
+@enumerate
+@item
+The @TeX{} and La@TeX{} math delimiters @samp{$ $}, @samp{$$ $$},
+@samp{\[ \]}, and @samp{\( \)};
+@item
+Lines beginning with @samp{\begin} and @samp{\end} (except matrix delimiters);
+@item
+Lines beginning with @samp{@@} (Texinfo delimiters).
+@item
+Lines beginning with @samp{.EQ} and @samp{.EN} (@dfn{eqn} delimiters);
+@item
+Lines containing a single @samp{%} or @samp{.\"} symbol and nothing else.
+@end enumerate
-@noindent
-@vindex calc-settings-file
-Another variable you might want to set is @code{calc-settings-file},
-which holds the file name in which commands like @kbd{m m} and @kbd{Z P}
-store ``permanent'' definitions. The default value for this variable
-is @code{"~/.emacs"}. If @code{calc-settings-file} does not contain
-@code{".emacs"} as a substring, and if the variable
-@code{calc-loaded-settings-file} is @code{nil}, then Calc will
-automatically load your settings file (if it exists) the first time
-Calc is invoked.@refill
+The variable @code{calc-embedded-open-close-formula-alist} is used to
+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
+@code{(@var{MAJOR-MODE} @var{OPEN-FORMULA-REGEXP}
+@var{CLOSE-FORMULA-REGEXP})}, and its default value is
+@code{nil}.
+@end defvar
-@ifinfo
-@example
+@defvar calc-embedded-open-word
+@defvarx calc-embedded-close-word
+@defvarx calc-embedded-open-close-word-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.
+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{nil}.
+@end defvar
-@end example
-@end ifinfo
-@appendixsec Testing the Installation
+@defvar calc-embedded-open-plain
+@defvarx calc-embedded-close-plain
+@defvarx calc-embedded-open-close-plain-alist
+See @ref{Customizing Embedded Mode}.@*
+The variables @code{calc-embedded-open-plain} and
+@code{calc-embedded-open-plain} are used to delimit ``plain''
+formulas. Note that these are actual strings, not regular
+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
+@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.
-@noindent
-To test your installation of Calc, start a new Emacs and type @kbd{M-# c}
-to make sure the autoloads and key bindings work. Type @kbd{M-# i}
-to make sure Calc can find its Info documentation. Press @kbd{q} to
-exit the Info system and @kbd{M-# c} to re-enter the Calculator.
-Type @kbd{20 S} to compute the sine of 20 degrees; this will test the
-autoloading of the extensions modules. The result should be
-0.342020143326. Finally, press @kbd{M-# c} again to make sure the
-Calculator can exit.
+The variable @code{calc-embedded-open-close-plain-alist} is used to
+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
+@code{(@var{MAJOR-MODE} @var{OPEN-PLAIN-STRING}
+@var{CLOSE-PLAIN-STRING})}, and its default value is
+@example
+ ((c++-mode "// %% " " %%\n")
+ (c-mode "/* %% " " %% */\n")
+ (f90-mode "! %% " " %%\n")
+ (fortran-mode "C %% " " %%\n")
+ (html-helper-mode "<!-- %% " " %% -->\n")
+ (html-mode "<!-- %% " " %% -->\n")
+ (nroff-mode "\\\" %% " " %%\n")
+ (pascal-mode "@{%% " " %%@}\n")
+ (sgml-mode "<!-- %% " " %% -->\n")
+ (xml-mode "<!-- %% " " %% -->\n")
+ (texinfo-mode "@@c %% " " %%\n"))
+@end example
+Any major modes added to @code{calc-embedded-open-close-plain-alist}
+should also be added to @code{calc-embedded-announce-formula-alist}
+and @code{calc-embedded-open-close-mode-alist}.
+@end defvar
-You may also wish to test the GNUPLOT interface; to plot a sine wave,
-type @kbd{' [0 ..@: 360], sin(x) @key{RET} g f}. Type @kbd{g q} when you
-are done viewing the plot.
+@defvar calc-embedded-open-new-formula
+@defvarx calc-embedded-close-new-formula
+@defvarx calc-embedded-open-close-new-formula-alist
+See @ref{Customizing Embedded Mode}.@*
+The variables @code{calc-embedded-open-new-formula} and
+@code{calc-embedded-close-new-formula} are strings which are
+inserted before and after a new formula when you type @kbd{C-x * f}.
+
+The default value of @code{calc-embedded-open-new-formula} is
+@code{"\n\n"}. If this string begins with a newline character and the
+@kbd{C-x * f} is typed at the beginning of a line, @kbd{C-x * f} will skip
+this first newline to avoid introducing unnecessary blank lines in the
+file. The default value of @code{calc-embedded-close-new-formula} is
+also @code{"\n\n"}. The final newline is omitted by @w{@kbd{C-x * f}}
+if typed at the end of a line. (It follows that if @kbd{C-x * f} is
+typed on a blank line, both a leading opening newline and a trailing
+closing newline are omitted.)
+
+The variable @code{calc-embedded-open-close-new-formula-alist} is used to
+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
+@code{(@var{MAJOR-MODE} @var{OPEN-NEW-FORMULA-STRING}
+@var{CLOSE-NEW-FORMULA-STRING})}, and its default value is
+@code{nil}.
+@end defvar
-Calc is now ready to use. If you wish to go through the Calc Tutorial,
-press @kbd{M-# t} to begin.
+@defvar calc-embedded-open-mode
+@defvarx calc-embedded-close-mode
+@defvarx calc-embedded-open-close-mode-alist
+See @ref{Customizing Embedded Mode}.@*
+The variables @code{calc-embedded-open-mode} and
+@code{calc-embedded-close-mode} are strings which Calc will place before
+and after any mode annotations that it inserts. Calc never scans for
+these strings; Calc always looks for the annotation itself, so it is not
+necessary to add them to user-written annotations.
+
+The default value of @code{calc-embedded-open-mode} is @code{"% "}
+and the default value of @code{calc-embedded-close-mode} is
+@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.
+
+The variable @code{calc-embedded-open-close-mode-alist} is used to
+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
+@code{(@var{MAJOR-MODE} @var{OPEN-MODE-STRING}
+@var{CLOSE-MODE-STRING})}, and its default value is
@example
-
+ ((c++-mode "// " "\n")
+ (c-mode "/* " " */\n")
+ (f90-mode "! " "\n")
+ (fortran-mode "C " "\n")
+ (html-helper-mode "<!-- " " -->\n")
+ (html-mode "<!-- " " -->\n")
+ (nroff-mode "\\\" " "\n")
+ (pascal-mode "@{ " " @}\n")
+ (sgml-mode "<!-- " " -->\n")
+ (xml-mode "<!-- " " -->\n")
+ (texinfo-mode "@@c " "\n"))
@end example
-@node Reporting Bugs, Summary, Installation, Top
+Any major modes added to @code{calc-embedded-open-close-mode-alist}
+should also be added to @code{calc-embedded-announce-formula-alist}
+and @code{calc-embedded-open-close-plain-alist}.
+@end defvar
+
+@node Reporting Bugs, Summary, Customizing Calc, Top
@appendix Reporting Bugs
@noindent
-If you find a bug in Calc, send e-mail to Colin Walters,
+If you find a bug in Calc, send e-mail to Jay Belanger,
@example
-walters@@debian.org @r{or}
-walters@@verbum.org
+belanger@@truman.edu
@end example
@noindent
-(In the following text, ``I'' refers to the original Calc author, Dave
-Gillespie).
-
-While I cannot guarantee that I will have time to work on your bug,
-I do try to fix bugs quickly whenever I can.
-
-The latest version of Calc is available from Savannah, in the Emacs
-CVS tree. See @uref{http://savannah.gnu.org/projects/emacs}.
-
There is an automatic command @kbd{M-x report-calc-bug} which helps
you to report bugs. This command prompts you for a brief subject
line, then leaves you in a mail editing buffer. Type @kbd{C-c C-c} to
reporting a Calc bug; this command sends mail to the maintainer's
regular mailbox.
-If you have suggestions for additional features for Calc, I would
-love to hear them. Some have dared to suggest that Calc is already
-top-heavy with features; I really don't see what they're talking
-about, so, if you have ideas, send them right in. (I may even have
-time to implement them!)
+If you have suggestions for additional features for Calc, please send
+them. Some have dared to suggest that Calc is already top-heavy with
+features; this obviously cannot be the case, so if you have ideas, send
+them right in.
At the front of the source file, @file{calc.el}, is a list of ideas for
-future work which I have not had time to do. If any enthusiastic souls
-wish to take it upon themselves to work on these, I would be delighted.
-Please let me know if you plan to contribute to Calc so I can coordinate
-your efforts with mine and those of others. I will do my best to help
-you in whatever way I can.
+future work. If any enthusiastic souls wish to take it upon themselves
+to work on these, please send a message (using @kbd{M-x report-calc-bug})
+so any efforts can be coordinated.
+
+The latest version of Calc is available from Savannah, in the Emacs
+CVS tree. See @uref{http://savannah.gnu.org/projects/emacs}.
@c [summary]
@node Summary, Key Index, Reporting Bugs, Top
@appendix Calc Summary
@noindent
-This section includes a complete list of Calc 2.02 keystroke commands.
+This section includes a complete list of Calc 2.1 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).
@advance@baselineskip-2.5pt
@let@c@sumbreak
@end iftex
-@r{ @: M-# a @: @: 33 @:calc-embedded-activate@:}
-@r{ @: M-# b @: @: @:calc-big-or-small@:}
-@r{ @: M-# c @: @: @:calc@:}
-@r{ @: M-# d @: @: @:calc-embedded-duplicate@:}
-@r{ @: M-# e @: @: 34 @:calc-embedded@:}
-@r{ @: M-# f @:formula @: @:calc-embedded-new-formula@:}
-@r{ @: M-# g @: @: 35 @:calc-grab-region@:}
-@r{ @: M-# i @: @: @:calc-info@:}
-@r{ @: M-# j @: @: @:calc-embedded-select@:}
-@r{ @: M-# k @: @: @:calc-keypad@:}
-@r{ @: M-# l @: @: @:calc-load-everything@:}
-@r{ @: M-# m @: @: @:read-kbd-macro@:}
-@r{ @: M-# n @: @: 4 @:calc-embedded-next@:}
-@r{ @: M-# o @: @: @:calc-other-window@:}
-@r{ @: M-# p @: @: 4 @:calc-embedded-previous@:}
-@r{ @: M-# q @:formula @: @:quick-calc@:}
-@r{ @: M-# r @: @: 36 @:calc-grab-rectangle@:}
-@r{ @: M-# s @: @: @:calc-info-summary@:}
-@r{ @: M-# t @: @: @:calc-tutorial@:}
-@r{ @: M-# u @: @: @:calc-embedded-update@:}
-@r{ @: M-# w @: @: @:calc-embedded-word@:}
-@r{ @: M-# x @: @: @:calc-quit@:}
-@r{ @: M-# y @: @:1,28,49 @:calc-copy-to-buffer@:}
-@r{ @: M-# z @: @: @:calc-user-invocation@:}
-@r{ @: M-# : @: @: 36 @:calc-grab-sum-down@:}
-@r{ @: M-# _ @: @: 36 @:calc-grab-sum-across@:}
-@r{ @: M-# ` @:editing @: 30 @:calc-embedded-edit@:}
-@r{ @: M-# 0 @:(zero) @: @:calc-reset@:}
+@r{ @: C-x * a @: @: 33 @:calc-embedded-activate@:}
+@r{ @: C-x * b @: @: @:calc-big-or-small@:}
+@r{ @: C-x * c @: @: @:calc@:}
+@r{ @: C-x * d @: @: @:calc-embedded-duplicate@:}
+@r{ @: C-x * e @: @: 34 @:calc-embedded@:}
+@r{ @: C-x * f @:formula @: @:calc-embedded-new-formula@:}
+@r{ @: C-x * g @: @: 35 @:calc-grab-region@:}
+@r{ @: C-x * i @: @: @:calc-info@:}
+@r{ @: C-x * j @: @: @:calc-embedded-select@:}
+@r{ @: C-x * k @: @: @:calc-keypad@:}
+@r{ @: C-x * l @: @: @:calc-load-everything@:}
+@r{ @: C-x * m @: @: @:read-kbd-macro@:}
+@r{ @: C-x * n @: @: 4 @:calc-embedded-next@:}
+@r{ @: C-x * o @: @: @:calc-other-window@:}
+@r{ @: C-x * p @: @: 4 @:calc-embedded-previous@:}
+@r{ @: C-x * q @:formula @: @:quick-calc@:}
+@r{ @: C-x * r @: @: 36 @:calc-grab-rectangle@:}
+@r{ @: C-x * s @: @: @:calc-info-summary@:}
+@r{ @: C-x * t @: @: @:calc-tutorial@:}
+@r{ @: C-x * u @: @: @:calc-embedded-update-formula@:}
+@r{ @: C-x * w @: @: @:calc-embedded-word@:}
+@r{ @: C-x * x @: @: @:calc-quit@:}
+@r{ @: C-x * y @: @:1,28,49 @:calc-copy-to-buffer@:}
+@r{ @: C-x * z @: @: @:calc-user-invocation@:}
+@r{ @: C-x * : @: @: 36 @:calc-grab-sum-down@:}
+@r{ @: C-x * _ @: @: 36 @:calc-grab-sum-across@:}
+@r{ @: C-x * ` @:editing @: 30 @:calc-embedded-edit@:}
+@r{ @: C-x * 0 @:(zero) @: @:calc-reset@:}
@c
@r{ @: 0-9 @:number @: @:@:number}
@r{ @: . @:number @: @:@:0.number}
@r{ @: _ @:number @: @:-@:number}
@r{ @: e @:number @: @:@:1e number}
-@r{ @: # @:number @: @:@:current-radix@t{#}number}
+@r{ @: # @:number @: @:@:current-radix@tfn{#}number}
@r{ @: P @:(in number) @: @:+/-@:}
@r{ @: M @:(in number) @: @:mod@:}
@r{ @: @@ ' " @: (in number)@: @:@:HMS form}
@r{ @: d O @: @: 50 @:calc-flat-language@:}
@r{ @: d P @: @: 50 @:calc-pascal-language@:}
@r{ @: d T @: @: 50 @:calc-tex-language@:}
+@r{ @: d L @: @: 50 @:calc-latex-language@:}
@r{ @: d U @: @: 50 @:calc-unformatted-language@:}
@r{ @: d W @: @: 50 @:calc-maple-language@:}
@c
@r{ @: m a @: @: 12,13 @:calc-algebraic-mode@:}
@r{ @: m d @: @: @:calc-degrees-mode@:}
+@r{ @: m e @: @: @:calc-embedded-preserve-modes@:}
@r{ @: m f @: @: 12 @:calc-frac-mode@:}
@r{ @: m g @: @: 52 @:calc-get-modes@:}
@r{ @: m h @: @: @:calc-hms-mode@:}
@r{ @: s d @:var, decl @: @:calc-declare-variable@:}
@r{ @: s e @:var, editing @: 29,30 @:calc-edit-variable@:}
@r{ @: s i @:buffer @: @:calc-insert-variables@:}
+@r{ @: s k @:const, var @: 29 @:calc-copy-special-constant@:}
@r{ a b@: s l @:var @: 29 @:@:a (letting var=b)}
@r{ a ...@: s m @:op, var @: 22,29 @:calc-store-map@:}
@r{ @: s n @:var @: 29,47 @:calc-store-neg@: (v/-1)}
@r{ @: s & @:var @: 29,47 @:calc-store-inv@: (v^-1)}
@r{ @: s [ @:var @: 29,47 @:calc-store-decr@: (v-1)}
@r{ @: s ] @:var @: 29,47 @:calc-store-incr@: (v-(-1))}
-@r{ a b@: s : @: @: 2 @:assign@:(a,b) a @t{:=} b}
-@r{ a@: s = @: @: 1 @:evalto@:(a,b) a @t{=>}}
+@r{ a b@: s : @: @: 2 @:assign@:(a,b) a @tfn{:=} b}
+@r{ a@: s = @: @: 1 @:evalto@:(a,b) a @tfn{=>}}
@c
@r{ @: t [ @: @: 4 @:calc-trail-first@:}
@c
@r{ @: Z ` @: @: @:calc-kbd-push@:}
@r{ @: Z ' @: @: @:calc-kbd-pop@:}
-@r{ a@: Z = @:message @: 28 @:calc-kbd-report@:}
-@r{ @: Z # @:prompt @: @:calc-kbd-query@:}
+@r{ @: Z # @: @: @:calc-kbd-query@:}
@c
@r{ comp@: Z C @:func, args @: 50 @:calc-user-define-composition@:}
@enumerate
@c 1
@item
-Positive prefix arguments apply to @cite{n} stack entries.
-Negative prefix arguments apply to the @cite{-n}th stack entry.
+Positive prefix arguments apply to @expr{n} stack entries.
+Negative prefix arguments apply to the @expr{-n}th stack entry.
A prefix of zero applies to the entire stack. (For @key{LFD} and
@kbd{M-@key{DEL}}, the meaning of the sign is reversed.)
@c 2
@item
-Positive prefix arguments apply to @cite{n} stack entries.
+Positive prefix arguments apply to @expr{n} stack entries.
Negative prefix arguments apply to the top stack entry
-and the next @cite{-n} stack entries.
+and the next @expr{-n} stack entries.
@c 3
@item
-Positive prefix arguments rotate top @cite{n} stack entries by one.
-Negative prefix arguments rotate the entire stack by @cite{-n}.
+Positive prefix arguments rotate top @expr{n} stack entries by one.
+Negative prefix arguments rotate the entire stack by @expr{-n}.
A prefix of zero reverses the entire stack.
@c 4
@c 5
@item
-Positive prefix arguments specify a precision @cite{p}.
-Negative prefix arguments reduce the current precision by @cite{-p}.
+Positive prefix arguments specify a precision @expr{p}.
+Negative prefix arguments reduce the current precision by @expr{-p}.
@c 6
@item
@c 9
@item
-Positive prefix arguments specify a word size of @cite{w} bits, unsigned.
-Negative prefix arguments specify a word size of @cite{w} bits, signed.
+Positive prefix arguments specify a word size of @expr{w} bits, unsigned.
+Negative prefix arguments specify a word size of @expr{w} bits, signed.
@c 10
@item
-Prefix arguments specify the shift amount @cite{n}. The @cite{w} argument
+Prefix arguments specify the shift amount @expr{n}. The @expr{w} argument
cannot be specified in the keyboard version of this command.
@c 11
@item
-From the keyboard, @cite{d} is omitted and defaults to zero.
+From the keyboard, @expr{d} is omitted and defaults to zero.
@c 12
@item
@c 14
@item
-A prefix argument, if any, is used for @cite{m} instead of taking
-@cite{m} from the stack. @cite{M} may take any of these values:
+A prefix argument, if any, is used for @expr{m} instead of taking
+@expr{m} from the stack. @expr{M} may take any of these values:
@iftex
{@advance@tableindent10pt
@end iftex
@table @asis
@item Integer
-Random integer in the interval @cite{[0 .. m)}.
+Random integer in the interval @expr{[0 .. m)}.
@item Float
-Random floating-point number in the interval @cite{[0 .. m)}.
+Random floating-point number in the interval @expr{[0 .. m)}.
@item 0.0
Gaussian with mean 1 and standard deviation 0.
@item Error form
@c 20
@item
-With a prefix argument of 1, take a single @c{$@var{n}\times2$}
-@i{@var{N}x2} matrix from the
-stack instead of two separate data vectors.
+With a prefix argument of 1, take a single
+@texline @var{n}@math{\times2}
+@infoline @mathit{@var{N}x2}
+matrix from the stack instead of two separate data vectors.
@c 21
@item
-The row or column number @cite{n} may be given as a numeric prefix
-argument instead. A plain @kbd{C-u} prefix says to take @cite{n}
-from the top of the stack. If @cite{n} is a vector or interval,
+The row or column number @expr{n} may be given as a numeric prefix
+argument instead. A plain @kbd{C-u} prefix says to take @expr{n}
+from the top of the stack. If @expr{n} is a vector or interval,
a subvector/submatrix of the input is created.
@c 22
@item
-The @cite{op} prompt can be answered with the key sequence for the
+The @expr{op} prompt can be answered with the key sequence for the
desired function, or with @kbd{x} or @kbd{z} followed by a function name,
or with @kbd{$} to take a formula from the top of the stack, or with
@kbd{'} and a typed formula. In the last two cases, the formula may
One of the mapping direction keys @kbd{_} (horizontal, i.e., map
by rows or reduce across), @kbd{:} (vertical, i.e., map by columns or
reduce down), or @kbd{=} (map or reduce by rows) may be used before
-entering @cite{op}; these modify the function name by adding the letter
+entering @expr{op}; these modify the function name by adding the letter
@code{r} for ``rows,'' @code{c} for ``columns,'' @code{a} for ``across,''
or @code{d} for ``down.''
@item -11
(@var{2}) Float with integer mantissa.
@item -12
-(@var{2}) Float with mantissa in @cite{[1 .. 10)}.
+(@var{2}) Float with mantissa in @expr{[1 .. 10)}.
@item -13
(@var{1}) Date form (using date numbers).
@item -14
@c 25
@item
-A prefix argument specifies the size @cite{n} of the matrix. With no
-prefix argument, @cite{n} is omitted and the size is inferred from
+A prefix argument specifies the size @expr{n} of the matrix. With no
+prefix argument, @expr{n} is omitted and the size is inferred from
the input vector.
@c 26
@item
-The prefix argument specifies the starting position @cite{n} (default 1).
+The prefix argument specifies the starting position @expr{n} (default 1).
@c 27
@item
@c 30
@item
-Editing occurs in a separate buffer. Press @kbd{M-# M-#} (or @kbd{C-c C-c},
-@key{LFD}, or in some cases @key{RET}) to finish the edit, or press
-@kbd{M-# x} to cancel the edit. The @key{LFD} key prevents evaluation
+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.
@c 31
@c 39
@item
-Answer for @cite{v} may also be of the form @cite{v = v_0} or
-@cite{v - v_0}.
+Answer for @expr{v} may also be of the form @expr{v = v_0} or
+@expr{v - v_0}.
@c 40
@item
-With a positive prefix argument, stack contains many @cite{y}'s and one
-common @cite{x}. With a zero prefix, stack contains a vector of
-@cite{y}s and a common @cite{x}. With a negative prefix, stack
-contains many @cite{[x,y]} vectors. (For 3D plots, substitute
-@cite{z} for @cite{y} and @cite{x,y} for @cite{x}.)
+With a positive prefix argument, stack contains many @expr{y}'s and one
+common @expr{x}. With a zero prefix, stack contains a vector of
+@expr{y}s and a common @expr{x}. With a negative prefix, stack
+contains many @expr{[x,y]} vectors. (For 3D plots, substitute
+@expr{z} for @expr{y} and @expr{x,y} for @expr{x}.)
@c 41
@item
stack levels. The notation @kbd{$3} refers to stack level three without
causing that value to be removed from the stack. Use @key{LFD} in place
of @key{RET} to prevent evaluation; use @kbd{M-=} in place of @key{RET}
-to evaluate variables.@refill
+to evaluate variables.
@c 47
@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 @c{$x \coloneq a-x$}
-@cite{x := a-x}.
+assigns
+@texline @math{x \coloneq a-x}.
+@infoline @expr{x := a-x}.
@c 48
@item
Press @kbd{?} repeatedly to see how to choose a model. Answer the
-variables prompt with @cite{iv} or @cite{iv;pv} to specify
+variables prompt with @expr{iv} or @expr{iv;pv} to specify
independent and parameter variables. A positive prefix argument
-takes @i{@var{n}+1} vectors from the stack; a zero prefix takes a matrix
+takes @mathit{@var{n}+1} vectors from the stack; a zero prefix takes a matrix
and a vector from the stack.
@c 49
corresponding Lisp variable.
The remaining variables are Lisp variables suitable for @code{setq}ing
-in your @file{.emacs} file.
+in your Calc init file or @file{.emacs} file.
@printindex vr