Gnus -- Minor tweak define #'time-to-seconds
[packages] / xemacs-packages / calc / calc.texinfo
1 \input texinfo                  @c -*-texinfo-*-
2 @comment %**start of header (This is for running Texinfo on a region.)
3 @c smallbook
4 @setfilename calc.info
5 @c [title]
6 @settitle GNU Emacs Calc 2.1 Manual
7 @comment %**end of header (This is for running Texinfo on a region.)
8 @setchapternewpage odd
9
10 @ignore
11
12 @tex
13 % Some special kludges to make TeX formatting prettier.
14 % Because makeinfo.c exists, we can't just define new commands.
15 % So instead, we take over little-used existing commands.
16 %
17 % Redefine @cite{text} to act like $text$ in regular TeX.
18 % Info will typeset this same as @samp{text}.
19 \gdef\goodtex{\tex \let\rm\goodrm \let\t\ttfont \turnoffactive}
20 \gdef\goodrm{\fam0\tenrm}
21 \gdef\cite{\goodtex$\citexxx}
22 \gdef\citexxx#1{#1$\Etex}
23 \global\let\oldxrefX=\xrefX
24 \gdef\xrefX[#1]{\begingroup\let\cite=\dfn\oldxrefX[#1]\endgroup}
25 %
26 % Redefine @i{text} to be equivalent to @cite{text}, i.e., to use math mode.
27 % This looks the same in TeX but omits the surrounding ` ' in Info.
28 \global\let\i=\cite
29 %
30 % Redefine @c{tex-stuff} \n @whatever{info-stuff}.
31 \gdef\c{\futurelet\next\mycxxx}
32 \gdef\mycxxx{%
33   \ifx\next\bgroup \goodtex\let\next\mycxxy
34   \else\ifx\next\mindex \let\next\relax
35   \else\ifx\next\kindex \let\next\relax
36   \else\ifx\next\starindex \let\next\relax \else \let\next\comment
37   \fi\fi\fi\fi \next
38 }
39 \gdef\mycxxy#1#2{#1\Etex\mycxxz}
40 \gdef\mycxxz#1{}
41 @end tex
42
43 @c Fix some things to make math mode work properly.
44 @iftex
45 @textfont0=@tenrm
46 @font@teni=cmmi10 scaled @magstephalf   @textfont1=@teni
47 @font@seveni=cmmi7 scaled @magstephalf  @scriptfont1=@seveni
48 @font@fivei=cmmi5 scaled @magstephalf   @scriptscriptfont1=@fivei
49 @font@tensy=cmsy10 scaled @magstephalf  @textfont2=@tensy
50 @font@sevensy=cmsy7 scaled @magstephalf @scriptfont2=@sevensy
51 @font@fivesy=cmsy5 scaled @magstephalf  @scriptscriptfont2=@fivesy
52 @font@tenex=cmex10 scaled @magstephalf  @textfont3=@tenex
53 @scriptfont3=@tenex  @scriptscriptfont3=@tenex
54 @textfont7=@tentt  @scriptfont7=@tentt  @scriptscriptfont7=@tentt
55 @end iftex
56
57 @c Fix some other things specifically for this manual.
58 @iftex
59 @finalout
60 @mathcode`@:=`@:  @c Make Calc fractions come out right in math mode
61 @tocindent=.5pc   @c Indent subsections in table of contents less
62 @rightskip=0pt plus 2pt  @c Favor short lines rather than overfull hboxes
63 @tex
64 \gdef\coloneq{\mathrel{\mathord:\mathord=}}
65 \ifdim\parskip>17pt
66   \global\parskip=12pt   % Standard parskip looks a bit too large
67 \fi
68 \gdef\internalBitem{\parskip=7pt\kyhpos=\tableindent\kyvpos=0pt
69 \smallbreak\parsearg\itemzzy}
70 \gdef\itemzzy#1{\itemzzz{#1}\relax\ifvmode\kern-7pt\fi}
71 \gdef\trademark{${}^{\rm TM}$}
72 \gdef\group{%
73   \par\vskip8pt\begingroup
74   \def\Egroup{\egroup\endgroup}%
75   \let\aboveenvbreak=\relax  % so that nothing gets between vtop and first box
76   \def\singlespace{\baselineskip=\singlespaceskip}%
77   \vtop\bgroup
78 }
79 %
80 %\global\abovedisplayskip=0pt
81 %\global\abovedisplayshortskip=-10pt
82 %\global\belowdisplayskip=7pt
83 %\global\belowdisplayshortskip=2pt
84 \gdef\beforedisplay{\vskip-10pt}
85 \gdef\afterdisplay{\vskip-5pt}
86 \gdef\beforedisplayh{\vskip-25pt}
87 \gdef\afterdisplayh{\vskip-10pt}
88 %
89 \gdef\printindex{\parsearg\calcprintindex}
90 \gdef\calcprintindex#1{%
91   \doprintindex{#1}%
92   \openin1 \jobname.#1s
93   \ifeof1{\let\s=\indexskip \csname indexsize#1\endcsname}\fi
94   \closein1
95 }
96 \gdef\indexskip{(This page intentionally left blank)\vfill\eject}
97 \gdef\indexsizeky{\s\s\s\s\s\s\s\s}
98 \gdef\indexsizepg{\s\s\s\s\s\s}
99 \gdef\indexsizetp{\s\s\s\s\s\s}
100 \gdef\indexsizecp{\s\s\s\s}
101 \gdef\indexsizevr{}
102 \gdef\indexsizefn{\s\s}
103 \gdef\langle#1\rangle{\it XXX}   % Avoid length mismatch with true expansion
104 %
105 % Ensure no indentation at beginning of sections, and avoid club paragraphs.
106 \global\let\calcchapternofonts=\chapternofonts
107 \gdef\chapternofonts{\aftergroup\calcfixclub\calcchapternofonts}
108 \gdef\calcfixclub{\calcclubpenalty=10000\noindent}
109 \global\let\calcdobreak=\dobreak
110 \gdef\dobreak{{\penalty-9999\dimen0=\pagetotal\advance\dimen0by1.5in
111 \ifdim\dimen0>\pagegoal\vfill\eject\fi}\calcdobreak}
112 %
113 \gdef\kindex{\def\indexname{ky}\futurelet\next\calcindexer}
114 \gdef\tindex{\def\indexname{tp}\futurelet\next\calcindexer}
115 \gdef\mindex{\let\indexname\relax\futurelet\next\calcindexer}
116 \gdef\calcindexer{\catcode`\ =\active\parsearg\calcindexerxx}
117 \gdef\calcindexerxx#1{%
118   \catcode`\ =10%
119   \ifvmode \indent \fi \setbox0=\lastbox \advance\kyhpos\wd0 \fixoddpages \box0
120   \setbox0=\hbox{\ninett #1}%
121   \calcindexersh{\llap{\hbox to 4em{\bumpoddpages\lower\kyvpos\box0\hss}\hskip\kyhpos}}%
122   \global\let\calcindexersh=\calcindexershow
123   \advance\clubpenalty by 5000%
124   \ifx\indexname\relax \else
125     \singlecodeindexer{#1\indexstar}%
126     \global\def\indexstar{}%
127   \fi
128   \futurelet\next\calcindexerxxx
129 }
130 \gdef\indexstar{}
131 \gdef\bumpoddpages{\ifodd\calcpageno\hskip7.3in\fi}
132 %\gdef\bumpoddpages{\hskip7.3in}   % for marginal notes on right side always
133 %\gdef\bumpoddpages{}              % for marginal notes on left side always
134 \gdef\fixoddpages{%
135 \global\calcpageno=\pageno
136 {\dimen0=\pagetotal
137 \advance\dimen0 by2\baselineskip
138 \ifdim\dimen0>\pagegoal
139 \global\advance\calcpageno by 1
140 \vfill\eject\noindent
141 \fi}%
142 }
143 \gdef\calcindexershow#1{\smash{#1}\advance\kyvpos by 11pt}
144 \gdef\calcindexernoshow#1{}
145 \global\let\calcindexersh=\calcindexershow
146 \gdef\calcindexerxxx{%
147   \ifx\indexname\relax
148     \ifx\next\kindex \global\let\calcindexersh=\calcindexernoshow \fi
149     \ifx\next\tindex \global\let\calcindexersh=\calcindexernoshow \fi
150   \fi
151   \calcindexerxxxx
152 }
153 \gdef\calcindexerxxxx#1{\next}
154 \gdef\indexstarxx{\thinspace{\rm *}}
155 \gdef\starindex{\global\let\indexstar=\indexstarxx}
156 \gdef\calceverypar{%
157 \kyhpos=\leftskip\kyvpos=0pt\clubpenalty=\calcclubpenalty
158 \calcclubpenalty=1000\relax
159 }
160 \gdef\idots{{\indrm...}}
161 @end tex
162 @newdimen@kyvpos @kyvpos=0pt
163 @newdimen@kyhpos @kyhpos=0pt
164 @newcount@calcclubpenalty @calcclubpenalty=1000
165 @newcount@calcpageno
166 @newtoks@calcoldeverypar @calcoldeverypar=@everypar
167 @everypar={@calceverypar@the@calcoldeverypar}
168 @ifx@turnoffactive@undefinedzzz@def@turnoffactive{}@fi
169 @ifx@ninett@undefinedzzz@font@ninett=cmtt9@fi
170 @catcode`@\=0 \catcode`\@=11
171 \r@ggedbottomtrue
172 \catcode`\@=0 @catcode`@\=@active
173 @end iftex
174
175 @end ignore
176
177 @ifinfo
178 @direntry
179 * Calc: (calc).               Scientific, financial, and symbolic calculator
180                               for Emacs
181 @end direntry
182
183 This file documents Calc, the GNU Emacs calculator.
184
185 Copyright (C) 1990, 1991 Free Software Foundation, Inc.
186
187 Permission is granted to make and distribute verbatim copies of this
188 manual provided the copyright notice and this permission notice are
189 preserved on all copies.
190
191 @ignore
192 Permission is granted to process this file through TeX and print the
193 results, provided the printed document carries copying permission notice
194 identical to this one except for the removal of this paragraph (this
195 paragraph not being relevant to the printed manual).
196
197 @end ignore
198 Permission is granted to copy and distribute modified versions of this
199 manual under the conditions for verbatim copying, provided also that the
200 section entitled ``GNU General Public License'' is included exactly as
201 in the original, and provided that the entire resulting derived work is
202 distributed under the terms of a permission notice identical to this one.
203
204 Permission is granted to copy and distribute translations of this manual
205 into another language, under the above conditions for modified versions,
206 except that the section entitled ``GNU General Public License'' may be
207 included in a translation approved by the author instead of in the
208 original English.
209 @end ifinfo
210
211 @titlepage
212 @sp 6
213 @center @titlefont{Calc Manual}
214 @sp 4
215 @center GNU Emacs Calc Version 2.1
216 @c [volume]
217 @sp 1
218 @center January 1992
219 @sp 5
220 @center Dave Gillespie
221 @page
222
223 @vskip 0pt plus 1filll
224 Copyright @copyright{} 1990, 1991 Free Software Foundation, Inc.
225
226 Permission is granted to make and distribute verbatim copies of
227 this manual provided the copyright notice and this permission notice
228 are preserved on all copies.
229
230 @ignore
231 Permission is granted to process this file through TeX and print the
232 results, provided the printed document carries copying permission notice
233 identical to this one except for the removal of this paragraph (this
234 paragraph not being relevant to the printed manual).
235
236 @end ignore
237 Permission is granted to copy and distribute modified versions of this
238 manual under the conditions for verbatim copying, provided also that the
239 section entitled ``GNU General Public License'' is included exactly as
240 in the original, and provided that the entire resulting derived work is
241 distributed under the terms of a permission notice identical to this one.
242
243 Permission is granted to copy and distribute translations of this manual
244 into another language, under the above conditions for modified versions,
245 except that the section entitled ``GNU General Public License'' may be
246 included in a translation approved by the author instead of in the
247 original English.
248 @end titlepage
249
250 @c [begin]
251 @ifnottex
252 @node Top, Copying,, (dir)
253 @chapter The GNU Emacs Calculator
254
255 @noindent
256 @dfn{Calc} is an advanced desk calculator and mathematical tool
257 that runs as part of the GNU Emacs environment.
258
259 This manual is divided into three major parts: "Getting Started," the
260 "Calc Tutorial," and the "Calc Reference."  The Tutorial introduces all
261 the major aspects of Calculator use in an easy, hands-on way.  The
262 remainder of the manual is a complete reference to the features of the
263 Calculator.
264
265 For help in the Emacs Info system (which you are using to read this
266 file), type @kbd{?}.  (You can also type @kbd{h} to run through a
267 longer Info tutorial.)
268
269 @end ifnottex
270 @menu
271 * Copying::               How you can copy and share Calc.
272
273 * Getting Started::       General description and overview.
274 @ifinfo
275 * Interactive Tutorial::  Same as tutorial.
276 @end ifinfo
277 * Tutorial::              A step-by-step introduction for beginners.
278
279 * Introduction::          Introduction to the Calc reference manual.
280 * Data Types::            Types of objects manipulated by Calc.
281 * Stack and Trail::       Manipulating the stack and trail buffers.
282 * Mode Settings::         Adjusting display format and other modes.
283 * Arithmetic::            Basic arithmetic functions.
284 * Scientific Functions::  Transcendentals and other scientific functions.
285 * Matrix Functions::      Operations on vectors and matrices.
286 * Algebra::               Manipulating expressions algebraically.
287 * Units::                 Operations on numbers with units.
288 * Store and Recall::      Storing and recalling variables.
289 * Graphics::              Commands for making graphs of data.
290 * Kill and Yank::         Moving data into and out of Calc.
291 * Embedded Mode::         Working with formulas embedded in a file.
292 * Programming::           Calc as a programmable calculator.
293
294 * Summary::               Summary of Calc commands and functions.
295
296 * Key Index::             The standard Calc key sequences.
297 * Command Index::         The interactive Calc commands.
298 * Function Index::        Functions (in algebraic formulas).
299 * Concept Index::         General concepts.
300 * Variable Index::        Variables used by Calc (both user and internal).
301 * Lisp Function Index::   Internal Lisp math functions.
302 @end menu
303
304 @node Copying, Getting Started, Top, Top
305 @unnumbered GNU GENERAL PUBLIC LICENSE
306 @include gpl.texi
307
308 @node Getting Started, Tutorial, Copying, Top
309 @chapter Getting Started
310
311 @noindent
312 This chapter provides a general overview of Calc, the GNU Emacs
313 Calculator:  What it is, how to start it and how to exit from it,
314 and what are the various ways that it can be used.
315
316 @menu
317 * What is Calc::
318 * About This Manual::
319 * Notations Used in This Manual::
320 * Using Calc::
321 * Demonstration of Calc::
322 * History and Acknowledgements::
323 @end menu
324
325 @node What is Calc, About This Manual, Getting Started, Getting Started
326 @section What is Calc?
327
328 @noindent
329 @dfn{Calc} is an advanced calculator and mathematical tool that runs as
330 part of the GNU Emacs environment.  Very roughly based on the HP-28/48
331 series of calculators, its many features include:
332
333 @itemize @bullet
334 @item
335 Choice of algebraic or RPN (stack-based) entry of calculations.
336
337 @item
338 Arbitrary precision integers and floating-point numbers.
339
340 @item
341 Arithmetic on rational numbers, complex numbers (rectangular and polar),
342 error forms with standard deviations, open and closed intervals, vectors
343 and matrices, dates and times, infinities, sets, quantities with units,
344 and algebraic formulas.
345
346 @item
347 Mathematical operations such as logarithms and trigonometric functions.
348
349 @item
350 Programmer's features (bitwise operations, non-decimal numbers).
351
352 @item
353 Financial functions such as future value and internal rate of return.
354
355 @item
356 Number theoretical features such as prime factorization and arithmetic
357 modulo @i{M} for any @i{M}.
358
359 @item
360 Algebraic manipulation features, including symbolic calculus.
361
362 @item
363 Moving data to and from regular editing buffers.
364
365 @item
366 ``Embedded mode'' for manipulating Calc formulas and data directly
367 inside any editing buffer.
368
369 @item
370 Graphics using GNUPLOT, a versatile (and free) plotting program.
371
372 @item
373 Easy programming using keyboard macros, algebraic formulas,
374 algebraic rewrite rules, or extended Emacs Lisp.
375 @end itemize
376
377 Calc tries to include a little something for everyone; as a result it is
378 large and might be intimidating to the first-time user.  If you plan to
379 use Calc only as a traditional desk calculator, all you really need to
380 read is the ``Getting Started'' chapter of this manual and possibly the
381 first few sections of the tutorial.  As you become more comfortable with
382 the program you can learn its additional features.  In terms of efficiency,
383 scope and depth, Calc cannot replace a powerful tool like Mathematica.
384 @c Removed this per RMS' request:
385 @c Mathematica@c{\trademark} @asis{ (tm)}.
386 But Calc has the advantages of convenience, portability, and availability
387 of the source code.  And, of course, it's free!
388
389 @node About This Manual, Notations Used in This Manual, What is Calc, Getting Started
390 @section About This Manual
391
392 @noindent
393 This document serves as a complete description of the GNU Emacs
394 Calculator.  It works both as an introduction for novices, and as
395 a reference for experienced users.  While it helps to have some
396 experience with GNU Emacs in order to get the most out of Calc,
397 this manual ought to be readable even if you don't know or use Emacs
398 regularly.
399
400 The manual is divided into three major parts:@: the ``Getting
401 Started'' chapter you are reading now, the Calc tutorial
402 and the Calc reference manual (the remaining chapters and appendices).
403
404 If you are in a hurry to use Calc, there is a brief ``demonstration''
405 below which illustrates the major features of Calc in just a couple of
406 pages.  If you don't have time to go through the full tutorial, this
407 will show you everything you need to know to begin.
408 @xref{Demonstration of Calc}.
409
410 The tutorial chapter walks you through the various parts of Calc
411 with lots of hands-on examples and explanations.  If you are new
412 to Calc and you have some time, try going through at least the
413 beginning of the tutorial.  The tutorial includes about 70 exercises
414 with answers.  These exercises give you some guided practice with
415 Calc, as well as pointing out some interesting and unusual ways
416 to use its features.
417
418 The reference section discusses Calc in complete depth.  You can read
419 the reference from start to finish if you want to learn every aspect
420 of Calc.  Or, you can look in the table of contents or the Concept
421 Index to find the parts of the manual that discuss the things you
422 need to know.
423
424 @c [fix-ref Help Commands]
425 You can access this manual on-line at any time within Calc by
426 pressing the @kbd{h i} key sequence.  Outside of the Calc window,
427 you can press @kbd{M-# i} to read the manual on-line.  Also, you
428 can jump directly to the Tutorial by pressing @kbd{h t} or @kbd{M-# t},
429 or to the Summary by pressing @kbd{h s} or @kbd{M-# s}.  Within Calc,
430 you can also go to the part of the manual describing any Calc key,
431 function, or variable using @w{@kbd{h k}}, @kbd{h f}, or @kbd{h v},
432 respectively.  @xref{Help Commands}.
433
434 @c Printed copies of this manual are also available from the Free Software
435 @c Foundation.
436
437 @node Notations Used in This Manual, Demonstration of Calc, About This Manual, Getting Started
438 @section Notations Used in This Manual
439
440 @noindent
441 This section describes the various notations that are used
442 throughout the Calc manual.
443
444 In keystroke sequences, uppercase letters mean you must hold down
445 the shift key while typing the letter.  Keys pressed with Control
446 held down are shown as @kbd{C-x}.  Keys pressed with Meta held down
447 are shown as @kbd{M-x}.  Other notations are @key{RET} for the
448 Return key, @key{SPC} for the space bar, @key{TAB} for the Tab key,
449 @key{DEL} for the Delete key, and @key{LFD} for the Line-Feed key.
450
451 (If you don't have the @key{LFD} or @key{TAB} keys on your keyboard,
452 the @kbd{C-j} and @kbd{C-i} keys are equivalent to them, respectively.
453 If you don't have a Meta key, look for Alt or Extend Char.  You can
454 also press @key{ESC} or @key{C-[} first to get the same effect, so
455 that @kbd{M-x}, @kbd{ESC x}, and @kbd{C-[ x} are all equivalent.)
456
457 Sometimes the @key{RET} key is not shown when it is ``obvious''
458 that you must press @kbd{RET} to proceed.  For example, the @key{RET}
459 is usually omitted in key sequences like @kbd{M-x calc-keypad @key{RET}}.
460
461 Commands are generally shown like this:  @kbd{p} (@code{calc-precision})
462 or @kbd{M-# k} (@code{calc-keypad}).  This means that the command is
463 normally used by pressing the @kbd{p} key or @kbd{M-# k} key sequence,
464 but it also has the full-name equivalent shown, e.g., @kbd{M-x calc-precision}.
465
466 Commands that correspond to functions in algebraic notation
467 are written:  @kbd{C} (@code{calc-cos}) [@code{cos}].  This means
468 the @kbd{C} key is equivalent to @kbd{M-x calc-cos}, and that
469 the corresponding function in an algebraic-style formula would
470 be @samp{cos(@var{x})}.
471
472 A few commands don't have key equivalents:  @code{calc-sincos}
473 [@code{sincos}].@refill
474
475 @node Demonstration of Calc, Using Calc, Notations Used in This Manual, Getting Started
476 @section A Demonstration of Calc
477
478 @noindent
479 @cindex Demonstration of Calc
480 This section will show some typical small problems being solved with
481 Calc.  The focus is more on demonstration than explanation, but
482 everything you see here will be covered more thoroughly in the
483 Tutorial.
484
485 To begin, start Emacs if necessary (usually the command @code{emacs}
486 does this), and type @kbd{M-# c} (or @kbd{ESC # c}) to start the
487 Calculator.  (@xref{Starting Calc}, if this doesn't work for you.)
488
489 Be sure to type all the sample input exactly, especially noting the
490 difference between lower-case and upper-case letters.  Remember,
491 @kbd{RET}, @kbd{TAB}, @kbd{DEL}, and @kbd{SPC} are the Return, Tab,
492 Delete, and Space keys.
493
494 @strong{RPN calculation.}  In RPN, you type the input number(s) first,
495 then the command to operate on the numbers.
496
497 @noindent
498 Type @kbd{2 RET 3 + Q} to compute @c{$\sqrt{2+3} = 2.2360679775$}
499 @asis{the square root of 2+3, which is 2.2360679775}.
500
501 @noindent
502 Type @kbd{P 2 ^} to compute @c{$\pi^2 = 9.86960440109$}
503 @asis{the value of `pi' squared, 9.86960440109}.
504
505 @noindent
506 Type @kbd{TAB} to exchange the order of these two results.
507
508 @noindent
509 Type @kbd{- I H S} to subtract these results and compute the Inverse
510 Hyperbolic sine of the difference, 2.72996136574.
511
512 @noindent
513 Type @kbd{DEL} to erase this result.
514
515 @strong{Algebraic calculation.}  You can also enter calculations using
516 conventional ``algebraic'' notation.  To enter an algebraic formula,
517 use the apostrophe key.
518
519 @noindent
520 Type @kbd{' sqrt(2+3) RET} to compute @c{$\sqrt{2+3}$}
521 @asis{the square root of 2+3}.
522
523 @noindent
524 Type @kbd{' pi^2 RET} to enter @c{$\pi^2$}
525 @asis{`pi' squared}.  To evaluate this symbolic
526 formula as a number, type @kbd{=}.
527
528 @noindent
529 Type @kbd{' arcsinh($ - $$) RET} to subtract the second-most-recent
530 result from the most-recent and compute the Inverse Hyperbolic sine.
531
532 @strong{Keypad mode.}  If you are using the X window system, press
533 @w{@kbd{M-# k}} to get Keypad mode.  (If you don't use X, skip to
534 the next section.)
535
536 @noindent
537 Click on the @key{2}, @key{ENTER}, @key{3}, @key{+}, and @key{SQRT}
538 ``buttons'' using your left mouse button.
539
540 @noindent
541 Click on @key{PI}, @key{2}, and @t{y^x}.
542
543 @noindent
544 Click on @key{INV}, then @key{ENTER} to swap the two results.
545
546 @noindent
547 Click on @key{-}, @key{INV}, @key{HYP}, and @key{SIN}.
548
549 @noindent
550 Click on @key{<-} to erase the result, then click @key{OFF} to turn
551 the Keypad Calculator off.
552
553 @strong{Grabbing data.}  Type @kbd{M-# x} if necessary to exit Calc.
554 Now select the following numbers as an Emacs region:  ``Mark'' the
555 front of the list by typing control-@kbd{SPC} there,
556 then move to the other end of the list.  (Either get this list from
557 the on-line copy of this manual, accessed by @w{@kbd{M-# i}}, or just
558 type these numbers into a scratch file.)  Now type @kbd{M-# g} to
559 ``grab'' these numbers into Calc.
560
561 @example
562 @group
563 1.23  1.97
564 1.6   2
565 1.19  1.08
566 @end group
567 @end example
568
569 @noindent
570 The result @samp{[1.23, 1.97, 1.6, 2, 1.19, 1.08]} is a Calc ``vector.''
571 Type @w{@kbd{V R +}} to compute the sum of these numbers.
572
573 @noindent
574 Type @kbd{U} to Undo this command, then type @kbd{V R *} to compute
575 the product of the numbers.
576
577 @noindent
578 You can also grab data as a rectangular matrix.  Place the cursor on
579 the upper-leftmost @samp{1} and set the mark, then move to just after
580 the lower-right @samp{8} and press @kbd{M-# r}.
581
582 @noindent
583 Type @kbd{v t} to transpose this @c{$3\times2$}
584 @asis{3x2} matrix into a @c{$2\times3$}
585 @asis{2x3} matrix.  Type
586 @w{@kbd{v u}} to unpack the rows into two separate vectors.  Now type
587 @w{@kbd{V R + TAB V R +}} to compute the sums of the two original columns.
588 (There is also a special grab-and-sum-columns command, @kbd{M-# :}.)
589
590 @strong{Units conversion.}  Units are entered algebraically.
591 Type @w{@kbd{' 43 mi/hr RET}} to enter the quantity 43 miles-per-hour.
592 Type @w{@kbd{u c km/hr RET}}.  Type @w{@kbd{u c m/s RET}}.
593
594 @strong{Date arithmetic.}  Type @kbd{t N} to get the current date and
595 time.  Type @kbd{90 +} to find the date 90 days from now.  Type
596 @kbd{' <25 dec 87> RET} to enter a date, then @kbd{- 7 /} to see how
597 many weeks have passed since then.
598
599 @strong{Algebra.}  Algebraic entries can also include formulas
600 or equations involving variables.  Type @kbd{' [x + y = a, x y = 1] RET}
601 to enter a pair of equations involving three variables.
602 (Note the leading apostrophe in this example; also, note that the space
603 between @samp{x y} is required.)  Type @w{@kbd{a S x,y RET}} to solve
604 these equations for the variables @cite{x} and @cite{y}.@refill
605
606 @noindent
607 Type @kbd{d B} to view the solutions in more readable notation.
608 Type @w{@kbd{d C}} to view them in C language notation, @kbd{d T}
609 to view them in the notation for the @TeX{} typesetting system, and
610 @kbd{d L} to view them in @LaTeX{} notation.
611 Type @kbd{d N} to return to the normal Calc notation.
612
613 @noindent
614 Type @kbd{7.5}, then @kbd{s l a RET} to let @cite{a = 7.5} in these formulas.
615 (That's a letter @kbd{l}, not a numeral @kbd{1}.)
616
617 @iftex
618 @strong{Help functions.}  You can read about any command in the on-line
619 manual.  Type @kbd{M-# c} to return to Calc after each of these
620 commands: @kbd{h k t N} to read about the @kbd{t N} command,
621 @kbd{h f sqrt RET} to read about the @code{sqrt} function, and
622 @kbd{h s} to read the Calc summary.
623 @end iftex
624 @ifnottex
625 @strong{Help functions.}  You can read about any command in the on-line
626 manual.  Remember to type the letter @kbd{l} (once or twice), then @kbd{M-# c}, to
627 return here after each of these commands: @w{@kbd{h k t N}} to read
628 about the @w{@kbd{t N}} command, @kbd{h f sqrt RET} to read about the
629 @code{sqrt} function, and @kbd{h s} to read the Calc summary.
630 @end ifnottex
631
632 Press @kbd{DEL} repeatedly to remove any leftover results from the stack.
633 To exit from Calc, press @kbd{q} or @kbd{M-# c} again.
634
635 @node Using Calc, History and Acknowledgements, Demonstration of Calc, Getting Started
636 @section Using Calc
637
638 @noindent
639 Calc has several user interfaces that are specialized for
640 different kinds of tasks.  As well as Calc's standard interface,
641 there are Quick Mode, Keypad Mode, and Embedded Mode.
642
643 @menu
644 * Starting Calc::
645 * The Standard Interface::
646 * Quick Mode Overview::
647 * Keypad Mode Overview::
648 * Standalone Operation::
649 * Embedded Mode Overview::
650 * Other M-# Commands::
651 @end menu
652
653 @node Starting Calc, The Standard Interface, Using Calc, Using Calc
654 @subsection Starting Calc
655
656 @noindent
657 On most systems, you can type @kbd{M-#} to start the Calculator.
658 The notation @kbd{M-#} is short for Meta-@kbd{#}.  On most
659 keyboards this means holding down the Meta (or Alt) and
660 Shift keys while typing @kbd{3}.
661
662 @cindex META key
663 Once again, if you don't have a Meta key on your keyboard you can type
664 @key{ESC} first, then @kbd{#}, to accomplish the same thing.  If you
665 don't even have an @key{ESC} key, you can fake it by holding down
666 Control or @key{CTRL} while typing a left square bracket
667 (that's @kbd{C-[} in Emacs notation).@refill
668
669 @kbd{M-#} is a @dfn{prefix key}; when you press it, Emacs waits for
670 you to press a second key to complete the command.  In this case,
671 you will follow @kbd{M-#} with a letter (upper- or lower-case, it
672 doesn't matter for @kbd{M-#}) that says which Calc interface you
673 want to use.
674
675 You can change the prefix key used for starting Calc by putting
676 @example
677 (global-set-key "PREFIXKEY" 'calc-dispatch)
678 @end example
679 in your .emacs file.  This manual will assume that you are using
680 the default prefix @kbd{M-#}; if you change the prefix, use your
681 new prefix whenever you see @kbd{M-#}.
682
683 To get Calc's standard interface, type @kbd{M-# c}.  To get
684 Keypad Mode, type @kbd{M-# k}.  Type @kbd{M-# ?} to get a brief
685 list of the available options, and type a second @kbd{?} to get
686 a complete list.
687
688 To ease typing, @kbd{M-# M-#} (or @kbd{M-# #} if that's easier)
689 also works to start Calc.  (You can also type your prefix key
690 followed by one of @kbd{=}, @kbd{&}, @kbd{\}, @kbd{/}, @kbd{+},
691 @kbd{-} or @kbd{*}, to make it more convenient if you have changed
692 the prefix.)
693
694 It starts the same interface (either
695 @kbd{M-# c} or @w{@kbd{M-# k}}) that you last used, selecting the
696 @kbd{M-# c} interface by default.  (If your installation has
697 a special function key set up to act like @kbd{M-#}, hitting that
698 function key twice is just like hitting @kbd{M-# M-#}.)
699
700 By default, @kbd{M-#} is bound to the command @code{calc-dispatch}.
701 If you decide to bind another key or key-sequence to 
702 @code{calc-dispatch}, then typing that key followed by your choice
703 of @kbd{#}, @kbd{&}, @kbd{\}, @kbd{=}, @kbd{*}, 
704 @kbd{/}, @kbd{+} or @kbd{-} will act like @kbd{M-# M-#}.
705
706 If @kbd{M-#} doesn't work for you, you can always type explicit
707 commands like @kbd{M-x calc} (for the standard user interface) or
708 @w{@kbd{M-x calc-keypad}} (for Keypad Mode).  First type @kbd{M-x}
709 (that's Meta with the letter @kbd{x}), then, at the prompt,
710 type the full command (like @kbd{calc-keypad}) and press Return.
711
712 If you type @kbd{M-x calc} and Emacs still doesn't recognize the
713 command (it will say @samp{[No match]} when you try to press
714 @key{RET}), then Calc has not been properly installed.
715
716 The same commands (like @kbd{M-# c} or @kbd{M-# M-#}) that start
717 the Calculator also turn it off if it is already on.
718
719 @node The Standard Interface, Quick Mode Overview, Starting Calc, Using Calc
720 @subsection The Standard Calc Interface
721
722 @noindent
723 @cindex Standard user interface
724 Calc's standard interface acts like a traditional RPN calculator,
725 operated by the normal Emacs keyboard.  When you type @kbd{M-# c}
726 to start the Calculator, the Emacs screen splits into two windows
727 with the file you were editing on top and Calc on the bottom.
728
729 @iftex
730 @advance@hsize20pt
731 @end iftex
732 @smallexample
733 @group
734
735 ...
736 --**-Emacs: myfile             (Fundamental)----All----------------------
737 --- Emacs Calculator Mode ---                   |Emacs Calculator Trail
738 2:  17.3                                        |    17.3
739 1:  -5                                          |    3
740     .                                           |    2
741                                                 |    4
742                                                 |  * 8
743                                                 |  ->-5
744                                                 |
745 --%%-Calc: 12 Deg       (Calculator)----All----- --%%-Emacs: *Calc Trail*
746 @end group
747 @end smallexample
748
749 In this figure, the mode-line for @file{myfile} has moved up and the
750 ``Calculator'' window has appeared below it.  As you can see, Calc
751 actually makes two windows side-by-side.  The lefthand one is
752 called the @dfn{stack window} and the righthand one is called the
753 @dfn{trail window.}  The stack holds the numbers involved in the
754 calculation you are currently performing.  The trail holds a complete
755 record of all calculations you have done.  In a desk calculator with
756 a printer, the trail corresponds to the paper tape that records what
757 you do.
758
759 In this case, the trail shows that four numbers (17.3, 3, 2, and 4)
760 were first entered into the Calculator, then the 2 and 4 were
761 multiplied to get 8, then the 3 and 8 were subtracted to get @i{-5}.
762 (The @samp{>} symbol shows that this was the most recent calculation.)
763 The net result is the two numbers 17.3 and @i{-5} sitting on the stack.
764
765 Most Calculator commands deal explicitly with the stack only, but
766 there is a set of commands that allow you to search back through
767 the trail and retrieve any previous result.
768
769 Calc commands use the digits, letters, and punctuation keys.
770 Shifted (i.e., upper-case) letters are different from lowercase
771 letters.  Some letters are @dfn{prefix} keys that begin two-letter
772 commands.  For example, @kbd{e} means ``enter exponent'' and shifted
773 @kbd{E} means @cite{e^x}.  With the @kbd{d} (``display modes'') prefix
774 the letter ``e'' takes on very different meanings:  @kbd{d e} means
775 ``engineering notation'' and @kbd{d E} means ``@dfn{eqn} language mode.''
776
777 There is nothing stopping you from switching out of the Calc
778 window and back into your editing window, say by using the Emacs
779 @w{@kbd{C-x o}} (@code{other-window}) command.  When the cursor is
780 inside a regular window, Emacs acts just like normal.  When the
781 cursor is in the Calc stack or trail windows, keys are interpreted
782 as Calc commands.
783
784 When you quit by pressing @kbd{M-# c} a second time, the Calculator
785 windows go away but the actual Stack and Trail are not gone, just
786 hidden.  When you press @kbd{M-# c} once again you will get the
787 same stack and trail contents you had when you last used the
788 Calculator.
789
790 The Calculator does not remember its state between Emacs sessions.
791 Thus if you quit Emacs and start it again, @kbd{M-# c} will give you
792 a fresh stack and trail.  There is a command (@kbd{m m}) that lets
793 you save your favorite mode settings between sessions, though.
794 One of the things it saves is which user interface (standard or
795 Keypad) you last used; otherwise, a freshly started Emacs will
796 always treat @kbd{M-# M-#} the same as @kbd{M-# c}.
797
798 The @kbd{q} key is another equivalent way to turn the Calculator off.
799
800 If you type @kbd{M-# b} first and then @kbd{M-# c}, you get a
801 full-screen version of Calc (@code{full-calc}) in which the stack and
802 trail windows are still side-by-side but are now as tall as the whole
803 Emacs screen.  When you press @kbd{q} or @kbd{M-# c} again to quit,
804 the file you were editing before reappears.  The @kbd{M-# b} key
805 switches back and forth between ``big'' full-screen mode and the
806 normal partial-screen mode.
807
808 Finally, @kbd{M-# o} (@code{calc-other-window}) is like @kbd{M-# c}
809 except that the Calc window is not selected.  The buffer you were
810 editing before remains selected instead.  @kbd{M-# o} is a handy
811 way to switch out of Calc momentarily to edit your file; type
812 @kbd{M-# c} to switch back into Calc when you are done.
813
814 @node Quick Mode Overview, Keypad Mode Overview, The Standard Interface, Using Calc
815 @subsection Quick Mode (Overview)
816
817 @noindent
818 @dfn{Quick Mode} is a quick way to use Calc when you don't need the
819 full complexity of the stack and trail.  To use it, type @kbd{M-# q}
820 (@code{quick-calc}) in any regular editing buffer.
821
822 Quick Mode is very simple:  It prompts you to type any formula in
823 standard algebraic notation (like @samp{4 - 2/3}) and then displays
824 the result at the bottom of the Emacs screen (@i{3.33333333333}
825 in this case).  You are then back in the same editing buffer you
826 were in before, ready to continue editing or to type @kbd{M-# q}
827 again to do another quick calculation.  The result of the calculation
828 will also be in the Emacs ``kill ring'' so that a @kbd{C-y} command
829 at this point will yank the result into your editing buffer.
830
831 Calc mode settings affect Quick Mode, too, though you will have to
832 go into regular Calc (with @kbd{M-# c}) to change the mode settings.
833
834 @c [fix-ref Quick Calculator mode]
835 @xref{Quick Calculator}, for further information.
836
837 @node Keypad Mode Overview, Standalone Operation, Quick Mode Overview, Using Calc
838 @subsection Keypad Mode (Overview)
839
840 @noindent
841 @dfn{Keypad Mode} is a mouse-based interface to the Calculator.
842 It is designed for use with the X window system.  If you don't
843 have X, you will have to operate keypad mode with your arrow
844 keys (which is probably more trouble than it's worth).
845
846 Type @kbd{M-# k} to turn Keypad Mode on or off.  Once again you
847 get two new windows, this time on the righthand side of the screen
848 instead of at the bottom.  The upper window is the familiar Calc
849 Stack; the lower window is a picture of a typical calculator keypad.
850
851 @tex
852 \dimen0=\pagetotal%
853 \advance \dimen0 by 24\baselineskip%
854 \ifdim \dimen0>\pagegoal \vfill\eject \fi%
855 \medskip
856 @end tex
857 @smallexample
858                                         |--- Emacs Calculator Mode ---
859                                         |2:  17.3
860                                         |1:  -5
861                                         |    .
862                                         |--%%-Calc: 12 Deg       (Calcul
863                                         |----+-----Calc 2.00-----+----1
864                                         |FLR |CEIL|RND |TRNC|CLN2|FLT |
865                                         |----+----+----+----+----+----|
866                                         | LN |EXP |    |ABS |IDIV|MOD |
867                                         |----+----+----+----+----+----|
868                                         |SIN |COS |TAN |SQRT|y^x |1/x |
869                                         |----+----+----+----+----+----|
870                                         |  ENTER  |+/- |EEX |UNDO| <- |
871                                         |-----+---+-+--+--+-+---++----|
872                                         | INV |  7  |  8  |  9  |  /  |
873                                         |-----+-----+-----+-----+-----|
874                                         | HYP |  4  |  5  |  6  |  *  |
875                                         |-----+-----+-----+-----+-----|
876                                         |EXEC |  1  |  2  |  3  |  -  |
877                                         |-----+-----+-----+-----+-----|
878                                         | OFF |  0  |  .  | PI  |  +  |
879                                         |-----+-----+-----+-----+-----+
880 @end smallexample
881 @iftex
882 @begingroup
883 @ifdim@hsize=5in
884 @vskip-3.7in
885 @advance@hsize-2.2in
886 @else
887 @vskip-3.89in
888 @advance@hsize-3.05in
889 @advance@vsize.1in
890 @fi
891 @end iftex
892
893 Keypad Mode is much easier for beginners to learn, because there
894 is no need to memorize lots of obscure key sequences.  But not all
895 commands in regular Calc are available on the Keypad.  You can
896 always switch the cursor into the Calc stack window to use
897 standard Calc commands if you need.  Serious Calc users, though,
898 often find they prefer the standard interface over Keypad Mode.
899
900 To operate the Calculator, just click on the ``buttons'' of the
901 keypad using your left mouse button.  To enter the two numbers
902 shown here you would click @w{@kbd{1 7 .@: 3 ENTER 5 +/- ENTER}}; to
903 add them together you would then click @kbd{+} (to get 12.3 on
904 the stack).
905
906 If you click the right mouse button, the top three rows of the
907 keypad change to show other sets of commands, such as advanced
908 math functions, vector operations, and operations on binary
909 numbers.
910
911 @iftex
912 @endgroup
913 @end iftex
914 Because Keypad Mode doesn't use the regular keyboard, Calc leaves
915 the cursor in your original editing buffer.  You can type in
916 this buffer in the usual way while also clicking on the Calculator
917 keypad.  One advantage of Keypad Mode is that you don't need an
918 explicit command to switch between editing and calculating.
919
920 If you press @kbd{M-# b} first, you get a full-screen Keypad Mode
921 (@code{full-calc-keypad}) with three windows:  The keypad in the lower
922 left, the stack in the lower right, and the trail on top.
923
924 @c [fix-ref Keypad Mode]
925 @xref{Keypad Mode}, for further information.
926
927 @node Standalone Operation, Embedded Mode Overview, Keypad Mode Overview, Using Calc
928 @subsection Standalone Operation
929
930 @noindent
931 @cindex Standalone Operation
932 If you are not in Emacs at the moment but you wish to use Calc,
933 you must start Emacs first.  If all you want is to run Calc, you
934 can give the commands:
935
936 @example
937 emacs -f full-calc
938 @end example
939
940 @noindent
941 or
942
943 @example
944 emacs -f full-calc-keypad
945 @end example
946
947 @noindent
948 which run a full-screen Calculator (as if by @kbd{M-# b M-# c}) or
949 a full-screen X-based Calculator (as if by @kbd{M-# b M-# k}).
950 In standalone operation, quitting the Calculator (by pressing
951 @kbd{q} or clicking on the keypad @key{EXIT} button) quits Emacs
952 itself.
953
954 @node Embedded Mode Overview, Other M-# Commands, Standalone Operation, Using Calc
955 @subsection Embedded Mode (Overview)
956
957 @noindent
958 @dfn{Embedded Mode} is a way to use Calc directly from inside an
959 editing buffer.  Suppose you have a formula written as part of a
960 document like this:
961
962 @smallexample
963 @group
964 The derivative of
965
966                                    ln(ln(x))
967
968 is
969 @end group
970 @end smallexample
971
972 @noindent
973 and you wish to have Calc compute and format the derivative for
974 you and store this derivative in the buffer automatically.  To
975 do this with Embedded Mode, first copy the formula down to where
976 you want the result to be:
977
978 @smallexample
979 @group
980 The derivative of
981
982                                    ln(ln(x))
983
984 is
985
986                                    ln(ln(x))
987 @end group
988 @end smallexample
989
990 Now, move the cursor onto this new formula and press @kbd{M-# e}.
991 Calc will read the formula (using the surrounding blank lines to
992 tell how much text to read), then push this formula (invisibly)
993 onto the Calc stack.  The cursor will stay on the formula in the
994 editing buffer, but the buffer's mode line will change to look
995 like the Calc mode line (with mode indicators like @samp{12 Deg}
996 and so on).  Even though you are still in your editing buffer,
997 the keyboard now acts like the Calc keyboard, and any new result
998 you get is copied from the stack back into the buffer.  To take
999 the derivative, you would type @kbd{a d x @key{RET}}.
1000
1001 @smallexample
1002 @group
1003 The derivative of
1004
1005                                    ln(ln(x))
1006
1007 is
1008
1009 1 / (x ln(x))
1010 @end group
1011 @end smallexample
1012
1013 To make this look nicer, you might want to press @kbd{d =} to center
1014 the formula, and even @kbd{d B} to use ``big'' display mode.
1015
1016 @smallexample
1017 @group
1018 The derivative of
1019
1020                                    ln(ln(x))
1021
1022 is
1023 % [calc-mode: justify: center]
1024 % [calc-mode: language: big]
1025
1026                                        1
1027                                     -------
1028                                     x ln(x)
1029 @end group
1030 @end smallexample
1031
1032 Calc has added annotations to the file to help it remember the modes
1033 that were used for this formula.  They are formatted like comments
1034 in the @TeX{} typesetting language, just in case you are using @TeX{} 
1035 or @LaTeX{}. (In this example @TeX{} is not being used, so you might 
1036 want to move these comments up to the top of the file or otherwise put 
1037 them out of the way.)
1038
1039 As an extra flourish, we can add an equation number using a
1040 righthand label:  Type @kbd{d @} (1) RET}.
1041
1042 @smallexample
1043 @group
1044 % [calc-mode: justify: center]
1045 % [calc-mode: language: big]
1046 % [calc-mode: right-label: " (1)"]
1047
1048                                        1
1049                                     -------                      (1)
1050                                     x ln(x)
1051 @end group
1052 @end smallexample
1053
1054 To leave Embedded Mode, type @kbd{M-# e} again.  The mode line
1055 and keyboard will revert to the way they were before.  (If you have
1056 actually been trying this as you read along, you'll want to press
1057 @kbd{M-# 0} [with the digit zero] now to reset the modes you changed.)
1058
1059 The related command @kbd{M-# w} operates on a single word, which
1060 generally means a single number, inside text.  It uses any
1061 non-numeric characters rather than blank lines to delimit the
1062 formula it reads.  Here's an example of its use:
1063
1064 @smallexample
1065 A slope of one-third corresponds to an angle of 1 degrees.
1066 @end smallexample
1067
1068 Place the cursor on the @samp{1}, then type @kbd{M-# w} to enable
1069 Embedded Mode on that number.  Now type @kbd{3 /} (to get one-third),
1070 and @kbd{I T} (the Inverse Tangent converts a slope into an angle),
1071 then @w{@kbd{M-# w}} again to exit Embedded mode.
1072
1073 @smallexample
1074 A slope of one-third corresponds to an angle of 18.4349488229 degrees.
1075 @end smallexample
1076
1077 @c [fix-ref Embedded Mode]
1078 @xref{Embedded Mode}, for full details.
1079
1080 @node Other M-# Commands, , Embedded Mode Overview, Using Calc
1081 @subsection Other @kbd{M-#} Commands
1082
1083 @noindent
1084 Two more Calc-related commands are @kbd{M-# g} and @kbd{M-# r},
1085 which ``grab'' data from a selected region of a buffer into the
1086 Calculator.  The region is defined in the usual Emacs way, by
1087 a ``mark'' placed at one end of the region, and the Emacs
1088 cursor or ``point'' placed at the other.
1089
1090 The @kbd{M-# g} command reads the region in the usual left-to-right,
1091 top-to-bottom order.  The result is packaged into a Calc vector
1092 of numbers and placed on the stack.  Calc (in its standard
1093 user interface) is then started.  Type @kbd{v u} if you want
1094 to unpack this vector into separate numbers on the stack.  Also,
1095 @kbd{C-u M-# g} interprets the region as a single number or
1096 formula.
1097
1098 The @kbd{M-# r} command reads a rectangle, with the point and
1099 mark defining opposite corners of the rectangle.  The result
1100 is a matrix of numbers on the Calculator stack.
1101
1102 Complementary to these is @kbd{M-# y}, which ``yanks'' the
1103 value at the top of the Calc stack back into an editing buffer.
1104 If you type @w{@kbd{M-# y}} while in such a buffer, the value is
1105 yanked at the current position.  If you type @kbd{M-# y} while
1106 in the Calc buffer, Calc makes an educated guess as to which
1107 editing buffer you want to use.  The Calc window does not have
1108 to be visible in order to use this command, as long as there
1109 is something on the Calc stack.
1110
1111 Here, for reference, is the complete list of @kbd{M-#} commands.
1112 The shift, control, and meta keys are ignored for the keystroke
1113 following @kbd{M-#}.
1114
1115 @noindent
1116 Commands for turning Calc on and off:
1117
1118 @table @kbd
1119 @item #
1120 Turn Calc on or off, employing the same user interface as last time.
1121
1122 @item C
1123 Turn Calc on or off using its standard bottom-of-the-screen
1124 interface.  If Calc is already turned on but the cursor is not
1125 in the Calc window, move the cursor into the window.
1126
1127 @item O
1128 Same as @kbd{C}, but don't select the new Calc window.  If
1129 Calc is already turned on and the cursor is in the Calc window,
1130 move it out of that window.
1131
1132 @item B
1133 Control whether @kbd{M-# c} and @kbd{M-# k} use the full screen.
1134
1135 @item Q
1136 Use Quick Mode for a single short calculation.
1137
1138 @item K
1139 Turn Calc Keypad mode on or off.
1140
1141 @item E
1142 Turn Calc Embedded mode on or off at the current formula.
1143
1144 @item J
1145 Turn Calc Embedded mode on or off, select the interesting part.
1146
1147 @item W
1148 Turn Calc Embedded mode on or off at the current word (number).
1149
1150 @item Z
1151 Turn Calc on in a user-defined way, as defined by a @kbd{Z I} command.
1152
1153 @item X
1154 Quit Calc; turn off standard, Keypad, or Embedded mode if on.
1155 (This is like @kbd{q} or @key{OFF} inside of Calc.)
1156 @end table
1157 @iftex
1158 @sp 2
1159 @end iftex
1160
1161 @c @group
1162 @noindent
1163 Commands for moving data into and out of the Calculator:
1164
1165 @table @kbd
1166 @item G
1167 Grab the region into the Calculator as a vector.
1168
1169 @item R
1170 Grab the rectangular region into the Calculator as a matrix.
1171
1172 @item :
1173 Grab the rectangular region and compute the sums of its columns.
1174
1175 @item _
1176 Grab the rectangular region and compute the sums of its rows.
1177
1178 @item Y
1179 Yank a value from the Calculator into the current editing buffer.
1180 @end table
1181 @iftex
1182 @sp 2
1183 @end iftex
1184 @c @end group
1185
1186 @c @group
1187 @noindent
1188 Commands for use with Embedded Mode:
1189
1190 @table @kbd
1191 @item A
1192 ``Activate'' the current buffer.  Locate all formulas that
1193 contain @samp{:=} or @samp{=>} symbols and record their locations
1194 so that they can be updated automatically as variables are changed.
1195
1196 @item D
1197 Duplicate the current formula immediately below and select
1198 the duplicate.
1199
1200 @item F
1201 Insert a new formula at the current point.
1202
1203 @item N
1204 Move the cursor to the next active formula in the buffer.
1205
1206 @item P
1207 Move the cursor to the previous active formula in the buffer.
1208
1209 @item U
1210 Update (i.e., as if by the @kbd{=} key) the formula at the current point.
1211
1212 @item `
1213 Edit (as if by @code{calc-edit}) the formula at the current point.
1214 @end table
1215 @iftex
1216 @sp 2
1217 @end iftex
1218 @c @end group
1219
1220 @c @group
1221 @noindent
1222 Miscellaneous commands:
1223
1224 @table @kbd
1225 @item I
1226 Run the Emacs Info system to read the Calc manual.
1227 (This is the same as @kbd{h i} inside of Calc.)
1228
1229 @item T
1230 Run the Emacs Info system to read the Calc Tutorial.
1231
1232 @item S
1233 Run the Emacs Info system to read the Calc Summary.
1234
1235 @item L
1236 Load Calc entirely into memory.  (Normally the various parts
1237 are loaded only as they are needed.)
1238
1239 @item M
1240 Read a region of written keystroke names (like @samp{C-n a b c RET})
1241 and record them as the current keyboard macro.
1242
1243 @item 0
1244 (This is the ``zero'' digit key.)  Reset the Calculator to
1245 its default state:  Empty stack, and default mode settings.
1246 With any prefix argument, reset everything but the stack.
1247 @end table
1248 @c @end group
1249
1250 @node History and Acknowledgements, , Using Calc, Getting Started
1251 @section History and Acknowledgements
1252
1253 @noindent
1254 Calc was originally started as a two-week project to occupy a lull
1255 in the author's schedule.  Basically, a friend asked if I remembered
1256 the value of @c{$2^{32}$}
1257 @cite{2^32}.  I didn't offhand, but I said, ``that's
1258 easy, just call up an @code{xcalc}.''  @code{Xcalc} duly reported
1259 that the answer to our question was @samp{4.294967e+09}---with no way to
1260 see the full ten digits even though we knew they were there in the
1261 program's memory!  I was so annoyed, I vowed to write a calculator
1262 of my own, once and for all.
1263
1264 I chose Emacs Lisp, a) because I had always been curious about it
1265 and b) because, being only a text editor extension language after
1266 all, Emacs Lisp would surely reach its limits long before the project
1267 got too far out of hand.
1268
1269 To make a long story short, Emacs Lisp turned out to be a distressingly
1270 solid implementation of Lisp, and the humble task of calculating
1271 turned out to be more open-ended than one might have expected.
1272
1273 Emacs Lisp doesn't have built-in floating point 
1274 math@footnote{This has changed; all modern Emacsen now have floating
1275 point support as well as support for larger integers.  
1276 In addition, SXEmacs has support for many different number types.}, 
1277 so it had to be
1278 simulated in software.  In fact, Emacs integers will only comfortably
1279 fit six decimal digits or so---not enough for a decent calculator.  So
1280 I had to write my own high-precision integer code as well, and once I had
1281 this I figured that arbitrary-size integers were just as easy as large
1282 integers.  Arbitrary floating-point precision was the logical next step.
1283 Also, since the large integer arithmetic was there anyway it seemed only
1284 fair to give the user direct access to it, which in turn made it practical
1285 to support fractions as well as floats.  All these features inspired me
1286 to look around for other data types that might be worth having.
1287
1288 Around this time, my friend Rick Koshi showed me his nifty new HP-28
1289 calculator.  It allowed the user to manipulate formulas as well as
1290 numerical quantities, and it could also operate on matrices.  I decided
1291 that these would be good for Calc to have, too.  And once things had
1292 gone this far, I figured I might as well take a look at serious algebra
1293 systems like Mathematica, Macsyma, and Maple for further ideas.  Since
1294 these systems did far more than I could ever hope to implement, I decided
1295 to focus on rewrite rules and other programming features so that users
1296 could implement what they needed for themselves.
1297
1298 Rick complained that matrices were hard to read, so I put in code to
1299 format them in a 2D style.  Once these routines were in place, Big mode
1300 was obligatory.  Gee, what other language modes would be useful?
1301
1302 Scott Hemphill and Allen Knutson, two friends with a strong mathematical
1303 bent, contributed ideas and algorithms for a number of Calc features
1304 including modulo forms, primality testing, and float-to-fraction conversion.
1305
1306 Units were added at the eager insistence of Mass Sivilotti.  Later,
1307 Ulrich Mueller at CERN and Przemek Klosowski at NIST provided invaluable
1308 expert assistance with the units table.  As far as I can remember, the
1309 idea of using algebraic formulas and variables to represent units dates
1310 back to an ancient article in Byte magazine about muMath, an early
1311 algebra system for microcomputers.
1312
1313 Many people have contributed to Calc by reporting bugs and suggesting
1314 features, large and small.  A few deserve special mention:  Tim Peters,
1315 who helped develop the ideas that led to the selection commands, rewrite
1316 rules, and many other algebra features; @c{Fran\c cois}
1317 @asis{Francois} Pinard, who contributed
1318 an early prototype of the Calc Summary appendix as well as providing
1319 valuable suggestions in many other areas of Calc; Carl Witty, whose eagle
1320 eyes discovered many typographical and factual errors in the Calc manual;
1321 Tim Kay, who drove the development of Embedded mode; Ove Ewerlid, who
1322 made many suggestions relating to the algebra commands and contributed
1323 some code for polynomial operations; Randal Schwartz, who suggested the
1324 @code{calc-eval} function; Robert J. Chassell, who suggested the Calc
1325 Tutorial and exercises; and Juha Sarlin, who first worked out how to split
1326 Calc into quickly-loading parts.  Bob Weiner helped immensely with the
1327 Lucid Emacs port.
1328
1329 @cindex Bibliography
1330 @cindex Knuth, Art of Computer Programming
1331 @cindex Numerical Recipes
1332 @c Should these be expanded into more complete references?
1333 Among the books used in the development of Calc were Knuth's @emph{Art
1334 of Computer Programming} (especially volume II, @emph{Seminumerical
1335 Algorithms}); @emph{Numerical Recipes} by Press, Flannery, Teukolsky,
1336 and Vetterling; Bevington's @emph{Data Reduction and Error Analysis for
1337 the Physical Sciences}; @emph{Concrete Mathematics} by Graham, Knuth,
1338 and Patashnik; Steele's @emph{Common Lisp, the Language}; the @emph{CRC
1339 Standard Math Tables} (William H. Beyer, ed.); and Abramowitz and
1340 Stegun's venerable @emph{Handbook of Mathematical Functions}.  I
1341 consulted the user's manuals for the HP-28 and HP-48 calculators, as
1342 well as for the programs Mathematica, SMP, Macsyma, Maple, MathCAD,
1343 Gnuplot, and others.  Also, of course, Calc could not have been written
1344 without the excellent @emph{GNU Emacs Lisp Reference Manual}, by Bil
1345 Lewis and Dan LaLiberte.
1346
1347 Final thanks go to Richard Stallman, without whose fine implementations
1348 of the Emacs editor, language, and environment, Calc would have been
1349 finished in two weeks.
1350
1351 @c [tutorial]
1352
1353 @ifinfo
1354 @c This node is accessed by the `M-# t' command.
1355 @node Interactive Tutorial, , , Top
1356 @chapter Tutorial
1357
1358 @noindent
1359 Some brief instructions on using the Emacs Info system for this tutorial:
1360
1361 Press the space bar and Delete keys to go forward and backward in a
1362 section by screenfuls (or use the regular Emacs scrolling commands
1363 for this).
1364
1365 Press @kbd{n} or @kbd{p} to go to the Next or Previous section.
1366 If the section has a @dfn{menu}, press a digit key like @kbd{1}
1367 or @kbd{2} to go to a sub-section from the menu.  Press @kbd{u} to
1368 go back up from a sub-section to the menu it is part of.
1369
1370 Exercises in the tutorial all have cross-references to the
1371 appropriate page of the ``answers'' section.  Press @kbd{f}, then
1372 the exercise number, to see the answer to an exercise.  After
1373 you have followed a cross-reference, you can press the letter
1374 @kbd{l} to return to where you were before.
1375
1376 You can press @kbd{?} at any time for a brief summary of Info commands.
1377
1378 Press @kbd{1} now to enter the first section of the Tutorial.
1379
1380 @menu
1381 * Tutorial::
1382 @end menu
1383 @end ifinfo
1384
1385 @node Tutorial, Introduction, Getting Started, Top
1386 @chapter Tutorial
1387
1388 @noindent
1389 This chapter explains how to use Calc and its many features, in
1390 a step-by-step, tutorial way.  You are encouraged to run Calc and
1391 work along with the examples as you read (@pxref{Starting Calc}).
1392 If you are already familiar with advanced calculators, you may wish
1393 @c [not-split]
1394 to skip on to the rest of this manual.
1395 @c [when-split]
1396 @c to skip on to volume II of this manual, the @dfn{Calc Reference}.
1397
1398 @c [fix-ref Embedded Mode]
1399 This tutorial describes the standard user interface of Calc only.
1400 The ``Quick Mode'' and ``Keypad Mode'' interfaces are fairly