This is Info file calc.info, produced by Makeinfo-1.55 from the input file calc.texinfo. This file documents Calc, the GNU Emacs calculator. Copyright (C) 1990, 1991 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the section entitled "GNU General Public License" is included exactly as in the original, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that the section entitled "GNU General Public License" may be included in a translation approved by the author instead of in the original English. File: calc.info, Node: Top, Next: Getting Started, Up: (dir) The GNU Emacs Calculator ************************ "Calc 2.02" is an advanced desk calculator and mathematical tool that runs as part of the GNU Emacs environment. This manual is divided into three major parts: "Getting Started," the "Calc Tutorial," and the "Calc Reference." The Tutorial introduces all the major aspects of Calculator use in an easy, hands-on way. The remainder of the manual is a complete reference to the features of the Calculator. For help in the Emacs Info system (which you are using to read this file), type `?'. (You can also type `h' to run through a longer Info tutorial.) * Menu: * Copying:: How you can copy and share Calc. * Getting Started:: General description and overview. * Tutorial:: A step-by-step introduction for beginners. * Introduction:: Introduction to the Calc reference manual. * Data Types:: Types of objects manipulated by Calc. * Stack and Trail:: Manipulating the stack and trail buffers. * Mode Settings:: Adjusting display format and other modes. * Arithmetic:: Basic arithmetic functions. * Scientific Functions:: Transcendentals and other scientific functions. * Matrix Functions:: Operations on vectors and matrices. * Algebra:: Manipulating expressions algebraically. * Units:: Operations on numbers with units. * Store and Recall:: Storing and recalling variables. * Graphics:: Commands for making graphs of data. * Kill and Yank:: Moving data into and out of Calc. * Embedded Mode:: Working with formulas embedded in a file. * Programming:: Calc as a programmable calculator. * Installation:: Installing Calc as a part of GNU Emacs. * Reporting Bugs:: How to report bugs and make suggestions. * Summary:: Summary of Calc commands and functions. * Key Index:: The standard Calc key sequences. * Command Index:: The interactive Calc commands. * Function Index:: Functions (in algebraic formulas). * Concept Index:: General concepts. * Variable Index:: Variables used by Calc (both user and internal). * Lisp Function Index:: Internal Lisp math functions. File: calc.info, Node: Copying, Next: Getting Started, Prev: Top, Up: Top GNU GENERAL PUBLIC LICENSE ************************** Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble ======== The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our 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. 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. 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 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. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we 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. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 1. 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". 2. 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. 3. 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: * cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and * 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). * 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 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. 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. 4. 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: * 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 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 the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) 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. 5. 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. 6. 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. 7. 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. 8. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will 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 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 Foundation. 9. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 10. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 11. 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. File: calc.info, Node: Getting Started, Next: Tutorial, Prev: Top, Up: Top Getting Started *************** This chapter provides a general overview of Calc, the GNU Emacs Calculator: What it is, how to start it and how to exit from it, and what are the various ways that it can be used. * Menu: * What is Calc:: * About This Manual:: * Notations Used in This Manual:: * Using Calc:: * Demonstration of Calc:: * History and Acknowledgements:: File: calc.info, Node: What is Calc, Next: About This Manual, Prev: Getting Started, Up: Getting Started What is Calc? ============= "Calc" is an advanced calculator and mathematical tool that runs as part of the GNU Emacs environment. Very roughly based on the HP-28/48 series of calculators, its many features include: * Choice of algebraic or RPN (stack-based) entry of calculations. * Arbitrary precision integers and floating-point numbers. * Arithmetic on rational numbers, complex numbers (rectangular and polar), error forms with standard deviations, open and closed intervals, vectors and matrices, dates and times, infinities, sets, quantities with units, and algebraic formulas. * Mathematical operations such as logarithms and trigonometric functions. * Programmer's features (bitwise operations, non-decimal numbers). * Financial functions such as future value and internal rate of return. * Number theoretical features such as prime factorization and arithmetic modulo M for any M. * Algebraic manipulation features, including symbolic calculus. * Moving data to and from regular editing buffers. * "Embedded mode" for manipulating Calc formulas and data directly inside any editing buffer. * Graphics using GNUPLOT, a versatile (and free) plotting program. * Easy programming using keyboard macros, algebraic formulas, algebraic rewrite rules, or extended Emacs Lisp. Calc tries to include a little something for everyone; as a result it is 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! File: calc.info, Node: About This Manual, Next: Notations Used in This Manual, Prev: What is Calc, Up: Getting Started About This Manual ================= This document serves as a complete description of the GNU Emacs Calculator. It works both as an introduction for novices, and as a reference for experienced users. While it helps to have some experience with GNU Emacs in order to get the most out of Calc, this manual ought to be readable even if you don't know or use Emacs regularly. The manual is divided into three major parts: the "Getting Started" chapter you are reading now, the Calc tutorial (chapter 2), and the Calc reference manual (the remaining chapters and appendices). If you are in a hurry to use Calc, there is a brief "demonstration" below which illustrates the major features of Calc in just a couple of pages. If you don't have time to go through the full tutorial, this will show you everything you need to know to begin. *Note Demonstration of Calc::. The tutorial chapter walks you through the various parts of Calc with lots of hands-on examples and explanations. If you are new to Calc and you have some time, try going through at least the beginning of the tutorial. The tutorial includes about 70 exercises with answers. These exercises give you some guided practice with Calc, as well as pointing out some interesting and unusual ways to use its features. The reference section discusses Calc in complete depth. You can read the reference from start to finish if you want to learn every aspect of Calc. Or, you can look in the table of contents or the Concept Index to find the parts of the manual that discuss the things you need to know. Every Calc keyboard command is listed in the Calc Summary, and also in the Key Index. Algebraic functions, `M-x' commands, and variables also have their own indices. In the printed manual, each paragraph that is referenced in the Key or Function Index is marked in the margin with its index entry. You can access this manual on-line at any time within Calc by pressing the `h i' key sequence. Outside of the Calc window, you can press `M-# i' to read the manual on-line. Also, you can jump directly to the Tutorial by pressing `h t' or `M-# t', or to the Summary by pressing `h s' or `M-# s'. Within Calc, you can also go to the part of the manual describing any Calc key, function, or variable using `h k', `h f', or `h v', respectively. *Note Help Commands::. Printed copies of this manual are also available from the Free Software Foundation. File: calc.info, Node: Notations Used in This Manual, Next: Demonstration of Calc, Prev: About This Manual, Up: Getting Started Notations Used in This Manual ============================= This section describes the various notations that are used throughout the Calc manual. In keystroke sequences, uppercase letters mean you must hold down the shift key while typing the letter. Keys pressed with Control held down are shown as `C-x'. Keys pressed with Meta held down are shown as `M-x'. Other notations are RET for the Return key, SPC for the space bar, TAB for the Tab key, DEL for the Delete key, and LFD for the Line-Feed key. (If you don't have the LFD or TAB keys on your keyboard, the `C-j' and `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 ESC or C-[ first to get the same effect, so that `M-x', `ESC x', and `C-[ x' are all equivalent.) Sometimes the RET key is not shown when it is "obvious" that you must press `RET' to proceed. For example, the RET is usually omitted in key sequences like `M-x calc-keypad RET'. Commands are generally shown like this: `p' (`calc-precision') or `M-# k' (`calc-keypad'). This means that the command is normally used by pressing the `p' key or `M-# k' key sequence, but it also has the full-name equivalent shown, e.g., `M-x calc-precision'. Commands that correspond to functions in algebraic notation are written: `C' (`calc-cos') [`cos']. This means the `C' key is equivalent to `M-x calc-cos', and that the corresponding function in an algebraic-style formula would be `cos(X)'. A few commands don't have key equivalents: `calc-sincos' [`sincos']. File: calc.info, Node: Demonstration of Calc, Next: Using Calc, Prev: Notations Used in This Manual, Up: Getting Started A Demonstration of Calc ======================= This section will show some typical small problems being solved with Calc. The focus is more on demonstration than explanation, but everything you see here will be covered more thoroughly in the Tutorial. To begin, start Emacs if necessary (usually the command `emacs' does this), and type `M-# c' (or `ESC # c') to start the Calculator. (*Note Starting Calc::, if this doesn't work for you.) Be sure to type all the sample input exactly, especially noting the difference between lower-case and upper-case letters. Remember, `RET', `TAB', `DEL', and `SPC' are the Return, Tab, Delete, and Space keys. *RPN calculation.* In RPN, you type the input number(s) first, then the command to operate on the numbers. Type `2 RET 3 + Q' to compute the square root of 2+3, which is 2.2360679775. Type `P 2 ^' to compute the value of `pi' squared, 9.86960440109. Type `TAB' to exchange the order of these two results. Type `- I H S' to subtract these results and compute the Inverse Hyperbolic sine of the difference, 2.72996136574. Type `DEL' to erase this result. *Algebraic calculation.* You can also enter calculations using conventional "algebraic" notation. To enter an algebraic formula, use the apostrophe key. Type `' sqrt(2+3) RET' to compute the square root of 2+3. Type `' pi^2 RET' to enter `pi' squared. To evaluate this symbolic formula as a number, type `='. Type `' arcsinh($ - $$) RET' to subtract the second-most-recent result from the most-recent and compute the Inverse Hyperbolic sine. *Keypad mode.* If you are using the X window system, press `M-# k' to get Keypad mode. (If you don't use X, skip to the next section.) Click on the 2, ENTER, 3, +, and SQRT "buttons" using your left mouse button. Click on PI, 2, and y^x. Click on INV, then ENTER to swap the two results. Click on -, INV, HYP, and SIN. Click on <- to erase the result, then click OFF to turn the Keypad Calculator off. *Grabbing data.* Type `M-# x' if necessary to exit Calc. Now select the following numbers as an Emacs region: "Mark" the front of the list by typing control-`SPC' or control-`@' there, then move to the other end of the list. (Either get this list from the on-line copy of this manual, accessed by `M-# i', or just type these numbers into a scratch file.) Now type `M-# g' to "grab" these numbers into Calc. 1.23 1.97 1.6 2 1.19 1.08 The result `[1.23, 1.97, 1.6, 2, 1.19, 1.08]' is a Calc "vector." Type `V R +' to compute the sum of these numbers. Type `U' to Undo this command, then type `V R *' to compute the product of the numbers. You can also grab data as a rectangular matrix. Place the cursor on the upper-leftmost `1' and set the mark, then move to just after the lower-right `8' and press `M-# r'. Type `v t' to transpose this 3x2 matrix into a 2x3 matrix. Type `v u' to unpack the rows into two separate vectors. Now type `V R + TAB V R +' to compute the sums of the two original columns. (There is also a special grab-and-sum-columns command, `M-# :'.) *Units conversion.* Units are entered algebraically. Type `' 43 mi/hr RET' to enter the quantity 43 miles-per-hour. Type `u c km/hr RET'. Type `u c m/s RET'. *Date arithmetic.* Type `t N' to get the current date and time. Type `90 +' to find the date 90 days from now. Type `' <25 dec 87> RET' to enter a date, then `- 7 /' to see how many weeks have passed since then. *Algebra.* Algebraic entries can also include formulas or equations involving variables. Type `' [x + y = a, x y = 1] RET' to enter a pair of equations involving three variables. (Note the leading apostrophe in this example; also, note that the space between `x y' is required.) Type `a S x,y RET' to solve these equations for the variables `x' and Type `d B' to view the solutions in more readable notation. Type `d C' to view them in C language notation, and `d T' to view them in the notation for the TeX typesetting system. Type `d N' to return to normal notation. Type `7.5', then `s l a RET' to let `a = 7.5' in these formulas. (That's a letter `l', not a numeral `1'.) *Help functions.* You can read about any command in the on-line manual. Remember to type the letter `l', then `M-# c', to return here after each of these commands: `h k t N' to read about the `t N' command, `h f sqrt RET' to read about the `sqrt' function, and `h s' to read the Calc summary. Press `DEL' repeatedly to remove any leftover results from the stack. To exit from Calc, press `q' or `M-# c' again. File: calc.info, Node: Using Calc, Next: History and Acknowledgements, Prev: Demonstration of Calc, Up: Getting Started Using Calc ========== 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. Calc must be "installed" before it can be used. *Note Installation::, for instructions on setting up and installing Calc. We will assume you or someone on your system has already installed Calc as described there. * Menu: * Starting Calc:: * The Standard Interface:: * Quick Mode Overview:: * Keypad Mode Overview:: * Standalone Operation:: * Embedded Mode Overview:: * Other M-# Commands:: File: calc.info, Node: Starting Calc, Next: The Standard Interface, Prev: Using Calc, Up: Using Calc Starting Calc ------------- On most systems, you can type `M-#' to start the Calculator. The notation `M-#' is short for Meta-`#'. On most keyboards this means holding down the Meta (or Alt) and Shift keys while typing `3'. Once again, if you don't have a Meta key on your keyboard you can type ESC first, then `#', to accomplish the same thing. If you don't even have an ESC key, you can fake it by holding down Control or CTRL while typing a left square bracket (that's `C-[' in Emacs notation). `M-#' is a "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 `M-#' with a letter (upper- or lower-case, it doesn't matter for `M-#') that says which Calc interface you want to use. To get Calc's standard interface, type `M-# c'. To get Keypad Mode, type `M-# k'. Type `M-# ?' to get a brief list of the available options, and type a second `?' to get a complete list. To ease typing, `M-# M-#' (or `M-# #' if that's easier) also works to start Calc. It starts the same interface (either `M-# c' or `M-# k') that you last used, selecting the `M-# c' interface by default. (If your installation has a special function key set up to act like `M-#', hitting that function key twice is just like hitting `M-# M-#'.) If `M-#' doesn't work for you, you can always type explicit commands like `M-x calc' (for the standard user interface) or `M-x calc-keypad' (for Keypad Mode). First type `M-x' (that's Meta with the letter `x'), then, at the prompt, type the full command (like `calc-keypad') and press Return. If you type `M-x calc' and Emacs still doesn't recognize the command (it will say `[No match]' when you try to press RET), then Calc has not been properly installed. The same commands (like `M-# c' or `M-# M-#') that start the Calculator also turn it off if it is already on. File: calc.info, Node: The Standard Interface, Next: Quick Mode Overview, Prev: Starting Calc, Up: Using Calc The Standard Calc Interface --------------------------- Calc's standard interface acts like a traditional RPN calculator, operated by the normal Emacs keyboard. When you type `M-# c' to start the Calculator, the Emacs screen splits into two windows with the file you were editing on top and Calc on the bottom. ... --**-Emacs: myfile (Fundamental)----All---------------------- --- Emacs Calculator Mode --- |Emacs Calc Mode v2.00... 2: 17.3 | 17.3 1: -5 | 3 . | 2 | 4 | * 8 | ->-5 | --%%-Calc: 12 Deg (Calculator)----All----- --%%-Emacs: *Calc Trail* In this figure, the mode-line for `myfile' has moved up and the "Calculator" window has appeared below it. As you can see, Calc actually makes two windows side-by-side. The lefthand one is called the "stack window" and the righthand one is called the "trail window." The stack holds the numbers involved in the calculation you are currently performing. The trail holds a complete record of all calculations you have done. In a desk calculator with a printer, the trail corresponds to the paper tape that records what 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 -5. (The `>' symbol shows that this was the most recent calculation.) The net result is the two numbers 17.3 and -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 the trail and retrieve any previous result. Calc commands use the digits, letters, and punctuation keys. Shifted (i.e., upper-case) letters are different from lowercase letters. Some letters are "prefix" keys that begin two-letter commands. For example, `e' means "enter exponent" and shifted `E' means `e^x'. With the `d' ("display modes") prefix the letter "e" takes on very different meanings: `d e' means "engineering notation" and `d E' means ""eqn" language mode." There is nothing stopping you from switching out of the Calc window and back into your editing window, say by using the Emacs `C-x o' (`other-window') command. When the cursor is 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 `M-# c' a second time, the Calculator windows go away but the actual Stack and Trail are not gone, just hidden. When you press `M-# 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, `M-# c' will give you a fresh stack and trail. There is a command (`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 `M-# M-#' the same as `M-# c'. The `q' key is another equivalent way to turn the Calculator off. If you type `M-# b' first and then `M-# c', you get a full-screen version of Calc (`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 `q' or `M-# c' again to quit, the file you were editing before reappears. The `M-# b' key switches back and forth between "big" full-screen mode and the normal partial-screen mode. Finally, `M-# o' (`calc-other-window') is like `M-# c' except that the Calc window is not selected. The buffer you were editing before remains selected instead. `M-# o' is a handy way to switch out of Calc momentarily to edit your file; type `M-# c' to switch back into Calc when you are done. File: calc.info, Node: Quick Mode Overview, Next: Keypad Mode Overview, Prev: The Standard Interface, Up: Using Calc Quick Mode (Overview) --------------------- "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 `M-# q' (`quick-calc') in any regular editing buffer. Quick Mode is very simple: It prompts you to type any formula in standard algebraic notation (like `4 - 2/3') and then displays the result at the bottom of the Emacs screen (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 `M-# q' again to do another quick calculation. The result of the calculation will also be in the Emacs "kill ring" so that a `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 `M-# c') to change the mode settings. *Note Quick Calculator::, for further information. File: calc.info, Node: Keypad Mode Overview, Next: Standalone Operation, Prev: Quick Mode Overview, Up: Using Calc Keypad Mode (Overview) ---------------------- "Keypad Mode" is a mouse-based interface to the Calculator. It is designed for use with the X window system. If you don't have X, 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. Type `M-# 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. |--- 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 | + | |-----+-----+-----+-----+-----+ 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. To operate the Calculator, just click on the "buttons" of the keypad using your left mouse button. To enter the two numbers shown here you would click `1 7 . 3 ENTER 5 +/- ENTER'; to add them together you would then click `+' (to get 12.3 on the stack). If you click the right mouse button, the top three rows of the 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 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 explicit command to switch between editing and calculating. If you press `M-# b' first, you get a full-screen Keypad Mode (`full-calc-keypad') with three windows: The keypad in the lower left, the stack in the lower right, and the trail on top. *Note Keypad Mode::, for further information. File: calc.info, Node: Standalone Operation, Next: Embedded Mode Overview, Prev: Keypad Mode Overview, Up: Using Calc Standalone Operation -------------------- If you are not in Emacs at the moment but you wish to use Calc, you must start Emacs first. If all you want is to run Calc, you can give the commands: emacs -f full-calc emacs -f full-calc-keypad which run a full-screen Calculator (as if by `M-# b M-# c') or a full-screen X-based Calculator (as if by `M-# b M-# k'). In standalone operation, quitting the Calculator (by pressing `q' or clicking on the keypad EXIT button) quits Emacs itself. File: calc.info, Node: Embedded Mode Overview, Next: Other M-# Commands, Prev: Standalone Operation, Up: Using Calc Embedded Mode (Overview) ------------------------ "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: The derivative of ln(ln(x)) is and you wish to have Calc compute and format the derivative for you and store this derivative in the buffer automatically. To do this with Embedded Mode, first copy the formula down to where you want the result to be: The derivative of ln(ln(x)) is ln(ln(x)) Now, move the cursor onto this new formula and press `M-# e'. Calc will read the formula (using the surrounding blank lines to tell how much text to read), then push this formula (invisibly) onto the Calc stack. The cursor will stay on the formula in the editing buffer, but the buffer's mode line will change to look like the Calc mode line (with mode indicators like `12 Deg' and so on). Even though you are still in your editing buffer, the keyboard now acts like the Calc keyboard, and any new result you get is copied from the stack back into the buffer. To take the derivative, you would type `a d x RET'. The derivative of ln(ln(x)) is 1 / ln(x) x To make this look nicer, you might want to press `d =' to center the formula, and even `d B' to use "big" display mode. The derivative of ln(ln(x)) is % [calc-mode: justify: center] % [calc-mode: language: big] 1 ------- ln(x) x 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.) As an extra flourish, we can add an equation number using a righthand label: Type `d } (1) RET'. % [calc-mode: justify: center] % [calc-mode: language: big] % [calc-mode: right-label: " (1)"] 1 ------- (1) ln(x) x To leave Embedded Mode, type `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 `M-# 0' [with the digit zero] now to reset the modes you changed.) The related command `M-# w' operates on a single word, which generally means a single number, inside text. It uses any non-numeric characters rather than blank lines to delimit the formula it reads. Here's an example of its use: A slope of one-third corresponds to an angle of 1 degrees. Place the cursor on the `1', then type `M-# w' to enable Embedded Mode on that number. Now type `3 /' (to get one-third), and `I T' (the Inverse Tangent converts a slope into an angle), then `M-# w' again to exit Embedded mode. A slope of one-third corresponds to an angle of 18.4349488229 degrees. *Note Embedded Mode::, for full details. File: calc.info, Node: Other M-# Commands, Prev: Embedded Mode Overview, Up: Using Calc Other `M-#' Commands -------------------- Two more Calc-related commands are `M-# g' and `M-# 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 `M-# 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 `v u' if you want to unpack this vector into separate numbers on the stack. Also, `C-u M-# g' interprets the region as a single number or formula. The `M-# 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 `M-# y', which "yanks" the value at the top of the Calc stack back into an editing buffer. If you type `M-# y' while in such a buffer, the value is yanked at the current position. If you type `M-# 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 `M-#' commands. The shift, control, and meta keys are ignored for the keystroke following `M-#'. Commands for turning Calc on and off: Turn Calc on or off, employing the same user interface as last time. Turn Calc on or off using its standard bottom-of-the-screen interface. If Calc is already turned on but the cursor is not in the Calc window, move the cursor into the window. Same as `C', but don't select the new Calc window. If Calc is already turned on and the cursor is in the Calc window, move it out of that window. Control whether `M-# c' and `M-# k' use the full screen. Use Quick Mode for a single short calculation. Turn Calc Keypad mode on or off. Turn Calc Embedded mode on or off at the current formula. Turn Calc Embedded mode on or off, select the interesting part. Turn Calc Embedded mode on or off at the current word (number). Turn Calc on in a user-defined way, as defined by a `Z I' command. Quit Calc; turn off standard, Keypad, or Embedded mode if on. (This is like `q' or OFF inside of Calc.) Commands for moving data into and out of the Calculator: Grab the region into the Calculator as a vector. Grab the rectangular region into the Calculator as a matrix. Grab the rectangular region and compute the sums of its columns. Grab the rectangular region and compute the sums of its rows. Yank a value from the Calculator into the current editing buffer. Commands for use with Embedded Mode: "Activate" the current buffer. Locate all formulas that contain `:=' or `=>' symbols and record their locations so that they can be updated automatically as variables are changed. Duplicate the current formula immediately below and select the duplicate. Insert a new formula at the current point. Move the cursor to the next active formula in the buffer. Move the cursor to the previous active formula in the buffer. Update (i.e., as if by the `=' key) the formula at the current point. Edit (as if by `calc-edit') the formula at the current point. Miscellaneous commands: Run the Emacs Info system to read the Calc manual. (This is the same as `h i' inside of Calc.) Run the Emacs Info system to read the Calc Tutorial. Run the Emacs Info system to read the Calc Summary. Load Calc entirely into memory. (Normally the various parts are loaded only as they are needed.) Read a region of written keystroke names (like `C-n a b c RET') and record them as the current keyboard macro. (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.