X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/02c1e496791be00a9db737792379b2c2099c2a02..baa2a74ea945327ce204b321fb419717d65158d1:/man/calc.texi diff --git a/man/calc.texi b/man/calc.texi index b432e7406a..6f3082fb77 100644 --- a/man/calc.texi +++ b/man/calc.texi @@ -3,7 +3,7 @@ @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.) @@ -13,28 +13,16 @@ @c @infoline foo @c `foo' will appear only in non-TeX output -@c In TeX output, @tmath{expr} will typeset expr in math mode. -@c In any output, @expr{expr} will typeset an expression; +@c @expr{expr} will typeset an expression; @c $x$ in TeX, @samp{x} otherwise. @iftex -@macro texline{stuff} -\stuff\ -@end macro -@macro tmath{stuff} -@tex -$\stuff\$ -@end tex +@macro texline @end macro @alias infoline=comment -@c @alias expr=math -@tex -\gdef\expr#1{\tex - \let\t\ttfont - \turnoffactive - $#1$ - \endgroup} -@end tex +@alias expr=math +@alias tfn=code +@alias mathit=expr @macro cpi{} @math{@pi{}} @end macro @@ -49,6 +37,8 @@ $\stuff\$ \stuff\ @end macro @alias expr=samp +@alias tfn=t +@alias mathit=i @macro cpi{} @expr{pi} @end macro @@ -93,11 +83,12 @@ $\stuff\$ @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 @@ -111,24 +102,25 @@ Software Foundation raise funds for GNU development.'' @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 @@ -171,10 +163,11 @@ longer Info tutorial.) * 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. @@ -189,11 +182,13 @@ longer Info tutorial.) @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. @@ -201,30 +196,33 @@ 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, @@ -237,128 +235,216 @@ want its recipients to know that what they have is not the original, so 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 @@ -367,11 +453,11 @@ be similar in spirit to the present version, but may differ in detail to 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 @@ -402,17 +488,91 @@ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 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 @@ -424,8 +584,8 @@ and what are the various ways that it can be used. * What is Calc:: * About This Manual:: * Notations Used in This Manual:: -* Using Calc:: * Demonstration of Calc:: +* Using Calc:: * History and Acknowledgements:: @end menu @@ -470,7 +630,7 @@ Algebraic manipulation features, including symbolic calculus. 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 @@ -486,10 +646,9 @@ large and might be intimidating to the first-time user. If you plan to 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 @@ -549,15 +708,42 @@ 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 @@ -579,7 +765,7 @@ regularly using Emacs. (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'' @@ -587,8 +773,8 @@ that you must press @key{RET} to proceed. For example, the @key{RET} 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 @@ -611,8 +797,9 @@ everything you see here will be covered more thoroughly in the 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, @@ -624,12 +811,12 @@ then the command to operate on the numbers. @noindent Type @kbd{2 @key{RET} 3 + Q} to compute -@texline @tmath{\sqrt{2+3} = 2.2360679775}. +@texline @math{\sqrt{2+3} = 2.2360679775}. @infoline the square root of 2+3, which is 2.2360679775. @noindent Type @kbd{P 2 ^} to compute -@texline @tmath{\pi^2 = 9.86960440109}. +@texline @math{\pi^2 = 9.86960440109}. @infoline the value of `pi' squared, 9.86960440109. @noindent @@ -648,12 +835,12 @@ use the apostrophe key. @noindent Type @kbd{' sqrt(2+3) @key{RET}} to compute -@texline @tmath{\sqrt{2+3}}. +@texline @math{\sqrt{2+3}}. @infoline the square root of 2+3. @noindent Type @kbd{' pi^2 @key{RET}} to enter -@texline @tmath{\pi^2}. +@texline @math{\pi^2}. @infoline `pi' squared. To evaluate this symbolic formula as a number, type @kbd{=}. @@ -662,7 +849,7 @@ 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 @@ -670,7 +857,7 @@ Click on the @key{2}, @key{ENTER}, @key{3}, @key{+}, and @key{SQRT} ``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. @@ -682,12 +869,12 @@ Click on @key{-}, @key{INV}, @key{HYP}, and @key{SIN}. 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 @@ -709,19 +896,19 @@ the product of the numbers. @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 -@texline @tmath{3\times2} +@texline @math{3\times2} @infoline 3x2 matrix into a -@texline @tmath{2\times3} +@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{M-# :}.) +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. @@ -741,9 +928,10 @@ 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 @expr{a = 7.5} in these formulas. @@ -751,21 +939,21 @@ Type @kbd{7.5}, then @kbd{s l a @key{RET}} to let @expr{a = 7.5} in these formul @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 @@ -773,7 +961,7 @@ To exit from Calc, press @kbd{q} or @kbd{M-# c} again. @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. +there are Quick mode, Keypad mode, and Embedded mode. @menu * Starting Calc:: @@ -782,54 +970,38 @@ there are Quick Mode, Keypad Mode, and Embedded Mode. * 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). +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 @@ -838,7 +1010,7 @@ the Calculator also turn it off if it is already on. @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. @@ -847,7 +1019,7 @@ 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 @@ -871,9 +1043,9 @@ you do. 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 @@ -894,55 +1066,55 @@ inside a regular window, Emacs acts just like normal. When the 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. @@ -951,13 +1123,12 @@ go into regular Calc (with @kbd{M-# c}) to change the mode settings. @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. @@ -969,36 +1140,38 @@ 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 @@ -1011,13 +1184,13 @@ keypad change to show other sets of commands, such as advanced 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. @@ -1045,17 +1218,17 @@ emacs -f full-calc-keypad @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: @@ -1072,7 +1245,7 @@ is @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 @@ -1087,7 +1260,7 @@ is @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 @@ -1111,7 +1284,7 @@ is @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 @@ -1131,10 +1304,10 @@ is 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}}. @@ -1151,12 +1324,10 @@ 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: @@ -1165,10 +1336,10 @@ 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. @@ -1177,48 +1348,51 @@ 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 @@ -1230,10 +1404,10 @@ Calc is already turned on and the cursor is in the Calc window, 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. @@ -1282,7 +1456,7 @@ Yank a value from the Calculator into the current editing buffer. @end iftex @noindent -Commands for use with Embedded Mode: +Commands for use with Embedded mode: @table @kbd @item A @@ -1337,8 +1511,7 @@ and record them as the current keyboard macro. @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 @@ -1348,7 +1521,7 @@ With any prefix argument, reset everything but the stack. Calc was originally started as a two-week project to occupy a lull in the author's schedule. Basically, a friend asked if I remembered the value of -@texline @tmath{2^{32}}. +@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 @@ -1379,13 +1552,13 @@ to look around for other data types that might be worth having. Around this time, my friend Rick Koshi showed me his nifty new HP-28 calculator. It allowed the user to manipulate formulas as well as -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 @@ -1406,7 +1579,7 @@ 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; -@texline Fran\c cois +@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; @@ -1426,16 +1599,14 @@ parts. Bob Weiner helped immensely with the Lucid Emacs port. 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 @@ -1444,7 +1615,7 @@ finished in two weeks. @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 @@ -1490,24 +1661,24 @@ to skip on to the rest of this manual. @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 @@ -1517,8 +1688,8 @@ general areas. @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 @@ -1588,8 +1759,8 @@ number of operands from the stack and pushes back the result. 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 @@ -1601,7 +1772,7 @@ will look at various points throughout the calculation: . 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 @@ -1670,7 +1841,7 @@ multiplication.) Figure it out by hand, then try it with Calc to see if you're right. @xref{RPN Answer 1, 1}. (@bullet{}) (@bullet{}) @strong{Exercise 2.} Compute -@texline @tmath{(2\times4) + (7\times9.4) + {5\over4}} +@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{}) @@ -1952,8 +2123,8 @@ entire stack.) @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 +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. @@ -2005,7 +2176,7 @@ $$ 2 + { 3 \times 4 \times 5 \over 6 \times 7^8 } - 9 $$ @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 @@ -2014,18 +2185,18 @@ can often be omitted: @samp{2 a} is the same as @samp{2*a}. 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. @@ -2040,7 +2211,7 @@ Press the apostrophe, then type @kbd{sqrt(5*2) - 3}. The result should 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! @@ -2049,7 +2220,7 @@ Some people prefer to enter complex numbers and vectors in algebraic 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 @@ -2065,15 +2236,15 @@ 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 @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 +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{*}) @@ -2084,7 +2255,7 @@ 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 -@texline @tmath{\sqrt{2\times4+1}}, +@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. @@ -2250,7 +2421,7 @@ when we discuss the algebra and calculus features of the Calculator. @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 @@ -2343,9 +2514,8 @@ key. If you type a prefix key by accident, you can press @kbd{C-g} 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, @@ -2388,7 +2558,7 @@ during entry of a number or algebraic formula. @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}. @@ -2678,7 +2848,7 @@ fit on a typical screen, either, so you will have to use horizontal 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 @@ -2746,11 +2916,11 @@ angle is measured in degrees. For example, @noindent The shift-@kbd{S} command computes the sine of an angle. The sine of 45 degrees is -@texline @tmath{\sqrt{2}/2}; +@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 @tmath{\sqrt{2}/2} +@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 @@ -2791,7 +2961,7 @@ either radians or degrees, depending on the current angular mode. @noindent Here we compute the Inverse Sine of -@texline @tmath{\sqrt{0.5}}, +@texline @math{\sqrt{0.5}}, @infoline @expr{sqrt(0.5)}, first in radians, then in degrees. @@ -2807,7 +2977,7 @@ 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 @@ -2831,7 +3001,7 @@ You can enter a fraction at any time using @kbd{:} notation. (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 @@ -2842,7 +3012,7 @@ why would you ever use floating-point numbers instead? 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. @@ -2858,7 +3028,7 @@ 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. @@ -2979,9 +3149,9 @@ logarithm). These can be modified by the @kbd{I} (inverse) and Let's compute the sine and cosine of an angle, and verify the identity -@texline @tmath{\sin^2x + \cos^2x = 1}. +@texline @math{\sin^2x + \cos^2x = 1}. @infoline @expr{sin(x)^2 + cos(x)^2 = 1}. -We'll arbitrarily pick @i{-64} degrees as a good value for @expr{x}. +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 @@ -3002,7 +3172,7 @@ Remember, @kbd{f h} is the @code{calc-hypot}, or square-root of sum of squares, command. Another identity is -@texline @tmath{\displaystyle\tan x = {\sin x \over \cos x}}. +@texline @math{\displaystyle\tan x = {\sin x \over \cos x}}. @infoline @expr{tan(x) = sin(x) / cos(x)}. @smallexample @group @@ -3017,7 +3187,7 @@ Another identity is A physical interpretation of this calculation is that if you move @expr{0.89879} units downward and @expr{0.43837} units to the right, -your direction of motion is @i{-64} degrees from horizontal. Suppose +your direction of motion is @mathit{-64} degrees from horizontal. Suppose we move in the opposite direction, up and to the left: @smallexample @@ -3065,7 +3235,7 @@ the top two stack elements right after the @kbd{U U}, then a pair of A similar identity is supposed to hold for hyperbolic sines and cosines, except that it is the @emph{difference} -@texline @tmath{\cosh^2x - \sinh^2x} +@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. @@ -3172,7 +3342,7 @@ in this case). If you take the factorial of a non-integer, Calc uses a generalized factorial function defined in terms of Euler's Gamma function -@texline @tmath{\Gamma(n)} +@texline @math{\Gamma(n)} @infoline @expr{gamma(n)} (which is itself available as the @kbd{f g} command). @@ -3189,13 +3359,13 @@ factorial function defined in terms of Euler's Gamma function @noindent Here we verify the identity -@texline @tmath{n! = \Gamma(n+1)}. +@texline @math{n! = \Gamma(n+1)}. @infoline @expr{@var{n}!@: = gamma(@var{n}+1)}. The binomial coefficient @var{n}-choose-@var{m} -@texline or @tmath{\displaystyle {n \choose m}} +@texline or @math{\displaystyle {n \choose m}} is defined by -@texline @tmath{\displaystyle {n! \over m! \, (n-m)!}} +@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 @@ -3480,7 +3650,7 @@ vector. (@bullet{}) @strong{Exercise 1.} Use @samp{*} to sum along the rows of the above -@texline @tmath{2\times3} +@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]}. @@ -3631,10 +3801,10 @@ 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 -@texline @tmath{N\times1} +@texline @math{N\times1} @infoline Nx1 or -@texline @tmath{1\times N} +@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]}. @@ -3683,7 +3853,7 @@ on the left by the transpose of @expr{A}: $A^T A \, X = A^T B$, where $A^T$ is the transpose \samp{trn(A)}. @end tex Now -@texline @tmath{A^T A} +@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'' @@ -3779,7 +3949,7 @@ of each element. (@bullet{}) @strong{Exercise 1.} Compute a vector of powers of two from -@texline @tmath{2^{-4}} +@texline @math{2^{-4}} @infoline @expr{2^-4} to @expr{2^4}. @xref{List Answer 1, 1}. (@bullet{}) @@ -3910,7 +4080,7 @@ of values in a file we have loaded into Emacs: @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.) @@ -3919,7 +4089,7 @@ 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 @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. @@ -3983,7 +4153,7 @@ $$ m = {N \sum x y - \sum x \sum y \over @noindent where -@texline @tmath{\sum x} +@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 @@ -4088,7 +4258,7 @@ $$ b = {\sum y - m \sum x \over N} $$ @end smallexample Let's ``plot'' this straight line approximation, -@texline @tmath{y \approx m x + b}, +@texline @math{y \approx m x + b}, @infoline @expr{m x + b}, and compare it with the original data. @@ -4132,8 +4302,8 @@ even @kbd{V R x max @key{RET}} if you had preferred.) 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}'' @@ -4189,7 +4359,7 @@ to solve for @expr{m} and @expr{b}, duplicating the above result. @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. @@ -4202,7 +4372,7 @@ 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{}) @@ -4341,7 +4511,7 @@ command to enable multi-line display of vectors.) @cindex Maximizing a function over a list of values @c [fix-ref Numerical Solutions] (@bullet{}) @strong{Exercise 8.} Compute a list of values of Bessel's -@texline @tmath{J_1(x)} +@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 @@ -4353,7 +4523,7 @@ of thing automatically; @pxref{Numerical Solutions}.) @cindex Digits, vectors of (@bullet{}) @strong{Exercise 9.} You are given an integer in the range -@texline @tmath{0 \le N < 10^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} @@ -4369,14 +4539,14 @@ happened? How would you do this test? @xref{List Answer 10, 10}. (@bullet{}) (@bullet{}) @strong{Exercise 11.} The area of a circle of radius one is @cpi{}. The area of the -@texline @tmath{2\times2} +@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 +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. @@ -4388,12 +4558,12 @@ 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 -@texline @tmath{2/\pi}. +@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 @tmath{6/\pi^2}. +@texline @math{6/\pi^2}. @infoline @expr{6/pi^2}. That provides yet another way to estimate @cpi{}.) @xref{List Answer 12, 12}. (@bullet{}) @@ -4423,7 +4593,7 @@ value and a number of steps @var{n} from the stack; it then applies the function you give to the starting value 0, 1, 2, up to @var{n} times and returns a vector of the results. Use this command to create a ``random walk'' of 50 steps. Start with the two-dimensional point -@expr{(0,0)}; then take one step a random distance between @i{-1} and 1 +@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. @@ -4502,7 +4672,7 @@ to allow for roundoff error!) @xref{Types Answer 1, 1}. (@bullet{}) @end smallexample @noindent -The square root of @i{-9} is by default rendered in rectangular form +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. @@ -4527,14 +4697,14 @@ algebraic entry. @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 @@ -4542,7 +4712,7 @@ with the symbol @code{nan} (for Not A Number). 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 @@ -4691,7 +4861,7 @@ a 60% chance that the result is correct within 0.59 degrees. @cindex Torus, volume of (@bullet{}) @strong{Exercise 7.} The volume of a torus (a donut shape) is -@texline @tmath{2 \pi^2 R r^2} +@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 @@ -4769,10 +4939,11 @@ or 24 hours. @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 @@ -4791,7 +4962,7 @@ that arises in the second one. @cindex Fermat, primality test of (@bullet{}) @strong{Exercise 10.} A theorem of Pierre de Fermat says that -@texline @w{@tmath{x^{n-1} \bmod n = 1}} +@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 @@ -4819,7 +4990,7 @@ 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 -@texline @tmath{\pi \times 10^7} +@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{}) @@ -4936,7 +5107,7 @@ numbers are in which units: @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 @@ -4972,7 +5143,7 @@ formulas. @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. @@ -5126,7 +5297,7 @@ 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 @expr{x = -1.19023} is also a maximum. @@ -5193,7 +5364,7 @@ polynomial? (The answer will be unique to within a constant 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. @@ -5208,7 +5379,7 @@ 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 @@ -5228,7 +5399,8 @@ One more mode that makes reading formulas easier is ``Big mode.'' 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 @@ -5296,7 +5468,7 @@ One way to do it is again with vector mapping and reduction: (@bullet{}) @strong{Exercise 3.} Find the integral from 1 to @expr{y} of -@texline @tmath{x \sin \pi x} +@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, @@ -5305,7 +5477,7 @@ integral for integers @expr{y} from 1 to 5. @xref{Algebra Answer 3, Calc's integrator can do many simple integrals symbolically, but many others are beyond its capabilities. Suppose we wish to find the area under the curve -@texline @tmath{\sin x \ln x} +@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 @@ -5356,7 +5528,7 @@ also have used plain @kbd{v x} as follows: @kbd{v x 10 @key{RET} 9 + .1 *}.) @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 @@ -5447,7 +5619,7 @@ $$ h (f(a) + f(a+h) + f(a+2h) + f(a+3h) + \cdots @end tex Compute the integral from 1 to 2 of -@texline @tmath{\sin x \ln x} +@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{}) @@ -5599,8 +5771,8 @@ having to retype it. @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'' @@ -5612,10 +5784,10 @@ only once and stores the compiled form along with the variable. That's 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{}) @@ -5870,15 +6042,7 @@ is one or more non-sum terms separated by @samp{+} or @samp{-} signs, 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 @expr{0^0} -to be ``indeterminate,'' and leaves it unevaluated (assuming infinite -mode is not enabled). Some people prefer to define @expr{0^0 = 1}, -so that the identity @expr{x^0 = 1} can safely be used for all @expr{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 @expr{x} near zero. @@ -5924,9 +6088,12 @@ on the stack, we want to be able to type @kbd{*} and get the result 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 @@ -5940,9 +6107,6 @@ system. But Lisp and rewrite rules take a while to master, and often 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 @@ -5993,7 +6157,7 @@ in @samp{a + 1} for @samp{x} in the defining formula. @end ignore @tindex Si (@bullet{}) @strong{Exercise 1.} The ``sine integral'' function -@texline @tmath{{\rm Si}(x)} +@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 @@ -6004,8 +6168,9 @@ which in algebraic notation is written like @samp{ninteg(f(t), t, 0, x)} 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 @@ -6071,7 +6236,7 @@ the following functions: @enumerate @item Compute -@texline @tmath{\displaystyle{\sin x \over x}}, +@texline @math{\displaystyle{\sin x \over x}}, @infoline @expr{sin(x) / x}, where @expr{x} is the number on the top of the stack. @@ -6137,13 +6302,13 @@ key if you have one, makes a copy of the number in level 2.) @cindex Phi, golden ratio A fascinating property of the Fibonacci numbers is that the @expr{n}th Fibonacci number can be found directly by computing -@texline @tmath{\phi^n / \sqrt{5}} +@texline @math{\phi^n / \sqrt{5}} @infoline @expr{phi^n / sqrt(5)} and then rounding to the nearest integer, where -@texline @tmath{\phi} (``phi''), +@texline @math{\phi} (``phi''), @infoline @expr{phi}, the ``golden ratio,'' is -@texline @tmath{(1 + \sqrt{5}) / 2}. +@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.) @@ -6160,17 +6325,17 @@ variable, or the @kbd{I H P} command.) @cindex Continued fractions (@bullet{}) @strong{Exercise 5.} The @dfn{continued fraction} representation of -@texline @tmath{\phi} +@texline @math{\phi} @infoline @expr{phi} is -@texline @tmath{1 + 1/(1 + 1/(1 + 1/( \ldots )))}. +@texline @math{1 + 1/(1 + 1/(1 + 1/( \ldots )))}. @infoline @expr{1 + 1/(1 + 1/(1 + 1/( ...@: )))}. We can compute an approximate value by carrying this however far and then replacing the innermost -@texline @tmath{1/( \ldots )} +@texline @math{1/( \ldots )} @infoline @expr{1/( ...@: )} by 1. Approximate -@texline @tmath{\phi} +@texline @math{\phi} @infoline @expr{phi} using a twenty-term continued fraction. @xref{Programming Answer 5, 5}. (@bullet{}) @@ -6270,7 +6435,7 @@ 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 -@texline @tmath{\displaystyle{2 n! \over (2 \pi)^n}}. +@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 @@ -6344,55 +6509,56 @@ then enter the real one in the edit command. @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 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 @@ -6403,21 +6569,18 @@ Press @kbd{M-# M-#} to finish editing and return to the Calculator. @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 ' @@ -6444,14 +6607,14 @@ $$ x_{\rm new} = x - {f(x) \over f'(x)} $$ @noindent where @expr{f'(x)} is the derivative of @expr{f}. The @expr{x} values will quickly converge to a solution, i.e., eventually -@texline @tmath{x_{\rm new}} +@texline @math{x_{\rm new}} @infoline @expr{new_x} and @expr{x} will be equal to within the limits of the current precision. Write a program which takes a formula involving the variable @expr{x}, and an initial guess @expr{x_0}, on the stack, and produces a value of @expr{x} for which the formula is zero. Use it to find a solution of -@texline @tmath{\sin(\cos x) = 0.5} +@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 @@ -6461,10 +6624,10 @@ method when it is able. @xref{Programming Answer 8, 8}. (@bullet{}) @cindex Gamma constant, Euler's @cindex Euler's gamma constant (@bullet{}) @strong{Exercise 9.} The @dfn{digamma} function -@texline @tmath{\psi(z) (``psi'')} +@texline @math{\psi(z) (``psi'')} @infoline @expr{psi(z)} is defined as the derivative of -@texline @tmath{\ln \Gamma(z)}. +@texline @math{\ln \Gamma(z)}. @infoline @expr{ln(gamma(z))}. For large values of @expr{z}, it can be approximated by the infinite sum @@ -6483,7 +6646,7 @@ $$ @noindent where -@texline @tmath{\sum} +@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 @@ -6491,27 +6654,27 @@ 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, -@texline @tmath{\gamma = -\psi(1)}. +@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 @tmath{\psi(1)} +@texline @math{\psi(1)} @infoline @expr{psi(1)} from -@texline @tmath{\psi(5)} +@texline @math{\psi(5)} @infoline @expr{psi(5)} using the recurrence -@texline @tmath{\psi(z+1) = \psi(z) + {1 \over z}}. +@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 @tmath{\psi(z)}; +@texline @math{\psi(z)}; @infoline @expr{psi(z)}; it should ``pump up'' @expr{z} if necessary to be greater than 5, then use the above summation formula. Use looping commands to compute the sum. Use your function to compute -@texline @tmath{\gamma} +@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.) @@ -6562,7 +6725,7 @@ it to a key with, e.g., @kbd{Z K s}. Now enter the true definition, 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 @expr{n} and @expr{m} on the stack. Test it with @emph{small} inputs like @@ -6656,8 +6819,7 @@ This section includes answers to all the exercises in the Calc tutorial. * 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. @@ -6688,18 +6850,18 @@ This section includes answers to all the exercises in the Calc tutorial. @kbd{1 @key{RET} 2 @key{RET} 3 @key{RET} 4 + * -} The result is -@texline @tmath{1 - (2 \times (3 + 4)) = -13}. +@texline @math{1 - (2 \times (3 + 4)) = -13}. @infoline @expr{1 - (2 * (3 + 4)) = -13}. @node RPN Answer 2, RPN Answer 3, RPN Answer 1, Answers to Exercises @subsection RPN Tutorial Exercise 2 @noindent -@texline @tmath{2\times4 + 7\times9.5 + {5\over4} = 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 -@texline @tmath{2\times4 = 8}, +@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 @@ -6850,7 +7012,7 @@ 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 @expr{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 @@ -7008,13 +7170,13 @@ give a floating-point result that is inaccurate even when rounded down to an integer. Consider @expr{123456789 / 2} when the current precision is 6 digits. The true answer is @expr{61728394.5}, but with a precision of 6 this will be rounded to -@texline @tmath{12345700.0/2.0 = 61728500.0}. +@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 @expr{123456789 / 2} +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. @@ -7027,9 +7189,9 @@ format. 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 @@ -7101,7 +7263,7 @@ matrix as usual. @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 @@ -7112,23 +7274,23 @@ mode: @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 -@texline @tmath{A^T A \, X = A^T B}, +@texline @math{A^T A \, X = A^T B}, @infoline @expr{trn(A) * A * X = trn(A) * B}, first we compute -@texline @tmath{A' = A^T A} +@texline @math{A' = A^T A} @infoline @expr{A2 = trn(A) * A} and -@texline @tmath{B' = A^T B}; +@texline @math{B' = A^T B}; @infoline @expr{B2 = trn(A) * B}; now, we have a system -@texline @tmath{A' X = B'} +@texline @math{A' X = B'} @infoline @expr{A2 * X = B2} which we can solve using Calc's @samp{/} command. @@ -7160,7 +7322,7 @@ $$ The first step is to enter the coefficient matrix. We'll store it in quick variable number 7 for later reference. Next, we compute the -@texline @tmath{B'} +@texline @math{B'} @infoline @expr{B2} vector. @@ -7178,7 +7340,7 @@ vector. @noindent Now we compute the matrix -@texline @tmath{A'} +@texline @math{A'} @infoline @expr{A2} and divide. @@ -7199,16 +7361,16 @@ and divide. round-off error.) Notice that the answers are similar to those for the -@texline @tmath{3\times3} +@texline @math{3\times3} @infoline 3x3 system solved in the text. That's because the fourth equation that was added to the system is almost identical to the first one multiplied by two. (If it were identical, we would have gotten the exact same answer since the -@texline @tmath{4\times3} +@texline @math{4\times3} @infoline 4x3 system would be equivalent to the original -@texline @tmath{3\times3} +@texline @math{3\times3} @infoline 3x3 system.) @@ -7285,7 +7447,7 @@ $$ m \times x + b \times 1 = y $$ @end tex Thus we want a -@texline @tmath{19\times2} +@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 @@ -7304,10 +7466,10 @@ we combine the two columns to form our @expr{A} matrix. @noindent Now we compute -@texline @tmath{A^T y} +@texline @math{A^T y} @infoline @expr{trn(A) * y} and -@texline @tmath{A^T A} +@texline @math{A^T A} @infoline @expr{trn(A) * A} and divide. @@ -7335,7 +7497,7 @@ and divide. @end smallexample Since we were solving equations of the form -@texline @tmath{m \times x + b \times 1 = y}, +@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 @@ -7355,7 +7517,7 @@ fits. @xref{Curve Fitting}. @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 @@ -7398,7 +7560,7 @@ then raise the number to that power.) @noindent A number @expr{j} is a divisor of @expr{n} if -@texline @tmath{n \mathbin{\hbox{\code{\%}}} j = 0}. +@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. @@ -7469,7 +7631,7 @@ zero, so adding zeros on the left and right is safe. From then on the job is pretty straightforward. Incidentally, Calc provides the -@texline @dfn{M@"obius} @tmath{\mu} +@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. @@ -7503,7 +7665,7 @@ The numbers down the lefthand edge of the list we desire are called the ``triangular numbers'' (now you know why!). The @expr{n}th triangular number is the sum of the integers from 1 to @expr{n}, and can be computed directly by the formula -@texline @tmath{n (n+1) \over 2}. +@texline @math{n (n+1) \over 2}. @infoline @expr{n * (n+1) / 2}. @smallexample @@ -7599,7 +7761,7 @@ A way to isolate the maximum value is to compute the maximum using @noindent It's a good idea to verify, as in the last step above, that only one value is equal to the maximum. (After all, a plot of -@texline @tmath{\sin x} +@texline @math{\sin x} @infoline @expr{sin(x)} might have many points all equal to the maximum value, 1.) @@ -7871,10 +8033,10 @@ This problem can be made a lot easier by taking advantage of some symmetries. First of all, after some thought it's clear that the @expr{y} axis can be ignored altogether. Just pick a random @expr{x} component for one end of the match, pick a random direction -@texline @tmath{\theta}, +@texline @math{\theta}, @infoline @expr{theta}, and see if @expr{x} and -@texline @tmath{x + \cos \theta} +@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 @@ -7891,10 +8053,10 @@ coordinates 0 and 1 for the lines on either side of the leftmost endpoint. The rightmost endpoint will be between 0 and 1 if the match does not cross a line, or between 1 and 2 if it does. So: Pick random @expr{x} and -@texline @tmath{\theta}, +@texline @math{\theta}, @infoline @expr{theta}, compute -@texline @tmath{x + \cos \theta}, +@texline @math{x + \cos \theta}, @infoline @expr{x + cos(theta)}, and count how many of the results are greater than one. Simple! @@ -8219,7 +8381,7 @@ precision slightly and try again: @noindent Aha! It's unlikely that an irrational number would equal a fraction this simple to within ten digits, so our original number was probably -@texline @tmath{\sqrt{27 \pi / 53}}. +@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 @@ -8259,7 +8421,7 @@ so it settles for the conservative answer @code{uinf}. @samp{ln(0) = -inf}. Here we have an infinite answer to a finite input. As in the @expr{1 / 0} case, Calc will only use infinities -here if you have turned on ``infinite'' mode. Otherwise, it will +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 @@ -8473,16 +8635,16 @@ Calc normally treats division by zero as an error, so that the formula @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 @@ -8502,9 +8664,9 @@ that interval arithmetic can do in this case. @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 @@ -9091,9 +9253,9 @@ apply and the rewrites will stop right away. @starindex @end ignore @tindex nterms -If @expr{x} is the sum @expr{a + b}, then `@t{nterms(}@var{x}@t{)}' must -be `@t{nterms(}@var{a}@t{)}' plus `@t{nterms(}@var{b}@t{)}'. If @expr{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 @@ -9107,48 +9269,9 @@ Here we have taken advantage of the fact that earlier rules always 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 @expr{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: @@ -9221,7 +9344,7 @@ for a way to do this in Calc, although for something as involved as 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 @@ -9260,7 +9383,7 @@ algebraic entry, whichever way you prefer: @noindent Computing -@texline @tmath{\displaystyle{\sin x \over x}}: +@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 )}. @@ -9331,7 +9454,7 @@ 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 @expr{n} in only -@texline @tmath{\log_2 n} +@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 @@ -9385,11 +9508,11 @@ harmonic number is 4.02. @noindent The first step is to compute the derivative @expr{f'(x)} and thus the formula -@texline @tmath{\displaystyle{x - {f(x) \over f'(x)}}}. +@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, @@ -9502,16 +9625,16 @@ method (among others) to look for numerical solutions to any equation. The first step is to adjust @expr{z} to be greater than 5. A simple ``for'' loop will do the job here. If @expr{z} is less than 5, we reduce the problem using -@texline @tmath{\psi(z) = \psi(z+1) - 1/z}. +@texline @math{\psi(z) = \psi(z+1) - 1/z}. @infoline @expr{psi(z) = psi(z+1) - 1/z}. We go on to compute -@texline @tmath{\psi(z+1)}, +@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, @@ -9546,7 +9669,7 @@ are exactly equal, not just equal to within the current precision.) @end smallexample Now we compute the initial part of the sum: -@texline @tmath{\ln z - {1 \over 2z}} +@texline @math{\ln z - {1 \over 2z}} @infoline @expr{ln(z) - 1/2z} minus the adjustment factor. @@ -9589,7 +9712,7 @@ up the value of @expr{2 n}. (Calc does have a summation command, @end smallexample This is the value of -@texline @tmath{-\gamma}, +@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: @@ -9624,7 +9747,7 @@ C-x ) @noindent Taking the derivative of a term of the form @expr{x^n} will produce a term like -@texline @tmath{n x^{n-1}}. +@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 @@ -9632,7 +9755,7 @@ 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, @@ -9741,7 +9864,7 @@ definition. The recurrence needs to be rewritten slightly, 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 @@ -9815,10 +9938,10 @@ C-x ) @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 @@ -9880,7 +10003,6 @@ numeric entry, undo, numeric prefix arguments, etc. * Numeric Entry:: * Algebraic Entry:: * Quick Calculator:: -* Keypad Mode:: * Prefix Arguments:: * Undo:: * Error Messages:: @@ -9901,24 +10023,23 @@ By default this creates a pair of small windows, @samp{*Calculator*} 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}. -@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 @@ -9933,7 +10054,7 @@ for you. For example, the following key sequences are equivalent: @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 @@ -9941,48 +10062,48 @@ functions or matrix operations. This is done to improve the response time 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}) +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. -@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}. @@ -9990,16 +10111,16 @@ 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 +@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. @@ -10039,14 +10160,19 @@ 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. -@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 @@ -10079,21 +10205,21 @@ provide help within Calc. Many of the @kbd{h} key functions are 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}, @@ -10101,14 +10227,14 @@ except that it selects the starting node of the tutorial rather 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 @@ -10198,7 +10324,7 @@ The first three keystrokes ``push'' the numbers 1 and 2 onto the stack. The @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}). +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 @@ -10261,7 +10387,7 @@ 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}}, +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 @@ -10282,7 +10408,7 @@ During numeric entry, the only editing key available is @key{DEL}. 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 -@texline @tmath{2+(3\times4) = 14} +@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 @@ -10290,7 +10416,7 @@ expressions in this way. You may want to use @key{DEL} every so often to 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. @@ -10301,7 +10427,7 @@ you complete your half-finished entry in a separate buffer. @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 @@ -10312,7 +10438,7 @@ 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}}. -@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 @@ -10320,15 +10446,15 @@ only. Numeric keys still begin a numeric entry in this mode. @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. @@ -10386,11 +10512,11 @@ you might then press @kbd{=} when it is time to evaluate this formula. @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. @@ -10399,11 +10525,11 @@ You can use the @kbd{$} character in a Quick Calculator formula to 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 @@ -10411,15 +10537,15 @@ settings. Thus, for example, to set the precision that the Quick 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 @@ -10515,7 +10641,7 @@ queried whether or not to restore the variable to its original value. 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.) @@ -10589,9 +10715,9 @@ that you must always press @kbd{w} yourself to see the messages). @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 @@ -10638,18 +10764,13 @@ Occasionally Calc may lose track of when a certain component is 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 @@ -10692,7 +10813,7 @@ approximation. This value will not need to be recomputed ever again unless you raise the precision still further. Many operations such as logarithms and sines make use of similarly cached values such as @cpiover{4} and -@texline @tmath{\ln 2}. +@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. @@ -10704,7 +10825,7 @@ data points computed by the graphing commands. 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 @@ -10804,7 +10925,7 @@ The Calculator stores integers to arbitrary precision. Addition, 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 @@ -10830,7 +10951,7 @@ A @dfn{fraction} is a ratio of two integers. Fractions are traditionally 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. @@ -10851,10 +10972,10 @@ 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 -@texline @tmath{10^{-3999999}} +@texline @math{10^{-3999999}} @infoline @expr{10^-3999999} (inclusive) to -@texline @tmath{10^{4000000}} +@texline @math{10^{4000000}} @infoline @expr{10^4000000} (exclusive), plus the corresponding negative values and zero. @@ -10926,16 +11047,16 @@ Rectangular complex numbers can also be displayed in @samp{@var{a}+@var{b}i} notation; @pxref{Complex Formats}. Polar complex numbers are displayed in the form -@texline `@t{(}@var{r}@t{;}@tmath{\theta}@t{)}' -@infoline `@t{(}@var{r}@t{;}@var{theta}@t{)}' +@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 @tmath{\theta} +@texline @math{\theta} @infoline @var{theta} is the argument or phase angle. The range of -@texline @tmath{\theta} +@texline @math{\theta} @infoline @var{theta} depends on the current angular mode (@pxref{Angular Modes}); it is -generally between @i{-180} and @i{+180} degrees or the equivalent range +generally between @mathit{-180} and @mathit{+180} degrees or the equivalent range in radians. Complex numbers are entered in stages using incomplete objects. @@ -10944,7 +11065,7 @@ Complex numbers are entered in stages using 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 @@ -10978,7 +11099,7 @@ larger, becomes arbitrarily close to zero. So you can imagine that if @expr{x} got ``all the way to infinity,'' then @expr{1 / x} would go all the way to zero. Similarly, when they say that @samp{exp(inf) = inf}, they mean that -@texline @tmath{e^x} +@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 @@ -11032,7 +11153,7 @@ infinity, it's just that @emph{which} number it stands for 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}. @@ -11075,7 +11196,7 @@ of its elements. @tindex vec Algebraic functions for building vectors include @samp{vec(a, b, c)} to build @samp{[a, b, c]}, @samp{cvec(a, n, m)} to build an -@texline @tmath{n\times m} +@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}. @@ -11206,7 +11327,7 @@ The @var{mins} value is an integer or integer-valued float between 0 and 59. 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. +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, @@ -11300,12 +11421,12 @@ between, say, @samp{<12:00am Mon Jan 1, 1900>} and 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{} is @samp{}. 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 @@ -11313,7 +11434,7 @@ called ``Julian.'' It was invented in 1583 by Joseph Justus 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} @@ -11344,13 +11465,28 @@ conversions. 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 -@texline @tmath{0 \le a < M}. +@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 the result 7. Further computations treat this 7 as just a regular integer. @@ -11368,39 +11504,21 @@ 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}' +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 @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'' +@w{`@tfn{(}@var{a} @tfn{mod} @var{M}@tfn{)^.5}'} will compute a ``modulo square root'' in the sense of reducing -@texline @tmath{\sqrt a} +@texline @math{\sqrt a} @infoline @expr{sqrt(a)} modulo @expr{M}, this is not a useful definition from the number-theoretical point of view.) -@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. - -You can also use @kbd{v p} and @kbd{%} to modify modulo forms. -@xref{Building Vectors}. @xref{Basic Arithmetic}. - 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 @expr{M} @@ -11413,6 +11531,9 @@ Modulo forms cannot have variables or formulas for components. If you 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 @@ -11428,12 +11549,12 @@ The algebraic function @samp{makemod(a, m)} builds the modulo form @cindex Standard deviations An @dfn{error form} is a number with an associated standard deviation, as in @samp{2.3 +/- 0.12}. The notation -@texline `@var{x} @t{+/-} @tmath{\sigma}' -@infoline `@var{x} @t{+/-} sigma' +@texline `@var{x} @tfn{+/-} @math{\sigma}' +@infoline `@var{x} @tfn{+/-} sigma' stands for an uncertain value which follows a normal or Gaussian distribution of mean @expr{x} and standard deviation or ``error'' -@texline @tmath{\sigma}. +@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 @@ -11444,7 +11565,7 @@ 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 @expr{f(x)} (such as -@texline @tmath{\sin x} +@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 @@ -11475,34 +11596,34 @@ 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 -@texline `@t{sin(}@var{x} @t{+/-} @tmath{\sigma}@t{)}' -@infoline `@t{sin(}@var{x} @t{+/-} @var{sigma}@t{)}' +@texline `@tfn{sin(}@var{x} @tfn{+/-} @math{\sigma}@tfn{)}' +@infoline `@tfn{sin(}@var{x} @tfn{+/-} @var{sigma}@tfn{)}' is -@texline `@tmath{\sigma} @t{abs(cos(}@var{x}@t{))}'. -@infoline `@var{sigma} @t{abs(cos(}@var{x}@t{))}'. +@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 @tmath{\cos x} +@texline @math{\cos x} @infoline @expr{cos(x)} is close to one so the error in the sine is close to -@texline @tmath{\sigma}; +@texline @math{\sigma}; @infoline @expr{sigma}; this makes sense, since -@texline @tmath{\sin x} +@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 @tmath{\cos x} +@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 @tmath{\sin x}. +@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 @tmath{\sin x} +@texline @math{\sin x} @infoline @expr{sin(x)} would indeed have been negligible. @@ -11514,7 +11635,7 @@ would indeed have been negligible. 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 @@ -11598,10 +11719,10 @@ rather than @samp{1 ..@: 0.1e2}. Add spaces or zeros if you want to 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 @@ -11611,14 +11732,14 @@ contain zero inside them Calc is forced to give the result, While it may seem that intervals and error forms are similar, they are based on entirely different concepts of inexact quantities. An error form -@texline `@var{x} @t{+/-} @tmath{\sigma}' -@infoline `@var{x} @t{+/-} @var{sigma}' +@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 @tmath{\sigma} +@texline @math{\sigma} @infoline @var{sigma} of the mean value @expr{x}. An interval -`@t{[}@var{a} @t{..@:} @var{b}@t{]}' means a +`@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 @@ -11723,26 +11844,26 @@ calculator, and a variable in a programming language. (In fact, a Calc 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. +(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}. +@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 @@ -11849,7 +11970,7 @@ the C-style ``if'' operator @samp{a?b:c} [@code{if}]; Note that, unlike in usual computer notation, multiplication binds more strongly than division: @samp{a*b/c*d} is equivalent to -@texline @tmath{a b \over c d}. +@texline @math{a b \over c d}. @infoline @expr{(a*b)/(c*d)}. @cindex Multiplication, implicit @@ -11895,10 +12016,10 @@ an infix operator preferentially (modulo, in this case), so you would 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 @@ -11914,9 +12035,9 @@ 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. @@ -12047,11 +12168,11 @@ intervening stack elements toward the top. @kbd{M-@key{TAB}} moves the 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. @@ -12070,13 +12191,11 @@ regular Emacs commands. With a numeric prefix argument, it edits the specified number of stack entries at once. (An argument of zero edits the entire stack; a negative argument edits one specific stack entry.) -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 @@ -12084,18 +12203,18 @@ original stack elements in the original buffer with these new values, 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} @@ -12244,16 +12363,18 @@ arguments from the stack. For example, after @kbd{2 @key{RET} 3 +}, 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, @@ -12266,13 +12387,6 @@ original argument you could use either @kbd{' sin($1)} or @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 @@ -12310,44 +12424,50 @@ the @emph{appearance} or @emph{interpretation} of the stack's contents. @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. @@ -12360,7 +12480,7 @@ extensions modules. Otherwise, the extensions modules will not be loaded 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 @@ -12452,7 +12572,7 @@ Hyperbolic Flag, which transforms @code{calc-sin} into @code{calc-sinh}. 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.) +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 @@ -12506,7 +12626,7 @@ Functions that compute angles produce a number in radians, a number in 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 @cpi{}.) @@ -12519,7 +12639,7 @@ multiplying by 180 over @cpi{}.) 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. +The default angular mode is Degrees. @node Polar Mode, Fraction Mode, Angular Modes, Calculation Modes @subsection Polar Mode @@ -12535,7 +12655,7 @@ number, or by entering @kbd{( 2 @key{SPC} 3 )}. @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 @@ -12547,16 +12667,18 @@ of the above example situations would produce polar complex numbers. 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 @expr{3:2} -even though @kbd{6 @key{RET} 4 /} produces @expr{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, @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. +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 @@ -12579,25 +12701,25 @@ on and off. When the mode is off, infinities do not arise except 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, @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}. @@ -12616,7 +12738,7 @@ number or a symbolic expression if the argument is an expression: @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)}. @@ -12643,12 +12765,12 @@ variables.) @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, @@ -12667,21 +12789,23 @@ a true identity matrix of the appropriate size. On the other hand, 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 @@ -12699,11 +12823,11 @@ for @samp{[x, y, z] + [1, 2, 3]}, but that's because you have broken 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 @@ -12719,14 +12843,14 @@ are changed. @xref{Evaluates-To Operator}. 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 @@ -12801,9 +12925,7 @@ 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 @expr{a+0} to @expr{a}, and @expr{a + 2 a} to @expr{3 a}, as well as evaluating functions like -@texline @t{deriv}@expr{(x^2,x)} -@infoline @expr{@t{deriv}(x^2, x)} -to @expr{2 x}. +@expr{@tfn{deriv}(x^2, x)} to @expr{2 x}. @kindex m B @pindex calc-bin-simplify-mode @@ -12840,7 +12962,7 @@ 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. +Definitions}, for another sample use of No-Simplification mode. @node Declarations, Display Modes, Simplification Modes, Mode Settings @section Declarations @@ -12987,7 +13109,7 @@ Numbers. (Real or complex.) 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 @@ -13071,6 +13193,8 @@ The value is not a vector. 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 @@ -13087,8 +13211,8 @@ and @code{y} are known to be vectors or matrices. (Calc currently 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} @@ -13100,7 +13224,7 @@ The value is a constant with respect to other variables. @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 @expr{3.5} if it substitutes the value first, or to @expr{-3.5} if @code{x} @@ -13240,8 +13364,8 @@ remains unevaluated. @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 @@ -13335,7 +13459,7 @@ command causes integers to be padded out with leading zeros according to the current binary word size. (@xref{Binary Functions}, for a discussion of word size.) If the absolute value of the word size is @expr{w}, all integers are displayed with at least enough digits to represent -@texline @tmath{2^w-1} +@texline @math{2^w-1} @infoline @expr{(2^w)-1} in the current radix. (Larger integers will still be displayed in their entirety.) @@ -13350,12 +13474,12 @@ entirety.) @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 @expr{N} it enables grouping on every @expr{N} digits. For floating-point numbers, grouping normally occurs only @@ -13373,7 +13497,7 @@ uses it as the digit separator. As a special case, @kbd{d , \} selects @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. @@ -13433,7 +13557,7 @@ significant figures but displays only six. (In fact, intermediate 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 . @@ -13861,11 +13985,12 @@ The @kbd{d t} (@code{calc-truncate-stack}) command moves the @samp{.}@: 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. +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 @@ -13896,7 +14021,7 @@ line at a time (or several lines with a prefix argument). 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. @@ -13917,20 +14042,20 @@ breaking lines are given below. Notice that the interaction between 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 @@ -13965,13 +14090,13 @@ Give a blank string (with @kbd{d @{ @key{RET}}) to turn the label off. 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. @@ -13981,7 +14106,7 @@ 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. @@ -13994,9 +14119,9 @@ and use the standard notation by giving a numeric prefix, e.g., @kbd{C-u '}. 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. @@ -14004,12 +14129,12 @@ Without being switched into C mode first, Calc would have misinterpreted 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. @@ -14017,7 +14142,7 @@ 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:: @@ -14073,7 +14198,7 @@ such as powers, quotients, and square roots: @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 @@ -14127,7 +14252,7 @@ all four modes, and unformatted notation works in any language mode (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 @@ -14146,12 +14271,12 @@ In C mode, vectors and matrices use curly braces instead of brackets. 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{} header. Functions whose names are different in C are translated automatically for entry and @@ -14193,7 +14318,7 @@ function!). 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 @@ -14202,72 +14327,122 @@ modes will use upper-case letters exclusively for display, and will 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). +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}. +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 -@texline @tmath{\sin{2 x}} +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 @tmath{\sin(2 + x)}. +@texline @math{\sin(2 + x)}. @infoline @expr{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.) +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 @@ -14281,26 +14456,58 @@ in Calc, @TeX{}, and @dfn{eqn} (described in the next section): @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 @@ -14309,10 +14516,18 @@ in Calc, @TeX{}, and @dfn{eqn} (described in the next section): @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 @@ -14321,30 +14536,50 @@ in Calc, @TeX{}, and @dfn{eqn} (described in the next section): @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: @@ -14381,8 +14616,9 @@ reading is: \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{*}. @@ -14510,7 +14746,7 @@ $$ \pmatrix{ {a \over b} & 0 \cr 0 & 2^{(x + 1)} } $$ @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 @@ -14552,7 +14788,7 @@ treated the same as a space in @dfn{eqn} mode, as is the @samp{~} 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@}}. @@ -14566,17 +14802,17 @@ are treated the same as curly braces: @samp{sqrt "1+x"} is equivalent to 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. @@ -14594,8 +14830,7 @@ if the matrix justification mode so specifies. @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 @@ -14618,8 +14853,7 @@ Subscripts use double square brackets: @samp{a[[i]]}. @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 @@ -14835,7 +15069,7 @@ object. @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 @@ -15098,7 +15332,7 @@ then return a certain measurement of the composition as an integer. @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. @@ -15274,9 +15508,9 @@ unrelated to the syntax tables described in the Emacs manual.) @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}. @@ -15305,7 +15539,7 @@ zero or more expressions separated by commas, and @samp{)}.'' 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, @@ -15425,7 +15659,7 @@ backslashes in tokens.) 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 @@ -15660,7 +15894,7 @@ In this approach, we allow @samp{#2} to equal the whole expression @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}. @@ -15733,19 +15967,20 @@ Polar mode. Value is 0 (rectangular) or 1 (polar); default is 0. Command is @kbd{m p}. @item -Matrix/scalar mode. Default value is @i{-1}. Value is 0 for scalar -mode, @i{-2} for matrix mode, or @var{N} for -@texline @tmath{N\times N} +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}. +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 @@ -15772,7 +16007,7 @@ programming commands. @xref{Conditionals in Macros}.) @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: @@ -15784,7 +16019,7 @@ The @samp{%%} is the Emacs symbol for ``read-only''; it shows that 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. @@ -15812,7 +16047,10 @@ Symbolic mode (@kbd{m s}; @pxref{Symbolic Mode}). 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}). @@ -15827,7 +16065,7 @@ Fraction mode (@kbd{m f}; @pxref{Fraction 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}). @@ -15881,7 +16119,10 @@ Pascal language mode (@kbd{d P}). 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}). @@ -15935,7 +16176,7 @@ No line breaking (@kbd{d b}). 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}). @@ -15988,7 +16229,7 @@ commands work by removing the top one or two values from the stack, 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 @@ -16035,14 +16276,14 @@ to every element of a vector. 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 @@ -16086,7 +16327,7 @@ infinite in different directions the result is @code{nan}. @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 * @@ -16192,9 +16433,9 @@ 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 @@ -16230,7 +16471,7 @@ absolute value squared of a number, vector or matrix, or error form. @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}. @@ -16248,7 +16489,7 @@ matrix, it computes the inverse of that matrix. @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 @@ -16293,7 +16534,7 @@ The @kbd{f M} (@code{calc-mant-part}) [@code{mant}] function extracts the ``mantissa'' part @expr{m} of its floating-point argument; @kbd{f X} (@code{calc-xpon-part}) [@code{xpon}] extracts the ``exponent'' part @expr{e}. The original number is equal to -@texline @tmath{m \times 10^e}, +@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 @@ -16310,7 +16551,7 @@ The @kbd{f S} (@code{calc-scale-float}) [@code{scf}] function scales a number 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. +or @samp{1:20} depending on the current Fraction mode. @kindex f [ @kindex f ] @@ -16326,7 +16567,7 @@ 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 -@texline @tmath{10^{-p}}, +@texline @math{10^{-p}}, @infoline @expr{10^-p}, where @expr{p} is the current precision. These operations are defined only on integers and floats. @@ -16367,7 +16608,7 @@ expressed as an integer-valued floating-point number. 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}. +@mathit{-4}. @kindex I F @pindex calc-ceiling @@ -16379,7 +16620,7 @@ infinity. Thus @kbd{3.6 F} produces 3, but @kbd{_3.6 F} produces @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}. +4, and @kbd{_3.6 I F} produces @mathit{-3}. @kindex R @pindex calc-round @@ -16393,7 +16634,7 @@ The @kbd{R} (@code{calc-round}) [@code{round} or @code{fround}] command 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}. +but @kbd{3.4 R} produces 3; @kbd{_3.5 R} produces @mathit{-4}. @kindex I R @pindex calc-trunc @@ -16406,7 +16647,7 @@ but @kbd{3.4 R} produces 3; @kbd{_3.5 R} produces @i{-4}. 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}. +@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 @@ -16457,7 +16698,7 @@ no second argument at all. @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} +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), @@ -16484,17 +16725,17 @@ 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 -@texline `@t{(}@var{r}@t{;}@tmath{\theta}@t{)}'. -@infoline `@t{(}@var{r}@t{;}@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 +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 @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 @@ -16518,8 +16759,8 @@ or matrix argument, these functions operate element-wise. @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 @@ -16643,7 +16884,7 @@ already a polar complex number, it uses @code{rect} instead. The 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 @@ -16899,8 +17140,8 @@ of the input date form are lost. With a numeric prefix argument @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 @@ -17231,7 +17472,9 @@ the corresponding generalized time zone (like @code{PGT}). 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. @@ -17269,7 +17512,7 @@ The Lisp variable @code{math-daylight-savings-hook} holds the 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; @@ -17317,7 +17560,7 @@ daylight savings hook: @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. @@ -17326,7 +17569,7 @@ beginning of daylight savings time; converting a date/time form that 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 @@ -17773,7 +18016,7 @@ formulas below for symbolic arguments only when you use the @kbd{a "} 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}. @@ -17913,14 +18156,6 @@ and the depreciation is zero for all subsequent periods. The @code{ddb} 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 @@ -17944,10 +18179,10 @@ particular, negative arguments are converted to positive integers modulo If the word size is negative, binary operations produce 2's complement integers from -@texline @tmath{-2^{-w-1}} +@texline @math{-2^{-w-1}} @infoline @expr{-(2^(-w-1))} to -@texline @tmath{2^{-w-1}-1} +@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. @@ -17963,7 +18198,7 @@ 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. +size of @mathit{-8} @kbd{b c} converts to the range @mathit{-128} to 127. @kindex b w @pindex calc-word-size @@ -17979,7 +18214,7 @@ When the binary operations are written in symbolic form, they take an 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. @@ -18131,11 +18366,11 @@ One miscellaneous command is shift-@kbd{P} (@code{calc-pi}), which pushes the value of @cpi{} (at the current precision) onto the stack. With the Hyperbolic flag, it pushes the value @expr{e}, the base of natural logarithms. With the Inverse flag, it pushes Euler's constant -@texline @tmath{\gamma} +@texline @math{\gamma} @infoline @expr{gamma} (about 0.5772). With both Inverse and Hyperbolic, it pushes the ``golden ratio'' -@texline @tmath{\phi} +@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.) @@ -18215,7 +18450,7 @@ The @kbd{H L} (@code{calc-log10}) [@code{log10}] command computes the common it raises ten to a given power.) Note that the common logarithm of a complex number is computed by taking the natural logarithm and dividing by -@texline @tmath{\ln10}. +@texline @math{\ln10}. @infoline @expr{ln(10)}. @kindex B @@ -18225,11 +18460,11 @@ by @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 -@texline @tmath{2^{10} = 1024}. +@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 +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 @@ -18247,11 +18482,11 @@ integer arithmetic is used; otherwise, this is equivalent to @pindex calc-expm1 @tindex expm1 The @kbd{f E} (@code{calc-expm1}) [@code{expm1}] command computes -@texline @tmath{e^x - 1}, +@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 @tmath{e^x} +@texline @math{e^x} @infoline @expr{exp(x)} is close to one. @@ -18259,7 +18494,7 @@ is close to one. @pindex calc-lnp1 @tindex lnp1 The @kbd{f L} (@code{calc-lnp1}) [@code{lnp1}] command computes -@texline @tmath{\ln(x+1)}, +@texline @math{\ln(x+1)}, @infoline @expr{ln(x+1)}, producing a more accurate answer when @expr{x} is close to zero. @@ -18285,7 +18520,7 @@ of the current angular mode. @xref{Basic Operations on Units}. 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 @@ -18294,7 +18529,7 @@ 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 -@cpiover{12}, @cpiover{10}, or @cpiover{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. @@ -18393,10 +18628,10 @@ variants of these functions. @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, @@ -18421,6 +18656,25 @@ 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.) +@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 @@ -18445,7 +18699,7 @@ 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: -@texline @tmath{\Gamma(a) = \int_0^\infty t^{a-1} e^t dt}. +@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.) @@ -18479,7 +18733,7 @@ integral: 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, -@texline @tmath{P(a,x) = \left( \int_0^x t^{a-1} e^t dt \right) / \Gamma(a)}. +@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). @@ -18512,10 +18766,10 @@ You can obtain these using the \kbd{H f G} [\code{gammag}] and @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 -@texline @tmath{B(a,b) = \Gamma(a) \Gamma(b) / \Gamma(a+b)}, +@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 @tmath{B(a,b) = \int_0^1 t^{a-1} (1-t)^{b-1} dt}. +@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 @@ -18525,7 +18779,7 @@ or by @tindex betaB The @kbd{f B} (@code{calc-inc-beta}) [@code{betaI}] command computes the incomplete beta function @expr{I(x,a,b)}. It is defined by -@texline @tmath{I(x,a,b) = \left( \int_0^x t^{a-1} (1-t)^{b-1} dt \right) / B(a,b)}. +@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}]. @@ -18537,11 +18791,11 @@ un-normalized version [@code{betaB}]. @tindex erfc The @kbd{f e} (@code{calc-erf}) [@code{erf}] command computes the error function -@texline @tmath{\hbox{erf}(x) = {2 \over \sqrt{\pi}} \int_0^x e^{-t^2} dt}. +@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 -@texline @tmath{\hbox{erf}(x) + \hbox{erfc}(x) = 1}. +@texline @math{\hbox{erf}(x) + \hbox{erfc}(x) = 1}. @infoline @expr{erf(x) + erfc(x) = 1}. @kindex f j @@ -18617,17 +18871,17 @@ 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 +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 @i{-8} (as is @expr{(1., -1.732)}); Calc chooses a perhaps +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 @@ -18642,10 +18896,10 @@ For @samp{arccosh(z)}: This is defined by 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 @@ -18715,7 +18969,7 @@ random numbers of various sorts. Given a positive numeric prefix argument @expr{M}, it produces a random integer @expr{N} in the range -@texline @tmath{0 \le N < M}. +@texline @math{0 \le N < M}. @infoline @expr{0 <= N < M}. Each of the @expr{M} values appears with equal probability. @@ -18725,15 +18979,15 @@ 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 @tmath{M < N \le 0}. +@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 @tmath{0 \le N < M} +@texline @math{0 \le N < M} @infoline @expr{0 <= N < M} or -@texline @tmath{M < N \le 0}, +@texline @math{M < N \le 0}, @infoline @expr{M < N <= 0}, according to the sign of @expr{M}. @@ -18743,15 +18997,15 @@ of one. The algorithm used generates random numbers in pairs; thus, every other call to this function will be especially fast. If @expr{M} is an error form -@texline @tmath{m} @code{+/-} @tmath{\sigma} +@texline @math{m} @code{+/-} @math{\sigma} @infoline @samp{m +/- s} where @var{m} and -@texline @tmath{\sigma} +@texline @math{\sigma} @infoline @var{s} are both real numbers, the result uses a Gaussian distribution with mean @var{m} and standard deviation -@texline @tmath{\sigma}. -@var{s}. +@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, @@ -18863,7 +19117,7 @@ generators that are typically used to implement @code{random}. If @code{RandSeed} contains an integer, Calc uses this integer to seed an ``additive congruential'' method (Knuth's algorithm 3.2.2A, computing -@texline @tmath{X_{n-55} - X_{n-24}}. +@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 @@ -18899,20 +19153,20 @@ value. To create a random floating-point number with precision @var{p}, Calc simply creates a random @var{p}-digit integer and multiplies by -@texline @tmath{10^{-p}}. +@texline @math{10^{-p}}. @infoline @expr{10^-p}. The resulting random numbers should be very clean, but note that relatively small numbers will have few significant random digits. In other words, with a precision of 12, you will occasionally get numbers on the order of -@texline @tmath{10^{-9}} +@texline @math{10^{-9}} @infoline @expr{10^-9} or -@texline @tmath{10^{-10}}, +@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 @tmath{10^{-12}}. +@texline @math{10^{-12}}. @infoline @expr{10^-12}. To create a random integer in the interval @samp{[0 .. @var{m})}, Calc @@ -18963,7 +19217,7 @@ numbers. The @kbd{k E} (@code{calc-extended-gcd}) [@code{egcd}] command computes the GCD of two integers @expr{x} and @expr{y} and returns a vector @expr{[g, a, b]} where -@texline @tmath{g = \gcd(x,y) = a x + b y}. +@texline @math{g = \gcd(x,y) = a x + b y}. @infoline @expr{g = gcd(x,y) = a x + b y}. @kindex ! @@ -19007,7 +19261,7 @@ 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 -@texline @tmath{N! \over M! (N-M)!\,}. +@texline @math{N! \over M! (N-M)!\,}. @infoline @expr{N! / M! (N-M)!}. @kindex H k c @@ -19050,11 +19304,11 @@ functions. @tindex stir2 The @kbd{k s} (@code{calc-stirling-number}) [@code{stir1}] command computes a Stirling number of the first -@texline kind@tie{}@tmath{n \brack m}, +@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{}@tmath{n \brace m}. +@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} @@ -19098,8 +19352,8 @@ result is a vector of the prime factors in increasing order. For larger 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 @@ -19133,7 +19387,7 @@ analogously finds the next prime less than a given number. @tindex totient The @kbd{k t} (@code{calc-totient}) [@code{totient}] command computes the Euler ``totient'' -@texline function@tie{}@tmath{\phi(n)}, +@texline function@tie{}@math{\phi(n)}, @infoline function, the number of integers less than @expr{n} which are relatively prime to @expr{n}. @@ -19142,7 +19396,7 @@ are relatively prime to @expr{n}. @pindex calc-moebius @tindex moebius The @kbd{k m} (@code{calc-moebius}) [@code{moebius}] command computes the -@texline M@"obius @tmath{\mu} +@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 @@ -19206,7 +19460,7 @@ recover the original arguments but substitute a new value for @expr{x}.) @end ignore @tindex ltpc The @samp{utpc(x,v)} function uses the chi-square distribution with -@texline @tmath{\nu} +@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}. @@ -19224,10 +19478,10 @@ correct if its chi-square statistic is @expr{x}. @tindex ltpf The @samp{utpf(F,v1,v2)} function uses the F distribution, used in various statistical tests. The parameters -@texline @tmath{\nu_1} +@texline @math{\nu_1} @infoline @expr{v1} and -@texline @tmath{\nu_2} +@texline @math{\nu_2} @infoline @expr{v2} are the degrees of freedom in the numerator and denominator, respectively, used in computing the statistic @expr{F}. @@ -19245,7 +19499,7 @@ respectively, used in computing the statistic @expr{F}. @tindex ltpn The @samp{utpn(x,m,s)} function uses a normal (Gaussian) distribution with mean @expr{m} and standard deviation -@texline @tmath{\sigma}. +@texline @math{\sigma}. @infoline @expr{s}. It is the probability that such a normal-distributed random variable would exceed @expr{x}. @@ -19278,18 +19532,18 @@ Poisson random events will occur. @tindex ltpt The @samp{utpt(t,v)} function uses the Student's ``t'' distribution with -@texline @tmath{\nu} +@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 @tmath{A(t|\nu)} +@texline @math{A(t|\nu)} @infoline @expr{A(t|v)} where -@texline @tmath{A(0|\nu) = 1} +@texline @math{A(0|\nu) = 1} @infoline @expr{A(0|v) = 1} and -@texline @tmath{A(\infty|\nu) \to 0}. +@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)}.) @@ -19409,8 +19663,8 @@ integer, is the exponent. The result is the mantissa 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 @@ -19449,7 +19703,7 @@ returned in the form @samp{[@w{[a, b, c]}, [d, e, f]]}. If any elements of the vector are negative, other kinds of packing are done at that level as described above. For example, @samp{[2, 3, -4]} takes 12 objects and creates a -@texline @tmath{2\times3} +@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 @@ -19465,7 +19719,7 @@ packing mode (an integer or a vector of integers) and @var{items} 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. @@ -19487,18 +19741,18 @@ the result of @kbd{C-u -4 v u} will be the two vectors @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 @@ -19559,7 +19813,7 @@ subtracted, multiplied, and divided; @pxref{Basic Arithmetic}. @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 @@ -19598,7 +19852,7 @@ 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 -@texline @tmath{3\times3} +@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 @@ -19620,7 +19874,7 @@ 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. @@ -19631,7 +19885,7 @@ The @kbd{v x} (@code{calc-index}) [@code{index}] function builds a vector 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 @@ -19824,7 +20078,7 @@ 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 -@texline @tmath{2\times3} +@texline @math{2\times3} @infoline 2x3 matrix. @@ -19856,13 +20110,13 @@ 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 -@texline @tmath{1\times4} +@texline @math{1\times4} @infoline 1x4 matrix), @kbd{v a 1} produces @samp{[[1], [2], [3], [4]]} (a -@texline @tmath{4\times1} +@texline @math{4\times1} @infoline 4x1 matrix), @kbd{v a 2} produces @samp{[[1, 2], [3, 4]]} (the original -@texline @tmath{2\times2} +@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 @@ -19960,7 +20214,7 @@ a one-column matrix. @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 @@ -20182,10 +20436,10 @@ 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 -@texline union@tie{}(@tmath{A \cup B}) +@texline union@tie{}(@math{A \cup B}) @infoline union and -@texline intersection@tie{}(@tmath{A \cap B}). +@texline intersection@tie{}(@math{A \cap B}). @infoline intersection. @kindex V - @@ -20294,7 +20548,7 @@ 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 -@texline (@tmath{2^{100}}, a 31-digit integer, in this case). +@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 @@ -20406,10 +20660,10 @@ plus or minus infinity. 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 -@texline @tmath{x \pm \sigma}, +@texline @math{x \pm \sigma}, @infoline @samp{x +/- s}, this is the weighted mean of the @expr{x} values with weights -@texline @tmath{1 /\sigma^2}. +@texline @math{1 /\sigma^2}. @infoline @expr{1 / s^2}. @tex \turnoffactive @@ -20421,7 +20675,7 @@ values divided by the count of the values. Note that a plain number can be considered an error form with error -@texline @tmath{\sigma = 0}. +@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 @@ -20431,7 +20685,7 @@ has an infinite weight, next to which an error form with a finite 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 +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. @@ -20530,7 +20784,7 @@ for a vector of numbers simply by using the @kbd{A} command. @cindex Sample statistics The @kbd{u S} (@code{calc-vector-sdev}) [@code{vsdev}] command computes the standard -@texline deviation@tie{}@tmath{\sigma} +@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 @@ -20546,7 +20800,7 @@ 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 -@texline @tmath{\sqrt{12}}. +@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. @@ -20584,7 +20838,7 @@ 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 -@texline square@tie{}@tmath{\sigma^2} +@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. @@ -20608,7 +20862,7 @@ 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 -@texline @tmath{N\times2} +@texline @math{N\times2} @infoline Nx2 matrix of data values. Once again, variable names can be used in place of actual vectors and matrices. @@ -20866,7 +21120,7 @@ If any argument to @kbd{V M} is a matrix, the operator is normally mapped across all elements of the matrix. For example, given the matrix @expr{[[1, -2, 3], [-4, 5, -6]]}, @kbd{V M A} takes six absolute values to produce another -@texline @tmath{3\times2} +@texline @math{3\times2} @infoline 3x2 matrix, @expr{[[1, 2, 3], [4, 5, 6]]}. @@ -21010,8 +21264,8 @@ but they are not currently supported with @kbd{V U} or @kbd{I V U}. 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}. @@ -21277,11 +21531,11 @@ for anything else'') prefix. 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}). +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 @@ -21335,7 +21589,7 @@ sub-formula, and press @w{@kbd{j s}} (@code{calc-select-here}). Calc will 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 @@ -21365,7 +21619,7 @@ to 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}.) @@ -21818,7 +22072,7 @@ The @kbd{j D} command is implemented using rewrite rules. @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! @@ -22015,17 +22269,17 @@ but which also substitutes stored values for variables in the formula. 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}.) @@ -22033,7 +22287,7 @@ in no-simplify mode. Using @kbd{a v} will evaluate this all the way to @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 @@ -22203,17 +22457,17 @@ Manipulation}. The @kbd{m D} command turns the default simplifications back on. The most basic default simplification is the evaluation of functions. -For example, @expr{2 + 3} is evaluated to @expr{5}, and @expr{@t{sqrt}(9)} +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{@t{tan}([2,3,4])}), -range (@expr{@t{tan}(90)}), or number (@expr{@t{tan}(3,5)}), -or if the function name is not recognized (@expr{@t{f}(5)}), or if -``symbolic'' mode (@pxref{Symbolic Mode}) prevents evaluation -(@expr{@t{sqrt}(2)}). +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 @expr{@t{sqrt}(5+4)} is -simplified to @expr{@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{? :} @@ -22291,7 +22545,7 @@ simplifications.) The distributive law is used to simplify sums in some cases: @expr{a x + b x} to @expr{(a + b) x}, where @expr{a} represents -a number or an implicit 1 or @i{-1} (as in @expr{x} or @expr{-x}) +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. @@ -22316,7 +22570,7 @@ to @expr{-a}. 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 +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}. @@ -22335,25 +22589,25 @@ rewritten to @expr{a (c - b)}. The distributive law of products and powers is used for adjacent terms of the product: @expr{x^a x^b} goes to -@texline @tmath{x^{a+b}} +@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{@t{sqrt}(x)}, and similarly for +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 -@expr{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: -@texline @tmath{x^{-2} y} +@texline @math{x^{-2} y} @infoline @expr{x^(-2) y} -goes to @expr{y / x^2} unless matrix mode is +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, @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. +@expr{(a/b) c} is changed to @expr{(a c)/b} unless in Matrix mode. @tex \bigskip @@ -22370,17 +22624,17 @@ infinite quantity, as directed by the current infinite mode. @xref{Infinite Mode}. The expression -@texline @tmath{a / b^{-c}} +@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 @tmath{b^{-c}} +@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 +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}. @@ -22404,70 +22658,69 @@ to @expr{a / (c - b)}, and @expr{(a - b) / (-c)} to @expr{(b - a) / c}. @end tex 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 or complex number, in which -case the result is an infinity or an unsimplified formula according -to the current infinite mode. Note that @expr{0^0} is an -indeterminate form, as evidenced by the fact that the simplifications -for @expr{x^0} and @expr{0^x} conflict when @expr{x=0}. +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 @tmath{a^{b c}} +@texline @math{a^{b c}} @infoline @expr{a^(b c)} only when @expr{c} is an integer and @expr{b c} also evaluates to an integer. Without these restrictions these simplifications would not be safe because of problems with principal values. (In other words, -@texline @tmath{((-3)^{1/2})^2} +@texline @math{((-3)^{1/2})^2} @infoline @expr{((-3)^1:2)^2} is safe to simplify, but -@texline @tmath{((-3)^2)^{1/2}} +@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{@t{sqrt}(x)^n} is simplified to -@texline @tmath{x^{n/2}} +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{@t{abs}(a^(b c))}. +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{@t{sqrt}(x)} generally act like one-half powers -@texline @tmath{x^{1:2}} +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 @tmath{1 / x^{1:2}} +@texline @math{1 / x^{1:2}} @infoline @expr{1 / x^1:2} is changed to -@texline @tmath{x^{-1:2}}, +@texline @math{x^{-1:2}}, @infoline @expr{x^(-1:2)}, -but @expr{1 / @t{sqrt}(x)} is left alone. +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: @expr{@t{idn}(a) + b} to @expr{a + b} if @expr{b} +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{@t{idn}(a) + @t{idn}(b)} to @expr{@t{idn}(a + b)}; -@expr{-@t{idn}(a)} to @expr{@t{idn}(-a)}; @expr{a @t{idn}(b)} to -@expr{@t{idn}(a b)} if @expr{a} is provably scalar, or to @expr{a b} -if @expr{a} is provably non-scalar; @expr{@t{idn}(a) @t{idn}(b)} to -@expr{@t{idn}(a b)}; analogous simplifications for quotients involving -@code{idn}; and @expr{@t{idn}(a)^n} to @expr{@t{idn}(a^n)} where +@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 @@ -22476,27 +22729,27 @@ if @expr{a} is provably non-scalar; @expr{@t{idn}(a) @t{idn}(b)} to The @code{floor} function and other integer truncation functions vanish if the argument is provably integer-valued, so that -@expr{@t{floor}(@t{round}(x))} simplifies to @expr{@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 @expr{@t{abs}(-x)} changes to @expr{@t{abs}(x)}. -The expression @expr{@t{abs}(@t{abs}(x))} changes to -@expr{@t{abs}(x)}; in fact, @expr{@t{abs}(x)} changes to @expr{x} or +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 -@expr{@t{arg}(@t{i})} and @expr{@t{arg}(-@t{i})} just for convenience. +@expr{@tfn{arg}(@tfn{i})} and @expr{@tfn{arg}(-@tfn{i})} just for convenience. -The expression @expr{@t{conj}(@t{conj}(x))} simplifies to @expr{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, -@expr{@t{conj}(a + b i)} is changed to -@expr{@t{conj}(a) - @t{conj}(b) i}, or to @expr{a - b i} if @expr{a} +@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 @@ -22506,13 +22759,13 @@ described in the next section does provide some simplifications for these functions, though. One important simplification that does occur is that -@expr{@t{ln}(@t{e})} is simplified to 1, and @expr{@t{ln}(@t{e}^x)} is +@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 @expr{!!x} to @expr{x}, this would not be valid in general because @@ -22580,7 +22833,7 @@ property that real-valued numbers, interval forms and infinities 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. @@ -22594,7 +22847,7 @@ 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, @expr{(a:b) x}, is changed to a quotient involving integers: @expr{a x / b}. This is not @@ -22609,7 +22862,7 @@ 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, @expr{a x^2 b / c x^3 d} will -cancel @expr{x^2} from both sides to get @expr{a b / c x d}. +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; @@ -22636,17 +22889,17 @@ user might not have been thinking of. Square roots of integer or rational arguments are simplified in several ways. (Note that these will be left unevaluated only in Symbolic mode.) First, square integer or rational factors are -pulled out so that @expr{@t{sqrt}(8)} is rewritten as -@texline @tmath{$2\,\t{sqrt}(2)$}. +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: @expr{1 / @t{sqrt}(3)} changes to @expr{@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: -@expr{@t{sqrt}(2:3)} changes to @expr{@t{sqrt}(6) / 3}. +@expr{@tfn{sqrt}(2:3)} changes to @expr{@tfn{sqrt}(6) / 3}. @tex \bigskip @@ -22678,18 +22931,27 @@ declared to be an integer. \bigskip @end tex -Trigonometric functions are simplified in several ways. First, -@expr{@t{sin}(@t{arcsin}(x))} is simplified to @expr{x}, and -similarly for @code{cos} and @code{tan}. If the argument to -@code{sin} is negative-looking, it is simplified to -@expr{-@t{sin}(x),}, and similarly for @code{cos} and @code{tan}. +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 @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}. -Trigonometric functions of inverses of different trigonometric -functions can also be simplified, as in @expr{@t{sin}(@t{arccos}(x))} -to @expr{@t{sqrt}(1 - x^2)}. - Hyperbolic functions of their inverses and of negative-looking arguments are also handled, as are exponentials of inverse hyperbolic functions. @@ -22697,29 +22959,29 @@ hyperbolic functions. 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 -@expr{@t{arcsin}(@t{sin}(x))} can @emph{not} safely change to +@expr{@tfn{arcsin}(@tfn{sin}(x))} can @emph{not} safely change to @expr{x}, since this only correct within an integer multiple of -@texline @tmath{2 \pi} +@texline @math{2 \pi} @infoline @expr{2 pi} -radians or 360 degrees. However, @expr{@t{arcsinh}(@t{sinh}(x))} is +radians or 360 degrees. However, @expr{@tfn{arcsinh}(@tfn{sinh}(x))} is simplified to @expr{x} if @expr{x} is known to be real. Several simplifications that apply to logarithms and exponentials -are that @expr{@t{exp}(@t{ln}(x))}, -@texline @t{e}@tmath{^{\ln(x)}}, -@infoline @expr{e^@t{ln}(x)}, +are that @expr{@tfn{exp}(@tfn{ln}(x))}, +@texline @tfn{e}@math{^{\ln(x)}}, +@infoline @expr{e^@tfn{ln}(x)}, and -@texline @tmath{10^{{\rm log10}(x)}} -@infoline @expr{10^@t{log10}(x)} -all reduce to @expr{x}. Also, @expr{@t{ln}(@t{exp}(x))}, etc., can +@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{@t{exp}(x)^y} is simplified to @expr{@t{exp}(x y)}. If @expr{x} +@expr{@tfn{exp}(x)^y} is simplified to @expr{@tfn{exp}(x y)}. If @expr{x} is a suitable multiple of -@texline @tmath{\pi i} +@texline @math{\pi i} @infoline @expr{pi i} (as described above for the trigonometric functions), then -@expr{@t{exp}(x)} or @expr{e^x} will be expanded. Finally, -@expr{@t{ln}(x)} is simplified to a form involving @code{pi} and +@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. @@ -22791,40 +23053,40 @@ by @kbd{a e}. Inverse trigonometric or hyperbolic functions, called with their corresponding non-inverse functions as arguments, are simplified -by @kbd{a e}. For example, @expr{@t{arcsin}(@t{sin}(x))} changes -to @expr{x}. Also, @expr{@t{arcsin}(@t{cos}(x))} and -@expr{@t{arccos}(@t{sin}(x))} both change to @expr{@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 @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 @expr{(x^a)^b} are simplified to -@texline @tmath{x^{a b}} +@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 @tmath{(x^2)^{1:2}} +@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{@t{sqrt}(x^a)} and @expr{@t{sqrt}(x)^a} are both +Similarly, @expr{@tfn{sqrt}(x^a)} and @expr{@tfn{sqrt}(x)^a} are both simplified (possibly unsafely) to -@texline @tmath{x^{a/2}}. +@texline @math{x^{a/2}}. @infoline @expr{x^(a/2)}. -Forms like @expr{@t{sqrt}(1 - sin(x)^2)} are simplified to, e.g., -@expr{@t{cos}(x)}. Calc has identities of this sort for @code{sin}, +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, -@expr{@t{sqrt}(a^2 b^3 + a^3 b^2)} simplifies to -@expr{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 @expr{@t{ln}(@t{exp}(x))}, -@expr{@t{ln}(@t{e}^x)}, and @expr{@t{log10}(10^x)} to @expr{x} are also +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). @@ -22887,7 +23149,7 @@ number for an answer, then the quotient simplifies to that number. For powers and square roots, the ``unsafe'' simplifications @expr{(a b)^c} to @expr{a^c b^c}, @expr{(a/b)^c} to @expr{a^c / b^c}, and @expr{(a^b)^c} to -@texline @tmath{a^{b c}} +@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 @@ -22902,10 +23164,10 @@ is simplified by noting that @expr{1.5 = 3:2}, that @samp{acre} is defined in terms of @samp{m^2}, and that the 2 in the power of @code{m} is a multiple of 2 in @expr{3:2}. Thus, @code{acre^1.5} is replaced by approximately -@texline @tmath{(4046 m^2)^{1.5}} +@texline @math{(4046 m^2)^{1.5}} @infoline @expr{(4046 m^2)^1.5}, which is then changed to -@texline @tmath{4046^{1.5} \, (m^2)^{1.5}}, +@texline @math{4046^{1.5} \, (m^2)^{1.5}}, @infoline @expr{4046^1.5 (m^2)^1.5}, then to @expr{257440 m^3}. @@ -23188,14 +23450,14 @@ With a numeric prefix argument @var{n}, this command computes the @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 @expr{f} with respect to @expr{x}, evaluated at the point -@texline @tmath{x=x_0}. +@texline @math{x=x_0}. @infoline @expr{x=x0}. If the formula being differentiated contains functions which Calc does @@ -23230,12 +23492,12 @@ argument once). @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; -@texline @tmath{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 @expr{x^3/(x^2+1)}, which is.) Also, square roots of terms involving @@ -23243,6 +23505,11 @@ is not strictly a quotient of polynomials, but it is equivalent to 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 @@ -23261,7 +23528,7 @@ integral $\int_a^b f(x) \, dx$. Please note that the current implementation of Calc's integrator sometimes produces results that are significantly more complex than they need to be. For example, the integral Calc finds for -@texline @tmath{1/(x+\sqrt{x^2+1})} +@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 @@ -23269,17 +23536,17 @@ 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 -@texline @tmath{1/(1+\tan x)} +@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 @tmath{\pi i / 2} +@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}. @@ -23333,7 +23600,7 @@ in your @code{IntegRules}. As a more serious example, the expression @samp{exp(x)/x} cannot be integrated in terms of the standard functions, so the ``exponential integral'' function -@texline @tmath{{\rm Ei}(x)} +@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} @@ -23354,7 +23621,7 @@ is allowed only within @code{IntegRules}; it means ``integrate this 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))}, @@ -23506,16 +23773,16 @@ form @expr{X = 0}. This command also works for inequalities, as in @expr{y < 3x + 6}. Some inequalities cannot be solved where the analogous equation could be; for example, solving -@texline @tmath{a < b \, c} +@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 @tmath{b \mathbin{\hbox{\code{!=}}} a/c} +@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 @tmath{a \le b \, c} +@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. @@ -23542,7 +23809,7 @@ Some equations have more than one solution. The Hyperbolic flag 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 @@ -23594,7 +23861,7 @@ on variables, but you can use the @kbd{a b} (@code{calc-substitute}) 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 @@ -23638,10 +23905,10 @@ 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). @@ -23975,11 +24242,11 @@ with the minimum value itself. Note that this command looks for a @emph{local} minimum. Many functions have more than one minimum; some, like -@texline @tmath{x \sin x}, +@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 @tmath{x \sin x} +@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 @@ -24102,7 +24369,7 @@ 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 -@texline @tmath{2\times N} +@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 @@ -24110,10 +24377,10 @@ 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 @tmath{N\times2} +@texline @math{N\times2} @infoline Nx2 matrix instead of a -@texline @tmath{2\times N} +@texline @math{2\times N} @infoline 2xN matrix, just press @kbd{v t} first to transpose the matrix. @@ -24211,11 +24478,11 @@ 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 @tmath{\chi^2 \ge 0}. +@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 @tmath{\chi^2} +@texline @math{\chi^2} @infoline @expr{chi^2} is as small as possible. @@ -24256,9 +24523,9 @@ 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 @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. +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 +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 @@ -24271,7 +24538,7 @@ line slightly to improve the fit. 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: @@ -24283,7 +24550,7 @@ The actual coefficients we get with a precision of 12, like @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 @@ -24376,10 +24643,10 @@ contain error forms. The data values must either all include errors or all be plain numbers. Error forms can go anywhere but generally go on the numbers in the last row of the data matrix. If the last row contains error forms -@texline `@var{y_i}@w{ @t{+/-} }@tmath{\sigma_i}', -@infoline `@var{y_i}@w{ @t{+/-} }@var{sigma_i}', +@texline `@var{y_i}@w{ @tfn{+/-} }@math{\sigma_i}', +@infoline `@var{y_i}@w{ @tfn{+/-} }@var{sigma_i}', then the -@texline @tmath{\chi^2} +@texline @math{\chi^2} @infoline @expr{chi^2} statistic is now, @@ -24402,7 +24669,7 @@ the fitting operation. If there are error forms on other rows of the data matrix, all the errors for a given data point are combined; the square root of the sum of the squares of the errors forms the -@texline @tmath{\sigma_i} +@texline @math{\sigma_i} @infoline @expr{sigma_i} used for the data point. @@ -24412,14 +24679,14 @@ probably use @kbd{H a F} so that the output also contains error estimates. If the input contains error forms but all the -@texline @tmath{\sigma_i} +@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 (@tmath{\chi^2} +@texline (@math{\chi^2} @infoline (@expr{chi^2} is simply scaled uniformly by -@texline @tmath{1 / \sigma^2}, +@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 @@ -24454,20 +24721,20 @@ will have length @expr{M = d+1} with the constant term first. @item The covariance matrix @expr{C} computed from the fit. This is an @var{m}x@var{m} symmetric matrix; the diagonal elements -@texline @tmath{C_{jj}} +@texline @math{C_{jj}} @infoline @expr{C_j_j} are the variances -@texline @tmath{\sigma_j^2} +@texline @math{\sigma_j^2} @infoline @expr{sigma_j^2} of the parameters. The other elements are covariances -@texline @tmath{\sigma_{ij}^2} +@texline @math{\sigma_{ij}^2} @infoline @expr{sigma_i_j^2} that describe the correlation between pairs of parameters. (A related set of numbers, the @dfn{linear correlation coefficients} -@texline @tmath{r_{ij}}, +@texline @math{r_{ij}}, @infoline @expr{r_i_j}, are defined as -@texline @tmath{\sigma_{ij}^2 / \sigma_i \, \sigma_j}.) +@texline @math{\sigma_{ij}^2 / \sigma_i \, \sigma_j}.) @infoline @expr{sigma_i_j^2 / sigma_i sigma_j}.) @item @@ -24478,11 +24745,11 @@ polynomial and multilinear fits described so far. @item The value of -@texline @tmath{\chi^2} +@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 @tmath{\chi^2 \approx N - M} +@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). @@ -24491,13 +24758,13 @@ data points and @expr{M} is the number of parameters). A measure of goodness of fit expressed as a probability @expr{Q}. This is computed from the @code{utpc} probability distribution function using -@texline @tmath{\chi^2} +@texline @math{\chi^2} @infoline @expr{chi^2} with @expr{N - M} degrees of freedom. A value of 0.5 implies a good fit; some texts recommend that often @expr{Q = 0.1} or even 0.001 can signify an acceptable fit. In particular, -@texline @tmath{\chi^2} +@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 @@ -24506,7 +24773,7 @@ have to accept smaller values of @expr{Q}. The @expr{Q} value is computed only if the input included error estimates. Otherwise, Calc will report the symbol @code{nan} for @expr{Q}. The reason is that in this case the -@texline @tmath{\chi^2} +@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 @@ -24525,31 +24792,31 @@ Here is a complete list of the standard models recognized by @kbd{a F}: @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. -@texline @tmath{{a \over b \sqrt{2 \pi}} \exp\left( -{1 \over 2} \left( x - c \over b \right)^2 \right)}. -@infoline @i{(a / b sqrt(2 pi)) exp(-0.5*((x-c)/b)^2)}. +@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 @@ -24661,18 +24928,18 @@ Calc uses the principal values of inverse functions like @code{ln} 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 -@texline @tmath{3\times360} -@infoline @i{3*360} +@texline @math{3\times360} +@infoline @mathit{3*360} degrees. The above model would appear to be a good way to determine the true frequency and phase of the sine wave, but in practice it would fail utterly. The righthand side of the actual model @samp{arcsin(y) = a t + b} will grow smoothly with @expr{t}, but -the lefthand side will bounce back and forth between @i{-90} and 90. +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. @@ -24727,16 +24994,16 @@ ln(y) = ln(a) + b ln(x) @noindent which matches the desired form with -@texline @tmath{Y = \ln(y)}, +@texline @math{Y = \ln(y)}, @infoline @expr{Y = ln(y)}, -@texline @tmath{A = \ln(a)}, +@texline @math{A = \ln(a)}, @infoline @expr{A = ln(a)}, @expr{F = 1}, @expr{B = b}, and -@texline @tmath{G = \ln(x)}. +@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 @tmath{a = \exp(A)} +@texline @math{a = \exp(A)} @infoline @expr{a = exp(A)} and @expr{b = B}. @@ -24750,7 +25017,7 @@ y = a + b c^2 - 2 b c x + b x^2 @noindent which matches with @expr{Y = y}, @expr{A = a + b c^2}, @expr{F = 1}, -@expr{B = -2 b c}, @expr{G = x} (the @i{-2} factor could just as easily +@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}. @@ -24782,7 +25049,7 @@ from the list of parameters when you answer the variables prompt. A last desperate step would be to use the general-purpose @code{minimize} function rather than @code{fit}. After all, both functions solve the problem of minimizing an expression (the -@texline @tmath{\chi^2} +@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 @@ -24793,7 +25060,7 @@ 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 -@texline @tmath{\chi^2} +@texline @math{\chi^2} @infoline @expr{chi^2} returned as the fifth result of the @code{xfit} function: @@ -24853,11 +25120,11 @@ 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 -@texline @tmath{\sigma_i} +@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 @tmath{\sigma_i}. +@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; @@ -24869,7 +25136,7 @@ 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 -@texline @tmath{\sigma} +@texline @math{\sigma} @infoline @expr{sigma} for the data point with no further ado.) @@ -25201,7 +25468,7 @@ As a special feature, if the limits are infinite (or omitted, as 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, @@ -25211,7 +25478,7 @@ Calc computes the number of iterations using the formula 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, @@ -25223,7 +25490,7 @@ If the lower limit is greater than the upper limit (assuming a 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. @@ -25249,7 +25516,7 @@ 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 -@texline @tmath{k \ne k_0}, +@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}. @@ -25424,7 +25691,7 @@ stack. It also works elementwise on vectors. For example, if 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 & @@ -25954,12 +26221,12 @@ like @samp{(x + y) + (z - w)}, are not tried. 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, @@ -26264,16 +26531,16 @@ then the rule set @samp{[f(0) := 0, import(linearF)]} will apply all three rules. It is possible to modify the imported rules slightly: @samp{import(x, v1, x1, v2, x2, @dots{})} imports the rule set @expr{x} with all occurrences of -@texline @tmath{v_1}, +@texline @math{v_1}, @infoline @expr{v1}, as either a variable name or a function name, replaced with -@texline @tmath{x_1} +@texline @math{x_1} @infoline @expr{x1} and so on. (If -@texline @tmath{v_1} +@texline @math{v_1} @infoline @expr{v1} is used as a function name, then -@texline @tmath{x_1} +@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, @@ -26436,8 +26703,8 @@ You must use @code{apply} for meta-variables with function names 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}}. @@ -27172,7 +27439,7 @@ To apply these manually, you could put them in a variable called 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 @@ -27248,11 +27515,11 @@ 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 @expr{(3,4)}, so that @samp{sqrt(25)} must be calculated, -then symbolic mode will not help because @samp{sqrt(25)} can be +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 @@ -27359,7 +27626,7 @@ A surprisingly useful rewrite rule is @samp{a/(b-c) := a*(b+c)/(b^2-c^2)}. 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)}. @@ -27469,7 +27736,7 @@ 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. -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. @@ -27653,7 +27920,7 @@ argument to @kbd{u v}. 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. @@ -27710,9 +27977,17 @@ for Angstroms. @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 @@ -27738,8 +28013,8 @@ the @kbd{u g} command gets the definition of one of these constants 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 @@ -27820,13 +28095,14 @@ possible to create user-defined temperature units. @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 @@ -27858,14 +28134,8 @@ to variables use the @kbd{s} prefix key. 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 @@ -27956,10 +28226,10 @@ All the arithmetic stores accept the Inverse prefix to reverse the order of the operands. If @expr{v} represents the contents of the variable, and @expr{a} is the value drawn from the stack, then regular @w{@kbd{s -}} assigns -@texline @tmath{v \coloneq v - a}, +@texline @math{v \coloneq v - a}, @infoline @expr{v := v - a}, but @kbd{I s -} assigns -@texline @tmath{v \coloneq a - v}. +@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 @@ -28034,12 +28304,21 @@ pushes the old value of @samp{a} on the stack and stores @samp{a = 6}. @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. +@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 to unstore these variables or to store new values into them if you like, @@ -28049,25 +28328,26 @@ you change the value of one of these variables, or of one of the other 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 @cpi{} -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 @@ -28104,7 +28384,7 @@ value of a variable without ever putting that value on the stack 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. @@ -28217,17 +28497,18 @@ names rather than prompting for the variable name. @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}; @@ -28239,10 +28520,11 @@ 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 @@ -28296,7 +28578,7 @@ 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. @@ -28358,11 +28640,11 @@ including the current simplification mode. Recall that the formula @samp{x + y + x} is not handled by Calc's default simplifications, but the @kbd{a s} command will reduce it to the simpler form @samp{y + 2 x}. You can also type @kbd{m A} -to enable an algebraic-simplification mode in which the +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 @@ -28401,17 +28683,17 @@ side effects. @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{=>}. @@ -28420,20 +28702,20 @@ 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. @@ -28546,13 +28828,13 @@ 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 -@texline @tmath{z_{ij}} +@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, @@ -28657,7 +28939,7 @@ 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 -@texline @tmath{\sin n x} +@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 @@ -28669,7 +28951,7 @@ 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 @expr{n}, it takes @expr{n+2} arguments (common ``x'' and ``y'', plus @expr{n} @@ -28908,7 +29190,7 @@ values, but if you store a vector of integers in one of these variables, 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. @@ -28947,10 +29229,10 @@ 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 -@texline @tmath{80\times24} +@texline @math{80\times24} @infoline 80x24 characters. The graph is displayed in -an Emacs ``recursive edit''; type @kbd{q} or @kbd{M-# M-#} to exit +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. @@ -29010,7 +29292,7 @@ of the @samp{*Gnuplot Commands*} buffer. @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 @@ -29023,7 +29305,8 @@ display or 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. +to display or print the output. These variables are customizable +(@pxref{Customizing Calc}). @kindex g x @pindex calc-graph-display @@ -29108,7 +29391,7 @@ killing GNUPLOT because you think it has gotten stuck. 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 @@ -29182,20 +29465,20 @@ difference.) @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 -@expr{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 @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 @@ -29206,19 +29489,19 @@ line. 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 @@ -29238,15 +29521,15 @@ were surrounded by square brackets. Leading line numbers (in the 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 @@ -29257,39 +29540,39 @@ 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 -@texline @tmath{1\times1} +@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 @@ -29321,13 +29604,13 @@ latter strips off the trailing newline. 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}). +@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 @@ -29344,8 +29627,8 @@ number, lengthening or shortening as necessary. The concept of ``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! @@ -29378,22 +29661,22 @@ whole line. So you can usually transfer a single number into Calc 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 @@ -29404,11 +29687,11 @@ the @samp{*Calc Keypad*} window, place the cursor on the desired ``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. @@ -29435,7 +29718,7 @@ original buffer. @smallexample @group -|----+-----Calc 2.00-----+----1 +|----+-----Calc 2.1------+----1 |FLR |CEIL|RND |TRNC|CLN2|FLT | |----+----+----+----+----+----| | LN |EXP | |ABS |IDIV|MOD | @@ -29456,7 +29739,7 @@ original buffer. @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. @@ -29473,7 +29756,7 @@ At other times it changes the sign of the number on the top of the 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. @@ -29493,7 +29776,7 @@ The @key{EXEC} key prompts you to enter any keystroke sequence 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 @@ -29554,9 +29837,9 @@ of 0 @samp{[]}, 1 @samp{[)}, 2 @samp{(]} or 3 @samp{()}, followed 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. @@ -29595,7 +29878,7 @@ same limit as last time. @key{INV GCD} computes the LCM (least common multiple) function. @key{INV FACT} is the gamma function. -@texline @tmath{\Gamma(x) = (x-1)!}. +@texline @math{\Gamma(x) = (x-1)!}. @infoline @expr{gamma(x) = (x-1)!}. @key{PERM} is the number-of-permutations function, which is on the @@ -29772,16 +30055,16 @@ The @key{OVER} key duplicates the second-to-top stack element. 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 @@ -29796,17 +30079,29 @@ linked to the stack and this copying is taken care of automatically. @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 @@ -29814,7 +30109,7 @@ understands are: 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 @@ -29828,25 +30123,25 @@ your own favorite delimiters. Delimiters like @samp{$ $} can appear 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 @@ -29856,7 +30151,7 @@ in Normal language mode, but the @code{atan} won't correspond to 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. @@ -29870,10 +30165,10 @@ not affected by Embedded mode. 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: @@ -29907,7 +30202,7 @@ needs to be commuted. 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: @@ -29923,9 +30218,9 @@ at this point will exchange the two stack values and restore 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 @@ -29933,11 +30228,11 @@ leaving Embedded mode always removes one thing. Anything else 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) @@ -29951,17 +30246,15 @@ you haven't done anything with this formula yet. 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 @@ -29981,12 +30274,13 @@ version. 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 @@ -30049,10 +30343,10 @@ and at x = 3 is @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. @@ -30066,7 +30360,7 @@ The derivative of @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 @@ -30081,12 +30375,12 @@ The derivative of @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. @@ -30094,43 +30388,40 @@ 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 @@ -30192,10 +30483,10 @@ will do the trick) to select the righthand side of the 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. @@ -30206,20 +30497,18 @@ bar := foo + 3 => 20 @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. +the change. The @kbd{C-x * u} (@code{calc-embedded-update-formula}) +command is a convenient way to do this. @example foo := 6 @@ -30227,29 +30516,29 @@ 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 @@ -30257,7 +30546,7 @@ formulas' positions are registered with Embedded mode so that 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 @@ -30272,7 +30561,7 @@ a few lines that look like this: @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. @@ -30280,41 +30569,41 @@ 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 @@ -30350,29 +30639,38 @@ and loaded in a later Emacs session, unless you have used 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. @@ -30402,8 +30700,9 @@ formula are never used (except for global annotations, described 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; @@ -30421,11 +30720,11 @@ of mode setting, the second is a name for the mode itself, and 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 @@ -30441,7 +30740,7 @@ that look like this, respectively: @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.) @@ -30459,11 +30758,11 @@ mode annotations somewhere out of the way, say, on a new page of 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. @@ -30479,36 +30778,35 @@ rules of reading annotations the @samp{(sci 0)} applies to it, too. 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 @@ -30582,8 +30880,8 @@ case). @vindex calc-embedded-open-word @vindex calc-embedded-close-word The @code{calc-embedded-open-word} and @code{calc-embedded-close-word} -variables are similar expressions used when you type @kbd{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 @@ -30591,20 +30889,22 @@ begins a ``plain'' formula written in front of the formatted 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. @@ -30612,24 +30912,25 @@ 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 @@ -30637,16 +30938,17 @@ regular expression) which should precede a mode annotation. 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 @@ -30739,30 +31041,30 @@ key we defined above. @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 @@ -30844,41 +31146,26 @@ Once you have bound your keyboard macro to a key, you can use @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}. - -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. - -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. +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 @@ -30983,7 +31270,7 @@ happened to be sitting on the stack before we typed the above definition! 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 / @@ -31023,7 +31310,7 @@ forced to use upward-counting conventions. In this case, if @var{initial} 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 @} @@ -31057,7 +31344,7 @@ conditional and looping commands. @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. @@ -31106,7 +31393,7 @@ for all mode-setting commands inside the macro. 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. @@ -31117,23 +31404,35 @@ are @emph{not} affected by @kbd{Z `} and @kbd{Z '}. @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 @@ -31145,29 +31444,29 @@ return control to the keyboard macro. @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!) @@ -31202,9 +31501,11 @@ If you want to give the formula a long-style name only, you can press @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 @@ -31263,8 +31564,9 @@ 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 @@ -31475,12 +31777,17 @@ step of @code{myfact} could have been written :"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 @@ -31667,7 +31974,7 @@ decreases the precision. @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.") @@ -31715,7 +32022,7 @@ to pop @var{num} values off the stack, resimplify them by calling @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) @@ -31994,7 +32301,7 @@ same thing with a single division by 512. @tindex mysin A somewhat limited sine function could be defined as follows, using the well-known Taylor series expansion for -@texline @tmath{\sin x}: +@texline @math{\sin x}: @infoline @samp{sin(x)}: @smallexample @@ -32178,7 +32485,7 @@ If the first argument to @code{calc-eval} is a list whose first 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. @@ -32201,7 +32508,7 @@ It's usually best to use this form of @code{calc-eval} unless your 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 @expr{a} is less than the one in @@ -32517,10 +32824,10 @@ which is not a Lisp list. 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} @@ -32541,7 +32848,7 @@ Floating-point numbers are stored in the form, @samp{(float @var{mant} @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 @@ -32745,7 +33052,7 @@ this function returns the selected portions rather than the entire 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} @@ -32777,7 +33084,7 @@ will be used. 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 @@ -32853,7 +33160,7 @@ is applied to the top stack element, or, if @var{unary} is not 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 +mapped between the next-to-top @mathit{-@var{arg}} stack elements and the top element. @end defun @@ -33139,13 +33446,13 @@ 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 +@samp{(normalize (list 'calcFunc-sin 5))}, which in Symbolic mode will return the formula @samp{sin(5)} to your function. @end defun @@ -33191,9 +33498,9 @@ 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. -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 @@ -33272,7 +33579,7 @@ or formula, this calls @code{reject-arg}. @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. @@ -33285,7 +33592,7 @@ considered to have zero digits. @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 @@ -33342,22 +33649,25 @@ example, for a rectangular complex number the result is the sum of 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. +@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} @@ -33381,7 +33691,7 @@ again to 30 digits for use in the present request. 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 @@ -33439,12 +33749,12 @@ If @var{a} is a formula, this returns the formula @samp{deg(@var{a})}. @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 @@ -33493,7 +33803,7 @@ function @code{frac}, and can be rather slow. @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 @@ -34400,13 +34710,13 @@ per Emacs session. @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 @@ -34415,10 +34725,24 @@ and @code{select-window} to create the Calc window. @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 @@ -34433,12 +34757,12 @@ text. (In fact it may still have leftover text from a previous @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 @@ -34503,112 +34827,319 @@ used the first time, your hook should add a variable to the 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. +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. +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 . "\n\\(\n\\)*") + (html-mode . "\n\\(\n\\)*") + (nroff-mode . "\\\\\"Embed\n\\(\\\\\" .*\n\\)*") + (pascal-mode . "@{Embed@}\n\\(@{.*@}\n\\)*") + (sgml-mode . "\n\\(\n\\)*") + (xml-mode . "\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. +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 @@ -34619,15 +35150,6 @@ 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 @@ -34635,25 +35157,25 @@ send your mail. Make sure your subject line indicates that you are 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). @@ -34701,41 +35223,41 @@ keystrokes are not listed in this summary. @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} @@ -35044,6 +35566,7 @@ keystrokes are not listed in this summary. @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@:} @@ -35225,6 +35748,7 @@ keystrokes are not listed in this summary. @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@:} @@ -35256,6 +35780,7 @@ keystrokes are not listed in this summary. @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)} @@ -35294,8 +35819,8 @@ keystrokes are not listed in this summary. @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@:} @@ -35497,8 +36022,7 @@ keystrokes are not listed in this summary. @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@:} @@ -35636,8 +36160,8 @@ input data set. Each entry may be a single value or a vector of values. @c 20 @item With a prefix argument of 1, take a single -@texline @tmath{@var{n}\times2} -@infoline @i{@var{N}x2} +@texline @var{n}@math{\times2} +@infoline @mathit{@var{N}x2} matrix from the stack instead of two separate data vectors. @c 21 @@ -35738,9 +36262,9 @@ Variable name may be a single digit or a full name. @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 @@ -35839,7 +36363,7 @@ to evaluate variables. The variable is replaced by the formula shown on the right. The Inverse flag reverses the order of the operands, e.g., @kbd{I s - x} assigns -@texline @tmath{x \coloneq a-x}. +@texline @math{x \coloneq a-x}. @infoline @expr{x := a-x}. @c 48 @@ -35847,7 +36371,7 @@ assigns Press @kbd{?} repeatedly to see how to choose a model. Answer the variables prompt with @expr{iv} or @expr{iv;pv} to specify independent and parameter variables. A positive prefix argument -takes @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 @@ -35924,7 +36448,7 @@ as Calc variables. Add a @samp{var-} prefix to get the name of the 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