/[emacs]/emacs/man/calc.texi
ViewVC logotype

Diff of /emacs/man/calc.texi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by pj, Tue Dec 25 17:20:00 2001 UTC revision 1.8 by rms, Thu Jan 3 23:38:47 2002 UTC
# Line 26  Line 26 
26  \gdef\citexxx#1{#1$\Etex}  \gdef\citexxx#1{#1$\Etex}
27  \global\let\oldxrefX=\xrefX  \global\let\oldxrefX=\xrefX
28  \gdef\xrefX[#1]{\begingroup\let\cite=\dfn\oldxrefX[#1]\endgroup}  \gdef\xrefX[#1]{\begingroup\let\cite=\dfn\oldxrefX[#1]\endgroup}
29  %  
 % Redefine @i{text} to be equivalent to @cite{text}, i.e., to use math mode.  
 % This looks the same in TeX but omits the surrounding ` ' in Info.  
 \global\let\i=\cite  
 %  
30  % Redefine @c{tex-stuff} \n @whatever{info-stuff}.  % Redefine @c{tex-stuff} \n @whatever{info-stuff}.
31  \gdef\c{\futurelet\next\mycxxx}  \gdef\c{\futurelet\next\mycxxx}
32  \gdef\mycxxx{%  \gdef\mycxxx{%
# Line 62  Line 58 
58  @iftex  @iftex
59  @finalout  @finalout
60  @mathcode`@:=`@:  @c Make Calc fractions come out right in math mode  @mathcode`@:=`@:  @c Make Calc fractions come out right in math mode
 @tocindent=.5pc   @c Indent subsections in table of contents less  
 @rightskip=0pt plus 2pt  @c Favor short lines rather than overfull hboxes  
61  @tex  @tex
62  \gdef\coloneq{\mathrel{\mathord:\mathord=}}  \gdef\coloneq{\mathrel{\mathord:\mathord=}}
63  \ifdim\parskip>17pt  
   \global\parskip=12pt   % Standard parskip looks a bit too large  
 \fi  
 \gdef\internalBitem{\parskip=7pt\kyhpos=\tableindent\kyvpos=0pt  
 \smallbreak\parsearg\itemzzy}  
 \gdef\itemzzy#1{\itemzzz{#1}\relax\ifvmode\kern-7pt\fi}  
 \gdef\trademark{${}^{\rm TM}$}  
 \gdef\group{%  
   \par\vskip8pt\begingroup  
   \def\Egroup{\egroup\endgroup}%  
   \let\aboveenvbreak=\relax  % so that nothing gets between vtop and first box  
   \def\singlespace{\baselineskip=\singlespaceskip}%  
   \vtop\bgroup  
 }  
 %  
 %\global\abovedisplayskip=0pt  
 %\global\abovedisplayshortskip=-10pt  
 %\global\belowdisplayskip=7pt  
 %\global\belowdisplayshortskip=2pt  
64  \gdef\beforedisplay{\vskip-10pt}  \gdef\beforedisplay{\vskip-10pt}
65  \gdef\afterdisplay{\vskip-5pt}  \gdef\afterdisplay{\vskip-5pt}
66  \gdef\beforedisplayh{\vskip-25pt}  \gdef\beforedisplayh{\vskip-25pt}
67  \gdef\afterdisplayh{\vskip-10pt}  \gdef\afterdisplayh{\vskip-10pt}
 %  
 \gdef\printindex{\parsearg\calcprintindex}  
 \gdef\calcprintindex#1{%  
   \doprintindex{#1}%  
   \openin1 \jobname.#1s  
   \ifeof1{\let\s=\indexskip \csname indexsize#1\endcsname}\fi  
   \closein1  
 }  
 \gdef\indexskip{(This page intentionally left blank)\vfill\eject}  
 \gdef\indexsizeky{\s\s\s\s\s\s\s\s}  
 \gdef\indexsizepg{\s\s\s\s\s\s}  
 \gdef\indexsizetp{\s\s\s\s\s\s}  
 \gdef\indexsizecp{\s\s\s\s}  
 \gdef\indexsizevr{}  
 \gdef\indexsizefn{\s\s}  
 \gdef\langle#1\rangle{\it XXX}   % Avoid length mismatch with true expansion  
 %  
 % Ensure no indentation at beginning of sections, and avoid club paragraphs.  
 \global\let\calcchapternofonts=\chapternofonts  
 \gdef\chapternofonts{\aftergroup\calcfixclub\calcchapternofonts}  
 \gdef\calcfixclub{\calcclubpenalty=10000\noindent}  
 \global\let\calcdobreak=\dobreak  
 \gdef\dobreak{{\penalty-9999\dimen0=\pagetotal\advance\dimen0by1.5in  
 \ifdim\dimen0>\pagegoal\vfill\eject\fi}\calcdobreak}  
 %  
 \gdef\kindex{\def\indexname{ky}\futurelet\next\calcindexer}  
 \gdef\tindex{\def\indexname{tp}\futurelet\next\calcindexer}  
 \gdef\mindex{\let\indexname\relax\futurelet\next\calcindexer}  
 \gdef\calcindexer{\catcode`\ =\active\parsearg\calcindexerxx}  
 \gdef\calcindexerxx#1{%  
   \catcode`\ =10%  
   \ifvmode \indent \fi \setbox0=\lastbox \advance\kyhpos\wd0 \fixoddpages \box0  
   \setbox0=\hbox{\ninett #1}%  
   \calcindexersh{\llap{\hbox to 4em{\bumpoddpages\lower\kyvpos\box0\hss}\hskip\kyhpos}}%  
   \global\let\calcindexersh=\calcindexershow  
   \advance\clubpenalty by 5000%  
   \ifx\indexname\relax \else  
     \singlecodeindexer{#1\indexstar}%  
     \global\def\indexstar{}%  
   \fi  
   \futurelet\next\calcindexerxxx  
 }  
 \gdef\indexstar{}  
 \gdef\bumpoddpages{\ifodd\calcpageno\hskip7.3in\fi}  
 %\gdef\bumpoddpages{\hskip7.3in}   % for marginal notes on right side always  
 %\gdef\bumpoddpages{}              % for marginal notes on left side always  
 \gdef\fixoddpages{%  
 \global\calcpageno=\pageno  
 {\dimen0=\pagetotal  
 \advance\dimen0 by2\baselineskip  
 \ifdim\dimen0>\pagegoal  
 \global\advance\calcpageno by 1  
 \vfill\eject\noindent  
 \fi}%  
 }  
 \gdef\calcindexershow#1{\smash{#1}\advance\kyvpos by 11pt}  
 \gdef\calcindexernoshow#1{}  
 \global\let\calcindexersh=\calcindexershow  
 \gdef\calcindexerxxx{%  
   \ifx\indexname\relax  
     \ifx\next\kindex \global\let\calcindexersh=\calcindexernoshow \fi  
     \ifx\next\tindex \global\let\calcindexersh=\calcindexernoshow \fi  
   \fi  
   \calcindexerxxxx  
 }  
 \gdef\calcindexerxxxx#1{\next}  
 \gdef\indexstarxx{\thinspace{\rm *}}  
 \gdef\starindex{\global\let\indexstar=\indexstarxx}  
 \gdef\calceverypar{%  
 \kyhpos=\leftskip\kyvpos=0pt\clubpenalty=\calcclubpenalty  
 \calcclubpenalty=1000\relax  
 }  
 \gdef\idots{{\indrm...}}  
68  @end tex  @end tex
69  @newdimen@kyvpos @kyvpos=0pt  @newdimen@kyvpos @kyvpos=0pt
70  @newdimen@kyhpos @kyhpos=0pt  @newdimen@kyhpos @kyhpos=0pt
71  @newcount@calcclubpenalty @calcclubpenalty=1000  @newcount@calcclubpenalty @calcclubpenalty=1000
72    @ignore
73  @newcount@calcpageno  @newcount@calcpageno
74  @newtoks@calcoldeverypar @calcoldeverypar=@everypar  @newtoks@calcoldeverypar @calcoldeverypar=@everypar
75  @everypar={@calceverypar@the@calcoldeverypar}  @everypar={@calceverypar@the@calcoldeverypar}
# Line 174  Line 78 
78  @catcode`@\=0 \catcode`\@=11  @catcode`@\=0 \catcode`\@=11
79  \r@ggedbottomtrue  \r@ggedbottomtrue
80  \catcode`\@=0 @catcode`@\=@active  \catcode`\@=0 @catcode`@\=@active
81    @end ignore
82  @end iftex  @end iftex
83    
84  @ifinfo  @ifinfo
# Line 574  Financial functions such as future value Line 479  Financial functions such as future value
479    
480  @item  @item
481  Number theoretical features such as prime factorization and arithmetic  Number theoretical features such as prime factorization and arithmetic
482  modulo @i{M} for any @i{M}.  modulo @var{m} for any @var{m}.
483    
484  @item  @item
485  Algebraic manipulation features, including symbolic calculus.  Algebraic manipulation features, including symbolic calculus.
# Line 601  read is the ``Getting Started'' chapter Line 506  read is the ``Getting Started'' chapter
506  first few sections of the tutorial.  As you become more comfortable with  first few sections of the tutorial.  As you become more comfortable with
507  the program you can learn its additional features.  In terms of efficiency,  the program you can learn its additional features.  In terms of efficiency,
508  scope and depth, Calc cannot replace a powerful tool like Mathematica.  scope and depth, Calc cannot replace a powerful tool like Mathematica.
 @c Removed this per RMS' request:  
 @c Mathematica@c{\trademark} @asis{ (tm)}.  
509  But Calc has the advantages of convenience, portability, and availability  But Calc has the advantages of convenience, portability, and availability
510  of the source code.  And, of course, it's free!  of the source code.  And, of course, it's free!
511    
# Line 691  Return key, @key{SPC} for the space bar, Line 594  Return key, @key{SPC} for the space bar,
594  the @kbd{C-j} and @kbd{C-i} keys are equivalent to them, respectively.  the @kbd{C-j} and @kbd{C-i} keys are equivalent to them, respectively.
595  If you don't have a Meta key, look for Alt or Extend Char.  You can  If you don't have a Meta key, look for Alt or Extend Char.  You can
596  also press @key{ESC} or @key{C-[} first to get the same effect, so  also press @key{ESC} or @key{C-[} first to get the same effect, so
597  that @kbd{M-x}, @kbd{ESC x}, and @kbd{C-[ x} are all equivalent.)  that @kbd{M-x}, @kbd{@key{ESC} x}, and @kbd{C-[ x} are all equivalent.)
598    
599  Sometimes the @key{RET} key is not shown when it is ``obvious''  Sometimes the @key{RET} key is not shown when it is ``obvious''
600  that you must press @kbd{RET} to proceed.  For example, the @key{RET}  that you must press @key{RET} to proceed.  For example, the @key{RET}
601  is usually omitted in key sequences like @kbd{M-x calc-keypad @key{RET}}.  is usually omitted in key sequences like @kbd{M-x calc-keypad @key{RET}}.
602    
603  Commands are generally shown like this:  @kbd{p} (@code{calc-precision})  Commands are generally shown like this:  @kbd{p} (@code{calc-precision})
# Line 722  everything you see here will be covered Line 625  everything you see here will be covered
625  Tutorial.  Tutorial.
626    
627  To begin, start Emacs if necessary (usually the command @code{emacs}  To begin, start Emacs if necessary (usually the command @code{emacs}
628  does this), and type @kbd{M-# c} (or @kbd{ESC # c}) to start the  does this), and type @kbd{M-# c} (or @kbd{@key{ESC} # c}) to start the
629  Calculator.  (@xref{Starting Calc}, if this doesn't work for you.)  Calculator.  (@xref{Starting Calc}, if this doesn't work for you.)
630    
631  Be sure to type all the sample input exactly, especially noting the  Be sure to type all the sample input exactly, especially noting the
632  difference between lower-case and upper-case letters.  Remember,  difference between lower-case and upper-case letters.  Remember,
633  @kbd{RET}, @kbd{TAB}, @kbd{DEL}, and @kbd{SPC} are the Return, Tab,  @key{RET}, @key{TAB}, @key{DEL}, and @key{SPC} are the Return, Tab,
634  Delete, and Space keys.  Delete, and Space keys.
635    
636  @strong{RPN calculation.}  In RPN, you type the input number(s) first,  @strong{RPN calculation.}  In RPN, you type the input number(s) first,
637  then the command to operate on the numbers.  then the command to operate on the numbers.
638    
639  @noindent  @noindent
640  Type @kbd{2 RET 3 + Q} to compute @c{$\sqrt{2+3} = 2.2360679775$}  Type @kbd{2 @key{RET} 3 + Q} to compute @c{$\sqrt{2+3} = 2.2360679775$}
641  @asis{the square root of 2+3, which is 2.2360679775}.  @asis{the square root of 2+3, which is 2.2360679775}.
642    
643  @noindent  @noindent
# Line 742  Type @kbd{P 2 ^} to compute @c{$\pi^2 = Line 645  Type @kbd{P 2 ^} to compute @c{$\pi^2 =
645  @asis{the value of `pi' squared, 9.86960440109}.  @asis{the value of `pi' squared, 9.86960440109}.
646    
647  @noindent  @noindent
648  Type @kbd{TAB} to exchange the order of these two results.  Type @key{TAB} to exchange the order of these two results.
649    
650  @noindent  @noindent
651  Type @kbd{- I H S} to subtract these results and compute the Inverse  Type @kbd{- I H S} to subtract these results and compute the Inverse
652  Hyperbolic sine of the difference, 2.72996136574.  Hyperbolic sine of the difference, 2.72996136574.
653    
654  @noindent  @noindent
655  Type @kbd{DEL} to erase this result.  Type @key{DEL} to erase this result.
656    
657  @strong{Algebraic calculation.}  You can also enter calculations using  @strong{Algebraic calculation.}  You can also enter calculations using
658  conventional ``algebraic'' notation.  To enter an algebraic formula,  conventional ``algebraic'' notation.  To enter an algebraic formula,
659  use the apostrophe key.  use the apostrophe key.
660    
661  @noindent  @noindent
662  Type @kbd{' sqrt(2+3) RET} to compute @c{$\sqrt{2+3}$}  Type @kbd{' sqrt(2+3) @key{RET}} to compute @c{$\sqrt{2+3}$}
663  @asis{the square root of 2+3}.  @asis{the square root of 2+3}.
664    
665  @noindent  @noindent
666  Type @kbd{' pi^2 RET} to enter @c{$\pi^2$}  Type @kbd{' pi^2 @key{RET}} to enter @c{$\pi^2$}
667  @asis{`pi' squared}.  To evaluate this symbolic  @asis{`pi' squared}.  To evaluate this symbolic
668  formula as a number, type @kbd{=}.  formula as a number, type @kbd{=}.
669    
670  @noindent  @noindent
671  Type @kbd{' arcsinh($ - $$) RET} to subtract the second-most-recent  Type @kbd{' arcsinh($ - $$) @key{RET}} to subtract the second-most-recent
672  result from the most-recent and compute the Inverse Hyperbolic sine.  result from the most-recent and compute the Inverse Hyperbolic sine.
673    
674  @strong{Keypad mode.}  If you are using the X window system, press  @strong{Keypad mode.}  If you are using the X window system, press
# Line 791  the Keypad Calculator off. Line 694  the Keypad Calculator off.
694    
695  @strong{Grabbing data.}  Type @kbd{M-# x} if necessary to exit Calc.  @strong{Grabbing data.}  Type @kbd{M-# x} if necessary to exit Calc.
696  Now select the following numbers as an Emacs region:  ``Mark'' the  Now select the following numbers as an Emacs region:  ``Mark'' the
697  front of the list by typing control-@kbd{SPC} or control-@kbd{@@} there,  front of the list by typing @kbd{C-@key{SPC}} or @kbd{C-@@} there,
698  then move to the other end of the list.  (Either get this list from  then move to the other end of the list.  (Either get this list from
699  the on-line copy of this manual, accessed by @w{@kbd{M-# i}}, or just  the on-line copy of this manual, accessed by @w{@kbd{M-# i}}, or just
700  type these numbers into a scratch file.)  Now type @kbd{M-# g} to  type these numbers into a scratch file.)  Now type @kbd{M-# g} to
701  ``grab'' these numbers into Calc.  ``grab'' these numbers into Calc.
702    
 @group  
703  @example  @example
704    @group
705  1.23  1.97  1.23  1.97
706  1.6   2  1.6   2
707  1.19  1.08  1.19  1.08
 @end example  
708  @end group  @end group
709    @end example
710    
711  @noindent  @noindent
712  The result @samp{[1.23, 1.97, 1.6, 2, 1.19, 1.08]} is a Calc ``vector.''  The result @samp{[1.23, 1.97, 1.6, 2, 1.19, 1.08]} is a Calc ``vector.''
# Line 823  Type @kbd{v t} to transpose this @c{$3\t Line 726  Type @kbd{v t} to transpose this @c{$3\t
726  @asis{3x2} matrix into a @c{$2\times3$}  @asis{3x2} matrix into a @c{$2\times3$}
727  @asis{2x3} matrix.  Type  @asis{2x3} matrix.  Type
728  @w{@kbd{v u}} to unpack the rows into two separate vectors.  Now type  @w{@kbd{v u}} to unpack the rows into two separate vectors.  Now type
729  @w{@kbd{V R + TAB V R +}} to compute the sums of the two original columns.  @w{@kbd{V R + @key{TAB} V R +}} to compute the sums of the two original columns.
730  (There is also a special grab-and-sum-columns command, @kbd{M-# :}.)  (There is also a special grab-and-sum-columns command, @kbd{M-# :}.)
731    
732  @strong{Units conversion.}  Units are entered algebraically.  @strong{Units conversion.}  Units are entered algebraically.
733  Type @w{@kbd{' 43 mi/hr RET}} to enter the quantity 43 miles-per-hour.  Type @w{@kbd{' 43 mi/hr @key{RET}}} to enter the quantity 43 miles-per-hour.
734  Type @w{@kbd{u c km/hr RET}}.  Type @w{@kbd{u c m/s RET}}.  Type @w{@kbd{u c km/hr @key{RET}}}.  Type @w{@kbd{u c m/s @key{RET}}}.
735    
736  @strong{Date arithmetic.}  Type @kbd{t N} to get the current date and  @strong{Date arithmetic.}  Type @kbd{t N} to get the current date and
737  time.  Type @kbd{90 +} to find the date 90 days from now.  Type  time.  Type @kbd{90 +} to find the date 90 days from now.  Type
738  @kbd{' <25 dec 87> RET} to enter a date, then @kbd{- 7 /} to see how  @kbd{' <25 dec 87> @key{RET}} to enter a date, then @kbd{- 7 /} to see how
739  many weeks have passed since then.  many weeks have passed since then.
740    
741  @strong{Algebra.}  Algebraic entries can also include formulas  @strong{Algebra.}  Algebraic entries can also include formulas
742  or equations involving variables.  Type @kbd{@w{' [x + y} = a, x y = 1] RET}  or equations involving variables.  Type @kbd{@w{' [x + y} = a, x y = 1] @key{RET}}
743  to enter a pair of equations involving three variables.  to enter a pair of equations involving three variables.
744  (Note the leading apostrophe in this example; also, note that the space  (Note the leading apostrophe in this example; also, note that the space
745  between @samp{x y} is required.)  Type @w{@kbd{a S x,y RET}} to solve  between @samp{x y} is required.)  Type @w{@kbd{a S x,y @key{RET}}} to solve
746  these equations for the variables @cite{x} and @cite{y}.@refill  these equations for the variables @cite{x} and @cite{y}.@refill
747    
748  @noindent  @noindent
# Line 849  to view them in the notation for the @Te Line 752  to view them in the notation for the @Te
752  Type @kbd{d N} to return to normal notation.  Type @kbd{d N} to return to normal notation.
753    
754  @noindent  @noindent
755  Type @kbd{7.5}, then @kbd{s l a RET} to let @cite{a = 7.5} in these formulas.  Type @kbd{7.5}, then @kbd{s l a @key{RET}} to let @cite{a = 7.5} in these formulas.
756  (That's a letter @kbd{l}, not a numeral @kbd{1}.)  (That's a letter @kbd{l}, not a numeral @kbd{1}.)
757    
758  @iftex  @iftex
759  @strong{Help functions.}  You can read about any command in the on-line  @strong{Help functions.}  You can read about any command in the on-line
760  manual.  Type @kbd{M-# c} to return to Calc after each of these  manual.  Type @kbd{M-# c} to return to Calc after each of these
761  commands: @kbd{h k t N} to read about the @kbd{t N} command,  commands: @kbd{h k t N} to read about the @kbd{t N} command,
762  @kbd{h f sqrt RET} to read about the @code{sqrt} function, and  @kbd{h f sqrt @key{RET}} to read about the @code{sqrt} function, and
763  @kbd{h s} to read the Calc summary.  @kbd{h s} to read the Calc summary.
764  @end iftex  @end iftex
765  @ifinfo  @ifinfo
766  @strong{Help functions.}  You can read about any command in the on-line  @strong{Help functions.}  You can read about any command in the on-line
767  manual.  Remember to type the letter @kbd{l}, then @kbd{M-# c}, to  manual.  Remember to type the letter @kbd{l}, then @kbd{M-# c}, to
768  return here after each of these commands: @w{@kbd{h k t N}} to read  return here after each of these commands: @w{@kbd{h k t N}} to read
769  about the @w{@kbd{t N}} command, @kbd{h f sqrt RET} to read about the  about the @w{@kbd{t N}} command, @kbd{h f sqrt @key{RET}} to read about the
770  @code{sqrt} function, and @kbd{h s} to read the Calc summary.  @code{sqrt} function, and @kbd{h s} to read the Calc summary.
771  @end ifinfo  @end ifinfo
772    
773  Press @kbd{DEL} repeatedly to remove any leftover results from the stack.  Press @key{DEL} repeatedly to remove any leftover results from the stack.
774  To exit from Calc, press @kbd{q} or @kbd{M-# c} again.  To exit from Calc, press @kbd{q} or @kbd{M-# c} again.
775    
776  @node Using Calc, History and Acknowledgements, Demonstration of Calc, Getting Started  @node Using Calc, History and Acknowledgements, Demonstration of Calc, Getting Started
# Line 951  operated by the normal Emacs keyboard. Line 854  operated by the normal Emacs keyboard.
854  to start the Calculator, the Emacs screen splits into two windows  to start the Calculator, the Emacs screen splits into two windows
855  with the file you were editing on top and Calc on the bottom.  with the file you were editing on top and Calc on the bottom.
856    
 @group  
857  @iftex  @iftex
858  @advance@hsize20pt  @advance@hsize20pt
859  @end iftex  @end iftex
860  @smallexample  @smallexample
861    @group
862    
863  ...  ...
864  --**-Emacs: myfile             (Fundamental)----All----------------------  --**-Emacs: myfile             (Fundamental)----All----------------------
# Line 968  with the file you were editing on top an Line 871  with the file you were editing on top an
871                                                  |  ->-5                                                  |  ->-5
872                                                  |                                                  |
873  --%%-Calc: 12 Deg       (Calculator)----All----- --%%-Emacs: *Calc Trail*  --%%-Calc: 12 Deg       (Calculator)----All----- --%%-Emacs: *Calc Trail*
 @end smallexample  
874  @end group  @end group
875    @end smallexample
876    
877  In this figure, the mode-line for @file{myfile} has moved up and the  In this figure, the mode-line for @file{myfile} has moved up and the
878  ``Calculator'' window has appeared below it.  As you can see, Calc  ``Calculator'' window has appeared below it.  As you can see, Calc
# Line 1185  itself. Line 1088  itself.
1088  editing buffer.  Suppose you have a formula written as part of a  editing buffer.  Suppose you have a formula written as part of a
1089  document like this:  document like this:
1090    
 @group  
1091  @smallexample  @smallexample
1092    @group
1093  The derivative of  The derivative of
1094    
1095                                     ln(ln(x))                                     ln(ln(x))
1096    
1097  is  is
 @end smallexample  
1098  @end group  @end group
1099    @end smallexample
1100    
1101  @noindent  @noindent
1102  and you wish to have Calc compute and format the derivative for  and you wish to have Calc compute and format the derivative for
# Line 1201  you and store this derivative in the buf Line 1104  you and store this derivative in the buf
1104  do this with Embedded Mode, first copy the formula down to where  do this with Embedded Mode, first copy the formula down to where
1105  you want the result to be:  you want the result to be:
1106    
 @group  
1107  @smallexample  @smallexample
1108    @group
1109  The derivative of  The derivative of
1110    
1111                                     ln(ln(x))                                     ln(ln(x))
# Line 1210  The derivative of Line 1113  The derivative of
1113  is  is
1114    
1115                                     ln(ln(x))                                     ln(ln(x))
 @end smallexample  
1116  @end group  @end group
1117    @end smallexample
1118    
1119  Now, move the cursor onto this new formula and press @kbd{M-# e}.  Now, move the cursor onto this new formula and press @kbd{M-# e}.
1120  Calc will read the formula (using the surrounding blank lines to  Calc will read the formula (using the surrounding blank lines to
# Line 1224  the keyboard now acts like the Calc keyb Line 1127  the keyboard now acts like the Calc keyb
1127  you get is copied from the stack back into the buffer.  To take  you get is copied from the stack back into the buffer.  To take
1128  the derivative, you would type @kbd{a d x @key{RET}}.  the derivative, you would type @kbd{a d x @key{RET}}.
1129    
 @group  
1130  @smallexample  @smallexample
1131    @group
1132  The derivative of  The derivative of
1133    
1134                                     ln(ln(x))                                     ln(ln(x))
# Line 1233  The derivative of Line 1136  The derivative of
1136  is  is
1137    
1138  1 / ln(x) x  1 / ln(x) x
 @end smallexample  
1139  @end group  @end group
1140    @end smallexample
1141    
1142  To make this look nicer, you might want to press @kbd{d =} to center  To make this look nicer, you might want to press @kbd{d =} to center
1143  the formula, and even @kbd{d B} to use ``big'' display mode.  the formula, and even @kbd{d B} to use ``big'' display mode.
1144    
 @group  
1145  @smallexample  @smallexample
1146    @group
1147  The derivative of  The derivative of
1148    
1149                                     ln(ln(x))                                     ln(ln(x))
# Line 1252  is Line 1155  is
1155                                         1                                         1
1156                                      -------                                      -------
1157                                      ln(x) x                                      ln(x) x
 @end smallexample  
1158  @end group  @end group
1159    @end smallexample
1160    
1161  Calc has added annotations to the file to help it remember the modes  Calc has added annotations to the file to help it remember the modes
1162  that were used for this formula.  They are formatted like comments  that were used for this formula.  They are formatted like comments
# Line 1263  these comments up to the top of the file Line 1166  these comments up to the top of the file
1166  of the way.)  of the way.)
1167    
1168  As an extra flourish, we can add an equation number using a  As an extra flourish, we can add an equation number using a
1169  righthand label:  Type @kbd{d @} (1) RET}.  righthand label:  Type @kbd{d @} (1) @key{RET}}.
1170    
 @group  
1171  @smallexample  @smallexample
1172    @group
1173  % [calc-mode: justify: center]  % [calc-mode: justify: center]
1174  % [calc-mode: language: big]  % [calc-mode: language: big]
1175  % [calc-mode: right-label: " (1)"]  % [calc-mode: right-label: " (1)"]
# Line 1274  righthand label:  Type @kbd{d @} (1) RET Line 1177  righthand label:  Type @kbd{d @} (1) RET
1177                                         1                                         1
1178                                      -------                      (1)                                      -------                      (1)
1179                                      ln(x) x                                      ln(x) x
 @end smallexample  
1180  @end group  @end group
1181    @end smallexample
1182    
1183  To leave Embedded Mode, type @kbd{M-# e} again.  The mode line  To leave Embedded Mode, type @kbd{M-# e} again.  The mode line
1184  and keyboard will revert to the way they were before.  (If you have  and keyboard will revert to the way they were before.  (If you have
# Line 1384  Quit Calc; turn off standard, Keypad, or Line 1287  Quit Calc; turn off standard, Keypad, or
1287  @sp 2  @sp 2
1288  @end iftex  @end iftex
1289    
 @group  
1290  @noindent  @noindent
1291  Commands for moving data into and out of the Calculator:  Commands for moving data into and out of the Calculator:
1292    
# Line 1407  Yank a value from the Calculator into th Line 1309  Yank a value from the Calculator into th
1309  @iftex  @iftex
1310  @sp 2  @sp 2
1311  @end iftex  @end iftex
 @end group  
1312    
 @group  
1313  @noindent  @noindent
1314  Commands for use with Embedded Mode:  Commands for use with Embedded Mode:
1315    
# Line 1441  Edit (as if by @code{calc-edit}) the for Line 1341  Edit (as if by @code{calc-edit}) the for
1341  @iftex  @iftex
1342  @sp 2  @sp 2
1343  @end iftex  @end iftex
 @end group  
1344    
 @group  
1345  @noindent  @noindent
1346  Miscellaneous commands:  Miscellaneous commands:
1347    
# Line 1463  Load Calc entirely into memory.  (Normal Line 1361  Load Calc entirely into memory.  (Normal
1361  are loaded only as they are needed.)  are loaded only as they are needed.)
1362    
1363  @item M  @item M
1364  Read a region of written keystroke names (like @samp{C-n a b c RET})  Read a region of written keystroke names (like @kbd{C-n a b c @key{RET}})
1365  and record them as the current keyboard macro.  and record them as the current keyboard macro.
1366    
1367  @item 0  @item 0
# Line 1471  and record them as the current keyboard Line 1369  and record them as the current keyboard
1369  its default state:  Empty stack, and default mode settings.  its default state:  Empty stack, and default mode settings.
1370  With any prefix argument, reset everything but the stack.  With any prefix argument, reset everything but the stack.
1371  @end table  @end table
 @end group  
1372    
1373  @node History and Acknowledgements, , Using Calc, Getting Started  @node History and Acknowledgements, , Using Calc, Getting Started
1374  @section History and Acknowledgements  @section History and Acknowledgements
# Line 1724  The @kbd{+} key ``pops'' the top two num Line 1621  The @kbd{+} key ``pops'' the top two num
1621  and pushes the result (5) back onto the stack.  Here's how the stack  and pushes the result (5) back onto the stack.  Here's how the stack
1622  will look at various points throughout the calculation:@refill  will look at various points throughout the calculation:@refill
1623    
 @group  
1624  @smallexample  @smallexample
1625    @group
1626      .          1:  2          2:  2          1:  5              .      .          1:  2          2:  2          1:  5              .
1627                     .          1:  3              .                     .          1:  3              .
1628                                    .                                    .
1629    
1630    M-# c          2 RET          3 RET            +             DEL    M-# c          2 @key{RET}          3 @key{RET}            +             @key{DEL}
 @end smallexample  
1631  @end group  @end group
1632    @end smallexample
1633    
1634  The @samp{.} symbol is a marker that represents the top of the stack.  The @samp{.} symbol is a marker that represents the top of the stack.
1635  Note that the ``top'' of the stack is really shown at the bottom of  Note that the ``top'' of the stack is really shown at the bottom of
# Line 1769  Thus @kbd{2 @key{RET} 3 +} will work jus Line 1666  Thus @kbd{2 @key{RET} 3 +} will work jus
1666  Examples in this tutorial will often omit @key{RET} even when the  Examples in this tutorial will often omit @key{RET} even when the
1667  stack displays shown would only happen if you did press @key{RET}:  stack displays shown would only happen if you did press @key{RET}:
1668    
 @group  
1669  @smallexample  @smallexample
1670    @group
1671  1:  2          2:  2          1:  5  1:  2          2:  2          1:  5
1672      .          1:  3              .      .          1:  3              .
1673                     .                     .
1674    
1675    2 RET            3              +    2 @key{RET}            3              +
 @end smallexample  
1676  @end group  @end group
1677    @end smallexample
1678    
1679  @noindent  @noindent
1680  Here, after pressing @kbd{3} the stack would really show @samp{1:  2}  Here, after pressing @kbd{3} the stack would really show @samp{1:  2}
# Line 1830  from positive to negative or vice-versa: Line 1727  from positive to negative or vice-versa:
1727  If you press @key{RET} when you're not entering a number, the effect  If you press @key{RET} when you're not entering a number, the effect
1728  is to duplicate the top number on the stack.  Consider this calculation:  is to duplicate the top number on the stack.  Consider this calculation:
1729    
 @group  
1730  @smallexample  @smallexample
1731    @group
1732  1:  3          2:  3          1:  9          2:  9          1:  81  1:  3          2:  3          1:  9          2:  9          1:  81
1733      .          1:  3              .          1:  9              .      .          1:  3              .          1:  9              .
1734                     .                             .                     .                             .
1735    
1736    3 RET           RET             *             RET             *    3 @key{RET}           @key{RET}             *             @key{RET}             *
 @end smallexample  
1737  @end group  @end group
1738    @end smallexample
1739    
1740  @noindent  @noindent
1741  (Of course, an easier way to do this would be @kbd{3 @key{RET} 4 ^},  (Of course, an easier way to do this would be @kbd{3 @key{RET} 4 ^},
# Line 1854  two stack entries.  Suppose you have com Line 1751  two stack entries.  Suppose you have com
1751  to get 5, and then you realize what you really wanted to compute  to get 5, and then you realize what you really wanted to compute
1752  was @cite{20 / (2+3)}.  was @cite{20 / (2+3)}.
1753    
 @group  
1754  @smallexample  @smallexample
1755    @group
1756  1:  5          2:  5          2:  20         1:  4  1:  5          2:  5          2:  20         1:  4
1757      .          1:  20         1:  5              .      .          1:  20         1:  5              .
1758                     .              .                     .              .
1759    
1760   2 RET 3 +         20            TAB             /   2 @key{RET} 3 +         20            @key{TAB}             /
 @end smallexample  
1761  @end group  @end group
1762    @end smallexample
1763    
1764  @noindent  @noindent
1765  Planning ahead, the calculation would have gone like this:  Planning ahead, the calculation would have gone like this:
1766    
 @group  
1767  @smallexample  @smallexample
1768    @group
1769  1:  20         2:  20         3:  20         2:  20         1:  4  1:  20         2:  20         3:  20         2:  20         1:  4
1770      .          1:  2          2:  2          1:  5              .      .          1:  2          2:  2          1:  5              .
1771                     .          1:  3              .                     .          1:  3              .
1772                                    .                                    .
1773    
1774    20 RET         2 RET            3              +              /    20 @key{RET}         2 @key{RET}            3              +              /
 @end smallexample  
1775  @end group  @end group
1776    @end smallexample
1777    
1778  A related stack command is @kbd{M-@key{TAB}} (hold @key{META} and type  A related stack command is @kbd{M-@key{TAB}} (hold @key{META} and type
1779  @key{TAB}).  It rotates the top three elements of the stack upward,  @key{TAB}).  It rotates the top three elements of the stack upward,
1780  bringing the object in level 3 to the top.  bringing the object in level 3 to the top.
1781    
 @group  
1782  @smallexample  @smallexample
1783    @group
1784  1:  10         2:  10         3:  10         3:  20         3:  30  1:  10         2:  10         3:  10         3:  20         3:  30
1785      .          1:  20         2:  20         2:  30         2:  10      .          1:  20         2:  20         2:  30         2:  10
1786                     .          1:  30         1:  10         1:  20                     .          1:  30         1:  10         1:  20
1787                                    .              .              .                                    .              .              .
1788    
1789    10 RET         20 RET         30 RET         M-TAB          M-TAB    10 @key{RET}         20 @key{RET}         30 @key{RET}         M-@key{TAB}          M-@key{TAB}
 @end smallexample  
1790  @end group  @end group
1791    @end smallexample
1792    
1793  (@bullet{}) @strong{Exercise 3.} Suppose the numbers 10, 20, and 30 are  (@bullet{}) @strong{Exercise 3.} Suppose the numbers 10, 20, and 30 are
1794  on the stack.  Figure out how to add one to the number in level 2  on the stack.  Figure out how to add one to the number in level 2
# Line 1903  arguments from the stack and push a resu Line 1800  arguments from the stack and push a resu
1800  @kbd{Q} (square root) pop a single number and push the result.  You can  @kbd{Q} (square root) pop a single number and push the result.  You can
1801  think of them as simply operating on the top element of the stack.  think of them as simply operating on the top element of the stack.
1802    
 @group  
1803  @smallexample  @smallexample
1804    @group
1805  1:  3          1:  9          2:  9          1:  25         1:  5  1:  3          1:  9          2:  9          1:  25         1:  5
1806      .              .          1:  16             .              .      .              .          1:  16             .              .
1807                                    .                                    .
1808    
1809    3 RET          RET *        4 RET RET *        +              Q    3 @key{RET}          @key{RET} *        4 @key{RET} @key{RET} *        +              Q
 @end smallexample  
1810  @end group  @end group
1811    @end smallexample
1812    
1813  @noindent  @noindent
1814  (Note that capital @kbd{Q} means to hold down the Shift key while  (Note that capital @kbd{Q} means to hold down the Shift key while
# Line 1923  right triangle.  Calc actually has a bui Line 1820  right triangle.  Calc actually has a bui
1820  @kbd{f h}, but let's suppose we can't remember the necessary keystrokes.  @kbd{f h}, but let's suppose we can't remember the necessary keystrokes.
1821  We can still enter it by its full name using @kbd{M-x} notation:  We can still enter it by its full name using @kbd{M-x} notation:
1822    
 @group  
1823  @smallexample  @smallexample
1824    @group
1825  1:  3          2:  3          1:  5  1:  3          2:  3          1:  5
1826      .          1:  4              .      .          1:  4              .
1827                     .                     .
1828    
1829    3 RET          4 RET      M-x calc-hypot    3 @key{RET}          4 @key{RET}      M-x calc-hypot
 @end smallexample  
1830  @end group  @end group
1831    @end smallexample
1832    
1833  All Calculator commands begin with the word @samp{calc-}.  Since it  All Calculator commands begin with the word @samp{calc-}.  Since it
1834  gets tiring to type this, Calc provides an @kbd{x} key which is just  gets tiring to type this, Calc provides an @kbd{x} key which is just
1835  like the regular Emacs @kbd{M-x} key except that it types the @samp{calc-}  like the regular Emacs @kbd{M-x} key except that it types the @samp{calc-}
1836  prefix for you:  prefix for you:
1837    
 @group  
1838  @smallexample  @smallexample
1839    @group
1840  1:  3          2:  3          1:  5  1:  3          2:  3          1:  5
1841      .          1:  4              .      .          1:  4              .
1842                     .                     .
1843    
1844    3 RET          4 RET         x hypot    3 @key{RET}          4 @key{RET}         x hypot
 @end smallexample  
1845  @end group  @end group
1846    @end smallexample
1847    
1848  What happens if you take the square root of a negative number?  What happens if you take the square root of a negative number?
1849    
 @group  
1850  @smallexample  @smallexample
1851    @group
1852  1:  4          1:  -4         1:  (0, 2)  1:  4          1:  -4         1:  (0, 2)
1853      .              .              .      .              .              .
1854    
1855    4 RET            n              Q    4 @key{RET}            n              Q
 @end smallexample  
1856  @end group  @end group
1857    @end smallexample
1858    
1859  @noindent  @noindent
1860  The notation @cite{(a, b)} represents a complex number.  The notation @cite{(a, b)} represents a complex number.
# Line 1975  complex result.) Line 1872  complex result.)
1872  Complex numbers are entered in the notation shown.  The @kbd{(} and  Complex numbers are entered in the notation shown.  The @kbd{(} and
1873  @kbd{,} and @kbd{)} keys manipulate ``incomplete complex numbers.''  @kbd{,} and @kbd{)} keys manipulate ``incomplete complex numbers.''
1874    
 @group  
1875  @smallexample  @smallexample
1876    @group
1877  1:  ( ...      2:  ( ...      1:  (2, ...    1:  (2, ...    1:  (2, 3)  1:  ( ...      2:  ( ...      1:  (2, ...    1:  (2, ...    1:  (2, 3)
1878      .          1:  2              .              3              .      .          1:  2              .              3              .
1879                     .                             .                     .                             .
1880    
1881      (              2              ,              3              )      (              2              ,              3              )
 @end smallexample  
1882  @end group  @end group
1883    @end smallexample
1884    
1885  You can perform calculations while entering parts of incomplete objects.  You can perform calculations while entering parts of incomplete objects.
1886  However, an incomplete object cannot actually participate in a calculation:  However, an incomplete object cannot actually participate in a calculation:
1887    
 @group  
1888  @smallexample  @smallexample
1889    @group
1890  1:  ( ...      2:  ( ...      3:  ( ...      1:  ( ...      1:  ( ...  1:  ( ...      2:  ( ...      3:  ( ...      1:  ( ...      1:  ( ...
1891      .          1:  2          2:  2              5              5      .          1:  2          2:  2              5              5
1892                     .          1:  3              .              .                     .          1:  3              .              .
1893                                    .                                    .
1894                                                               (error)                                                               (error)
1895      (             2 RET           3              +              +      (             2 @key{RET}           3              +              +
 @end smallexample  
1896  @end group  @end group
1897    @end smallexample
1898    
1899  @noindent  @noindent
1900  Adding 5 to an incomplete object makes no sense, so the last command  Adding 5 to an incomplete object makes no sense, so the last command
# Line 2006  produces an error message and leaves the Line 1903  produces an error message and leaves the
1903  Incomplete objects can't participate in arithmetic, but they can be  Incomplete objects can't participate in arithmetic, but they can be
1904  moved around by the regular stack commands.  moved around by the regular stack commands.
1905    
 @group  
1906  @smallexample  @smallexample
1907    @group
1908  2:  2          3:  2          3:  3          1:  ( ...      1:  (2, 3)  2:  2          3:  2          3:  3          1:  ( ...      1:  (2, 3)
1909  1:  3          2:  3          2:  ( ...          2              .  1:  3          2:  3          2:  ( ...          2              .
1910      .          1:  ( ...      1:  2              3      .          1:  ( ...      1:  2              3
1911                     .              .              .                     .              .              .
1912    
1913  2 RET 3 RET        (            M-TAB          M-TAB            )  2 @key{RET} 3 @key{RET}        (            M-@key{TAB}          M-@key{TAB}            )
 @end smallexample  
1914  @end group  @end group
1915    @end smallexample
1916    
1917  @noindent  @noindent
1918  Note that the @kbd{,} (comma) key did not have to be used here.  Note that the @kbd{,} (comma) key did not have to be used here.
# Line 2041  necessary digits.  Numeric prefix argume Line 1938  necessary digits.  Numeric prefix argume
1938  prefix arguments in a variety of ways.  For example, a numeric prefix  prefix arguments in a variety of ways.  For example, a numeric prefix
1939  on the @kbd{+} operator adds any number of stack entries at once:  on the @kbd{+} operator adds any number of stack entries at once:
1940    
 @group  
1941  @smallexample  @smallexample
1942    @group
1943  1:  10         2:  10         3:  10         3:  10         1:  60  1:  10         2:  10         3:  10         3:  10         1:  60
1944      .          1:  20         2:  20         2:  20             .      .          1:  20         2:  20         2:  20             .
1945                     .          1:  30         1:  30                     .          1:  30         1:  30
1946                                    .              .                                    .              .
1947    
1948    10 RET         20 RET         30 RET         C-u 3            +    10 @key{RET}         20 @key{RET}         30 @key{RET}         C-u 3            +
 @end smallexample  
1949  @end group  @end group
1950    @end smallexample
1951    
1952  For stack manipulation commands like @key{RET}, a positive numeric  For stack manipulation commands like @key{RET}, a positive numeric
1953  prefix argument operates on the top @var{n} stack entries at once.  A  prefix argument operates on the top @var{n} stack entries at once.  A
# Line 2058  negative argument operates on the entry Line 1955  negative argument operates on the entry
1955  argument of zero operates on the entire stack.  In this example, we copy  argument of zero operates on the entire stack.  In this example, we copy
1956  the second-to-top element of the stack:  the second-to-top element of the stack:
1957    
 @group  
1958  @smallexample  @smallexample
1959    @group
1960  1:  10         2:  10         3:  10         3:  10         4:  10  1:  10         2:  10         3:  10         3:  10         4:  10
1961      .          1:  20         2:  20         2:  20         3:  20      .          1:  20         2:  20         2:  20         3:  20
1962                     .          1:  30         1:  30         2:  30                     .          1:  30         1:  30         2:  30
1963                                    .              .          1:  20                                    .              .          1:  20
1964                                                                  .                                                                  .
1965    
1966    10 RET         20 RET         30 RET         C-u -2          RET    10 @key{RET}         20 @key{RET}         30 @key{RET}         C-u -2          @key{RET}
 @end smallexample  
1967  @end group  @end group
1968    @end smallexample
1969    
1970  @cindex Clearing the stack  @cindex Clearing the stack
1971  @cindex Emptying the stack  @cindex Emptying the stack
1972  Another common idiom is @kbd{M-0 DEL}, which clears the stack.  Another common idiom is @kbd{M-0 @key{DEL}}, which clears the stack.
1973  (The @kbd{M-0} numeric prefix tells @key{DEL} to operate on the  (The @kbd{M-0} numeric prefix tells @key{DEL} to operate on the
1974  entire stack.)  entire stack.)
1975    
# Line 2117  is equivalent to Line 2014  is equivalent to
2014  or, in large mathematical notation,  or, in large mathematical notation,
2015    
2016  @ifinfo  @ifinfo
 @group  
2017  @example  @example
2018    @group
2019      3 * 4 * 5      3 * 4 * 5
2020  2 + --------- - 9  2 + --------- - 9
2021            8            8
2022       6 * 7       6 * 7
 @end example  
2023  @end group  @end group
2024    @end example
2025  @end ifinfo  @end ifinfo
2026  @tex  @tex
2027  \turnoffactive  \turnoffactive
# Line 2180  distracting, even though they otherwise Line 2077  distracting, even though they otherwise
2077    
2078  Still in algebraic mode, type:  Still in algebraic mode, type:
2079    
 @group  
2080  @smallexample  @smallexample
2081    @group
2082  1:  (2, 3)     2:  (2, 3)     1:  (8, -1)    2:  (8, -1)    1:  (9, -1)  1:  (2, 3)     2:  (2, 3)     1:  (8, -1)    2:  (8, -1)    1:  (9, -1)
2083      .          1:  (1, -2)        .          1:  1              .      .          1:  (1, -2)        .          1:  1              .
2084                     .                             .                     .                             .
2085    
2086   (2,3) RET      (1,-2) RET        *              1 RET          +   (2,3) @key{RET}      (1,-2) @key{RET}        *              1 @key{RET}          +
 @end smallexample  
2087  @end group  @end group
2088    @end smallexample
2089    
2090  Algebraic mode allows us to enter complex numbers without pressing  Algebraic mode allows us to enter complex numbers without pressing
2091  an apostrophe first, but it also means we need to press @key{RET}  an apostrophe first, but it also means we need to press @key{RET}
# Line 2218  of the stack.  Here, we perform the calc Line 2115  of the stack.  Here, we perform the calc
2115  which on a traditional calculator would be done by pressing  which on a traditional calculator would be done by pressing
2116  @kbd{2 * 4 + 1 =} and then the square-root key.  @kbd{2 * 4 + 1 =} and then the square-root key.
2117    
 @group  
2118  @smallexample  @smallexample
2119    @group
2120  1:  8          1:  9          1:  3  1:  8          1:  9          1:  3
2121      .              .              .      .              .              .
2122    
2123    ' 2*4 RET        $+1 RET        Q    ' 2*4 @key{RET}        $+1 @key{RET}        Q
 @end smallexample  
2124  @end group  @end group
2125    @end smallexample
2126    
2127  @noindent  @noindent
2128  Notice that we didn't need to press an apostrophe for the @kbd{$+1},  Notice that we didn't need to press an apostrophe for the @kbd{$+1},
# Line 2237  if the @kbd{Q} key on your keyboard were Line 2134  if the @kbd{Q} key on your keyboard were
2134  @xref{Algebraic Answer 1, 1}. (@bullet{})  @xref{Algebraic Answer 1, 1}. (@bullet{})
2135    
2136  The notations @kbd{$$}, @kbd{$$$}, and so on stand for higher stack  The notations @kbd{$$}, @kbd{$$$}, and so on stand for higher stack
2137  entries.  For example, @kbd{' $$+$ RET} is just like typing @kbd{+}.  entries.  For example, @kbd{' $$+$ @key{RET}} is just like typing @kbd{+}.
2138    
2139  Algebraic formulas can include @dfn{variables}.  To store in a  Algebraic formulas can include @dfn{variables}.  To store in a
2140  variable, press @kbd{s s}, then type the variable name, then press  variable, press @kbd{s s}, then type the variable name, then press
# Line 2247  on the stack, while @w{@kbd{s t}} remove Line 2144  on the stack, while @w{@kbd{s t}} remove
2144  stores it in the variable.)  A variable name should consist of one  stores it in the variable.)  A variable name should consist of one
2145  or more letters or digits, beginning with a letter.  or more letters or digits, beginning with a letter.
2146    
 @group  
2147  @smallexample  @smallexample
2148    @group
2149  1:  17             .          1:  a + a^2    1:  306  1:  17             .          1:  a + a^2    1:  306
2150      .                             .              .      .                             .              .
2151    
2152      17          s t a RET      ' a+a^2 RET       =      17          s t a @key{RET}      ' a+a^2 @key{RET}       =
 @end smallexample  
2153  @end group  @end group
2154    @end smallexample
2155    
2156  @noindent  @noindent
2157  The @kbd{=} key @dfn{evaluates} a formula by replacing all its  The @kbd{=} key @dfn{evaluates} a formula by replacing all its
# Line 2264  For RPN calculations, you can recall a v Line 2161  For RPN calculations, you can recall a v
2161  stack either by entering its name as a formula and pressing @kbd{=},  stack either by entering its name as a formula and pressing @kbd{=},
2162  or by using the @kbd{s r} command.  or by using the @kbd{s r} command.
2163    
 @group  
2164  @smallexample  @smallexample
2165    @group
2166  1:  17         2:  17         3:  17         2:  17         1:  306  1:  17         2:  17         3:  17         2:  17         1:  306
2167      .          1:  17         2:  17         1:  289            .      .          1:  17         2:  17         1:  289            .
2168                     .          1:  2              .                     .          1:  2              .
2169                                    .                                    .
2170    
2171    s r a RET     ' a RET =         2              ^              +    s r a @key{RET}     ' a @key{RET} =         2              ^              +
 @end smallexample  
2172  @end group  @end group
2173    @end smallexample
2174    
2175  If you press a single digit for a variable name (as in @kbd{s t 3}, you  If you press a single digit for a variable name (as in @kbd{s t 3}, you
2176  get one of ten @dfn{quick variables} @code{q0} through @code{q9}.  get one of ten @dfn{quick variables} @code{q0} through @code{q9}.
# Line 2285  simply @kbd{s 3} as a shorthand for @kbd Line 2182  simply @kbd{s 3} as a shorthand for @kbd
2182  Any variables in an algebraic formula for which you have not stored  Any variables in an algebraic formula for which you have not stored
2183  values are left alone, even when you evaluate the formula.  values are left alone, even when you evaluate the formula.
2184    
 @group  
2185  @smallexample  @smallexample
2186    @group
2187  1:  2 a + 2 b     1:  34 + 2 b  1:  2 a + 2 b     1:  34 + 2 b
2188      .                 .      .                 .
2189    
2190   ' 2a+2b RET          =   ' 2a+2b @key{RET}          =
 @end smallexample  
2191  @end group  @end group
2192    @end smallexample
2193    
2194  Calls to function names which are undefined in Calc are also left  Calls to function names which are undefined in Calc are also left
2195  alone, as are calls for which the value is undefined.  alone, as are calls for which the value is undefined.
2196    
 @group  
2197  @smallexample  @smallexample
2198    @group
2199  1:  2 + log10(0) + log10(x) + log10(5, 6) + foo(3)  1:  2 + log10(0) + log10(x) + log10(5, 6) + foo(3)
2200      .      .
2201    
2202   ' log10(100) + log10(0) + log10(x) + log10(5,6) + foo(3) RET   ' log10(100) + log10(0) + log10(x) + log10(5,6) + foo(3) @key{RET}
 @end smallexample  
2203  @end group  @end group
2204    @end smallexample
2205    
2206  @noindent  @noindent
2207  In this example, the first call to @code{log10} works, but the other  In this example, the first call to @code{log10} works, but the other
# Line 2341  the stack, you will see two copies of th Line 2238  the stack, you will see two copies of th
2238  between them.  The lefthand formula is exactly like you typed it;  between them.  The lefthand formula is exactly like you typed it;
2239  the righthand formula has been evaluated as if by typing @kbd{=}.  the righthand formula has been evaluated as if by typing @kbd{=}.
2240    
 @group  
2241  @smallexample  @smallexample
2242    @group
2243  2:  2 + 3 => 5                     2:  2 + 3 => 5  2:  2 + 3 => 5                     2:  2 + 3 => 5
2244  1:  2 a + 2 b => 34 + 2 b          1:  2 a + 2 b => 20 + 2 b  1:  2 a + 2 b => 34 + 2 b          1:  2 a + 2 b => 20 + 2 b
2245      .                                  .      .                                  .
2246    
2247  ' 2+3 => RET  ' 2a+2b RET s =          10 s t a RET  ' 2+3 => @key{RET}  ' 2a+2b @key{RET} s =          10 s t a @key{RET}
 @end smallexample  
2248  @end group  @end group
2249    @end smallexample
2250    
2251  @noindent  @noindent
2252  Notice that the instant we stored a new value in @code{a}, all  Notice that the instant we stored a new value in @code{a}, all
# Line 2360  to see the effects on the formulas' valu Line 2257  to see the effects on the formulas' valu
2257    
2258  You can also ``unstore'' a variable when you are through with it:  You can also ``unstore'' a variable when you are through with it:
2259    
 @group  
2260  @smallexample  @smallexample
2261    @group
2262  2:  2 + 5 => 5  2:  2 + 5 => 5
2263  1:  2 a + 2 b => 2 a + 2 b  1:  2 a + 2 b => 2 a + 2 b
2264      .      .
2265    
2266      s u a RET      s u a @key{RET}
 @end smallexample  
2267  @end group  @end group
2268    @end smallexample
2269    
2270  We will encounter formulas involving variables and functions again  We will encounter formulas involving variables and functions again
2271  when we discuss the algebra and calculus features of the Calculator.  when we discuss the algebra and calculus features of the Calculator.
# Line 2378  when we discuss the algebra and calculus Line 2275  when we discuss the algebra and calculus
2275    
2276  @noindent  @noindent
2277  If you make a mistake, you can usually correct it by pressing shift-@kbd{U},  If you make a mistake, you can usually correct it by pressing shift-@kbd{U},
2278  the ``undo'' command.  First, clear the stack (@kbd{M-0 DEL}) and exit  the ``undo'' command.  First, clear the stack (@kbd{M-0 @key{DEL}}) and exit
2279  and restart Calc (@kbd{M-# M-# M-# M-#}) to make sure things start off  and restart Calc (@kbd{M-# M-# M-# M-#}) to make sure things start off
2280  with a clean slate.  Now:  with a clean slate.  Now:
2281    
 @group  
2282  @smallexample  @smallexample
2283    @group
2284  1:  2          2:  2          1:  8          2:  2          1:  6  1:  2          2:  2          1:  8          2:  2          1:  6
2285      .          1:  3              .          1:  3              .      .          1:  3              .          1:  3              .
2286                     .                             .                     .                             .
2287    
2288     2 RET           3              ^              U              *     2 @key{RET}           3              ^              U              *
 @end smallexample  
2289  @end group  @end group
2290    @end smallexample
2291    
2292  You can undo any number of times.  Calc keeps a complete record of  You can undo any number of times.  Calc keeps a complete record of
2293  all you have done since you last opened the Calc window.  After the  all you have done since you last opened the Calc window.  After the
2294  above example, you could type:  above example, you could type:
2295    
 @group  
2296  @smallexample  @smallexample
2297    @group
2298  1:  6          2:  2          1:  2              .              .  1:  6          2:  2          1:  2              .              .
2299      .          1:  3              .      .          1:  3              .
2300                     .                     .
2301                                                               (error)                                                               (error)
2302                     U              U              U              U                     U              U              U              U
 @end smallexample  
2303  @end group  @end group
2304    @end smallexample
2305    
2306  You can also type @kbd{D} to ``redo'' a command that you have undone  You can also type @kbd{D} to ``redo'' a command that you have undone
2307  mistakenly.  mistakenly.
2308    
 @group  
2309  @smallexample  @smallexample
2310    @group
2311      .          1:  2          2:  2          1:  6          1:  6      .          1:  2          2:  2          1:  6          1:  6
2312                     .          1:  3              .              .                     .          1:  3              .              .
2313                                    .                                    .
2314                                                               (error)                                                               (error)
2315                     D              D              D              D                     D              D              D              D
 @end smallexample  
2316  @end group  @end group
2317    @end smallexample
2318    
2319  @noindent  @noindent
2320  It was not possible to redo past the @cite{6}, since that was placed there  It was not possible to redo past the @cite{6}, since that was placed there
# Line 2540  You can set the precision to anything yo Line 2437  You can set the precision to anything yo
2437  then entering a suitable number.  Try pressing @kbd{p 30 @key{RET}},  then entering a suitable number.  Try pressing @kbd{p 30 @key{RET}},
2438  then doing @kbd{1 @key{RET} 7 /} again:  then doing @kbd{1 @key{RET} 7 /} again:
2439    
 @group  
2440  @smallexample  @smallexample
2441    @group
2442  1:  0.142857142857  1:  0.142857142857
2443  2:  0.142857142857142857142857142857  2:  0.142857142857142857142857142857
2444      .      .
 @end smallexample  
2445  @end group  @end group
2446    @end smallexample
2447    
2448  Although the precision can be set arbitrarily high, Calc always  Although the precision can be set arbitrarily high, Calc always
2449  has to have @emph{some} value for the current precision.  After  has to have @emph{some} value for the current precision.  After
# Line 2564  duplicate the number, then @w{@kbd{1 +}} Line 2461  duplicate the number, then @w{@kbd{1 +}}
2461  key didn't round the number, because it doesn't do any calculation.  key didn't round the number, because it doesn't do any calculation.
2462  But the instant we pressed @kbd{+}, the number was rounded down.  But the instant we pressed @kbd{+}, the number was rounded down.
2463    
 @group  
2464  @smallexample  @smallexample
2465    @group
2466  1:  0.142857142857  1:  0.142857142857
2467  2:  0.142857142857142857142857142857  2:  0.142857142857142857142857142857
2468  3:  1.14285714286  3:  1.14285714286
2469      .      .
 @end smallexample  
2470  @end group  @end group
2471    @end smallexample
2472    
2473  @noindent  @noindent
2474  In fact, since we added a digit on the left, we had to lose one  In fact, since we added a digit on the left, we had to lose one
# Line 2595  to convert an integer to floating-point Line 2492  to convert an integer to floating-point
2492    
2493  Let's try entering that last calculation:  Let's try entering that last calculation:
2494    
 @group  
2495  @smallexample  @smallexample
2496    @group
2497  1:  2.         2:  2.         1:  1.99506311689e3010  1:  2.         2:  2.         1:  1.99506311689e3010
2498      .          1:  10000          .      .          1:  10000          .
2499                     .                     .
2500    
2501    2.0 RET          10000 RET      ^    2.0 @key{RET}          10000 @key{RET}      ^
 @end smallexample  
2502  @end group  @end group
2503    @end smallexample
2504    
2505  @noindent  @noindent
2506  @cindex Scientific notation, entry of  @cindex Scientific notation, entry of
# Line 2612  power of,'' and is used by Calc automati Line 2509  power of,'' and is used by Calc automati
2509  number out fully would introduce more extra zeros than you probably  number out fully would introduce more extra zeros than you probably
2510  want to see.  You can enter numbers in this notation, too.  want to see.  You can enter numbers in this notation, too.
2511    
 @group  
2512  @smallexample  @smallexample
2513    @group
2514  1:  2.         2:  2.         1:  1.99506311678e3010  1:  2.         2:  2.         1:  1.99506311678e3010
2515      .          1:  10000.         .      .          1:  10000.         .
2516                     .                     .
2517    
2518    2.0 RET          1e4 RET        ^    2.0 @key{RET}          1e4 @key{RET}        ^
 @end smallexample  
2519  @end group  @end group
2520    @end smallexample
2521    
2522  @cindex Round-off errors  @cindex Round-off errors
2523  @noindent  @noindent
# Line 2635  a slight error crept in during one of th Line 2532  a slight error crept in during one of th
2532  one should we trust?  Let's raise the precision a bit and find  one should we trust?  Let's raise the precision a bit and find
2533  out:  out:
2534    
 @group  
2535  @smallexample  @smallexample
2536    @group
2537      .          1:  2.         2:  2.         1:  1.995063116880828e3010      .          1:  2.         2:  2.         1:  1.995063116880828e3010
2538                     .          1:  10000.         .                     .          1:  10000.         .
2539                                    .                                    .
2540    
2541   p 16 RET        2. RET           1e4            ^    p 12 RET   p 16 @key{RET}        2. @key{RET}           1e4            ^    p 12 @key{RET}
 @end smallexample  
2542  @end group  @end group
2543    @end smallexample
2544    
2545  @noindent  @noindent
2546  @cindex Guard digits  @cindex Guard digits
# Line 2672  notation}.  You get them by pressing @w{ Line 2569  notation}.  You get them by pressing @w{
2569  supply a numeric prefix argument which says how many digits  supply a numeric prefix argument which says how many digits
2570  should be displayed.  As an example, let's put a few numbers  should be displayed.  As an example, let's put a few numbers
2571  onto the stack and try some different display modes.  First,  onto the stack and try some different display modes.  First,
2572  use @kbd{M-0 DEL} to clear the stack, then enter the four  use @kbd{M-0 @key{DEL}} to clear the stack, then enter the four
2573  numbers shown here:  numbers shown here:
2574    
 @group  
2575  @smallexample  @smallexample
2576    @group
2577  4:  12345      4:  12345      4:  12345      4:  12345      4:  12345  4:  12345      4:  12345      4:  12345      4:  12345      4:  12345
2578  3:  12345.     3:  12300.     3:  1.2345e4   3:  1.23e4     3:  12345.000  3:  12345.     3:  12300.     3:  1.2345e4   3:  1.23e4     3:  12345.000
2579  2:  123.45     2:  123.       2:  1.2345e2   2:  1.23e2     2:  123.450  2:  123.45     2:  123.       2:  1.2345e2   2:  1.23e2     2:  123.450
# Line 2684  numbers shown here: Line 2581  numbers shown here:
2581      .              .              .              .              .      .              .              .              .              .
2582    
2583     d n          M-3 d n          d s          M-3 d s        M-3 d f     d n          M-3 d n          d s          M-3 d s        M-3 d f
 @end smallexample  
2584  @end group  @end group
2585    @end smallexample
2586    
2587  @noindent  @noindent
2588  Notice that when we typed @kbd{M-3 d n}, the numbers were rounded down  Notice that when we typed @kbd{M-3 d n}, the numbers were rounded down
# Line 2706  so Calc allows you to type shift-@kbd{H} Line 2603  so Calc allows you to type shift-@kbd{H}
2603  prevent it from updating the stack.  Anything Calc displays after the  prevent it from updating the stack.  Anything Calc displays after the
2604  mode-changing command will appear in the new format.  mode-changing command will appear in the new format.
2605    
 @group  
2606  @smallexample  @smallexample
2607    @group
2608  4:  12345      4:  12345      4:  12345      4:  12345      4:  12345  4:  12345      4:  12345      4:  12345      4:  12345      4:  12345
2609  3:  12345.000  3:  12345.000  3:  12345.000  3:  1.2345e4   3:  12345.  3:  12345.000  3:  12345.000  3:  12345.000  3:  1.2345e4   3:  12345.
2610  2:  123.450    2:  123.450    2:  1.2345e1   2:  1.2345e1   2:  123.45  2:  123.450    2:  123.450    2:  1.2345e1   2:  1.2345e1   2:  123.45
2611  1:  12.345     1:  1.2345e1   1:  1.2345e2   1:  1.2345e2   1:  12.345  1:  12.345     1:  1.2345e1   1:  1.2345e2   1:  1.2345e2   1:  12.345
2612      .              .              .              .              .      .              .              .              .              .
2613    
2614      H d s          DEL U          TAB            d SPC          d n      H d s          @key{DEL} U          @key{TAB}            d @key{SPC}          d n
 @end smallexample  
2615  @end group  @end group
2616    @end smallexample
2617    
2618  @noindent  @noindent
2619  Here the @kbd{H d s} command changes to scientific notation but without  Here the @kbd{H d s} command changes to scientific notation but without
2620  updating the screen.  Deleting the top stack entry and undoing it back  updating the screen.  Deleting the top stack entry and undoing it back
2621  causes it to show up in the new format; swapping the top two stack  causes it to show up in the new format; swapping the top two stack
2622  entries reformats both entries.  The @kbd{d SPC} command refreshes the  entries reformats both entries.  The @kbd{d @key{SPC}} command refreshes the
2623  whole stack.  The @kbd{d n} command changes back to the normal float  whole stack.  The @kbd{d n} command changes back to the normal float
2624  format; since it doesn't have an @kbd{H} prefix, it also updates all  format; since it doesn't have an @kbd{H} prefix, it also updates all
2625  the stack entries to be in @kbd{d n} format.  the stack entries to be in @kbd{d n} format.
# Line 2864  the @samp{Deg} indicator in the mode lin Line 2761  the @samp{Deg} indicator in the mode lin
2761  a command that interprets a number as an angle, it will assume the  a command that interprets a number as an angle, it will assume the
2762  angle is measured in degrees.  For example,  angle is measured in degrees.  For example,
2763    
 @group  
2764  @smallexample  @smallexample
2765    @group
2766  1:  45         1:  0.707106781187   1:  0.500000000001    1:  0.5  1:  45         1:  0.707106781187   1:  0.500000000001    1:  0.5
2767      .              .                    .                     .      .              .                    .                     .
2768    
2769      45             S                    2 ^                   c 1      45             S                    2 ^                   c 1
 @end smallexample  
2770  @end group  @end group
2771    @end smallexample
2772    
2773  @noindent  @noindent
2774  The shift-@kbd{S} command computes the sine of an angle.  The sine  The shift-@kbd{S} command computes the sine of an angle.  The sine
# Line 2898  To do this calculation in radians, we wo Line 2795  To do this calculation in radians, we wo
2795  again, this is a shifted capital @kbd{P}.  Remember, unshifted  again, this is a shifted capital @kbd{P}.  Remember, unshifted
2796  @kbd{p} sets the precision.)  @kbd{p} sets the precision.)
2797    
 @group  
2798  @smallexample  @smallexample
2799    @group
2800  1:  3.14159265359   1:  0.785398163398   1:  0.707106781187  1:  3.14159265359   1:  0.785398163398   1:  0.707106781187
2801      .                   .                .      .                   .                .
2802    
2803      P                   4 /       m r    S      P                   4 /       m r    S
 @end smallexample  
2804  @end group  @end group
2805    @end smallexample
2806    
2807  Likewise, inverse trigonometric functions generate results in  Likewise, inverse trigonometric functions generate results in
2808  either radians or degrees, depending on the current angular mode.  either radians or degrees, depending on the current angular mode.
2809    
 @group  
2810  @smallexample  @smallexample
2811    @group
2812  1:  0.707106781187   1:  0.785398163398   1:  45.  1:  0.707106781187   1:  0.785398163398   1:  45.
2813      .                    .                    .      .                    .                    .
2814    
2815      .5 Q        m r      I S        m d       U I S      .5 Q        m r      I S        m d       U I S
 @end smallexample  
2816  @end group  @end group
2817    @end smallexample
2818    
2819  @noindent  @noindent
2820  Here we compute the Inverse Sine of @c{$\sqrt{0.5}$}  Here we compute the Inverse Sine of @c{$\sqrt{0.5}$}
# Line 2927  radians, then in degrees. Line 2824  radians, then in degrees.
2824  Use @kbd{c d} and @kbd{c r} to convert a number from radians to degrees  Use @kbd{c d} and @kbd{c r} to convert a number from radians to degrees
2825  and vice-versa.  and vice-versa.
2826    
 @group  
2827  @smallexample  @smallexample
2828    @group
2829  1:  45         1:  0.785398163397     1:  45.  1:  45         1:  0.785398163397     1:  45.
2830      .              .                      .      .              .                      .
2831    
2832      45             c r                    c d      45             c r                    c d
 @end smallexample  
2833  @end group  @end group
2834    @end smallexample
2835    
2836  Another interesting mode is @dfn{fraction mode}.  Normally,  Another interesting mode is @dfn{fraction mode}.  Normally,
2837  dividing two integers produces a floating-point result if the  dividing two integers produces a floating-point result if the
# Line 2942  quotient can't be expressed as an exact Line 2839  quotient can't be expressed as an exact
2839  causes integer division to produce a fraction, i.e., a rational  causes integer division to produce a fraction, i.e., a rational
2840  number, instead.  number, instead.
2841    
 @group  
2842  @smallexample  @smallexample
2843    @group
2844  2:  12         1:  1.33333333333    1:  4:3  2:  12         1:  1.33333333333    1:  4:3
2845  1:  9              .                    .  1:  9              .                    .
2846      .      .
2847    
2848   12 RET 9          /          m f       U /      m f   12 @key{RET} 9          /          m f       U /      m f
 @end smallexample  
2849  @end group  @end group
2850    @end smallexample
2851    
2852  @noindent  @noindent
2853  In the first case, we get an approximate floating-point result.  In the first case, we get an approximate floating-point result.
# Line 2975  again when we changed to fraction mode. Line 2872  again when we changed to fraction mode.
2872  evaluates-to operator you can get commands like @kbd{m f} to  evaluates-to operator you can get commands like @kbd{m f} to
2873  recompute for you.  recompute for you.
2874    
 @group  
2875  @smallexample  @smallexample
2876    @group
2877  1:  12 / 9 => 1.33333333333    1:  12 / 9 => 1.333    1:  12 / 9 => 4:3  1:  12 / 9 => 1.33333333333    1:  12 / 9 => 1.333    1:  12 / 9 => 4:3
2878      .                              .                      .      .                              .                      .
2879    
2880     ' 12/9 => RET                   p 4 RET                m f     ' 12/9 => @key{RET}                   p 4 @key{RET}                m f
 @end smallexample  
2881  @end group  @end group
2882    @end smallexample
2883    
2884  @noindent  @noindent
2885  In this example, the righthand side of the @samp{=>} operator  In this example, the righthand side of the @samp{=>} operator
# Line 3003  and @kbd{^}.  Each normally takes two nu Line 2900  and @kbd{^}.  Each normally takes two nu
2900  and pushes back a result.  The @kbd{n} and @kbd{&} keys perform  and pushes back a result.  The @kbd{n} and @kbd{&} keys perform
2901  change-sign and reciprocal operations, respectively.  change-sign and reciprocal operations, respectively.
2902    
 @group  
2903  @smallexample  @smallexample
2904    @group
2905  1:  5          1:  0.2        1:  5.         1:  -5.        1:  5.  1:  5          1:  0.2        1:  5.         1:  -5.        1:  5.
2906      .              .              .              .              .      .              .              .              .              .
2907    
2908      5              &              &              n              n      5              &              &              n              n
 @end smallexample  
2909  @end group  @end group
2910    @end smallexample
2911    
2912  @cindex Binary operators  @cindex Binary operators
2913  You can apply a ``binary operator'' like @kbd{+} across any number of  You can apply a ``binary operator'' like @kbd{+} across any number of
# Line 3018  stack entries by giving it a numeric pre Line 2915  stack entries by giving it a numeric pre
2915  pairwise to several stack elements along with the top one if you use  pairwise to several stack elements along with the top one if you use
2916  a negative prefix.  a negative prefix.
2917    
 @group  
2918  @smallexample  @smallexample
2919    @group
2920  3:  2          1:  9          3:  2          4:  2          3:  12  3:  2          1:  9          3:  2          4:  2          3:  12
2921  2:  3              .          2:  3          3:  3          2:  13  2:  3              .          2:  3          3:  3          2:  13
2922  1:  4                         1:  4          2:  4          1:  14  1:  4                         1:  4          2:  4          1:  14
2923      .                             .          1:  10             .      .                             .          1:  10             .
2924                                                   .                                                   .
2925    
2926  2 RET 3 RET 4     M-3 +           U              10          M-- M-3 +  2 @key{RET} 3 @key{RET} 4     M-3 +           U              10          M-- M-3 +
 @end smallexample  
2927  @end group  @end group
2928    @end smallexample
2929    
2930  @cindex Unary operators  @cindex Unary operators
2931  You can apply a ``unary operator'' like @kbd{&} to the top @var{n}  You can apply a ``unary operator'' like @kbd{&} to the top @var{n}
2932  stack entries with a numeric prefix, too.  stack entries with a numeric prefix, too.
2933    
 @group  
2934  @smallexample  @smallexample
2935    @group
2936  3:  2          3:  0.5                3:  0.5  3:  2          3:  0.5                3:  0.5
2937  2:  3          2:  0.333333333333     2:  3.  2:  3          2:  0.333333333333     2:  3.
2938  1:  4          1:  0.25               1:  4.  1:  4          1:  0.25               1:  4.
2939      .              .                      .      .              .                      .
2940    
2941  2 RET 3 RET 4      M-3 &                  M-2 &  2 @key{RET} 3 @key{RET} 4      M-3 &                  M-2 &
 @end smallexample  
2942  @end group  @end group
2943    @end smallexample
2944    
2945  Notice that the results here are left in floating-point form.  Notice that the results here are left in floating-point form.
2946  We can convert them back to integers by pressing @kbd{F}, the  We can convert them back to integers by pressing @kbd{F}, the
# Line 3051  We can convert them back to integers by Line 2948  We can convert them back to integers by
2948  integer.  There is also @kbd{R}, which rounds to the nearest  integer.  There is also @kbd{R}, which rounds to the nearest
2949  integer.  integer.
2950    
 @group  
2951  @smallexample  @smallexample
2952    @group
2953  7:  2.         7:  2          7:  2  7:  2.         7:  2          7:  2
2954  6:  2.4        6:  2          6:  2  6:  2.4        6:  2          6:  2
2955  5:  2.5        5:  2          5:  3  5:  2.5        5:  2          5:  3
# Line 3063  integer. Line 2960  integer.
2960      .              .              .      .              .              .
2961    
2962                    M-7 F        U M-7 R                    M-7 F        U M-7 R
 @end smallexample  
2963  @end group  @end group
2964    @end smallexample
2965    
2966  Since dividing-and-flooring (i.e., ``integer quotient'') is such a  Since dividing-and-flooring (i.e., ``integer quotient'') is such a
2967  common operation, Calc provides a special command for that purpose, the  common operation, Calc provides a special command for that purpose, the
# Line 3072  backslash @kbd{\}.  Another common arith Line 2969  backslash @kbd{\}.  Another common arith
2969  computes the remainder that would arise from a @kbd{\} operation, i.e.,  computes the remainder that would arise from a @kbd{\} operation, i.e.,
2970  the ``modulo'' of two numbers.  For example,  the ``modulo'' of two numbers.  For example,
2971    
 @group  
2972  @smallexample  @smallexample
2973    @group
2974  2:  1234       1:  12         2:  1234       1:  34  2:  1234       1:  12         2:  1234       1:  34
2975  1:  100            .          1:  100            .  1:  100            .          1:  100            .
2976      .                             .      .                             .
2977    
2978  1234 RET 100       \              U              %  1234 @key{RET} 100       \              U              %
 @end smallexample  
2979  @end group  @end group
2980    @end smallexample
2981    
2982  These commands actually work for any real numbers, not just integers.  These commands actually work for any real numbers, not just integers.
2983    
 @group  
2984  @smallexample  @smallexample
2985    @group
2986  2:  3.1415     1:  3          2:  3.1415     1:  0.1415  2:  3.1415     1:  3          2:  3.1415     1:  0.1415
2987  1:  1              .          1:  1              .  1:  1              .          1:  1              .
2988      .                             .      .                             .
2989    
2990  3.1415 RET 1       \              U              %  3.1415 @key{RET} 1       \              U              %
 @end smallexample  
2991  @end group  @end group
2992    @end smallexample
2993    
2994  (@bullet{}) @strong{Exercise 1.}  The @kbd{\} command would appear to be a  (@bullet{}) @strong{Exercise 1.}  The @kbd{\} command would appear to be a
2995  frill, since you could always do the same thing with @kbd{/ F}.  Think  frill, since you could always do the same thing with @kbd{/ F}.  Think
# Line 3112  identity @c{$\sin^2x + \cos^2x = 1$} Line 3009  identity @c{$\sin^2x + \cos^2x = 1$}
3009  arbitrarily pick @i{-64} degrees as a good value for @cite{x}.  With  arbitrarily pick @i{-64} degrees as a good value for @cite{x}.  With
3010  the angular mode set to degrees (type @w{@kbd{m d}}), do:  the angular mode set to degrees (type @w{@kbd{m d}}), do:
3011    
 @group  
3012  @smallexample  @smallexample
3013    @group
3014  2:  -64        2:  -64        2:  -0.89879   2:  -0.89879   1:  1.  2:  -64        2:  -64        2:  -0.89879   2:  -0.89879   1:  1.
3015  1:  -64        1:  -0.89879   1:  -64        1:  0.43837        .  1:  -64        1:  -0.89879   1:  -64        1:  0.43837        .
3016      .              .              .              .      .              .              .              .
3017    
3018   64 n RET RET      S              TAB            C              f h   64 n @key{RET} @key{RET}      S              @key{TAB}            C              f h
 @end smallexample  
3019  @end group  @end group
3020    @end smallexample
3021    
3022  @noindent  @noindent
3023  (For brevity, we're showing only five digits of the results here.  (For brevity, we're showing only five digits of the results here.
# Line 3131  of squares, command. Line 3028  of squares, command.
3028    
3029  Another identity is @c{$\displaystyle\tan x = {\sin x \over \cos x}$}  Another identity is @c{$\displaystyle\tan x = {\sin x \over \cos x}$}
3030  @cite{tan(x) = sin(x) / cos(x)}.  @cite{tan(x) = sin(x) / cos(x)}.
 @group  
3031  @smallexample  @smallexample
3032    @group
3033    
3034  2:  -0.89879   1:  -2.0503    1:  -64.  2:  -0.89879   1:  -2.0503    1:  -64.
3035  1:  0.43837        .              .  1:  0.43837        .              .
3036      .      .
3037    
3038      U              /              I T      U              /              I T
 @end smallexample  
3039  @end group  @end group
3040    @end smallexample
3041    
3042  A physical interpretation of this calculation is that if you move  A physical interpretation of this calculation is that if you move
3043  @cite{0.89879} units downward and @cite{0.43837} units to the right,  @cite{0.89879} units downward and @cite{0.43837} units to the right,
3044  your direction of motion is @i{-64} degrees from horizontal.  Suppose  your direction of motion is @i{-64} degrees from horizontal.  Suppose
3045  we move in the opposite direction, up and to the left:  we move in the opposite direction, up and to the left:
3046    
 @group  
3047  @smallexample  @smallexample
3048    @group
3049  2:  -0.89879   2:  0.89879    1:  -2.0503    1:  -64.  2:  -0.89879   2:  0.89879    1:  -2.0503    1:  -64.
3050  1:  0.43837    1:  -0.43837       .              .  1:  0.43837    1:  -0.43837       .              .
3051      .              .      .              .
3052    
3053      U U            M-2 n          /              I T      U U            M-2 n          /              I T
 @end smallexample  
3054  @end group  @end group
3055    @end smallexample
3056    
3057  @noindent  @noindent
3058  How can the angle be the same?  The answer is that the @kbd{/} operation  How can the angle be the same?  The answer is that the @kbd{/} operation
# Line 3166  computes the inverse tangent of the quot Line 3063  computes the inverse tangent of the quot
3063  Since you feed it the two original numbers, it has enough information  Since you feed it the two original numbers, it has enough information
3064  to give you a full 360-degree answer.  to give you a full 360-degree answer.
3065    
 @group  
3066  @smallexample  @smallexample
3067    @group
3068  2:  0.89879    1:  116.       3:  116.       2:  116.       1:  180.  2:  0.89879    1:  116.       3:  116.       2:  116.       1:  180.
3069  1:  -0.43837       .          2:  -0.89879   1:  -64.           .  1:  -0.43837       .          2:  -0.89879   1:  -64.           .
3070      .                         1:  0.43837        .      .                         1:  0.43837        .
3071                                    .                                    .
3072    
3073      U U            f T         M-RET M-2 n       f T            -      U U            f T         M-@key{RET} M-2 n       f T            -
 @end smallexample  
3074  @end group  @end group
3075    @end smallexample
3076    
3077  @noindent  @noindent
3078  The resulting angles differ by 180 degrees; in other words, they  The resulting angles differ by 180 degrees; in other words, they
# Line 3196  except that it is the @emph{difference} Line 3093  except that it is the @emph{difference}
3093  @cite{cosh(x)^2 - sinh(x)^2} that always equals one.  @cite{cosh(x)^2 - sinh(x)^2} that always equals one.
3094  Let's try to verify this identity.@refill  Let's try to verify this identity.@refill
3095    
 @group  
3096  @smallexample  @smallexample
3097    @group
3098  2:  -64        2:  -64        2:  -64        2:  9.7192e54  2:  9.7192e54  2:  -64        2:  -64        2:  -64        2:  9.7192e54  2:  9.7192e54
3099  1:  -64        1:  -3.1175e27 1:  9.7192e54  1:  -64        1:  9.7192e54  1:  -64        1:  -3.1175e27 1:  9.7192e54  1:  -64        1:  9.7192e54
3100      .              .              .              .              .      .              .              .              .              .
3101    
3102   64 n RET RET      H C            2 ^            TAB            H S 2 ^   64 n @key{RET} @key{RET}      H C            2 ^            @key{TAB}            H S 2 ^
 @end smallexample  
3103  @end group  @end group
3104    @end smallexample
3105    
3106  @noindent  @noindent
3107  @cindex Roundoff errors, examples  @cindex Roundoff errors, examples
# Line 3228  The logarithm and exponential functions, Line 3125  The logarithm and exponential functions,
3125  @cite{e} normally but use base-10 instead if you use the Hyperbolic  @cite{e} normally but use base-10 instead if you use the Hyperbolic
3126  prefix.  prefix.
3127    
 @group  
3128  @smallexample  @smallexample
3129    @group
3130  1:  1000       1:  6.9077     1:  1000       1:  3  1:  1000       1:  6.9077     1:  1000       1:  3
3131      .              .              .              .      .              .              .              .
3132    
3133      1000           L              U              H L      1000           L              U              H L
 @end smallexample  
3134  @end group  @end group
3135    @end smallexample
3136    
3137  @noindent  @noindent
3138  First, we mistakenly compute a natural logarithm.  Then we undo  First, we mistakenly compute a natural logarithm.  Then we undo
# Line 3244  and compute a common logarithm instead. Line 3141  and compute a common logarithm instead.
3141  The @kbd{B} key computes a general base-@var{b} logarithm for any  The @kbd{B} key computes a general base-@var{b} logarithm for any
3142  value of @var{b}.  value of @var{b}.
3143    
 @group  
3144  @smallexample  @smallexample
3145    @group
3146  2:  1000       1:  3          1:  1000.      2:  1000.      1:  6.9077  2:  1000       1:  3          1:  1000.      2:  1000.      1:  6.9077
3147  1:  10             .              .          1:  2.71828        .  1:  10             .              .          1:  2.71828        .
3148      .                                            .      .                                            .
3149    
3150   1000 RET 10       B              H E            H P            B   1000 @key{RET} 10       B              H E            H P            B
 @end smallexample  
3151  @end group  @end group
3152    @end smallexample
3153    
3154  @noindent  @noindent
3155  Here we first use @kbd{B} to compute the base-10 logarithm, then use  Here we first use @kbd{B} to compute the base-10 logarithm, then use
# Line 3280  The Calculator also has a set of functio Line 3177  The Calculator also has a set of functio
3177  and statistics.  You may be familiar with the @dfn{factorial} function,  and statistics.  You may be familiar with the @dfn{factorial} function,
3178  which computes the product of all the integers up to a given number.  which computes the product of all the integers up to a given number.
3179    
 @group  
3180  @smallexample  @smallexample
3181    @group
3182  1:  100        1:  93326215443...    1:  100.       1:  9.3326e157  1:  100        1:  93326215443...    1:  100.       1:  9.3326e157
3183      .              .                     .              .      .              .                     .              .
3184    
3185      100            !                     U c f          !      100            !                     U c f          !
 @end smallexample  
3186  @end group  @end group
3187    @end smallexample
3188    
3189  @noindent  @noindent
3190  Recall, the @kbd{c f} command converts the integer or fraction at the  Recall, the @kbd{c f} command converts the integer or fraction at the
# Line 3303  factorial function defined in terms of E Line 3200  factorial function defined in terms of E
3200  @cite{gamma(n)}  @cite{gamma(n)}
3201  (which is itself available as the @kbd{f g} command).  (which is itself available as the @kbd{f g} command).
3202    
 @group  
3203  @smallexample  @smallexample
3204    @group
3205  3:  4.         3:  24.               1:  5.5        1:  52.342777847  3:  4.         3:  24.               1:  5.5        1:  52.342777847
3206  2:  4.5        2:  52.3427777847         .              .  2:  4.5        2:  52.3427777847         .              .
3207  1:  5.         1:  120.  1:  5.         1:  120.
3208      .              .      .              .
3209    
3210                     M-3 !              M-0 DEL 5.5       f g                     M-3 !              M-0 @key{DEL} 5.5       f g
 @end smallexample  
3211  @end group  @end group
3212    @end smallexample
3213    
3214  @noindent  @noindent
3215  Here we verify the identity @c{$n! = \Gamma(n+1)$}  Here we verify the identity @c{$n! = \Gamma(n+1)$}
# Line 3331  The @kbd{k} prefix key defines several c Line 3228  The @kbd{k} prefix key defines several c
3228  combinatorics and number theory.  Here we compute the binomial  combinatorics and number theory.  Here we compute the binomial
3229  coefficient 30-choose-20, then determine its prime factorization.  coefficient 30-choose-20, then determine its prime factorization.
3230    
 @group  
3231  @smallexample  @smallexample
3232    @group
3233  2:  30         1:  30045015   1:  [3, 3, 5, 7, 11, 13, 23, 29]  2:  30         1:  30045015   1:  [3, 3, 5, 7, 11, 13, 23, 29]
3234  1:  20             .              .  1:  20             .              .
3235      .      .
3236    
3237   30 RET 20         k c            k f   30 @key{RET} 20         k c            k f
 @end smallexample  
3238  @end group  @end group
3239    @end smallexample
3240    
3241  @noindent  @noindent
3242  You can verify these prime factors by using @kbd{v u} to ``unpack''  You can verify these prime factors by using @kbd{v u} to ``unpack''
# Line 3352  Suppose a program you are writing needs Line 3249  Suppose a program you are writing needs
3249  10000 entries.  It's best to use a prime number as the actual size  10000 entries.  It's best to use a prime number as the actual size
3250  of a hash table.  Calc can compute the next prime number after 10000:  of a hash table.  Calc can compute the next prime number after 10000:
3251    
 @group  
3252  @smallexample  @smallexample
3253    @group
3254  1:  10000      1:  10007      1:  9973  1:  10000      1:  10007      1:  9973
3255      .              .              .      .              .              .
3256    
3257      10000          k n            I k n      10000          k n            I k n
 @end smallexample  
3258  @end group  @end group
3259    @end smallexample
3260    
3261  @noindent  @noindent
3262  Just for kicks we've also computed the next prime @emph{less} than  Just for kicks we've also computed the next prime @emph{less} than
# Line 3396  a vector as a list of objects. Line 3293  a vector as a list of objects.
3293  If you add two vectors, the result is a vector of the sums of the  If you add two vectors, the result is a vector of the sums of the
3294  elements, taken pairwise.  elements, taken pairwise.
3295    
 @group  
3296  @smallexample  @smallexample
3297    @group
3298  1:  [1, 2, 3]     2:  [1, 2, 3]     1:  [8, 8, 3]  1:  [1, 2, 3]     2:  [1, 2, 3]     1:  [8, 8, 3]
3299      .             1:  [7, 6, 0]         .      .             1:  [7, 6, 0]         .
3300                        .                        .
3301    
3302      [1,2,3]  s 1      [7 6 0]  s 2      +      [1,2,3]  s 1      [7 6 0]  s 2      +
 @end smallexample  
3303  @end group  @end group
3304    @end smallexample
3305    
3306  @noindent  @noindent
3307  Note that we can separate the vector elements with either commas or  Note that we can separate the vector elements with either commas or
# Line 3416  If you multiply two vectors, the result Line 3313  If you multiply two vectors, the result
3313  of the elements taken pairwise.  This is called the @dfn{dot product}  of the elements taken pairwise.  This is called the @dfn{dot product}
3314  of the vectors.  of the vectors.
3315    
 @group  
3316  @smallexample  @smallexample
3317    @group
3318  2:  [1, 2, 3]     1:  19  2:  [1, 2, 3]     1:  19
3319  1:  [7, 6, 0]         .  1:  [7, 6, 0]         .
3320      .      .
3321    
3322      r 1 r 2           *      r 1 r 2           *
 @end smallexample  
3323  @end group  @end group
3324    @end smallexample
3325    
3326  @cindex Dot product  @cindex Dot product
3327  The dot product of two vectors is equal to the product of their  The dot product of two vectors is equal to the product of their
# Line 3434  specified point in three-dimensional spa Line 3331  specified point in three-dimensional spa
3331  (absolute value) command can be used to compute the length of a  (absolute value) command can be used to compute the length of a
3332  vector.  vector.
3333    
 @group  
3334  @smallexample  @smallexample
3335    @group
3336  3:  19            3:  19          1:  0.550782    1:  56.579  3:  19            3:  19          1:  0.550782    1:  56.579
3337  2:  [1, 2, 3]     2:  3.741657        .               .  2:  [1, 2, 3]     2:  3.741657        .               .
3338  1:  [7, 6, 0]     1:  9.219544  1:  [7, 6, 0]     1:  9.219544
3339      .                 .      .                 .
3340    
3341      M-RET             M-2 A          * /             I C      M-@key{RET}             M-2 A          * /             I C
 @end smallexample  
3342  @end group  @end group
3343    @end smallexample
3344    
3345  @noindent  @noindent
3346  First we recall the arguments to the dot product command, then  First we recall the arguments to the dot product command, then
# Line 3462  input vectors.  Unlike the dot product, Line 3359  input vectors.  Unlike the dot product,
3359  defined only for three-dimensional vectors.  Let's double-check  defined only for three-dimensional vectors.  Let's double-check
3360  our computation of the angle using the cross product.  our computation of the angle using the cross product.
3361    
 @group  
3362  @smallexample  @smallexample
3363    @group
3364  2:  [1, 2, 3]  3:  [-18, 21, -8]  1:  [-0.52, 0.61, -0.23]  1:  56.579  2:  [1, 2, 3]  3:  [-18, 21, -8]  1:  [-0.52, 0.61, -0.23]  1:  56.579
3365  1:  [7, 6, 0]  2:  [1, 2, 3]          .                         .  1:  [7, 6, 0]  2:  [1, 2, 3]          .                         .
3366      .          1:  [7, 6, 0]      .          1:  [7, 6, 0]
3367                     .                     .
3368    
3369      r 1 r 2        V C  s 3  M-RET    M-2 A * /                 A I S      r 1 r 2        V C  s 3  M-@key{RET}    M-2 A * /                 A I S
 @end smallexample  
3370  @end group  @end group
3371    @end smallexample
3372    
3373  @noindent  @noindent
3374  First we recall the original vectors and compute their cross product,  First we recall the original vectors and compute their cross product,
# Line 3490  If we take the dot product of two perpen Line 3387  If we take the dot product of two perpen
3387  to get zero, since the cosine of 90 degrees is zero.  Let's check  to get zero, since the cosine of 90 degrees is zero.  Let's check
3388  that the cross product is indeed perpendicular to both inputs:  that the cross product is indeed perpendicular to both inputs:
3389    
 @group  
3390  @smallexample  @smallexample
3391    @group
3392  2:  [1, 2, 3]      1:  0          2:  [7, 6, 0]      1:  0  2:  [1, 2, 3]      1:  0          2:  [7, 6, 0]      1:  0
3393  1:  [-18, 21, -8]      .          1:  [-18, 21, -8]      .  1:  [-18, 21, -8]      .          1:  [-18, 21, -8]      .
3394      .                                 .      .                                 .
3395    
3396      r 1 r 3            *          DEL r 2 r 3            *      r 1 r 3            *          @key{DEL} r 2 r 3            *
 @end smallexample  
3397  @end group  @end group
3398    @end smallexample
3399    
3400  @cindex Normalizing a vector  @cindex Normalizing a vector
3401  @cindex Unit vectors  @cindex Unit vectors
# Line 3523  This means you can enter a matrix using Line 3420  This means you can enter a matrix using
3420  also use the semicolon character to enter a matrix.  We'll show  also use the semicolon character to enter a matrix.  We'll show
3421  both methods here:  both methods here:
3422    
 @group  
3423  @smallexample  @smallexample
3424    @group
3425  1:  [ [ 1, 2, 3 ]             1:  [ [ 1, 2, 3 ]  1:  [ [ 1, 2, 3 ]             1:  [ [ 1, 2, 3 ]
3426        [ 4, 5, 6 ] ]                 [ 4, 5, 6 ] ]        [ 4, 5, 6 ] ]                 [ 4, 5, 6 ] ]
3427      .                             .      .                             .
3428    
3429    [[1 2 3] [4 5 6]]             ' [1 2 3; 4 5 6] RET    [[1 2 3] [4 5 6]]             ' [1 2 3; 4 5 6] @key{RET}
 @end smallexample  
3430  @end group  @end group
3431    @end smallexample
3432    
3433  @noindent  @noindent
3434  We'll be using this matrix again, so type @kbd{s 4} to save it now.  We'll be using this matrix again, so type @kbd{s 4} to save it now.
# Line 3549  of the right matrix. Line 3446  of the right matrix.
3446  If we try to duplicate this matrix and multiply it by itself,  If we try to duplicate this matrix and multiply it by itself,
3447  the dimensions are wrong and the multiplication cannot take place:  the dimensions are wrong and the multiplication cannot take place:
3448    
 @group  
3449  @smallexample  @smallexample
3450    @group
3451  1:  [ [ 1, 2, 3 ]   * [ [ 1, 2, 3 ]  1:  [ [ 1, 2, 3 ]   * [ [ 1, 2, 3 ]
3452        [ 4, 5, 6 ] ]     [ 4, 5, 6 ] ]        [ 4, 5, 6 ] ]     [ 4, 5, 6 ] ]
3453      .      .
3454    
3455      RET *      @key{RET} *
 @end smallexample  
3456  @end group  @end group
3457    @end smallexample
3458    
3459  @noindent  @noindent
3460  Though rather hard to read, this is a formula which shows the product  Though rather hard to read, this is a formula which shows the product
# Line 3566  been left in symbolic form. Line 3463  been left in symbolic form.
3463    
3464  We can multiply the matrices if we @dfn{transpose} one of them first.  We can multiply the matrices if we @dfn{transpose} one of them first.
3465    
 @group  
3466  @smallexample  @smallexample
3467    @group
3468  2:  [ [ 1, 2, 3 ]       1:  [ [ 14, 32 ]      1:  [ [ 17, 22, 27 ]  2:  [ [ 1, 2, 3 ]       1:  [ [ 14, 32 ]      1:  [ [ 17, 22, 27 ]
3469        [ 4, 5, 6 ] ]           [ 32, 77 ] ]          [ 22, 29, 36 ]        [ 4, 5, 6 ] ]           [ 32, 77 ] ]          [ 22, 29, 36 ]
3470  1:  [ [ 1, 4 ]              .                       [ 27, 36, 45 ] ]  1:  [ [ 1, 4 ]              .                       [ 27, 36, 45 ] ]
# Line 3575  We can multiply the matrices if we @dfn{ Line 3472  We can multiply the matrices if we @dfn{
3472        [ 3, 6 ] ]        [ 3, 6 ] ]
3473      .      .
3474    
3475      U v t                   *                     U TAB *      U v t                   *                     U @key{TAB} *
 @end smallexample  
3476  @end group  @end group
3477    @end smallexample
3478    
3479  Matrix multiplication is not commutative; indeed, switching the  Matrix multiplication is not commutative; indeed, switching the
3480  order of the operands can even change the dimensions of the result  order of the operands can even change the dimensions of the result
# Line 3588  single row or column depending on which Line 3485  single row or column depending on which
3485  on.  The result is a plain vector which should also be interpreted  on.  The result is a plain vector which should also be interpreted
3486  as a row or column as appropriate.  as a row or column as appropriate.
3487    
 @group  
3488  @smallexample  @smallexample
3489    @group
3490  2:  [ [ 1, 2, 3 ]      1:  [14, 32]  2:  [ [ 1, 2, 3 ]      1:  [14, 32]
3491        [ 4, 5, 6 ] ]        .        [ 4, 5, 6 ] ]        .
3492  1:  [1, 2, 3]  1:  [1, 2, 3]
3493      .      .
3494    
3495      r 4 r 1                *      r 4 r 1                *
 @end smallexample  
3496  @end group  @end group
3497    @end smallexample
3498    
3499  Multiplying in the other order wouldn't work because the number of  Multiplying in the other order wouldn't work because the number of
3500  rows in the matrix is different from the number of elements in the  rows in the matrix is different from the number of elements in the
# Line 3615  diagonal and zeros elsewhere.  It has th Line 3512  diagonal and zeros elsewhere.  It has th
3512  by an identity matrix, on the left or on the right, always produces  by an identity matrix, on the left or on the right, always produces
3513  the original matrix.  the original matrix.
3514    
 @group  
3515  @smallexample  @smallexample
3516    @group
3517  1:  [ [ 1, 2, 3 ]      2:  [ [ 1, 2, 3 ]      1:  [ [ 1, 2, 3 ]  1:  [ [ 1, 2, 3 ]      2:  [ [ 1, 2, 3 ]      1:  [ [ 1, 2, 3 ]
3518        [ 4, 5, 6 ] ]          [ 4, 5, 6 ] ]          [ 4, 5, 6 ] ]        [ 4, 5, 6 ] ]          [ 4, 5, 6 ] ]          [ 4, 5, 6 ] ]
3519      .                  1:  [ [ 1, 0, 0 ]          .      .                  1:  [ [ 1, 0, 0 ]          .
# Line 3624  the original matrix. Line 3521  the original matrix.
3521                               [ 0, 0, 1 ] ]                               [ 0, 0, 1 ] ]
3522                             .                             .
3523    
3524      r 4                    v i 3 RET              *      r 4                    v i 3 @key{RET}              *
 @end smallexample  
3525  @end group  @end group
3526    @end smallexample
3527    
3528  If a matrix is square, it is often possible to find its @dfn{inverse},  If a matrix is square, it is often possible to find its @dfn{inverse},
3529  that is, a matrix which, when multiplied by the original matrix, yields  that is, a matrix which, when multiplied by the original matrix, yields
3530  an identity matrix.  The @kbd{&} (reciprocal) key also computes the  an identity matrix.  The @kbd{&} (reciprocal) key also computes the
3531  inverse of a matrix.  inverse of a matrix.
3532    
 @group  
3533  @smallexample  @smallexample
3534    @group
3535  1:  [ [ 1, 2, 3 ]      1:  [ [   -2.4,     1.2,   -0.2 ]  1:  [ [ 1, 2, 3 ]      1:  [ [   -2.4,     1.2,   -0.2 ]
3536        [ 4, 5, 6 ]            [    2.8,    -1.4,    0.4 ]        [ 4, 5, 6 ]            [    2.8,    -1.4,    0.4 ]
3537        [ 7, 6, 0 ] ]          [ -0.73333, 0.53333, -0.2 ] ]        [ 7, 6, 0 ] ]          [ -0.73333, 0.53333, -0.2 ] ]
3538      .                      .      .                      .
3539    
3540      r 4 r 2 |  s 5         &      r 4 r 2 |  s 5         &
 @end smallexample  
3541  @end group  @end group
3542    @end smallexample
3543    
3544  @noindent  @noindent
3545  The vertical bar @kbd{|} @dfn{concatenates} numbers, vectors, and  The vertical bar @kbd{|} @dfn{concatenates} numbers, vectors, and
# Line 3651  our matrix to make it square. Line 3548  our matrix to make it square.
3548    
3549  We can multiply these two matrices in either order to get an identity.  We can multiply these two matrices in either order to get an identity.
3550    
 @group  
3551  @smallexample  @smallexample
3552    @group
3553  1:  [ [ 1., 0., 0. ]      1:  [ [ 1., 0., 0. ]  1:  [ [ 1., 0., 0. ]      1:  [ [ 1., 0., 0. ]
3554        [ 0., 1., 0. ]            [ 0., 1., 0. ]        [ 0., 1., 0. ]            [ 0., 1., 0. ]
3555        [ 0., 0., 1. ] ]          [ 0., 0., 1. ] ]        [ 0., 0., 1. ] ]          [ 0., 0., 1. ] ]
3556      .                         .      .                         .
3557    
3558      M-RET  *                  U TAB *      M-@key{RET}  *                  U @key{TAB} *
 @end smallexample  
3559  @end group  @end group
3560    @end smallexample
3561    
3562  @cindex Systems of linear equations  @cindex Systems of linear equations
3563  @cindex Linear equations, systems of  @cindex Linear equations, systems of
# Line 3716  $$ Line 3613  $$
3613  We can solve this system of equations by multiplying both sides by the  We can solve this system of equations by multiplying both sides by the
3614  inverse of the matrix.  Calc can do this all in one step:  inverse of the matrix.  Calc can do this all in one step:
3615    
 @group  
3616  @smallexample  @smallexample
3617    @group
3618  2:  [6, 2, 3]          1:  [-12.6, 15.2, -3.93333]  2:  [6, 2, 3]          1:  [-12.6, 15.2, -3.93333]
3619  1:  [ [ 1, 2, 3 ]          .  1:  [ [ 1, 2, 3 ]          .
3620        [ 4, 5, 6 ]        [ 4, 5, 6 ]
# Line 3725  inverse of the matrix.  Calc can do this Line 3622  inverse of the matrix.  Calc can do this
3622      .      .
3623    
3624      [6,2,3] r 5            /      [6,2,3] r 5            /
 @end smallexample  
3625  @end group  @end group
3626    @end smallexample
3627    
3628  @noindent  @noindent
3629  The result is the @cite{[a, b, c]} vector that solves the equations.  The result is the @cite{[a, b, c]} vector that solves the equations.
# Line 3735  inverse.) Line 3632  inverse.)
3632    
3633  Let's verify this solution:  Let's verify this solution:
3634    
 @group  
3635  @smallexample  @smallexample
3636    @group
3637  2:  [ [ 1, 2, 3 ]                1:  [6., 2., 3.]  2:  [ [ 1, 2, 3 ]                1:  [6., 2., 3.]
3638        [ 4, 5, 6 ]                    .        [ 4, 5, 6 ]                    .
3639        [ 7, 6, 0 ] ]        [ 7, 6, 0 ] ]
3640  1:  [-12.6, 15.2, -3.93333]  1:  [-12.6, 15.2, -3.93333]
3641      .      .
3642    
3643      r 5  TAB                         *      r 5  @key{TAB}                         *
 @end smallexample  
3644  @end group  @end group
3645    @end smallexample
3646    
3647  @noindent  @noindent
3648  Note that we had to be careful about the order in which we multiplied  Note that we had to be careful about the order in which we multiplied
# Line 3851  number. Line 3748  number.
3748    
3749  You can pack and unpack stack entries into vectors:  You can pack and unpack stack entries into vectors:
3750    
 @group  
3751  @smallexample  @smallexample
3752    @group
3753  3:  10         1:  [10, 20, 30]     3:  10  3:  10         1:  [10, 20, 30]     3:  10
3754  2:  20             .                2:  20  2:  20             .                2:  20
3755  1:  30                              1:  30  1:  30                              1:  30
3756      .                                   .      .                                   .
3757    
3758                     M-3 v p              v u                     M-3 v p              v u
 @end smallexample  
3759  @end group  @end group
3760    @end smallexample
3761    
3762  You can also build vectors out of consecutive integers, or out  You can also build vectors out of consecutive integers, or out
3763  of many copies of a given value:  of many copies of a given value:
3764    
 @group  
3765  @smallexample  @smallexample
3766    @group
3767  1:  [1, 2, 3, 4]    2:  [1, 2, 3, 4]    2:  [1, 2, 3, 4]  1:  [1, 2, 3, 4]    2:  [1, 2, 3, 4]    2:  [1, 2, 3, 4]
3768      .               1:  17              1:  [17, 17, 17, 17]      .               1:  17              1:  [17, 17, 17, 17]
3769                          .                   .                          .                   .
3770    
3771      v x 4 RET           17                  v b 4 RET      v x 4 @key{RET}           17                  v b 4 @key{RET}
 @end smallexample  
3772  @end group  @end group
3773    @end smallexample
3774    
3775  You can apply an operator to every element of a vector using the  You can apply an operator to every element of a vector using the
3776  @dfn{map} command.  @dfn{map} command.
3777    
 @group  
3778  @smallexample  @smallexample
3779    @group
3780  1:  [17, 34, 51, 68]   1:  [289, 1156, 2601, 4624]  1:  [17, 34, 51, 68]  1:  [17, 34, 51, 68]   1:  [289, 1156, 2601, 4624]  1:  [17, 34, 51, 68]
3781      .                      .                            .      .                      .                            .
3782    
3783      V M *                  2 V M ^                      V M Q      V M *                  2 V M ^                      V M Q
 @end smallexample  
3784  @end group  @end group
3785    @end smallexample
3786    
3787  @noindent  @noindent
3788  In the first step, we multiply the vector of integers by the vector  In the first step, we multiply the vector of integers by the vector
# Line 3903  You can also @dfn{reduce} a binary opera Line 3800  You can also @dfn{reduce} a binary opera
3800  For example, reducing @samp{*} computes the product of all the  For example, reducing @samp{*} computes the product of all the
3801  elements in the vector:  elements in the vector:
3802    
 @group  
3803  @smallexample  @smallexample
3804    @group
3805  1:  123123     1:  [3, 7, 11, 13, 41]      1:  123123  1:  123123     1:  [3, 7, 11, 13, 41]      1:  123123
3806      .              .                           .      .              .                           .
3807    
3808      123123         k f                         V R *      123123         k f                         V R *
 @end smallexample  
3809  @end group  @end group
3810    @end smallexample
3811    
3812  @noindent  @noindent
3813  In this example, we decompose 123123 into its prime factors, then  In this example, we decompose 123123 into its prime factors, then
# Line 3919  multiply those factors together again to Line 3816  multiply those factors together again to
3816  We could compute a dot product ``by hand'' using mapping and  We could compute a dot product ``by hand'' using mapping and
3817  reduction:  reduction:
3818    
 @group  
3819  @smallexample  @smallexample
3820    @group
3821  2:  [1, 2, 3]     1:  [7, 12, 0]     1:  19  2:  [1, 2, 3]     1:  [7, 12, 0]     1:  19
3822  1:  [7, 6, 0]         .                  .  1:  [7, 6, 0]         .                  .
3823      .      .
3824    
3825      r 1 r 2           V M *              V R +      r 1 r 2           V M *              V R +
 @end smallexample  
3826  @end group  @end group
3827    @end smallexample
3828    
3829  @noindent  @noindent
3830  Recalling two vectors from the previous section, we compute the  Recalling two vectors from the previous section, we compute the
# Line 3938  A slight variant of vector reduction is Line 3835  A slight variant of vector reduction is
3835  @kbd{V U}.  This produces a vector of the intermediate results from  @kbd{V U}.  This produces a vector of the intermediate results from
3836  a corresponding reduction.  Here we compute a table of factorials:  a corresponding reduction.  Here we compute a table of factorials:
3837    
 @group  
3838  @smallexample  @smallexample
3839    @group
3840  1:  [1, 2, 3, 4, 5, 6]    1:  [1, 2, 6, 24, 120, 720]  1:  [1, 2, 3, 4, 5, 6]    1:  [1, 2, 6, 24, 120, 720]
3841      .                         .      .                         .
3842    
3843      v x 6 RET                 V U *      v x 6 @key{RET}                 V U *
 @end smallexample  
3844  @end group  @end group
3845    @end smallexample
3846    
3847  Calc allows vectors to grow as large as you like, although it gets  Calc allows vectors to grow as large as you like, although it gets
3848  rather slow if vectors have more than about a hundred elements.  rather slow if vectors have more than about a hundred elements.
# Line 3954  for display, not calculating on them.  T Line 3851  for display, not calculating on them.  T
3851  (if your computer is very fast you may need to substitute a larger  (if your computer is very fast you may need to substitute a larger
3852  vector size).  vector size).
3853    
 @group  
3854  @smallexample  @smallexample
3855    @group
3856  1:  [1, 2, 3, 4, ...      1:  [2, 3, 4, 5, ...  1:  [1, 2, 3, 4, ...      1:  [2, 3, 4, 5, ...
3857      .                         .      .                         .
3858    
3859      v x 500 RET               1 V M +      v x 500 @key{RET}               1 V M +
 @end smallexample  
3860  @end group  @end group
3861    @end smallexample
3862    
3863  Now press @kbd{v .} (the letter @kbd{v}, then a period) and try the  Now press @kbd{v .} (the letter @kbd{v}, then a period) and try the
3864  experiment again.  In @kbd{v .} mode, long vectors are displayed  experiment again.  In @kbd{v .} mode, long vectors are displayed
3865  ``abbreviated'' like this:  ``abbreviated'' like this:
3866    
 @group  
3867  @smallexample  @smallexample
3868    @group
3869  1:  [1, 2, 3, ..., 500]   1:  [2, 3, 4, ..., 501]  1:  [1, 2, 3, ..., 500]   1:  [2, 3, 4, ..., 501]
3870      .                         .      .                         .
3871    
3872      v x 500 RET               1 V M +      v x 500 @key{RET}               1 V M +
 @end smallexample  
3873  @end group  @end group
3874    @end smallexample
3875    
3876  @noindent  @noindent
3877  (where now the @samp{...} is actually part of the Calc display).  (where now the @samp{...} is actually part of the Calc display).
# Line 4032  the manual and find this table there.  ( Line 3929  the manual and find this table there.  (
3929    
3930  Position the cursor at the upper-left corner of this table, just  Position the cursor at the upper-left corner of this table, just
3931  to the left of the @cite{1.34}.  Press @kbd{C-@@} to set the mark.  to the left of the @cite{1.34}.  Press @kbd{C-@@} to set the mark.
3932  (On your system this may be @kbd{C-2}, @kbd{C-SPC}, or @kbd{NUL}.)  (On your system this may be @kbd{C-2}, @kbd{C-@key{SPC}}, or @kbd{NUL}.)
3933  Now position the cursor to the lower-right, just after the @cite{1.354}.  Now position the cursor to the lower-right, just after the @cite{1.354}.
3934  You have now defined this region as an Emacs ``rectangle.''  Still  You have now defined this region as an Emacs ``rectangle.''  Still
3935  in the Info buffer, type @kbd{M-# r}.  This command  in the Info buffer, type @kbd{M-# r}.  This command
3936  (@code{calc-grab-rectangle}) will pop you back into the Calculator, with  (@code{calc-grab-rectangle}) will pop you back into the Calculator, with
3937  the contents of the rectangle you specified in the form of a matrix.@refill  the contents of the rectangle you specified in the form of a matrix.@refill
3938    
 @group  
3939  @smallexample  @smallexample
3940    @group
3941  1:  [ [ 1.34, 0.234 ]  1:  [ [ 1.34, 0.234 ]
3942        [ 1.41, 0.298 ]        [ 1.41, 0.298 ]
3943        @dots{}        @dots{}
 @end smallexample  
3944  @end group  @end group
3945    @end smallexample
3946    
3947  @noindent  @noindent
3948  (You may wish to use @kbd{v .} mode to abbreviate the display of this  (You may wish to use @kbd{v .} mode to abbreviate the display of this
# Line 4056  transpose this matrix into a pair of row Line 3953  transpose this matrix into a pair of row
3953  just a vector of vectors.  So we can unpack the matrix into a pair  just a vector of vectors.  So we can unpack the matrix into a pair
3954  of row vectors on the stack.  of row vectors on the stack.
3955    
 @group  
3956  @smallexample  @smallexample
3957    @group
3958  1:  [ [ 1.34,  1.41,  1.49,  ... ]     2:  [1.34, 1.41, 1.49, ... ]  1:  [ [ 1.34,  1.41,  1.49,  ... ]     2:  [1.34, 1.41, 1.49, ... ]
3959        [ 0.234, 0.298, 0.402, ... ] ]   1:  [0.234, 0.298, 0.402, ... ]        [ 0.234, 0.298, 0.402, ... ] ]   1:  [0.234, 0.298, 0.402, ... ]
3960      .                                      .      .                                      .
3961    
3962      v t                                    v u      v t                                    v u
 @end smallexample  
3963  @end group  @end group
3964    @end smallexample
3965    
3966  @noindent  @noindent
3967  Let's store these in quick variables 1 and 2, respectively.  Let's store these in quick variables 1 and 2, respectively.
3968    
 @group  
3969  @smallexample  @smallexample
3970    @group
3971  1:  [1.34, 1.41, 1.49, ... ]        .  1:  [1.34, 1.41, 1.49, ... ]        .
3972      .      .
3973    
3974      t 2                             t 1      t 2                             t 1
 @end smallexample  
3975  @end group  @end group
3976    @end smallexample
3977    
3978  @noindent  @noindent
3979  (Recall that @kbd{t 2} is a variant of @kbd{s 2} that removes the  (Recall that @kbd{t 2} is a variant of @kbd{s 2} that removes the
# Line 4104  While there is an actual @code{sum} func Line 4001  While there is an actual @code{sum} func
4001  sum a vector using a simple reduction.  First, let's compute the four  sum a vector using a simple reduction.  First, let's compute the four
4002  different sums that this formula uses.  different sums that this formula uses.
4003    
 @group  
4004  @smallexample  @smallexample
4005    @group
4006  1:  41.63                 1:  98.0003  1:  41.63                 1:  98.0003
4007      .                         .      .                         .
4008    
4009   r 1 V R +   t 3           r 1 2 V M ^ V R +   t 4   r 1 V R +   t 3           r 1 2 V M ^ V R +   t 4
4010    
 @end smallexample  
4011  @end group  @end group
4012    @end smallexample
4013  @noindent  @noindent
 @group  
4014  @smallexample  @smallexample
4015    @group
4016  1:  13.613                1:  33.36554  1:  13.613                1:  33.36554
4017      .                         .      .                         .
4018    
4019   r 2 V R +   t 5           r 1 r 2 V M * V R +   t 6   r 2 V R +   t 5           r 1 r 2 V M * V R +   t 6
 @end smallexample  
4020  @end group  @end group
4021    @end smallexample
4022    
4023  @ifinfo  @ifinfo
4024  @noindent  @noindent
# Line 4139  $\sum x y$.) Line 4036  $\sum x y$.)
4036  Finally, we also need @cite{N}, the number of data points.  This is just  Finally, we also need @cite{N}, the number of data points.  This is just
4037  the length of either of our lists.  the length of either of our lists.
4038    
 @group  
4039  @smallexample  @smallexample
4040    @group
4041  1:  19  1:  19
4042      .      .
4043    
4044   r 1 v l   t 7   r 1 v l   t 7
 @end smallexample  
4045  @end group  @end group
4046    @end smallexample
4047    
4048  @noindent  @noindent
4049  (That's @kbd{v} followed by a lower-case @kbd{l}.)  (That's @kbd{v} followed by a lower-case @kbd{l}.)
4050    
4051  Now we grind through the formula:  Now we grind through the formula:
4052    
 @group  
4053  @smallexample  @smallexample
4054    @group
4055  1:  633.94526  2:  633.94526  1:  67.23607  1:  633.94526  2:  633.94526  1:  67.23607
4056      .          1:  566.70919      .      .          1:  566.70919      .
4057                     .                     .
4058    
4059   r 7 r 6 *      r 3 r 5 *         -   r 7 r 6 *      r 3 r 5 *         -
4060    
 @end smallexample  
4061  @end group  @end group
4062    @end smallexample
4063  @noindent  @noindent
 @group  
4064  @smallexample  @smallexample
4065    @group
4066  2:  67.23607   3:  67.23607   2:  67.23607   1:  0.52141679  2:  67.23607   3:  67.23607   2:  67.23607   1:  0.52141679
4067  1:  1862.0057  2:  1862.0057  1:  128.9488       .  1:  1862.0057  2:  1862.0057  1:  128.9488       .
4068      .          1:  1733.0569      .      .          1:  1733.0569      .
4069                     .                     .
4070    
4071   r 7 r 4 *      r 3 2 ^           -              /   t 8   r 7 r 4 *      r 3 2 ^           -              /   t 8
 @end smallexample  
4072  @end group  @end group
4073    @end smallexample
4074    
4075  That gives us the slope @cite{m}.  The y-intercept @cite{b} can now  That gives us the slope @cite{m}.  The y-intercept @cite{b} can now
4076  be found with the simple formula,  be found with the simple formula,
# Line 4191  $$ b = {\sum y - m \sum x \over N} $$ Line 4088  $$ b = {\sum y - m \sum x \over N} $$
4088  \vskip10pt  \vskip10pt
4089  @end tex  @end tex
4090    
 @group  
4091  @smallexample  @smallexample
4092    @group
4093  1:  13.613     2:  13.613     1:  -8.09358   1:  -0.425978  1:  13.613     2:  13.613     1:  -8.09358   1:  -0.425978
4094      .          1:  21.70658       .              .      .          1:  21.70658       .              .
4095                     .                     .
4096    
4097     r 5            r 8 r 3 *       -              r 7 /   t 9     r 5            r 8 r 3 *       -              r 7 /   t 9
 @end smallexample  
4098  @end group  @end group
4099    @end smallexample
4100    
4101  Let's ``plot'' this straight line approximation, @c{$y \approx m x + b$}  Let's ``plot'' this straight line approximation, @c{$y \approx m x + b$}
4102  @cite{m x + b}, and compare it with the original data.@refill  @cite{m x + b}, and compare it with the original data.@refill
4103    
 @group  
4104  @smallexample  @smallexample
4105    @group
4106  1:  [0.699, 0.735, ... ]    1:  [0.273, 0.309, ... ]  1:  [0.699, 0.735, ... ]    1:  [0.273, 0.309, ... ]
4107      .                           .      .                           .
4108    
4109      r 1 r 8 *                   r 9 +    s 0      r 1 r 8 *                   r 9 +    s 0
 @end smallexample  
4110  @end group  @end group
4111    @end smallexample
4112    
4113  @noindent  @noindent
4114  Notice that multiplying a vector by a constant, and adding a constant  Notice that multiplying a vector by a constant, and adding a constant
# Line 4222  we've just been doing geometry in 19-dim Line 4119  we've just been doing geometry in 19-dim
4119  We can subtract this vector from our original @cite{y} vector to get  We can subtract this vector from our original @cite{y} vector to get
4120  a feel for the error of our fit.  Let's find the maximum error:  a feel for the error of our fit.  Let's find the maximum error:
4121    
 @group  
4122  @smallexample  @smallexample
4123    @group
4124  1:  [0.0387, 0.0112, ... ]   1:  [0.0387, 0.0112, ... ]   1:  0.0897  1:  [0.0387, 0.0112, ... ]   1:  [0.0387, 0.0112, ... ]   1:  0.0897
4125      .                            .                            .      .                            .                            .
4126    
4127      r 2 -                        V M A                        V R X      r 2 -                        V M A                        V R X
 @end smallexample  
4128  @end group  @end group
4129    @end smallexample
4130    
4131  @noindent  @noindent
4132  First we compute a vector of differences, then we take the absolute  First we compute a vector of differences, then we take the absolute
# Line 4248  GNUPLOT 3.0, the following instructions Line 4145  GNUPLOT 3.0, the following instructions
4145  kind of display you have.  Some GNUPLOT 2.0, non-X-windows systems  kind of display you have.  Some GNUPLOT 2.0, non-X-windows systems
4146  may require additional steps to view the graphs.)  may require additional steps to view the graphs.)
4147    
4148  Let's start by plotting the original data.  Recall the ``@i{x}'' and ``@i{y}''  Let's start by plotting the original data.  Recall the ``@var{x}'' and ``@var{y}''
4149  vectors onto the stack and press @kbd{g f}.  This ``fast'' graphing  vectors onto the stack and press @kbd{g f}.  This ``fast'' graphing
4150  command does everything you need to do for simple, straightforward  command does everything you need to do for simple, straightforward
4151  plotting of data.  plotting of data.
4152    
 @group  
4153  @smallexample  @smallexample
4154    @group
4155  2:  [1.34, 1.41, 1.49, ... ]  2:  [1.34, 1.41, 1.49, ... ]
4156  1:  [0.234, 0.298, 0.402, ... ]  1:  [0.234, 0.298, 0.402, ... ]
4157      .      .
4158    
4159      r 1 r 2    g f      r 1 r 2    g f
 @end smallexample  
4160  @end group  @end group
4161    @end smallexample
4162    
4163  If all goes well, you will shortly get a new window containing a graph  If all goes well, you will shortly get a new window containing a graph
4164  of the data.  (If not, contact your GNUPLOT or Calc installer to find  of the data.  (If not, contact your GNUPLOT or Calc installer to find
# Line 4272  Press @kbd{q} when you are done viewing Line 4169  Press @kbd{q} when you are done viewing
4169    
4170  Next, let's add the line we got from our least-squares fit:  Next, let's add the line we got from our least-squares fit:
4171    
 @group  
4172  @smallexample  @smallexample
4173    @group
4174  2:  [1.34, 1.41, 1.49, ... ]  2:  [1.34, 1.41, 1.49, ... ]
4175  1:  [0.273, 0.309, 0.351, ... ]  1:  [0.273, 0.309, 0.351, ... ]
4176      .      .
4177    
4178      DEL r 0    g a  g p      @key{DEL} r 0    g a  g p
 @end smallexample  
4179  @end group  @end group
4180    @end smallexample
4181    
4182  It's not very useful to get symbols to mark the data points on this  It's not very useful to get symbols to mark the data points on this
4183  second curve; you can type @kbd{g S g p} to remove them.  Type @kbd{g q}  second curve; you can type @kbd{g S g p} to remove them.  Type @kbd{g q}
# Line 4328  always comes out to zero.  Let's verify Line 4225  always comes out to zero.  Let's verify
4225  for \cite{n=6}.  for \cite{n=6}.
4226  @end tex  @end tex
4227    
 @group  
4228  @smallexample  @smallexample
4229    @group
4230  1:  [1, 2, 3, 4, 5, 6, 7]     1:  [0, 1, 2, 3, 4, 5, 6]  1:  [1, 2, 3, 4, 5, 6, 7]     1:  [0, 1, 2, 3, 4, 5, 6]
4231      .                             .      .                             .
4232    
4233      v x 7 RET                     1 -      v x 7 @key{RET}                     1 -
4234    
 @end smallexample  
4235  @end group  @end group
4236    @end smallexample
4237  @noindent  @noindent
 @group  
4238  @smallexample  @smallexample
4239    @group
4240  1:  [1, -6, 15, -20, 15, -6, 1]          1:  0  1:  [1, -6, 15, -20, 15, -6, 1]          1:  0
4241      .                                        .      .                                        .
4242    
4243      V M ' (-1)^$ choose(6,$) RET             V R +      V M ' (-1)^$ choose(6,$) @key{RET}             V R +
 @end smallexample  
4244  @end group  @end group
4245    @end smallexample
4246    
4247  The @kbd{V M '} command prompts you to enter any algebraic expression  The @kbd{V M '} command prompts you to enter any algebraic expression
4248  to define the function to map over the vector.  The symbol @samp{$}  to define the function to map over the vector.  The symbol @samp{$}
# Line 4354  The Calculator applies this formula to e Line 4251  The Calculator applies this formula to e
4251  substituting each element's value for the @samp{$} sign(s) in turn.  substituting each element's value for the @samp{$} sign(s) in turn.
4252    
4253  To define a two-argument function, use @samp{$$} for the first  To define a two-argument function, use @samp{$$} for the first
4254  argument and @samp{$} for the second:  @kbd{V M ' $$-$ RET} is  argument and @samp{$} for the second:  @kbd{V M ' $$-$ @key{RET}} is
4255  equivalent to @kbd{V M -}.  This is analogous to regular algebraic  equivalent to @kbd{V M -}.  This is analogous to regular algebraic
4256  entry, where @samp{$$} would refer to the next-to-top stack entry  entry, where @samp{$$} would refer to the next-to-top stack entry
4257  and @samp{$} would refer to the top stack entry, and @kbd{' $$-$ RET}  and @samp{$} would refer to the top stack entry, and @kbd{' $$-$ @key{RET}}
4258  would act exactly like @kbd{-}.  would act exactly like @kbd{-}.
4259    
4260  Notice that the @kbd{V M '} command has recorded two things in the  Notice that the @kbd{V M '} command has recorded two things in the
# Line 4414  leave 1 on the stack if it is, or 0 if i Line 4311  leave 1 on the stack if it is, or 0 if i
4311  like the following diagram.  (You may wish to use the @kbd{v /}  like the following diagram.  (You may wish to use the @kbd{v /}
4312  command to enable multi-line display of vectors.)  command to enable multi-line display of vectors.)
4313    
 @group  
4314  @smallexample  @smallexample
4315    @group
4316  1:  [ [1],  1:  [ [1],
4317        [1, 2],        [1, 2],
4318        [1, 2, 3],        [1, 2, 3],
4319        [1, 2, 3, 4],        [1, 2, 3, 4],
4320        [1, 2, 3, 4, 5],        [1, 2, 3, 4, 5],
4321        [1, 2, 3, 4, 5, 6] ]        [1, 2, 3, 4, 5, 6] ]
 @end smallexample  
4322  @end group  @end group
4323    @end smallexample
4324    
4325  @noindent  @noindent
4326  @xref{List Answer 6, 6}. (@bullet{})  @xref{List Answer 6, 6}. (@bullet{})
4327    
4328  (@bullet{}) @strong{Exercise 7.}  Build the following list of lists.  (@bullet{}) @strong{Exercise 7.}  Build the following list of lists.
4329    
 @group  
4330  @smallexample  @smallexample
4331    @group
4332  1:  [ [0],  1:  [ [0],
4333        [1, 2],        [1, 2],
4334        [3, 4, 5],        [3, 4, 5],
4335        [6, 7, 8, 9],        [6, 7, 8, 9],
4336        [10, 11, 12, 13, 14],        [10, 11, 12, 13, 14],
4337        [15, 16, 17, 18, 19, 20] ]        [15, 16, 17, 18, 19, 20] ]
 @end smallexample  
4338  @end group  @end group
4339    @end smallexample
4340    
4341  @noindent  @noindent
4342  @xref{List Answer 7, 7}. (@bullet{})  @xref{List Answer 7, 7}. (@bullet{})
# Line 4476  happened?  How would you do this test? Line 4373  happened?  How would you do this test?
4373  is @c{$\pi$}  is @c{$\pi$}
4374  @cite{pi}.  The area of the @c{$2\times2$}  @cite{pi}.  The area of the @c{$2\times2$}
4375  @asis{2x2} square that encloses that  @asis{2x2} square that encloses that
4376  circle is 4.  So if we throw @i{N} darts at random points in the square,  circle is 4.  So if we throw @var{n} darts at random points in the square,
4377  about @c{$\pi/4$}  about @c{$\pi/4$}
4378  @cite{pi/4} of them will land inside the circle.  This gives us  @cite{pi/4} of them will land inside the circle.  This gives us
4379  an entertaining way to estimate the value of @c{$\pi$}  an entertaining way to estimate the value of @c{$\pi$}
# Line 4549  the mathematical concept of real numbers Line 4446  the mathematical concept of real numbers
4446  and are susceptible to roundoff error.  Calc also supports @dfn{fractions},  and are susceptible to roundoff error.  Calc also supports @dfn{fractions},
4447  which can exactly represent any rational number.  which can exactly represent any rational number.
4448    
 @group  
4449  @smallexample  @smallexample
4450    @group
4451  1:  3628800    2:  3628800    1:  518400:7   1:  518414:7   1:  7:518414  1:  3628800    2:  3628800    1:  518400:7   1:  518414:7   1:  7:518414
4452      .          1:  49             .              .              .      .          1:  49             .              .              .
4453                     .                     .
4454    
4455      10 !           49 RET         :              2 +            &      10 !           49 @key{RET}         :              2 +            &
 @end smallexample  
4456  @end group  @end group
4457    @end smallexample
4458    
4459  @noindent  @noindent
4460  The @kbd{:} command divides two integers to get a fraction; @kbd{/}  The @kbd{:} command divides two integers to get a fraction; @kbd{/}
# Line 4569  fraction beginning with 49. Line 4466  fraction beginning with 49.
4466  You can convert between floating-point and fractional format using  You can convert between floating-point and fractional format using
4467  @kbd{c f} and @kbd{c F}:  @kbd{c f} and @kbd{c F}:
4468    
 @group  
4469  @smallexample  @smallexample
4470    @group
4471  1:  1.35027217629e-5    1:  7:518414  1:  1.35027217629e-5    1:  7:518414
4472      .                       .      .                       .
4473    
4474      c f                     c F      c f                     c F
 @end smallexample  
4475  @end group  @end group
4476    @end smallexample
4477    
4478  The @kbd{c F} command replaces a floating-point number with the  The @kbd{c F} command replaces a floating-point number with the
4479  ``simplest'' fraction whose floating-point representation is the  ``simplest'' fraction whose floating-point representation is the
4480  same, to within the current precision.  same, to within the current precision.
4481    
 @group  
4482  @smallexample  @smallexample
4483    @group
4484  1:  3.14159265359   1:  1146408:364913   1:  3.1416   1:  355:113  1:  3.14159265359   1:  1146408:364913   1:  3.1416   1:  355:113
4485      .                   .                    .            .      .                   .                    .            .
4486    
4487      P                   c F      DEL       p 5 RET P      c F      P                   c F      @key{DEL}       p 5 @key{RET} P      c F
 @end smallexample  
4488  @end group  @end group
4489    @end smallexample
4490    
4491  (@bullet{}) @strong{Exercise 1.}  A calculation has produced the  (@bullet{}) @strong{Exercise 1.}  A calculation has produced the
4492  result 1.26508260337.  You suspect it is the square root of the  result 1.26508260337.  You suspect it is the square root of the
# Line 4599  to allow for roundoff error!)  @xref{Typ Line 4496  to allow for roundoff error!)  @xref{Typ
4496    
4497  @dfn{Complex numbers} can be stored in both rectangular and polar form.  @dfn{Complex numbers} can be stored in both rectangular and polar form.
4498    
 @group  
4499  @smallexample  @smallexample
4500    @group
4501  1:  -9     1:  (0, 3)    1:  (3; 90.)   1:  (6; 90.)   1:  (2.4495; 45.)  1:  -9     1:  (0, 3)    1:  (3; 90.)   1:  (6; 90.)   1:  (2.4495; 45.)
4502      .          .             .              .              .      .          .             .              .              .
4503    
4504      9 n        Q             c p            2 *            Q      9 n        Q             c p            2 *            Q
 @end smallexample  
4505  @end group  @end group
4506    @end smallexample
4507    
4508  @noindent  @noindent
4509  The square root of @i{-9} is by default rendered in rectangular form  The square root of @i{-9} is by default rendered in rectangular form
# Line 4622  also write @samp{-inf} for minus infinit Line 4519  also write @samp{-inf} for minus infinit
4519  real number.  The word @code{inf} can only be input using  real number.  The word @code{inf} can only be input using
4520  algebraic entry.  algebraic entry.
4521    
 @group  
4522  @smallexample  @smallexample
4523    @group
4524  2:  inf        2:  -inf       2:  -inf       2:  -inf       1:  nan  2:  inf        2:  -inf       2:  -inf       2:  -inf       1:  nan
4525  1:  -17        1:  -inf       1:  -inf       1:  inf            .  1:  -17        1:  -inf       1:  -inf       1:  inf            .
4526      .              .              .              .      .              .              .              .
4527    
4528  ' inf RET 17 n     *  RET         72 +           A              +  ' inf @key{RET} 17 n     *  @key{RET}         72 +           A              +
 @end smallexample  
4529  @end group  @end group
4530    @end smallexample
4531    
4532  @noindent  @noindent
4533  Since infinity is infinitely large, multiplying it by any finite  Since infinity is infinitely large, multiplying it by any finite
# Line 4651  Dividing by zero is normally treated as Line 4548  Dividing by zero is normally treated as
4548  Calc to write an answer in terms of infinity by pressing @kbd{m i}  Calc to write an answer in terms of infinity by pressing @kbd{m i}
4549  to turn on ``infinite mode.''  to turn on ``infinite mode.''
4550    
 @group  
4551  @smallexample  @smallexample
4552    @group
4553  3:  nan        2:  nan        2:  nan        2:  nan        1:  nan  3:  nan        2:  nan        2:  nan        2:  nan        1:  nan
4554  2:  1          1:  1 / 0      1:  uinf       1:  uinf           .  2:  1          1:  1 / 0      1:  uinf       1:  uinf           .
4555  1:  0              .              .              .  1:  0              .              .              .
4556      .      .
4557    
4558    1 RET 0          /       m i    U /            17 n *         +    1 @key{RET} 0          /       m i    U /            17 n *         +
 @end smallexample  
4559  @end group  @end group
4560    @end smallexample
4561    
4562  @noindent  @noindent
4563  Dividing by zero normally is left unevaluated, but after @kbd{m i}  Dividing by zero normally is left unevaluated, but after @kbd{m i}
# Line 4694  a complex number?  Can it stand for infi Line 4591  a complex number?  Can it stand for infi
4591  @dfn{HMS forms} represent a value in terms of hours, minutes, and  @dfn{HMS forms} represent a value in terms of hours, minutes, and
4592  seconds.  seconds.
4593    
 @group  
4594  @smallexample  @smallexample
4595    @group
4596  1:  2@@ 30' 0"     1:  3@@ 30' 0"     2:  3@@ 30' 0"     1:  2.  1:  2@@ 30' 0"     1:  3@@ 30' 0"     2:  3@@ 30' 0"     1:  2.
4597      .                 .             1:  1@@ 45' 0."        .      .                 .             1:  1@@ 45' 0."        .
4598                                          .                                          .
4599    
4600    2@@ 30' RET          1 +               RET 2 /           /    2@@ 30' @key{RET}          1 +               @key{RET} 2 /           /
 @end smallexample  
4601  @end group  @end group
4602    @end smallexample
4603    
4604  HMS forms can also be used to hold angles in degrees, minutes, and  HMS forms can also be used to hold angles in degrees, minutes, and
4605  seconds.  seconds.
4606    
 @group  
4607  @smallexample  @smallexample
4608    @group
4609  1:  0.5        1:  26.56505   1:  26@@ 33' 54.18"    1:  0.44721  1:  0.5        1:  26.56505   1:  26@@ 33' 54.18"    1:  0.44721
4610      .              .              .                     .      .              .              .                     .
4611    
4612      0.5            I T            c h                   S      0.5            I T            c h                   S
 @end smallexample  
4613  @end group  @end group
4614    @end smallexample
4615    
4616  @noindent  @noindent
4617  First we convert the inverse tangent of 0.5 to degrees-minutes-seconds  First we convert the inverse tangent of 0.5 to degrees-minutes-seconds
# Line 4732  A @dfn{date form} represents a date, or Line 4629  A @dfn{date form} represents a date, or
4629  be entered using algebraic entry.  Date forms are surrounded by  be entered using algebraic entry.  Date forms are surrounded by
4630  @samp{< >} symbols; most standard formats for dates are recognized.  @samp{< >} symbols; most standard formats for dates are recognized.
4631    
 @group  
4632  @smallexample  @smallexample
4633    @group
4634  2:  <Sun Jan 13, 1991>                    1:  2.25  2:  <Sun Jan 13, 1991>                    1:  2.25
4635  1:  <6:00pm Thu Jan 10, 1991>                 .  1:  <6:00pm Thu Jan 10, 1991>                 .
4636      .      .
4637    
4638  ' <13 Jan 1991>, <1/10/91, 6pm> RET           -  ' <13 Jan 1991>, <1/10/91, 6pm> @key{RET}           -
 @end smallexample  
4639  @end group  @end group
4640    @end smallexample
4641    
4642  @noindent  @noindent
4643  In this example, we enter two dates, then subtract to find the  In this example, we enter two dates, then subtract to find the
# Line 4748  number of days between them.  It is also Line 4645  number of days between them.  It is also
4645  HMS form or a number (of days) to a date form to get another  HMS form or a number (of days) to a date form to get another
4646  date form.  date form.
4647    
 @group  
4648  @smallexample  @smallexample
4649    @group
4650  1:  <4:45:59pm Mon Jan 14, 1991>     1:  <2:50:59am Thu Jan 17, 1991>  1:  <4:45:59pm Mon Jan 14, 1991>     1:  <2:50:59am Thu Jan 17, 1991>
4651      .                                    .      .                                    .
4652    
4653      t N                                  2 + 10@@ 5' +      t N                                  2 + 10@@ 5' +
 @end smallexample  
4654  @end group  @end group
4655    @end smallexample
4656    
4657  @c [fix-ref Date Arithmetic]  @c [fix-ref Date Arithmetic]
4658  @noindent  @noindent
# Line 4781  error of 1 meter, and 8 meters tall, wit Line 4678  error of 1 meter, and 8 meters tall, wit
4678  meters.  What is the slope of a line from here to the top of the  meters.  What is the slope of a line from here to the top of the
4679  pole, and what is the equivalent angle in degrees?  pole, and what is the equivalent angle in degrees?
4680    
 @group  
4681  @smallexample  @smallexample
4682    @group
4683  1:  8 +/- 0.2    2:  8 +/- 0.2   1:  0.266 +/- 0.011   1:  14.93 +/- 0.594  1:  8 +/- 0.2    2:  8 +/- 0.2   1:  0.266 +/- 0.011   1:  14.93 +/- 0.594
4684      .            1:  30 +/- 1        .                     .      .            1:  30 +/- 1        .                     .
4685                       .                       .
4686    
4687      8 p .2 RET       30 p 1          /                     I T      8 p .2 @key{RET}       30 p 1          /                     I T
 @end smallexample  
4688  @end group  @end group
4689    @end smallexample
4690    
4691  @noindent  @noindent
4692  This means that the angle is about 15 degrees, and, assuming our  This means that the angle is about 15 degrees, and, assuming our
# Line 4811  you exact bounds on an answer.  Suppose Line 4708  you exact bounds on an answer.  Suppose
4708  our telephone pole is definitely between 28 and 31 meters away,  our telephone pole is definitely between 28 and 31 meters away,
4709  and that it is between 7.7 and 8.1 meters tall.  and that it is between 7.7 and 8.1 meters tall.
4710    
 @group  
4711  @smallexample  @smallexample
4712    @group
4713  1:  [7.7 .. 8.1]  2:  [7.7 .. 8.1]  1:  [0.24 .. 0.28]  1:  [13.9 .. 16.1]  1:  [7.7 .. 8.1]  2:  [7.7 .. 8.1]  1:  [0.24 .. 0.28]  1:  [13.9 .. 16.1]
4714      .             1:  [28 .. 31]        .                   .      .             1:  [28 .. 31]        .                   .
4715                        .                        .
4716    
4717    [ 7.7 .. 8.1 ]    [ 28 .. 31 ]        /                   I T    [ 7.7 .. 8.1 ]    [ 28 .. 31 ]        /                   I T
 @end smallexample  
4718  @end group  @end group
4719    @end smallexample
4720    
4721  @noindent  @noindent
4722  If our bounds were correct, then the angle to the top of the pole  If our bounds were correct, then the angle to the top of the pole
# Line 4833  parentheses instead of square brackets. Line 4730  parentheses instead of square brackets.
4730  which is inclusive (``closed'') on one end and exclusive (``open'') on  which is inclusive (``closed'') on one end and exclusive (``open'') on
4731  the other.  the other.
4732    
 @group  
4733  @smallexample  @smallexample
4734    @group
4735  1:  [1 .. 10)    1:  (0.1 .. 1]   2:  (0.1 .. 1]   1:  (0.2 .. 3)  1:  [1 .. 10)    1:  (0.1 .. 1]   2:  (0.1 .. 1]   1:  (0.2 .. 3)
4736      .                .            1:  [2 .. 3)         .      .                .            1:  [2 .. 3)         .
4737                                        .                                        .
4738    
4739    [ 1 .. 10 )        &              [ 2 .. 3 )         *    [ 1 .. 10 )        &              [ 2 .. 3 )         *
 @end smallexample  
4740  @end group  @end group
4741    @end smallexample
4742    
4743  @noindent  @noindent
4744  The Calculator automatically keeps track of which end values should  The Calculator automatically keeps track of which end values should
# Line 4856  zero)?  What about @samp{@w{1 /} @w{(-10 Line 4753  zero)?  What about @samp{@w{1 /} @w{(-10
4753  @xref{Types Answer 8, 8}. (@bullet{})  @xref{Types Answer 8, 8}. (@bullet{})
4754    
4755  (@bullet{}) @strong{Exercise 9.}  Two easy ways of squaring a number  (@bullet{}) @strong{Exercise 9.}  Two easy ways of squaring a number
4756  are @kbd{RET *} and @w{@kbd{2 ^}}.  Normally these produce the same  are @kbd{@key{RET} *} and @w{@kbd{2 ^}}.  Normally these produce the same
4757  answer.  Would you expect this still to hold true for interval forms?  answer.  Would you expect this still to hold true for interval forms?
4758  If not, which of these will result in a larger interval?  If not, which of these will result in a larger interval?
4759  @xref{Types Answer 9, 9}. (@bullet{})  @xref{Types Answer 9, 9}. (@bullet{})
4760    
4761  A @dfn{modulo form} is used for performing arithmetic modulo @i{M}.  A @dfn{modulo form} is used for performing arithmetic modulo @var{m}.
4762  For example, arithmetic involving time is generally done modulo 12  For example, arithmetic involving time is generally done modulo 12
4763  or 24 hours.  or 24 hours.
4764    
 @group  
4765  @smallexample  @smallexample
4766    @group
4767  1:  17 mod 24    1:  3 mod 24     1:  21 mod 24    1:  9 mod 24  1:  17 mod 24    1:  3 mod 24     1:  21 mod 24    1:  9 mod 24
4768      .                .                .                .      .                .                .                .
4769    
4770      17 M 24 RET      10 +             n                5 /      17 M 24 @key{RET}      10 +             n                5 /
 @end smallexample  
4771  @end group  @end group
4772    @end smallexample
4773    
4774  @noindent  @noindent
4775  In this last step, Calc has found a new number which, when multiplied  In this last step, Calc has found a new number which, when multiplied
4776  by 5 modulo 24, produces the original number, 21.  If @i{M} is prime  by 5 modulo 24, produces the original number, 21.  If @var{m} is prime
4777  it is always possible to find such a number.  For non-prime @i{M}  it is always possible to find such a number.  For non-prime @var{m}
4778  like 24, it is only sometimes possible.  like 24, it is only sometimes possible.
4779    
 @group  
4780  @smallexample  @smallexample
4781    @group
4782  1:  10 mod 24    1:  16 mod 24    1:  1000000...   1:  16  1:  10 mod 24    1:  16 mod 24    1:  1000000...   1:  16
4783      .                .                .                .      .                .                .                .
4784    
4785      10 M 24 RET      100 ^            10 RET 100 ^     24 %      10 M 24 @key{RET}      100 ^            10 @key{RET} 100 ^     24 %
 @end smallexample  
4786  @end group  @end group
4787    @end smallexample
4788    
4789  @noindent  @noindent
4790  These two calculations get the same answer, but the first one is  These two calculations get the same answer, but the first one is
# Line 4910  modulo forms, or as the phase part of a Line 4807  modulo forms, or as the phase part of a
4807  For example, the @code{calc-time} command pushes the current time  For example, the @code{calc-time} command pushes the current time
4808  of day on the stack as an HMS/modulo form.  of day on the stack as an HMS/modulo form.
4809    
 @group  
4810  @smallexample  @smallexample
4811    @group
4812  1:  17@@ 34' 45" mod 24@@ 0' 0"     1:  6@@ 22' 15" mod 24@@ 0' 0"  1:  17@@ 34' 45" mod 24@@ 0' 0"     1:  6@@ 22' 15" mod 24@@ 0' 0"
4813      .                                 .      .                                 .
4814    
4815      x time RET                        n      x time @key{RET}                        n
 @end smallexample  
4816  @end group  @end group
4817    @end smallexample
4818    
4819  @noindent  @noindent
4820  This calculation tells me it is six hours and 22 minutes until midnight.  This calculation tells me it is six hours and 22 minutes until midnight.
# Line 4940  application of algebraic expressions, wh Line 4837  application of algebraic expressions, wh
4837  suggestive names like @samp{cm} and @samp{in} to represent units  suggestive names like @samp{cm} and @samp{in} to represent units
4838  like centimeters and inches.  like centimeters and inches.
4839    
 @group  
4840  @smallexample  @smallexample
4841    @group
4842  1:  2 in        1:  5.08 cm      1:  0.027778 fath   1:  0.0508 m  1:  2 in        1:  5.08 cm      1:  0.027778 fath   1:  0.0508 m
4843      .               .                .                   .      .               .                .                   .
4844    
4845      ' 2in RET       u c cm RET       u c fath RET        u b      ' 2in @key{RET}       u c cm @key{RET}       u c fath @key{RET}        u b
 @end smallexample  
4846  @end group  @end group
4847    @end smallexample
4848    
4849  @noindent  @noindent
4850  We enter the quantity ``2 inches'' (actually an algebraic expression  We enter the quantity ``2 inches'' (actually an algebraic expression
# Line 4955  which means two times the variable @samp Line 4852  which means two times the variable @samp
4852  first to centimeters, then to fathoms, then finally to ``base'' units,  first to centimeters, then to fathoms, then finally to ``base'' units,
4853  which in this case means meters.  which in this case means meters.
4854    
 @group  
4855  @smallexample  @smallexample
4856    @group
4857  1:  9 acre     1:  3 sqrt(acre)   1:  190.84 m   1:  190.84 m + 30 cm  1:  9 acre     1:  3 sqrt(acre)   1:  190.84 m   1:  190.84 m + 30 cm
4858      .              .                  .              .      .              .                  .              .
4859    
4860   ' 9 acre RET      Q                  u s            ' $+30 cm RET   ' 9 acre @key{RET}      Q                  u s            ' $+30 cm @key{RET}
4861    
 @end smallexample  
4862  @end group  @end group
4863    @end smallexample
4864  @noindent  @noindent
 @group  
4865  @smallexample  @smallexample
4866    @group
4867  1:  191.14 m     1:  36536.3046 m^2    1:  365363046 cm^2  1:  191.14 m     1:  36536.3046 m^2    1:  365363046 cm^2
4868      .                .                     .      .                .                     .
4869    
4870      u s              2 ^                   u c cgs      u s              2 ^                   u c cgs
 @end smallexample  
4871  @end group  @end group
4872    @end smallexample
4873    
4874  @noindent  @noindent
4875  Since units expressions are really just formulas, taking the square  Since units expressions are really just formulas, taking the square
# Line 4987  as its standard unit of length. Line 4884  as its standard unit of length.
4884    
4885  There is a wide variety of units defined in the Calculator.  There is a wide variety of units defined in the Calculator.
4886    
 @group  
4887  @smallexample  @smallexample
4888    @group
4889  1:  55 mph     1:  88.5139 kph   1:   88.5139 km / hr   1:  8.201407e-8 c  1:  55 mph     1:  88.5139 kph   1:   88.5139 km / hr   1:  8.201407e-8 c
4890      .              .                  .                     .      .              .                  .                     .
4891    
4892   ' 55 mph RET      u c kph RET        u c km/hr RET         u c c RET   ' 55 mph @key{RET}      u c kph @key{RET}        u c km/hr @key{RET}         u c c @key{RET}
 @end smallexample  
4893  @end group  @end group
4894    @end smallexample
4895    
4896  @noindent  @noindent
4897  We express a speed first in miles per hour, then in kilometers per  We express a speed first in miles per hour, then in kilometers per
# Line 5008  units there is no difference, but temper Line 4905  units there is no difference, but temper
4905  as well as a scale factor and so there must be two explicit commands  as well as a scale factor and so there must be two explicit commands
4906  for them.  for them.
4907    
 @group  
4908  @smallexample  @smallexample
4909    @group
4910  1:  20 degF       1:  11.1111 degC     1:  -20:3 degC    1:  -6.666 degC  1:  20 degF       1:  11.1111 degC     1:  -20:3 degC    1:  -6.666 degC
4911      .                 .                    .                 .      .                 .                    .                 .
4912    
4913    ' 20 degF RET       u c degC RET         U u t degC RET    c f    ' 20 degF @key{RET}       u c degC @key{RET}         U u t degC @key{RET}    c f
 @end smallexample  
4914  @end group  @end group
4915    @end smallexample
4916    
4917  @noindent  @noindent
4918  First we convert a change of 20 degrees Fahrenheit into an equivalent  First we convert a change of 20 degrees Fahrenheit into an equivalent
# Line 5029  Then @kbd{u c} and @kbd{u t} will prompt Line 4926  Then @kbd{u c} and @kbd{u t} will prompt
4926  When you use this method, you're responsible for remembering which  When you use this method, you're responsible for remembering which
4927  numbers are in which units:  numbers are in which units:
4928    
 @group  
4929  @smallexample  @smallexample
4930    @group
4931  1:  55         1:  88.5139              1:  8.201407e-8  1:  55         1:  88.5139              1:  8.201407e-8
4932      .              .                        .      .              .                        .
4933    
4934      55             u c mph RET kph RET      u c km/hr RET c RET      55             u c mph @key{RET} kph @key{RET}      u c km/hr @key{RET} c @key{RET}
 @end smallexample  
4935  @end group  @end group
4936    @end smallexample
4937    
4938  To see a complete list of built-in units, type @kbd{u v}.  Press  To see a complete list of built-in units, type @kbd{u v}.  Press
4939  @w{@kbd{M-# c}} again to re-enter the Calculator when you're done looking  @w{@kbd{M-# c}} again to re-enter the Calculator when you're done looking
# Line 5079  If you enter a formula in algebraic mode Line 4976  If you enter a formula in algebraic mode
4976  the formula itself is pushed onto the stack.  You can manipulate  the formula itself is pushed onto the stack.  You can manipulate
4977  formulas as regular data objects.  formulas as regular data objects.
4978    
 @group  
4979  @smallexample  @smallexample
4980    @group
4981  1:  2 x^2 - 6       1:  6 - 2 x^2       1:  (6 - 2 x^2) (3 x^2 + y)  1:  2 x^2 - 6       1:  6 - 2 x^2       1:  (6 - 2 x^2) (3 x^2 + y)
4982      .                   .                   .      .                   .                   .
4983    
4984      ' 2x^2-6 RET        n                   ' 3x^2+y RET *      ' 2x^2-6 @key{RET}        n                   ' 3x^2+y @key{RET} *
 @end smallexample  
4985  @end group  @end group
4986    @end smallexample
4987    
4988  (@bullet{}) @strong{Exercise 1.}  Do @kbd{' x RET Q 2 ^} and  (@bullet{}) @strong{Exercise 1.}  Do @kbd{' x @key{RET} Q 2 ^} and
4989  @kbd{' x RET 2 ^ Q} both wind up with the same result (@samp{x})?  @kbd{' x @key{RET} 2 ^ Q} both wind up with the same result (@samp{x})?
4990  Why or why not?  @xref{Algebra Answer 1, 1}. (@bullet{})  Why or why not?  @xref{Algebra Answer 1, 1}. (@bullet{})
4991    
4992  There are also commands for doing common algebraic operations on  There are also commands for doing common algebraic operations on
4993  formulas.  Continuing with the formula from the last example,  formulas.  Continuing with the formula from the last example,
4994    
 @group  
4995  @smallexample  @smallexample
4996    @group
4997  1:  18 x^2 + 6 y - 6 x^4 - 2 x^2 y    1:  (18 - 2 y) x^2 - 6 x^4 + 6 y  1:  18 x^2 + 6 y - 6 x^4 - 2 x^2 y    1:  (18 - 2 y) x^2 - 6 x^4 + 6 y
4998      .                                     .      .                                     .
4999    
5000      a x                                   a c x RET      a x                                   a c x @key{RET}
 @end smallexample  
5001  @end group  @end group
5002    @end smallexample
5003    
5004  @noindent  @noindent
5005  First we ``expand'' using the distributive law, then we ``collect''  First we ``expand'' using the distributive law, then we ``collect''
# Line 5111  terms involving like powers of @cite{x}. Line 5008  terms involving like powers of @cite{x}.
5008  Let's find the value of this expression when @cite{x} is 2 and @cite{y}  Let's find the value of this expression when @cite{x} is 2 and @cite{y}
5009  is one-half.  is one-half.
5010    
 @group  
5011  @smallexample  @smallexample
5012    @group
5013  1:  17 x^2 - 6 x^4 + 3      1:  -25  1:  17 x^2 - 6 x^4 + 3      1:  -25
5014      .                           .      .                           .
5015    
5016      1:2 s l y RET               2 s l x RET      1:2 s l y @key{RET}               2 s l x @key{RET}
 @end smallexample  
5017  @end group  @end group
5018    @end smallexample
5019    
5020  @noindent  @noindent
5021  The @kbd{s l} command means ``let''; it takes a number from the top of  The @kbd{s l} command means ``let''; it takes a number from the top of
# Line 5129  back to its original value, if any. Line 5026  back to its original value, if any.
5026    
5027  (An earlier exercise in this tutorial involved storing a value in the  (An earlier exercise in this tutorial involved storing a value in the
5028  variable @code{x}; if this value is still there, you will have to  variable @code{x}; if this value is still there, you will have to
5029  unstore it with @kbd{s u x RET} before the above example will work  unstore it with @kbd{s u x @key{RET}} before the above example will work
5030  properly.)  properly.)
5031    
5032  @cindex Maximum of a function using Calculus  @cindex Maximum of a function using Calculus
# Line 5140  values of @cite{x} for which the derivat Line 5037  values of @cite{x} for which the derivat
5037  derivative of the function at that value of @cite{x} is negative,  derivative of the function at that value of @cite{x} is negative,
5038  the function has a local maximum there.  the function has a local maximum there.
5039    
 @group  
5040  @smallexample  @smallexample
5041    @group
5042  1:  17 x^2 - 6 x^4 + 3      1:  34 x - 24 x^3  1:  17 x^2 - 6 x^4 + 3      1:  34 x - 24 x^3
5043      .                           .      .                           .
5044    
5045      U DEL  s 1                  a d x RET   s 2      U @key{DEL}  s 1                  a d x @key{RET}   s 2
 @end smallexample  
5046  @end group  @end group
5047    @end smallexample
5048    
5049  @noindent  @noindent
5050  Well, the derivative is clearly zero when @cite{x} is zero.  To find  Well, the derivative is clearly zero when @cite{x} is zero.  To find
5051  the other root(s), let's divide through by @cite{x} and then solve:  the other root(s), let's divide through by @cite{x} and then solve:
5052    
 @group  
5053  @smallexample  @smallexample
5054    @group
5055  1:  (34 x - 24 x^3) / x    1:  34 x / x - 24 x^3 / x    1:  34 - 24 x^2  1:  (34 x - 24 x^3) / x    1:  34 x / x - 24 x^3 / x    1:  34 - 24 x^2
5056      .                          .                            .      .                          .                            .
5057    
5058      ' x RET /                  a x                          a s      ' x @key{RET} /                  a x                          a s
5059    
 @end smallexample  
5060  @end group  @end group
5061    @end smallexample
5062  @noindent  @noindent
 @group  
5063  @smallexample  @smallexample
5064    @group
5065  1:  34 - 24 x^2 = 0        1:  x = 1.19023  1:  34 - 24 x^2 = 0        1:  x = 1.19023
5066      .                          .      .                          .
5067    
5068      0 a =  s 3                 a S x RET      0 a =  s 3                 a S x @key{RET}
 @end smallexample  
5069  @end group  @end group
5070    @end smallexample
5071    
5072  @noindent  @noindent
5073  Notice the use of @kbd{a s} to ``simplify'' the formula.  When the  Notice the use of @kbd{a s} to ``simplify'' the formula.  When the
# Line 5179  default algebraic simplifications don't Line 5076  default algebraic simplifications don't
5076    
5077  Now we compute the second derivative and plug in our values of @cite{x}:  Now we compute the second derivative and plug in our values of @cite{x}:
5078    
 @group  
5079  @smallexample  @smallexample
5080    @group
5081  1:  1.19023        2:  1.19023         2:  1.19023  1:  1.19023        2:  1.19023         2:  1.19023
5082      .              1:  34 x - 24 x^3   1:  34 - 72 x^2      .              1:  34 x - 24 x^3   1:  34 - 72 x^2
5083                         .                   .                         .                   .
5084    
5085      a .                r 2                 a d x RET s 4      a .                r 2                 a d x @key{RET} s 4
 @end smallexample  
5086  @end group  @end group
5087    @end smallexample
5088    
5089  @noindent  @noindent
5090  (The @kbd{a .} command extracts just the righthand side of an equation.  (The @kbd{a .} command extracts just the righthand side of an equation.
5091  Another method would have been to use @kbd{v u} to unpack the equation  Another method would have been to use @kbd{v u} to unpack the equation
5092  @w{@samp{x = 1.19}} to @samp{x} and @samp{1.19}, then use @kbd{M-- M-2 DEL}  @w{@samp{x = 1.19}} to @samp{x} and @samp{1.19}, then use @kbd{M-- M-2 @key{DEL}}
5093  to delete the @samp{x}.)  to delete the @samp{x}.)
5094    
 @group  
5095  @smallexample  @smallexample
5096    @group
5097  2:  34 - 72 x^2   1:  -68.         2:  34 - 72 x^2     1:  34  2:  34 - 72 x^2   1:  -68.         2:  34 - 72 x^2     1:  34
5098  1:  1.19023           .            1:  0                   .  1:  1.19023           .            1:  0                   .
5099      .                                  .      .                                  .
5100    
5101      TAB               s l x RET        U DEL 0             s l x RET      @key{TAB}               s l x @key{RET}        U @key{DEL} 0             s l x @key{RET}
 @end smallexample  
5102  @end group  @end group
5103    @end smallexample
5104    
5105  @noindent  @noindent
5106  The first of these second derivatives is negative, so we know the function  The first of these second derivatives is negative, so we know the function
# Line 5218  arbitrary sign (as occurs in the quadrat Line 5115  arbitrary sign (as occurs in the quadrat
5115  If it needs an arbitrary integer, it picks zero.  We can get a full  If it needs an arbitrary integer, it picks zero.  We can get a full
5116  solution by pressing @kbd{H} (the Hyperbolic flag) before @kbd{a S}.  solution by pressing @kbd{H} (the Hyperbolic flag) before @kbd{a S}.
5117    
 @group  
5118  @smallexample  @smallexample
5119    @group
5120  1:  34 - 24 x^2 = 0    1:  x = 1.19023 s1      1:  x = -1.19023  1:  34 - 24 x^2 = 0    1:  x = 1.19023 s1      1:  x = -1.19023
5121      .                      .                       .      .                      .                       .
5122    
5123      r 3                    H a S x RET  s 5        1 n  s l s1 RET      r 3                    H a S x @key{RET}  s 5        1 n  s l s1 @key{RET}
 @end smallexample  
5124  @end group  @end group
5125    @end smallexample
5126    
5127  @noindent  @noindent
5128  Calc has invented the variable @samp{s1} to represent an unknown sign;  Calc has invented the variable @samp{s1} to represent an unknown sign;
# Line 5237  negative, answer, so @cite{x = -1.19023} Line 5134  negative, answer, so @cite{x = -1.19023}
5134  To find the actual maximum value, we must plug our two values of @cite{x}  To find the actual maximum value, we must plug our two values of @cite{x}
5135  into the original formula.  into the original formula.
5136    
 @group  
5137  @smallexample  @smallexample
5138    @group
5139  2:  17 x^2 - 6 x^4 + 3    1:  24.08333 s1^2 - 12.04166 s1^4 + 3  2:  17 x^2 - 6 x^4 + 3    1:  24.08333 s1^2 - 12.04166 s1^4 + 3
5140  1:  x = 1.19023 s1            .  1:  x = 1.19023 s1            .
5141      .      .
5142    
5143      r 1 r 5                   s l RET      r 1 r 5                   s l @key{RET}
 @end smallexample  
5144  @end group  @end group
5145    @end smallexample
5146    
5147  @noindent  @noindent
5148  (Here we see another way to use @kbd{s l}; if its input is an equation  (Here we see another way to use @kbd{s l}; if its input is an equation
# Line 5255  like an assignment to that variable if y Line 5152  like an assignment to that variable if y
5152  It's clear that this will have the same value for either sign of  It's clear that this will have the same value for either sign of
5153  @code{s1}, but let's work it out anyway, just for the exercise:  @code{s1}, but let's work it out anyway, just for the exercise:
5154    
 @group  
5155  @smallexample  @smallexample
5156    @group
5157  2:  [-1, 1]              1:  [15.04166, 15.04166]  2:  [-1, 1]              1:  [15.04166, 15.04166]
5158  1:  24.08333 s1^2 ...        .  1:  24.08333 s1^2 ...        .
5159      .      .
5160    
5161    [ 1 n , 1 ] TAB            V M $ RET    [ 1 n , 1 ] @key{TAB}            V M $ @key{RET}
 @end smallexample  
5162  @end group  @end group
5163    @end smallexample
5164    
5165  @noindent  @noindent
5166  Here we have used a vector mapping operation to evaluate the function  Here we have used a vector mapping operation to evaluate the function
# Line 5301  like @samp{sqrt(5)} that can't be evalua Line 5198  like @samp{sqrt(5)} that can't be evalua
5198  symbolic form rather than giving a floating-point approximate answer.  symbolic form rather than giving a floating-point approximate answer.
5199  Fraction mode (@kbd{m f}) is also useful when doing algebra.  Fraction mode (@kbd{m f}) is also useful when doing algebra.
5200    
 @group  
5201  @smallexample  @smallexample
5202    @group
5203  2:  34 x - 24 x^3        2:  34 x - 24 x^3  2:  34 x - 24 x^3        2:  34 x - 24 x^3
5204  1:  34 x - 24 x^3        1:  [sqrt(51) / 6, sqrt(51) / -6, 0]  1:  34 x - 24 x^3        1:  [sqrt(51) / 6, sqrt(51) / -6, 0]
5205      .                        .      .                        .
5206    
5207      r 2  RET     m s  m f    a P x RET      r 2  @key{RET}     m s  m f    a P x @key{RET}
 @end smallexample  
5208  @end group  @end group
5209    @end smallexample
5210    
5211  One more mode that makes reading formulas easier is ``Big mode.''  One more mode that makes reading formulas easier is ``Big mode.''
5212    
 @group  
5213  @smallexample  @smallexample
5214    @group
5215                 3                 3
5216  2:  34 x - 24 x  2:  34 x - 24 x
5217    
# Line 5326  One more mode that makes reading formula Line 5223  One more mode that makes reading formula
5223      .      .
5224    
5225      d B      d B
 @end smallexample  
5226  @end group  @end group
5227    @end smallexample
5228    
5229  Here things like powers, square roots, and quotients and fractions  Here things like powers, square roots, and quotients and fractions
5230  are displayed in a two-dimensional pictorial form.  Calc has other  are displayed in a two-dimensional pictorial form.  Calc has other
5231  language modes as well, such as C mode, FORTRAN mode, and @TeX{} mode.  language modes as well, such as C mode, FORTRAN mode, and @TeX{} mode.
5232    
 @group  
5233  @smallexample  @smallexample
5234    @group
5235  2:  34*x - 24*pow(x, 3)               2:  34*x - 24*x**3  2:  34*x - 24*pow(x, 3)               2:  34*x - 24*x**3
5236  1:  @{sqrt(51) / 6, sqrt(51) / -6, 0@}  1:  /sqrt(51) / 6, sqrt(51) / -6, 0/  1:  @{sqrt(51) / 6, sqrt(51) / -6, 0@}  1:  /sqrt(51) / 6, sqrt(51) / -6, 0/
5237      .                                     .      .                                     .
5238    
5239      d C                                   d F      d C                                   d F
5240    
 @end smallexample  
5241  @end group  @end group
5242    @end smallexample
5243  @noindent  @noindent
 @group  
5244  @smallexample  @smallexample
5245    @group
5246  3:  34 x - 24 x^3  3:  34 x - 24 x^3
5247  2:  [@{\sqrt@{51@} \over 6@}, @{\sqrt@{51@} \over -6@}, 0]  2:  [@{\sqrt@{51@} \over 6@}, @{\sqrt@{51@} \over -6@}, 0]
5248  1:  @{2 \over 3@} \sqrt@{5@}  1:  @{2 \over 3@} \sqrt@{5@}
5249      .      .
5250    
5251      d T   ' 2 \sqrt@{5@} \over 3 RET      d T   ' 2 \sqrt@{5@} \over 3 @key{RET}
 @end smallexample  
5252  @end group  @end group
5253    @end smallexample
5254    
5255  @noindent  @noindent
5256  As you can see, language modes affect both entry and display of  As you can see, language modes affect both entry and display of
# Line 5375  are shown in normal mode.) Line 5272  are shown in normal mode.)
5272  What is the area under the portion of this curve from @cite{x = 1} to @cite{2}?  What is the area under the portion of this curve from @cite{x = 1} to @cite{2}?
5273  This is simply the integral of the function:  This is simply the integral of the function:
5274    
 @group  
5275  @smallexample  @smallexample
5276    @group
5277  1:  17 x^2 - 6 x^4 + 3     1:  5.6666 x^3 - 1.2 x^5 + 3 x  1:  17 x^2 - 6 x^4 + 3     1:  5.6666 x^3 - 1.2 x^5 + 3 x
5278      .                          .      .                          .
5279    
5280      r 1                        a i x      r 1                        a i x
 @end smallexample  
5281  @end group  @end group
5282    @end smallexample
5283    
5284  @noindent  @noindent
5285  We want to evaluate this at our two values for @cite{x} and subtract.  We want to evaluate this at our two values for @cite{x} and subtract.
5286  One way to do it is again with vector mapping and reduction:  One way to do it is again with vector mapping and reduction:
5287    
 @group  
5288  @smallexample  @smallexample
5289    @group
5290  2:  [2, 1]            1:  [12.93333, 7.46666]    1:  5.46666  2:  [2, 1]            1:  [12.93333, 7.46666]    1:  5.46666
5291  1:  5.6666 x^3 ...        .                          .  1:  5.6666 x^3 ...        .                          .
5292    
5293     [ 2 , 1 ] TAB          V M $ RET                  V R -     [ 2 , 1 ] @key{TAB}          V M $ @key{RET}                  V R -
 @end smallexample  
5294  @end group  @end group
5295    @end smallexample
5296    
5297  (@bullet{}) @strong{Exercise 3.}  Find the integral from 1 to @cite{y}  (@bullet{}) @strong{Exercise 3.}  Find the integral from 1 to @cite{y}
5298  of @c{$x \sin \pi x$}  of @c{$x \sin \pi x$}
# Line 5407  Calc's integrator can do many simple int Line 5304  Calc's integrator can do many simple int
5304  others are beyond its capabilities.  Suppose we wish to find the area  others are beyond its capabilities.  Suppose we wish to find the area
5305  under the curve @c{$\sin x \ln x$}  under the curve @c{$\sin x \ln x$}
5306  @cite{sin(x) ln(x)} over the same range of @cite{x}.  If  @cite{sin(x) ln(x)} over the same range of @cite{x}.  If
5307  you entered this formula and typed @kbd{a i x RET} (don't bother to try  you entered this formula and typed @kbd{a i x @key{RET}} (don't bother to try
5308  this), Calc would work for a long time but would be unable to find a  this), Calc would work for a long time but would be unable to find a
5309  solution.  In fact, there is no closed-form solution to this integral.  solution.  In fact, there is no closed-form solution to this integral.
5310  Now what do we do?  Now what do we do?
# Line 5419  to do this by hand using vector mapping Line 5316  to do this by hand using vector mapping
5316  slow, though, since the sine and logarithm functions take a long time.  slow, though, since the sine and logarithm functions take a long time.
5317  We can save some time by reducing the working precision.  We can save some time by reducing the working precision.
5318    
 @group  
5319  @smallexample  @smallexample
5320    @group
5321  3:  10                  1:  [1, 1.1, 1.2,  ...  , 1.8, 1.9]  3:  10                  1:  [1, 1.1, 1.2,  ...  , 1.8, 1.9]
5322  2:  1                       .  2:  1                       .
5323  1:  0.1  1:  0.1
5324      .      .
5325    
5326   10 RET 1 RET .1 RET        C-u v x   10 @key{RET} 1 @key{RET} .1 @key{RET}        C-u v x
 @end smallexample  
5327  @end group  @end group
5328    @end smallexample
5329    
5330  @noindent  @noindent
5331  (Note that we have used the extended version of @kbd{v x}; we could  (Note that we have used the extended version of @kbd{v x}; we could
5332  also have used plain @kbd{v x} as follows:  @kbd{v x 10 RET 9 + .1 *}.)  also have used plain @kbd{v x} as follows:  @kbd{v x 10 @key{RET} 9 + .1 *}.)
5333    
 @group  
5334  @smallexample  @smallexample
5335    @group
5336  2:  [1, 1.1, ... ]              1:  [0., 0.084941, 0.16993, ... ]  2:  [1, 1.1, ... ]              1:  [0., 0.084941, 0.16993, ... ]
5337  1:  sin(x) ln(x)                    .  1:  sin(x) ln(x)                    .
5338      .      .
5339    
5340      ' sin(x) ln(x) RET  s 1    m r  p 5 RET   V M $ RET      ' sin(x) ln(x) @key{RET}  s 1    m r  p 5 @key{RET}   V M $ @key{RET}
5341    
 @end smallexample  
5342  @end group  @end group
5343    @end smallexample
5344  @noindent  @noindent
 @group  
5345  @smallexample  @smallexample
5346    @group
5347  1:  3.4195     0.34195  1:  3.4195     0.34195
5348      .          .      .          .
5349    
5350      V R +      0.1 *      V R +      0.1 *
 @end smallexample  
5351  @end group  @end group
5352    @end smallexample
5353    
5354  @noindent  @noindent
5355  (If you got wildly different results, did you remember to switch  (If you got wildly different results, did you remember to switch
# Line 5468  is the same for every box.) Line 5365  is the same for every box.)
5365  The true value of this integral turns out to be about 0.374, so  The true value of this integral turns out to be about 0.374, so
5366  we're not doing too well.  Let's try another approach.  we're not doing too well.  Let's try another approach.
5367    
 @group  
5368  @smallexample  @smallexample
5369    @group
5370  1:  sin(x) ln(x)    1:  0.84147 x - 0.84147 + 0.11957 (x - 1)^2 - ...  1:  sin(x) ln(x)    1:  0.84147 x - 0.84147 + 0.11957 (x - 1)^2 - ...
5371      .                   .      .                   .
5372    
5373      r 1                 a t x=1 RET 4 RET      r 1                 a t x=1 @key{RET} 4 @key{RET}
 @end smallexample  
5374  @end group  @end group
5375    @end smallexample
5376    
5377  @noindent  @noindent
5378  Here we have computed the Taylor series expansion of the function  Here we have computed the Taylor series expansion of the function
5379  about the point @cite{x=1}.  We can now integrate this polynomial  about the point @cite{x=1}.  We can now integrate this polynomial
5380  approximation, since polynomials are easy to integrate.  approximation, since polynomials are easy to integrate.
5381    
 @group  
5382  @smallexample  @smallexample
5383    @group
5384  1:  0.42074 x^2 + ...    1:  [-0.0446, -0.42073]      1:  0.3761  1:  0.42074 x^2 + ...    1:  [-0.0446, -0.42073]      1:  0.3761
5385      .                        .                            .      .                        .                            .
5386    
5387      a i x RET            [ 2 , 1 ] TAB  V M $ RET         V R -      a i x @key{RET}            [ 2 , 1 ] @key{TAB}  V M $ @key{RET}         V R -
 @end smallexample  
5388  @end group  @end group
5389    @end smallexample
5390    
5391  @noindent  @noindent
5392  Better!  By increasing the precision and/or asking for more terms  Better!  By increasing the precision and/or asking for more terms
# Line 5577  that you can use to define your own alge Line 5474  that you can use to define your own alge
5474    
5475  Suppose we want to simplify this trigonometric formula:  Suppose we want to simplify this trigonometric formula:
5476    
 @group  
5477  @smallexample  @smallexample
5478    @group
5479  1:  1 / cos(x) - sin(x) tan(x)  1:  1 / cos(x) - sin(x) tan(x)
5480      .      .
5481    
5482      ' 1/cos(x) - sin(x) tan(x) RET   s 1      ' 1/cos(x) - sin(x) tan(x) @key{RET}   s 1
 @end smallexample  
5483  @end group  @end group
5484    @end smallexample
5485    
5486  @noindent  @noindent
5487  If we were simplifying this by hand, we'd probably replace the  If we were simplifying this by hand, we'd probably replace the
# Line 5595  rules just for practice. Line 5492  rules just for practice.
5492    
5493  Rewrite rules are written with the @samp{:=} symbol.  Rewrite rules are written with the @samp{:=} symbol.
5494    
 @group  
5495  @smallexample  @smallexample
5496    @group
5497  1:  1 / cos(x) - sin(x)^2 / cos(x)  1:  1 / cos(x) - sin(x)^2 / cos(x)
5498      .      .
5499    
5500      a r tan(a) := sin(a)/cos(a) RET      a r tan(a) := sin(a)/cos(a) @key{RET}
 @end smallexample  
5501  @end group  @end group
5502    @end smallexample
5503    
5504  @noindent  @noindent
5505  (The ``assignment operator'' @samp{:=} has several uses in Calc.  All  (The ``assignment operator'' @samp{:=} has several uses in Calc.  All
# Line 5625  mix this in with the rest of the origina Line 5522  mix this in with the rest of the origina
5522    
5523  To merge over a common denominator, we can use another simple rule:  To merge over a common denominator, we can use another simple rule:
5524    
 @group  
5525  @smallexample  @smallexample
5526    @group
5527  1:  (1 - sin(x)^2) / cos(x)  1:  (1 - sin(x)^2) / cos(x)
5528      .      .
5529    
5530      a r a/x + b/x := (a+b)/x RET      a r a/x + b/x := (a+b)/x @key{RET}
 @end smallexample  
5531  @end group  @end group
5532    @end smallexample
5533    
5534  This rule points out several interesting features of rewrite patterns.  This rule points out several interesting features of rewrite patterns.
5535  First, if a meta-variable appears several times in a pattern, it must  First, if a meta-variable appears several times in a pattern, it must
# Line 5665  that the rule @samp{sin(x)^2 := 1 - cos( Line 5562  that the rule @samp{sin(x)^2 := 1 - cos(
5562  latter rule has a more general pattern so it will work in many other  latter rule has a more general pattern so it will work in many other
5563  situations, too.  situations, too.
5564    
 @group  
5565  @smallexample  @smallexample
5566    @group
5567  1:  (1 + cos(x)^2 - 1) / cos(x)           1:  cos(x)  1:  (1 + cos(x)^2 - 1) / cos(x)           1:  cos(x)
5568      .                                         .      .                                         .
5569    
5570      a r sin(x)^2 := 1 - cos(x)^2 RET          a s      a r sin(x)^2 := 1 - cos(x)^2 @key{RET}          a s
 @end smallexample  
5571  @end group  @end group
5572    @end smallexample
5573    
5574  You may ask, what's the point of using the most general rule if you  You may ask, what's the point of using the most general rule if you
5575  have to type it in every time anyway?  The answer is that Calc allows  have to type it in every time anyway?  The answer is that Calc allows
# Line 5683  need it again later.  Also, if the rule Line 5580  need it again later.  Also, if the rule
5580  can simply Undo, edit the variable, and run the rule again without  can simply Undo, edit the variable, and run the rule again without
5581  having to retype it.  having to retype it.
5582    
 @group  
5583  @smallexample  @smallexample
5584  ' tan(x) := sin(x)/cos(x) RET      s t tsc RET  @group
5585  ' a/x + b/x := (a+b)/x RET         s t merge RET  ' tan(x) := sin(x)/cos(x) @key{RET}      s t tsc @key{RET}
5586  ' sin(x)^2 := 1 - cos(x)^2 RET     s t sinsqr RET  ' a/x + b/x := (a+b)/x @key{RET}         s t merge @key{RET}
5587    ' sin(x)^2 := 1 - cos(x)^2 @key{RET}     s t sinsqr @key{RET}
5588    
5589  1:  1 / cos(x) - sin(x) tan(x)     1:  cos(x)  1:  1 / cos(x) - sin(x) tan(x)     1:  cos(x)
5590      .                                  .      .                                  .
5591    
5592      r 1                a r tsc RET  a r merge RET  a r sinsqr RET  a s      r 1                a r tsc @key{RET}  a r merge @key{RET}  a r sinsqr @key{RET}  a s
 @end smallexample  
5593  @end group  @end group
5594    @end smallexample
5595    
5596  To edit a variable, type @kbd{s e} and the variable name, use regular  To edit a variable, type @kbd{s e} and the variable name, use regular
5597  Emacs editing commands as necessary, then type @kbd{M-# M-#} or  Emacs editing commands as necessary, then type @kbd{M-# M-#} or
# Line 5720  rewrite.  @xref{Rewrites Answer 1, 1}. ( Line 5617  rewrite.  @xref{Rewrites Answer 1, 1}. (
5617  The @kbd{a r} command can also accept a vector of rewrite rules, or  The @kbd{a r} command can also accept a vector of rewrite rules, or
5618  a variable containing a vector of rules.  a variable containing a vector of rules.
5619    
 @group  
5620  @smallexample  @smallexample
5621    @group
5622  1:  [tsc, merge, sinsqr]          1:  [tan(x) := sin(x) / cos(x), ... ]  1:  [tsc, merge, sinsqr]          1:  [tan(x) := sin(x) / cos(x), ... ]
5623      .                                 .      .                                 .
5624    
5625      ' [tsc,merge,sinsqr] RET          =      ' [tsc,merge,sinsqr] @key{RET}          =
5626    
 @end smallexample  
5627  @end group  @end group
5628    @end smallexample
5629  @noindent  @noindent
 @group  
5630  @smallexample  @smallexample
5631    @group
5632  1:  1 / cos(x) - sin(x) tan(x)    1:  cos(x)  1:  1 / cos(x) - sin(x) tan(x)    1:  cos(x)
5633      .                                 .      .                                 .
5634    
5635      s t trig RET  r 1                 a r trig RET  a s      s t trig @key{RET}  r 1                 a r trig @key{RET}  a s
 @end smallexample  
5636  @end group  @end group
5637    @end smallexample
5638    
5639  @c [fix-ref Nested Formulas with Rewrite Rules]  @c [fix-ref Nested Formulas with Rewrite Rules]
5640  Calc tries all the rules you give against all parts of the formula,  Calc tries all the rules you give against all parts of the formula,
# Line 5751  has gotten into an infinite loop.  You c Line 5648  has gotten into an infinite loop.  You c
5648  to @kbd{a r} to specify any limit.  In particular, @kbd{M-1 a r} does  to @kbd{a r} to specify any limit.  In particular, @kbd{M-1 a r} does
5649  only one rewrite at a time.  only one rewrite at a time.
5650    
 @group  
5651  @smallexample  @smallexample
5652    @group
5653  1:  1 / cos(x) - sin(x)^2 / cos(x)    1:  (1 - sin(x)^2) / cos(x)  1:  1 / cos(x) - sin(x)^2 / cos(x)    1:  (1 - sin(x)^2) / cos(x)
5654      .                                     .      .                                     .
5655    
5656      r 1  M-1 a r trig RET                 M-1 a r trig RET      r 1  M-1 a r trig @key{RET}                 M-1 a r trig @key{RET}
 @end smallexample  
5657  @end group  @end group
5658    @end smallexample
5659    
5660  You can type @kbd{M-0 a r} if you want no limit at all on the number  You can type @kbd{M-0 a r} if you want no limit at all on the number
5661  of rewrites that occur.  of rewrites that occur.
# Line 5766  of rewrites that occur. Line 5663  of rewrites that occur.
5663  Rewrite rules can also be @dfn{conditional}.  Simply follow the rule  Rewrite rules can also be @dfn{conditional}.  Simply follow the rule
5664  with a @samp{::} symbol and the desired condition.  For example,  with a @samp{::} symbol and the desired condition.  For example,
5665    
 @group  
5666  @smallexample  @smallexample
5667    @group
5668  1:  exp(2 pi i) + exp(3 pi i) + exp(4 pi i)  1:  exp(2 pi i) + exp(3 pi i) + exp(4 pi i)
5669      .      .
5670    
5671      ' exp(2 pi i) + exp(3 pi i) + exp(4 pi i) RET      ' exp(2 pi i) + exp(3 pi i) + exp(4 pi i) @key{RET}
5672    
 @end smallexample  
5673  @end group  @end group
5674    @end smallexample
5675  @noindent  @noindent
 @group  
5676  @smallexample  @smallexample
5677    @group
5678  1:  1 + exp(3 pi i) + 1  1:  1 + exp(3 pi i) + 1
5679      .      .
5680    
5681      a r exp(k pi i) := 1 :: k % 2 = 0 RET      a r exp(k pi i) := 1 :: k % 2 = 0 @key{RET}
 @end smallexample  
5682  @end group  @end group
5683    @end smallexample
5684    
5685  @noindent  @noindent
5686  (Recall, @samp{k % 2} is the remainder from dividing @samp{k} by 2,  (Recall, @samp{k % 2} is the remainder from dividing @samp{k} by 2,
# Line 5799  to match any @samp{f} with five argument Line 5696  to match any @samp{f} with five argument
5696  only when the fifth argument is literally @samp{e}!@refill  only when the fifth argument is literally @samp{e}!@refill
5697    
5698  @cindex Fibonacci numbers  @cindex Fibonacci numbers
5699  @c @starindex  @ignore
5700    @starindex
5701    @end ignore
5702  @tindex fib  @tindex fib
5703  Rewrite rules provide an interesting way to define your own functions.  Rewrite rules provide an interesting way to define your own functions.
5704  Suppose we want to define @samp{fib(n)} to produce the @var{n}th  Suppose we want to define @samp{fib(n)} to produce the @var{n}th
# Line 5807  Fibonacci number.  The first two Fibonac Line 5706  Fibonacci number.  The first two Fibonac
5706  later numbers are formed by summing the two preceding numbers in  later numbers are formed by summing the two preceding numbers in
5707  the sequence.  This is easy to express in a set of three rules:  the sequence.  This is easy to express in a set of three rules:
5708    
 @group  
5709  @smallexample  @smallexample
5710  ' [fib(1) := 1, fib(2) := 1, fib(n) := fib(n-1) + fib(n-2)] RET  s t fib  @group
5711    ' [fib(1) := 1, fib(2) := 1, fib(n) := fib(n-1) + fib(n-2)] @key{RET}  s t fib
5712    
5713  1:  fib(7)               1:  13  1:  fib(7)               1:  13
5714      .                        .      .                        .
5715    
5716      ' fib(7) RET             a r fib RET      ' fib(7) @key{RET}             a r fib @key{RET}
 @end smallexample  
5717  @end group  @end group
5718    @end smallexample
5719    
5720  One thing that is guaranteed about the order that rewrites are tried  One thing that is guaranteed about the order that rewrites are tried
5721  is that, for any given subformula, earlier rules in the rule set will  is that, for any given subformula, earlier rules in the rule set will
# Line 5830  will match @samp{fib(x)} and replace it Line 5729  will match @samp{fib(x)} and replace it
5729  Each of these will then be replaced to get @samp{fib(x-2) + 2 fib(x-3) +  Each of these will then be replaced to get @samp{fib(x-2) + 2 fib(x-3) +
5730  fib(x-4)}, and so on, expanding forever.  What we really want is to apply  fib(x-4)}, and so on, expanding forever.  What we really want is to apply
5731  the third rule only when @samp{n} is an integer greater than two.  Type  the third rule only when @samp{n} is an integer greater than two.  Type
5732  @w{@kbd{s e fib RET}}, then edit the third rule to:  @w{@kbd{s e fib @key{RET}}}, then edit the third rule to:
5733    
5734  @smallexample  @smallexample
5735  fib(n) := fib(n-1) + fib(n-2) :: integer(n) :: n > 2  fib(n) := fib(n-1) + fib(n-2) :: integer(n) :: n > 2
# Line 5839  fib(n) := fib(n-1) + fib(n-2) :: integer Line 5738  fib(n) := fib(n-1) + fib(n-2) :: integer
5738  @noindent  @noindent
5739  Now:  Now:
5740    
 @group  
5741  @smallexample  @smallexample
5742    @group
5743  1:  fib(6) + fib(x) + fib(0)      1:  8 + fib(x) + fib(0)  1:  fib(6) + fib(x) + fib(0)      1:  8 + fib(x) + fib(0)
5744      .                                 .      .                                 .
5745    
5746      ' fib(6)+fib(x)+fib(0) RET        a r fib RET      ' fib(6)+fib(x)+fib(0) @key{RET}        a r fib @key{RET}
 @end smallexample  
5747  @end group  @end group
5748    @end smallexample
5749    
5750  @noindent  @noindent
5751  We've created a new function, @code{fib}, and a new command,  We've created a new function, @code{fib}, and a new command,
5752  @w{@kbd{a r fib RET}}, which means ``evaluate all @code{fib} calls in  @w{@kbd{a r fib @key{RET}}}, which means ``evaluate all @code{fib} calls in
5753  this formula.''  To make things easier still, we can tell Calc to  this formula.''  To make things easier still, we can tell Calc to
5754  apply these rules automatically by storing them in the special  apply these rules automatically by storing them in the special
5755  variable @code{EvalRules}.  variable @code{EvalRules}.
5756    
 @group  
5757  @smallexample  @smallexample
5758    @group
5759  1:  [fib(1) := ...]    .                1:  [8, 13]  1:  [fib(1) := ...]    .                1:  [8, 13]
5760      .                                       .      .                                       .
5761    
5762      s r fib RET        s t EvalRules RET    ' [fib(6), fib(7)] RET      s r fib @key{RET}        s t EvalRules @key{RET}    ' [fib(6), fib(7)] @key{RET}
 @end smallexample  
5763  @end group  @end group
5764    @end smallexample
5765    
5766  It turns out that this rule set has the problem that it does far  It turns out that this rule set has the problem that it does far
5767  more work than it needs to when @samp{n} is large.  Consider the  more work than it needs to when @samp{n} is large.  Consider the
5768  first few steps of the computation of @samp{fib(6)}:  first few steps of the computation of @samp{fib(6)}:
5769    
 @group  
5770  @smallexample  @smallexample
5771    @group
5772  fib(6) =  fib(6) =
5773  fib(5)              +               fib(4) =  fib(5)              +               fib(4) =
5774  fib(4)     +      fib(3)     +      fib(3)     +      fib(2) =  fib(4)     +      fib(3)     +      fib(3)     +      fib(2) =
5775  fib(3) + fib(2) + fib(2) + fib(1) + fib(2) + fib(1) + 1 = ...  fib(3) + fib(2) + fib(2) + fib(1) + fib(2) + fib(1) + 1 = ...
 @end smallexample  
5776  @end group  @end group
5777    @end smallexample
5778    
5779  @noindent  @noindent
5780  Note that @samp{fib(3)} appears three times here.  Unless Calc's  Note that @samp{fib(3)} appears three times here.  Unless Calc's
# Line 5897  for technical reasons it is most effecti Line 5796  for technical reasons it is most effecti
5796  example, if the rule rewrites @samp{fib(7)} to something that evaluates  example, if the rule rewrites @samp{fib(7)} to something that evaluates
5797  to 13, then the rule @samp{fib(7) := 13} will be added to the rule set.  to 13, then the rule @samp{fib(7) := 13} will be added to the rule set.
5798    
5799  Type @kbd{' fib(8) RET} to compute the eighth Fibonacci number, then  Type @kbd{' fib(8) @key{RET}} to compute the eighth Fibonacci number, then
5800  type @kbd{s E} again to see what has happened to the rule set.  type @kbd{s E} again to see what has happened to the rule set.
5801    
5802  With the @code{remember} feature, our rule set can now compute  With the @code{remember} feature, our rule set can now compute
# Line 5907  computed the result for a particular @va Line 5806  computed the result for a particular @va
5806  (and the results for all smaller @var{n}) later in just one step.  (and the results for all smaller @var{n}) later in just one step.
5807    
5808  All Calc operations will run somewhat slower whenever @code{EvalRules}  All Calc operations will run somewhat slower whenever @code{EvalRules}
5809  contains any rules.  You should type @kbd{s u EvalRules RET} now to  contains any rules.  You should type @kbd{s u EvalRules @key{RET}} now to
5810  un-store the variable.  un-store the variable.
5811    
5812  (@bullet{}) @strong{Exercise 2.}  Sometimes it is possible to reformulate  (@bullet{}) @strong{Exercise 2.}  Sometimes it is possible to reformulate
# Line 6045  key sequence to correspond to any formul Line 5944  key sequence to correspond to any formul
5944  the shift-@kbd{Z} prefix; the user commands they create use the lower  the shift-@kbd{Z} prefix; the user commands they create use the lower
5945  case @kbd{z} prefix.  case @kbd{z} prefix.
5946    
 @group  
5947  @smallexample  @smallexample
5948    @group
5949  1:  1 + x + x^2 / 2 + x^3 / 6         1:  1 + x + x^2 / 2 + x^3 / 6  1:  1 + x + x^2 / 2 + x^3 / 6         1:  1 + x + x^2 / 2 + x^3 / 6
5950      .                                     .      .                                     .
5951    
5952      ' 1 + x + x^2/2! + x^3/3! RET         Z F e myexp RET RET RET y      ' 1 + x + x^2/2! + x^3/3! @key{RET}         Z F e myexp @key{RET} @key{RET} @key{RET} y
 @end smallexample  
5953  @end group  @end group
5954    @end smallexample
5955    
5956  This polynomial is a Taylor series approximation to @samp{exp(x)}.  This polynomial is a Taylor series approximation to @samp{exp(x)}.
5957  The @kbd{Z F} command asks a number of questions.  The above answers  The @kbd{Z F} command asks a number of questions.  The above answers
# Line 6063  default argument list @samp{(x)} is acce Line 5962  default argument list @samp{(x)} is acce
5962  answers the question ``leave it in symbolic form for non-constant  answers the question ``leave it in symbolic form for non-constant
5963  arguments?''  arguments?''
5964    
 @group  
5965  @smallexample  @smallexample
5966    @group
5967  1:  1.3495     2:  1.3495     3:  1.3495  1:  1.3495     2:  1.3495     3:  1.3495
5968      .          1:  1.34986    2:  1.34986      .          1:  1.34986    2:  1.34986
5969                     .          1:  myexp(a + 1)                     .          1:  myexp(a + 1)
5970                                    .                                    .
5971    
5972      .3 z e         .3 E           ' a+1 RET z e      .3 z e         .3 E           ' a+1 @key{RET} z e
 @end smallexample  
5973  @end group  @end group
5974    @end smallexample
5975    
5976  @noindent  @noindent
5977  First we call our new @code{exp} approximation with 0.3 as an  First we call our new @code{exp} approximation with 0.3 as an
# Line 6084  final question, @samp{myexp(a + 1)} woul Line 5983  final question, @samp{myexp(a + 1)} woul
5983  in @samp{a + 1} for @samp{x} in the defining formula.  in @samp{a + 1} for @samp{x} in the defining formula.
5984    
5985  @cindex Sine integral Si(x)  @cindex Sine integral Si(x)
5986  @c @starindex  @ignore
5987    @starindex
5988    @end ignore
5989  @tindex Si  @tindex Si
5990  (@bullet{}) @strong{Exercise 1.}  The ``sine integral'' function  (@bullet{}) @strong{Exercise 1.}  The ``sine integral'' function
5991  @c{${\rm Si}(x)$}  @c{${\rm Si}(x)$}
# Line 6107  keystrokes which Emacs has stored away a Line 6008  keystrokes which Emacs has stored away a
6008  For example, if you find yourself typing @kbd{H a S x @key{RET}} often,  For example, if you find yourself typing @kbd{H a S x @key{RET}} often,
6009  you may wish to program a keyboard macro to type this for you.  you may wish to program a keyboard macro to type this for you.
6010    
 @group  
6011  @smallexample  @smallexample
6012    @group
6013  1:  y = sqrt(x)          1:  x = y^2  1:  y = sqrt(x)          1:  x = y^2
6014      .                        .      .                        .
6015    
6016      ' y=sqrt(x) RET       C-x ( H a S x RET C-x )      ' y=sqrt(x) @key{RET}       C-x ( H a S x @key{RET} C-x )
6017    
6018  1:  y = cos(x)           1:  x = s1 arccos(y) + 2 pi n1  1:  y = cos(x)           1:  x = s1 arccos(y) + 2 pi n1
6019      .                        .      .                        .
6020    
6021      ' y=cos(x) RET           X      ' y=cos(x) @key{RET}           X
 @end smallexample  
6022  @end group  @end group
6023    @end smallexample
6024    
6025  @noindent  @noindent
6026  When you type @kbd{C-x (}, Emacs begins recording.  But it is also  When you type @kbd{C-x (}, Emacs begins recording.  But it is also
# Line 6130  re-execute the same keystrokes. Line 6031  re-execute the same keystrokes.
6031    
6032  You can give a name to your macro by typing @kbd{Z K}.  You can give a name to your macro by typing @kbd{Z K}.
6033    
 @group  
6034  @smallexample  @smallexample
6035    @group
6036  1:  .              1:  y = x^4         1:  x = s2 sqrt(s1 sqrt(y))  1:  .              1:  y = x^4         1:  x = s2 sqrt(s1 sqrt(y))
6037                         .                   .                         .                   .
6038    
6039    Z K x RET            ' y=x^4 RET         z x    Z K x @key{RET}            ' y=x^4 @key{RET}         z x
 @end smallexample  
6040  @end group  @end group
6041    @end smallexample
6042    
6043  @noindent  @noindent
6044  Notice that we use shift-@kbd{Z} to define the command, and lower-case  Notice that we use shift-@kbd{Z} to define the command, and lower-case
# Line 6145  Notice that we use shift-@kbd{Z} to defi Line 6046  Notice that we use shift-@kbd{Z} to defi
6046    
6047  Keyboard macros can call other macros.  Keyboard macros can call other macros.
6048    
 @group  
6049  @smallexample  @smallexample
6050    @group
6051  1:  abs(x)        1:  x = s1 y                1:  2 / x    1:  x = 2 / y  1:  abs(x)        1:  x = s1 y                1:  2 / x    1:  x = 2 / y
6052      .                 .                           .            .      .                 .                           .            .
6053    
6054   ' abs(x) RET   C-x ( ' y RET a = z x C-x )    ' 2/x RET       X   ' abs(x) @key{RET}   C-x ( ' y @key{RET} a = z x C-x )    ' 2/x @key{RET}       X
 @end smallexample  
6055  @end group  @end group
6056    @end smallexample
6057    
6058  (@bullet{}) @strong{Exercise 2.}  Define a keyboard macro to negate  (@bullet{}) @strong{Exercise 2.}  Define a keyboard macro to negate
6059  the item in level 3 of the stack, without disturbing the rest of  the item in level 3 of the stack, without disturbing the rest of
# Line 6186  In many programs, some of the steps must Line 6087  In many programs, some of the steps must
6087  Calc has @dfn{looping} commands that allow this.  Loops are useful  Calc has @dfn{looping} commands that allow this.  Loops are useful
6088  inside keyboard macros, but actually work at any time.  inside keyboard macros, but actually work at any time.
6089    
 @group  
6090  @smallexample  @smallexample
6091    @group
6092  1:  x^6          2:  x^6        1: 360 x^2  1:  x^6          2:  x^6        1: 360 x^2
6093      .            1:  4             .      .            1:  4             .
6094                       .                       .
6095    
6096    ' x^6 RET          4         Z < a d x RET Z >    ' x^6 @key{RET}          4         Z < a d x @key{RET} Z >
 @end smallexample  
6097  @end group  @end group
6098    @end smallexample
6099    
6100  @noindent  @noindent
6101  Here we have computed the fourth derivative of @cite{x^6} by  Here we have computed the fourth derivative of @cite{x^6} by
# Line 6208  type @w{@kbd{Z C-g}} to cancel the loop Line 6109  type @w{@kbd{Z C-g}} to cancel the loop
6109  @cindex Fibonacci numbers  @cindex Fibonacci numbers
6110  Here's another example:  Here's another example:
6111    
 @group  
6112  @smallexample  @smallexample
6113    @group
6114  3:  1               2:  10946  3:  1               2:  10946
6115  2:  1               1:  17711  2:  1               1:  17711
6116  1:  20                  .  1:  20                  .
6117      .      .
6118    
6119  1 RET RET 20       Z < TAB C-j + Z >  1 @key{RET} @key{RET} 20       Z < @key{TAB} C-j + Z >
 @end smallexample  
6120  @end group  @end group
6121    @end smallexample
6122    
6123  @noindent  @noindent
6124  The numbers in levels 2 and 1 should be the 21st and 22nd Fibonacci  The numbers in levels 2 and 1 should be the 21st and 22nd Fibonacci
# Line 6236  and then rounding to the nearest integer Line 6137  and then rounding to the nearest integer
6137  @cite{(1 + sqrt(5)) / 2}.  (For convenience, this constant is available  @cite{(1 + sqrt(5)) / 2}.  (For convenience, this constant is available
6138  from the @code{phi} variable, or the @kbd{I H P} command.)  from the @code{phi} variable, or the @kbd{I H P} command.)
6139    
 @group  
6140  @smallexample  @smallexample
6141    @group
6142  1:  1.61803         1:  24476.0000409    1:  10945.9999817    1:  10946  1:  1.61803         1:  24476.0000409    1:  10945.9999817    1:  10946
6143      .                   .                    .                    .      .                   .                    .                    .
6144    
6145      I H P               21 ^                 5 Q /                R      I H P               21 ^                 5 Q /                R
 @end smallexample  
6146  @end group  @end group
6147    @end smallexample
6148    
6149  @cindex Continued fractions  @cindex Continued fractions
6150  (@bullet{}) @strong{Exercise 5.}  The @dfn{continued fraction}  (@bullet{}) @strong{Exercise 5.}  The @dfn{continued fraction}
# Line 6270  A more sophisticated kind of loop is the Line 6171  A more sophisticated kind of loop is the
6171  we wish to compute the 20th ``harmonic'' number, which is equal to  we wish to compute the 20th ``harmonic'' number, which is equal to
6172  the sum of the reciprocals of the integers from 1 to 20.  the sum of the reciprocals of the integers from 1 to 20.
6173    
 @group  
6174  @smallexample  @smallexample
6175    @group
6176  3:  0               1:  3.597739  3:  0               1:  3.597739
6177  2:  1                   .  2:  1                   .
6178  1:  20  1:  20
6179      .      .
6180    
6181  0 RET 1 RET 20         Z ( & + 1 Z )  0 @key{RET} 1 @key{RET} 20         Z ( & + 1 Z )
 @end smallexample  
6182  @end group  @end group
6183    @end smallexample
6184    
6185  @noindent  @noindent
6186  The ``for'' loop pops two numbers, the lower and upper limits, then  The ``for'' loop pops two numbers, the lower and upper limits, then
# Line 6294  This harmonic number function uses the s Line 6195  This harmonic number function uses the s
6195  total as well as for the various loop housekeeping functions.  If  total as well as for the various loop housekeeping functions.  If
6196  you find this disorienting, you can sum in a variable instead:  you find this disorienting, you can sum in a variable instead:
6197    
 @group  
6198  @smallexample  @smallexample
6199    @group
6200  1:  0         2:  1                  .            1:  3.597739  1:  0         2:  1                  .            1:  3.597739
6201      .         1:  20                                  .      .         1:  20                                  .
6202                    .                    .
6203    
6204      0 t 7       1 RET 20      Z ( & s + 7 1 Z )       r 7      0 t 7       1 @key{RET} 20      Z ( & s + 7 1 Z )       r 7
 @end smallexample  
6205  @end group  @end group
6206    @end smallexample
6207    
6208  @noindent  @noindent
6209  The @kbd{s +} command adds the top-of-stack into the value in a  The @kbd{s +} command adds the top-of-stack into the value in a
# Line 6325  we have to worry about the programs clob Line 6226  we have to worry about the programs clob
6226  caller was keeping in those same variables.  This is easy to  caller was keeping in those same variables.  This is easy to
6227  fix, though:  fix, though:
6228    
 @group  
6229  @smallexample  @smallexample
6230    @group
6231      .        1:  0.6667       1:  0.6667     3:  0.6667      .        1:  0.6667       1:  0.6667     3:  0.6667
6232                   .                .          2:  3.597739                   .                .          2:  3.597739
6233                                               1:  0.6667                                               1:  0.6667
6234                                                   .                                                   .
6235    
6236     Z `    p 4 RET 2 RET 3 /   s 7 s s a RET    Z '  r 7 s r a RET     Z `    p 4 @key{RET} 2 @key{RET} 3 /   s 7 s s a @key{RET}    Z '  r 7 s r a @key{RET}
 @end smallexample  
6237  @end group  @end group
6238    @end smallexample
6239    
6240  @noindent  @noindent
6241  When we type @kbd{Z `} (that's a back-quote character), Calc saves  When we type @kbd{Z `} (that's a back-quote character), Calc saves
# Line 6358  command, @kbd{k b}, to compute exact Ber Line 6259  command, @kbd{k b}, to compute exact Ber
6259  this command is very slow for large @cite{n} since the higher  this command is very slow for large @cite{n} since the higher
6260  Bernoulli numbers are very large fractions.)  Bernoulli numbers are very large fractions.)
6261    
 @group  
6262  @smallexample  @smallexample
6263    @group
6264  1:  10               1:  0.0756823  1:  10               1:  0.0756823
6265      .                    .      .                    .
6266    
6267      10     C-x ( RET 2 % Z [ DEL 0 Z : ' 2 $! / (2 pi)^$ RET = Z ] C-x )      10     C-x ( @key{RET} 2 % Z [ @key{DEL} 0 Z : ' 2 $! / (2 pi)^$ @key{RET} = Z ] C-x )
 @end smallexample  
6268  @end group  @end group
6269    @end smallexample
6270    
6271  @noindent  @noindent
6272  You can read @kbd{Z [} as ``then,'' @kbd{Z :} as ``else,'' and  You can read @kbd{Z [} as ``then,'' @kbd{Z :} as ``else,'' and
# Line 6378  if we're asking for an odd Bernoulli num Line 6279  if we're asking for an odd Bernoulli num
6279    
6280  The actual tenth Bernoulli number is @cite{5/66}.  The actual tenth Bernoulli number is @cite{5/66}.
6281    
 @group  
6282  @smallexample  @smallexample
6283    @group
6284  3:  0.0756823    1:  0          1:  0.25305    1:  0          1:  1.16659  3:  0.0756823    1:  0          1:  0.25305    1:  0          1:  1.16659
6285  2:  5:66             .              .              .              .  2:  5:66             .              .              .              .
6286  1:  0.0757575  1:  0.0757575
6287      .      .
6288    
6289  10 k b RET c f   M-0 DEL 11 X   DEL 12 X       DEL 13 X       DEL 14 X  10 k b @key{RET} c f   M-0 @key{DEL} 11 X   @key{DEL} 12 X       @key{DEL} 13 X       @key{DEL} 14 X
 @end smallexample  
6290  @end group  @end group
6291    @end smallexample
6292    
6293  Just to exercise loops a bit more, let's compute a table of even  Just to exercise loops a bit more, let's compute a table of even
6294  Bernoulli numbers.  Bernoulli numbers.
6295    
 @group  
6296  @smallexample  @smallexample
6297    @group
6298  3:  []             1:  [0.10132, 0.03079, 0.02340, 0.033197, ...]  3:  []             1:  [0.10132, 0.03079, 0.02340, 0.033197, ...]
6299  2:  2                  .  2:  2                  .
6300  1:  30  1:  30
6301      .      .
6302    
6303   [ ] 2 RET 30          Z ( X | 2 Z )   [ ] 2 @key{RET} 30          Z ( X | 2 Z )
 @end smallexample  
6304  @end group  @end group
6305    @end smallexample
6306    
6307  @noindent  @noindent
6308  The vertical-bar @kbd{|} is the vector-concatenation command.  When  The vertical-bar @kbd{|} is the vector-concatenation command.  When
# Line 6423  it using @kbd{Z E}.  First, you must att Line 6324  it using @kbd{Z E}.  First, you must att
6324  One technique is to enter a throwaway dummy definition for the macro,  One technique is to enter a throwaway dummy definition for the macro,
6325  then enter the real one in the edit command.  then enter the real one in the edit command.
6326    
 @group  
6327  @smallexample  @smallexample
6328    @group
6329  1:  3                   1:  3           Keyboard Macro Editor.  1:  3                   1:  3           Keyboard Macro Editor.
6330      .                       .           Original keys: 1 RET 2 +      .                       .           Original keys: 1 @key{RET} 2 +
6331    
6332                                          type "1\r"                                          type "1\r"
6333                                          type "2"                                          type "2"
6334                                          calc-plus                                          calc-plus
6335    
6336  C-x ( 1 RET 2 + C-x )    Z K h RET      Z E h  C-x ( 1 @key{RET} 2 + C-x )    Z K h @key{RET}      Z E h
 @end smallexample  
6337  @end group  @end group
6338    @end smallexample
6339    
6340  @noindent  @noindent
6341  This shows the screen display assuming you have the @file{macedit}  This shows the screen display assuming you have the @file{macedit}
# Line 6460  type "0"              # Push a zero Line 6361  type "0"              # Push a zero
6361  calc-store-into       # Store it in variable 1  calc-store-into       # Store it in variable 1
6362  type "1"  type "1"
6363  type "1"              # Initial value for loop  type "1"              # Initial value for loop
6364  calc-roll-down        # This is the TAB key; swap initial & final  calc-roll-down        # This is the @key{TAB} key; swap initial & final
6365  calc-kbd-for          # Begin "for" loop...  calc-kbd-for          # Begin "for" loop...
6366  calc-inv              #   Take reciprocal  calc-inv              #   Take reciprocal
6367  calc-store-plus       #   Add to accumulator  calc-store-plus       #   Add to accumulator
# Line 6475  calc-kbd-pop          # Restore values ( Line 6376  calc-kbd-pop          # Restore values (
6376  @noindent  @noindent
6377  Press @kbd{M-# M-#} to finish editing and return to the Calculator.  Press @kbd{M-# M-#} to finish editing and return to the Calculator.
6378    
 @group  
6379  @smallexample  @smallexample
6380    @group
6381  1:  20         1:  3.597739  1:  20         1:  3.597739
6382      .              .      .              .
6383    
6384      20             z h      20             z h
 @end smallexample  
6385  @end group  @end group
6386    @end smallexample
6387    
6388  If you don't know how to write a particular command in @file{macedit}  If you don't know how to write a particular command in @file{macedit}
6389  format, you can always write it as keystrokes in a @code{type} command.  format, you can always write it as keystrokes in a @code{type} command.
# Line 6492  a handy @code{read-kbd-macro} command wh Line 6393  a handy @code{read-kbd-macro} command wh
6393  of the current buffer as a sequence of keystroke names, and defines that  of the current buffer as a sequence of keystroke names, and defines that
6394  sequence on the @kbd{X} (and @kbd{C-x e}) key.  Because this is so  sequence on the @kbd{X} (and @kbd{C-x e}) key.  Because this is so
6395  useful, Calc puts this command on the @kbd{M-# m} key.  Try reading in  useful, Calc puts this command on the @kbd{M-# m} key.  Try reading in
6396  this macro in the following form:  Press @kbd{C-@@} (or @kbd{C-SPC}) at  this macro in the following form:  Press @kbd{C-@@} (or @kbd{C-@key{SPC}}) at
6397  one end of the text below, then type @kbd{M-# m} at the other.  one end of the text below, then type @kbd{M-# m} at the other.
6398    
 @group  
6399  @example  @example
6400    @group
6401  Z ` 0 t 1  Z ` 0 t 1
6402      1 TAB      1 @key{TAB}
6403      Z (  & s + 1  1 Z )      Z (  & s + 1  1 Z )
6404      r 1      r 1
6405  Z '  Z '
 @end example  
6406  @end group  @end group
6407    @end example
6408    
6409  (@bullet{}) @strong{Exercise 8.}  A general algorithm for solving  (@bullet{}) @strong{Exercise 8.}  A general algorithm for solving
6410  equations numerically is @dfn{Newton's Method}.  Given the equation  equations numerically is @dfn{Newton's Method}.  Given the equation
# Line 6667  The rest of this manual tells the whole Line 6568  The rest of this manual tells the whole
6568  This section includes answers to all the exercises in the Calc tutorial.  This section includes answers to all the exercises in the Calc tutorial.
6569    
6570  @menu  @menu
6571  * RPN Answer 1::           1 RET 2 RET 3 RET 4 + * -  * RPN Answer 1::           1 @key{RET} 2 @key{RET} 3 @key{RET} 4 + * -
6572  * RPN Answer 2::           2*4 + 7*9.5 + 5/4  * RPN Answer 2::           2*4 + 7*9.5 + 5/4
6573  * RPN Answer 3::           Operating on levels 2 and 3  * RPN Answer 3::           Operating on levels 2 and 3
6574  * RPN Answer 4::           Joe's complex problems  * RPN Answer 4::           Joe's complex problems
# Line 6770  that result on the stack while you compu Line 6671  that result on the stack while you compu
6671  both of these results waiting on the stack you can then compute the  both of these results waiting on the stack you can then compute the
6672  final term, then press @kbd{+ +} to add everything up.  final term, then press @kbd{+ +} to add everything up.
6673    
 @group  
6674  @smallexample  @smallexample
6675    @group
6676  2:  2          1:  8          3:  8          2:  8  2:  2          1:  8          3:  8          2:  8
6677  1:  4              .          2:  7          1:  66.5  1:  4              .          2:  7          1:  66.5
6678      .                         1:  9.5            .      .                         1:  9.5            .
6679                                    .                                    .
6680    
6681    2 RET 4          *          7 RET 9.5          *    2 @key{RET} 4          *          7 @key{RET} 9.5          *
6682    
 @end smallexample  
6683  @end group  @end group
6684    @end smallexample
6685  @noindent  @noindent
 @group  
6686  @smallexample  @smallexample
6687    @group
6688  4:  8          3:  8          2:  8          1:  75.75  4:  8          3:  8          2:  8          1:  75.75
6689  3:  66.5       2:  66.5       1:  67.75          .  3:  66.5       2:  66.5       1:  67.75          .
6690  2:  5          1:  1.25           .  2:  5          1:  1.25           .
6691  1:  4              .  1:  4              .
6692      .      .
6693    
6694    5 RET 4          /              +              +    5 @key{RET} 4          /              +              +
 @end smallexample  
6695  @end group  @end group
6696    @end smallexample
6697    
6698  Alternatively, you could add the first two terms before going on  Alternatively, you could add the first two terms before going on
6699  with the third term.  with the third term.
6700    
 @group  
6701  @smallexample  @smallexample
6702    @group
6703  2:  8          1:  74.5       3:  74.5       2:  74.5       1:  75.75  2:  8          1:  74.5       3:  74.5       2:  74.5       1:  75.75
6704  1:  66.5           .          2:  5          1:  1.25           .  1:  66.5           .          2:  5          1:  1.25           .
6705      .                         1:  4              .      .                         1:  4              .
6706                                    .                                    .
6707    
6708     ...             +            5 RET 4          /              +     ...             +            5 @key{RET} 4          /              +
 @end smallexample  
6709  @end group  @end group
6710    @end smallexample
6711    
6712  On an old-style RPN calculator this second method would have the  On an old-style RPN calculator this second method would have the
6713  advantage of using only three stack levels.  But since Calc's stack  advantage of using only three stack levels.  But since Calc's stack
# Line 6819  you choose is purely a matter of taste. Line 6720  you choose is purely a matter of taste.
6720  @noindent  @noindent
6721  The @key{TAB} key provides a way to operate on the number in level 2.  The @key{TAB} key provides a way to operate on the number in level 2.
6722    
 @group  
6723  @smallexample  @smallexample
6724    @group
6725  3:  10         3:  10         4:  10         3:  10         3:  10  3:  10         3:  10         4:  10         3:  10         3:  10
6726  2:  20         2:  30         3:  30         2:  30         2:  21  2:  20         2:  30         3:  30         2:  30         2:  21
6727  1:  30         1:  20         2:  20         1:  21         1:  30  1:  30         1:  20         2:  20         1:  21         1:  30
6728      .              .          1:  1              .              .      .              .          1:  1              .              .
6729                                    .                                    .
6730    
6731                    TAB             1              +             TAB                    @key{TAB}             1              +             @key{TAB}
 @end smallexample  
6732  @end group  @end group
6733    @end smallexample
6734    
6735  Similarly, @key{M-TAB} gives you access to the number in level 3.  Similarly, @kbd{M-@key{TAB}} gives you access to the number in level 3.
6736    
 @group  
6737  @smallexample  @smallexample
6738    @group
6739  3:  10         3:  21         3:  21         3:  30         3:  11  3:  10         3:  21         3:  21         3:  30         3:  11
6740  2:  21         2:  30         2:  30         2:  11         2:  21  2:  21         2:  30         2:  30         2:  11         2:  21
6741  1:  30         1:  10         1:  11         1:  21         1:  30  1:  30         1:  10         1:  11         1:  21         1:  30
6742      .              .              .              .              .      .              .              .              .              .
6743    
6744                    M-TAB           1 +           M-TAB          M-TAB                    M-@key{TAB}           1 +           M-@key{TAB}          M-@key{TAB}
 @end smallexample  
6745  @end group  @end group
6746    @end smallexample
6747    
6748  @node RPN Answer 4, Algebraic Answer 1, RPN Answer 3, Answers to Exercises  @node RPN Answer 4, Algebraic Answer 1, RPN Answer 3, Answers to Exercises
6749  @subsection RPN Tutorial Exercise 4  @subsection RPN Tutorial Exercise 4
# Line 6851  Similarly, @key{M-TAB} gives you access Line 6752  Similarly, @key{M-TAB} gives you access
6752  Either @kbd{( 2 , 3 )} or @kbd{( 2 @key{SPC} 3 )} would have worked,  Either @kbd{( 2 , 3 )} or @kbd{( 2 @key{SPC} 3 )} would have worked,
6753  but using both the comma and the space at once yields:  but using both the comma and the space at once yields:
6754    
 @group  
6755  @smallexample  @smallexample
6756    @group
6757  1:  ( ...      2:  ( ...      1:  (2, ...    2:  (2, ...    2:  (2, ...  1:  ( ...      2:  ( ...      1:  (2, ...    2:  (2, ...    2:  (2, ...
6758      .          1:  2              .          1:  (2, ...    1:  (2, 3)      .          1:  2              .          1:  (2, ...    1:  (2, 3)
6759                     .                             .              .                     .                             .              .
6760    
6761      (              2              ,             SPC            3 )      (              2              ,             @key{SPC}            3 )
 @end smallexample  
6762  @end group  @end group
6763    @end smallexample
6764    
6765  Joe probably tried to type @kbd{@key{TAB} @key{DEL}} to swap the  Joe probably tried to type @kbd{@key{TAB} @key{DEL}} to swap the
6766  extra incomplete object to the top of the stack and delete it.  extra incomplete object to the top of the stack and delete it.
# Line 6867  But a feature of Calc is that @key{DEL} Line 6768  But a feature of Calc is that @key{DEL}
6768  deletes just one component out of that object, so he had to press  deletes just one component out of that object, so he had to press
6769  @key{DEL} twice to finish the job.  @key{DEL} twice to finish the job.
6770    
 @group  
6771  @smallexample  @smallexample
6772    @group
6773  2:  (2, ...    2:  (2, 3)     2:  (2, 3)     1:  (2, 3)  2:  (2, ...    2:  (2, 3)     2:  (2, 3)     1:  (2, 3)
6774  1:  (2, 3)     1:  (2, ...    1:  ( ...          .  1:  (2, 3)     1:  (2, ...    1:  ( ...          .
6775      .              .              .      .              .              .
6776    
6777                    TAB            DEL            DEL                    @key{TAB}            @key{DEL}            @key{DEL}
 @end smallexample  
6778  @end group  @end group
6779    @end smallexample
6780    
6781  (As it turns out, deleting the second-to-top stack entry happens often  (As it turns out, deleting the second-to-top stack entry happens often
6782  enough that Calc provides a special key, @kbd{M-DEL}, to do just that.  enough that Calc provides a special key, @kbd{M-@key{DEL}}, to do just that.
6783  @kbd{M-DEL} is just like @kbd{TAB DEL}, except that it doesn't exhibit  @kbd{M-@key{DEL}} is just like @kbd{@key{TAB} @key{DEL}}, except that it doesn't exhibit
6784  the ``feature'' that tripped poor Joe.)  the ``feature'' that tripped poor Joe.)
6785    
6786  @node Algebraic Answer 1, Algebraic Answer 2, RPN Answer 4, Answers to Exercises  @node Algebraic Answer 1, Algebraic Answer 2, RPN Answer 4, Answers to Exercises
# Line 6990  needs to display scientific notation in Line 6891  needs to display scientific notation in
6891  @samp{16#F.E8F*16.^15}.  You can enter a number like this as an  @samp{16#F.E8F*16.^15}.  You can enter a number like this as an
6892  algebraic entry.  Also, pressing @kbd{e} without any digits before it  algebraic entry.  Also, pressing @kbd{e} without any digits before it
6893  normally types @kbd{1e}, but in a high radix it types @kbd{16.^} and  normally types @kbd{1e}, but in a high radix it types @kbd{16.^} and
6894  puts you in algebraic entry:  @kbd{16#f.e8f RET e 15 RET *} is another  puts you in algebraic entry:  @kbd{16#f.e8f @key{RET} e 15 @key{RET} *} is another
6895  way to enter this number.  way to enter this number.
6896    
6897  The reason Calc puts a decimal point in the @samp{16.^} is to prevent  The reason Calc puts a decimal point in the @samp{16.^} is to prevent
# Line 7018  commands decrease or increase a number b Line 6919  commands decrease or increase a number b
6919  place (according to the current precision).  They are useful for  place (according to the current precision).  They are useful for
6920  determining facts like this.  determining facts like this.
6921    
 @group  
6922  @smallexample  @smallexample
6923    @group
6924  1:  0.707106781187      1:  0.500000000001  1:  0.707106781187      1:  0.500000000001
6925      .                       .      .                       .
6926    
6927      45 S                    2 ^      45 S                    2 ^
6928    
 @end smallexample  
6929  @end group  @end group
6930    @end smallexample
6931  @noindent  @noindent
 @group  
6932  @smallexample  @smallexample
6933    @group
6934  1:  0.707106781187      1:  0.707106781186      1:  0.499999999999  1:  0.707106781187      1:  0.707106781186      1:  0.499999999999
6935      .                       .                       .      .                       .                       .
6936    
6937      U  DEL                  f [                     2 ^      U  @key{DEL}                  f [                     2 ^
 @end smallexample  
6938  @end group  @end group
6939    @end smallexample
6940    
6941  A high-precision calculation must be carried out in high precision  A high-precision calculation must be carried out in high precision
6942  all the way.  The only number in the original problem which was known  all the way.  The only number in the original problem which was known
# Line 7102  doesn't try. Line 7003  doesn't try.
7003  Duplicate the vector, compute its length, then divide the vector  Duplicate the vector, compute its length, then divide the vector
7004  by its length:  @kbd{@key{RET} A /}.  by its length:  @kbd{@key{RET} A /}.
7005    
 @group  
7006  @smallexample  @smallexample
7007    @group
7008  1:  [1, 2, 3]  2:  [1, 2, 3]      1:  [0.27, 0.53, 0.80]  1:  1.  1:  [1, 2, 3]  2:  [1, 2, 3]      1:  [0.27, 0.53, 0.80]  1:  1.
7009      .          1:  3.74165738677      .                       .      .          1:  3.74165738677      .                       .
7010                     .                     .
7011    
7012      r 1            RET A              /                       A      r 1            @key{RET} A              /                       A
 @end smallexample  
7013  @end group  @end group
7014    @end smallexample
7015    
7016  The final @kbd{A} command shows that the normalized vector does  The final @kbd{A} command shows that the normalized vector does
7017  indeed have unit length.  indeed have unit length.
# Line 7135  get the row sum.  Similarly, use @kbd{[1 Line 7036  get the row sum.  Similarly, use @kbd{[1
7036  @subsection Matrix Tutorial Exercise 2  @subsection Matrix Tutorial Exercise 2
7037    
7038  @ifinfo  @ifinfo
 @group  
7039  @example  @example
7040    @group
7041     x + a y = 6     x + a y = 6
7042     x + b y = 10     x + b y = 10
 @end example  
7043  @end group  @end group
7044    @end example
7045  @end ifinfo  @end ifinfo
7046  @tex  @tex
7047  \turnoffactive  \turnoffactive
# Line 7154  $$ Line 7055  $$
7055  Just enter the righthand side vector, then divide by the lefthand side  Just enter the righthand side vector, then divide by the lefthand side
7056  matrix as usual.  matrix as usual.
7057    
 @group  
7058  @smallexample  @smallexample
7059    @group
7060  1:  [6, 10]    2:  [6, 10]         1:  [6 - 4 a / (b - a), 4 / (b - a) ]  1:  [6, 10]    2:  [6, 10]         1:  [6 - 4 a / (b - a), 4 / (b - a) ]
7061      .          1:  [ [ 1, a ]          .      .          1:  [ [ 1, a ]          .
7062                       [ 1, b ] ]                       [ 1, b ] ]
7063                     .                     .
7064    
7065  ' [6 10] RET     ' [1 a; 1 b] RET      /  ' [6 10] @key{RET}     ' [1 a; 1 b] @key{RET}      /
 @end smallexample  
7066  @end group  @end group
7067    @end smallexample
7068    
7069  This can be made more readable using @kbd{d B} to enable ``big'' display  This can be made more readable using @kbd{d B} to enable ``big'' display
7070  mode:  mode:
7071    
 @group  
7072  @smallexample  @smallexample
7073    @group
7074            4 a     4            4 a     4
7075  1:  [6 - -----, -----]  1:  [6 - -----, -----]
7076           b - a  b - a           b - a  b - a
 @end smallexample  
7077  @end group  @end group
7078    @end smallexample
7079    
7080  Type @kbd{d N} to return to ``normal'' display mode afterwards.  Type @kbd{d N} to return to ``normal'' display mode afterwards.
7081    
# Line 7192  system @c{$A' X = B'$} Line 7093  system @c{$A' X = B'$}
7093  command.  command.
7094    
7095  @ifinfo  @ifinfo
 @group  
7096  @example  @example
7097    @group
7098      a + 2b + 3c = 6      a + 2b + 3c = 6
7099     4a + 5b + 6c = 2     4a + 5b + 6c = 2
7100     7a + 6b      = 3     7a + 6b      = 3
7101     2a + 4b + 6c = 11     2a + 4b + 6c = 11
 @end example  
7102  @end group  @end group
7103    @end example
7104  @end ifinfo  @end ifinfo
7105  @tex  @tex
7106  \turnoffactive  \turnoffactive
# Line 7222  quick variable number 7 for later refere Line 7123  quick variable number 7 for later refere
7123  @c{$B'$}  @c{$B'$}
7124  @cite{B2} vector.  @cite{B2} vector.
7125    
 @group  
7126  @smallexample  @smallexample
7127    @group
7128  1:  [ [ 1, 2, 3 ]             2:  [ [ 1, 4, 7, 2 ]     1:  [57, 84, 96]  1:  [ [ 1, 2, 3 ]             2:  [ [ 1, 4, 7, 2 ]     1:  [57, 84, 96]
7129        [ 4, 5, 6 ]                   [ 2, 5, 6, 4 ]         .        [ 4, 5, 6 ]                   [ 2, 5, 6, 4 ]         .
7130        [ 7, 6, 0 ]                   [ 3, 6, 0, 6 ] ]        [ 7, 6, 0 ]                   [ 3, 6, 0, 6 ] ]
7131        [ 2, 4, 6 ] ]           1:  [6, 2, 3, 11]        [ 2, 4, 6 ] ]           1:  [6, 2, 3, 11]
7132      .                             .      .                             .
7133    
7134  ' [1 2 3; 4 5 6; 7 6 0; 2 4 6] RET  s 7  v t  [6 2 3 11]   *  ' [1 2 3; 4 5 6; 7 6 0; 2 4 6] @key{RET}  s 7  v t  [6 2 3 11]   *
 @end smallexample  
7135  @end group  @end group
7136    @end smallexample
7137    
7138  @noindent  @noindent
7139  Now we compute the matrix @c{$A'$}  Now we compute the matrix @c{$A'$}
7140  @cite{A2} and divide.  @cite{A2} and divide.
7141    
 @group  
7142  @smallexample  @smallexample
7143    @group
7144  2:  [57, 84, 96]          1:  [-11.64, 14.08, -3.64]  2:  [57, 84, 96]          1:  [-11.64, 14.08, -3.64]
7145  1:  [ [ 70, 72, 39 ]          .  1:  [ [ 70, 72, 39 ]          .
7146        [ 72, 81, 60 ]        [ 72, 81, 60 ]
# Line 7247  Now we compute the matrix @c{$A'$} Line 7148  Now we compute the matrix @c{$A'$}
7148      .      .
7149    
7150      r 7 v t r 7 *             /      r 7 v t r 7 *             /
 @end smallexample  
7151  @end group  @end group
7152    @end smallexample
7153    
7154  @noindent  @noindent
7155  (The actual computed answer will be slightly inexact due to  (The actual computed answer will be slightly inexact due to
# Line 7268  Since the first and fourth equations are Line 7169  Since the first and fourth equations are
7169  can't both be satisfied at once.  Let's plug our answers back into  can't both be satisfied at once.  Let's plug our answers back into
7170  the original system of equations to see how well they match.  the original system of equations to see how well they match.
7171    
 @group  
7172  @smallexample  @smallexample
7173    @group
7174  2:  [-11.64, 14.08, -3.64]     1:  [5.6, 2., 3., 11.2]  2:  [-11.64, 14.08, -3.64]     1:  [5.6, 2., 3., 11.2]
7175  1:  [ [ 1, 2, 3 ]                  .  1:  [ [ 1, 2, 3 ]                  .
7176        [ 4, 5, 6 ]        [ 4, 5, 6 ]
# Line 7277  the original system of equations to see Line 7178  the original system of equations to see
7178        [ 2, 4, 6 ] ]        [ 2, 4, 6 ] ]
7179      .      .
7180    
7181      r 7                            TAB *      r 7                            @key{TAB} *
 @end smallexample  
7182  @end group  @end group
7183    @end smallexample
7184    
7185  @noindent  @noindent
7186  This is reasonably close to our original @cite{B} vector,  This is reasonably close to our original @cite{B} vector,
# Line 7294  adjusted to get the range of integers we Line 7195  adjusted to get the range of integers we
7195  across the vector will accomplish this, although it turns out the  across the vector will accomplish this, although it turns out the
7196  plain @samp{-} key will work just as well.  plain @samp{-} key will work just as well.
7197    
 @group  
7198  @smallexample  @smallexample
7199    @group
7200  2:  2                              2:  2  2:  2                              2:  2
7201  1:  [1, 2, 3, 4, 5, 6, 7, 8, 9]    1:  [-4, -3, -2, -1, 0, 1, 2, 3, 4]  1:  [1, 2, 3, 4, 5, 6, 7, 8, 9]    1:  [-4, -3, -2, -1, 0, 1, 2, 3, 4]
7202      .                                  .      .                                  .
7203    
7204      2  v x 9 RET                       5 V M -   or   5 -      2  v x 9 @key{RET}                       5 V M -   or   5 -
 @end smallexample  
7205  @end group  @end group
7206    @end smallexample
7207    
7208  @noindent  @noindent
7209  Now we use @kbd{V M ^} to map the exponentiation operator across the  Now we use @kbd{V M ^} to map the exponentiation operator across the
7210  vector.  vector.
7211    
 @group  
7212  @smallexample  @smallexample
7213    @group
7214  1:  [0.0625, 0.125, 0.25, 0.5, 1, 2, 4, 8, 16]  1:  [0.0625, 0.125, 0.25, 0.5, 1, 2, 4, 8, 16]
7215      .      .
7216    
7217      V M ^      V M ^
 @end smallexample  
7218  @end group  @end group
7219    @end smallexample
7220    
7221  @node List Answer 2, List Answer 3, List Answer 1, Answers to Exercises  @node List Answer 2, List Answer 3, List Answer 1, Answers to Exercises
7222  @subsection List Tutorial Exercise 2  @subsection List Tutorial Exercise 2
# Line 7341  Thus we want a @c{$19\times2$} Line 7242  Thus we want a @c{$19\times2$}
7242  ones as the other column.  So, first we build the column of ones, then  ones as the other column.  So, first we build the column of ones, then
7243  we combine the two columns to form our @cite{A} matrix.  we combine the two columns to form our @cite{A} matrix.
7244    
 @group  
7245  @smallexample  @smallexample
7246    @group
7247  2:  [1.34, 1.41, 1.49, ... ]    1:  [ [ 1.34, 1 ]  2:  [1.34, 1.41, 1.49, ... ]    1:  [ [ 1.34, 1 ]
7248  1:  [1, 1, 1, ...]                    [ 1.41, 1 ]  1:  [1, 1, 1, ...]                    [ 1.41, 1 ]
7249      .                                 [ 1.49, 1 ]      .                                 [ 1.49, 1 ]
7250                                        @dots{}                                        @dots{}
7251    
7252      r 1 1 v b 19 RET                M-2 v p v t   s 3      r 1 1 v b 19 @key{RET}                M-2 v p v t   s 3
 @end smallexample  
7253  @end group  @end group
7254    @end smallexample
7255    
7256  @noindent  @noindent
7257  Now we compute @c{$A^T y$}  Now we compute @c{$A^T y$}
7258  @cite{trn(A) * y} and @c{$A^T A$}  @cite{trn(A) * y} and @c{$A^T A$}
7259  @cite{trn(A) * A} and divide.  @cite{trn(A) * A} and divide.
7260    
 @group  
7261  @smallexample  @smallexample
7262    @group
7263  1:  [33.36554, 13.613]    2:  [33.36554, 13.613]  1:  [33.36554, 13.613]    2:  [33.36554, 13.613]
7264      .                     1:  [ [ 98.0003, 41.63 ]      .                     1:  [ [ 98.0003, 41.63 ]
7265                                  [  41.63,   19   ] ]                                  [  41.63,   19   ] ]
7266                                .                                .
7267    
7268   v t r 2 *                    r 3 v t r 3 *   v t r 2 *                    r 3 v t r 3 *
 @end smallexample  
7269  @end group  @end group
7270    @end smallexample
7271    
7272  @noindent  @noindent
7273  (Hey, those numbers look familiar!)  (Hey, those numbers look familiar!)
7274    
 @group  
7275  @smallexample  @smallexample
7276    @group
7277  1:  [0.52141679, -0.425978]  1:  [0.52141679, -0.425978]
7278      .      .
7279    
7280      /      /
 @end smallexample  
7281  @end group  @end group
7282    @end smallexample
7283    
7284  Since we were solving equations of the form @c{$m \times x + b \times 1 = y$}  Since we were solving equations of the form @c{$m \times x + b \times 1 = y$}
7285  @cite{m*x + b*1 = y}, these  @cite{m*x + b*1 = y}, these
# Line 7397  fits.  @xref{Curve Fitting}. Line 7298  fits.  @xref{Curve Fitting}.
7298  @subsection List Tutorial Exercise 3  @subsection List Tutorial Exercise 3
7299    
7300  @noindent  @noindent
7301  Move to one end of the list and press @kbd{C-@@} (or @kbd{C-SPC} or  Move to one end of the list and press @kbd{C-@@} (or @kbd{C-@key{SPC}} or
7302  whatever) to set the mark, then move to the other end of the list  whatever) to set the mark, then move to the other end of the list
7303  and type @w{@kbd{M-# g}}.  and type @w{@kbd{M-# g}}.
7304    
 @group  
7305  @smallexample  @smallexample
7306    @group
7307  1:  [2.3, 6, 22, 15.1, 7, 15, 14, 7.5, 2.5]  1:  [2.3, 6, 22, 15.1, 7, 15, 14, 7.5, 2.5]
7308      .      .
 @end smallexample  
7309  @end group  @end group
7310    @end smallexample
7311    
7312  To make things interesting, let's assume we don't know at a glance  To make things interesting, let's assume we don't know at a glance
7313  how many numbers are in this list.  Then we could type:  how many numbers are in this list.  Then we could type:
7314    
 @group  
7315  @smallexample  @smallexample
7316    @group
7317  2:  [2.3, 6, 22, ... ]     2:  [2.3, 6, 22, ... ]  2:  [2.3, 6, 22, ... ]     2:  [2.3, 6, 22, ... ]
7318  1:  [2.3, 6, 22, ... ]     1:  126356422.5  1:  [2.3, 6, 22, ... ]     1:  126356422.5
7319      .                          .      .                          .
7320    
7321      RET                        V R *      @key{RET}                        V R *
7322    
 @end smallexample  
7323  @end group  @end group
7324    @end smallexample
7325  @noindent  @noindent
 @group  
7326  @smallexample  @smallexample
7327    @group
7328  2:  126356422.5            2:  126356422.5     1:  7.94652913734  2:  126356422.5            2:  126356422.5     1:  7.94652913734
7329  1:  [2.3, 6, 22, ... ]     1:  9                   .  1:  [2.3, 6, 22, ... ]     1:  9                   .
7330      .                          .      .                          .
7331    
7332      TAB                        v l                 I ^      @key{TAB}                        v l                 I ^
 @end smallexample  
7333  @end group  @end group
7334    @end smallexample
7335    
7336  @noindent  @noindent
7337  (The @kbd{I ^} command computes the @var{n}th root of a number.  (The @kbd{I ^} command computes the @var{n}th root of a number.
# Line 7445  A number @cite{j} is a divisor of @cite{ Line 7346  A number @cite{j} is a divisor of @cite{
7346  @samp{n % j = 0}.  The first  @samp{n % j = 0}.  The first
7347  step is to get a vector that identifies the divisors.  step is to get a vector that identifies the divisors.
7348    
 @group  
7349  @smallexample  @smallexample
7350    @group
7351  2:  30                  2:  [0, 0, 0, 2, ...]    1:  [1, 1, 1, 0, ...]  2:  30                  2:  [0, 0, 0, 2, ...]    1:  [1, 1, 1, 0, ...]
7352  1:  [1, 2, 3, 4, ...]   1:  0                        .  1:  [1, 2, 3, 4, ...]   1:  0                        .
7353      .                       .      .                       .
7354    
7355   30 RET v x 30 RET   s 1    V M %  0                 V M a =  s 2   30 @key{RET} v x 30 @key{RET}   s 1    V M %  0                 V M a =  s 2
 @end smallexample  
7356  @end group  @end group
7357    @end smallexample
7358    
7359  @noindent  @noindent
7360  This vector has 1's marking divisors of 30 and 0's marking non-divisors.  This vector has 1's marking divisors of 30 and 0's marking non-divisors.
# Line 7461  This vector has 1's marking divisors of Line 7362  This vector has 1's marking divisors of
7362  The zeroth divisor function is just the total number of divisors.  The zeroth divisor function is just the total number of divisors.
7363  The first divisor function is the sum of the divisors.  The first divisor function is the sum of the divisors.
7364    
 @group  
7365  @smallexample  @smallexample
7366    @group
7367  1:  8      3:  8                    2:  8                    2:  8  1:  8      3:  8                    2:  8                    2:  8
7368             2:  [1, 2, 3, 4, ...]    1:  [1, 2, 3, 0, ...]    1:  72             2:  [1, 2, 3, 4, ...]    1:  [1, 2, 3, 0, ...]    1:  72
7369             1:  [1, 1, 1, 0, ...]        .                        .             1:  [1, 1, 1, 0, ...]        .                        .
7370                 .                 .
7371    
7372     V R +       r 1 r 2                  V M *                  V R +     V R +       r 1 r 2                  V M *                  V R +
 @end smallexample  
7373  @end group  @end group
7374    @end smallexample
7375    
7376  @noindent  @noindent
7377  Once again, the last two steps just compute a dot product for which  Once again, the last two steps just compute a dot product for which
# Line 7485  This list will always be in sorted order Line 7386  This list will always be in sorted order
7386  they will be right next to each other.  A suitable method is to compare  they will be right next to each other.  A suitable method is to compare
7387  the list with a copy of itself shifted over by one.  the list with a copy of itself shifted over by one.
7388    
 @group  
7389  @smallexample  @smallexample
7390    @group
7391  1:  [3, 7, 7, 7, 19]   2:  [3, 7, 7, 7, 19]     2:  [3, 7, 7, 7, 19, 0]  1:  [3, 7, 7, 7, 19]   2:  [3, 7, 7, 7, 19]     2:  [3, 7, 7, 7, 19, 0]
7392      .                  1:  [3, 7, 7, 7, 19, 0]  1:  [0, 3, 7, 7, 7, 19]      .                  1:  [3, 7, 7, 7, 19, 0]  1:  [0, 3, 7, 7, 7, 19]
7393                             .                        .                             .                        .
7394    
7395      19551 k f              RET 0 |                  TAB 0 TAB |      19551 k f              @key{RET} 0 |                  @key{TAB} 0 @key{TAB} |
7396    
 @end smallexample  
7397  @end group  @end group
7398    @end smallexample
7399  @noindent  @noindent
 @group  
7400  @smallexample  @smallexample
7401    @group
7402  1:  [0, 0, 1, 1, 0, 0]   1:  2          1:  0  1:  [0, 0, 1, 1, 0, 0]   1:  2          1:  0
7403      .                        .              .      .                        .              .
7404    
7405      V M a =                  V R +          0 a =      V M a =                  V R +          0 a =
 @end smallexample  
7406  @end group  @end group
7407    @end smallexample
7408    
7409  @noindent  @noindent
7410  Note that we have to arrange for both vectors to have the same length  Note that we have to arrange for both vectors to have the same length
# Line 7520  more convenient way to do the above test Line 7421  more convenient way to do the above test
7421  @subsection List Tutorial Exercise 6  @subsection List Tutorial Exercise 6
7422    
7423  @noindent  @noindent
7424  First use @kbd{v x 6 RET} to get a list of integers, then @kbd{V M v x}  First use @kbd{v x 6 @key{RET}} to get a list of integers, then @kbd{V M v x}
7425  to get a list of lists of integers!  to get a list of lists of integers!
7426    
7427  @node List Answer 7, List Answer 8, List Answer 6, Answers to Exercises  @node List Answer 7, List Answer 8, List Answer 6, Answers to Exercises
# Line 7530  to get a list of lists of integers! Line 7431  to get a list of lists of integers!
7431  Here's one solution.  First, compute the triangular list from the previous  Here's one solution.  First, compute the triangular list from the previous
7432  exercise and type @kbd{1 -} to subtract one from all the elements.  exercise and type @kbd{1 -} to subtract one from all the elements.
7433    
 @group  
7434  @smallexample  @smallexample
7435    @group
7436  1:  [ [0],  1:  [ [0],
7437        [0, 1],        [0, 1],
7438        [0, 1, 2],        [0, 1, 2],
7439        @dots{}        @dots{}
7440    
7441      1 -      1 -
 @end smallexample  
7442  @end group  @end group
7443    @end smallexample
7444    
7445  The numbers down the lefthand edge of the list we desire are called  The numbers down the lefthand edge of the list we desire are called
7446  the ``triangular numbers'' (now you know why!).  The @cite{n}th  the ``triangular numbers'' (now you know why!).  The @cite{n}th
# Line 7547  triangular number is the sum of the inte Line 7448  triangular number is the sum of the inte
7448  can be computed directly by the formula @c{$n (n+1) \over 2$}  can be computed directly by the formula @c{$n (n+1) \over 2$}
7449  @cite{n * (n+1) / 2}.  @cite{n * (n+1) / 2}.
7450    
 @group  
7451  @smallexample  @smallexample
7452    @group
7453  2:  [ [0], [0, 1], ... ]    2:  [ [0], [0, 1], ... ]  2:  [ [0], [0, 1], ... ]    2:  [ [0], [0, 1], ... ]
7454  1:  [0, 1, 2, 3, 4, 5]      1:  [0, 1, 3, 6, 10, 15]  1:  [0, 1, 2, 3, 4, 5]      1:  [0, 1, 3, 6, 10, 15]
7455      .                           .      .                           .
7456    
7457      v x 6 RET 1 -               V M ' $ ($+1)/2 RET      v x 6 @key{RET} 1 -               V M ' $ ($+1)/2 @key{RET}
 @end smallexample  
7458  @end group  @end group
7459    @end smallexample
7460    
7461  @noindent  @noindent
7462  Adding this list to the above list of lists produces the desired  Adding this list to the above list of lists produces the desired
7463  result:  result:
7464    
 @group  
7465  @smallexample  @smallexample
7466    @group
7467  1:  [ [0],  1:  [ [0],
7468        [1, 2],        [1, 2],
7469        [3, 4, 5],        [3, 4, 5],
# Line 7572  result: Line 7473  result:
7473        .        .
7474    
7475        V M +        V M +
 @end smallexample  
7476  @end group  @end group
7477    @end smallexample
7478    
7479  If we did not know the formula for triangular numbers, we could have  If we did not know the formula for triangular numbers, we could have
7480  computed them using a @kbd{V U +} command.  We could also have  computed them using a @kbd{V U +} command.  We could also have
7481  gotten them the hard way by mapping a reduction across the original  gotten them the hard way by mapping a reduction across the original
7482  triangular list.  triangular list.
7483    
 @group  
7484  @smallexample  @smallexample
7485    @group
7486  2:  [ [0], [0, 1], ... ]    2:  [ [0], [0, 1], ... ]  2:  [ [0], [0, 1], ... ]    2:  [ [0], [0, 1], ... ]
7487  1:  [ [0], [0, 1], ... ]    1:  [0, 1, 3, 6, 10, 15]  1:  [ [0], [0, 1], ... ]    1:  [0, 1, 3, 6, 10, 15]
7488      .                           .      .                           .
7489    
7490      RET                         V M V R +      @key{RET}                         V M V R +
 @end smallexample  
7491  @end group  @end group
7492    @end smallexample
7493    
7494  @noindent  @noindent
7495  (This means ``map a @kbd{V R +} command across the vector,'' and  (This means ``map a @kbd{V R +} command across the vector,'' and
# Line 7601  since each element of the main vector is Line 7502  since each element of the main vector is
7502  @noindent  @noindent
7503  The first step is to build a list of values of @cite{x}.  The first step is to build a list of values of @cite{x}.
7504    
 @group  
7505  @smallexample  @smallexample
7506    @group
7507  1:  [1, 2, 3, ..., 21]  1:  [0, 1, 2, ..., 20]  1:  [0, 0.25, 0.5, ..., 5]  1:  [1, 2, 3, ..., 21]  1:  [0, 1, 2, ..., 20]  1:  [0, 0.25, 0.5, ..., 5]
7508      .                       .                       .      .                       .                       .
7509    
7510      v x 21 RET              1 -                     4 /  s 1      v x 21 @key{RET}              1 -                     4 /  s 1
 @end smallexample  
7511  @end group  @end group
7512    @end smallexample
7513    
7514  Next, we compute the Bessel function values.  Next, we compute the Bessel function values.
7515    
 @group  
7516  @smallexample  @smallexample
7517    @group
7518  1:  [0., 0.124, 0.242, ..., -0.328]  1:  [0., 0.124, 0.242, ..., -0.328]
7519      .      .
7520    
7521      V M ' besJ(1,$) RET      V M ' besJ(1,$) @key{RET}
 @end smallexample  
7522  @end group  @end group
7523    @end smallexample
7524    
7525  @noindent  @noindent
7526  (Another way to do this would be @kbd{1 TAB V M f j}.)  (Another way to do this would be @kbd{1 @key{TAB} V M f j}.)
7527    
7528  A way to isolate the maximum value is to compute the maximum using  A way to isolate the maximum value is to compute the maximum using
7529  @kbd{V R X}, then compare all the Bessel values with that maximum.  @kbd{V R X}, then compare all the Bessel values with that maximum.
7530    
 @group  
7531  @smallexample  @smallexample
7532    @group
7533  2:  [0., 0.124, 0.242, ... ]   1:  [0, 0, 0, ... ]    2:  [0, 0, 0, ... ]  2:  [0., 0.124, 0.242, ... ]   1:  [0, 0, 0, ... ]    2:  [0, 0, 0, ... ]
7534  1:  0.5801562                      .                  1:  1  1:  0.5801562                      .                  1:  1
7535      .                                                     .      .                                                     .
7536    
7537      RET V R X                      V M a =                RET V R +    DEL      @key{RET} V R X                      V M a =                @key{RET} V R +    @key{DEL}
 @end smallexample  
7538  @end group  @end group
7539    @end smallexample
7540    
7541  @noindent  @noindent
7542  It's a good idea to verify, as in the last step above, that only  It's a good idea to verify, as in the last step above, that only
# Line 7647  The vector we have now has a single 1 in Line 7548  The vector we have now has a single 1 in
7548  the maximum value of @cite{x}.  Now it is a simple matter to convert  the maximum value of @cite{x}.  Now it is a simple matter to convert
7549  this back into the corresponding value itself.  this back into the corresponding value itself.
7550    
 @group  
7551  @smallexample  @smallexample
7552    @group
7553  2:  [0, 0, 0, ... ]         1:  [0, 0., 0., ... ]    1:  1.75  2:  [0, 0, 0, ... ]         1:  [0, 0., 0., ... ]    1:  1.75
7554  1:  [0, 0.25, 0.5, ... ]        .                        .  1:  [0, 0.25, 0.5, ... ]        .                        .
7555      .      .
7556    
7557      r 1                         V M *                    V R +      r 1                         V M *                    V R +
 @end smallexample  
7558  @end group  @end group
7559    @end smallexample
7560    
7561  If @kbd{a =} had produced more than one @cite{1} value, this method  If @kbd{a =} had produced more than one @cite{1} value, this method
7562  would have given the sum of all maximum @cite{x} values; not very  would have given the sum of all maximum @cite{x} values; not very
# Line 7668  The built-in @kbd{a X} command maximizes Line 7569  The built-in @kbd{a X} command maximizes
7569  efficient methods.  Just for illustration, let's use @kbd{a X}  efficient methods.  Just for illustration, let's use @kbd{a X}
7570  to maximize @samp{besJ(1,x)} over this same interval.  to maximize @samp{besJ(1,x)} over this same interval.
7571    
 @group  
7572  @smallexample  @smallexample
7573    @group
7574  2:  besJ(1, x)                 1:  [1.84115, 0.581865]  2:  besJ(1, x)                 1:  [1.84115, 0.581865]
7575  1:  [0 .. 5]                       .  1:  [0 .. 5]                       .
7576      .      .
7577    
7578  ' besJ(1,x), [0..5] RET            a X x RET  ' besJ(1,x), [0..5] @key{RET}            a X x @key{RET}
 @end smallexample  
7579  @end group  @end group
7580    @end smallexample
7581    
7582  @noindent  @noindent
7583  The output from @kbd{a X} is a vector containing the value of @cite{x}  The output from @kbd{a X} is a vector containing the value of @cite{x}
# Line 7689  As you can see, our simple search got qu Line 7590  As you can see, our simple search got qu
7590  @noindent  @noindent
7591  Step one is to convert our integer into vector notation.  Step one is to convert our integer into vector notation.
7592    
 @group  
7593  @smallexample  @smallexample
7594    @group
7595  1:  25129925999           3:  25129925999  1:  25129925999           3:  25129925999
7596      .                     2:  10      .                     2:  10
7597                            1:  [11, 10, 9, ..., 1, 0]                            1:  [11, 10, 9, ..., 1, 0]
7598                                .                                .
7599    
7600      25129925999 RET           10 RET 12 RET v x 12 RET -      25129925999 @key{RET}           10 @key{RET} 12 @key{RET} v x 12 @key{RET} -
7601    
 @end smallexample  
7602  @end group  @end group
7603    @end smallexample
7604  @noindent  @noindent
 @group  
7605  @smallexample  @smallexample
7606    @group
7607  1:  25129925999              1:  [0, 2, 25, 251, 2512, ... ]  1:  25129925999              1:  [0, 2, 25, 251, 2512, ... ]
7608  2:  [100000000000, ... ]         .  2:  [100000000000, ... ]         .
7609      .      .
7610    
7611      V M ^   s 1                  V M \      V M ^   s 1                  V M \
 @end smallexample  
7612  @end group  @end group
7613    @end smallexample
7614    
7615  @noindent  @noindent
7616  (Recall, the @kbd{\} command computes an integer quotient.)  (Recall, the @kbd{\} command computes an integer quotient.)
7617    
 @group  
7618  @smallexample  @smallexample
7619    @group
7620  1:  [0, 2, 5, 1, 2, 9, 9, 2, 5, 9, 9, 9]  1:  [0, 2, 5, 1, 2, 9, 9, 2, 5, 9, 9, 9]
7621      .      .
7622    
7623      10 V M %   s 2      10 V M %   s 2
 @end smallexample  
7624  @end group  @end group
7625    @end smallexample
7626    
7627  Next we must increment this number.  This involves adding one to  Next we must increment this number.  This involves adding one to
7628  the last digit, plus handling carries.  There is a carry to the  the last digit, plus handling carries.  There is a carry to the
7629  left out of a digit if that digit is a nine and all the digits to  left out of a digit if that digit is a nine and all the digits to
7630  the right of it are nines.  the right of it are nines.
7631    
 @group  
7632  @smallexample  @smallexample
7633    @group
7634  1:  [0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1]   1:  [1, 1, 1, 0, 0, 1, ... ]  1:  [0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1]   1:  [1, 1, 1, 0, 0, 1, ... ]
7635      .                                          .      .                                          .
7636    
7637      9 V M a =                                  v v      9 V M a =                                  v v
7638    
 @end smallexample  
7639  @end group  @end group
7640    @end smallexample
7641  @noindent  @noindent
 @group  
7642  @smallexample  @smallexample
7643    @group
7644  1:  [1, 1, 1, 0, 0, 0, ... ]   1:  [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]  1:  [1, 1, 1, 0, 0, 0, ... ]   1:  [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]
7645      .                              .      .                              .
7646    
7647      V U *                          v v 1 |      V U *                          v v 1 |
 @end smallexample  
7648  @end group  @end group
7649    @end smallexample
7650    
7651  @noindent  @noindent
7652  Accumulating @kbd{*} across a vector of ones and zeros will preserve  Accumulating @kbd{*} across a vector of ones and zeros will preserve
# Line 7754  except the rightmost digit.  Concatenati Line 7655  except the rightmost digit.  Concatenati
7655  care of aligning the carries properly, and also adding one to the  care of aligning the carries properly, and also adding one to the
7656  rightmost digit.  rightmost digit.
7657    
 @group  
7658  @smallexample  @smallexample
7659    @group
7660  2:  [0, 0, 0, 0, ... ]     1:  [0, 0, 2, 5, 1, 2, 9, 9, 2, 6, 0, 0, 0]  2:  [0, 0, 0, 0, ... ]     1:  [0, 0, 2, 5, 1, 2, 9, 9, 2, 6, 0, 0, 0]
7661  1:  [0, 0, 2, 5, ... ]         .  1:  [0, 0, 2, 5, ... ]         .
7662      .      .
7663    
7664      0 r 2 |                    V M +  10 V M %      0 r 2 |                    V M +  10 V M %
 @end smallexample  
7665  @end group  @end group
7666    @end smallexample
7667    
7668  @noindent  @noindent
7669  Here we have concatenated 0 to the @emph{left} of the original number;  Here we have concatenated 0 to the @emph{left} of the original number;
# Line 7771  digits that generated them. Line 7672  digits that generated them.
7672    
7673  Finally, we must convert this list back into an integer.  Finally, we must convert this list back into an integer.
7674    
 @group  
7675  @smallexample  @smallexample
7676    @group
7677  3:  [0, 0, 2, 5, ... ]        2:  [0, 0, 2, 5, ... ]  3:  [0, 0, 2, 5, ... ]        2:  [0, 0, 2, 5, ... ]
7678  2:  1000000000000             1:  [1000000000000, 100000000000, ... ]  2:  1000000000000             1:  [1000000000000, 100000000000, ... ]
7679  1:  [100000000000, ... ]          .  1:  [100000000000, ... ]          .
7680      .      .
7681    
7682      10 RET 12 ^  r 1              |      10 @key{RET} 12 ^  r 1              |
7683    
 @end smallexample  
7684  @end group  @end group
7685    @end smallexample
7686  @noindent  @noindent
 @group  
7687  @smallexample  @smallexample
7688    @group
7689  1:  [0, 0, 20000000000, 5000000000, ... ]    1:  25129926000  1:  [0, 0, 20000000000, 5000000000, ... ]    1:  25129926000
7690      .                                            .      .                                            .
7691    
7692      V M *                                        V R +      V M *                                        V R +
 @end smallexample  
7693  @end group  @end group
7694    @end smallexample
7695    
7696  @noindent  @noindent
7697  Another way to do this final step would be to reduce the formula  Another way to do this final step would be to reduce the formula
7698  @w{@samp{10 $$ + $}} across the vector of digits.  @w{@samp{10 $$ + $}} across the vector of digits.
7699    
 @group  
7700  @smallexample  @smallexample
7701    @group
7702  1:  [0, 0, 2, 5, ... ]        1:  25129926000  1:  [0, 0, 2, 5, ... ]        1:  25129926000
7703      .                             .      .                             .
7704    
7705                                    V R ' 10 $$ + $ RET                                    V R ' 10 $$ + $ @key{RET}
 @end smallexample  
7706  @end group  @end group
7707    @end smallexample
7708    
7709  @node List Answer 10, List Answer 11, List Answer 9, Answers to Exercises  @node List Answer 10, List Answer 11, List Answer 9, Answers to Exercises
7710  @subsection List Tutorial Exercise 10  @subsection List Tutorial Exercise 10
# Line 7816  compared with @cite{d}.  This is not at Line 7717  compared with @cite{d}.  This is not at
7717    
7718  Here's a more correct method:  Here's a more correct method:
7719    
 @group  
7720  @smallexample  @smallexample
7721    @group
7722  1:  [7, 7, 7, 8, 7]      2:  [7, 7, 7, 8, 7]  1:  [7, 7, 7, 8, 7]      2:  [7, 7, 7, 8, 7]
7723      .                    1:  7      .                    1:  7
7724                               .                               .
7725    
7726    ' [7,7,7,8,7] RET          RET v r 1 RET    ' [7,7,7,8,7] @key{RET}          @key{RET} v r 1 @key{RET}
7727    
 @end smallexample  
7728  @end group  @end group
7729    @end smallexample
7730  @noindent  @noindent
 @group  
7731  @smallexample  @smallexample
7732    @group
7733  1:  [1, 1, 1, 0, 1]      1:  0  1:  [1, 1, 1, 0, 1]      1:  0
7734      .                        .      .                        .
7735    
7736      V M a =                  V R *      V M a =                  V R *
 @end smallexample  
7737  @end group  @end group
7738    @end smallexample
7739    
7740  @node List Answer 11, List Answer 12, List Answer 10, Answers to Exercises  @node List Answer 11, List Answer 12, List Answer 10, Answers to Exercises
7741  @subsection List Tutorial Exercise 11  @subsection List Tutorial Exercise 11
# Line 7847  and a vector of @cite{y^2}. Line 7748  and a vector of @cite{y^2}.
7748  We can make this go a bit faster by using the @kbd{v .} and @kbd{t .}  We can make this go a bit faster by using the @kbd{v .} and @kbd{t .}
7749  commands.  commands.
7750    
 @group  
7751  @smallexample  @smallexample
7752    @group
7753  2:  [2., 2., ..., 2.]          2:  [2., 2., ..., 2.]  2:  [2., 2., ..., 2.]          2:  [2., 2., ..., 2.]
7754  1:  [2., 2., ..., 2.]          1:  [1.16, 1.98, ..., 0.81]  1:  [2., 2., ..., 2.]          1:  [1.16, 1.98, ..., 0.81]
7755      .                              .      .                              .
7756    
7757   v . t .  2. v b 100 RET RET       V M k r   v . t .  2. v b 100 @key{RET} @key{RET}       V M k r
7758    
 @end smallexample  
7759  @end group  @end group
7760    @end smallexample
7761  @noindent  @noindent
 @group  
7762  @smallexample  @smallexample
7763    @group
7764  2:  [2., 2., ..., 2.]          1:  [0.026, 0.96, ..., 0.036]  2:  [2., 2., ..., 2.]          1:  [0.026, 0.96, ..., 0.036]
7765  1:  [0.026, 0.96, ..., 0.036]  2:  [0.53, 0.81, ..., 0.094]  1:  [0.026, 0.96, ..., 0.036]  2:  [0.53, 0.81, ..., 0.094]
7766      .                              .      .                              .
7767    
7768      1 -  2 V M ^                   TAB  V M k r  1 -  2 V M ^      1 -  2 V M ^                   @key{TAB}  V M k r  1 -  2 V M ^
 @end smallexample  
7769  @end group  @end group
7770    @end smallexample
7771    
7772  Now we sum the @cite{x^2} and @cite{y^2} values, compare with 1 to  Now we sum the @cite{x^2} and @cite{y^2} values, compare with 1 to
7773  get a vector of 1/0 truth values, then sum the truth values.  get a vector of 1/0 truth values, then sum the truth values.
7774    
 @group  
7775  @smallexample  @smallexample
7776    @group
7777  1:  [0.56, 1.78, ..., 0.13]    1:  [1, 0, ..., 1]    1:  84  1:  [0.56, 1.78, ..., 0.13]    1:  [1, 0, ..., 1]    1:  84
7778      .                              .                     .      .                              .                     .
7779    
7780      +                              1 V M a <             V R +      +                              1 V M a <             V R +
 @end smallexample  
7781  @end group  @end group
7782    @end smallexample
7783    
7784  @noindent  @noindent
7785  The ratio @cite{84/100} should approximate the ratio @c{$\pi/4$}  The ratio @cite{84/100} should approximate the ratio @c{$\pi/4$}
7786  @cite{pi/4}.  @cite{pi/4}.
7787    
 @group  
7788  @smallexample  @smallexample
7789    @group
7790  1:  0.84       1:  3.36       2:  3.36       1:  1.0695  1:  0.84       1:  3.36       2:  3.36       1:  1.0695
7791      .              .          1:  3.14159        .      .              .          1:  3.14159        .
7792    
7793      100 /          4 *            P              /      100 /          4 *            P              /
 @end smallexample  
7794  @end group  @end group
7795    @end smallexample
7796    
7797  @noindent  @noindent
7798  Our estimate, 3.36, is off by about 7%.  We could get a better estimate  Our estimate, 3.36, is off by about 7%.  We could get a better estimate
# Line 7939  and count how many of the results are gr Line 7840  and count how many of the results are gr
7840  We can make this go a bit faster by using the @kbd{v .} and @kbd{t .}  We can make this go a bit faster by using the @kbd{v .} and @kbd{t .}
7841  commands.  commands.
7842    
 @group  
7843  @smallexample  @smallexample
7844    @group
7845  1:  [0.52, 0.71, ..., 0.72]    2:  [0.52, 0.71, ..., 0.72]  1:  [0.52, 0.71, ..., 0.72]    2:  [0.52, 0.71, ..., 0.72]
7846      .                          1:  [78.4, 64.5, ..., -42.9]      .                          1:  [78.4, 64.5, ..., -42.9]
7847                                     .                                     .
7848    
7849  v . t . 1. v b 100 RET  V M k r    180. v b 100 RET  V M k r  90 -  v . t . 1. v b 100 @key{RET}  V M k r    180. v b 100 @key{RET}  V M k r  90 -
 @end smallexample  
7850  @end group  @end group
7851    @end smallexample
7852    
7853  @noindent  @noindent
7854  (The next step may be slow, depending on the speed of your computer.)  (The next step may be slow, depending on the speed of your computer.)
7855    
 @group  
7856  @smallexample  @smallexample
7857    @group
7858  2:  [0.52, 0.71, ..., 0.72]    1:  [0.72, 1.14, ..., 1.45]  2:  [0.52, 0.71, ..., 0.72]    1:  [0.72, 1.14, ..., 1.45]
7859  1:  [0.20, 0.43, ..., 0.73]        .  1:  [0.20, 0.43, ..., 0.73]        .
7860      .      .
7861    
7862      m d  V M C                     +      m d  V M C                     +
7863    
 @end smallexample  
7864  @end group  @end group
7865    @end smallexample
7866  @noindent  @noindent
 @group  
7867  @smallexample  @smallexample
7868    @group
7869  1:  [0, 1, ..., 1]       1:  0.64            1:  3.125  1:  [0, 1, ..., 1]       1:  0.64            1:  3.125
7870      .                        .                   .      .                        .                   .
7871    
7872      1 V M a >                V R + 100 /         2 TAB /      1 V M a >                V R + 100 /         2 @key{TAB} /
 @end smallexample  
7873  @end group  @end group
7874    @end smallexample
7875    
7876  Let's try the third method, too.  We'll use random integers up to  Let's try the third method, too.  We'll use random integers up to
7877  one million.  The @kbd{k r} command with an integer argument picks  one million.  The @kbd{k r} command with an integer argument picks
7878  a random integer.  a random integer.
7879    
 @group  
7880  @smallexample  @smallexample
7881    @group
7882  2:  [1000000, 1000000, ..., 1000000]   2:  [78489, 527587, ..., 814975]  2:  [1000000, 1000000, ..., 1000000]   2:  [78489, 527587, ..., 814975]
7883  1:  [1000000, 1000000, ..., 1000000]   1:  [324014, 358783, ..., 955450]  1:  [1000000, 1000000, ..., 1000000]   1:  [324014, 358783, ..., 955450]
7884      .                                      .      .                                      .
7885    
7886      1000000 v b 100 RET RET                V M k r  TAB  V M k r      1000000 v b 100 @key{RET} @key{RET}                V M k r  @key{TAB}  V M k r
7887    
 @end smallexample  
7888  @end group  @end group
7889    @end smallexample
7890  @noindent  @noindent
 @group  
7891  @smallexample  @smallexample
7892    @group
7893  1:  [1, 1, ..., 25]      1:  [1, 1, ..., 0]     1:  0.56  1:  [1, 1, ..., 25]      1:  [1, 1, ..., 0]     1:  0.56
7894      .                        .                      .      .                        .                      .
7895    
7896      V M k g                  1 V M a =              V R + 100 /      V M k g                  1 V M a =              V R + 100 /
7897    
 @end smallexample  
7898  @end group  @end group
7899    @end smallexample
7900  @noindent  @noindent
 @group  
7901  @smallexample  @smallexample
7902    @group
7903  1:  10.714        1:  3.273  1:  10.714        1:  3.273
7904      .                 .      .                 .
7905    
7906      6 TAB /           Q      6 @key{TAB} /           Q
 @end smallexample  
7907  @end group  @end group
7908    @end smallexample
7909    
7910  For a proof of this property of the GCD function, see section 4.5.2,  For a proof of this property of the GCD function, see section 4.5.2,
7911  exercise 10, of Knuth's @emph{Art of Computer Programming}, volume II.  exercise 10, of Knuth's @emph{Art of Computer Programming}, volume II.
# Line 8018  return to full-sized display of vectors. Line 7919  return to full-sized display of vectors.
7919  @noindent  @noindent
7920  First, we put the string on the stack as a vector of ASCII codes.  First, we put the string on the stack as a vector of ASCII codes.
7921    
 @group  
7922  @smallexample  @smallexample
7923    @group
7924  1:  [84, 101, 115, ..., 51]  1:  [84, 101, 115, ..., 51]
7925      .      .
7926    
7927      "Testing, 1, 2, 3 RET      "Testing, 1, 2, 3 @key{RET}
 @end smallexample  
7928  @end group  @end group
7929    @end smallexample
7930    
7931  @noindent  @noindent
7932  Note that the @kbd{"} key, like @kbd{$}, initiates algebraic entry so  Note that the @kbd{"} key, like @kbd{$}, initiates algebraic entry so
# Line 8038  if the input vector is @cite{[a, b, c, d Line 7939  if the input vector is @cite{[a, b, c, d
7939  @cite{3 (3 (3a + b) + c) + d = 27a + 9b + 3c + d}.  In other words,  @cite{3 (3 (3a + b) + c) + d = 27a + 9b + 3c + d}.  In other words,
7940  it's a sum of descending powers of three times the ASCII codes.  it's a sum of descending powers of three times the ASCII codes.
7941    
 @group  
7942  @smallexample  @smallexample
7943    @group
7944  2:  [84, 101, 115, ..., 51]    2:  [84, 101, 115, ..., 51]  2:  [84, 101, 115, ..., 51]    2:  [84, 101, 115, ..., 51]
7945  1:  16                         1:  [15, 14, 13, ..., 0]  1:  16                         1:  [15, 14, 13, ..., 0]
7946      .                              .      .                              .
7947    
7948      RET v l                        v x 16 RET -      @key{RET} v l                        v x 16 @key{RET} -
7949    
 @end smallexample  
7950  @end group  @end group
7951    @end smallexample
7952  @noindent  @noindent
 @group  
7953  @smallexample  @smallexample
7954    @group
7955  2:  [84, 101, 115, ..., 51]    1:  1960915098    1:  121  2:  [84, 101, 115, ..., 51]    1:  1960915098    1:  121
7956  1:  [14348907, ..., 1]             .                 .  1:  [14348907, ..., 1]             .                 .
7957      .      .
7958    
7959      3 TAB V M ^                    *                 511 %      3 @key{TAB} V M ^                    *                 511 %
 @end smallexample  
7960  @end group  @end group
7961    @end smallexample
7962    
7963  @noindent  @noindent
7964  Once again, @kbd{*} elegantly summarizes most of the computation.  Once again, @kbd{*} elegantly summarizes most of the computation.
# Line 8066  But there's an even more elegant approac Line 7967  But there's an even more elegant approac
7967  function of two arguments that computes its first argument times three  function of two arguments that computes its first argument times three
7968  plus its second argument.  plus its second argument.
7969    
 @group  
7970  @smallexample  @smallexample
7971    @group
7972  1:  [84, 101, 115, ..., 51]    1:  1960915098  1:  [84, 101, 115, ..., 51]    1:  1960915098
7973      .                              .      .                              .
7974    
7975      "Testing, 1, 2, 3 RET          V R ' 3$$+$ RET      "Testing, 1, 2, 3 @key{RET}          V R ' 3$$+$ @key{RET}
 @end smallexample  
7976  @end group  @end group
7977    @end smallexample
7978    
7979  @noindent  @noindent
7980  If you did the decimal arithmetic exercise, this will be familiar.  If you did the decimal arithmetic exercise, this will be familiar.
# Line 8087  without affecting the result.  While thi Line 7988  without affecting the result.  While thi
7988  arithmetic operations, the numbers we operate on remain small so  arithmetic operations, the numbers we operate on remain small so
7989  the operations are faster.  the operations are faster.
7990    
 @group  
7991  @smallexample  @smallexample
7992    @group
7993  1:  [84, 101, 115, ..., 51]    1:  121  1:  [84, 101, 115, ..., 51]    1:  121
7994      .                              .      .                              .
7995    
7996      "Testing, 1, 2, 3 RET          V R ' (3$$+$)%511 RET      "Testing, 1, 2, 3 @key{RET}          V R ' (3$$+$)%511 @key{RET}
 @end smallexample  
7997  @end group  @end group
7998    @end smallexample
7999    
8000  Why does this work?  Think about a two-step computation:  Why does this work?  Think about a two-step computation:
8001  @w{@cite{3 (3a + b) + c}}.  Taking a result modulo 511 basically means  @w{@cite{3 (3a + b) + c}}.  Taking a result modulo 511 basically means
# Line 8153  the calculation.  Therefore the two meth Line 8054  the calculation.  Therefore the two meth
8054    
8055  Later in the tutorial we will encounter @dfn{modulo forms}, which  Later in the tutorial we will encounter @dfn{modulo forms}, which
8056  basically automate the idea of reducing every intermediate result  basically automate the idea of reducing every intermediate result
8057  modulo some value @i{M}.  modulo some value @var{m}.
8058    
8059  @node List Answer 14, Types Answer 1, List Answer 13, Answers to Exercises  @node List Answer 14, Types Answer 1, List Answer 13, Answers to Exercises
8060  @subsection List Tutorial Exercise 14  @subsection List Tutorial Exercise 14
# Line 8162  We want to use @kbd{H V U} to nest a fun Line 8063  We want to use @kbd{H V U} to nest a fun
8063  step to an @cite{(x,y)} coordinate.  The function is a bit long, but  step to an @cite{(x,y)} coordinate.  The function is a bit long, but
8064  otherwise the problem is quite straightforward.  otherwise the problem is quite straightforward.
8065    
 @group  
8066  @smallexample  @smallexample
8067    @group
8068  2:  [0, 0]     1:  [ [    0,       0    ]  2:  [0, 0]     1:  [ [    0,       0    ]
8069  1:  50               [  0.4288, -0.1695 ]  1:  50               [  0.4288, -0.1695 ]
8070      .                [ -0.4787, -0.9027 ]      .                [ -0.4787, -0.9027 ]
8071                       ...                       ...
8072    
8073      [0,0] 50       H V U ' <# + [random(2.0)-1, random(2.0)-1]> RET      [0,0] 50       H V U ' <# + [random(2.0)-1, random(2.0)-1]> @key{RET}
 @end smallexample  
8074  @end group  @end group
8075    @end smallexample
8076    
8077  Just as the text recommended, we used @samp{< >} nameless function  Just as the text recommended, we used @samp{< >} nameless function
8078  notation to keep the two @code{random} calls from being evaluated  notation to keep the two @code{random} calls from being evaluated
# Line 8181  We now have a vector of @cite{[x, y]} su Line 8082  We now have a vector of @cite{[x, y]} su
8082  rules acts like a matrix.  We can transpose this matrix and unpack  rules acts like a matrix.  We can transpose this matrix and unpack
8083  to get a pair of vectors, @cite{x} and @cite{y}, suitable for graphing.  to get a pair of vectors, @cite{x} and @cite{y}, suitable for graphing.
8084    
 @group  
8085  @smallexample  @smallexample
8086    @group
8087  2:  [ 0, 0.4288, -0.4787, ... ]  2:  [ 0, 0.4288, -0.4787, ... ]
8088  1:  [ 0, -0.1696, -0.9027, ... ]  1:  [ 0, -0.1696, -0.9027, ... ]
8089      .      .
8090    
8091      v t  v u  g f      v t  v u  g f
 @end smallexample  
8092  @end group  @end group
8093    @end smallexample
8094    
8095  Incidentally, because the @cite{x} and @cite{y} are completely  Incidentally, because the @cite{x} and @cite{y} are completely
8096  independent in this case, we could have done two separate commands  independent in this case, we could have done two separate commands
# Line 8200  a random direction exactly gives us an @ Line 8101  a random direction exactly gives us an @
8101  length; in fact, the new nesting function is even briefer, though  length; in fact, the new nesting function is even briefer, though
8102  we might want to lower the precision a bit for it.  we might want to lower the precision a bit for it.
8103    
 @group  
8104  @smallexample  @smallexample
8105    @group
8106  2:  [0, 0]     1:  [ [    0,      0    ]  2:  [0, 0]     1:  [ [    0,      0    ]
8107  1:  50               [  0.1318, 0.9912 ]  1:  50               [  0.1318, 0.9912 ]
8108      .                [ -0.5965, 0.3061 ]      .                [ -0.5965, 0.3061 ]
8109                       ...                       ...
8110    
8111      [0,0] 50   m d  p 6 RET   H V U ' <# + sincos(random(360.0))> RET      [0,0] 50   m d  p 6 @key{RET}   H V U ' <# + sincos(random(360.0))> @key{RET}
 @end smallexample  
8112  @end group  @end group
8113    @end smallexample
8114    
8115  Another @kbd{v t v u g f} sequence will graph this new random walk.  Another @kbd{v t v u g f} sequence will graph this new random walk.
8116    
# Line 8229  If the number is the square root of @c{$ Line 8130  If the number is the square root of @c{$
8130  then its square, divided by @c{$\pi$}  then its square, divided by @c{$\pi$}
8131  @cite{pi}, should be a rational number.  @cite{pi}, should be a rational number.
8132    
 @group  
8133  @smallexample  @smallexample
8134    @group
8135  1:  1.26508260337    1:  0.509433962268   1:  2486645810:4881193627  1:  1.26508260337    1:  0.509433962268   1:  2486645810:4881193627
8136      .                    .                    .      .                    .                    .
8137    
8138                           2 ^ P /              c F                           2 ^ P /              c F
 @end smallexample  
8139  @end group  @end group
8140    @end smallexample
8141    
8142  @noindent  @noindent
8143  Technically speaking this is a rational number, but not one that is  Technically speaking this is a rational number, but not one that is
# Line 8247  irrational number to within 12 digits. Line 8148  irrational number to within 12 digits.
8148  But perhaps our result was not quite exact.  Let's reduce the  But perhaps our result was not quite exact.  Let's reduce the
8149  precision slightly and try again:  precision slightly and try again:
8150    
 @group  
8151  @smallexample  @smallexample
8152    @group
8153  1:  0.509433962268     1:  27:53  1:  0.509433962268     1:  27:53
8154      .                      .      .                      .
8155    
8156      U p 10 RET             c F      U p 10 @key{RET}             c F
 @end smallexample  
8157  @end group  @end group
8158    @end smallexample
8159    
8160  @noindent  @noindent
8161  Aha!  It's unlikely that an irrational number would equal a fraction  Aha!  It's unlikely that an irrational number would equal a fraction
# Line 8327  unable to tell what the true answer is. Line 8228  unable to tell what the true answer is.
8228  @node Types Answer 4, Types Answer 5, Types Answer 3, Answers to Exercises  @node Types Answer 4, Types Answer 5, Types Answer 3, Answers to Exercises
8229  @subsection Types Tutorial Exercise 4  @subsection Types Tutorial Exercise 4
8230    
 @group  
8231  @smallexample  @smallexample
8232    @group
8233  2:  0@@ 47' 26"              1:  0@@ 2' 47.411765"  2:  0@@ 47' 26"              1:  0@@ 2' 47.411765"
8234  1:  17                          .  1:  17                          .
8235      .      .
8236    
8237      0@@ 47' 26" RET 17           /      0@@ 47' 26" @key{RET} 17           /
 @end smallexample  
8238  @end group  @end group
8239    @end smallexample
8240    
8241  @noindent  @noindent
8242  The average song length is two minutes and 47.4 seconds.  The average song length is two minutes and 47.4 seconds.
8243    
 @group  
8244  @smallexample  @smallexample
8245    @group
8246  2:  0@@ 2' 47.411765"     1:  0@@ 3' 7.411765"    1:  0@@ 53' 6.000005"  2:  0@@ 2' 47.411765"     1:  0@@ 3' 7.411765"    1:  0@@ 53' 6.000005"
8247  1:  0@@ 0' 20"                .                      .  1:  0@@ 0' 20"                .                      .
8248      .      .
8249    
8250      20"                      +                      17 *      20"                      +                      17 *
 @end smallexample  
8251  @end group  @end group
8252    @end smallexample
8253    
8254  @noindent  @noindent
8255  The album would be 53 minutes and 6 seconds long.  The album would be 53 minutes and 6 seconds long.
# Line 8361  Let's suppose it's January 14, 1991.  Th Line 8262  Let's suppose it's January 14, 1991.  Th
8262  to keep trying 13ths of months until Calc reports a Friday.  to keep trying 13ths of months until Calc reports a Friday.
8263  We can do this by manually entering dates, or by using @kbd{t I}:  We can do this by manually entering dates, or by using @kbd{t I}:
8264    
 @group  
8265  @smallexample  @smallexample
8266    @group
8267  1:  <Wed Feb 13, 1991>    1:  <Wed Mar 13, 1991>   1:  <Sat Apr 13, 1991>  1:  <Wed Feb 13, 1991>    1:  <Wed Mar 13, 1991>   1:  <Sat Apr 13, 1991>
8268      .                         .                        .      .                         .                        .
8269    
8270      ' <2/13> RET       DEL    ' <3/13> RET             t I      ' <2/13> @key{RET}       @key{DEL}    ' <3/13> @key{RET}             t I
 @end smallexample  
8271  @end group  @end group
8272    @end smallexample
8273    
8274  @noindent  @noindent
8275  (Calc assumes the current year if you don't say otherwise.)  (Calc assumes the current year if you don't say otherwise.)
# Line 8379  vector mapping.  The @kbd{t I} command a Line 8280  vector mapping.  The @kbd{t I} command a
8280  ``how-many-months'' argument, which defaults to one.  This  ``how-many-months'' argument, which defaults to one.  This
8281  argument is exactly what we want to map over:  argument is exactly what we want to map over:
8282    
 @group  
8283  @smallexample  @smallexample
8284    @group
8285  2:  <Sat Apr 13, 1991>     1:  [<Mon May 13, 1991>, <Thu Jun 13, 1991>,  2:  <Sat Apr 13, 1991>     1:  [<Mon May 13, 1991>, <Thu Jun 13, 1991>,
8286  1:  [1, 2, 3, 4, 5, 6]          <Sat Jul 13, 1991>, <Tue Aug 13, 1991>,  1:  [1, 2, 3, 4, 5, 6]          <Sat Jul 13, 1991>, <Tue Aug 13, 1991>,
8287      .                           <Fri Sep 13, 1991>, <Sun Oct 13, 1991>]      .                           <Fri Sep 13, 1991>, <Sun Oct 13, 1991>]
8288                                 .                                 .
8289    
8290      v x 6 RET                  V M t I      v x 6 @key{RET}                  V M t I
 @end smallexample  
8291  @end group  @end group
8292    @end smallexample
8293    
8294  @ifinfo  @ifinfo
8295  @noindent  @noindent
# Line 8399  Et voila, September 13, 1991 is a Friday Line 8300  Et voila, September 13, 1991 is a Friday
8300  {\it Et voil{\accent"12 a}}, September 13, 1991 is a Friday.  {\it Et voil{\accent"12 a}}, September 13, 1991 is a Friday.
8301  @end tex  @end tex
8302    
 @group  
8303  @smallexample  @smallexample
8304    @group
8305  1:  242  1:  242
8306      .      .
8307    
8308  ' <sep 13> - <jan 14> RET  ' <sep 13> - <jan 14> @key{RET}
 @end smallexample  
8309  @end group  @end group
8310    @end smallexample
8311    
8312  @noindent  @noindent
8313  And the answer to our original question:  242 days to go.  And the answer to our original question:  242 days to go.
# Line 8428  the number of days between now and then, Line 8329  the number of days between now and then,
8329  number of years times 365.  The number of extra days we find must be  number of years times 365.  The number of extra days we find must be
8330  equal to the number of leap years there were.  equal to the number of leap years there were.
8331    
 @group  
8332  @smallexample  @smallexample
8333    @group
8334  1:  <Mon Jan 1, 10001>     2:  <Mon Jan 1, 10001>     1:  2925593  1:  <Mon Jan 1, 10001>     2:  <Mon Jan 1, 10001>     1:  2925593
8335      .                      1:  <Tue Jan 1, 1991>          .      .                      1:  <Tue Jan 1, 1991>          .
8336                                 .                                 .
8337    
8338    ' <jan 1 10001> RET         ' <jan 1 1991> RET          -    ' <jan 1 10001> @key{RET}         ' <jan 1 1991> @key{RET}          -
8339    
 @end smallexample  
8340  @end group  @end group
8341    @end smallexample
8342  @noindent  @noindent
 @group  
8343  @smallexample  @smallexample
8344    @group
8345  3:  2925593       2:  2925593     2:  2925593     1:  1943  3:  2925593       2:  2925593     2:  2925593     1:  1943
8346  2:  10001         1:  8010        1:  2923650         .  2:  10001         1:  8010        1:  2923650         .
8347  1:  1991              .               .  1:  1991              .               .
8348      .      .
8349    
8350    10001 RET 1991      -               365 *           -    10001 @key{RET} 1991      -               365 *           -
 @end smallexample  
8351  @end group  @end group
8352    @end smallexample
8353    
8354  @c [fix-ref Date Forms]  @c [fix-ref Date Forms]
8355  @noindent  @noindent
# Line 8464  background information in that regard.) Line 8365  background information in that regard.)
8365  The relative errors must be converted to absolute errors so that  The relative errors must be converted to absolute errors so that
8366  @samp{+/-} notation may be used.  @samp{+/-} notation may be used.
8367    
 @group  
8368  @smallexample  @smallexample
8369    @group
8370  1:  1.              2:  1.  1:  1.              2:  1.
8371      .               1:  0.2      .               1:  0.2
8372                          .                          .
8373    
8374      20 RET .05 *        4 RET .05 *      20 @key{RET} .05 *        4 @key{RET} .05 *
 @end smallexample  
8375  @end group  @end group
8376    @end smallexample
8377    
8378  Now we simply chug through the formula.  Now we simply chug through the formula.
8379    
 @group  
8380  @smallexample  @smallexample
8381    @group
8382  1:  19.7392088022    1:  394.78 +/- 19.739    1:  6316.5 +/- 706.21  1:  19.7392088022    1:  394.78 +/- 19.739    1:  6316.5 +/- 706.21
8383      .                    .                        .      .                    .                        .
8384    
8385      2 P 2 ^ *            20 p 1 *                 4 p .2 RET 2 ^ *      2 P 2 ^ *            20 p 1 *                 4 p .2 @key{RET} 2 ^ *
 @end smallexample  
8386  @end group  @end group
8387    @end smallexample
8388    
8389  It turns out the @kbd{v u} command will unpack an error form as  It turns out the @kbd{v u} command will unpack an error form as
8390  well as a vector.  This saves us some retyping of numbers.  well as a vector.  This saves us some retyping of numbers.
8391    
 @group  
8392  @smallexample  @smallexample
8393    @group
8394  3:  6316.5 +/- 706.21     2:  6316.5 +/- 706.21  3:  6316.5 +/- 706.21     2:  6316.5 +/- 706.21
8395  2:  6316.5                1:  0.1118  2:  6316.5                1:  0.1118
8396  1:  706.21                    .  1:  706.21                    .
8397      .      .
8398    
8399      RET v u                   TAB /      @key{RET} v u                   @key{TAB} /
 @end smallexample  
8400  @end group  @end group
8401    @end smallexample
8402    
8403  @noindent  @noindent
8404  Thus the volume is 6316 cubic centimeters, within about 11 percent.  Thus the volume is 6316 cubic centimeters, within about 11 percent.
# Line 8537  that interval arithmetic can do in this Line 8438  that interval arithmetic can do in this
8438  @node Types Answer 9, Types Answer 10, Types Answer 8, Answers to Exercises  @node Types Answer 9, Types Answer 10, Types Answer 8, Answers to Exercises
8439  @subsection Types Tutorial Exercise 9  @subsection Types Tutorial Exercise 9
8440    
 @group  
8441  @smallexample  @smallexample
8442    @group
8443  1:  [-3 .. 3]       2:  [-3 .. 3]     2:  [0 .. 9]  1:  [-3 .. 3]       2:  [-3 .. 3]     2:  [0 .. 9]
8444      .               1:  [0 .. 9]      1:  [-9 .. 9]      .               1:  [0 .. 9]      1:  [-9 .. 9]
8445                          .                 .                          .                 .
8446    
8447      [ 3 n .. 3 ]        RET 2 ^           TAB RET *      [ 3 n .. 3 ]        @key{RET} 2 ^           @key{TAB} @key{RET} *
 @end smallexample  
8448  @end group  @end group
8449    @end smallexample
8450    
8451  @noindent  @noindent
8452  In the first case the result says, ``if a number is between @i{-3} and  In the first case the result says, ``if a number is between @i{-3} and
# Line 8564  The same issue arises when you try to sq Line 8465  The same issue arises when you try to sq
8465  @noindent  @noindent
8466  Testing the first number, we might arbitrarily choose 17 for @cite{x}.  Testing the first number, we might arbitrarily choose 17 for @cite{x}.
8467    
 @group  
8468  @smallexample  @smallexample
8469    @group
8470  1:  17 mod 811749613   2:  17 mod 811749613   1:  533694123 mod 811749613  1:  17 mod 811749613   2:  17 mod 811749613   1:  533694123 mod 811749613
8471      .                      811749612              .      .                      811749612              .
8472                             .                             .
8473    
8474      17 M 811749613 RET     811749612              ^      17 M 811749613 @key{RET}     811749612              ^
 @end smallexample  
8475  @end group  @end group
8476    @end smallexample
8477    
8478  @noindent  @noindent
8479  Since 533694123 is (considerably) different from 1, the number 811749613  Since 533694123 is (considerably) different from 1, the number 811749613
# Line 8583  various ways to avoid this, and algebrai Line 8484  various ways to avoid this, and algebrai
8484  a vector mapping operation we can perform several tests at once.  Let's  a vector mapping operation we can perform several tests at once.  Let's
8485  use this method to test the second number.  use this method to test the second number.
8486    
 @group  
8487  @smallexample  @smallexample
8488    @group
8489  2:  [17, 42, 100000]               1:  [1 mod 15485863, 1 mod ... ]  2:  [17, 42, 100000]               1:  [1 mod 15485863, 1 mod ... ]
8490  1:  15485863                           .  1:  15485863                           .
8491      .      .
8492    
8493   [17 42 100000] 15485863 RET           V M ' ($$ mod $)^($-1) RET   [17 42 100000] 15485863 @key{RET}           V M ' ($$ mod $)^($-1) @key{RET}
 @end smallexample  
8494  @end group  @end group
8495    @end smallexample
8496    
8497  @noindent  @noindent
8498  The result is three ones (modulo @cite{n}), so it's very probable that  The result is three ones (modulo @cite{n}), so it's very probable that
# Line 8614  There are several ways to insert a calcu Line 8515  There are several ways to insert a calcu
8515  One way to convert a number of seconds to an HMS form is simply to  One way to convert a number of seconds to an HMS form is simply to
8516  multiply the number by an HMS form representing one second:  multiply the number by an HMS form representing one second:
8517    
 @group  
8518  @smallexample  @smallexample
8519    @group
8520  1:  31415926.5359     2:  31415926.5359     1:  8726@@ 38' 46.5359"  1:  31415926.5359     2:  31415926.5359     1:  8726@@ 38' 46.5359"
8521      .                 1:  0@@ 0' 1"              .      .                 1:  0@@ 0' 1"              .
8522                            .                            .
8523    
8524      P 1e7 *               0@@ 0' 1"              *      P 1e7 *               0@@ 0' 1"              *
8525    
 @end smallexample  
8526  @end group  @end group
8527    @end smallexample
8528  @noindent  @noindent
 @group  
8529  @smallexample  @smallexample
8530    @group
8531  2:  8726@@ 38' 46.5359"             1:  6@@ 6' 2.5359" mod 24@@ 0' 0"  2:  8726@@ 38' 46.5359"             1:  6@@ 6' 2.5359" mod 24@@ 0' 0"
8532  1:  15@@ 27' 16" mod 24@@ 0' 0"          .  1:  15@@ 27' 16" mod 24@@ 0' 0"          .
8533      .      .
8534    
8535      x time RET                         +      x time @key{RET}                         +
 @end smallexample  
8536  @end group  @end group
8537    @end smallexample
8538    
8539  @noindent  @noindent
8540  It will be just after six in the morning.  It will be just after six in the morning.
# Line 8641  It will be just after six in the morning Line 8542  It will be just after six in the morning
8542  The algebraic @code{hms} function can also be used to build an  The algebraic @code{hms} function can also be used to build an
8543  HMS form:  HMS form:
8544    
 @group  
8545  @smallexample  @smallexample
8546    @group
8547  1:  hms(0, 0, 10000000. pi)       1:  8726@@ 38' 46.5359"  1:  hms(0, 0, 10000000. pi)       1:  8726@@ 38' 46.5359"
8548      .                                 .      .                                 .
8549    
8550    ' hms(0, 0, 1e7 pi) RET             =    ' hms(0, 0, 1e7 pi) @key{RET}             =
 @end smallexample  
8551  @end group  @end group
8552    @end smallexample
8553    
8554  @noindent  @noindent
8555  The @kbd{=} key is necessary to evaluate the symbol @samp{pi} to  The @kbd{=} key is necessary to evaluate the symbol @samp{pi} to
# Line 8661  the actual number 3.14159... Line 8562  the actual number 3.14159...
8562  As we recall, there are 17 songs of about 2 minutes and 47 seconds  As we recall, there are 17 songs of about 2 minutes and 47 seconds
8563  each.  each.
8564    
 @group  
8565  @smallexample  @smallexample
8566    @group
8567  2:  0@@ 2' 47"                    1:  [0@@ 3' 7" .. 0@@ 3' 47"]  2:  0@@ 2' 47"                    1:  [0@@ 3' 7" .. 0@@ 3' 47"]
8568  1:  [0@@ 0' 20" .. 0@@ 1' 0"]          .  1:  [0@@ 0' 20" .. 0@@ 1' 0"]          .
8569      .      .
8570    
8571      [ 0@@ 20" .. 0@@ 1' ]              +      [ 0@@ 20" .. 0@@ 1' ]              +
8572    
 @end smallexample  
8573  @end group  @end group
8574    @end smallexample
8575  @noindent  @noindent
 @group  
8576  @smallexample  @smallexample
8577    @group
8578  1:  [0@@ 52' 59." .. 1@@ 4' 19."]  1:  [0@@ 52' 59." .. 1@@ 4' 19."]
8579      .      .
8580    
8581      17 *      17 *
 @end smallexample  
8582  @end group  @end group
8583    @end smallexample
8584    
8585  @noindent  @noindent
8586  No matter how long it is, the album will fit nicely on one CD.  No matter how long it is, the album will fit nicely on one CD.
# Line 8688  No matter how long it is, the album will Line 8589  No matter how long it is, the album will
8589  @subsection Types Tutorial Exercise 13  @subsection Types Tutorial Exercise 13
8590    
8591  @noindent  @noindent
8592  Type @kbd{' 1 yr RET u c s RET}.  The answer is 31557600 seconds.  Type @kbd{' 1 yr @key{RET} u c s @key{RET}}.  The answer is 31557600 seconds.
8593    
8594  @node Types Answer 14, Types Answer 15, Types Answer 13, Answers to Exercises  @node Types Answer 14, Types Answer 15, Types Answer 13, Answers to Exercises
8595  @subsection Types Tutorial Exercise 14  @subsection Types Tutorial Exercise 14
# Line 8697  Type @kbd{' 1 yr RET u c s RET}.  The an Line 8598  Type @kbd{' 1 yr RET u c s RET}.  The an
8598  How long will it take for a signal to get from one end of the computer  How long will it take for a signal to get from one end of the computer
8599  to the other?  to the other?
8600    
 @group  
8601  @smallexample  @smallexample
8602    @group
8603  1:  m / c         1:  3.3356 ns  1:  m / c         1:  3.3356 ns
8604      .                 .      .                 .
8605    
8606   ' 1 m / c RET        u c ns RET   ' 1 m / c @key{RET}        u c ns @key{RET}
 @end smallexample  
8607  @end group  @end group
8608    @end smallexample
8609    
8610  @noindent  @noindent
8611  (Recall, @samp{c} is a ``unit'' corresponding to the speed of light.)  (Recall, @samp{c} is a ``unit'' corresponding to the speed of light.)
8612    
 @group  
8613  @smallexample  @smallexample
8614    @group
8615  1:  3.3356 ns     1:  0.81356 ns / ns     1:  0.81356  1:  3.3356 ns     1:  0.81356 ns / ns     1:  0.81356
8616  2:  4.1 ns            .                       .  2:  4.1 ns            .                       .
8617      .      .
8618    
8619    ' 4.1 ns RET        /                       u s    ' 4.1 ns @key{RET}        /                       u s
 @end smallexample  
8620  @end group  @end group
8621    @end smallexample
8622    
8623  @noindent  @noindent
8624  Thus a signal could take up to 81 percent of a clock cycle just to  Thus a signal could take up to 81 percent of a clock cycle just to
# Line 8731  could actually attain the full speed of Line 8632  could actually attain the full speed of
8632  The speed limit is 55 miles per hour on most highways.  We want to  The speed limit is 55 miles per hour on most highways.  We want to
8633  find the ratio of Sam's speed to the US speed limit.  find the ratio of Sam's speed to the US speed limit.
8634    
 @group  
8635  @smallexample  @smallexample
8636    @group
8637  1:  55 mph         2:  55 mph           3:  11 hr mph / yd  1:  55 mph         2:  55 mph           3:  11 hr mph / yd
8638      .              1:  5 yd / hr            .      .              1:  5 yd / hr            .
8639                         .                         .
8640    
8641    ' 55 mph RET       ' 5 yd/hr RET          /    ' 55 mph @key{RET}       ' 5 yd/hr @key{RET}          /
 @end smallexample  
8642  @end group  @end group
8643    @end smallexample
8644    
8645  The @kbd{u s} command cancels out these units to get a plain  The @kbd{u s} command cancels out these units to get a plain
8646  number.  Now we take the logarithm base two to find the final  number.  Now we take the logarithm base two to find the final
8647  answer, assuming that each successive pill doubles his speed.  answer, assuming that each successive pill doubles his speed.
8648    
 @group  
8649  @smallexample  @smallexample
8650    @group
8651  1:  19360.       2:  19360.       1:  14.24  1:  19360.       2:  19360.       1:  14.24
8652      .            1:  2                .      .            1:  2                .
8653                       .                       .
8654    
8655      u s              2                B      u s              2                B
 @end smallexample  
8656  @end group  @end group
8657    @end smallexample
8658    
8659  @noindent  @noindent
8660  Thus Sam can take up to 14 pills without a worry.  Thus Sam can take up to 14 pills without a worry.
# Line 8780  is zero when @cite{x} is any of these va Line 8681  is zero when @cite{x} is any of these va
8681  will do the job.  We can use @kbd{a c x} to write this in a more  will do the job.  We can use @kbd{a c x} to write this in a more
8682  familiar form.  familiar form.
8683    
 @group  
8684  @smallexample  @smallexample
8685    @group
8686  1:  34 x - 24 x^3          1:  [1.19023, -1.19023, 0]  1:  34 x - 24 x^3          1:  [1.19023, -1.19023, 0]
8687      .                          .      .                          .
8688    
8689      r 2                        a P x RET      r 2                        a P x @key{RET}
8690    
 @end smallexample  
8691  @end group  @end group
8692    @end smallexample
8693  @noindent  @noindent
 @group  
8694  @smallexample  @smallexample
8695    @group
8696  1:  [x - 1.19023, x + 1.19023, x]     1:  (x - 1.19023) (x + 1.19023) x  1:  [x - 1.19023, x + 1.19023, x]     1:  (x - 1.19023) (x + 1.19023) x
8697      .                                     .      .                                     .
8698    
8699      V M ' x-$ RET                         V R *      V M ' x-$ @key{RET}                         V R *
8700    
 @end smallexample  
8701  @end group  @end group
8702    @end smallexample
8703  @noindent  @noindent
 @group  
8704  @smallexample  @smallexample
8705    @group
8706  1:  x^3 - 1.41666 x        1:  34 x - 24 x^3  1:  x^3 - 1.41666 x        1:  34 x - 24 x^3
8707      .                          .      .                          .
8708    
8709      a c x RET                  24 n *  a x      a c x @key{RET}                  24 n *  a x
 @end smallexample  
8710  @end group  @end group
8711    @end smallexample
8712    
8713  @noindent  @noindent
8714  Sure enough, our answer (multiplied by a suitable constant) is the  Sure enough, our answer (multiplied by a suitable constant) is the
# Line 8816  same as the original polynomial. Line 8717  same as the original polynomial.
8717  @node Algebra Answer 3, Algebra Answer 4, Algebra Answer 2, Answers to Exercises  @node Algebra Answer 3, Algebra Answer 4, Algebra Answer 2, Answers to Exercises
8718  @subsection Algebra Tutorial Exercise 3  @subsection Algebra Tutorial Exercise 3
8719    
 @group  
8720  @smallexample  @smallexample
8721    @group
8722  1:  x sin(pi x)         1:  (sin(pi x) - pi x cos(pi x)) / pi^2  1:  x sin(pi x)         1:  (sin(pi x) - pi x cos(pi x)) / pi^2
8723      .                       .      .                       .
8724    
8725    ' x sin(pi x) RET   m r   a i x RET    ' x sin(pi x) @key{RET}   m r   a i x @key{RET}
8726    
 @end smallexample  
8727  @end group  @end group
8728    @end smallexample
8729  @noindent  @noindent
 @group  
8730  @smallexample  @smallexample
8731    @group
8732  1:  [y, 1]  1:  [y, 1]
8733  2:  (sin(pi x) - pi x cos(pi x)) / pi^2  2:  (sin(pi x) - pi x cos(pi x)) / pi^2
8734      .      .
8735    
8736    ' [y,1] RET TAB    ' [y,1] @key{RET} @key{TAB}
8737    
 @end smallexample  
8738  @end group  @end group
8739    @end smallexample
8740  @noindent  @noindent
 @group  
8741  @smallexample  @smallexample
8742    @group
8743  1:  [(sin(pi y) - pi y cos(pi y)) / pi^2, (sin(pi) - pi cos(pi)) / pi^2]  1:  [(sin(pi y) - pi y cos(pi y)) / pi^2, (sin(pi) - pi cos(pi)) / pi^2]
8744      .      .
8745    
8746      V M $ RET      V M $ @key{RET}
8747    
 @end smallexample  
8748  @end group  @end group
8749    @end smallexample
8750  @noindent  @noindent
 @group  
8751  @smallexample  @smallexample
8752    @group
8753  1:  (sin(pi y) - pi y cos(pi y)) / pi^2 + (pi cos(pi) - sin(pi)) / pi^2  1:  (sin(pi y) - pi y cos(pi y)) / pi^2 + (pi cos(pi) - sin(pi)) / pi^2
8754      .      .
8755    
8756      V R -      V R -
8757    
 @end smallexample  
8758  @end group  @end group
8759    @end smallexample
8760  @noindent  @noindent
 @group  
8761  @smallexample  @smallexample
8762    @group
8763  1:  (sin(3.14159 y) - 3.14159 y cos(3.14159 y)) / 9.8696 - 0.3183  1:  (sin(3.14159 y) - 3.14159 y cos(3.14159 y)) / 9.8696 - 0.3183
8764      .      .
8765    
8766      =      =
8767    
 @end smallexample  
8768  @end group  @end group
8769    @end smallexample
8770  @noindent  @noindent
 @group  
8771  @smallexample  @smallexample
8772    @group
8773  1:  [0., -0.95493, 0.63662, -1.5915, 1.2732]  1:  [0., -0.95493, 0.63662, -1.5915, 1.2732]
8774      .      .
8775    
8776      v x 5 RET  TAB  V M $ RET      v x 5 @key{RET}  @key{TAB}  V M $ @key{RET}
 @end smallexample  
8777  @end group  @end group
8778    @end smallexample
8779    
8780  @node Algebra Answer 4, Rewrites Answer 1, Algebra Answer 3, Answers to Exercises  @node Algebra Answer 4, Rewrites Answer 1, Algebra Answer 3, Answers to Exercises
8781  @subsection Algebra Tutorial Exercise 4  @subsection Algebra Tutorial Exercise 4
# Line 8885  the contributions from the slices, since Line 8786  the contributions from the slices, since
8786  coefficients.  So first we must come up with a vector of these  coefficients.  So first we must come up with a vector of these
8787  coefficients.  Here's one way:  coefficients.  Here's one way:
8788    
 @group  
8789  @smallexample  @smallexample
8790    @group
8791  2:  -1                 2:  3                    1:  [4, 2, ..., 4]  2:  -1                 2:  3                    1:  [4, 2, ..., 4]
8792  1:  [1, 2, ..., 9]     1:  [-1, 1, ..., -1]         .  1:  [1, 2, ..., 9]     1:  [-1, 1, ..., -1]         .
8793      .                      .      .                      .
8794    
8795      1 n v x 9 RET          V M ^  3 TAB             -      1 n v x 9 @key{RET}          V M ^  3 @key{TAB}             -
8796    
 @end smallexample  
8797  @end group  @end group
8798    @end smallexample
8799  @noindent  @noindent
 @group  
8800  @smallexample  @smallexample
8801    @group
8802  1:  [4, 2, ..., 4, 1]      1:  [1, 4, 2, ..., 4, 1]  1:  [4, 2, ..., 4, 1]      1:  [1, 4, 2, ..., 4, 1]
8803      .                          .      .                          .
8804    
8805      1 |                        1 TAB |      1 |                        1 @key{TAB} |
 @end smallexample  
8806  @end group  @end group
8807    @end smallexample
8808    
8809  @noindent  @noindent
8810  Now we compute the function values.  Note that for this method we need  Now we compute the function values.  Note that for this method we need
8811  eleven values, including both endpoints of the desired interval.  eleven values, including both endpoints of the desired interval.
8812    
 @group  
8813  @smallexample  @smallexample
8814    @group
8815  2:  [1, 4, 2, ..., 4, 1]  2:  [1, 4, 2, ..., 4, 1]
8816  1:  [1, 1.1, 1.2,  ...  , 1.8, 1.9, 2.]  1:  [1, 1.1, 1.2,  ...  , 1.8, 1.9, 2.]
8817      .      .
8818    
8819   11 RET 1 RET .1 RET  C-u v x   11 @key{RET} 1 @key{RET} .1 @key{RET}  C-u v x
8820    
 @end smallexample  
8821  @end group  @end group
8822    @end smallexample
8823  @noindent  @noindent
 @group  
8824  @smallexample  @smallexample
8825    @group
8826  2:  [1, 4, 2, ..., 4, 1]  2:  [1, 4, 2, ..., 4, 1]
8827  1:  [0., 0.084941, 0.16993, ... ]  1:  [0., 0.084941, 0.16993, ... ]
8828      .      .
8829    
8830      ' sin(x) ln(x) RET   m r  p 5 RET   V M $ RET      ' sin(x) ln(x) @key{RET}   m r  p 5 @key{RET}   V M $ @key{RET}
 @end smallexample  
8831  @end group  @end group
8832    @end smallexample
8833    
8834  @noindent  @noindent
8835  Once again this calls for @kbd{V M * V R +}; a simple @kbd{*} does the  Once again this calls for @kbd{V M * V R +}; a simple @kbd{*} does the
8836  same thing.  same thing.
8837    
 @group  
8838  @smallexample  @smallexample
8839    @group
8840  1:  11.22      1:  1.122      1:  0.374  1:  11.22      1:  1.122      1:  0.374
8841      .              .              .      .              .              .
8842    
8843      *              .1 *           3 /      *              .1 *           3 /
 @end smallexample  
8844  @end group  @end group
8845    @end smallexample
8846    
8847  @noindent  @noindent
8848  Wow!  That's even better than the result from the Taylor series method.  Wow!  That's even better than the result from the Taylor series method.
# Line 8952  Wow!  That's even better than the result Line 8853  Wow!  That's even better than the result
8853  @noindent  @noindent
8854  We'll use Big mode to make the formulas more readable.  We'll use Big mode to make the formulas more readable.
8855    
 @group  
8856  @smallexample  @smallexample
8857    @group
8858                                                 ___                                                 ___
8859                                            2 + V 2                                            2 + V 2
8860  1:  (2 + sqrt(2)) / (1 + sqrt(2))     1:  --------  1:  (2 + sqrt(2)) / (1 + sqrt(2))     1:  --------
# Line 8962  We'll use Big mode to make the formulas Line 8863  We'll use Big mode to make the formulas
8863    
8864                                            .                                            .
8865    
8866    ' (2+sqrt(2)) / (1+sqrt(2)) RET         d B    ' (2+sqrt(2)) / (1+sqrt(2)) @key{RET}         d B
 @end smallexample  
8867  @end group  @end group
8868    @end smallexample
8869    
8870  @noindent  @noindent
8871  Multiplying by the conjugate helps because @cite{(a+b) (a-b) = a^2 - b^2}.  Multiplying by the conjugate helps because @cite{(a+b) (a-b) = a^2 - b^2}.
8872    
 @group  
8873  @smallexample  @smallexample
8874    @group
8875            ___    ___            ___    ___
8876  1:  (2 + V 2 ) (V 2  - 1)  1:  (2 + V 2 ) (V 2  - 1)
8877      .      .
8878    
8879    a r a/(b+c) := a*(b-c) / (b^2-c^2) RET    a r a/(b+c) := a*(b-c) / (b^2-c^2) @key{RET}
8880    
 @end smallexample  
8881  @end group  @end group
8882    @end smallexample
8883  @noindent  @noindent
 @group  
8884  @smallexample  @smallexample
8885    @group
8886           ___                         ___           ___                         ___
8887  1:  2 + V 2  - 2                1:  V 2  1:  2 + V 2  - 2                1:  V 2
8888      .                               .      .                               .
8889    
8890    a r a*(b+c) := a*b + a*c          a s    a r a*(b+c) := a*b + a*c          a s
 @end smallexample  
8891  @end group  @end group
8892    @end smallexample
8893    
8894  @noindent  @noindent
8895  (We could have used @kbd{a x} instead of a rewrite rule for the  (We could have used @kbd{a x} instead of a rewrite rule for the
# Line 9004  sines and cosines or the imaginary const Line 8905  sines and cosines or the imaginary const
8905  @noindent  @noindent
8906  Here is the rule set:  Here is the rule set:
8907    
 @group  
8908  @smallexample  @smallexample
8909    @group
8910  [ fib(n) := fib(n, 1, 1) :: integer(n) :: n >= 1,  [ fib(n) := fib(n, 1, 1) :: integer(n) :: n >= 1,
8911    fib(1, x, y) := x,    fib(1, x, y) := x,
8912    fib(n, x, y) := fib(n-1, y, x+y) ]    fib(n, x, y) := fib(n-1, y, x+y) ]
 @end smallexample  
8913  @end group  @end group
8914    @end smallexample
8915    
8916  @noindent  @noindent
8917  The first rule turns a one-argument @code{fib} that people like to write  The first rule turns a one-argument @code{fib} that people like to write
# Line 9060  on the lefthand side, so that the rule m Line 8961  on the lefthand side, so that the rule m
8961  @subsection Rewrites Tutorial Exercise 4  @subsection Rewrites Tutorial Exercise 4
8962    
8963  @noindent  @noindent
8964  @c @starindex  @ignore
8965    @starindex
8966    @end ignore
8967  @tindex seq  @tindex seq
8968  Here is a suitable set of rules to solve the first part of the problem:  Here is a suitable set of rules to solve the first part of the problem:
8969    
 @group  
8970  @smallexample  @smallexample
8971    @group
8972  [ seq(n, c) := seq(n/2,  c+1) :: n%2 = 0,  [ seq(n, c) := seq(n/2,  c+1) :: n%2 = 0,
8973    seq(n, c) := seq(3n+1, c+1) :: n%2 = 1 :: n > 1 ]    seq(n, c) := seq(3n+1, c+1) :: n%2 = 1 :: n > 1 ]
 @end smallexample  
8974  @end group  @end group
8975    @end smallexample
8976    
8977  Given the initial formula @samp{seq(6, 0)}, application of these  Given the initial formula @samp{seq(6, 0)}, application of these
8978  rules produces the following sequence of formulas:  rules produces the following sequence of formulas:
# Line 9090  whereupon neither of the rules match, an Line 8993  whereupon neither of the rules match, an
8993    
8994  We can pretty this up a bit with a couple more rules:  We can pretty this up a bit with a couple more rules:
8995    
 @group  
8996  @smallexample  @smallexample
8997    @group
8998  [ seq(n) := seq(n, 0),  [ seq(n) := seq(n, 0),
8999    seq(1, c) := c,    seq(1, c) := c,
9000    ... ]    ... ]
 @end smallexample  
9001  @end group  @end group
9002    @end smallexample
9003    
9004  @noindent  @noindent
9005  Now, given @samp{seq(6)} as the starting configuration, we get 8  Now, given @samp{seq(6)} as the starting configuration, we get 8
# Line 9104  as the result. Line 9007  as the result.
9007    
9008  The change to return a vector is quite simple:  The change to return a vector is quite simple:
9009    
 @group  
9010  @smallexample  @smallexample
9011    @group
9012  [ seq(n) := seq(n, []) :: integer(n) :: n > 0,  [ seq(n) := seq(n, []) :: integer(n) :: n > 0,
9013    seq(1, v) := v | 1,    seq(1, v) := v | 1,
9014    seq(n, v) := seq(n/2,  v | n) :: n%2 = 0,    seq(n, v) := seq(n/2,  v | n) :: n%2 = 0,
9015    seq(n, v) := seq(3n+1, v | n) :: n%2 = 1 ]    seq(n, v) := seq(3n+1, v | n) :: n%2 = 1 ]
 @end smallexample  
9016  @end group  @end group
9017    @end smallexample
9018    
9019  @noindent  @noindent
9020  Given @samp{seq(6)}, the result is @samp{[6, 3, 10, 5, 16, 8, 4, 2, 1]}.  Given @samp{seq(6)}, the result is @samp{[6, 3, 10, 5, 16, 8, 4, 2, 1]}.
# Line 9131  apply and the rewrites will stop right a Line 9034  apply and the rewrites will stop right a
9034  @subsection Rewrites Tutorial Exercise 5  @subsection Rewrites Tutorial Exercise 5
9035    
9036  @noindent  @noindent
9037  @c @starindex  @ignore
9038    @starindex
9039    @end ignore
9040  @tindex nterms  @tindex nterms
9041  If @cite{x} is the sum @cite{a + b}, then `@t{nterms(}@i{x}@t{)}' must  If @cite{x} is the sum @cite{a + b}, then `@t{nterms(}@var{x}@t{)}' must
9042  be `@t{nterms(}@i{a}@t{)}' plus `@t{nterms(}@i{b}@t{)}'.  If @cite{x}  be `@t{nterms(}@var{a}@t{)}' plus `@t{nterms(}@var{b}@t{)}'.  If @cite{x}
9043  is not a sum, then `@t{nterms(}@i{x}@t{)}' = 1.  is not a sum, then `@t{nterms(}@var{x}@t{)}' = 1.
9044    
 @group  
9045  @smallexample  @smallexample
9046    @group
9047  [ nterms(a + b) := nterms(a) + nterms(b),  [ nterms(a + b) := nterms(a) + nterms(b),
9048    nterms(x)     := 1 ]    nterms(x)     := 1 ]
 @end smallexample  
9049  @end group  @end group
9050    @end smallexample
9051    
9052  @noindent  @noindent
9053  Here we have taken advantage of the fact that earlier rules always  Here we have taken advantage of the fact that earlier rules always
# Line 9155  already know that @samp{x} is not a sum. Line 9060  already know that @samp{x} is not a sum.
9060  Just put the rule @samp{0^0 := 1} into @code{EvalRules}.  For example,  Just put the rule @samp{0^0 := 1} into @code{EvalRules}.  For example,
9061  before making this definition we have:  before making this definition we have:
9062    
 @group  
9063  @smallexample  @smallexample
9064    @group
9065  2:  [-2, -1, 0, 1, 2]                1:  [1, 1, 0^0, 1, 1]  2:  [-2, -1, 0, 1, 2]                1:  [1, 1, 0^0, 1, 1]
9066  1:  0                                    .  1:  0                                    .
9067      .      .
9068    
9069      v x 5 RET  3 -  0                    V M ^      v x 5 @key{RET}  3 -  0                    V M ^
 @end smallexample  
9070  @end group  @end group
9071    @end smallexample
9072    
9073  @noindent  @noindent
9074  But then:  But then:
9075    
 @group  
9076  @smallexample  @smallexample
9077    @group
9078  2:  [-2, -1, 0, 1, 2]                1:  [1, 1, 1, 1, 1]  2:  [-2, -1, 0, 1, 2]                1:  [1, 1, 1, 1, 1]
9079  1:  0                                    .  1:  0                                    .
9080      .      .
9081    
9082      U  ' 0^0:=1 RET s t EvalRules RET    V M ^      U  ' 0^0:=1 @key{RET} s t EvalRules @key{RET}    V M ^
 @end smallexample  
9083  @end group  @end group
9084    @end smallexample
9085    
9086  Perhaps more surprisingly, this rule still works with infinite mode  Perhaps more surprisingly, this rule still works with infinite mode
9087  turned on.  Calc tries @code{EvalRules} before any built-in rules for  turned on.  Calc tries @code{EvalRules} before any built-in rules for
# Line 9194  a nasty surprise when you use Calc to ba Line 9099  a nasty surprise when you use Calc to ba
9099  @noindent  @noindent
9100  Here is a rule set that will do the job:  Here is a rule set that will do the job:
9101    
 @group  
9102  @smallexample  @smallexample
9103    @group
9104  [ a*(b + c) := a*b + a*c,  [ a*(b + c) := a*b + a*c,
9105    opt(a) O(x^n) + opt(b) O(x^m) := O(x^n) :: n <= m    opt(a) O(x^n) + opt(b) O(x^m) := O(x^n) :: n <= m
9106       :: constant(a) :: constant(b),       :: constant(a) :: constant(b),
# Line 9204  Here is a rule set that will do the job: Line 9109  Here is a rule set that will do the job:
9109    a O(x^n) := O(x^n) :: constant(a),    a O(x^n) := O(x^n) :: constant(a),
9110    x^opt(m) O(x^n) := O(x^(n+m)),    x^opt(m) O(x^n) := O(x^(n+m)),
9111    O(x^n) O(x^m) := O(x^(n+m)) ]    O(x^n) O(x^m) := O(x^(n+m)) ]
 @end smallexample  
9112  @end group  @end group
9113    @end smallexample
9114    
9115  If we really want the @kbd{+} and @kbd{*} keys to operate naturally  If we really want the @kbd{+} and @kbd{*} keys to operate naturally
9116  on power series, we should put these rules in @code{EvalRules}.  For  on power series, we should put these rules in @code{EvalRules}.  For
# Line 9273  variables, the default argument list wil Line 9178  variables, the default argument list wil
9178  change this to @samp{(x)} since @cite{t} is really a dummy variable  change this to @samp{(x)} since @cite{t} is really a dummy variable
9179  to be used within @code{ninteg}.  to be used within @code{ninteg}.
9180    
9181  The exact keystrokes are @kbd{Z F s Si RET RET C-b C-b DEL DEL RET y}.  The exact keystrokes are @kbd{Z F s Si @key{RET} @key{RET} C-b C-b @key{DEL} @key{DEL} @key{RET} y}.
9182  (The @kbd{C-b C-b DEL DEL} are what fix the argument list.)  (The @kbd{C-b C-b @key{DEL} @key{DEL}} are what fix the argument list.)
9183    
9184  @node Programming Answer 2, Programming Answer 3, Programming Answer 1, Answers to Exercises  @node Programming Answer 2, Programming Answer 3, Programming Answer 1, Answers to Exercises
9185  @subsection Programming Tutorial Exercise 2  @subsection Programming Tutorial Exercise 2
9186    
9187  @noindent  @noindent
9188  One way is to move the number to the top of the stack, operate on  One way is to move the number to the top of the stack, operate on
9189  it, then move it back:  @kbd{C-x ( M-TAB n M-TAB M-TAB C-x )}.  it, then move it back:  @kbd{C-x ( M-@key{TAB} n M-@key{TAB} M-@key{TAB} C-x )}.
9190    
9191  Another way is to negate the top three stack entries, then negate  Another way is to negate the top three stack entries, then negate
9192  again the top two stack entries:  @kbd{C-x ( M-3 n M-2 n C-x )}.  again the top two stack entries:  @kbd{C-x ( M-3 n M-2 n C-x )}.
# Line 9291  command like @kbd{n} to operate on the s Line 9196  command like @kbd{n} to operate on the s
9196  which is just what we want:  @kbd{C-x ( M-- 3 n C-x )}.  which is just what we want:  @kbd{C-x ( M-- 3 n C-x )}.
9197    
9198  Just for kicks, let's also do it algebraically:  Just for kicks, let's also do it algebraically:
9199  @w{@kbd{C-x ( ' -$$$, $$, $ RET C-x )}}.  @w{@kbd{C-x ( ' -$$$, $$, $ @key{RET} C-x )}}.
9200    
9201  @node Programming Answer 3, Programming Answer 4, Programming Answer 2, Answers to Exercises  @node Programming Answer 3, Programming Answer 4, Programming Answer 2, Answers to Exercises
9202  @subsection Programming Tutorial Exercise 3  @subsection Programming Tutorial Exercise 3
# Line 9304  algebraic entry, whichever way you prefe Line 9209  algebraic entry, whichever way you prefe
9209  Computing @c{$\displaystyle{\sin x \over x}$}  Computing @c{$\displaystyle{\sin x \over x}$}
9210  @cite{sin(x) / x}:  @cite{sin(x) / x}:
9211    
9212  Using the stack:  @kbd{C-x (  RET S TAB /  C-x )}.  Using the stack:  @kbd{C-x (  @key{RET} S @key{TAB} /  C-x )}.
9213    
9214  Using algebraic entry:  @kbd{C-x (  ' sin($)/$ RET  C-x )}.  Using algebraic entry:  @kbd{C-x (  ' sin($)/$ @key{RET}  C-x )}.
9215    
9216  @noindent  @noindent
9217  Computing the logarithm:  Computing the logarithm:
9218    
9219  Using the stack:  @kbd{C-x (  TAB B  C-x )}  Using the stack:  @kbd{C-x (  @key{TAB} B  C-x )}
9220    
9221  Using algebraic entry:  @kbd{C-x (  ' log($,$$) RET  C-x )}.  Using algebraic entry:  @kbd{C-x (  ' log($,$$) @key{RET}  C-x )}.
9222    
9223  @noindent  @noindent
9224  Computing the vector of integers:  Computing the vector of integers:
9225    
9226  Using the stack:  @kbd{C-x (  1 RET 1  C-u v x  C-x )}.  (Recall that  Using the stack:  @kbd{C-x (  1 @key{RET} 1  C-u v x  C-x )}.  (Recall that
9227  @kbd{C-u v x} takes the vector size, starting value, and increment  @kbd{C-u v x} takes the vector size, starting value, and increment
9228  from the stack.)  from the stack.)
9229    
# Line 9326  Alternatively:  @kbd{C-x (  ~ v x  C-x ) Line 9231  Alternatively:  @kbd{C-x (  ~ v x  C-x )
9231  number from the stack and uses it as the prefix argument for the  number from the stack and uses it as the prefix argument for the
9232  next command.)  next command.)
9233    
9234  Using algebraic entry:  @kbd{C-x (  ' index($) RET  C-x )}.  Using algebraic entry:  @kbd{C-x (  ' index($) @key{RET}  C-x )}.
9235    
9236  @node Programming Answer 4, Programming Answer 5, Programming Answer 3, Answers to Exercises  @node Programming Answer 4, Programming Answer 5, Programming Answer 3, Answers to Exercises
9237  @subsection Programming Tutorial Exercise 4  @subsection Programming Tutorial Exercise 4
9238    
9239  @noindent  @noindent
9240  Here's one way:  @kbd{C-x ( RET V R + TAB v l / C-x )}.  Here's one way:  @kbd{C-x ( @key{RET} V R + @key{TAB} v l / C-x )}.
9241    
9242  @node Programming Answer 5, Programming Answer 6, Programming Answer 4, Answers to Exercises  @node Programming Answer 5, Programming Answer 6, Programming Answer 4, Answers to Exercises
9243  @subsection Programming Tutorial Exercise 5  @subsection Programming Tutorial Exercise 5
9244    
 @group  
9245  @smallexample  @smallexample
9246    @group
9247  2:  1              1:  1.61803398502         2:  1.61803398502  2:  1              1:  1.61803398502         2:  1.61803398502
9248  1:  20                 .                     1:  1.61803398875  1:  20                 .                     1:  1.61803398875
9249      .                                            .      .                                            .
9250    
9251     1 RET 20         Z < & 1 + Z >                I H P     1 @key{RET} 20         Z < & 1 + Z >                I H P
 @end smallexample  
9252  @end group  @end group
9253    @end smallexample
9254    
9255  @noindent  @noindent
9256  This answer is quite accurate.  This answer is quite accurate.
# Line 9366  Thus @samp{[0, 1; 1, 1]^n * [1, 1]} comp Line 9271  Thus @samp{[0, 1; 1, 1]^n * [1, 1]} comp
9271  and @cite{n+2}.  Here's one program that does the job:  and @cite{n+2}.  Here's one program that does the job:
9272    
9273  @example  @example
9274  C-x ( ' [0, 1; 1, 1] ^ ($-1) * [1, 1] RET v u DEL C-x )  C-x ( ' [0, 1; 1, 1] ^ ($-1) * [1, 1] @key{RET} v u @key{DEL} C-x )
9275  @end example  @end example
9276    
9277  @noindent  @noindent
# Line 9386  The trick here is to compute the harmoni Line 9291  The trick here is to compute the harmoni
9291  the loop counter itself accumulates the sum of reciprocals.  We use  the loop counter itself accumulates the sum of reciprocals.  We use
9292  a separate variable to hold the integer counter.  a separate variable to hold the integer counter.
9293    
 @group  
9294  @smallexample  @smallexample
9295    @group
9296  1:  1          2:  1       1:  .  1:  1          2:  1       1:  .
9297      .          1:  4      .          1:  4
9298                     .                     .
9299    
9300      1 t 1       1 RET 4      Z ( t 2 r 1 1 + s 1 & Z )      1 t 1       1 @key{RET} 4      Z ( t 2 r 1 1 + s 1 & Z )
 @end smallexample  
9301  @end group  @end group
9302    @end smallexample
9303    
9304  @noindent  @noindent
9305  The body of the loop goes as follows:  First save the harmonic sum  The body of the loop goes as follows:  First save the harmonic sum
# Line 9405  the for loop to use as the step value. Line 9310  the for loop to use as the step value.
9310  the ``loop counter'' by that amount and keep going until the  the ``loop counter'' by that amount and keep going until the
9311  loop counter exceeds 4.  loop counter exceeds 4.
9312    
 @group  
9313  @smallexample  @smallexample
9314    @group
9315  2:  31                  3:  31  2:  31                  3:  31
9316  1:  3.99498713092       2:  3.99498713092  1:  3.99498713092       2:  3.99498713092
9317      .                   1:  4.02724519544      .                   1:  4.02724519544
9318                              .                              .
9319    
9320      r 1 r 2                 RET 31 & +      r 1 r 2                 @key{RET} 31 & +
 @end smallexample  
9321  @end group  @end group
9322    @end smallexample
9323    
9324  Thus we find that the 30th harmonic number is 3.99, and the 31st  Thus we find that the 30th harmonic number is 3.99, and the 31st
9325  harmonic number is 4.02.  harmonic number is 4.02.
# Line 9434  keystrokes without executing them.  In t Line 9339  keystrokes without executing them.  In t
9339  pretend Calc actually executed the keystrokes as you typed them,  pretend Calc actually executed the keystrokes as you typed them,
9340  just for purposes of illustration.)  just for purposes of illustration.)
9341    
 @group  
9342  @smallexample  @smallexample
9343    @group
9344  2:  sin(cos(x)) - 0.5            3:  4.5  2:  sin(cos(x)) - 0.5            3:  4.5
9345  1:  4.5                          2:  sin(cos(x)) - 0.5  1:  4.5                          2:  sin(cos(x)) - 0.5
9346      .                            1:  -(sin(x) cos(cos(x)))      .                            1:  -(sin(x) cos(cos(x)))
9347                                       .                                       .
9348    
9349  ' sin(cos(x))-0.5 RET 4.5  m r  C-x ( Z `  TAB RET a d x RET  ' sin(cos(x))-0.5 @key{RET} 4.5  m r  C-x ( Z `  @key{TAB} @key{RET} a d x @key{RET}
9350    
 @end smallexample  
9351  @end group  @end group
9352    @end smallexample
9353  @noindent  @noindent
 @group  
9354  @smallexample  @smallexample
9355    @group
9356  2:  4.5  2:  4.5
9357  1:  x + (sin(cos(x)) - 0.5) / sin(x) cos(cos(x))  1:  x + (sin(cos(x)) - 0.5) / sin(x) cos(cos(x))
9358      .      .
9359    
9360      /  ' x RET TAB -   t 1      /  ' x @key{RET} @key{TAB} -   t 1
 @end smallexample  
9361  @end group  @end group
9362    @end smallexample
9363    
9364  Now, we enter the loop.  We'll use a repeat loop with a 20-repetition  Now, we enter the loop.  We'll use a repeat loop with a 20-repetition
9365  limit just in case the method fails to converge for some reason.  limit just in case the method fails to converge for some reason.
9366  (Normally, the @w{@kbd{Z /}} command will stop the loop before all 20  (Normally, the @w{@kbd{Z /}} command will stop the loop before all 20
9367  repetitions are done.)  repetitions are done.)
9368    
 @group  
9369  @smallexample  @smallexample
9370    @group
9371  1:  4.5         3:  4.5                     2:  4.5  1:  4.5         3:  4.5                     2:  4.5
9372      .           2:  x + (sin(cos(x)) ...    1:  5.24196456928      .           2:  x + (sin(cos(x)) ...    1:  5.24196456928
9373                  1:  4.5                         .                  1:  4.5                         .
9374                      .                      .
9375    
9376    20 Z <          RET r 1 TAB                 s l x RET    20 Z <          @key{RET} r 1 @key{TAB}                 s l x @key{RET}
 @end smallexample  
9377  @end group  @end group
9378    @end smallexample
9379    
9380  This is the new guess for @cite{x}.  Now we compare it with the  This is the new guess for @cite{x}.  Now we compare it with the
9381  old one to see if we've converged.  old one to see if we've converged.
9382    
 @group  
9383  @smallexample  @smallexample
9384    @group
9385  3:  5.24196     2:  5.24196     1:  5.24196     1:  5.26345856348  3:  5.24196     2:  5.24196     1:  5.24196     1:  5.26345856348
9386  2:  5.24196     1:  0               .               .  2:  5.24196     1:  0               .               .
9387  1:  4.5             .  1:  4.5             .
9388      .      .
9389    
9390    RET M-TAB         a =             Z /             Z > Z ' C-x )    @key{RET} M-@key{TAB}         a =             Z /             Z > Z ' C-x )
 @end smallexample  
9391  @end group  @end group
9392    @end smallexample
9393    
9394  The loop converges in just a few steps to this value.  To check  The loop converges in just a few steps to this value.  To check
9395  the result, we can simply substitute it back into the equation.  the result, we can simply substitute it back into the equation.
9396    
 @group  
9397  @smallexample  @smallexample
9398    @group
9399  2:  5.26345856348  2:  5.26345856348
9400  1:  0.499999999997  1:  0.499999999997
9401      .      .
9402    
9403   RET ' sin(cos($)) RET   @key{RET} ' sin(cos($)) @key{RET}
 @end smallexample  
9404  @end group  @end group
9405    @end smallexample
9406    
9407  Let's test the new definition again:  Let's test the new definition again:
9408    
 @group  
9409  @smallexample  @smallexample
9410    @group
9411  2:  x^2 - 9           1:  3.  2:  x^2 - 9           1:  3.
9412  1:  1                     .  1:  1                     .
9413      .      .
9414    
9415    ' x^2-9 RET 1           X    ' x^2-9 @key{RET} 1           X
 @end smallexample  
9416  @end group  @end group
9417    @end smallexample
9418    
9419  Once again, here's the full Newton's Method definition:  Once again, here's the full Newton's Method definition:
9420    
 @group  
9421  @example  @example
9422  C-x ( Z `  TAB RET a d x RET  /  ' x RET TAB -  t 1  @group
9423             20 Z <  RET r 1 TAB  s l x RET  C-x ( Z `  @key{TAB} @key{RET} a d x @key{RET}  /  ' x @key{RET} @key{TAB} -  t 1
9424                     RET M-TAB  a =  Z /             20 Z <  @key{RET} r 1 @key{TAB}  s l x @key{RET}
9425                       @key{RET} M-@key{TAB}  a =  Z /
9426                Z >                Z >
9427        Z '        Z '
9428  C-x )  C-x )
 @end example  
9429  @end group  @end group
9430    @end example
9431    
9432  @c [fix-ref Nesting and Fixed Points]  @c [fix-ref Nesting and Fixed Points]
9433  It turns out that Calc has a built-in command for applying a formula  It turns out that Calc has a built-in command for applying a formula
# Line 9553  keystrokes without executing them.  In t Line 9458  keystrokes without executing them.  In t
9458  pretend Calc actually executed the keystrokes as you typed them,  pretend Calc actually executed the keystrokes as you typed them,
9459  just for purposes of illustration.)  just for purposes of illustration.)
9460    
 @group  
9461  @smallexample  @smallexample
9462    @group
9463  1:  1.             1:  1.  1:  1.             1:  1.
9464      .                  .      .                  .
9465    
9466   1.0 RET       C-x ( Z `  s 1  0 t 2   1.0 @key{RET}       C-x ( Z `  s 1  0 t 2
 @end smallexample  
9467  @end group  @end group
9468    @end smallexample
9469    
9470  Here, variable 1 holds @cite{z} and variable 2 holds the adjustment  Here, variable 1 holds @cite{z} and variable 2 holds the adjustment
9471  factor.  If @cite{z < 5}, we use a loop to increase it.  factor.  If @cite{z < 5}, we use a loop to increase it.
# Line 9570  otherwise the calculation below will try Line 9475  otherwise the calculation below will try
9475  and will never converge because fractions compare equal only if they  and will never converge because fractions compare equal only if they
9476  are exactly equal, not just equal to within the current precision.)  are exactly equal, not just equal to within the current precision.)
9477    
 @group  
9478  @smallexample  @smallexample
9479    @group
9480  3:  1.      2:  1.       1:  6.  3:  1.      2:  1.       1:  6.
9481  2:  1.      1:  1            .  2:  1.      1:  1            .
9482  1:  5           .  1:  5           .
9483      .      .
9484    
9485    RET 5        a <    Z [  5 Z (  & s + 2  1 s + 1  1 Z ) r 1  Z ]    @key{RET} 5        a <    Z [  5 Z (  & s + 2  1 s + 1  1 Z ) r 1  Z ]
 @end smallexample  
9486  @end group  @end group
9487    @end smallexample
9488    
9489  Now we compute the initial part of the sum:  @c{$\ln z - {1 \over 2z}$}  Now we compute the initial part of the sum:  @c{$\ln z - {1 \over 2z}$}
9490  @cite{ln(z) - 1/2z}  @cite{ln(z) - 1/2z}
9491  minus the adjustment factor.  minus the adjustment factor.
9492    
 @group  
9493  @smallexample  @smallexample
9494    @group
9495  2:  1.79175946923      2:  1.7084261359      1:  -0.57490719743  2:  1.79175946923      2:  1.7084261359      1:  -0.57490719743
9496  1:  0.0833333333333    1:  2.28333333333         .  1:  0.0833333333333    1:  2.28333333333         .
9497      .                      .      .                      .
9498    
9499      L  r 1 2 * &           -  r 2                -      L  r 1 2 * &           -  r 2                -
 @end smallexample  
9500  @end group  @end group
9501    @end smallexample
9502    
9503  Now we evaluate the series.  We'll use another ``for'' loop counting  Now we evaluate the series.  We'll use another ``for'' loop counting
9504  up the value of @cite{2 n}.  (Calc does have a summation command,  up the value of @cite{2 n}.  (Calc does have a summation command,
9505  @kbd{a +}, but we'll use loops just to get more practice with them.)  @kbd{a +}, but we'll use loops just to get more practice with them.)
9506    
 @group  
9507  @smallexample  @smallexample
9508    @group
9509  3:  -0.5749       3:  -0.5749        4:  -0.5749      2:  -0.5749  3:  -0.5749       3:  -0.5749        4:  -0.5749      2:  -0.5749
9510  2:  2             2:  1:6            3:  1:6          1:  2.3148e-3  2:  2             2:  1:6            3:  1:6          1:  2.3148e-3
9511  1:  40            1:  2              2:  2                .  1:  40            1:  2              2:  2                .
9512      .                 .              1:  36.      .                 .              1:  36.
9513                                           .                                           .
9514    
9515     2 RET 40        Z ( RET k b TAB     RET r 1 TAB ^      * /     2 @key{RET} 40        Z ( @key{RET} k b @key{TAB}     @key{RET} r 1 @key{TAB} ^      * /
9516    
 @end smallexample  
9517  @end group  @end group
9518    @end smallexample
9519  @noindent  @noindent
 @group  
9520  @smallexample  @smallexample
9521    @group
9522  3:  -0.5749       3:  -0.5772      2:  -0.5772     1:  -0.577215664892  3:  -0.5749       3:  -0.5772      2:  -0.5772     1:  -0.577215664892
9523  2:  -0.5749       2:  -0.5772      1:  0               .  2:  -0.5749       2:  -0.5772      1:  0               .
9524  1:  2.3148e-3     1:  -0.5749          .  1:  2.3148e-3     1:  -0.5749          .
9525      .                 .      .                 .
9526    
9527    TAB RET M-TAB       - RET M-TAB      a =     Z /    2  Z )  Z ' C-x )    @key{TAB} @key{RET} M-@key{TAB}       - @key{RET} M-@key{TAB}      a =     Z /    2  Z )  Z ' C-x )
 @end smallexample  
9528  @end group  @end group
9529    @end smallexample
9530    
9531  This is the value of @c{$-\gamma$}  This is the value of @c{$-\gamma$}
9532  @cite{- gamma}, with a slight bit of roundoff error.  @cite{- gamma}, with a slight bit of roundoff error.
9533  To get a full 12 digits, let's use a higher precision:  To get a full 12 digits, let's use a higher precision:
9534    
 @group  
9535  @smallexample  @smallexample
9536    @group
9537  2:  -0.577215664892      2:  -0.577215664892  2:  -0.577215664892      2:  -0.577215664892
9538  1:  1.                   1:  -0.577215664901532  1:  1.                   1:  -0.577215664901532
9539    
9540      1. RET                   p 16 RET X      1. @key{RET}                   p 16 @key{RET} X
 @end smallexample  
9541  @end group  @end group
9542    @end smallexample
9543    
9544  Here's the complete sequence of keystrokes:  Here's the complete sequence of keystrokes:
9545    
 @group  
9546  @example  @example
9547    @group
9548  C-x ( Z `  s 1  0 t 2  C-x ( Z `  s 1  0 t 2
9549             RET 5 a <  Z [  5 Z (  & s + 2  1 s + 1  1 Z ) r 1  Z ]             @key{RET} 5 a <  Z [  5 Z (  & s + 2  1 s + 1  1 Z ) r 1  Z ]
9550             L r 1 2 * & - r 2 -             L r 1 2 * & - r 2 -
9551             2 RET 40  Z (  RET k b TAB RET r 1 TAB ^ * /             2 @key{RET} 40  Z (  @key{RET} k b @key{TAB} @key{RET} r 1 @key{TAB} ^ * /
9552                            TAB RET M-TAB - RET M-TAB a = Z /                            @key{TAB} @key{RET} M-@key{TAB} - @key{RET} M-@key{TAB} a = Z /
9553                    2  Z )                    2  Z )
9554        Z '        Z '
9555  C-x )  C-x )
 @end example  
9556  @end group  @end group
9557    @end example
9558    
9559  @node Programming Answer 10, Programming Answer 11, Programming Answer 9, Answers to Exercises  @node Programming Answer 10, Programming Answer 11, Programming Answer 9, Answers to Exercises
9560  @subsection Programming Tutorial Exercise 10  @subsection Programming Tutorial Exercise 10
# Line 9669  keystrokes without executing them.  In t Line 9574  keystrokes without executing them.  In t
9574  pretend Calc actually executed the keystrokes as you typed them,  pretend Calc actually executed the keystrokes as you typed them,
9575  just for purposes of illustration.)  just for purposes of illustration.)
9576    
 @group  
9577  @smallexample  @smallexample
9578    @group
9579  2:  5 x^4 + (x + 1)^2          3:  5 x^4 + (x + 1)^2  2:  5 x^4 + (x + 1)^2          3:  5 x^4 + (x + 1)^2
9580  1:  6                          2:  0  1:  6                          2:  0
9581      .                          1:  6      .                          1:  6
9582                                     .                                     .
9583    
9584    ' 5 x^4 + (x+1)^2 RET 6        C-x ( Z `  [ ] t 1  0 TAB    ' 5 x^4 + (x+1)^2 @key{RET} 6        C-x ( Z `  [ ] t 1  0 @key{TAB}
 @end smallexample  
9585  @end group  @end group
9586    @end smallexample
9587    
9588  @noindent  @noindent
9589  Variable 1 will accumulate the vector of coefficients.  Variable 1 will accumulate the vector of coefficients.
9590    
 @group  
9591  @smallexample  @smallexample
9592    @group
9593  2:  0              3:  0                  2:  5 x^4 + ...  2:  0              3:  0                  2:  5 x^4 + ...
9594  1:  5 x^4 + ...    2:  5 x^4 + ...        1:  1  1:  5 x^4 + ...    2:  5 x^4 + ...        1:  1
9595      .              1:  1                      .      .              1:  1                      .
9596                         .                         .
9597    
9598     Z ( TAB         RET 0 s l x RET            M-TAB ! /  s | 1     Z ( @key{TAB}         @key{RET} 0 s l x @key{RET}            M-@key{TAB} ! /  s | 1
 @end smallexample  
9599  @end group  @end group
9600    @end smallexample
9601    
9602  @noindent  @noindent
9603  Note that @kbd{s | 1} appends the top-of-stack value to the vector  Note that @kbd{s | 1} appends the top-of-stack value to the vector
9604  in a variable; it is completely analogous to @kbd{s + 1}.  We could  in a variable; it is completely analogous to @kbd{s + 1}.  We could
9605  have written instead, @kbd{r 1 TAB | t 1}.  have written instead, @kbd{r 1 @key{TAB} | t 1}.
9606    
 @group  
9607  @smallexample  @smallexample
9608    @group
9609  1:  20 x^3 + 2 x + 2      1:  0         1:  [1, 2, 1, 0, 5, 0, 0]  1:  20 x^3 + 2 x + 2      1:  0         1:  [1, 2, 1, 0, 5, 0, 0]
9610      .                         .             .      .                         .             .
9611    
9612      a d x RET                 1 Z )         DEL r 1  Z ' C-x )      a d x @key{RET}                 1 Z )         @key{DEL} r 1  Z ' C-x )
 @end smallexample  
9613  @end group  @end group
9614    @end smallexample
9615    
9616  To convert back, a simple method is just to map the coefficients  To convert back, a simple method is just to map the coefficients
9617  against a table of powers of @cite{x}.  against a table of powers of @cite{x}.
9618    
 @group  
9619  @smallexample  @smallexample
9620    @group
9621  2:  [1, 2, 1, 0, 5, 0, 0]    2:  [1, 2, 1, 0, 5, 0, 0]  2:  [1, 2, 1, 0, 5, 0, 0]    2:  [1, 2, 1, 0, 5, 0, 0]
9622  1:  6                        1:  [0, 1, 2, 3, 4, 5, 6]  1:  6                        1:  [0, 1, 2, 3, 4, 5, 6]
9623      .                            .      .                            .
9624    
9625      6 RET                        1 + 0 RET 1 C-u v x      6 @key{RET}                        1 + 0 @key{RET} 1 C-u v x
9626    
 @end smallexample  
9627  @end group  @end group
9628    @end smallexample
9629  @noindent  @noindent
 @group  
9630  @smallexample  @smallexample
9631    @group
9632  2:  [1, 2, 1, 0, 5, 0, 0]    2:  1 + 2 x + x^2 + 5 x^4  2:  [1, 2, 1, 0, 5, 0, 0]    2:  1 + 2 x + x^2 + 5 x^4
9633  1:  [1, x, x^2, x^3, ... ]       .  1:  [1, x, x^2, x^3, ... ]       .
9634      .      .
9635    
9636      ' x RET TAB V M ^            *      ' x @key{RET} @key{TAB} V M ^            *
 @end smallexample  
9637  @end group  @end group
9638    @end smallexample
9639    
9640  Once again, here are the whole polynomial to/from vector programs:  Once again, here are the whole polynomial to/from vector programs:
9641    
 @group  
9642  @example  @example
9643  C-x ( Z `  [ ] t 1  0 TAB  @group
9644             Z (  TAB RET 0 s l x RET M-TAB ! /  s | 1  C-x ( Z `  [ ] t 1  0 @key{TAB}
9645                  a d x RET             Z (  @key{TAB} @key{RET} 0 s l x @key{RET} M-@key{TAB} ! /  s | 1
9646                    a d x @key{RET}
9647           1 Z ) r 1           1 Z ) r 1
9648        Z '        Z '
9649  C-x )  C-x )
9650    
9651  C-x (  1 + 0 RET 1 C-u v x ' x RET TAB V M ^ *  C-x )  C-x (  1 + 0 @key{RET} 1 C-u v x ' x @key{RET} @key{TAB} V M ^ *  C-x )
 @end example  
9652  @end group  @end group
9653    @end example
9654    
9655  @node Programming Answer 11, Programming Answer 12, Programming Answer 10, Answers to Exercises  @node Programming Answer 11, Programming Answer 12, Programming Answer 10, Answers to Exercises
9656  @subsection Programming Tutorial Exercise 11  @subsection Programming Tutorial Exercise 11
# Line 9753  C-x (  1 + 0 RET 1 C-u v x ' x RET TAB V Line 9658  C-x (  1 + 0 RET 1 C-u v x ' x RET TAB V
9658  @noindent  @noindent
9659  First we define a dummy program to go on the @kbd{z s} key.  The true  First we define a dummy program to go on the @kbd{z s} key.  The true
9660  @w{@kbd{z s}} key is supposed to take two numbers from the stack and  @w{@kbd{z s}} key is supposed to take two numbers from the stack and
9661  return one number, so @kbd{DEL} as a dummy definition will make  return one number, so @key{DEL} as a dummy definition will make
9662  sure the stack comes out right.  sure the stack comes out right.
9663    
 @group  
9664  @smallexample  @smallexample
9665    @group
9666  2:  4          1:  4                         2:  4  2:  4          1:  4                         2:  4
9667  1:  2              .                         1:  2  1:  2              .                         1:  2
9668      .                                            .      .                                            .
9669    
9670    4 RET 2       C-x ( DEL C-x )  Z K s RET       2    4 @key{RET} 2       C-x ( @key{DEL} C-x )  Z K s @key{RET}       2
 @end smallexample  
9671  @end group  @end group
9672    @end smallexample
9673    
9674  The last step replaces the 2 that was eaten during the creation  The last step replaces the 2 that was eaten during the creation
9675  of the dummy @kbd{z s} command.  Now we move on to the real  of the dummy @kbd{z s} command.  Now we move on to the real
# Line 9774  to the form @cite{s(n,m) = s(n-1,m-1) - Line 9679  to the form @cite{s(n,m) = s(n-1,m-1) -
9679  (Because this definition is long, it will be repeated in concise form  (Because this definition is long, it will be repeated in concise form
9680  below.  You can use @kbd{M-# m} to load it from there.)  below.  You can use @kbd{M-# m} to load it from there.)
9681    
 @group  
9682  @smallexample  @smallexample
9683    @group
9684  2:  4        4:  4       3:  4       2:  4  2:  4        4:  4       3:  4       2:  4
9685  1:  2        3:  2       2:  2       1:  2  1:  2        3:  2       2:  2       1:  2
9686      .        2:  4       1:  0           .      .        2:  4       1:  0           .
9687               1:  2           .               1:  2           .
9688                   .                   .
9689    
9690    C-x (       M-2 RET        a =         Z [  DEL DEL 1  Z :    C-x (       M-2 @key{RET}        a =         Z [  @key{DEL} @key{DEL} 1  Z :
9691    
 @end smallexample  
9692  @end group  @end group
9693    @end smallexample
9694  @noindent  @noindent
 @group  
9695  @smallexample  @smallexample
9696    @group
9697  4:  4       2:  4                     2:  3      4:  3    4:  3    3:  3  4:  4       2:  4                     2:  3      4:  3    4:  3    3:  3
9698  3:  2       1:  2                     1:  2      3:  2    3:  2    2:  2  3:  2       1:  2                     1:  2      3:  2    3:  2    2:  2
9699  2:  2           .                         .      2:  3    2:  3    1:  3  2:  2           .                         .      2:  3    2:  3    1:  3
9700  1:  0                                            1:  2    1:  1        .  1:  0                                            1:  2    1:  1        .
9701      .                                                .        .      .                                                .        .
9702    
9703    RET 0   a = Z [  DEL DEL 0  Z :  TAB 1 - TAB   M-2 RET     1 -      z s    @key{RET} 0   a = Z [  @key{DEL} @key{DEL} 0  Z :  @key{TAB} 1 - @key{TAB}   M-2 @key{RET}     1 -      z s
 @end smallexample  
9704  @end group  @end group
9705    @end smallexample
9706    
9707  @noindent  @noindent
9708  (Note that the value 3 that our dummy @kbd{z s} produces is not correct;  (Note that the value 3 that our dummy @kbd{z s} produces is not correct;
9709  it is merely a placeholder that will do just as well for now.)  it is merely a placeholder that will do just as well for now.)
9710    
 @group  
9711  @smallexample  @smallexample
9712    @group
9713  3:  3               4:  3           3:  3       2:  3      1:  -6  3:  3               4:  3           3:  3       2:  3      1:  -6
9714  2:  3               3:  3           2:  3       1:  9          .  2:  3               3:  3           2:  3       1:  9          .
9715  1:  2               2:  3           1:  3           .  1:  2               2:  3           1:  3           .
9716      .               1:  2               .      .               1:  2               .
9717                          .                          .
9718    
9719   M-TAB M-TAB     TAB RET M-TAB         z s          *          -   M-@key{TAB} M-@key{TAB}     @key{TAB} @key{RET} M-@key{TAB}         z s          *          -
9720    
 @end smallexample  
9721  @end group  @end group
9722    @end smallexample
9723  @noindent  @noindent
 @group  
9724  @smallexample  @smallexample
9725    @group
9726  1:  -6                          2:  4          1:  11      2:  11  1:  -6                          2:  4          1:  11      2:  11
9727      .                           1:  2              .       1:  11      .                           1:  2              .       1:  11
9728                                      .                          .                                      .                          .
9729    
9730    Z ] Z ] C-x )   Z K s RET      DEL 4 RET 2       z s      M-RET k s    Z ] Z ] C-x )   Z K s @key{RET}      @key{DEL} 4 @key{RET} 2       z s      M-@key{RET} k s
 @end smallexample  
9731  @end group  @end group
9732    @end smallexample
9733    
9734  Even though the result that we got during the definition was highly  Even though the result that we got during the definition was highly
9735  bogus, once the definition is complete the @kbd{z s} command gets  bogus, once the definition is complete the @kbd{z s} command gets
# Line 9832  the right answers. Line 9737  the right answers.
9737    
9738  Here's the full program once again:  Here's the full program once again:
9739    
 @group  
9740  @example  @example
9741  C-x (  M-2 RET a =  @group
9742         Z [  DEL DEL 1  C-x (  M-2 @key{RET} a =
9743         Z :  RET 0 a =         Z [  @key{DEL} @key{DEL} 1
9744              Z [  DEL DEL 0         Z :  @key{RET} 0 a =
9745              Z :  TAB 1 - TAB M-2 RET 1 - z s              Z [  @key{DEL} @key{DEL} 0
9746                   M-TAB M-TAB TAB RET M-TAB z s * -              Z :  @key{TAB} 1 - @key{TAB} M-2 @key{RET} 1 - z s
9747                     M-@key{TAB} M-@key{TAB} @key{TAB} @key{RET} M-@key{TAB} z s * -
9748              Z ]              Z ]
9749         Z ]         Z ]
9750  C-x )  C-x )
 @end example  
9751  @end group  @end group
9752    @end example
9753    
9754  You can read this definition using @kbd{M-# m} (@code{read-kbd-macro})  You can read this definition using @kbd{M-# m} (@code{read-kbd-macro})
9755  followed by @kbd{Z K s}, without having to make a dummy definition  followed by @kbd{Z K s}, without having to make a dummy definition
# Line 9863  First, we store the rewrite rules corres Line 9768  First, we store the rewrite rules corres
9768  Stirling numbers in a convenient variable:  Stirling numbers in a convenient variable:
9769    
9770  @smallexample  @smallexample
9771  s e StirlingRules RET  s e StirlingRules @key{RET}
9772  [ s(n,n) := 1  :: n >= 0,  [ s(n,n) := 1  :: n >= 0,
9773    s(n,0) := 0  :: n > 0,    s(n,0) := 0  :: n > 0,
9774    s(n,m) := s(n-1,m-1) - (n-1) s(n-1,m) :: n >= m :: m >= 1 ]    s(n,m) := s(n-1,m-1) - (n-1) s(n-1,m) :: n >= m :: m >= 1 ]
# Line 9872  C-c C-c Line 9777  C-c C-c
9777    
9778  Now, it's just a matter of applying the rules:  Now, it's just a matter of applying the rules:
9779    
 @group  
9780  @smallexample  @smallexample
9781    @group
9782  2:  4          1:  s(4, 2)              1:  11  2:  4          1:  s(4, 2)              1:  11
9783  1:  2              .                        .  1:  2              .                        .
9784      .      .
9785    
9786    4 RET 2       C-x (  ' s($$,$) RET     a r StirlingRules RET  C-x )    4 @key{RET} 2       C-x (  ' s($$,$) @key{RET}     a r StirlingRules @key{RET}  C-x )
 @end smallexample  
9787  @end group  @end group
9788    @end smallexample
9789    
9790  As in the case of the @code{fib} rules, it would be useful to put these  As in the case of the @code{fib} rules, it would be useful to put these
9791  rules in @code{EvalRules} and to add a @samp{:: remember} condition to  rules in @code{EvalRules} and to add a @samp{:: remember} condition to
# Line 9942  still exists and is updated silently.  @ Line 9847  still exists and is updated silently.  @
9847    
9848  @kindex M-# c  @kindex M-# c
9849  @kindex M-# M-#  @kindex M-# M-#
9850  @c @mindex @null  @ignore
9851    @mindex @null
9852    @end ignore
9853  @kindex M-# #  @kindex M-# #
9854  In most installations, the @kbd{M-# c} key sequence is a more  In most installations, the @kbd{M-# c} key sequence is a more
9855  convenient way to start the Calculator.  Also, @kbd{M-# M-#} and  convenient way to start the Calculator.  Also, @kbd{M-# M-#} and
# Line 9999  window, @kbd{M-# o} switches you out of Line 9906  window, @kbd{M-# o} switches you out of
9906  tendency to drop you into the Calc Trail window instead, which  tendency to drop you into the Calc Trail window instead, which
9907  @kbd{M-# o} takes care not to do.)  @kbd{M-# o} takes care not to do.)
9908    
9909  @c @mindex M-# q  @ignore
9910    @mindex M-# q
9911    @end ignore
9912  For one quick calculation, you can type @kbd{M-# q} (@code{quick-calc})  For one quick calculation, you can type @kbd{M-# q} (@code{quick-calc})
9913  which prompts you for a formula (like @samp{2+3/4}).  The result is  which prompts you for a formula (like @samp{2+3/4}).  The result is
9914  displayed at the bottom of the Emacs screen without ever creating  displayed at the bottom of the Emacs screen without ever creating
9915  any special Calculator windows.  @xref{Quick Calculator}.  any special Calculator windows.  @xref{Quick Calculator}.
9916    
9917  @c @mindex M-# k  @ignore
9918    @mindex M-# k
9919    @end ignore
9920  Finally, if you are using the X window system you may want to try  Finally, if you are using the X window system you may want to try
9921  @kbd{M-# k} (@code{calc-keypad}) which runs Calc with a  @kbd{M-# k} (@code{calc-keypad}) which runs Calc with a
9922  ``calculator keypad'' picture as well as a stack display.  Click on  ``calculator keypad'' picture as well as a stack display.  Click on
# Line 10028  The @kbd{M-# x} command also turns the C Line 9939  The @kbd{M-# x} command also turns the C
9939  user interface (standard, Keypad, or Embedded) is currently active.  user interface (standard, Keypad, or Embedded) is currently active.
9940  It also cancels @code{calc-edit} mode if used from there.  It also cancels @code{calc-edit} mode if used from there.
9941    
9942  @kindex d SPC  @kindex d @key{SPC}
9943  @pindex calc-refresh  @pindex calc-refresh
9944  @cindex Refreshing a garbled display  @cindex Refreshing a garbled display
9945  @cindex Garbled displays, refreshing  @cindex Garbled displays, refreshing
9946  The @kbd{d SPC} key sequence (@code{calc-refresh}) redraws the contents  The @kbd{d @key{SPC}} key sequence (@code{calc-refresh}) redraws the contents
9947  of the Calculator buffer from memory.  Use this if the contents of the  of the Calculator buffer from memory.  Use this if the contents of the
9948  buffer have been damaged somehow.  buffer have been damaged somehow.
9949    
9950  @c @mindex o  @ignore
9951    @mindex o
9952    @end ignore
9953  The @kbd{o} key (@code{calc-realign}) moves the cursor back to its  The @kbd{o} key (@code{calc-realign}) moves the cursor back to its
9954  ``home'' position at the bottom of the Calculator buffer.  ``home'' position at the bottom of the Calculator buffer.
9955    
# Line 10250  argument, it instead moves the cursor to Line 10163  argument, it instead moves the cursor to
10163  The @key{RET} (or equivalent @key{SPC}) key is only required to separate  The @key{RET} (or equivalent @key{SPC}) key is only required to separate
10164  two consecutive numbers.  two consecutive numbers.
10165  (After all, if you typed @kbd{1 2} by themselves the Calculator  (After all, if you typed @kbd{1 2} by themselves the Calculator
10166  would enter the number 12.)  If you press @kbd{RET} or @kbd{SPC} @emph{not}  would enter the number 12.)  If you press @key{RET} or @key{SPC} @emph{not}
10167  right after typing a number, the key duplicates the number on the top of  right after typing a number, the key duplicates the number on the top of
10168  the stack.  @kbd{@key{RET} *} is thus a handy way to square a number.@refill  the stack.  @kbd{@key{RET} *} is thus a handy way to square a number.@refill
10169    
# Line 10294  non-decimal numbers, @kbd{:} for fractio Line 10207  non-decimal numbers, @kbd{:} for fractio
10207  These notations are described later in this manual with the corresponding  These notations are described later in this manual with the corresponding
10208  data types.  @xref{Data Types}.  data types.  @xref{Data Types}.
10209    
10210  During numeric entry, the only editing key available is @kbd{DEL}.  During numeric entry, the only editing key available is @key{DEL}.
10211    
10212  @node Algebraic Entry, Quick Calculator, Numeric Entry, Introduction  @node Algebraic Entry, Quick Calculator, Numeric Entry, Introduction
10213  @section Algebraic Entry  @section Algebraic Entry
# Line 10354  punctuation keys begin algebraic entry. Line 10267  punctuation keys begin algebraic entry.
10267  is the command to quit Calc, @kbd{M-p} sets the precision, and  is the command to quit Calc, @kbd{M-p} sets the precision, and
10268  @kbd{M-m t} (or @kbd{M-m M-t}, if you prefer) turns total algebraic  @kbd{M-m t} (or @kbd{M-m M-t}, if you prefer) turns total algebraic
10269  mode back off again.  Meta keys also terminate algebraic entry, so  mode back off again.  Meta keys also terminate algebraic entry, so
10270  that @kbd{2+3 M-S} is equivalent to @kbd{2+3 RET M-S}.  The symbol  that @kbd{2+3 M-S} is equivalent to @kbd{2+3 @key{RET} M-S}.  The symbol
10271  @samp{Alg*} will appear in the mode line whenever you are in this mode.  @samp{Alg*} will appear in the mode line whenever you are in this mode.
10272    
10273  Pressing @kbd{'} (the apostrophe) a second time re-enters the previous  Pressing @kbd{'} (the apostrophe) a second time re-enters the previous
# Line 10394  those three numbers onto the stack (leav Line 10307  those three numbers onto the stack (leav
10307  @samp{$,$$} exchanges the top two elements of the stack, just like the  @samp{$,$$} exchanges the top two elements of the stack, just like the
10308  @key{TAB} key.  @key{TAB} key.
10309    
10310  You can finish an algebraic entry with @kbd{M-=} or @kbd{M-RET} instead  You can finish an algebraic entry with @kbd{M-=} or @kbd{M-@key{RET}} instead
10311  of @key{RET}.  This uses @kbd{=} to evaluate the variables in each  of @key{RET}.  This uses @kbd{=} to evaluate the variables in each
10312  formula that goes onto the stack.  (Thus @kbd{' pi @key{RET}} pushes  formula that goes onto the stack.  (Thus @kbd{' pi @key{RET}} pushes
10313  the variable @samp{pi}, but @kbd{' pi M-RET} pushes 3.1415.)  the variable @samp{pi}, but @kbd{' pi M-@key{RET}} pushes 3.1415.)
10314    
10315  If you finish your algebraic entry by pressing @kbd{LFD} (or @kbd{C-j})  If you finish your algebraic entry by pressing @key{LFD} (or @kbd{C-j})
10316  instead of @key{RET}, Calc disables the default simplifications  instead of @key{RET}, Calc disables the default simplifications
10317  (as if by @kbd{m O}; @pxref{Simplification Modes}) while the entry  (as if by @kbd{m O}; @pxref{Simplification Modes}) while the entry
10318  is being pushed on the stack.  Thus @kbd{' 1+2 @key{RET}} pushes 3  is being pushed on the stack.  Thus @kbd{' 1+2 @key{RET}} pushes 3
# Line 10558  information is cleared whenever you give Line 10471  information is cleared whenever you give
10471  information, i.e., if you undo, then enter a number on the stack or make  information, i.e., if you undo, then enter a number on the stack or make
10472  any other change, then it will be too late to redo.  any other change, then it will be too late to redo.
10473    
10474  @kindex M-RET  @kindex M-@key{RET}
10475  @pindex calc-last-args  @pindex calc-last-args
10476  @cindex Last-arguments feature  @cindex Last-arguments feature
10477  @cindex Arguments, restoring  @cindex Arguments, restoring
# Line 11089  Many other operations are applied to vec Line 11002  Many other operations are applied to vec
11002  the complex conjugate of a vector is a vector of the complex conjugates  the complex conjugate of a vector is a vector of the complex conjugates
11003  of its elements.@refill  of its elements.@refill
11004    
11005  @c @starindex  @ignore
11006    @starindex
11007    @end ignore
11008  @tindex vec  @tindex vec
11009  Algebraic functions for building vectors include @samp{vec(a, b, c)}  Algebraic functions for building vectors include @samp{vec(a, b, c)}
11010  to build @samp{[a, b, c]}, @samp{cvec(a, n, m)} to build an @c{$n\times m$}  to build @samp{[a, b, c]}, @samp{cvec(a, n, m)} to build an @c{$n\times m$}
# Line 11111  enter a string at any time by pressing t Line 11026  enter a string at any time by pressing t
11026  marks and backslashes are written @samp{\"} and @samp{\\}, respectively,  marks and backslashes are written @samp{\"} and @samp{\\}, respectively,
11027  inside strings.  Other notations introduced by backslashes are:  inside strings.  Other notations introduced by backslashes are:
11028    
 @group  
11029  @example  @example
11030    @group
11031  \a     7          \^@@    0  \a     7          \^@@    0
11032  \b     8          \^a-z  1-26  \b     8          \^a-z  1-26
11033  \e     27         \^[    27  \e     27         \^[    27
# Line 11121  inside strings.  Other notations introdu Line 11036  inside strings.  Other notations introdu
11036  \r     13         \^^    30  \r     13         \^^    30
11037  \t     9          \^_    31  \t     9          \^_    31
11038                    \^?    127                    \^?    127
 @end example  
11039  @end group  @end group
11040    @end example
11041    
11042  @noindent  @noindent
11043  Finally, a backslash followed by three octal digits produces any  Finally, a backslash followed by three octal digits produces any
# Line 11146  The only Calc feature that uses strings Line 11061  The only Calc feature that uses strings
11061  @pxref{Compositions}.  Strings also provide a convenient  @pxref{Compositions}.  Strings also provide a convenient
11062  way to do conversions between ASCII characters and integers.  way to do conversions between ASCII characters and integers.
11063    
11064  @c @starindex  @ignore
11065    @starindex
11066    @end ignore
11067  @tindex string  @tindex string
11068  There is a @code{string} function which provides a different display  There is a @code{string} function which provides a different display
11069  format for strings.  Basically, @samp{string(@var{s})}, where @var{s}  format for strings.  Basically, @samp{string(@var{s})}, where @var{s}
# Line 11163  Characters below 32, and character 127, Line 11080  Characters below 32, and character 127,
11080  (same as shown above, but without the backslash).  The quote and  (same as shown above, but without the backslash).  The quote and
11081  backslash characters are left alone, as are characters 128 and above.  backslash characters are left alone, as are characters 128 and above.
11082    
11083  @c @starindex  @ignore
11084    @starindex
11085    @end ignore
11086  @tindex bstring  @tindex bstring
11087  The @code{bstring} function is just like @code{string} except that  The @code{bstring} function is just like @code{string} except that
11088  the resulting string is breakable across multiple lines if it doesn't  the resulting string is breakable across multiple lines if it doesn't
# Line 11184  use HMS as the angular mode so that calc Line 11103  use HMS as the angular mode so that calc
11103  degrees, minutes, and seconds.  degrees, minutes, and seconds.
11104    
11105  @kindex @@  @kindex @@
11106  @c @mindex @null  @ignore
11107    @mindex @null
11108    @end ignore
11109  @kindex ' (HMS forms)  @kindex ' (HMS forms)
11110  @c @mindex @null  @ignore
11111    @mindex @null
11112    @end ignore
11113  @kindex " (HMS forms)  @kindex " (HMS forms)
11114  @c @mindex @null  @ignore
11115    @mindex @null
11116    @end ignore
11117  @kindex h (HMS forms)  @kindex h (HMS forms)
11118  @c @mindex @null  @ignore
11119    @mindex @null
11120    @end ignore
11121  @kindex o (HMS forms)  @kindex o (HMS forms)
11122  @c @mindex @null  @ignore
11123    @mindex @null
11124    @end ignore
11125  @kindex m (HMS forms)  @kindex m (HMS forms)
11126  @c @mindex @null  @ignore
11127    @mindex @null
11128    @end ignore
11129  @kindex s (HMS forms)  @kindex s (HMS forms)
11130  The default format for HMS values is  The default format for HMS values is
11131  @samp{@var{hours}@@ @var{mins}' @var{secs}"}.  During entry, the letters  @samp{@var{hours}@@ @var{mins}' @var{secs}"}.  During entry, the letters
# Line 11343  conversions. Line 11274  conversions.
11274  @noindent  @noindent
11275  @cindex Modulo forms  @cindex Modulo forms
11276  A @dfn{modulo form} is a real number which is taken modulo (i.e., within  A @dfn{modulo form} is a real number which is taken modulo (i.e., within
11277  an integer multiple of) some value @cite{M}.  Arithmetic modulo @cite{M}  an integer multiple of) some value @var{M}.  Arithmetic modulo @var{M}
11278  often arises in number theory.  Modulo forms are written  often arises in number theory.  Modulo forms are written
11279  `@i{a} @t{mod} @i{M}',  `@var{a} @t{mod} @var{M}',
11280  where @cite{a} and @cite{M} are real numbers or HMS forms, and  where @var{a} and @var{M} are real numbers or HMS forms, and
11281  @c{$0 \le a < M$}  @c{$0 \le a < M$}
11282  @cite{0 <= a < @var{M}}.  @cite{0 <= a < @var{M}}.
11283  In many applications @cite{a} and @cite{M} will be  In many applications @cite{a} and @cite{M} will be
# Line 11369  are integers, this calculation is done m Line 11300  are integers, this calculation is done m
11300  actually computing the power and then reducing.)  actually computing the power and then reducing.)
11301    
11302  @cindex Modulo division  @cindex Modulo division
11303  Two modulo forms `@i{a} @t{mod} @i{M}' and `@i{b} @t{mod} @i{M}'  Two modulo forms `@var{a} @t{mod} @var{M}' and `@var{b} @t{mod} @var{M}'
11304  can be divided if @cite{a}, @cite{b}, and @cite{M} are all  can be divided if @cite{a}, @cite{b}, and @cite{M} are all
11305  integers.  The result is the modulo form which, when multiplied by  integers.  The result is the modulo form which, when multiplied by
11306  `@i{b} @t{mod} @i{M}', produces `@i{a} @t{mod} @i{M}'.  If  `@var{b} @t{mod} @var{M}', produces `@var{a} @t{mod} @var{M}'.  If
11307  there is no solution to this equation (which can happen only when  there is no solution to this equation (which can happen only when
11308  @cite{M} is non-prime), or if any of the arguments are non-integers, the  @cite{M} is non-prime), or if any of the arguments are non-integers, the
11309  division is left in symbolic form.  Other operations, such as square  division is left in symbolic form.  Other operations, such as square
11310  roots, are not yet supported for modulo forms.  (Note that, although  roots, are not yet supported for modulo forms.  (Note that, although
11311  @w{`@t{(}@i{a} @t{mod} @i{M}@t{)^.5}'} will compute a ``modulo square root''  @w{`@t{(}@var{a} @t{mod} @var{M}@t{)^.5}'} will compute a ``modulo square root''
11312  in the sense of reducing @c{$\sqrt a$}  in the sense of reducing @c{$\sqrt a$}
11313  @cite{sqrt(a)} modulo @cite{M}, this is not a  @cite{sqrt(a)} modulo @cite{M}, this is not a
11314  useful definition from the number-theoretical point of view.)@refill  useful definition from the number-theoretical point of view.)@refill
11315    
11316  @c @mindex M  @ignore
11317    @mindex M
11318    @end ignore
11319  @kindex M (modulo forms)  @kindex M (modulo forms)
11320  @c @mindex mod  @ignore
11321    @mindex mod
11322    @end ignore
11323  @tindex mod (operator)  @tindex mod (operator)
11324  To create a modulo form during numeric entry, press the shift-@kbd{M}  To create a modulo form during numeric entry, press the shift-@kbd{M}
11325  key to enter the word @samp{mod}.  As a special convenience, pressing  key to enter the word @samp{mod}.  As a special convenience, pressing
# Line 11408  Modulo forms cannot have variables or fo Line 11343  Modulo forms cannot have variables or fo
11343  enter the formula @samp{(x + 2) mod 5}, Calc propagates the modulus  enter the formula @samp{(x + 2) mod 5}, Calc propagates the modulus
11344  to each of the coefficients:  @samp{(1 mod 5) x + (2 mod 5)}.  to each of the coefficients:  @samp{(1 mod 5) x + (2 mod 5)}.
11345    
11346  @c @starindex  @ignore
11347    @starindex
11348    @end ignore
11349  @tindex makemod  @tindex makemod
11350  The algebraic function @samp{makemod(a, m)} builds the modulo form  The algebraic function @samp{makemod(a, m)} builds the modulo form
11351  @w{@samp{a mod m}}.  @w{@samp{a mod m}}.
# Line 11421  The algebraic function @samp{makemod(a, Line 11358  The algebraic function @samp{makemod(a,
11358  @cindex Standard deviations  @cindex Standard deviations
11359  An @dfn{error form} is a number with an associated standard  An @dfn{error form} is a number with an associated standard
11360  deviation, as in @samp{2.3 +/- 0.12}.  The notation  deviation, as in @samp{2.3 +/- 0.12}.  The notation
11361  `@i{x} @t{+/-} @c{$\sigma$}  `@var{x} @t{+/-} @c{$\sigma$}
11362  @asis{sigma}' stands for an uncertain value which follows a normal or  @asis{sigma}' stands for an uncertain value which follows a normal or
11363  Gaussian distribution of mean @cite{x} and standard deviation or  Gaussian distribution of mean @cite{x} and standard deviation or
11364  ``error'' @c{$\sigma$}  ``error'' @c{$\sigma$}
# Line 11464  Consult a good text on error analysis fo Line 11401  Consult a good text on error analysis fo
11401  of standard deviations.  Actual errors often are neither Gaussian-distributed  of standard deviations.  Actual errors often are neither Gaussian-distributed
11402  nor uncorrelated, and the above formulas are valid only when errors  nor uncorrelated, and the above formulas are valid only when errors
11403  are small.  As an example, the error arising from  are small.  As an example, the error arising from
11404  `@t{sin(}@i{x} @t{+/-} @c{$\sigma$}  `@t{sin(}@var{x} @t{+/-} @c{$\sigma$}
11405  @i{sigma}@t{)}' is  @var{sigma}@t{)}' is
11406  `@c{$\sigma$\nobreak}  `@c{$\sigma$\nobreak}
11407  @i{sigma} @t{abs(cos(}@i{x}@t{))}'.  When @cite{x} is close to zero,  @var{sigma} @t{abs(cos(}@var{x}@t{))}'.  When @cite{x} is close to zero,
11408  @c{$\cos x$}  @c{$\cos x$}
11409  @cite{cos(x)} is  @cite{cos(x)} is
11410  close to one so the error in the sine is close to @c{$\sigma$}  close to one so the error in the sine is close to @c{$\sigma$}
# Line 11485  the small-error approximation underlying Line 11422  the small-error approximation underlying
11422  in @cite{x} had been small, the error in @c{$\sin x$}  in @cite{x} had been small, the error in @c{$\sin x$}
11423  @cite{sin(x)} would indeed have been negligible.@refill  @cite{sin(x)} would indeed have been negligible.@refill
11424    
11425  @c @mindex p  @ignore
11426    @mindex p
11427    @end ignore
11428  @kindex p (error forms)  @kindex p (error forms)
11429  @tindex +/-  @tindex +/-
11430  To enter an error form during regular numeric entry, use the @kbd{p}  To enter an error form during regular numeric entry, use the @kbd{p}
# Line 11506  not a complex distribution around a real Line 11445  not a complex distribution around a real
11445  Error forms may also be composed of HMS forms.  For best results, both  Error forms may also be composed of HMS forms.  For best results, both
11446  the mean and the error should be HMS forms if either one is.  the mean and the error should be HMS forms if either one is.
11447    
11448  @c @starindex  @ignore
11449    @starindex
11450    @end ignore
11451  @tindex sdev  @tindex sdev
11452  The algebraic function @samp{sdev(a, b)} builds the error form @samp{a +/- b}.  The algebraic function @samp{sdev(a, b)} builds the error form @samp{a +/- b}.
11453    
# Line 11585  contain zero inside them Calc is forced Line 11526  contain zero inside them Calc is forced
11526    
11527  While it may seem that intervals and error forms are similar, they are  While it may seem that intervals and error forms are similar, they are
11528  based on entirely different concepts of inexact quantities.  An error  based on entirely different concepts of inexact quantities.  An error
11529  form `@i{x} @t{+/-} @c{$\sigma$}  form `@var{x} @t{+/-} @c{$\sigma$}
11530  @i{sigma}' means a variable is random, and its value could  @var{sigma}' means a variable is random, and its value could
11531  be anything but is ``probably'' within one @c{$\sigma$}  be anything but is ``probably'' within one @c{$\sigma$}
11532  @i{sigma} of the mean value @cite{x}.  @var{sigma} of the mean value @cite{x}.
11533  An interval `@t{[}@i{a} @t{..@:} @i{b}@t{]}' means a variable's value  An interval `@t{[}@var{a} @t{..@:} @var{b}@t{]}' means a variable's value
11534  is unknown, but guaranteed to lie in the specified range.  Error forms  is unknown, but guaranteed to lie in the specified range.  Error forms
11535  are statistical or ``average case'' approximations; interval arithmetic  are statistical or ``average case'' approximations; interval arithmetic
11536  tends to produce ``worst case'' bounds on an answer.@refill  tends to produce ``worst case'' bounds on an answer.@refill
# Line 11600  HMS forms or date forms. Line 11541  HMS forms or date forms.
11541  @xref{Set Operations}, for commands that interpret interval forms  @xref{Set Operations}, for commands that interpret interval forms
11542  as subsets of the set of real numbers.  as subsets of the set of real numbers.
11543    
11544  @c @starindex  @ignore
11545    @starindex
11546    @end ignore
11547  @tindex intv  @tindex intv
11548  The algebraic function @samp{intv(n, a, b)} builds an interval form  The algebraic function @samp{intv(n, a, b)} builds an interval form
11549  from @samp{a} to @samp{b}; @samp{n} is an integer code which must  from @samp{a} to @samp{b}; @samp{n} is an integer code which must
# Line 11622  error. Line 11565  error.
11565  @section Incomplete Objects  @section Incomplete Objects
11566    
11567  @noindent  @noindent
11568  @c @mindex [ ]  @ignore
11569    @mindex [ ]
11570    @end ignore
11571  @kindex [  @kindex [
11572  @c @mindex ( )  @ignore
11573    @mindex ( )
11574    @end ignore
11575  @kindex (  @kindex (
11576  @kindex ,  @kindex ,
11577  @c @mindex @null  @ignore
11578    @mindex @null
11579    @end ignore
11580  @kindex ]  @kindex ]
11581  @c @mindex @null  @ignore
11582    @mindex @null
11583    @end ignore
11584  @kindex )  @kindex )
11585  @cindex Incomplete vectors  @cindex Incomplete vectors
11586  @cindex Incomplete complex numbers  @cindex Incomplete complex numbers
# Line 11919  type, such as numbers, vectors, formulas Line 11870  type, such as numbers, vectors, formulas
11870  @section Stack Manipulation Commands  @section Stack Manipulation Commands
11871    
11872  @noindent  @noindent
11873  @kindex RET  @kindex @key{RET}
11874  @kindex SPC  @kindex @key{SPC}
11875  @pindex calc-enter  @pindex calc-enter
11876  @cindex Duplicating stack entries  @cindex Duplicating stack entries
11877  To duplicate the top object on the stack, press @key{RET} or @key{SPC}  To duplicate the top object on the stack, press @key{RET} or @key{SPC}
# Line 11936  For example, with @samp{10 20 30} on the Line 11887  For example, with @samp{10 20 30} on the
11887  @kbd{C-u - 2 @key{RET}} creates @samp{10 20 30 20}, and  @kbd{C-u - 2 @key{RET}} creates @samp{10 20 30 20}, and
11888  @kbd{C-u 0 @key{RET}} creates @samp{10 20 30 10 20 30}.@refill  @kbd{C-u 0 @key{RET}} creates @samp{10 20 30 10 20 30}.@refill
11889    
11890  @kindex LFD  @kindex @key{LFD}
11891  @pindex calc-over  @pindex calc-over
11892  The @key{LFD} (@code{calc-over}) command (on a key marked Line-Feed if you  The @key{LFD} (@code{calc-over}) command (on a key marked Line-Feed if you
11893  have it, else on @kbd{C-j}) is like @code{calc-enter}  have it, else on @kbd{C-j}) is like @code{calc-enter}
# Line 11946  Thus with @samp{10 20 30} on the stack, Line 11897  Thus with @samp{10 20 30} on the stack,
11897  are both equivalent to @kbd{C-u - 2 @key{RET}}, producing  are both equivalent to @kbd{C-u - 2 @key{RET}}, producing
11898  @samp{10 20 30 20}.@refill  @samp{10 20 30 20}.@refill
11899    
11900  @kindex DEL  @kindex @key{DEL}
11901  @kindex C-d  @kindex C-d
11902  @pindex calc-pop  @pindex calc-pop
11903  @cindex Removing stack entries  @cindex Removing stack entries
# Line 11964  For example, with @samp{10 20 30} on the Line 11915  For example, with @samp{10 20 30} on the
11915  @kbd{C-u - 2 @key{DEL}} leaves @samp{10 30}, and  @kbd{C-u - 2 @key{DEL}} leaves @samp{10 30}, and
11916  @kbd{C-u 0 @key{DEL}} leaves an empty stack.@refill  @kbd{C-u 0 @key{DEL}} leaves an empty stack.@refill
11917    
11918  @kindex M-DEL  @kindex M-@key{DEL}
11919  @pindex calc-pop-above  @pindex calc-pop-above
11920  The @key{M-DEL} (@code{calc-pop-above}) command is to @key{DEL} what  The @key{M-@key{DEL}} (@code{calc-pop-above}) command is to @key{DEL} what
11921  @key{LFD} is to @key{RET}:  It interprets the sign of the numeric  @key{LFD} is to @key{RET}:  It interprets the sign of the numeric
11922  prefix argument in the opposite way, and the default argument is 2.  prefix argument in the opposite way, and the default argument is 2.
11923  Thus @key{M-DEL} by itself removes the second-from-top stack element,  Thus @key{M-@key{DEL}} by itself removes the second-from-top stack element,
11924  leaving the first, third, fourth, and so on; @kbd{M-3 M-DEL} deletes  leaving the first, third, fourth, and so on; @kbd{M-3 M-@key{DEL}} deletes
11925  the third stack element.  the third stack element.
11926    
11927  @kindex TAB  @kindex @key{TAB}
11928  @pindex calc-roll-down  @pindex calc-roll-down
11929  To exchange the top two elements of the stack, press @key{TAB}  To exchange the top two elements of the stack, press @key{TAB}
11930  (@code{calc-roll-down}).  Given a positive numeric prefix argument, the  (@code{calc-roll-down}).  Given a positive numeric prefix argument, the
# Line 11987  For example, with @samp{10 20 30 40 50} Line 11938  For example, with @samp{10 20 30 40 50}
11938  @kbd{C-u - 2 @key{TAB}} creates @samp{40 50 10 20 30}, and  @kbd{C-u - 2 @key{TAB}} creates @samp{40 50 10 20 30}, and
11939  @kbd{C-u 0 @key{TAB}} creates @samp{50 40 30 20 10}.@refill  @kbd{C-u 0 @key{TAB}} creates @samp{50 40 30 20 10}.@refill
11940    
11941  @kindex M-TAB  @kindex M-@key{TAB}
11942  @pindex calc-roll-up  @pindex calc-roll-up
11943  The command @key{M-TAB} (@code{calc-roll-up}) is analogous to @key{TAB}  The command @kbd{M-@key{TAB}} (@code{calc-roll-up}) is analogous to @key{TAB}
11944  except that it rotates upward instead of downward.  Also, the default  except that it rotates upward instead of downward.  Also, the default
11945  with no prefix argument is to rotate the top 3 elements.  with no prefix argument is to rotate the top 3 elements.
11946  For example, with @samp{10 20 30 40 50} on the stack,  For example, with @samp{10 20 30 40 50} on the stack,
11947  @key{M-TAB} creates @samp{10 20 40 50 30},  @kbd{M-@key{TAB}} creates @samp{10 20 40 50 30},
11948  @kbd{C-u 4 @key{M-TAB}} creates @samp{10 30 40 50 20},  @kbd{C-u 4 M-@key{TAB}} creates @samp{10 30 40 50 20},
11949  @kbd{C-u - 2 @key{M-TAB}} creates @samp{30 40 50 10 20}, and  @kbd{C-u - 2 M-@key{TAB}} creates @samp{30 40 50 10 20}, and
11950  @kbd{C-u 0 @key{M-TAB}} creates @samp{50 40 30 20 10}.@refill  @kbd{C-u 0 M-@key{TAB}} creates @samp{50 40 30 20 10}.@refill
11951    
11952  A good way to view the operation of @key{TAB} and @key{M-TAB} is in  A good way to view the operation of @key{TAB} and @kbd{M-@key{TAB}} is in
11953  terms of moving a particular element to a new position in the stack.  terms of moving a particular element to a new position in the stack.
11954  With a positive argument @i{n}, @key{TAB} moves the top stack  With a positive argument @var{n}, @key{TAB} moves the top stack
11955  element down to level @i{n}, making room for it by pulling all the  element down to level @var{n}, making room for it by pulling all the
11956  intervening stack elements toward the top.  @key{M-TAB} moves the  intervening stack elements toward the top.  @kbd{M-@key{TAB}} moves the
11957  element at level @i{n} up to the top.  (Compare with @key{LFD},  element at level @var{n} up to the top.  (Compare with @key{LFD},
11958  which copies instead of moving the element in level @i{n}.)  which copies instead of moving the element in level @var{n}.)
11959    
11960  With a negative argument @i{-n}, @key{TAB} rotates the stack  With a negative argument @i{-@var{n}}, @key{TAB} rotates the stack
11961  to move the object in level @i{n} to the deepest place in the  to move the object in level @var{n} to the deepest place in the
11962  stack, and the object in level @i{n+1} to the top.  @key{M-TAB}  stack, and the object in level @i{@var{n}+1} to the top.  @kbd{M-@key{TAB}}
11963  rotates the deepest stack element to be in level @i{n}, also  rotates the deepest stack element to be in level @i{n}, also
11964  putting the top stack element in level @i{n+1}.  putting the top stack element in level @i{@var{n}+1}.
11965    
11966  @xref{Selecting Subformulas}, for a way to apply these commands to  @xref{Selecting Subformulas}, for a way to apply these commands to
11967  any portion of a vector or formula on the stack.  any portion of a vector or formula on the stack.
# Line 12208  another example, @kbd{K a s} simplifies Line 12159  another example, @kbd{K a s} simplifies
12159  simplified version of the formula onto the stack after the original  simplified version of the formula onto the stack after the original
12160  formula (rather than replacing the original formula).  formula (rather than replacing the original formula).
12161    
12162  Note that you could get the same effect by typing @kbd{RET a s},  Note that you could get the same effect by typing @kbd{@key{RET} a s},
12163  copying the formula and then simplifying the copy.  One difference  copying the formula and then simplifying the copy.  One difference
12164  is that for a very large formula the time taken to format the  is that for a very large formula the time taken to format the
12165  intermediate copy in @kbd{RET a s} could be noticeable; @kbd{K a s}  intermediate copy in @kbd{@key{RET} a s} could be noticeable; @kbd{K a s}
12166  would avoid this extra work.  would avoid this extra work.
12167    
12168  Even stack manipulation commands are affected.  @key{TAB} works by  Even stack manipulation commands are affected.  @key{TAB} works by
# Line 12385  of the numbers involved. Line 12336  of the numbers involved.
12336  If you need to work with a particular fixed accuracy (say, dollars and  If you need to work with a particular fixed accuracy (say, dollars and
12337  cents with two digits after the decimal point), one solution is to work  cents with two digits after the decimal point), one solution is to work
12338  with integers and an ``implied'' decimal point.  For example, $8.99  with integers and an ``implied'' decimal point.  For example, $8.99
12339  divided by 6 would be entered @kbd{899 RET 6 /}, yielding 149.833  divided by 6 would be entered @kbd{899 @key{RET} 6 /}, yielding 149.833
12340  (actually $1.49833 with our implied decimal point); pressing @kbd{R}  (actually $1.49833 with our implied decimal point); pressing @kbd{R}
12341  would round this to 150 cents, i.e., $1.50.  would round this to 150 cents, i.e., $1.50.
12342    
# Line 12832  the declaration, effectively ``undeclari Line 12783  the declaration, effectively ``undeclari
12783  A declaration is in general a vector of @dfn{type symbols} and  A declaration is in general a vector of @dfn{type symbols} and
12784  @dfn{range} values.  If there is only one type symbol or range value,  @dfn{range} values.  If there is only one type symbol or range value,
12785  you can write it directly rather than enclosing it in a vector.  you can write it directly rather than enclosing it in a vector.
12786  For example, @kbd{s d foo RET real RET} declares @code{foo} to  For example, @kbd{s d foo @key{RET} real @key{RET}} declares @code{foo} to
12787  be a real number, and @kbd{s d bar RET [int, const, [1..6]] RET}  be a real number, and @kbd{s d bar @key{RET} [int, const, [1..6]] @key{RET}}
12788  declares @code{bar} to be a constant integer between 1 and 6.  declares @code{bar} to be a constant integer between 1 and 6.
12789  (Actually, you can omit the outermost brackets and Calc will  (Actually, you can omit the outermost brackets and Calc will
12790  provide them for you: @kbd{s d bar RET int, const, [1..6] RET}.)  provide them for you: @kbd{s d bar @key{RET} int, const, [1..6] @key{RET}}.)
12791    
12792  @cindex @code{Decls} variable  @cindex @code{Decls} variable
12793  @vindex Decls  @vindex Decls
# Line 12858  declaration you will have to edit the @c Line 12809  declaration you will have to edit the @c
12809    
12810  For example, the declaration matrix  For example, the declaration matrix
12811    
 @group  
12812  @smallexample  @smallexample
12813    @group
12814  [ [ foo,       real       ]  [ [ foo,       real       ]
12815    [ [j, k, n], int        ]    [ [j, k, n], int        ]
12816    [ f(1,2,3),  [0 .. inf) ] ]    [ f(1,2,3),  [0 .. inf) ] ]
 @end smallexample  
12817  @end group  @end group
12818    @end smallexample
12819    
12820  @noindent  @noindent
12821  declares that @code{foo} represents a real number, @code{j}, @code{k}  declares that @code{foo} represents a real number, @code{j}, @code{k}
# Line 12890  vector consisting of zero or more type s Line 12841  vector consisting of zero or more type s
12841  more intervals or numbers that represent the set of possible values  more intervals or numbers that represent the set of possible values
12842  for the variable.  for the variable.
12843    
 @group  
12844  @smallexample  @smallexample
12845    @group
12846  [ [ a, [1, 2, 3, 4, 5] ]  [ [ a, [1, 2, 3, 4, 5] ]
12847    [ b, [1 .. 5]        ]    [ b, [1 .. 5]        ]
12848    [ c, [int, 1 .. 5]   ] ]    [ c, [int, 1 .. 5]   ] ]
 @end smallexample  
12849  @end group  @end group
12850    @end smallexample
12851    
12852  Here @code{a} is declared to contain one of the five integers shown;  Here @code{a} is declared to contain one of the five integers shown;
12853  @code{b} is any number in the interval from 1 to 5 (any real number  @code{b} is any number in the interval from 1 to 5 (any real number
# Line 12968  this property, you could get Calc to rec Line 12919  this property, you could get Calc to rec
12919  One instance of this simplification is @samp{sqrt(x^2)} (since the  One instance of this simplification is @samp{sqrt(x^2)} (since the
12920  @code{sqrt} function is effectively a one-half power).  Normally  @code{sqrt} function is effectively a one-half power).  Normally
12921  Calc leaves this formula alone.  After the command  Calc leaves this formula alone.  After the command
12922  @kbd{s d x RET real RET}, however, it can simplify the formula to  @kbd{s d x @key{RET} real @key{RET}}, however, it can simplify the formula to
12923  @samp{abs(x)}.  And after @kbd{s d x RET nonneg RET}, Calc can  @samp{abs(x)}.  And after @kbd{s d x @key{RET} nonneg @key{RET}}, Calc can
12924  simplify this formula all the way to @samp{x}.  simplify this formula all the way to @samp{x}.
12925    
12926  If there are any intervals or real numbers in the type specifier,  If there are any intervals or real numbers in the type specifier,
# Line 13088  do @samp{dint(n)} and @samp{dint(2 n - 3 Line 13039  do @samp{dint(n)} and @samp{dint(2 n - 3
13039  Calc consults knowledge of its own built-in functions as well as your  Calc consults knowledge of its own built-in functions as well as your
13040  own declarations: @samp{dint(floor(x))} returns 1.  own declarations: @samp{dint(floor(x))} returns 1.
13041    
13042  @c @starindex  @ignore
13043    @starindex
13044    @end ignore
13045  @tindex dint  @tindex dint
13046  @c @starindex  @ignore
13047    @starindex
13048    @end ignore
13049  @tindex dnumint  @tindex dnumint
13050  @c @starindex  @ignore
13051    @starindex
13052    @end ignore
13053  @tindex dnatnum  @tindex dnatnum
13054  The @code{dint} function checks if its argument is an integer.  The @code{dint} function checks if its argument is an integer.
13055  The @code{dnatnum} function checks if its argument is a natural  The @code{dnatnum} function checks if its argument is a natural
# Line 13103  data type functions also accept vectors Line 13060  data type functions also accept vectors
13060  suitable elements, and that real infinities @samp{inf} and @samp{-inf}  suitable elements, and that real infinities @samp{inf} and @samp{-inf}
13061  are considered to be integers for the purposes of these functions.  are considered to be integers for the purposes of these functions.
13062    
13063  @c @starindex  @ignore
13064    @starindex
13065    @end ignore
13066  @tindex drat  @tindex drat
13067  The @code{drat} function checks if its argument is rational, i.e.,  The @code{drat} function checks if its argument is rational, i.e.,
13068  an integer or fraction.  Infinities count as rational, but intervals  an integer or fraction.  Infinities count as rational, but intervals
13069  and error forms do not.  and error forms do not.
13070    
13071  @c @starindex  @ignore
13072    @starindex
13073    @end ignore
13074  @tindex dreal  @tindex dreal
13075  The @code{dreal} function checks if its argument is real.  This  The @code{dreal} function checks if its argument is real.  This
13076  includes integers, fractions, floats, real error forms, and intervals.  includes integers, fractions, floats, real error forms, and intervals.
13077    
13078  @c @starindex  @ignore
13079    @starindex
13080    @end ignore
13081  @tindex dimag  @tindex dimag
13082  The @code{dimag} function checks if its argument is imaginary,  The @code{dimag} function checks if its argument is imaginary,
13083  i.e., is mathematically equal to a real number times @cite{i}.  i.e., is mathematically equal to a real number times @cite{i}.
13084    
13085  @c @starindex  @ignore
13086    @starindex
13087    @end ignore
13088  @tindex dpos  @tindex dpos
13089  @c @starindex  @ignore
13090    @starindex
13091    @end ignore
13092  @tindex dneg  @tindex dneg
13093  @c @starindex  @ignore
13094    @starindex
13095    @end ignore
13096  @tindex dnonneg  @tindex dnonneg
13097  The @code{dpos} function checks for positive (but nonzero) reals.  The @code{dpos} function checks for positive (but nonzero) reals.
13098  The @code{dneg} function checks for negative reals.  The @code{dnonneg}  The @code{dneg} function checks for negative reals.  The @code{dnonneg}
# Line 13134  expression like @cite{x > 0} to 1 or 0 u Line 13103  expression like @cite{x > 0} to 1 or 0 u
13103  so the actual functions @code{dpos}, @code{dneg}, and @code{dnonneg}  so the actual functions @code{dpos}, @code{dneg}, and @code{dnonneg}
13104  are rarely necessary.  are rarely necessary.
13105    
13106  @c @starindex  @ignore
13107    @starindex
13108    @end ignore
13109  @tindex dnonzero  @tindex dnonzero
13110  The @code{dnonzero} function checks that its argument is nonzero.  The @code{dnonzero} function checks that its argument is nonzero.
13111  This includes all nonzero real or complex numbers, all intervals that  This includes all nonzero real or complex numbers, all intervals that
# Line 13144  deduced to be nonzero.  It does not incl Line 13115  deduced to be nonzero.  It does not incl
13115  represent values which could be anything including zero.  (This is  represent values which could be anything including zero.  (This is
13116  also the set of objects considered ``true'' in conditional contexts.)  also the set of objects considered ``true'' in conditional contexts.)
13117    
13118  @c @starindex  @ignore
13119    @starindex
13120    @end ignore
13121  @tindex deven  @tindex deven
13122  @c @starindex  @ignore
13123    @starindex
13124    @end ignore
13125  @tindex dodd  @tindex dodd
13126  The @code{deven} function returns 1 if its argument is known to be  The @code{deven} function returns 1 if its argument is known to be
13127  an even integer (or integer-valued float); it returns 0 if its argument  an even integer (or integer-valued float); it returns 0 if its argument
# Line 13154  is known not to be even (because it is k Line 13129  is known not to be even (because it is k
13129  The @kbd{a s} command uses this to simplify a test of the form  The @kbd{a s} command uses this to simplify a test of the form
13130  @samp{x % 2 = 0}.  There is also an analogous @code{dodd} function.  @samp{x % 2 = 0}.  There is also an analogous @code{dodd} function.
13131    
13132  @c @starindex  @ignore
13133    @starindex
13134    @end ignore
13135  @tindex drange  @tindex drange
13136  The @code{drange} function returns a set (an interval or a vector  The @code{drange} function returns a set (an interval or a vector
13137  of intervals and/or numbers; @pxref{Set Operations}) that describes  of intervals and/or numbers; @pxref{Set Operations}) that describes
# Line 13166  etc., and a suitable set like @samp{[0 . Line 13143  etc., and a suitable set like @samp{[0 .
13143  the expression is not provably real, the @code{drange} function  the expression is not provably real, the @code{drange} function
13144  remains unevaluated.  remains unevaluated.
13145    
13146  @c @starindex  @ignore
13147    @starindex
13148    @end ignore
13149  @tindex dscalar  @tindex dscalar
13150  The @code{dscalar} function returns 1 if its argument is provably  The @code{dscalar} function returns 1 if its argument is provably
13151  scalar, or 0 if its argument is provably non-scalar.  It is left  scalar, or 0 if its argument is provably non-scalar.  It is left
# Line 13196  refresh the stack to leave the stack dis Line 13175  refresh the stack to leave the stack dis
13175  will appear in the mode line when Calc thinks the stack display may not  will appear in the mode line when Calc thinks the stack display may not
13176  reflect the latest mode settings.  reflect the latest mode settings.
13177    
13178  @kindex d RET  @kindex d @key{RET}
13179  @pindex calc-refresh-top  @pindex calc-refresh-top
13180  The @kbd{d RET} (@code{calc-refresh-top}) command reformats the  The @kbd{d @key{RET}} (@code{calc-refresh-top}) command reformats the
13181  top stack entry according to all the current modes.  Positive prefix  top stack entry according to all the current modes.  Positive prefix
13182  arguments reformat the top @var{n} entries; negative prefix arguments  arguments reformat the top @var{n} entries; negative prefix arguments
13183  reformat the specified entry, and a prefix of zero is equivalent to  reformat the specified entry, and a prefix of zero is equivalent to
13184  @kbd{d SPC} (@code{calc-refresh}), which reformats the entire stack.  @kbd{d @key{SPC}} (@code{calc-refresh}), which reformats the entire stack.
13185  For example, @kbd{H d s M-2 d RET} changes to scientific notation  For example, @kbd{H d s M-2 d @key{RET}} changes to scientific notation
13186  but reformats only the top two stack entries in the new mode.  but reformats only the top two stack entries in the new mode.
13187    
13188  The @kbd{I} prefix has another effect on the display modes.  The mode  The @kbd{I} prefix has another effect on the display modes.  The mode
13189  is set only temporarily; the top stack entry is reformatted according  is set only temporarily; the top stack entry is reformatted according
13190  to that mode, then the original mode setting is restored.  In other  to that mode, then the original mode setting is restored.  In other
13191  words, @kbd{I d s} is equivalent to @kbd{H d s d RET H d (@var{old mode})}.  words, @kbd{I d s} is equivalent to @kbd{H d s d @key{RET} H d (@var{old mode})}.
13192    
13193  @menu  @menu
13194  * Radix Modes::  * Radix Modes::
# Line 13829  stack entries are displayed flush-right Line 13808  stack entries are displayed flush-right
13808  window.@refill  window.@refill
13809    
13810  If you change the width of the Calculator window you may have to type  If you change the width of the Calculator window you may have to type
13811  @kbd{d SPC} (@code{calc-refresh}) to re-align right-justified or centered  @kbd{d @key{SPC}} (@code{calc-refresh}) to re-align right-justified or centered
13812  text.  text.
13813    
13814  Right-justification is especially useful together with fixed-point  Right-justification is especially useful together with fixed-point
# Line 14200  in Calc, @TeX{}, and @dfn{eqn} (describe Line 14179  in Calc, @TeX{}, and @dfn{eqn} (describe
14179  @let@calcindexershow=@calcindexernoshow  @c Suppress marginal notes  @let@calcindexershow=@calcindexernoshow  @c Suppress marginal notes
14180  @let@calcindexersh=@calcindexernoshow  @let@calcindexersh=@calcindexernoshow
14181  @end iftex  @end iftex
14182  @c @starindex  @ignore
14183    @starindex
14184    @end ignore
14185  @tindex acute  @tindex acute
14186  @c @starindex  @ignore
14187    @starindex
14188    @end ignore
14189  @tindex bar  @tindex bar
14190  @c @starindex  @ignore
14191    @starindex
14192    @end ignore
14193  @tindex breve  @tindex breve
14194  @c @starindex  @ignore
14195    @starindex
14196    @end ignore
14197  @tindex check  @tindex check
14198  @c @starindex  @ignore
14199    @starindex
14200    @end ignore
14201  @tindex dot  @tindex dot
14202  @c @starindex  @ignore
14203    @starindex
14204    @end ignore
14205  @tindex dotdot  @tindex dotdot
14206  @c @starindex  @ignore
14207    @starindex
14208    @end ignore
14209  @tindex dyad  @tindex dyad
14210  @c @starindex  @ignore
14211    @starindex
14212    @end ignore
14213  @tindex grave  @tindex grave
14214  @c @starindex  @ignore
14215    @starindex
14216    @end ignore
14217  @tindex hat  @tindex hat
14218  @c @starindex  @ignore
14219    @starindex
14220    @end ignore
14221  @tindex Prime  @tindex Prime
14222  @c @starindex  @ignore
14223    @starindex
14224    @end ignore
14225  @tindex tilde  @tindex tilde
14226  @c @starindex  @ignore
14227    @starindex
14228    @end ignore
14229  @tindex under  @tindex under
14230  @c @starindex  @ignore
14231    @starindex
14232    @end ignore
14233  @tindex Vec  @tindex Vec
14234  @iftex  @iftex
14235  @endgroup  @endgroup
# Line 14294  end of this section. Line 14299  end of this section.
14299  @iftex  @iftex
14300  Here are some examples of how various Calc formulas are formatted in @TeX{}:  Here are some examples of how various Calc formulas are formatted in @TeX{}:
14301    
 @group  
14302  @example  @example
14303    @group
14304  sin(a^2 / b_i)  sin(a^2 / b_i)
14305  \sin\left( {a^2 \over b_i} \right)  \sin\left( {a^2 \over b_i} \right)
14306    @end group
14307  @end example  @end example
14308  @tex  @tex
14309  \let\rm\goodrm  \let\rm\goodrm
14310  $$ \sin\left( a^2 \over b_i \right) $$  $$ \sin\left( a^2 \over b_i \right) $$
14311  @end tex  @end tex
14312  @sp 1  @sp 1
 @end group  
14313    
 @group  
14314  @example  @example
14315    @group
14316  [(3, 4), 3:4, 3 +/- 4, [3 .. inf)]  [(3, 4), 3:4, 3 +/- 4, [3 .. inf)]
14317  [3 + 4i, @{3 \over 4@}, 3 \pm 4, [3 \ldots \infty)]  [3 + 4i, @{3 \over 4@}, 3 \pm 4, [3 \ldots \infty)]
14318    @end group
14319  @end example  @end example
14320  @tex  @tex
14321  \turnoffactive  \turnoffactive
14322  $$ [3 + 4i, {3 \over 4}, 3 \pm 4, [ 3 \ldots \infty)] $$  $$ [3 + 4i, {3 \over 4}, 3 \pm 4, [ 3 \ldots \infty)] $$
14323  @end tex  @end tex
14324  @sp 1  @sp 1
 @end group  
14325    
 @group  
14326  @example  @example
14327    @group
14328  [abs(a), abs(a / b), floor(a), ceil(a / b)]  [abs(a), abs(a / b), floor(a), ceil(a / b)]
14329  [|a|, \left| a \over b \right|,  [|a|, \left| a \over b \right|,
14330   \lfloor a \rfloor, \left\lceil a \over b \right\rceil]   \lfloor a \rfloor, \left\lceil a \over b \right\rceil]
14331    @end group
14332  @end example  @end example
14333  @tex  @tex
14334  $$ [|a|, \left| a \over b \right|,  $$ [|a|, \left| a \over b \right|,
14335      \lfloor a \rfloor, \left\lceil a \over b \right\rceil] $$      \lfloor a \rfloor, \left\lceil a \over b \right\rceil] $$
14336  @end tex  @end tex
14337  @sp 1  @sp 1
 @end group  
14338    
 @group  
14339  @example  @example
14340    @group
14341  [sin(a), sin(2 a), sin(2 + a), sin(a / b)]  [sin(a), sin(2 a), sin(2 + a), sin(a / b)]
14342  [\sin@{a@}, \sin@{2 a@}, \sin(2 + a),  [\sin@{a@}, \sin@{2 a@}, \sin(2 + a),
14343   \sin\left( @{a \over b@} \right)]   \sin\left( @{a \over b@} \right)]
14344    @end group
14345  @end example  @end example
14346  @tex  @tex
14347  \turnoffactive\let\rm\goodrm  \turnoffactive\let\rm\goodrm
14348  $$ [\sin{a}, \sin{2 a}, \sin(2 + a), \sin\left( {a \over b} \right)] $$  $$ [\sin{a}, \sin{2 a}, \sin(2 + a), \sin\left( {a \over b} \right)] $$
14349  @end tex  @end tex
14350  @sp 2  @sp 2
 @end group  
14351    
 @group  
14352  First with plain @kbd{d T}, then with @kbd{C-u d T}, then finally with  First with plain @kbd{d T}, then with @kbd{C-u d T}, then finally with
14353  @kbd{C-u - d T} (using the example definition  @kbd{C-u - d T} (using the example definition
14354  @samp{\def\foo#1@{\tilde F(#1)@}}:  @samp{\def\foo#1@{\tilde F(#1)@}}:
14355    
14356  @example  @example
14357    @group
14358  [f(a), foo(bar), sin(pi)]  [f(a), foo(bar), sin(pi)]
14359  [f(a), foo(bar), \sin{\pi}]  [f(a), foo(bar), \sin{\pi}]
14360  [f(a), \hbox@{foo@}(\hbox@{bar@}), \sin@{\pi@}]  [f(a), \hbox@{foo@}(\hbox@{bar@}), \sin@{\pi@}]
14361  [f(a), \foo@{\hbox@{bar@}@}, \sin@{\pi@}]  [f(a), \foo@{\hbox@{bar@}@}, \sin@{\pi@}]
14362    @end group
14363  @end example  @end example
14364  @tex  @tex
14365  \let\rm\goodrm  \let\rm\goodrm
# Line 14363  $$ [f(a), \hbox{foo}(\hbox{bar}), \sin{\ Line 14368  $$ [f(a), \hbox{foo}(\hbox{bar}), \sin{\
14368  $$ [f(a), \tilde F(\hbox{bar}), \sin{\pi}] $$  $$ [f(a), \tilde F(\hbox{bar}), \sin{\pi}] $$
14369  @end tex  @end tex
14370  @sp 2  @sp 2
 @end group  
14371    
 @group  
14372  First with @samp{\def\evalto@{@}}, then with @samp{\def\evalto#1\to@{@}}:  First with @samp{\def\evalto@{@}}, then with @samp{\def\evalto#1\to@{@}}:
14373    
14374  @example  @example
14375    @group
14376  2 + 3 => 5  2 + 3 => 5
14377  \evalto 2 + 3 \to 5  \evalto 2 + 3 \to 5
14378    @end group
14379  @end example  @end example
14380  @tex  @tex
14381  \turnoffactive  \turnoffactive
# Line 14379  $$ 2 + 3 \to 5 $$ Line 14383  $$ 2 + 3 \to 5 $$
14383  $$ 5 $$  $$ 5 $$
14384  @end tex  @end tex
14385  @sp 2  @sp 2
 @end group  
14386    
 @group  
14387  First with standard @code{\to}, then with @samp{\let\to\Rightarrow}:  First with standard @code{\to}, then with @samp{\let\to\Rightarrow}:
14388    
14389  @example  @example
14390    @group
14391  [2 + 3 => 5, a / 2 => (b + c) / 2]  [2 + 3 => 5, a / 2 => (b + c) / 2]
14392  [@{2 + 3 \to 5@}, @{@{a \over 2@} \to @{b + c \over 2@}@}]  [@{2 + 3 \to 5@}, @{@{a \over 2@} \to @{b + c \over 2@}@}]
14393    @end group
14394  @end example  @end example
14395  @tex  @tex
14396  \turnoffactive  \turnoffactive
# Line 14396  $$ [{2 + 3 \to 5}, {{a \over 2} \to {b + Line 14399  $$ [{2 + 3 \to 5}, {{a \over 2} \to {b +
14399  $$ [{2 + 3 \to 5}, {{a \over 2} \to {b + c \over 2}}] $$}  $$ [{2 + 3 \to 5}, {{a \over 2} \to {b + c \over 2}}] $$}
14400  @end tex  @end tex
14401  @sp 2  @sp 2
 @end group  
14402    
 @group  
14403  Matrices normally, then changing @code{\matrix} to @code{\pmatrix}:  Matrices normally, then changing @code{\matrix} to @code{\pmatrix}:
14404    
14405  @example  @example
14406    @group
14407  [ [ a / b, 0 ], [ 0, 2^(x + 1) ] ]  [ [ a / b, 0 ], [ 0, 2^(x + 1) ] ]
14408  \matrix@{ @{a \over b@} & 0 \\ 0 & 2^@{(x + 1)@} @}  \matrix@{ @{a \over b@} & 0 \\ 0 & 2^@{(x + 1)@} @}
14409  \pmatrix@{ @{a \over b@} & 0 \\ 0 & 2^@{(x + 1)@} @}  \pmatrix@{ @{a \over b@} & 0 \\ 0 & 2^@{(x + 1)@} @}
14410    @end group
14411  @end example  @end example
14412  @tex  @tex
14413  \turnoffactive  \turnoffactive
# Line 14413  $$ \matrix{ {a \over b} & 0 \cr 0 & 2^{( Line 14415  $$ \matrix{ {a \over b} & 0 \cr 0 & 2^{(
14415  $$ \pmatrix{ {a \over b} & 0 \cr 0 & 2^{(x + 1)} } $$  $$ \pmatrix{ {a \over b} & 0 \cr 0 & 2^{(x + 1)} } $$
14416  @end tex  @end tex
14417  @sp 2  @sp 2
 @end group  
14418  @end iftex  @end iftex
14419    
14420  @node Eqn Language Mode, Mathematica Language Mode, TeX Language Mode, Language Modes  @node Eqn Language Mode, Mathematica Language Mode, TeX Language Mode, Language Modes
# Line 14602  to @TeX{}'s ``boxes.''  Each multi-line Line 14603  to @TeX{}'s ``boxes.''  Each multi-line
14603  decide how formulas should be positioned relative to one another.  decide how formulas should be positioned relative to one another.
14604  For example, in the Big mode formula  For example, in the Big mode formula
14605    
 @group  
14606  @example  @example
14607    @group
14608            2            2
14609       a + b       a + b
14610  17 + ------  17 + ------
14611         c         c
 @end example  
14612  @end group  @end group
14613    @end example
14614    
14615  @noindent  @noindent
14616  the second term of the sum is four lines tall and has line three as  the second term of the sum is four lines tall and has line three as
# Line 14669  but the unnatural form @samp{a + (b + c) Line 14670  but the unnatural form @samp{a + (b + c)
14670  Right-associative operators like @samp{^} format the lefthand argument  Right-associative operators like @samp{^} format the lefthand argument
14671  with one-higher precedence.  with one-higher precedence.
14672    
14673  @c @starindex  @ignore
14674    @starindex
14675    @end ignore
14676  @tindex cprec  @tindex cprec
14677  The @code{cprec} function formats an expression with an arbitrary  The @code{cprec} function formats an expression with an arbitrary
14678  precedence.  For example, @samp{cprec(abc, 185)} will combine into  precedence.  For example, @samp{cprec(abc, 185)} will combine into
# Line 14700  structure of formulas.  It will not brea Line 14703  structure of formulas.  It will not brea
14703  it can use an earlier break point from an ``outer'' formula instead.  it can use an earlier break point from an ``outer'' formula instead.
14704  For example, a vector of sums might be formatted as:  For example, a vector of sums might be formatted as:
14705    
 @group  
14706  @example  @example
14707    @group
14708  [ a + b + c, d + e + f,  [ a + b + c, d + e + f,
14709    g + h + i, j + k + l, m ]    g + h + i, j + k + l, m ]
 @end example  
14710  @end group  @end group
14711    @end example
14712    
14713  @noindent  @noindent
14714  If the @samp{m} can fit, then so, it seems, could the @samp{g}.  If the @samp{m} can fit, then so, it seems, could the @samp{g}.
# Line 14733  object. Line 14736  object.
14736  @subsubsection Horizontal Compositions  @subsubsection Horizontal Compositions
14737    
14738  @noindent  @noindent
14739  @c @starindex  @ignore
14740    @starindex
14741    @end ignore
14742  @tindex choriz  @tindex choriz
14743  The @code{choriz} function takes a vector of objects and composes  The @code{choriz} function takes a vector of objects and composes
14744  them horizontally.  For example, @samp{choriz([17, a b/c, d])} formats  them horizontally.  For example, @samp{choriz([17, a b/c, d])} formats
14745  as @w{@samp{17a b / cd}} in normal language mode, or as  as @w{@samp{17a b / cd}} in normal language mode, or as
14746    
 @group  
14747  @example  @example
14748    @group
14749    a b    a b
14750  17---d  17---d
14751     c     c
 @end example  
14752  @end group  @end group
14753    @end example
14754    
14755  @noindent  @noindent
14756  in Big language mode.  This is actually one case of the general  in Big language mode.  This is actually one case of the general
# Line 14775  baselines of the component compositions, Line 14780  baselines of the component compositions,
14780  @subsubsection Vertical Compositions  @subsubsection Vertical Compositions
14781    
14782  @noindent  @noindent
14783  @c @starindex  @ignore
14784    @starindex
14785    @end ignore
14786  @tindex cvert  @tindex cvert
14787  The @code{cvert} function makes a vertical composition.  Each  The @code{cvert} function makes a vertical composition.  Each
14788  component of the vector is centered in a column.  The baseline of  component of the vector is centered in a column.  The baseline of
# Line 14783  the result is by default the top line of Line 14790  the result is by default the top line of
14790  For example, @samp{f(cvert([a, bb, ccc]), cvert([a^2 + 1, b^2]))}  For example, @samp{f(cvert([a, bb, ccc]), cvert([a^2 + 1, b^2]))}
14791  formats in Big mode as  formats in Big mode as
14792    
 @group  
14793  @example  @example
14794    @group
14795  f( a ,  2    )  f( a ,  2    )
14796    bb   a  + 1    bb   a  + 1
14797    ccc     2    ccc     2
14798           b           b
 @end example  
14799  @end group  @end group
14800    @end example
14801    
14802  @c @starindex  @ignore
14803    @starindex
14804    @end ignore
14805  @tindex cbase  @tindex cbase
14806  There are several special composition functions that work only as  There are several special composition functions that work only as
14807  components of a vertical composition.  The @code{cbase} function  components of a vertical composition.  The @code{cbase} function
# Line 14801  will be the same as the baseline of what Line 14810  will be the same as the baseline of what
14810  in @code{cbase}.  Thus @samp{f(cvert([a, cbase(bb), ccc]),  in @code{cbase}.  Thus @samp{f(cvert([a, cbase(bb), ccc]),
14811  cvert([a^2 + 1, cbase(b^2)]))} displays as  cvert([a^2 + 1, cbase(b^2)]))} displays as
14812    
 @group  
14813  @example  @example
14814    @group
14815          2          2
14816         a  + 1         a  + 1
14817     a      2     a      2
14818  f(bb ,   b   )  f(bb ,   b   )
14819    ccc    ccc
 @end example  
14820  @end group  @end group
14821    @end example
14822    
14823  @c @starindex  @ignore
14824    @starindex
14825    @end ignore
14826  @tindex ctbase  @tindex ctbase
14827  @c @starindex  @ignore
14828    @starindex
14829    @end ignore
14830  @tindex cbbase  @tindex cbbase
14831  There are also @code{ctbase} and @code{cbbase} functions which  There are also @code{ctbase} and @code{cbbase} functions which
14832  make the baseline of the vertical composition equal to the top  make the baseline of the vertical composition equal to the top
# Line 14821  or bottom line (rather than the baseline Line 14834  or bottom line (rather than the baseline
14834  Thus @samp{cvert([cbase(a / b)]) + cvert([ctbase(a / b)]) +  Thus @samp{cvert([cbase(a / b)]) + cvert([ctbase(a / b)]) +
14835  cvert([cbbase(a / b)])} gives  cvert([cbbase(a / b)])} gives
14836    
 @group  
14837  @example  @example
14838    @group
14839          a          a
14840  a       -  a       -
14841  - + a + b  - + a + b
14842  b   -  b   -
14843      b      b
 @end example  
14844  @end group  @end group
14845    @end example
14846    
14847  There should be only one @code{cbase}, @code{ctbase}, or @code{cbbase}  There should be only one @code{cbase}, @code{ctbase}, or @code{cbbase}
14848  function in a given vertical composition.  These functions can also  function in a given vertical composition.  These functions can also
# Line 14838  which means the baseline is the top line Line 14851  which means the baseline is the top line
14851  @samp{cbbase()} means the baseline is the bottom line of the preceding  @samp{cbbase()} means the baseline is the bottom line of the preceding
14852  item.  item.
14853    
14854  @c @starindex  @ignore
14855    @starindex
14856    @end ignore
14857  @tindex crule  @tindex crule
14858  The @code{crule} function builds a ``rule,'' or horizontal line,  The @code{crule} function builds a ``rule,'' or horizontal line,
14859  across a vertical composition.  By itself @samp{crule()} uses @samp{-}  across a vertical composition.  By itself @samp{crule()} uses @samp{-}
# Line 14848  vector of exactly one character code.  I Line 14863  vector of exactly one character code.  I
14863  width of the widest item in the stack.  For example, a quotient  width of the widest item in the stack.  For example, a quotient
14864  with a thick line is @samp{cvert([a + 1, cbase(crule("=")), b^2])}:  with a thick line is @samp{cvert([a + 1, cbase(crule("=")), b^2])}:
14865    
 @group  
14866  @example  @example
14867    @group
14868  a + 1  a + 1
14869  =====  =====
14870    2    2
14871   b   b
 @end example  
14872  @end group  @end group
14873    @end example
14874    
14875  @c @starindex  @ignore
14876    @starindex
14877    @end ignore
14878  @tindex clvert  @tindex clvert
14879  @c @starindex  @ignore
14880    @starindex
14881    @end ignore
14882  @tindex crvert  @tindex crvert
14883  Finally, the functions @code{clvert} and @code{crvert} act exactly  Finally, the functions @code{clvert} and @code{crvert} act exactly
14884  like @code{cvert} except that the items are left- or right-justified  like @code{cvert} except that the items are left- or right-justified
14885  in the stack.  Thus @samp{clvert([a, bb, ccc]) + crvert([a, bb, ccc])}  in the stack.  Thus @samp{clvert([a, bb, ccc]) + crvert([a, bb, ccc])}
14886  gives:  gives:
14887    
 @group  
14888  @example  @example
14889    @group
14890  a   +   a  a   +   a
14891  bb     bb  bb     bb
14892  ccc   ccc  ccc   ccc
 @end example  
14893  @end group  @end group
14894    @end example
14895    
14896  Like @code{choriz}, the vertical compositions accept a second argument  Like @code{choriz}, the vertical compositions accept a second argument
14897  which gives the precedence to use when formatting the components.  which gives the precedence to use when formatting the components.
# Line 14882  Vertical compositions do not support sep Line 14901  Vertical compositions do not support sep
14901  @subsubsection Other Compositions  @subsubsection Other Compositions
14902    
14903  @noindent  @noindent
14904  @c @starindex  @ignore
14905    @starindex
14906    @end ignore
14907  @tindex csup  @tindex csup
14908  The @code{csup} function builds a superscripted expression.  For  The @code{csup} function builds a superscripted expression.  For
14909  example, @samp{csup(a, b)} looks the same as @samp{a^b} does in Big  example, @samp{csup(a, b)} looks the same as @samp{a^b} does in Big
# Line 14890  language mode.  This is essentially a ho Line 14911  language mode.  This is essentially a ho
14911  @samp{a} and @samp{b}, where @samp{b} is shifted up so that its  @samp{a} and @samp{b}, where @samp{b} is shifted up so that its
14912  bottom line is one above the baseline.  bottom line is one above the baseline.
14913    
14914  @c @starindex  @ignore
14915    @starindex
14916    @end ignore
14917  @tindex csub  @tindex csub
14918  Likewise, the @code{csub} function builds a subscripted expression.  Likewise, the @code{csub} function builds a subscripted expression.
14919  This shifts @samp{b} down so that its top line is one below the  This shifts @samp{b} down so that its top line is one below the
# Line 14898  bottom line of @samp{a} (note that this Line 14921  bottom line of @samp{a} (note that this
14921  @code{csup}).  Other arrangements can be obtained by using  @code{csup}).  Other arrangements can be obtained by using
14922  @code{choriz} and @code{cvert} directly.  @code{choriz} and @code{cvert} directly.
14923    
14924  @c @starindex  @ignore
14925    @starindex
14926    @end ignore
14927  @tindex cflat  @tindex cflat
14928  The @code{cflat} function formats its argument in ``flat'' mode,  The @code{cflat} function formats its argument in ``flat'' mode,
14929  as obtained by @samp{d O}, if the current language mode is normal  as obtained by @samp{d O}, if the current language mode is normal
# Line 14906  or Big.  It has no effect in other langu Line 14931  or Big.  It has no effect in other langu
14931  @samp{a^(b/c)} is formatted by Big mode like @samp{csup(a, cflat(b/c))}  @samp{a^(b/c)} is formatted by Big mode like @samp{csup(a, cflat(b/c))}
14932  to improve its readability.  to improve its readability.
14933    
14934  @c @starindex  @ignore
14935    @starindex
14936    @end ignore
14937  @tindex cspace  @tindex cspace
14938  The @code{cspace} function creates horizontal space.  For example,  The @code{cspace} function creates horizontal space.  For example,
14939  @samp{cspace(4)} is effectively the same as @samp{string("    ")}.  @samp{cspace(4)} is effectively the same as @samp{string("    ")}.
# Line 14916  looks like @samp{abababab}.  If the seco Line 14943  looks like @samp{abababab}.  If the seco
14943  it is formatted in the normal way and then several copies of that  it is formatted in the normal way and then several copies of that
14944  are composed together:  @samp{cspace(4, a^2)} yields  are composed together:  @samp{cspace(4, a^2)} yields
14945    
 @group  
14946  @example  @example
14947    @group
14948   2 2 2 2   2 2 2 2
14949  a a a a  a a a a
 @end example  
14950  @end group  @end group
14951    @end example
14952    
14953  @noindent  @noindent
14954  If the number argument is zero, this is a zero-width object.  If the number argument is zero, this is a zero-width object.
14955    
14956  @c @starindex  @ignore
14957    @starindex
14958    @end ignore
14959  @tindex cvspace  @tindex cvspace
14960  The @code{cvspace} function creates vertical space, or a vertical  The @code{cvspace} function creates vertical space, or a vertical
14961  stack of copies of a certain string or formatted object.  The  stack of copies of a certain string or formatted object.  The
# Line 14934  baseline is the center line of the resul Line 14963  baseline is the center line of the resul
14963  argument of zero will produce an object which contributes zero  argument of zero will produce an object which contributes zero
14964  height if used in a vertical composition.  height if used in a vertical composition.
14965    
14966  @c @starindex  @ignore
14967    @starindex
14968    @end ignore
14969  @tindex ctspace  @tindex ctspace
14970  @c @starindex  @ignore
14971    @starindex
14972    @end ignore
14973  @tindex cbspace  @tindex cbspace
14974  There are also @code{ctspace} and @code{cbspace} functions which  There are also @code{ctspace} and @code{cbspace} functions which
14975  create vertical space with the baseline the same as the baseline  create vertical space with the baseline the same as the baseline
# Line 14944  of the top or bottom copy, respectively, Line 14977  of the top or bottom copy, respectively,
14977  Thus @samp{cvspace(2, a/b) + ctspace(2, a/b) + cbspace(2, a/b)}  Thus @samp{cvspace(2, a/b) + ctspace(2, a/b) + cbspace(2, a/b)}
14978  displays as:  displays as:
14979    
 @group  
14980  @example  @example
14981    @group
14982          a          a
14983          -          -
14984  a       b  a       b
# Line 14955  a   b   b Line 14988  a   b   b
14988  -   a  -   a
14989  b   -  b   -
14990      b      b
 @end example  
14991  @end group  @end group
14992    @end example
14993    
14994  @node Information about Compositions, User-Defined Compositions, Other Compositions, Compositions  @node Information about Compositions, User-Defined Compositions, Other Compositions, Compositions
14995  @subsubsection Information about Compositions  @subsubsection Information about Compositions
# Line 14966  The functions in this section are actual Line 14999  The functions in this section are actual
14999  arguments according to the current language and other display modes,  arguments according to the current language and other display modes,
15000  then return a certain measurement of the composition as an integer.  then return a certain measurement of the composition as an integer.
15001    
15002  @c @starindex  @ignore
15003    @starindex
15004    @end ignore
15005  @tindex cwidth  @tindex cwidth
15006  The @code{cwidth} function measures the width, in characters, of a  The @code{cwidth} function measures the width, in characters, of a
15007  composition.  For example, @samp{cwidth(a + b)} is 5, and  composition.  For example, @samp{cwidth(a + b)} is 5, and
# Line 14974  composition.  For example, @samp{cwidth( Line 15009  composition.  For example, @samp{cwidth(
15009  @TeX{} mode (for @samp{@{a \over b@}}).  The argument may involve  @TeX{} mode (for @samp{@{a \over b@}}).  The argument may involve
15010  the composition functions described in this section.  the composition functions described in this section.
15011    
15012  @c @starindex  @ignore
15013    @starindex
15014    @end ignore
15015  @tindex cheight  @tindex cheight
15016  The @code{cheight} function measures the height of a composition.  The @code{cheight} function measures the height of a composition.
15017  This is the total number of lines in the argument's printed form.  This is the total number of lines in the argument's printed form.
15018    
15019  @c @starindex  @ignore
15020    @starindex
15021    @end ignore
15022  @tindex cascent  @tindex cascent
15023  @c @starindex  @ignore
15024    @starindex
15025    @end ignore
15026  @tindex cdescent  @tindex cdescent
15027  The functions @code{cascent} and @code{cdescent} measure the amount  The functions @code{cascent} and @code{cdescent} measure the amount
15028  of the height that is above (and including) the baseline, or below  of the height that is above (and including) the baseline, or below
# Line 15031  mode will be removed.  The function will Line 15072  mode will be removed.  The function will
15072  For example, the default format for the binomial coefficient function  For example, the default format for the binomial coefficient function
15073  @samp{choose(n, m)} in the Big language mode is  @samp{choose(n, m)} in the Big language mode is
15074    
 @group  
15075  @example  @example
15076    @group
15077   n   n
15078  ( )  ( )
15079   m   m
 @end example  
15080  @end group  @end group
15081    @end example
15082    
15083  @noindent  @noindent
15084  You might prefer the notation,  You might prefer the notation,
15085    
 @group  
15086  @example  @example
15087    @group
15088   C   C
15089  n m  n m
 @end example  
15090  @end group  @end group
15091    @end example
15092    
15093  @noindent  @noindent
15094  To define this notation, first make sure you are in Big mode,  To define this notation, first make sure you are in Big mode,
# Line 15065  of @samp{(C m n)}.  Edit this list to be Line 15106  of @samp{(C m n)}.  Edit this list to be
15106  off with @kbd{m O} and enter @samp{choose(a,b) + choose(7,3)}  off with @kbd{m O} and enter @samp{choose(a,b) + choose(7,3)}
15107  as an algebraic entry.  as an algebraic entry.
15108    
 @group  
15109  @example  @example
15110    @group
15111   C  +  C   C  +  C
15112  a b   7 3  a b   7 3
 @end example  
15113  @end group  @end group
15114    @end example
15115    
15116  As another example, let's define the usual notation for Stirling  As another example, let's define the usual notation for Stirling
15117  numbers of the first kind, @samp{stir1(n, m)}.  This is just like  numbers of the first kind, @samp{stir1(n, m)}.  This is just like
# Line 15386  foo ( @{ @{ # @}*, @}*; ) := matrix(#1) Line 15427  foo ( @{ @{ # @}*, @}*; ) := matrix(#1)
15427  @end example  @end example
15428    
15429  @noindent  @noindent
15430  will parse @samp{foo(1,2,3,4)} as @samp{bar([1,2,3,4])}, and  will parse @samp{foo(1, 2, 3, 4)} as @samp{bar([1, 2, 3, 4])}, and
15431  @samp{foo(1,2;3,4)} as @samp{matrix([[1,2],[3,4]])}.  Also, after  @samp{foo(1, 2; 3, 4)} as @samp{matrix([[1, 2], [3, 4]])}.  Also, after
15432  some thought it's easy to see how this pair of rules will parse  some thought it's easy to see how this pair of rules will parse
15433  @samp{foo(1,2,3)} as @samp{matrix([[1,2,3]])}, since the first  @samp{foo(1, 2, 3)} as @samp{matrix([[1, 2, 3]])}, since the first
15434  rule will only match an even number of arguments.  The rule  rule will only match an even number of arguments.  The rule
15435    
15436  @example  @example
# Line 15417  empty vector is produced. Line 15458  empty vector is produced.
15458  Another variant is @samp{@{ ... @}?$}, which means the body is  Another variant is @samp{@{ ... @}?$}, which means the body is
15459  optional only at the end of the input formula.  All built-in syntax  optional only at the end of the input formula.  All built-in syntax
15460  rules in Calc use this for closing delimiters, so that during  rules in Calc use this for closing delimiters, so that during
15461  algebraic entry you can type @kbd{[sqrt(2), sqrt(3 RET}, omitting  algebraic entry you can type @kbd{[sqrt(2), sqrt(3 @key{RET}}, omitting
15462  the closing parenthesis and bracket.  Calc does this automatically  the closing parenthesis and bracket.  Calc does this automatically
15463  for trailing @samp{)}, @samp{]}, and @samp{>} tokens in syntax  for trailing @samp{)}, @samp{]}, and @samp{>} tokens in syntax
15464  rules, but you can use @samp{@{ ... @}?$} explicitly to get  rules, but you can use @samp{@{ ... @}?$} explicitly to get
# Line 15546  on the current mode settings. Line 15587  on the current mode settings.
15587  @cindex @code{Modes} variable  @cindex @code{Modes} variable
15588  @vindex Modes  @vindex Modes
15589  The modes vector is also available in the special variable  The modes vector is also available in the special variable
15590  @code{Modes}.  In other words, @kbd{m g} is like @kbd{s r Modes RET}.  @code{Modes}.  In other words, @kbd{m g} is like @kbd{s r Modes @key{RET}}.
15591  It will not work to store into this variable; in fact, if you do,  It will not work to store into this variable; in fact, if you do,
15592  @code{Modes} will cease to track the current modes.  (The @kbd{m g}  @code{Modes} will cease to track the current modes.  (The @kbd{m g}
15593  command will continue to work, however.)  command will continue to work, however.)
# Line 15600  Command is @kbd{m p}. Line 15641  Command is @kbd{m p}.
15641    
15642  @item  @item
15643  Matrix/scalar mode.  Default value is @i{-1}.  Value is 0 for scalar  Matrix/scalar mode.  Default value is @i{-1}.  Value is 0 for scalar
15644  mode, @i{-2} for matrix mode, or @i{N} for @c{$N\times N$}  mode, @i{-2} for matrix mode, or @var{N} for @c{$N\times N$}
15645  @i{NxN} matrix mode.  Command is @kbd{m v}.  @var{N}x@var{N} matrix mode.  Command is @kbd{m v}.
15646    
15647  @item  @item
15648  Simplification mode.  Default is 1.  Value is @i{-1} for off (@kbd{m O}),  Simplification mode.  Default is 1.  Value is @i{-1} for off (@kbd{m O}),
# Line 15613  Infinite mode.  Default is @i{-1} (off). Line 15654  Infinite mode.  Default is @i{-1} (off).
15654  or 0 if the mode is on with positive zeros.  Command is @kbd{m i}.  or 0 if the mode is on with positive zeros.  Command is @kbd{m i}.
15655  @end enumerate  @end enumerate
15656    
15657  For example, the sequence @kbd{M-1 m g RET 2 + ~ p} increases the  For example, the sequence @kbd{M-1 m g @key{RET} 2 + ~ p} increases the
15658  precision by two, leaving a copy of the old precision on the stack.  precision by two, leaving a copy of the old precision on the stack.
15659  Later, @kbd{~ p} will restore the original precision using that  Later, @kbd{~ p} will restore the original precision using that
15660  stack value.  (This sequence might be especially useful inside a  stack value.  (This sequence might be especially useful inside a
15661  keyboard macro.)  keyboard macro.)
15662    
15663  As another example, @kbd{M-3 m g 1 - ~ DEL} deletes all but the  As another example, @kbd{M-3 m g 1 - ~ @key{DEL}} deletes all but the
15664  oldest (bottommost) stack entry.  oldest (bottommost) stack entry.
15665    
15666  Yet another example:  The HP-48 ``round'' command rounds a number  Yet another example:  The HP-48 ``round'' command rounds a number
# Line 15878  interpret a prefix argument. Line 15919  interpret a prefix argument.
15919  @noindent  @noindent
15920  @kindex +  @kindex +
15921  @pindex calc-plus  @pindex calc-plus
15922  @c @mindex @null  @ignore
15923    @mindex @null
15924    @end ignore
15925  @tindex +  @tindex +
15926  The @kbd{+} (@code{calc-plus}) command adds two numbers.  The numbers may  The @kbd{+} (@code{calc-plus}) command adds two numbers.  The numbers may
15927  be any of the standard Calc data types.  The resulting sum is pushed back  be any of the standard Calc data types.  The resulting sum is pushed back
# Line 15942  infinite in different directions the res Line 15985  infinite in different directions the res
15985    
15986  @kindex -  @kindex -
15987  @pindex calc-minus  @pindex calc-minus
15988  @c @mindex @null  @ignore
15989    @mindex @null
15990    @end ignore
15991  @tindex -  @tindex -
15992  The @kbd{-} (@code{calc-minus}) command subtracts two values.  The top  The @kbd{-} (@code{calc-minus}) command subtracts two values.  The top
15993  number on the stack is subtracted from the one behind it, so that the  number on the stack is subtracted from the one behind it, so that the
# Line 15951  available for @kbd{+} are available for Line 15996  available for @kbd{+} are available for
15996    
15997  @kindex *  @kindex *
15998  @pindex calc-times  @pindex calc-times
15999  @c @mindex @null  @ignore
16000    @mindex @null
16001    @end ignore
16002  @tindex *  @tindex *
16003  The @kbd{*} (@code{calc-times}) command multiplies two numbers.  If one  The @kbd{*} (@code{calc-times}) command multiplies two numbers.  If one
16004  argument is a vector and the other a scalar, the scalar is multiplied by  argument is a vector and the other a scalar, the scalar is multiplied by
# Line 15974  whereas @w{@samp{[-2 ..@: 3] ^ 2}} is @s Line 16021  whereas @w{@samp{[-2 ..@: 3] ^ 2}} is @s
16021    
16022  @kindex /  @kindex /
16023  @pindex calc-divide  @pindex calc-divide
16024  @c @mindex @null  @ignore
16025    @mindex @null
16026    @end ignore
16027  @tindex /  @tindex /
16028  The @kbd{/} (@code{calc-divide}) command divides two numbers.  When  The @kbd{/} (@code{calc-divide}) command divides two numbers.  When
16029  dividing a scalar @cite{B} by a square matrix @cite{A}, the computation  dividing a scalar @cite{B} by a square matrix @cite{A}, the computation
# Line 16000  interval. Line 16049  interval.
16049    
16050  @kindex ^  @kindex ^
16051  @pindex calc-power  @pindex calc-power
16052  @c @mindex @null  @ignore
16053    @mindex @null
16054    @end ignore
16055  @tindex ^  @tindex ^
16056  The @kbd{^} (@code{calc-power}) command raises a number to a power.  If  The @kbd{^} (@code{calc-power}) command raises a number to a power.  If
16057  the power is an integer, an exact result is computed using repeated  the power is an integer, an exact result is computed using repeated
# Line 16012  the result is also an error (or interval Line 16063  the result is also an error (or interval
16063  @kindex I ^  @kindex I ^
16064  @tindex nroot  @tindex nroot
16065  If you press the @kbd{I} (inverse) key first, the @kbd{I ^} command  If you press the @kbd{I} (inverse) key first, the @kbd{I ^} command
16066  computes an Nth root:  @kbd{125 RET 3 I ^} computes the number 5.  computes an Nth root:  @kbd{125 @key{RET} 3 I ^} computes the number 5.
16067  (This is entirely equivalent to @kbd{125 RET 1:3 ^}.)  (This is entirely equivalent to @kbd{125 @key{RET} 1:3 ^}.)
16068    
16069  @kindex \  @kindex \
16070  @pindex calc-idiv  @pindex calc-idiv
16071  @tindex idiv  @tindex idiv
16072  @c @mindex @null  @ignore
16073    @mindex @null
16074    @end ignore
16075  @tindex \  @tindex \
16076  The @kbd{\} (@code{calc-idiv}) command divides two numbers on the stack  The @kbd{\} (@code{calc-idiv}) command divides two numbers on the stack
16077  to produce an integer result.  It is equivalent to dividing with  to produce an integer result.  It is equivalent to dividing with
# Line 16029  operation when the arguments are integer Line 16082  operation when the arguments are integer
16082    
16083  @kindex %  @kindex %
16084  @pindex calc-mod  @pindex calc-mod
16085  @c @mindex @null  @ignore
16086    @mindex @null
16087    @end ignore
16088  @tindex %  @tindex %
16089  The @kbd{%} (@code{calc-mod}) command performs a ``modulo'' (or ``remainder'')  The @kbd{%} (@code{calc-mod}) command performs a ``modulo'' (or ``remainder'')
16090  operation.  Mathematically, @samp{a%b = a - (a\b)*b}, and is defined  operation.  Mathematically, @samp{a%b = a - (a\b)*b}, and is defined
# Line 16207  expressed as an integer-valued floating- Line 16262  expressed as an integer-valued floating-
16262  @pindex calc-floor  @pindex calc-floor
16263  @tindex floor  @tindex floor
16264  @tindex ffloor  @tindex ffloor
16265  @c @mindex @null  @ignore
16266    @mindex @null
16267    @end ignore
16268  @kindex H F  @kindex H F
16269  The @kbd{F} (@code{calc-floor}) [@code{floor} or @code{ffloor}] command  The @kbd{F} (@code{calc-floor}) [@code{floor} or @code{ffloor}] command
16270  truncates a real number to the next lower integer, i.e., toward minus  truncates a real number to the next lower integer, i.e., toward minus
# Line 16218  infinity.  Thus @kbd{3.6 F} produces 3, Line 16275  infinity.  Thus @kbd{3.6 F} produces 3,
16275  @pindex calc-ceiling  @pindex calc-ceiling
16276  @tindex ceil  @tindex ceil
16277  @tindex fceil  @tindex fceil
16278  @c @mindex @null  @ignore
16279    @mindex @null
16280    @end ignore
16281  @kindex H I F  @kindex H I F
16282  The @kbd{I F} (@code{calc-ceiling}) [@code{ceil} or @code{fceil}]  The @kbd{I F} (@code{calc-ceiling}) [@code{ceil} or @code{fceil}]
16283  command truncates toward positive infinity.  Thus @kbd{3.6 I F} produces  command truncates toward positive infinity.  Thus @kbd{3.6 I F} produces
# Line 16228  command truncates toward positive infini Line 16287  command truncates toward positive infini
16287  @pindex calc-round  @pindex calc-round
16288  @tindex round  @tindex round
16289  @tindex fround  @tindex fround
16290  @c @mindex @null  @ignore
16291    @mindex @null
16292    @end ignore
16293  @kindex H R  @kindex H R
16294  The @kbd{R} (@code{calc-round}) [@code{round} or @code{fround}] command  The @kbd{R} (@code{calc-round}) [@code{round} or @code{fround}] command
16295  rounds to the nearest integer.  When the fractional part is .5 exactly,  rounds to the nearest integer.  When the fractional part is .5 exactly,
# Line 16240  but @kbd{3.4 R} produces 3; @kbd{_3.5 R} Line 16301  but @kbd{3.4 R} produces 3; @kbd{_3.5 R}
16301  @pindex calc-trunc  @pindex calc-trunc
16302  @tindex trunc  @tindex trunc
16303  @tindex ftrunc  @tindex ftrunc
16304  @c @mindex @null  @ignore
16305    @mindex @null
16306    @end ignore
16307  @kindex H I R  @kindex H I R
16308  The @kbd{I R} (@code{calc-trunc}) [@code{trunc} or @code{ftrunc}]  The @kbd{I R} (@code{calc-trunc}) [@code{trunc} or @code{ftrunc}]
16309  command truncates toward zero.  In other words, it ``chops off''  command truncates toward zero.  In other words, it ``chops off''
# Line 16254  these functions operate on all elements Line 16317  these functions operate on all elements
16317  Applied to a date form, they operate on the internal numerical  Applied to a date form, they operate on the internal numerical
16318  representation of dates, converting a date/time form into a pure date.  representation of dates, converting a date/time form into a pure date.
16319    
16320  @c @starindex  @ignore
16321    @starindex
16322    @end ignore
16323  @tindex rounde  @tindex rounde
16324  @c @starindex  @ignore
16325    @starindex
16326    @end ignore
16327  @tindex roundu  @tindex roundu
16328  @c @starindex  @ignore
16329    @starindex
16330    @end ignore
16331  @tindex frounde  @tindex frounde
16332  @c @starindex  @ignore
16333    @starindex
16334    @end ignore
16335  @tindex froundu  @tindex froundu
16336  There are two more rounding functions which can only be entered in  There are two more rounding functions which can only be entered in
16337  algebraic notation.  The @code{roundu} function is like @code{round}  algebraic notation.  The @code{roundu} function is like @code{round}
# Line 16288  no second argument at all. Line 16359  no second argument at all.
16359    
16360  @cindex Fractional part of a number  @cindex Fractional part of a number
16361  To compute the fractional part of a number (i.e., the amount which, when  To compute the fractional part of a number (i.e., the amount which, when
16362  added to `@t{floor(}@i{N}@t{)}', will produce @cite{N}) just take @cite{N}  added to `@t{floor(}@var{n}@t{)}', will produce @var{n}) just take @var{n}
16363  modulo 1 using the @code{%} command.@refill  modulo 1 using the @code{%} command.@refill
16364    
16365  Note also the @kbd{\} (integer quotient), @kbd{f I} (integer logarithm),  Note also the @kbd{\} (integer quotient), @kbd{f I} (integer logarithm),
# Line 16315  this command replaces each element by it Line 16386  this command replaces each element by it
16386  The @kbd{G} (@code{calc-argument}) [@code{arg}] command computes the  The @kbd{G} (@code{calc-argument}) [@code{arg}] command computes the
16387  ``argument'' or polar angle of a complex number.  For a number in polar  ``argument'' or polar angle of a complex number.  For a number in polar
16388  notation, this is simply the second component of the pair  notation, this is simply the second component of the pair
16389  `@t{(}@i{r}@t{;}@c{$\theta$}  `@t{(}@var{r}@t{;}@c{$\theta$}
16390  @i{theta}@t{)}'.  @var{theta}@t{)}'.
16391  The result is expressed according to the current angular mode and will  The result is expressed according to the current angular mode and will
16392  be in the range @i{-180} degrees (exclusive) to @i{+180} degrees  be in the range @i{-180} degrees (exclusive) to @i{+180} degrees
16393  (inclusive), or the equivalent range in radians.@refill  (inclusive), or the equivalent range in radians.@refill
# Line 16342  The @kbd{f i} (@code{calc-im}) [@code{im Line 16413  The @kbd{f i} (@code{calc-im}) [@code{im
16413  by its imaginary part; real numbers are converted to zero.  With a vector  by its imaginary part; real numbers are converted to zero.  With a vector
16414  or matrix argument, these functions operate element-wise.@refill  or matrix argument, these functions operate element-wise.@refill
16415    
16416  @c @mindex v p  @ignore
16417    @mindex v p
16418    @end ignore
16419  @kindex v p (complex)  @kindex v p (complex)
16420  @pindex calc-pack  @pindex calc-pack
16421  The @kbd{v p} (@code{calc-pack}) command can pack the top two numbers on  The @kbd{v p} (@code{calc-pack}) command can pack the top two numbers on
# Line 16351  a prefix argument of @i{-1}, it produces Line 16424  a prefix argument of @i{-1}, it produces
16424  with an argument of @i{-2}, it produces a polar complex number.  with an argument of @i{-2}, it produces a polar complex number.
16425  (Also, @pxref{Building Vectors}.)  (Also, @pxref{Building Vectors}.)
16426    
16427  @c @mindex v u  @ignore
16428    @mindex v u
16429    @end ignore
16430  @kindex v u (complex)  @kindex v u (complex)
16431  @pindex calc-unpack  @pindex calc-unpack
16432  The @kbd{v u} (@code{calc-unpack}) command takes the complex number  The @kbd{v u} (@code{calc-unpack}) command takes the complex number
# Line 16617  The @kbd{t U} (@code{calc-unix-time}) [@ Line 16692  The @kbd{t U} (@code{calc-unix-time}) [@
16692  converts a date form into a Unix time value, which is the number of  converts a date form into a Unix time value, which is the number of
16693  seconds since midnight on Jan 1, 1970, or vice-versa.  The numeric result  seconds since midnight on Jan 1, 1970, or vice-versa.  The numeric result
16694  will be an integer if the current precision is 12 or less; for higher  will be an integer if the current precision is 12 or less; for higher
16695  precisions, the result may be a float with (@var{precision}@i{-}12)  precisions, the result may be a float with (@var{precision}@minus{}12)
16696  digits after the decimal.  Just as for @kbd{t J}, the numeric time  digits after the decimal.  Just as for @kbd{t J}, the numeric time
16697  is interpreted in the GMT time zone and the date form is interpreted  is interpreted in the GMT time zone and the date form is interpreted
16698  in the current or specified zone.  Some systems use Unix-like  in the current or specified zone.  Some systems use Unix-like
# Line 16751  to preserve the time-of-day portion of t Line 16826  to preserve the time-of-day portion of t
16826  the time to midnight; hint:@: how can @code{newweek} be defined in terms  the time to midnight; hint:@: how can @code{newweek} be defined in terms
16827  of the @code{weekday} function?).  of the @code{weekday} function?).
16828    
16829  @c @starindex  @ignore
16830    @starindex
16831    @end ignore
16832  @tindex pwday  @tindex pwday
16833  The @samp{pwday(@var{date})} function (not on any key) computes the  The @samp{pwday(@var{date})} function (not on any key) computes the
16834  day-of-month number of the Sunday on or before @var{date}.  With  day-of-month number of the Sunday on or before @var{date}.  With
# Line 16779  Because of this, @kbd{t I t I} and @kbd{ Line 16856  Because of this, @kbd{t I t I} and @kbd{
16856  the same results (@samp{<Mar 28, 1991>} versus @samp{<Mar 31, 1991>}  the same results (@samp{<Mar 28, 1991>} versus @samp{<Mar 31, 1991>}
16857  in this case).  in this case).
16858    
16859  @c @starindex  @ignore
16860    @starindex
16861    @end ignore
16862  @tindex incyear  @tindex incyear
16863  The @samp{incyear(@var{date}, @var{step})} function increases  The @samp{incyear(@var{date}, @var{step})} function increases
16864  a date form by the specified number of years, which may be  a date form by the specified number of years, which may be
# Line 16931  completely consistent though; a subtract Line 17010  completely consistent though; a subtract
17010  might come out a bit differently, since @kbd{t +} is incapable of  might come out a bit differently, since @kbd{t +} is incapable of
17011  producing a date that falls on a weekend or holiday.)  producing a date that falls on a weekend or holiday.)
17012    
17013  @c @starindex  @ignore
17014    @starindex
17015    @end ignore
17016  @tindex holiday  @tindex holiday
17017  There is a @code{holiday} function, not on any keys, that takes  There is a @code{holiday} function, not on any keys, that takes
17018  any date form and returns 1 if that date falls on a weekend or  any date form and returns 1 if that date falls on a weekend or
# Line 16970  computes the actual number of 24-hour pe Line 17051  computes the actual number of 24-hour pe
17051  days between two dates without taking daylight savings into account.  days between two dates without taking daylight savings into account.
17052    
17053  @pindex calc-time-zone  @pindex calc-time-zone
17054  @c @starindex  @ignore
17055    @starindex
17056    @end ignore
17057  @tindex tzone  @tindex tzone
17058  The @code{calc-time-zone} [@code{tzone}] command converts the time  The @code{calc-time-zone} [@code{tzone}] command converts the time
17059  zone specified by its numeric prefix argument into a number of  zone specified by its numeric prefix argument into a number of
# Line 16995  note that for each time zone there is on Line 17078  note that for each time zone there is on
17078  another for daylight savings time, and a third for ``generalized'' time  another for daylight savings time, and a third for ``generalized'' time
17079  in which the daylight savings adjustment is computed from context.  in which the daylight savings adjustment is computed from context.
17080    
 @group  
17081  @smallexample  @smallexample
17082    @group
17083  YST  PST  MST  CST  EST  AST    NST    GMT   WET     MET    MEZ  YST  PST  MST  CST  EST  AST    NST    GMT   WET     MET    MEZ
17084   9    8    7    6    5    4     3.5     0     -1      -2     -2   9    8    7    6    5    4     3.5     0     -1      -2     -2
17085    
# Line 17005  YDT  PDT  MDT  CDT  EDT  ADT    NDT    B Line 17088  YDT  PDT  MDT  CDT  EDT  ADT    NDT    B
17088    
17089  YGT  PGT  MGT  CGT  EGT  AGT    NGT    BGT   WEGT    MEGT   MEGZ  YGT  PGT  MGT  CGT  EGT  AGT    NGT    BGT   WEGT    MEGT   MEGZ
17090  9/8  8/7  7/6  6/5  5/4  4/3  3.5/2.5  0/-1 -1/-2   -2/-3  -2/-3  9/8  8/7  7/6  6/5  5/4  4/3  3.5/2.5  0/-1 -1/-2   -2/-3  -2/-3
 @end smallexample  
17091  @end group  @end group
17092    @end smallexample
17093    
17094  @vindex math-tzone-names  @vindex math-tzone-names
17095  To define time zone names that do not appear in the above table,  To define time zone names that do not appear in the above table,
# Line 17015  is a list of lists describing the differ Line 17098  is a list of lists describing the differ
17098  structure is best explained by an example.  The three entries for  structure is best explained by an example.  The three entries for
17099  Pacific Time look like this:  Pacific Time look like this:
17100    
 @group  
17101  @smallexample  @smallexample
17102    @group
17103  ( ( "PST" 8 0 )    ; Name as an upper-case string, then standard  ( ( "PST" 8 0 )    ; Name as an upper-case string, then standard
17104    ( "PDT" 8 -1 )   ; adjustment, then daylight savings adjustment.    ( "PDT" 8 -1 )   ; adjustment, then daylight savings adjustment.
17105    ( "PGT" 8 "PST" "PDT" ) )   ; Generalized time zone.    ( "PGT" 8 "PST" "PDT" ) )   ; Generalized time zone.
 @end smallexample  
17106  @end group  @end group
17107    @end smallexample
17108    
17109  @cindex @code{TimeZone} variable  @cindex @code{TimeZone} variable
17110  @vindex TimeZone  @vindex TimeZone
# Line 17163  that the daylight-savings computation is Line 17246  that the daylight-savings computation is
17246  local time, not in the GMT time that a numeric @var{date}  local time, not in the GMT time that a numeric @var{date}
17247  is typically represented in.  is typically represented in.
17248    
17249  @c @starindex  @ignore
17250    @starindex
17251    @end ignore
17252  @tindex dsadj  @tindex dsadj
17253  The @samp{dsadj(@var{date}, @var{zone})} function computes the  The @samp{dsadj(@var{date}, @var{zone})} function computes the
17254  daylight savings adjustment that is appropriate for @var{date} in  daylight savings adjustment that is appropriate for @var{date} in
# Line 17239  but the number @samp{5.4} is probably @e Line 17324  but the number @samp{5.4} is probably @e
17324  represents a rate of 540 percent!  represents a rate of 540 percent!
17325    
17326  The key sequence @kbd{M-% *} effectively means ``percent-of.''  The key sequence @kbd{M-% *} effectively means ``percent-of.''
17327  For example, @kbd{68 RET 25 M-% *} computes 17, which is 25% of  For example, @kbd{68 @key{RET} 25 M-% *} computes 17, which is 25% of
17328  68 (and also 68% of 25, which comes out to the same thing).  68 (and also 68% of 25, which comes out to the same thing).
17329    
17330  @kindex c %  @kindex c %
# Line 17253  this number to @samp{0.08%}.)  The @kbd{ Line 17338  this number to @samp{0.08%}.)  The @kbd{
17338  to convert a formula like @samp{8%} back to numeric form, 0.08.  to convert a formula like @samp{8%} back to numeric form, 0.08.
17339    
17340  To compute what percentage one quantity is of another quantity,  To compute what percentage one quantity is of another quantity,
17341  use @kbd{/ c %}.  For example, @w{@kbd{17 RET 68 / c %}} displays  use @kbd{/ c %}.  For example, @w{@kbd{17 @key{RET} 68 / c %}} displays
17342  @samp{25%}.  @samp{25%}.
17343    
17344  @kindex b %  @kindex b %
# Line 17261  use @kbd{/ c %}.  For example, @w{@kbd{1 Line 17346  use @kbd{/ c %}.  For example, @w{@kbd{1
17346  @tindex relch  @tindex relch
17347  The @kbd{b %} (@code{calc-percent-change}) [@code{relch}] command  The @kbd{b %} (@code{calc-percent-change}) [@code{relch}] command
17348  calculates the percentage change from one number to another.  calculates the percentage change from one number to another.
17349  For example, @kbd{40 RET 50 b %} produces the answer @samp{25%},  For example, @kbd{40 @key{RET} 50 b %} produces the answer @samp{25%},
17350  since 50 is 25% larger than 40.  A negative result represents a  since 50 is 25% larger than 40.  A negative result represents a
17351  decrease:  @kbd{50 RET 40 b %} produces @samp{-20%}, since 40 is  decrease:  @kbd{50 @key{RET} 40 b %} produces @samp{-20%}, since 40 is
17352  20% smaller than 50.  (The answers are different in magnitude  20% smaller than 50.  (The answers are different in magnitude
17353  because, in the first case, we're increasing by 25% of 40, but  because, in the first case, we're increasing by 25% of 40, but
17354  in the second case, we're decreasing by 20% of 50.)  The effect  in the second case, we're decreasing by 20% of 50.)  The effect
17355  of @kbd{40 RET 50 b %} is to compute @cite{(50-40)/40}, converting  of @kbd{40 @key{RET} 50 b %} is to compute @cite{(50-40)/40}, converting
17356  the answer to percentage form as if by @kbd{c %}.  the answer to percentage form as if by @kbd{c %}.
17357    
17358  @node Future Value, Present Value, Percentages, Financial Functions  @node Future Value, Present Value, Percentages, Financial Functions
# Line 17297  earning 5.4% interest, starting right no Line 17382  earning 5.4% interest, starting right no
17382  in the account after five years?  @code{fvb(5.4%, 5, 1000) = 5870.73}.  in the account after five years?  @code{fvb(5.4%, 5, 1000) = 5870.73}.
17383  Thus you will have earned $870 worth of interest over the years.  Thus you will have earned $870 worth of interest over the years.
17384  Using the stack, this calculation would have been  Using the stack, this calculation would have been
17385  @kbd{5.4 M-% 5 RET 1000 I b F}.  Note that the rate is expressed  @kbd{5.4 M-% 5 @key{RET} 1000 I b F}.  Note that the rate is expressed
17386  as a number between 0 and 1, @emph{not} as a percentage.  as a number between 0 and 1, @emph{not} as a percentage.
17387    
17388  @kindex H b F  @kindex H b F
# Line 17552  return value will as usual be zero if @v Line 17637  return value will as usual be zero if @v
17637    
17638  For example, pushing the vector @cite{[1,2,3,4,5]} (perhaps with @kbd{v x 5})  For example, pushing the vector @cite{[1,2,3,4,5]} (perhaps with @kbd{v x 5})
17639  and then mapping @kbd{V M ' [sln(12000,2000,5,$), syd(12000,2000,5,$),  and then mapping @kbd{V M ' [sln(12000,2000,5,$), syd(12000,2000,5,$),
17640  ddb(12000,2000,5,$)] RET} produces a matrix that allows us to compare  ddb(12000,2000,5,$)] @key{RET}} produces a matrix that allows us to compare
17641  the three depreciation methods:  the three depreciation methods:
17642    
 @group  
17643  @example  @example
17644    @group
17645  [ [ 2000, 3333, 4800 ]  [ [ 2000, 3333, 4800 ]
17646    [ 2000, 2667, 2880 ]    [ 2000, 2667, 2880 ]
17647    [ 2000, 2000, 1728 ]    [ 2000, 2000, 1728 ]
17648    [ 2000, 1333,  592 ]    [ 2000, 1333,  592 ]
17649    [ 2000,  667,   0  ] ]    [ 2000,  667,   0  ] ]
 @end example  
17650  @end group  @end group
17651    @end example
17652    
17653  @noindent  @noindent
17654  (Values have been rounded to nearest integers in this figure.)  (Values have been rounded to nearest integers in this figure.)
# Line 17850  Bits shifted ``off the end,'' according Line 17935  Bits shifted ``off the end,'' according
17935    
17936  @kindex H b l  @kindex H b l
17937  @kindex H b r  @kindex H b r
17938  @c @mindex @idots  @ignore
17939    @mindex @idots
17940    @end ignore
17941  @kindex H b L  @kindex H b L
17942  @c @mindex @null  @ignore
17943    @mindex @null
17944    @end ignore
17945  @kindex H b R  @kindex H b R
17946  @c @mindex @null  @ignore
17947    @mindex @null
17948    @end ignore
17949  @kindex H b t  @kindex H b t
17950  The @kbd{H b l} command also does a left shift, but it takes two arguments  The @kbd{H b l} command also does a left shift, but it takes two arguments
17951  from the stack (the value to shift, and, at top-of-stack, the number of  from the stack (the value to shift, and, at top-of-stack, the number of
# Line 17906  bits in a binary integer. Line 17997  bits in a binary integer.
17997    
17998  Another interesting use of the set representation of binary integers  Another interesting use of the set representation of binary integers
17999  is to reverse the bits in, say, a 32-bit integer.  Type @kbd{b u} to  is to reverse the bits in, say, a 32-bit integer.  Type @kbd{b u} to
18000  unpack; type @kbd{31 TAB -} to replace each bit-number in the set  unpack; type @kbd{31 @key{TAB} -} to replace each bit-number in the set
18001  with 31 minus that bit-number; type @kbd{b p} to pack the set back  with 31 minus that bit-number; type @kbd{b p} to pack the set back
18002  into a binary integer.  into a binary integer.
18003    
# Line 17948  In Symbolic mode, these commands push th Line 18039  In Symbolic mode, these commands push th
18039  actual variables @samp{pi}, @samp{e}, @samp{gamma}, and @samp{phi},  actual variables @samp{pi}, @samp{e}, @samp{gamma}, and @samp{phi},
18040  respectively, instead of their values; @pxref{Symbolic Mode}.@refill  respectively, instead of their values; @pxref{Symbolic Mode}.@refill
18041    
18042  @c @mindex Q  @ignore
18043  @c @mindex I Q  @mindex Q
18044    @end ignore
18045    @ignore
18046    @mindex I Q
18047    @end ignore
18048  @kindex I Q  @kindex I Q
18049  @tindex sqr  @tindex sqr
18050  The @kbd{Q} (@code{calc-sqrt}) [@code{sqrt}] function is described elsewhere;  The @kbd{Q} (@code{calc-sqrt}) [@code{sqrt}] function is described elsewhere;
# Line 17977  interpret a prefix argument. Line 18072  interpret a prefix argument.
18072  @kindex L  @kindex L
18073  @pindex calc-ln  @pindex calc-ln
18074  @tindex ln  @tindex ln
18075  @c @mindex @null  @ignore
18076    @mindex @null
18077    @end ignore
18078  @kindex I E  @kindex I E
18079  The shift-@kbd{L} (@code{calc-ln}) [@code{ln}] command computes the natural  The shift-@kbd{L} (@code{calc-ln}) [@code{ln}] command computes the natural
18080  logarithm of the real or complex number on the top of the stack.  With  logarithm of the real or complex number on the top of the stack.  With
# Line 17987  this is redundant with the @kbd{E} comma Line 18084  this is redundant with the @kbd{E} comma
18084  @kindex E  @kindex E
18085  @pindex calc-exp  @pindex calc-exp
18086  @tindex exp  @tindex exp
18087  @c @mindex @null  @ignore
18088    @mindex @null
18089    @end ignore
18090  @kindex I L  @kindex I L
18091  The shift-@kbd{E} (@code{calc-exp}) [@code{exp}] command computes the  The shift-@kbd{E} (@code{calc-exp}) [@code{exp}] command computes the
18092  exponential, i.e., @cite{e} raised to the power of the number on the stack.  exponential, i.e., @cite{e} raised to the power of the number on the stack.
# Line 17999  the @code{calc-ln} command. Line 18098  the @code{calc-ln} command.
18098  @pindex calc-log10  @pindex calc-log10
18099  @tindex log10  @tindex log10
18100  @tindex exp10  @tindex exp10
18101  @c @mindex @null  @ignore
18102    @mindex @null
18103    @end ignore
18104  @kindex H I L  @kindex H I L
18105  @c @mindex @null  @ignore
18106    @mindex @null
18107    @end ignore
18108  @kindex H I E  @kindex H I E
18109  The @kbd{H L} (@code{calc-log10}) [@code{log10}] command computes the common  The @kbd{H L} (@code{calc-log10}) [@code{log10}] command computes the common
18110  (base-10) logarithm of a number.  (With the Inverse flag [@code{exp10}],  (base-10) logarithm of a number.  (With the Inverse flag [@code{exp10}],
# Line 18113  Hyperbolic and Inverse flags, it compute Line 18216  Hyperbolic and Inverse flags, it compute
18216  @kindex C  @kindex C
18217  @pindex calc-cos  @pindex calc-cos
18218  @tindex cos  @tindex cos
18219  @c @mindex @idots  @ignore
18220    @mindex @idots
18221    @end ignore
18222  @kindex I C  @kindex I C
18223  @pindex calc-arccos  @pindex calc-arccos
18224  @c @mindex @null  @ignore
18225    @mindex @null
18226    @end ignore
18227  @tindex arccos  @tindex arccos
18228  @c @mindex @null  @ignore
18229    @mindex @null
18230    @end ignore
18231  @kindex H C  @kindex H C
18232  @pindex calc-cosh  @pindex calc-cosh
18233  @c @mindex @null  @ignore
18234    @mindex @null
18235    @end ignore
18236  @tindex cosh  @tindex cosh
18237  @c @mindex @null  @ignore
18238    @mindex @null
18239    @end ignore
18240  @kindex H I C  @kindex H I C
18241  @pindex calc-arccosh  @pindex calc-arccosh
18242  @c @mindex @null  @ignore
18243    @mindex @null
18244    @end ignore
18245  @tindex arccosh  @tindex arccosh
18246  @c @mindex @null  @ignore
18247    @mindex @null
18248    @end ignore
18249  @kindex T  @kindex T
18250  @pindex calc-tan  @pindex calc-tan
18251  @c @mindex @null  @ignore
18252    @mindex @null
18253    @end ignore
18254  @tindex tan  @tindex tan
18255  @c @mindex @null  @ignore
18256    @mindex @null
18257    @end ignore
18258  @kindex I T  @kindex I T
18259  @pindex calc-arctan  @pindex calc-arctan
18260  @c @mindex @null  @ignore
18261    @mindex @null
18262    @end ignore
18263  @tindex arctan  @tindex arctan
18264  @c @mindex @null  @ignore
18265    @mindex @null
18266    @end ignore
18267  @kindex H T  @kindex H T
18268  @pindex calc-tanh  @pindex calc-tanh
18269  @c @mindex @null  @ignore
18270    @mindex @null
18271    @end ignore
18272  @tindex tanh  @tindex tanh
18273  @c @mindex @null  @ignore
18274    @mindex @null
18275    @end ignore
18276  @kindex H I T  @kindex H I T
18277  @pindex calc-arctanh  @pindex calc-arctanh
18278  @c @mindex @null  @ignore
18279    @mindex @null
18280    @end ignore
18281  @tindex arctanh  @tindex arctanh
18282  The shift-@kbd{C} (@code{calc-cos}) [@code{cos}] command computes the cosine  The shift-@kbd{C} (@code{calc-cos}) [@code{cos}] command computes the cosine
18283  of an angle or complex number, and shift-@kbd{T} (@code{calc-tan}) [@code{tan}]  of an angle or complex number, and shift-@kbd{T} (@code{calc-tan}) [@code{tan}]
# Line 18168  which @code{arctan2} would avoid.  By (a Line 18299  which @code{arctan2} would avoid.  By (a
18299  @samp{arctan2(0,0)=0}.  @samp{arctan2(0,0)=0}.
18300    
18301  @pindex calc-sincos  @pindex calc-sincos
18302  @c @starindex  @ignore
18303    @starindex
18304    @end ignore
18305  @tindex sincos  @tindex sincos
18306  @c @starindex  @ignore
18307  @c @mindex arc@idots  @starindex
18308    @end ignore
18309    @ignore
18310    @mindex arc@idots
18311    @end ignore
18312  @tindex arcsincos  @tindex arcsincos
18313  The @code{calc-sincos} [@code{sincos}] command computes the sine and  The @code{calc-sincos} [@code{sincos}] command computes the sine and
18314  cosine of a number, returning them as a vector of the form  cosine of a number, returning them as a vector of the form
# Line 18209  integral:  @c{$\Gamma(a) = \int_0^\infty Line 18346  integral:  @c{$\Gamma(a) = \int_0^\infty
18346    
18347  @kindex f G  @kindex f G
18348  @tindex gammaP  @tindex gammaP
18349  @c @mindex @idots  @ignore
18350    @mindex @idots
18351    @end ignore
18352  @kindex I f G  @kindex I f G
18353  @c @mindex @null  @ignore
18354    @mindex @null
18355    @end ignore
18356  @kindex H f G  @kindex H f G
18357  @c @mindex @null  @ignore
18358    @mindex @null
18359    @end ignore
18360  @kindex H I f G  @kindex H I f G
18361  @pindex calc-inc-gamma  @pindex calc-inc-gamma
18362  @c @mindex @null  @ignore
18363    @mindex @null
18364    @end ignore
18365  @tindex gammaQ  @tindex gammaQ
18366  @c @mindex @null  @ignore
18367    @mindex @null
18368    @end ignore
18369  @tindex gammag  @tindex gammag
18370  @c @mindex @null  @ignore
18371    @mindex @null
18372    @end ignore
18373  @tindex gammaG  @tindex gammaG
18374  The @kbd{f G} (@code{calc-inc-gamma}) [@code{gammaP}] command computes  The @kbd{f G} (@code{calc-inc-gamma}) [@code{gammaP}] command computes
18375  the incomplete gamma function, denoted @samp{P(a,x)}.  This is defined by  the incomplete gamma function, denoted @samp{P(a,x)}.  This is defined by
# Line 18481  of one.  The algorithm used generates ra Line 18630  of one.  The algorithm used generates ra
18630  every other call to this function will be especially fast.  every other call to this function will be especially fast.
18631    
18632  If @cite{M} is an error form @c{$m$ @code{+/-} $\sigma$}  If @cite{M} is an error form @c{$m$ @code{+/-} $\sigma$}
18633  @samp{m +/- s} where @i{m}  @samp{m +/- s} where @var{m}
18634  and @c{$\sigma$}  and @c{$\sigma$}
18635  @i{s} are both real numbers, the result uses a Gaussian  @var{s} are both real numbers, the result uses a Gaussian
18636  distribution with mean @i{m} and standard deviation @c{$\sigma$}  distribution with mean @var{m} and standard deviation @c{$\sigma$}
18637  @i{s}.  @var{s}.
18638    
18639  If @cite{M} is an interval form, the lower and upper bounds specify the  If @cite{M} is an interval form, the lower and upper bounds specify the
18640  acceptable limits of the random numbers.  If both bounds are integers,  acceptable limits of the random numbers.  If both bounds are integers,
# Line 18695  the GCD of two integers @cite{x} and @ci Line 18844  the GCD of two integers @cite{x} and @ci
18844  @kindex !  @kindex !
18845  @pindex calc-factorial  @pindex calc-factorial
18846  @tindex fact  @tindex fact
18847  @c @mindex @null  @ignore
18848    @mindex @null
18849    @end ignore
18850  @tindex !  @tindex !
18851  The @kbd{!} (@code{calc-factorial}) [@code{fact}] command computes the  The @kbd{!} (@code{calc-factorial}) [@code{fact}] command computes the
18852  factorial of the number at the top of the stack.  If the number is an  factorial of the number at the top of the stack.  If the number is an
# Line 18710  the commands in this section.@refill Line 18861  the commands in this section.@refill
18861  @kindex k d  @kindex k d
18862  @pindex calc-double-factorial  @pindex calc-double-factorial
18863  @tindex dfact  @tindex dfact
18864  @c @mindex @null  @ignore
18865    @mindex @null
18866    @end ignore
18867  @tindex !!  @tindex !!
18868  The @kbd{k d} (@code{calc-double-factorial}) [@code{dfact}] command  The @kbd{k d} (@code{calc-double-factorial}) [@code{dfact}] command
18869  computes the ``double factorial'' of an integer.  For an even integer,  computes the ``double factorial'' of an integer.  For an even integer,
# Line 18796  even a single iteration is quite reliabl Line 18949  even a single iteration is quite reliabl
18949  the number will be reported as definitely prime or non-prime if possible,  the number will be reported as definitely prime or non-prime if possible,
18950  or otherwise ``probably'' prime with a certain probability of error.  or otherwise ``probably'' prime with a certain probability of error.
18951    
18952  @c @starindex  @ignore
18953    @starindex
18954    @end ignore
18955  @tindex prime  @tindex prime
18956  The normal @kbd{k p} command performs one iteration of the primality  The normal @kbd{k p} command performs one iteration of the primality
18957  test.  Pressing @kbd{k p} repeatedly for the same integer will perform  test.  Pressing @kbd{k p} repeatedly for the same integer will perform
# Line 18820  element of the list will be @i{-1}.  For Line 18975  element of the list will be @i{-1}.  For
18975    
18976  @kindex k n  @kindex k n
18977  @pindex calc-next-prime  @pindex calc-next-prime
18978  @c @mindex nextpr@idots  @ignore
18979    @mindex nextpr@idots
18980    @end ignore
18981  @tindex nextprime  @tindex nextprime
18982  The @kbd{k n} (@code{calc-next-prime}) [@code{nextprime}] command finds  The @kbd{k n} (@code{calc-next-prime}) [@code{nextprime}] command finds
18983  the next prime above a given number.  Essentially, it searches by calling  the next prime above a given number.  Essentially, it searches by calling
# Line 18836  prime. Line 18993  prime.
18993    
18994  @kindex I k n  @kindex I k n
18995  @pindex calc-prev-prime  @pindex calc-prev-prime
18996  @c @mindex prevpr@idots  @ignore
18997    @mindex prevpr@idots
18998    @end ignore
18999  @tindex prevprime  @tindex prevprime
19000  The @kbd{I k n} (@code{calc-prev-prime}) [@code{prevprime}] command  The @kbd{I k n} (@code{calc-prev-prime}) [@code{prevprime}] command
19001  analogously finds the next prime less than a given number.  analogously finds the next prime less than a given number.
# Line 18907  recover the original arguments but subst Line 19066  recover the original arguments but subst
19066  @kindex k C  @kindex k C
19067  @pindex calc-utpc  @pindex calc-utpc
19068  @tindex utpc  @tindex utpc
19069  @c @mindex @idots  @ignore
19070    @mindex @idots
19071    @end ignore
19072  @kindex I k C  @kindex I k C
19073  @c @mindex @null  @ignore
19074    @mindex @null
19075    @end ignore
19076  @tindex ltpc  @tindex ltpc
19077  The @samp{utpc(x,v)} function uses the chi-square distribution with  The @samp{utpc(x,v)} function uses the chi-square distribution with
19078  @c{$\nu$}  @c{$\nu$}
# Line 18919  correct if its chi-square statistic is @ Line 19082  correct if its chi-square statistic is @
19082  @kindex k F  @kindex k F
19083  @pindex calc-utpf  @pindex calc-utpf
19084  @tindex utpf  @tindex utpf
19085  @c @mindex @idots  @ignore
19086    @mindex @idots
19087    @end ignore
19088  @kindex I k F  @kindex I k F
19089  @c @mindex @null  @ignore
19090    @mindex @null
19091    @end ignore
19092  @tindex ltpf  @tindex ltpf
19093  The @samp{utpf(F,v1,v2)} function uses the F distribution, used in  The @samp{utpf(F,v1,v2)} function uses the F distribution, used in
19094  various statistical tests.  The parameters @c{$\nu_1$}  various statistical tests.  The parameters @c{$\nu_1$}
# Line 18933  respectively, used in computing the stat Line 19100  respectively, used in computing the stat
19100  @kindex k N  @kindex k N
19101  @pindex calc-utpn  @pindex calc-utpn
19102  @tindex utpn  @tindex utpn
19103  @c @mindex @idots  @ignore
19104    @mindex @idots
19105    @end ignore
19106  @kindex I k N  @kindex I k N
19107  @c @mindex @null  @ignore
19108    @mindex @null
19109    @end ignore
19110  @tindex ltpn  @tindex ltpn
19111  The @samp{utpn(x,m,s)} function uses a normal (Gaussian) distribution  The @samp{utpn(x,m,s)} function uses a normal (Gaussian) distribution
19112  with mean @cite{m} and standard deviation @c{$\sigma$}  with mean @cite{m} and standard deviation @c{$\sigma$}
# Line 18946  exceed @cite{x}. Line 19117  exceed @cite{x}.
19117  @kindex k P  @kindex k P
19118  @pindex calc-utpp  @pindex calc-utpp
19119  @tindex utpp  @tindex utpp
19120  @c @mindex @idots  @ignore
19121    @mindex @idots
19122    @end ignore
19123  @kindex I k P  @kindex I k P
19124  @c @mindex @null  @ignore
19125    @mindex @null
19126    @end ignore
19127  @tindex ltpp  @tindex ltpp
19128  The @samp{utpp(n,x)} function uses a Poisson distribution with  The @samp{utpp(n,x)} function uses a Poisson distribution with
19129  mean @cite{x}.  It is the probability that @cite{n} or more such  mean @cite{x}.  It is the probability that @cite{n} or more such
# Line 18957  Poisson random events will occur. Line 19132  Poisson random events will occur.
19132  @kindex k T  @kindex k T
19133  @pindex calc-ltpt  @pindex calc-ltpt
19134  @tindex utpt  @tindex utpt
19135  @c @mindex @idots  @ignore
19136    @mindex @idots
19137    @end ignore
19138  @kindex I k T  @kindex I k T
19139  @c @mindex @null  @ignore
19140    @mindex @null
19141    @end ignore
19142  @tindex ltpt  @tindex ltpt
19143  The @samp{utpt(t,v)} function uses the Student's ``t'' distribution  The @samp{utpt(t,v)} function uses the Student's ``t'' distribution
19144  with @c{$\nu$}  with @c{$\nu$}
# Line 19133  example, @samp{[2, 3, -4]} takes 12 obje Line 19312  example, @samp{[2, 3, -4]} takes 12 obje
19312  Also, @samp{[-4, -10]} will convert four integers into an  Also, @samp{[-4, -10]} will convert four integers into an
19313  error form consisting of two fractions:  @samp{a:b +/- c:d}.  error form consisting of two fractions:  @samp{a:b +/- c:d}.
19314    
19315  @c @starindex  @ignore
19316    @starindex
19317    @end ignore
19318  @tindex pack  @tindex pack
19319  There is an equivalent algebraic function,  There is an equivalent algebraic function,
19320  @samp{pack(@var{mode}, @var{items})} where @var{mode} is a  @samp{pack(@var{mode}, @var{items})} where @var{mode} is a
# Line 19192  re-packing mode will be a vector of leng Line 19373  re-packing mode will be a vector of leng
19373  to unpack a matrix, say, or a vector of error forms.  Higher  to unpack a matrix, say, or a vector of error forms.  Higher
19374  unpacking modes unpack the input even more deeply.  unpacking modes unpack the input even more deeply.
19375    
19376  @c @starindex  @ignore
19377    @starindex
19378    @end ignore
19379  @tindex unpack  @tindex unpack
19380  There are two algebraic functions analogous to @kbd{v u}.  There are two algebraic functions analogous to @kbd{v u}.
19381  The @samp{unpack(@var{mode}, @var{item})} function unpacks the  The @samp{unpack(@var{mode}, @var{item})} function unpacks the
# Line 19201  a vector of components.  Here the @var{m Line 19384  a vector of components.  Here the @var{m
19384  integer, not a vector.  For example, @samp{unpack(-4, a +/- b)}  integer, not a vector.  For example, @samp{unpack(-4, a +/- b)}
19385  returns @samp{[a, b]}, as does @samp{unpack(1, a +/- b)}.  returns @samp{[a, b]}, as does @samp{unpack(1, a +/- b)}.
19386    
19387  @c @starindex  @ignore
19388    @starindex
19389    @end ignore
19390  @tindex unpackt  @tindex unpackt
19391  The @code{unpackt} function is like @code{unpack} but instead  The @code{unpackt} function is like @code{unpack} but instead
19392  of returning a simple vector of items, it returns a vector of  of returning a simple vector of items, it returns a vector of
# Line 19227  subtracted, multiplied, and divided; @px Line 19412  subtracted, multiplied, and divided; @px
19412    
19413  @kindex |  @kindex |
19414  @pindex calc-concat  @pindex calc-concat
19415  @c @mindex @null  @ignore
19416    @mindex @null
19417    @end ignore
19418  @tindex |  @tindex |
19419  The @kbd{|} (@code{calc-concat}) command ``concatenates'' two vectors  The @kbd{|} (@code{calc-concat}) command ``concatenates'' two vectors
19420  into one.  For example, after @kbd{@w{[ 1 , 2 ]} [ 3 , 4 ] |}, the stack  into one.  For example, after @kbd{@w{[ 1 , 2 ]} [ 3 , 4 ] |}, the stack
# Line 19254  See also @code{cons} and @code{rcons} be Line 19441  See also @code{cons} and @code{rcons} be
19441  @kindex H I |  @kindex H I |
19442  The @kbd{I |} and @kbd{H I |} commands are similar, but they use their  The @kbd{I |} and @kbd{H I |} commands are similar, but they use their
19443  two stack arguments in the opposite order.  Thus @kbd{I |} is equivalent  two stack arguments in the opposite order.  Thus @kbd{I |} is equivalent
19444  to @kbd{TAB |}, but possibly more convenient and also a bit faster.  to @kbd{@key{TAB} |}, but possibly more convenient and also a bit faster.
19445    
19446  @kindex v d  @kindex v d
19447  @pindex calc-diag  @pindex calc-diag
# Line 19349  whereas @code{cons} will insert @var{h} Line 19536  whereas @code{cons} will insert @var{h}
19536    
19537  @kindex H v h  @kindex H v h
19538  @tindex rhead  @tindex rhead
19539  @c @mindex @idots  @ignore
19540    @mindex @idots
19541    @end ignore
19542  @kindex H I v h  @kindex H I v h
19543  @c @mindex @null  @ignore
19544    @mindex @null
19545    @end ignore
19546  @kindex H v k  @kindex H v k
19547  @c @mindex @null  @ignore
19548    @mindex @null
19549    @end ignore
19550  @tindex rtail  @tindex rtail
19551  @c @mindex @null  @ignore
19552    @mindex @null
19553    @end ignore
19554  @tindex rcons  @tindex rcons
19555  Each of these three functions also accepts the Hyperbolic flag [@code{rhead},  Each of these three functions also accepts the Hyperbolic flag [@code{rhead},
19556  @code{rtail}, @code{rcons}] in which case @var{t} instead represents  @code{rtail}, @code{rcons}] in which case @var{t} instead represents
# Line 19581  phone numbers will remain sorted by name Line 19776  phone numbers will remain sorted by name
19776  @cindex Histograms  @cindex Histograms
19777  @kindex V H  @kindex V H
19778  @pindex calc-histogram  @pindex calc-histogram
19779  @c @mindex histo@idots  @ignore
19780    @mindex histo@idots
19781    @end ignore
19782  @tindex histogram  @tindex histogram
19783  The @kbd{V H} (@code{calc-histogram}) [@code{histogram}] command builds a  The @kbd{V H} (@code{calc-histogram}) [@code{histogram}] command builds a
19784  histogram of a vector of numbers.  Vector elements are assumed to be  histogram of a vector of numbers.  Vector elements are assumed to be
# Line 19683  vectors or matrices: @code{change-sign}, Line 19880  vectors or matrices: @code{change-sign},
19880  The @kbd{V J} (@code{calc-conj-transpose}) [@code{ctrn}] command computes  The @kbd{V J} (@code{calc-conj-transpose}) [@code{ctrn}] command computes
19881  the conjugate transpose of its argument, i.e., @samp{conj(trn(x))}.  the conjugate transpose of its argument, i.e., @samp{conj(trn(x))}.
19882    
19883  @c @mindex A  @ignore
19884    @mindex A
19885    @end ignore
19886  @kindex A (vectors)  @kindex A (vectors)
19887  @pindex calc-abs (vectors)  @pindex calc-abs (vectors)
19888  @c @mindex abs  @ignore
19889    @mindex abs
19890    @end ignore
19891  @tindex abs (vectors)  @tindex abs (vectors)
19892  The @kbd{A} (@code{calc-abs}) [@code{abs}] command computes the  The @kbd{A} (@code{calc-abs}) [@code{abs}] command computes the
19893  Frobenius norm of a vector or matrix argument.  This is the square  Frobenius norm of a vector or matrix argument.  This is the square
# Line 19722  The @kbd{V C} (@code{calc-cross}) [@code Line 19923  The @kbd{V C} (@code{calc-cross}) [@code
19923  right-handed cross product of two vectors, each of which must have  right-handed cross product of two vectors, each of which must have
19924  exactly three elements.  exactly three elements.
19925    
19926  @c @mindex &  @ignore
19927    @mindex &
19928    @end ignore
19929  @kindex & (matrices)  @kindex & (matrices)
19930  @pindex calc-inv (matrices)  @pindex calc-inv (matrices)
19931  @c @mindex inv  @ignore
19932    @mindex inv
19933    @end ignore
19934  @tindex inv (matrices)  @tindex inv (matrices)
19935  The @kbd{&} (@code{calc-inv}) [@code{inv}] command computes the  The @kbd{&} (@code{calc-inv}) [@code{inv}] command computes the
19936  inverse of a square matrix.  If the matrix is singular, the inverse  inverse of a square matrix.  If the matrix is singular, the inverse
# Line 20068  has an infinite weight, next to which an Line 20273  has an infinite weight, next to which an
20273  weight is completely negligible.)  weight is completely negligible.)
20274    
20275  This function also works for distributions (error forms or  This function also works for distributions (error forms or
20276  intervals).  The mean of an error form `@i{a} @t{+/-} @i{b}' is simply  intervals).  The mean of an error form `@var{a} @t{+/-} @var{b}' is simply
20277  @cite{a}.  The mean of an interval is the mean of the minimum  @cite{a}.  The mean of an interval is the mean of the minimum
20278  and maximum values of the interval.  and maximum values of the interval.
20279    
# Line 20136  $$ { N \over \displaystyle \sum {1 \over Line 20341  $$ { N \over \displaystyle \sum {1 \over
20341  @cindex Geometric mean  @cindex Geometric mean
20342  The @kbd{u G} (@code{calc-vector-geometric-mean}) [@code{vgmean}]  The @kbd{u G} (@code{calc-vector-geometric-mean}) [@code{vgmean}]
20343  command computes the geometric mean of the data values.  This  command computes the geometric mean of the data values.  This
20344  is the @i{N}th root of the product of the values.  This is also  is the @var{n}th root of the product of the values.  This is also
20345  equal to the @code{exp} of the arithmetic mean of the logarithms  equal to the @code{exp} of the arithmetic mean of the logarithms
20346  of the data values.  of the data values.
20347  @tex  @tex
# Line 20223  is the square@c{ $\sigma^2$} Line 20428  is the square@c{ $\sigma^2$}
20428  squares of the deviations of the data values from the mean.  squares of the deviations of the data values from the mean.
20429  (This definition also applies when the argument is a distribution.)  (This definition also applies when the argument is a distribution.)
20430    
20431  @c @starindex  @ignore
20432    @starindex
20433    @end ignore
20434  @tindex vflat  @tindex vflat
20435  The @code{vflat} algebraic function returns a vector of its  The @code{vflat} algebraic function returns a vector of its
20436  arguments, interpreted in the same way as the other functions  arguments, interpreted in the same way as the other functions
# Line 20343  Calc will prompt for the number of argum Line 20550  Calc will prompt for the number of argum
20550  can't figure it out on its own (say, because you named a function that  can't figure it out on its own (say, because you named a function that
20551  is currently undefined).  It is also possible to type a digit key before  is currently undefined).  It is also possible to type a digit key before
20552  the function name to specify the number of arguments, e.g.,  the function name to specify the number of arguments, e.g.,
20553  @kbd{V M 3 x f RET} calls @code{f} with three arguments even if it  @kbd{V M 3 x f @key{RET}} calls @code{f} with three arguments even if it
20554  looks like it ought to have only two.  This technique may be necessary  looks like it ought to have only two.  This technique may be necessary
20555  if the function allows a variable number of arguments.  For example,  if the function allows a variable number of arguments.  For example,
20556  the @kbd{v e} [@code{vexp}] function accepts two or three arguments;  the @kbd{v e} [@code{vexp}] function accepts two or three arguments;
# Line 20381  which means ``a function of two argument Line 20588  which means ``a function of two argument
20588  argument minus the second argument.''  The symbols @samp{#1} and @samp{#2}  argument minus the second argument.''  The symbols @samp{#1} and @samp{#2}
20589  are placeholders for the arguments.  You can use any names for these  are placeholders for the arguments.  You can use any names for these
20590  placeholders if you wish, by including an argument list followed by a  placeholders if you wish, by including an argument list followed by a
20591  colon:  @samp{<x, y : x - y>}.  When you type @kbd{V A ' $$ + 2$^$$ RET},  colon:  @samp{<x, y : x - y>}.  When you type @kbd{V A ' $$ + 2$^$$ @key{RET}},
20592  Calc builds the nameless function @samp{<#1 + 2 #2^#1>} as the function  Calc builds the nameless function @samp{<#1 + 2 #2^#1>} as the function
20593  to map across the vectors.  When you type @kbd{V A ' x + 2y^x RET RET},  to map across the vectors.  When you type @kbd{V A ' x + 2y^x @key{RET} @key{RET}},
20594  Calc builds the nameless function @w{@samp{<x, y : x + 2 y^x>}}.  In both  Calc builds the nameless function @w{@samp{<x, y : x + 2 y^x>}}.  In both
20595  cases, Calc also writes the nameless function to the Trail so that you  cases, Calc also writes the nameless function to the Trail so that you
20596  can get it back later if you wish.  can get it back later if you wish.
# Line 20399  the stack and use it with @w{@kbd{V A $} Line 20606  the stack and use it with @w{@kbd{V A $}
20606  argument list in this case, since the nameless function specifies the  argument list in this case, since the nameless function specifies the
20607  argument list as well as the function itself.  In @kbd{V A '}, you can  argument list as well as the function itself.  In @kbd{V A '}, you can
20608  omit the @samp{< >} marks if you use @samp{#} notation for the arguments,  omit the @samp{< >} marks if you use @samp{#} notation for the arguments,
20609  so that @kbd{V A ' #1+#2 RET} is the same as @kbd{V A ' <#1+#2> RET},  so that @kbd{V A ' #1+#2 @key{RET}} is the same as @kbd{V A ' <#1+#2> @key{RET}},
20610  which in turn is the same as @kbd{V A ' $$+$ RET}.  which in turn is the same as @kbd{V A ' $$+$ @key{RET}}.
20611    
20612  @cindex Lambda expressions  @cindex Lambda expressions
20613  @c @starindex  @ignore
20614    @starindex
20615    @end ignore
20616  @tindex lambda  @tindex lambda
20617  The internal format for @samp{<x, y : x + y>} is @samp{lambda(x, y, x + y)}.  The internal format for @samp{<x, y : x + y>} is @samp{lambda(x, y, x + y)}.
20618  (The word @code{lambda} derives from Lisp notation and the theory of  (The word @code{lambda} derives from Lisp notation and the theory of
# Line 20420  called.) Line 20629  called.)
20629    
20630  @tindex add  @tindex add
20631  @tindex sub  @tindex sub
20632  @c @mindex @idots  @ignore
20633    @mindex @idots
20634    @end ignore
20635  @tindex mul  @tindex mul
20636  @c @mindex @null  @ignore
20637    @mindex @null
20638    @end ignore
20639  @tindex div  @tindex div
20640  @c @mindex @null  @ignore
20641    @mindex @null
20642    @end ignore
20643  @tindex pow  @tindex pow
20644  @c @mindex @null  @ignore
20645    @mindex @null
20646    @end ignore
20647  @tindex neg  @tindex neg
20648  @c @mindex @null  @ignore
20649    @mindex @null
20650    @end ignore
20651  @tindex mod  @tindex mod
20652  @c @mindex @null  @ignore
20653    @mindex @null
20654    @end ignore
20655  @tindex vconcat  @tindex vconcat
20656  As usual, commands like @kbd{V A} have algebraic function name equivalents.  As usual, commands like @kbd{V A} have algebraic function name equivalents.
20657  For example, @kbd{V A k g} with an argument of @samp{v} is equivalent to  For example, @kbd{V A k g} with an argument of @samp{v} is equivalent to
# Line 20441  written as algebraic symbols have the na Line 20662  written as algebraic symbols have the na
20662  @code{mul}, @code{div}, @code{pow}, @code{neg}, @code{mod}, and  @code{mul}, @code{div}, @code{pow}, @code{neg}, @code{mod}, and
20663  @code{vconcat}.@refill  @code{vconcat}.@refill
20664    
20665  @c @starindex  @ignore
20666    @starindex
20667    @end ignore
20668  @tindex call  @tindex call
20669  The @code{call} function builds a function call out of several arguments:  The @code{call} function builds a function call out of several arguments:
20670  @samp{call(gcd, x, y)} is the same as @samp{apply(gcd, [x, y])}, which  @samp{call(gcd, x, y)} is the same as @samp{apply(gcd, [x, y])}, which
# Line 20675  Newton's method for finding roots is a c Line 20898  Newton's method for finding roots is a c
20898  to a fixed point.  To find the square root of five starting with an  to a fixed point.  To find the square root of five starting with an
20899  initial guess, Newton's method would look for a fixed point of the  initial guess, Newton's method would look for a fixed point of the
20900  function @samp{(x + 5/x) / 2}.  Putting a guess of 1 on the stack  function @samp{(x + 5/x) / 2}.  Putting a guess of 1 on the stack
20901  and typing @kbd{H I V R ' ($ + 5/$)/2 RET} quickly yields the result  and typing @kbd{H I V R ' ($ + 5/$)/2 @key{RET}} quickly yields the result
20902  2.23607.  This is equivalent to using the @kbd{a R} (@code{calc-find-root})  2.23607.  This is equivalent to using the @kbd{a R} (@code{calc-find-root})
20903  command to find a root of the equation @samp{x^2 = 5}.  command to find a root of the equation @samp{x^2 = 5}.
20904    
# Line 20788  enables commas or semicolons at the ends Line 21011  enables commas or semicolons at the ends
21011  The default format is @samp{RO}.  (Before Calc 2.00, the format  The default format is @samp{RO}.  (Before Calc 2.00, the format
21012  was fixed at @samp{ROC}.)  Here are some example matrices:  was fixed at @samp{ROC}.)  Here are some example matrices:
21013    
 @group  
21014  @example  @example
21015    @group
21016  [ [ 123,  0,   0  ]       [ [ 123,  0,   0  ],  [ [ 123,  0,   0  ]       [ [ 123,  0,   0  ],
21017    [  0,  123,  0  ]         [  0,  123,  0  ],    [  0,  123,  0  ]         [  0,  123,  0  ],
21018    [  0,   0,  123 ] ]       [  0,   0,  123 ] ]    [  0,   0,  123 ] ]       [  0,   0,  123 ] ]
21019    
21020           RO                        ROC           RO                        ROC
21021    
 @end example  
21022  @end group  @end group
21023    @end example
21024  @noindent  @noindent
 @group  
21025  @example  @example
21026    @group
21027    [ 123,  0,   0            [ 123,  0,   0 ;    [ 123,  0,   0            [ 123,  0,   0 ;
21028       0,  123,  0               0,  123,  0 ;       0,  123,  0               0,  123,  0 ;
21029       0,   0,  123 ]            0,   0,  123 ]       0,   0,  123 ]            0,   0,  123 ]
21030    
21031            O                        OC            O                        OC
21032    
 @end example  
21033  @end group  @end group
21034    @end example
21035  @noindent  @noindent
 @group  
21036  @example  @example
21037    @group
21038    [ 123,  0,   0  ]           123,  0,   0    [ 123,  0,   0  ]           123,  0,   0
21039    [  0,  123,  0  ]            0,  123,  0    [  0,  123,  0  ]            0,  123,  0
21040    [  0,   0,  123 ]            0,   0,  123    [  0,   0,  123 ]            0,   0,  123
21041    
21042            R                       @r{blank}            R                       @r{blank}
 @end example  
21043  @end group  @end group
21044    @end example
21045    
21046  @noindent  @noindent
21047  Note that of the formats shown here, @samp{RO}, @samp{ROC}, and  Note that of the formats shown here, @samp{RO}, @samp{ROC}, and
# Line 20950  all of the rest of the formula with dots Line 21173  all of the rest of the formula with dots
21173  display mode but is perhaps easiest in ``big'' (@kbd{d B}) mode.  display mode but is perhaps easiest in ``big'' (@kbd{d B}) mode.
21174  Suppose you enter the following formula:  Suppose you enter the following formula:
21175    
 @group  
21176  @smallexample  @smallexample
21177    @group
21178             3    ___             3    ___
21179      (a + b)  + V c      (a + b)  + V c
21180  1:  ---------------  1:  ---------------
21181          2 x + 1          2 x + 1
 @end smallexample  
21182  @end group  @end group
21183    @end smallexample
21184    
21185  @noindent  @noindent
21186  (by typing @kbd{' ((a+b)^3 + sqrt(c)) / (2x+1)}).  If you move the  (by typing @kbd{' ((a+b)^3 + sqrt(c)) / (2x+1)}).  If you move the
21187  cursor to the letter @samp{b} and press @w{@kbd{j s}}, the display changes  cursor to the letter @samp{b} and press @w{@kbd{j s}}, the display changes
21188  to  to
21189    
 @group  
21190  @smallexample  @smallexample
21191    @group
21192             .    ...             .    ...
21193      .. . b.  . . .      .. . b.  . . .
21194  1*  ...............  1*  ...............
21195          . . . .          . . . .
 @end smallexample  
21196  @end group  @end group
21197    @end smallexample
21198    
21199  @noindent  @noindent
21200  Every character not part of the sub-formula @samp{b} has been changed  Every character not part of the sub-formula @samp{b} has been changed
# Line 20984  may not be visible.  @pxref{Embedded Mod Line 21207  may not be visible.  @pxref{Embedded Mod
21207  If you had instead placed the cursor on the parenthesis immediately to  If you had instead placed the cursor on the parenthesis immediately to
21208  the right of the @samp{b}, the selection would have been:  the right of the @samp{b}, the selection would have been:
21209    
 @group  
21210  @smallexample  @smallexample
21211    @group
21212             .    ...             .    ...
21213      (a + b)  . . .      (a + b)  . . .
21214  1*  ...............  1*  ...............
21215          . . . .          . . . .
 @end smallexample  
21216  @end group  @end group
21217    @end smallexample
21218    
21219  @noindent  @noindent
21220  The portion selected is always large enough to be considered a complete  The portion selected is always large enough to be considered a complete
# Line 21102  Once you have selected a sub-formula, yo Line 21325  Once you have selected a sub-formula, yo
21325  @w{@kbd{j m}} (@code{calc-select-more}) command.  If @samp{a + b} is  @w{@kbd{j m}} (@code{calc-select-more}) command.  If @samp{a + b} is
21326  selected, pressing @w{@kbd{j m}} repeatedly works as follows:  selected, pressing @w{@kbd{j m}} repeatedly works as follows:
21327    
 @group  
21328  @smallexample  @smallexample
21329    @group
21330             3    ...                3    ___                3    ___             3    ...                3    ___                3    ___
21331      (a + b)  . . .          (a + b)  + V c          (a + b)  + V c      (a + b)  . . .          (a + b)  + V c          (a + b)  + V c
21332  1*  ...............     1*  ...............     1*  ---------------  1*  ...............     1*  ...............     1*  ---------------
21333          . . . .                 . . . .                 2 x + 1          . . . .                 . . . .                 2 x + 1
 @end smallexample  
21334  @end group  @end group
21335    @end smallexample
21336    
21337  @noindent  @noindent
21338  In the last example, the entire formula is selected.  This is roughly  In the last example, the entire formula is selected.  This is roughly
# Line 21193  illustrated in the above examples; if we Line 21416  illustrated in the above examples; if we
21416  to the other style in which the selected portion itself is obscured  to the other style in which the selected portion itself is obscured
21417  by @samp{#} signs:  by @samp{#} signs:
21418    
 @group  
21419  @smallexample  @smallexample
21420    @group
21421             3    ...                  #    ___             3    ...                  #    ___
21422      (a + b)  . . .            ## # ##  + V c      (a + b)  . . .            ## # ##  + V c
21423  1*  ...............       1*  ---------------  1*  ...............       1*  ---------------
21424          . . . .                   2 x + 1          . . . .                   2 x + 1
 @end smallexample  
21425  @end group  @end group
21426    @end smallexample
21427    
21428  @node Operating on Selections, Rearranging with Selections, Displaying Selections, Selecting Subformulas  @node Operating on Selections, Rearranging with Selections, Displaying Selections, Selecting Subformulas
21429  @subsection Operating on Selections  @subsection Operating on Selections
# Line 21232  the top two stack elements; here it swap Line 21455  the top two stack elements; here it swap
21455  the selected portion of the formula, returning the old selected  the selected portion of the formula, returning the old selected
21456  portion to the top of the stack.  portion to the top of the stack.
21457    
 @group  
21458  @smallexample  @smallexample
21459    @group
21460             3    ...                    ...                    ___             3    ...                    ...                    ___
21461      (a + b)  . . .           17 x y . . .           17 x y + V c      (a + b)  . . .           17 x y . . .           17 x y + V c
21462  2*  ...............      2*  .............      2:  -------------  2*  ...............      2*  .............      2:  -------------
# Line 21241  portion to the top of the stack. Line 21464  portion to the top of the stack.
21464    
21465                                      3                      3                                      3                      3
21466  1:  17 x y               1:  (a + b)            1:  (a + b)  1:  17 x y               1:  (a + b)            1:  (a + b)
 @end smallexample  
21467  @end group  @end group
21468    @end smallexample
21469    
21470  In this example we select a sub-formula of our original example,  In this example we select a sub-formula of our original example,
21471  enter a new formula, @key{TAB} it into place, then deselect to see  enter a new formula, @key{TAB} it into place, then deselect to see
# Line 21275  the sub-formula with the constant zero, Line 21498  the sub-formula with the constant zero,
21498  it uses the constant one instead.  The @key{DEL} key automatically  it uses the constant one instead.  The @key{DEL} key automatically
21499  deselects and re-simplifies the entire formula afterwards.  Thus:  deselects and re-simplifies the entire formula afterwards.  Thus:
21500    
 @group  
21501  @smallexample  @smallexample
21502    @group
21503                ###                ###
21504      17 x y + # #          17 x y         17 # y          17 y      17 x y + # #          17 x y         17 # y          17 y
21505  1*  -------------     1:  -------    1*  -------    1:  -------  1*  -------------     1:  -------    1*  -------    1:  -------
21506         2 x + 1            2 x + 1        2 x + 1        2 x + 1         2 x + 1            2 x + 1        2 x + 1        2 x + 1
 @end smallexample  
21507  @end group  @end group
21508    @end smallexample
21509    
21510  In this example, we first delete the @samp{sqrt(c)} term; Calc  In this example, we first delete the @samp{sqrt(c)} term; Calc
21511  accomplishes this by replacing @samp{sqrt(c)} with zero and  accomplishes this by replacing @samp{sqrt(c)} with zero and
# Line 21294  If you select an element of a vector and Line 21517  If you select an element of a vector and
21517  element is deleted from the vector.  If you delete one side of  element is deleted from the vector.  If you delete one side of
21518  an equation or inequality, only the opposite side remains.  an equation or inequality, only the opposite side remains.
21519    
21520  @kindex j DEL  @kindex j @key{DEL}
21521  @pindex calc-del-selection  @pindex calc-del-selection
21522  The @kbd{j @key{DEL}} (@code{calc-del-selection}) command is like  The @kbd{j @key{DEL}} (@code{calc-del-selection}) command is like
21523  @key{DEL} but with the auto-selecting behavior of @kbd{j '} and  @key{DEL} but with the auto-selecting behavior of @kbd{j '} and
# Line 21302  The @kbd{j @key{DEL}} (@code{calc-del-se Line 21525  The @kbd{j @key{DEL}} (@code{calc-del-se
21525  indicated by the cursor, or, in the absence of a selection, it  indicated by the cursor, or, in the absence of a selection, it
21526  deletes the sub-formula indicated by the cursor position.  deletes the sub-formula indicated by the cursor position.
21527    
21528  @kindex j RET  @kindex j @key{RET}
21529  @pindex calc-grab-selection  @pindex calc-grab-selection
21530  (There is also an auto-selecting @kbd{j @key{RET}} (@code{calc-copy-selection})  (There is also an auto-selecting @kbd{j @key{RET}} (@code{calc-copy-selection})
21531  command.)  command.)
# Line 21312  select the denominator, press @kbd{5 -} Line 21535  select the denominator, press @kbd{5 -}
21535  denominator, press @kbd{n} to negate the denominator, then  denominator, press @kbd{n} to negate the denominator, then
21536  press @kbd{Q} to take the square root.  press @kbd{Q} to take the square root.
21537    
 @group  
21538  @smallexample  @smallexample
21539    @group
21540       .. .           .. .           .. .             .. .       .. .           .. .           .. .             .. .
21541  1*  .......    1*  .......    1*  .......    1*  ..........  1*  .......    1*  .......    1*  .......    1*  ..........
21542      2 x + 1        2 x - 4        4 - 2 x         _________      2 x + 1        2 x - 4        4 - 2 x         _________
21543                                                   V 4 - 2 x                                                   V 4 - 2 x
 @end smallexample  
21544  @end group  @end group
21545    @end smallexample
21546    
21547  Certain types of operations on selections are not allowed.  For  Certain types of operations on selections are not allowed.  For
21548  example, for an arithmetic function like @kbd{-} no more than one of  example, for an arithmetic function like @kbd{-} no more than one of
# Line 21334  in an ``un-natural'' state.  Consider ne Line 21557  in an ``un-natural'' state.  Consider ne
21557  of our sample formula by selecting it and pressing @kbd{n}  of our sample formula by selecting it and pressing @kbd{n}
21558  (@code{calc-change-sign}).@refill  (@code{calc-change-sign}).@refill
21559    
 @group  
21560  @smallexample  @smallexample
21561    @group
21562         .. .                .. .         .. .                .. .
21563  1*  ..........      1*  ...........  1*  ..........      1*  ...........
21564       .........           ..........       .........           ..........
21565      . . . 2 x           . . . -2 x      . . . 2 x           . . . -2 x
 @end smallexample  
21566  @end group  @end group
21567    @end smallexample
21568    
21569  Unselecting the sub-formula reveals that the minus sign, which would  Unselecting the sub-formula reveals that the minus sign, which would
21570  normally have cancelled out with the subtraction automatically, has  normally have cancelled out with the subtraction automatically, has
# Line 21350  selected portion.  Pressing @kbd{=} (@co Line 21573  selected portion.  Pressing @kbd{=} (@co
21573  any other mathematical operation on the whole formula will cause it  any other mathematical operation on the whole formula will cause it
21574  to be simplified.  to be simplified.
21575    
 @group  
21576  @smallexample  @smallexample
21577    @group
21578         17 y                17 y         17 y                17 y
21579  1:  -----------     1:  ----------  1:  -----------     1:  ----------
21580       __________          _________       __________          _________
21581      V 4 - -2 x          V 4 + 2 x      V 4 - -2 x          V 4 + 2 x
 @end smallexample  
21582  @end group  @end group
21583    @end smallexample
21584    
21585  @node Rearranging with Selections, , Operating on Selections, Selecting Subformulas  @node Rearranging with Selections, , Operating on Selections, Selecting Subformulas
21586  @subsection Rearranging Formulas using Selections  @subsection Rearranging Formulas using Selections
# Line 21370  sub-formula to the right in its surround Line 21593  sub-formula to the right in its surround
21593  selection is one term of a sum or product; the sum or product is  selection is one term of a sum or product; the sum or product is
21594  rearranged according to the commutative laws of algebra.  rearranged according to the commutative laws of algebra.
21595    
21596  As with @kbd{j '} and @kbd{j DEL}, the term under the cursor is used  As with @kbd{j '} and @kbd{j @key{DEL}}, the term under the cursor is used
21597  if there is no selection in the current formula.  All commands described  if there is no selection in the current formula.  All commands described
21598  in this section share this property.  In this example, we place the  in this section share this property.  In this example, we place the
21599  cursor on the @samp{a} and type @kbd{j R}, then repeat.  cursor on the @samp{a} and type @kbd{j R}, then repeat.
# Line 22106  for any @cite{x}.  This occurs even if y Line 22329  for any @cite{x}.  This occurs even if y
22329  value in the Calc variable @samp{e}; but this would be a bad idea  value in the Calc variable @samp{e}; but this would be a bad idea
22330  in any case if you were also using natural logarithms!  in any case if you were also using natural logarithms!
22331    
22332  Among the logical functions, @t{!}@i{(a} @t{<=} @i{b)} changes to  Among the logical functions, @t{(@var{a} <= @var{b})} changes to
22333  @cite{a > b} and so on.  Equations and inequalities where both sides  @t{@var{a} > @var{b}} and so on.  Equations and inequalities where both sides
22334  are either negative-looking or zero are simplified by negating both sides  are either negative-looking or zero are simplified by negating both sides
22335  and reversing the inequality.  While it might seem reasonable to simplify  and reversing the inequality.  While it might seem reasonable to simplify
22336  @cite{!!x} to @cite{x}, this would not be valid in general because  @cite{!!x} to @cite{x}, this would not be valid in general because
# Line 22346  as is @cite{x^2 >= 0} if @cite{x} is kno Line 22569  as is @cite{x^2 >= 0} if @cite{x} is kno
22569  @cindex Extended simplification  @cindex Extended simplification
22570  @kindex a e  @kindex a e
22571  @pindex calc-simplify-extended  @pindex calc-simplify-extended
22572  @c @mindex esimpl@idots  @ignore
22573    @mindex esimpl@idots
22574    @end ignore
22575  @tindex esimplify  @tindex esimplify
22576  The @kbd{a e} (@code{calc-simplify-extended}) [@code{esimplify}] command  The @kbd{a e} (@code{calc-simplify-extended}) [@code{esimplify}] command
22577  is like @kbd{a s}  is like @kbd{a s}
# Line 22543  found, and polynomials in more than one Line 22768  found, and polynomials in more than one
22768  version of Calc.)  version of Calc.)
22769    
22770  @vindex FactorRules  @vindex FactorRules
22771  @c @starindex  @ignore
22772    @starindex
22773    @end ignore
22774  @tindex thecoefs  @tindex thecoefs
22775  @c @starindex  @ignore
22776  @c @mindex @idots  @starindex
22777    @end ignore
22778    @ignore
22779    @mindex @idots
22780    @end ignore
22781  @tindex thefactors  @tindex thefactors
22782  The rewrite-based factorization method uses rules stored in the variable  The rewrite-based factorization method uses rules stored in the variable
22783  @code{FactorRules}.  @xref{Rewrite Rules}, for a discussion of the  @code{FactorRules}.  @xref{Rewrite Rules}, for a discussion of the
# Line 22664  The remainder from the division, if any, Line 22895  The remainder from the division, if any,
22895  of the screen and is also placed in the Trail along with the quotient.  of the screen and is also placed in the Trail along with the quotient.
22896    
22897  Using @code{pdiv} in algebraic notation, you can specify the particular  Using @code{pdiv} in algebraic notation, you can specify the particular
22898  variable to be used as the base:  `@t{pdiv(}@i{a}@t{,}@i{b}@t{,}@i{x}@t{)}'.  variable to be used as the base: @code{pdiv(@var{a},@var{b},@var{x})}.
22899  If @code{pdiv} is given only two arguments (as is always the case with  If @code{pdiv} is given only two arguments (as is always the case with
22900  the @kbd{a \} command), then it does a multivariate division as outlined  the @kbd{a \} command), then it does a multivariate division as outlined
22901  above.  above.
# Line 22893  to use your rule; integral tables genera Line 23124  to use your rule; integral tables genera
23124  in your @code{IntegRules}.  in your @code{IntegRules}.
23125    
23126  @cindex Exponential integral Ei(x)  @cindex Exponential integral Ei(x)
23127  @c @starindex  @ignore
23128    @starindex
23129    @end ignore
23130  @tindex Ei  @tindex Ei
23131  As a more serious example, the expression @samp{exp(x)/x} cannot be  As a more serious example, the expression @samp{exp(x)/x} cannot be
23132  integrated in terms of the standard functions, so the ``exponential  integrated in terms of the standard functions, so the ``exponential
# Line 23129  happens for both @kbd{a S} and @kbd{H a Line 23362  happens for both @kbd{a S} and @kbd{H a
23362    
23363  @cindex @code{GenCount} variable  @cindex @code{GenCount} variable
23364  @vindex GenCount  @vindex GenCount
23365  @c @starindex  @ignore
23366    @starindex
23367    @end ignore
23368  @tindex an  @tindex an
23369  @c @starindex  @ignore
23370    @starindex
23371    @end ignore
23372  @tindex as  @tindex as
23373  If you store a positive integer in the Calc variable @code{GenCount},  If you store a positive integer in the Calc variable @code{GenCount},
23374  then Calc will generate formulas of the form @samp{as(@var{n})} for  then Calc will generate formulas of the form @samp{as(@var{n})} for
# Line 23231  equations toward the front of the list. Line 23468  equations toward the front of the list.
23468  solve any system of linear equations, and also many kinds of  solve any system of linear equations, and also many kinds of
23469  nonlinear systems.  nonlinear systems.
23470    
23471  @c @starindex  @ignore
23472    @starindex
23473    @end ignore
23474  @tindex elim  @tindex elim
23475  Normally there will be as many variables as equations.  If you  Normally there will be as many variables as equations.  If you
23476  give fewer variables than equations (an ``over-determined'' system  give fewer variables than equations (an ``over-determined'' system
# Line 23269  to satisfy the equations.  @xref{Curve F Line 23508  to satisfy the equations.  @xref{Curve F
23508  @subsection Decomposing Polynomials  @subsection Decomposing Polynomials
23509    
23510  @noindent  @noindent
23511  @c @starindex  @ignore
23512    @starindex
23513    @end ignore
23514  @tindex poly  @tindex poly
23515  The @code{poly} function takes a polynomial and a variable as  The @code{poly} function takes a polynomial and a variable as
23516  arguments, and returns a vector of polynomial coefficients (constant  arguments, and returns a vector of polynomial coefficients (constant
# Line 23292  use @samp{vlen(poly(p, x)) - 1}.  For ex Line 23533  use @samp{vlen(poly(p, x)) - 1}.  For ex
23533  returns @samp{[1, 4, 6, 4, 1]}, so @samp{poly((x+1)^4, x)_(2+1)}  returns @samp{[1, 4, 6, 4, 1]}, so @samp{poly((x+1)^4, x)_(2+1)}
23534  gives the @cite{x^2} coefficient of this polynomial, 6.  gives the @cite{x^2} coefficient of this polynomial, 6.
23535    
23536  @c @starindex  @ignore
23537    @starindex
23538    @end ignore
23539  @tindex gpoly  @tindex gpoly
23540  One important feature of the solver is its ability to recognize  One important feature of the solver is its ability to recognize
23541  formulas which are ``essentially'' polynomials.  This ability is  formulas which are ``essentially'' polynomials.  This ability is
# Line 23343  can handle quartics and smaller polynomi Line 23586  can handle quartics and smaller polynomi
23586  @samp{gpoly(@var{expr}, @var{var}, 4)} to discover whether @var{expr}  @samp{gpoly(@var{expr}, @var{var}, 4)} to discover whether @var{expr}
23587  can be treated by its linear, quadratic, cubic, or quartic formulas.  can be treated by its linear, quadratic, cubic, or quartic formulas.
23588    
23589  @c @starindex  @ignore
23590    @starindex
23591    @end ignore
23592  @tindex pdeg  @tindex pdeg
23593  The @code{pdeg} function computes the degree of a polynomial;  The @code{pdeg} function computes the degree of a polynomial;
23594  @samp{pdeg(p,x)} is the highest power of @code{x} that appears in  @samp{pdeg(p,x)} is the highest power of @code{x} that appears in
# Line 23358  that @code{pdeg(c) = pdeg(c,x) = 0} for Line 23603  that @code{pdeg(c) = pdeg(c,x) = 0} for
23603  the degree of the constant zero is considered to be @code{-inf}  the degree of the constant zero is considered to be @code{-inf}
23604  (minus infinity).  (minus infinity).
23605    
23606  @c @starindex  @ignore
23607    @starindex
23608    @end ignore
23609  @tindex plead  @tindex plead
23610  The @code{plead} function finds the leading term of a polynomial.  The @code{plead} function finds the leading term of a polynomial.
23611  Thus @samp{plead(p,x)} is equivalent to @samp{poly(p,x)_vlen(poly(p,x))},  Thus @samp{plead(p,x)} is equivalent to @samp{poly(p,x)_vlen(poly(p,x))},
# Line 23366  though again more efficient.  In particu Line 23613  though again more efficient.  In particu
23613  returns 1024 without expanding out the list of coefficients.  The  returns 1024 without expanding out the list of coefficients.  The
23614  value of @code{plead(p,x)} will be zero only if @cite{p = 0}.  value of @code{plead(p,x)} will be zero only if @cite{p = 0}.
23615    
23616  @c @starindex  @ignore
23617    @starindex
23618    @end ignore
23619  @tindex pcont  @tindex pcont
23620  The @code{pcont} function finds the @dfn{content} of a polynomial.  This  The @code{pcont} function finds the @dfn{content} of a polynomial.  This
23621  is the greatest common divisor of all the coefficients of the polynomial.  is the greatest common divisor of all the coefficients of the polynomial.
# Line 23389  denominators, as well as dividing by any Line 23638  denominators, as well as dividing by any
23638  numerators.  The numerical content of a polynomial is negative only  numerators.  The numerical content of a polynomial is negative only
23639  if all the coefficients in the polynomial are negative.  if all the coefficients in the polynomial are negative.
23640    
23641  @c @starindex  @ignore
23642    @starindex
23643    @end ignore
23644  @tindex pprim  @tindex pprim
23645  The @code{pprim} function finds the @dfn{primitive part} of a  The @code{pprim} function finds the @dfn{primitive part} of a
23646  polynomial, which is simply the polynomial divided (using @code{pdiv}  polynomial, which is simply the polynomial divided (using @code{pdiv}
# Line 23539  variable can only be determined meaningf Line 23790  variable can only be determined meaningf
23790  you should set the precision to twice as many digits as you need in your  you should set the precision to twice as many digits as you need in your
23791  answer.  answer.
23792    
23793  @c @mindex wmin@idots  @ignore
23794    @mindex wmin@idots
23795    @end ignore
23796  @tindex wminimize  @tindex wminimize
23797  @c @mindex wmax@idots  @ignore
23798    @mindex wmax@idots
23799    @end ignore
23800  @tindex wmaximize  @tindex wmaximize
23801  The @kbd{H a N} [@code{wminimize}] command, analogously to @kbd{H a R},  The @kbd{H a N} [@code{wminimize}] command, analogously to @kbd{H a R},
23802  expands the guess interval to enclose a minimum rather than requiring  expands the guess interval to enclose a minimum rather than requiring
# Line 23661  name only those and let the parameters u Line 23916  name only those and let the parameters u
23916  For example, suppose the data matrix  For example, suppose the data matrix
23917    
23918  @ifinfo  @ifinfo
 @group  
23919  @example  @example
23920    @group
23921  [ [ 1, 2, 3, 4,  5  ]  [ [ 1, 2, 3, 4,  5  ]
23922    [ 5, 7, 9, 11, 13 ] ]    [ 5, 7, 9, 11, 13 ] ]
 @end example  
23923  @end group  @end group
23924    @end example
23925  @end ifinfo  @end ifinfo
23926  @tex  @tex
23927  \turnoffactive  \turnoffactive
# Line 23680  $$ Line 23935  $$
23935    
23936  @noindent  @noindent
23937  is on the stack and we wish to do a simple linear fit.  Type  is on the stack and we wish to do a simple linear fit.  Type
23938  @kbd{a F}, then @kbd{1} for the model, then @kbd{RET} to use  @kbd{a F}, then @kbd{1} for the model, then @key{RET} to use
23939  the default names.  The result will be the formula @cite{3 + 2 x}  the default names.  The result will be the formula @cite{3 + 2 x}
23940  on the stack.  Calc has created the model expression @kbd{a + b x},  on the stack.  Calc has created the model expression @kbd{a + b x},
23941  then found the optimal values of @cite{a} and @cite{b} to fit the  then found the optimal values of @cite{a} and @cite{b} to fit the
# Line 23696  than pick them out of the formula.  (You Line 23951  than pick them out of the formula.  (You
23951  to move this vector to the stack; see @ref{Trail Commands}.  to move this vector to the stack; see @ref{Trail Commands}.
23952    
23953  Specifying a different independent variable name will affect the  Specifying a different independent variable name will affect the
23954  resulting formula: @kbd{a F 1 k RET} produces @kbd{3 + 2 k}.  resulting formula: @kbd{a F 1 k @key{RET}} produces @kbd{3 + 2 k}.
23955  Changing the parameter names (say, @kbd{a F 1 k;b,m RET}) will affect  Changing the parameter names (say, @kbd{a F 1 k;b,m @key{RET}}) will affect
23956  the equations that go into the trail.  the equations that go into the trail.
23957    
23958  @tex  @tex
# Line 23712  The result is: Line 23967  The result is:
23967  2.6 + 2.2 x  2.6 + 2.2 x
23968  @end example  @end example
23969    
23970  Evaluating this formula, say with @kbd{v x 5 RET TAB V M $ RET}, shows  Evaluating this formula, say with @kbd{v x 5 @key{RET} @key{TAB} V M $ @key{RET}}, shows
23971  a reasonably close match to the y-values in the data.  a reasonably close match to the y-values in the data.
23972    
23973  @example  @example
23974  [4.8, 7., 9.2, 11.4, 13.6]  [4.8, 7., 9.2, 11.4, 13.6]
23975  @end example  @end example
23976    
23977  Since there is no line which passes through all the @i{N} data points,  Since there is no line which passes through all the @var{n} data points,
23978  Calc has chosen a line that best approximates the data points using  Calc has chosen a line that best approximates the data points using
23979  the method of least squares.  The idea is to define the @dfn{chi-square}  the method of least squares.  The idea is to define the @dfn{chi-square}
23980  error measure  error measure
# Line 23754  formula in place of @cite{a + b x_i}. Line 24009  formula in place of @cite{a + b x_i}.
24009  @end tex  @end tex
24010    
24011  A numeric prefix argument causes the @kbd{a F} command to take the  A numeric prefix argument causes the @kbd{a F} command to take the
24012  data in some other form than one big matrix.  A positive argument @i{N}  data in some other form than one big matrix.  A positive argument @var{n}
24013  will take @i{N} items from the stack, corresponding to the @i{N} rows  will take @var{N} items from the stack, corresponding to the @var{n} rows
24014  of a data matrix.  In the linear case, @i{N} must be 2 since there  of a data matrix.  In the linear case, @var{n} must be 2 since there
24015  is always one independent variable and one dependent variable.  is always one independent variable and one dependent variable.
24016    
24017  A prefix of zero or plain @kbd{C-u} is a compromise; Calc takes two  A prefix of zero or plain @kbd{C-u} is a compromise; Calc takes two
24018  items from the stack, an @i{N}-row matrix of @cite{x} values, and a  items from the stack, an @var{n}-row matrix of @cite{x} values, and a
24019  vector of @cite{y} values.  If there is only one independent variable,  vector of @cite{y} values.  If there is only one independent variable,
24020  the @cite{x} values can be either a one-row matrix or a plain vector,  the @cite{x} values can be either a one-row matrix or a plain vector,
24021  in which case the @kbd{C-u} prefix is the same as a @w{@kbd{C-u 2}} prefix.  in which case the @kbd{C-u} prefix is the same as a @w{@kbd{C-u 2}} prefix.
# Line 23773  To fit the data to higher-order polynomi Line 24028  To fit the data to higher-order polynomi
24028  digits @kbd{2} through @kbd{9} when prompted for a model.  For example,  digits @kbd{2} through @kbd{9} when prompted for a model.  For example,
24029  we could fit the original data matrix from the previous section  we could fit the original data matrix from the previous section
24030  (with 13, not 14) to a parabola instead of a line by typing  (with 13, not 14) to a parabola instead of a line by typing
24031  @kbd{a F 2 RET}.  @kbd{a F 2 @key{RET}}.
24032    
24033  @example  @example
24034  2.00000000001 x - 1.5e-12 x^2 + 2.99999999999  2.00000000001 x - 1.5e-12 x^2 + 2.99999999999
# Line 23797  line slightly to improve the fit. Line 24052  line slightly to improve the fit.
24052  @end example  @end example
24053    
24054  An important result from the theory of polynomial fitting is that it  An important result from the theory of polynomial fitting is that it
24055  is always possible to fit @i{N} data points exactly using a polynomial  is always possible to fit @var{n} data points exactly using a polynomial
24056  of degree @i{N-1}, sometimes called an @dfn{interpolating polynomial}.  of degree @i{@var{n}-1}, sometimes called an @dfn{interpolating polynomial}.
24057  Using the modified (14) data matrix, a model number of 4 gives  Using the modified (14) data matrix, a model number of 4 gives
24058  a polynomial that exactly matches all five data points:  a polynomial that exactly matches all five data points:
24059    
# Line 23837  is linear or multilinear by counting the Line 24092  is linear or multilinear by counting the
24092    
24093  Given the data matrix,  Given the data matrix,
24094    
 @group  
24095  @example  @example
24096    @group
24097  [ [  1,   2,   3,    4,   5  ]  [ [  1,   2,   3,    4,   5  ]
24098    [  7,   2,   3,    5,   2  ]    [  7,   2,   3,    5,   2  ]
24099    [ 14.5, 15, 18.5, 22.5, 24 ] ]    [ 14.5, 15, 18.5, 22.5, 24 ] ]
 @end example  
24100  @end group  @end group
24101    @end example
24102    
24103  @noindent  @noindent
24104  the command @kbd{a F 1 RET} will call the first row @cite{x} and the  the command @kbd{a F 1 @key{RET}} will call the first row @cite{x} and the
24105  second row @cite{y}, and will fit the values in the third row to the  second row @cite{y}, and will fit the values in the third row to the
24106  model @cite{a + b x + c y}.  model @cite{a + b x + c y}.
24107    
# Line 23903  contain error forms.  The data values mu Line 24158  contain error forms.  The data values mu
24158  or all be plain numbers.  Error forms can go anywhere but generally  or all be plain numbers.  Error forms can go anywhere but generally
24159  go on the numbers in the last row of the data matrix.  If the last  go on the numbers in the last row of the data matrix.  If the last
24160  row contains error forms  row contains error forms
24161  `@i{y_i}@w{ @t{+/-} }@c{$\sigma_i$}  `@var{y_i}@w{ @t{+/-} }@c{$\sigma_i$}
24162  @i{sigma_i}', then the @c{$\chi^2$}  @var{sigma_i}', then the @c{$\chi^2$}
24163  @cite{chi^2}  @cite{chi^2}
24164  statistic is now,  statistic is now,
24165    
# Line 23973  will have length @cite{M = d+1} with the Line 24228  will have length @cite{M = d+1} with the
24228    
24229  @item  @item
24230  The covariance matrix @cite{C} computed from the fit.  This is  The covariance matrix @cite{C} computed from the fit.  This is
24231  an @i{M}x@i{M} symmetric matrix; the diagonal elements  an @var{m}x@var{m} symmetric matrix; the diagonal elements
24232  @c{$C_{jj}$}  @c{$C_{jj}$}
24233  @cite{C_j_j} are the variances @c{$\sigma_j^2$}  @cite{C_j_j} are the variances @c{$\sigma_j^2$}
24234  @cite{sigma_j^2} of the parameters.  @cite{sigma_j^2} of the parameters.
# Line 24268  manually by doing a series of fits.  You Line 24523  manually by doing a series of fits.  You
24523  graphing them, by examining the goodness-of-fit measures returned by  graphing them, by examining the goodness-of-fit measures returned by
24524  @kbd{I a F}, or by some other method suitable to your application.  @kbd{I a F}, or by some other method suitable to your application.
24525  Note that some models can be linearized in several ways.  The  Note that some models can be linearized in several ways.  The
24526  Gaussian-plus-@i{d} model can be linearized by setting @cite{d}  Gaussian-plus-@var{d} model can be linearized by setting @cite{d}
24527  (the background) to a constant, or by setting @cite{b} (the standard  (the background) to a constant, or by setting @cite{b} (the standard
24528  deviation) and @cite{c} (the mean) to constants.  deviation) and @cite{c} (the mean) to constants.
24529    
# Line 24384  a special @kbd{s F} command just for edi Line 24639  a special @kbd{s F} command just for edi
24639    
24640  @xref{Rewrite Rules}, for a discussion of rewrite rules.  @xref{Rewrite Rules}, for a discussion of rewrite rules.
24641    
24642  @c @starindex  @ignore
24643    @starindex
24644    @end ignore
24645  @tindex fitvar  @tindex fitvar
24646  @c @starindex  @ignore
24647  @c @mindex @idots  @starindex
24648    @end ignore
24649    @ignore
24650    @mindex @idots
24651    @end ignore
24652  @tindex fitparam  @tindex fitparam
24653  @c @starindex  @ignore
24654  @c @mindex @null  @starindex
24655    @end ignore
24656    @ignore
24657    @mindex @null
24658    @end ignore
24659  @tindex fitmodel  @tindex fitmodel
24660  @c @starindex  @ignore
24661  @c @mindex @null  @starindex
24662    @end ignore
24663    @ignore
24664    @mindex @null
24665    @end ignore
24666  @tindex fitsystem  @tindex fitsystem
24667  @c @starindex  @ignore
24668  @c @mindex @null  @starindex
24669    @end ignore
24670    @ignore
24671    @mindex @null
24672    @end ignore
24673  @tindex fitdummy  @tindex fitdummy
24674  Calc uses @code{FitRules} as follows.  First, it converts the model  Calc uses @code{FitRules} as follows.  First, it converts the model
24675  to an equation if necessary and encloses the model equation in a  to an equation if necessary and encloses the model equation in a
# Line 24408  to @samp{fitvar(1)}, @samp{fitvar(2)}, e Line 24681  to @samp{fitvar(1)}, @samp{fitvar(2)}, e
24681  is the highest-numbered @code{fitvar}.  For example, the power law  is the highest-numbered @code{fitvar}.  For example, the power law
24682  model @cite{a x^b} is converted to @cite{y = a x^b}, then to  model @cite{a x^b} is converted to @cite{y = a x^b}, then to
24683    
 @group  
24684  @smallexample  @smallexample
24685    @group
24686  fitmodel(fitvar(2) = fitparam(1) fitvar(1)^fitparam(2))  fitmodel(fitvar(2) = fitparam(1) fitvar(1)^fitparam(2))
 @end smallexample  
24687  @end group  @end group
24688    @end smallexample
24689    
24690  Calc then applies the rewrites as if by @samp{C-u 0 a r FitRules}.  Calc then applies the rewrites as if by @samp{C-u 0 a r FitRules}.
24691  (The zero prefix means that rewriting should continue until no further  (The zero prefix means that rewriting should continue until no further
# Line 24436  parameters (the length of the @var{abc} Line 24709  parameters (the length of the @var{abc}
24709    
24710  The power law model eventually boils down to  The power law model eventually boils down to
24711    
 @group  
24712  @smallexample  @smallexample
24713    @group
24714  fitsystem(ln(fitvar(2)),  fitsystem(ln(fitvar(2)),
24715            [1, ln(fitvar(1))],            [1, ln(fitvar(1))],
24716            [exp(fitdummy(1)), fitdummy(2)])            [exp(fitdummy(1)), fitdummy(2)])
 @end smallexample  
24717  @end group  @end group
24718    @end smallexample
24719    
24720  The actual implementation of @code{FitRules} is complicated; it  The actual implementation of @code{FitRules} is complicated; it
24721  proceeds in four phases.  First, common rearrangements are done  proceeds in four phases.  First, common rearrangements are done
# Line 24492  removes the fourth @var{model} argument Line 24765  removes the fourth @var{model} argument
24765  to obtain the three-argument @code{fitsystem} that the linear  to obtain the three-argument @code{fitsystem} that the linear
24766  least-squares solver wants to see.  least-squares solver wants to see.
24767    
24768  @c @starindex  @ignore
24769  @c @mindex hasfit@idots  @starindex
24770    @end ignore
24771    @ignore
24772    @mindex hasfit@idots
24773    @end ignore
24774  @tindex hasfitparams  @tindex hasfitparams
24775  @c @starindex  @ignore
24776  @c @mindex @null  @starindex
24777    @end ignore
24778    @ignore
24779    @mindex @null
24780    @end ignore
24781  @tindex hasfitvars  @tindex hasfitvars
24782  Two functions which are useful in connection with @code{FitRules}  Two functions which are useful in connection with @code{FitRules}
24783  are @samp{hasfitparams(x)} and @samp{hasfitvars(x)}, which check  are @samp{hasfitparams(x)} and @samp{hasfitvars(x)}, which check
# Line 24613  name of the summation index variable, th Line 24894  name of the summation index variable, th
24894  sum (any formula), and the upper limit of the sum.  If you  sum (any formula), and the upper limit of the sum.  If you
24895  enter a blank line at any of these prompts, that prompt and  enter a blank line at any of these prompts, that prompt and
24896  any later ones are answered by reading additional elements from  any later ones are answered by reading additional elements from
24897  the stack.  Thus, @kbd{' k^2 RET ' k RET 1 RET 5 RET a + RET}  the stack.  Thus, @kbd{' k^2 @key{RET} ' k @key{RET} 1 @key{RET} 5 @key{RET} a + @key{RET}}
24898  produces the result 55.  produces the result 55.
24899  @tex  @tex
24900  \turnoffactive  \turnoffactive
# Line 24627  in Calc because @code{i} has the imagina Line 24908  in Calc because @code{i} has the imagina
24908  as a value.  If you pressed @kbd{=} on a sum over @code{i}, it would  as a value.  If you pressed @kbd{=} on a sum over @code{i}, it would
24909  be changed to a nonsensical sum over the ``variable'' @cite{(0, 1)}!  be changed to a nonsensical sum over the ``variable'' @cite{(0, 1)}!
24910  If you really want to use @code{i} as an index variable, use  If you really want to use @code{i} as an index variable, use
24911  @w{@kbd{s u i RET}} first to ``unstore'' this variable.  @w{@kbd{s u i @key{RET}}} first to ``unstore'' this variable.
24912  (@xref{Storing Variables}.)  (@xref{Storing Variables}.)
24913    
24914  A numeric prefix argument steps the index by that amount rather  A numeric prefix argument steps the index by that amount rather
24915  than by one.  Thus @kbd{' a_k RET C-u -2 a + k RET 10 RET 0 RET}  than by one.  Thus @kbd{' a_k @key{RET} C-u -2 a + k @key{RET} 10 @key{RET} 0 @key{RET}}
24916  yields @samp{a_10 + a_8 + a_6 + a_4 + a_2 + a_0}.  A prefix  yields @samp{a_10 + a_8 + a_6 + a_4 + a_2 + a_0}.  A prefix
24917  argument of plain @kbd{C-u} causes @kbd{a +} to prompt for the  argument of plain @kbd{C-u} causes @kbd{a +} to prompt for the
24918  step value, in which case you can enter any formula or enter  step value, in which case you can enter any formula or enter
# Line 24823  distinct numbers. Line 25104  distinct numbers.
25104    
25105  @kindex a <  @kindex a <
25106  @tindex lt  @tindex lt
25107  @c @mindex @idots  @ignore
25108    @mindex @idots
25109    @end ignore
25110  @kindex a >  @kindex a >
25111  @c @mindex @null  @ignore
25112    @mindex @null
25113    @end ignore
25114  @kindex a [  @kindex a [
25115  @c @mindex @null  @ignore
25116    @mindex @null
25117    @end ignore
25118  @kindex a ]  @kindex a ]
25119  @pindex calc-less-than  @pindex calc-less-than
25120  @pindex calc-greater-than  @pindex calc-greater-than
25121  @pindex calc-less-equal  @pindex calc-less-equal
25122  @pindex calc-greater-equal  @pindex calc-greater-equal
25123  @c @mindex @null  @ignore
25124    @mindex @null
25125    @end ignore
25126  @tindex gt  @tindex gt
25127  @c @mindex @null  @ignore
25128    @mindex @null
25129    @end ignore
25130  @tindex leq  @tindex leq
25131  @c @mindex @null  @ignore
25132    @mindex @null
25133    @end ignore
25134  @tindex geq  @tindex geq
25135  @c @mindex @null  @ignore
25136    @mindex @null
25137    @end ignore
25138  @tindex <  @tindex <
25139  @c @mindex @null  @ignore
25140    @mindex @null
25141    @end ignore
25142  @tindex >  @tindex >
25143  @c @mindex @null  @ignore
25144    @mindex @null
25145    @end ignore
25146  @tindex <=  @tindex <=
25147  @c @mindex @null  @ignore
25148    @mindex @null
25149    @end ignore
25150  @tindex >=  @tindex >=
25151  The @kbd{a <} (@code{calc-less-than}) [@samp{lt(a,b)} or @samp{a < b}]  The @kbd{a <} (@code{calc-less-than}) [@samp{lt(a,b)} or @samp{a < b}]
25152  operation is true if @cite{a} is less than @cite{b}.  Similar functions  operation is true if @cite{a} is less than @cite{b}.  Similar functions
# Line 24908  number. Line 25209  number.
25209  @kindex a :  @kindex a :
25210  @pindex calc-logical-if  @pindex calc-logical-if
25211  @tindex if  @tindex if
25212  @c @mindex ? :  @ignore
25213    @mindex ? :
25214    @end ignore
25215  @tindex ?  @tindex ?
25216  @c @mindex @null  @ignore
25217    @mindex @null
25218    @end ignore
25219  @tindex :  @tindex :
25220  @cindex Arguments, not evaluated  @cindex Arguments, not evaluated
25221  The @kbd{a :} (@code{calc-logical-if}) [@samp{if(a,b,c)} or @samp{a ? b :@: c}]  The @kbd{a :} (@code{calc-logical-if}) [@samp{if(a,b,c)} or @samp{a ? b :@: c}]
# Line 24948  plain number, @cite{a} must be numerical Line 25253  plain number, @cite{a} must be numerical
25253  @xref{Set Operations}, for a group of commands that manipulate sets  @xref{Set Operations}, for a group of commands that manipulate sets
25254  of this sort.  of this sort.
25255    
25256  @c @starindex  @ignore
25257    @starindex
25258    @end ignore
25259  @tindex typeof  @tindex typeof
25260  The @samp{typeof(a)} function produces an integer or variable which  The @samp{typeof(a)} function produces an integer or variable which
25261  characterizes @cite{a}.  If @cite{a} is a number, vector, or variable,  characterizes @cite{a}.  If @cite{a} is a number, vector, or variable,
# Line 24975  the result will be one of the following Line 25282  the result will be one of the following
25282  Otherwise, @cite{a} is a formula, and the result is a variable which  Otherwise, @cite{a} is a formula, and the result is a variable which
25283  represents the name of the top-level function call.  represents the name of the top-level function call.
25284    
25285  @c @starindex  @ignore
25286    @starindex
25287    @end ignore
25288  @tindex integer  @tindex integer
25289  @c @starindex  @ignore
25290    @starindex
25291    @end ignore
25292  @tindex real  @tindex real
25293  @c @starindex  @ignore
25294    @starindex
25295    @end ignore
25296  @tindex constant  @tindex constant
25297  The @samp{integer(a)} function returns true if @cite{a} is an integer.  The @samp{integer(a)} function returns true if @cite{a} is an integer.
25298  The @samp{real(a)} function  The @samp{real(a)} function
# Line 24997  is true because @samp{floor(x)} is prova Line 25310  is true because @samp{floor(x)} is prova
25310  @samp{integer(floor(x))} does not because @samp{floor(x)} is not  @samp{integer(floor(x))} does not because @samp{floor(x)} is not
25311  literally an integer constant.  literally an integer constant.
25312    
25313  @c @starindex  @ignore
25314    @starindex
25315    @end ignore
25316  @tindex refers  @tindex refers
25317  The @samp{refers(a,b)} function is true if the variable (or sub-expression)  The @samp{refers(a,b)} function is true if the variable (or sub-expression)
25318  @cite{b} appears in @cite{a}, or false otherwise.  Unlike the other  @cite{b} appears in @cite{a}, or false otherwise.  Unlike the other
# Line 25006  even if its arguments are still in symbo Line 25321  even if its arguments are still in symbo
25321  @code{refers} will be left unevaluated is if @cite{a} is a plain  @code{refers} will be left unevaluated is if @cite{a} is a plain
25322  variable (different from @cite{b}).  variable (different from @cite{b}).
25323    
25324  @c @starindex  @ignore
25325    @starindex
25326    @end ignore
25327  @tindex negative  @tindex negative
25328  The @samp{negative(a)} function returns true if @cite{a} ``looks'' negative,  The @samp{negative(a)} function returns true if @cite{a} ``looks'' negative,
25329  because it is a negative number, because it is of the form @cite{-x},  because it is a negative number, because it is of the form @cite{-x},
# Line 25017  be stored in a formula if the default si Line 25334  be stored in a formula if the default si
25334  first with @kbd{m O} (or if it appears in an unevaluated context such  first with @kbd{m O} (or if it appears in an unevaluated context such
25335  as a rewrite rule condition).  as a rewrite rule condition).
25336    
25337  @c @starindex  @ignore
25338    @starindex
25339    @end ignore
25340  @tindex variable  @tindex variable
25341  The @samp{variable(a)} function is true if @cite{a} is a variable,  The @samp{variable(a)} function is true if @cite{a} is a variable,
25342  or false if not.  If @cite{a} is a function call, this test is left  or false if not.  If @cite{a} is a function call, this test is left
25343  in symbolic form.  Built-in variables like @code{pi} and @code{inf}  in symbolic form.  Built-in variables like @code{pi} and @code{inf}
25344  are considered variables like any others by this test.  are considered variables like any others by this test.
25345    
25346  @c @starindex  @ignore
25347    @starindex
25348    @end ignore
25349  @tindex nonvar  @tindex nonvar
25350  The @samp{nonvar(a)} function is true if @cite{a} is a non-variable.  The @samp{nonvar(a)} function is true if @cite{a} is a non-variable.
25351  If its argument is a variable it is left unsimplified; it never  If its argument is a variable it is left unsimplified; it never
# Line 25032  actually returns zero.  However, since C Line 25353  actually returns zero.  However, since C
25353  commands consider ``false'' anything not provably true, this is  commands consider ``false'' anything not provably true, this is
25354  often good enough.  often good enough.
25355    
25356  @c @starindex  @ignore
25357    @starindex
25358    @end ignore
25359  @tindex lin  @tindex lin
25360  @c @starindex  @ignore
25361    @starindex
25362    @end ignore
25363  @tindex linnt  @tindex linnt
25364  @c @starindex  @ignore
25365    @starindex
25366    @end ignore
25367  @tindex islin  @tindex islin
25368  @c @starindex  @ignore
25369    @starindex
25370    @end ignore
25371  @tindex islinnt  @tindex islinnt
25372  @cindex Linearity testing  @cindex Linearity testing
25373  The functions @code{lin}, @code{linnt}, @code{islin}, and @code{islinnt}  The functions @code{lin}, @code{linnt}, @code{islin}, and @code{islinnt}
# Line 25076  first two cases but not the third.  Also Line 25405  first two cases but not the third.  Also
25405  @code{linnt} accept plain constants as linear in the one-argument  @code{linnt} accept plain constants as linear in the one-argument
25406  case: @samp{islin(2,x)} is true, but @samp{islin(2)} is false.  case: @samp{islin(2,x)} is true, but @samp{islin(2)} is false.
25407    
25408  @c @starindex  @ignore
25409    @starindex
25410    @end ignore
25411  @tindex istrue  @tindex istrue
25412  The @samp{istrue(a)} function returns 1 if @cite{a} is a nonzero  The @samp{istrue(a)} function returns 1 if @cite{a} is a nonzero
25413  number or provably nonzero formula, or 0 if @cite{a} is anything else.  number or provably nonzero formula, or 0 if @cite{a} is anything else.
# Line 25155  in several ways: Line 25486  in several ways:
25486    
25487  @enumerate  @enumerate
25488  @item  @item
25489  With a rule:  @kbd{f(x) := g(x) RET}.  With a rule:  @kbd{f(x) := g(x) @key{RET}}.
25490  @item  @item
25491  With a vector of rules:  @kbd{[f1(x) := g1(x), f2(x) := g2(x)] RET}.  With a vector of rules:  @kbd{[f1(x) := g1(x), f2(x) := g2(x)] @key{RET}}.
25492  (You can omit the enclosing square brackets if you wish.)  (You can omit the enclosing square brackets if you wish.)
25493  @item  @item
25494  With the name of a variable that contains the rule or rules vector:  With the name of a variable that contains the rule or rules vector:
25495  @kbd{myrules RET}.  @kbd{myrules @key{RET}}.
25496  @item  @item
25497  With any formula except a rule, a vector, or a variable name; this  With any formula except a rule, a vector, or a variable name; this
25498  will be interpreted as the @var{old} half of a rewrite rule,  will be interpreted as the @var{old} half of a rewrite rule,
# Line 25363  pattern will check all pairs of terms fo Line 25694  pattern will check all pairs of terms fo
25694  will take whichever suitable pair it discovers first.  will take whichever suitable pair it discovers first.
25695    
25696  In general, a pattern using an associative operator like @samp{a + b}  In general, a pattern using an associative operator like @samp{a + b}
25697  will try @i{2 n} different ways to match a sum of @i{n} terms  will try @var{2 n} different ways to match a sum of @var{n} terms
25698  like @samp{x + y + z - w}.  First, @samp{a} is matched against each  like @samp{x + y + z - w}.  First, @samp{a} is matched against each
25699  of @samp{x}, @samp{y}, @samp{z}, and @samp{-w} in turn, with @samp{b}  of @samp{x}, @samp{y}, @samp{z}, and @samp{-w} in turn, with @samp{b}
25700  being matched to the remainders @samp{y + z - w}, @samp{x + z - w}, etc.  being matched to the remainders @samp{y + z - w}, @samp{x + z - w}, etc.
# Line 25670  Here is a complete list of these markers Line 26001  Here is a complete list of these markers
26001  markers that work inside a pattern; then come the markers that  markers that work inside a pattern; then come the markers that
26002  work in the righthand side of a rule.  work in the righthand side of a rule.
26003    
26004  @c @starindex  @ignore
26005    @starindex
26006    @end ignore
26007  @tindex import  @tindex import
26008  One kind of marker, @samp{import(x)}, takes the place of a whole  One kind of marker, @samp{import(x)}, takes the place of a whole
26009  rule.  Here @cite{x} is the name of a variable containing another  rule.  Here @cite{x} is the name of a variable containing another
# Line 25697  The special functions allowed in pattern Line 26030  The special functions allowed in pattern
26030    
26031  @table @samp  @table @samp
26032  @item quote(x)  @item quote(x)
26033  @c @starindex  @ignore
26034    @starindex
26035    @end ignore
26036  @tindex quote  @tindex quote
26037  This pattern matches exactly @cite{x}; variable names in @cite{x} are  This pattern matches exactly @cite{x}; variable names in @cite{x} are
26038  not interpreted as meta-variables.  The only flexibility is that  not interpreted as meta-variables.  The only flexibility is that
# Line 25709  The rewrite may produce either @samp{g(1 Line 26044  The rewrite may produce either @samp{g(1
26044  as a result in this case.)  as a result in this case.)
26045    
26046  @item plain(x)  @item plain(x)
26047  @c @starindex  @ignore
26048    @starindex
26049    @end ignore
26050  @tindex plain  @tindex plain
26051  Here @cite{x} must be a function call @samp{f(x1,x2,@dots{})}.  This  Here @cite{x} must be a function call @samp{f(x1,x2,@dots{})}.  This
26052  pattern matches a call to function @cite{f} with the specified  pattern matches a call to function @cite{f} with the specified
# Line 25721  as well, you must enclose them with more Line 26058  as well, you must enclose them with more
26058  @samp{plain(plain(@w{-a}) + plain(b c))}.  @samp{plain(plain(@w{-a}) + plain(b c))}.
26059    
26060  @item opt(x,def)  @item opt(x,def)
26061  @c @starindex  @ignore
26062    @starindex
26063    @end ignore
26064  @tindex opt  @tindex opt
26065  Here @cite{x} must be a variable name.  This must appear as an  Here @cite{x} must be a variable name.  This must appear as an
26066  argument to a function or an element of a vector; it specifies that  argument to a function or an element of a vector; it specifies that
# Line 25744  case, @emph{not} the value that matched Line 26083  case, @emph{not} the value that matched
26083  In other words, the default @var{def} is effectively quoted.  In other words, the default @var{def} is effectively quoted.
26084    
26085  @item condition(x,c)  @item condition(x,c)
26086  @c @starindex  @ignore
26087    @starindex
26088    @end ignore
26089  @tindex condition  @tindex condition
26090  @tindex ::  @tindex ::
26091  This matches the pattern @cite{x}, with the attached condition  This matches the pattern @cite{x}, with the attached condition
26092  @cite{c}.  It is the same as @samp{x :: c}.  @cite{c}.  It is the same as @samp{x :: c}.
26093    
26094  @item pand(x,y)  @item pand(x,y)
26095  @c @starindex  @ignore
26096    @starindex
26097    @end ignore
26098  @tindex pand  @tindex pand
26099  @tindex &&&  @tindex &&&
26100  This matches anything that matches both pattern @cite{x} and  This matches anything that matches both pattern @cite{x} and
# Line 25759  pattern @cite{y}.  It is the same as @sa Line 26102  pattern @cite{y}.  It is the same as @sa
26102  @pxref{Composing Patterns in Rewrite Rules}.  @pxref{Composing Patterns in Rewrite Rules}.
26103    
26104  @item por(x,y)  @item por(x,y)
26105  @c @starindex  @ignore
26106    @starindex
26107    @end ignore
26108  @tindex por  @tindex por
26109  @tindex |||  @tindex |||
26110  This matches anything that matches either pattern @cite{x} or  This matches anything that matches either pattern @cite{x} or
26111  pattern @cite{y}.  It is the same as @w{@samp{x ||| y}}.  pattern @cite{y}.  It is the same as @w{@samp{x ||| y}}.
26112    
26113  @item pnot(x)  @item pnot(x)
26114  @c @starindex  @ignore
26115    @starindex
26116    @end ignore
26117  @tindex pnot  @tindex pnot
26118  @tindex !!!  @tindex !!!
26119  This matches anything that does not match pattern @cite{x}.  This matches anything that does not match pattern @cite{x}.
26120  It is the same as @samp{!!! x}.  It is the same as @samp{!!! x}.
26121    
26122  @item cons(h,t)  @item cons(h,t)
26123  @c @mindex cons  @ignore
26124    @mindex cons
26125    @end ignore
26126  @tindex cons (rewrites)  @tindex cons (rewrites)
26127  This matches any vector of one or more elements.  The first  This matches any vector of one or more elements.  The first
26128  element is matched to @cite{h}; a vector of the remaining  element is matched to @cite{h}; a vector of the remaining
# Line 25783  length can also be matched as actual vec Line 26132  length can also be matched as actual vec
26132  to the rule @samp{[a,b] := [a+b]}.  to the rule @samp{[a,b] := [a+b]}.
26133    
26134  @item rcons(t,h)  @item rcons(t,h)
26135  @c @mindex rcons  @ignore
26136    @mindex rcons
26137    @end ignore
26138  @tindex rcons (rewrites)  @tindex rcons (rewrites)
26139  This is like @code{cons}, except that the @emph{last} element  This is like @code{cons}, except that the @emph{last} element
26140  is matched to @cite{h}, with the remaining elements matched  is matched to @cite{h}, with the remaining elements matched
26141  to @cite{t}.  to @cite{t}.
26142    
26143  @item apply(f,args)  @item apply(f,args)
26144  @c @mindex apply  @ignore
26145    @mindex apply
26146    @end ignore
26147  @tindex apply (rewrites)  @tindex apply (rewrites)
26148  This matches any function call.  The name of the function, in  This matches any function call.  The name of the function, in
26149  the form of a variable, is matched to @cite{f}.  The arguments  the form of a variable, is matched to @cite{f}.  The arguments
# Line 25836  or enter the rule as @samp{apply(f, [x]) Line 26189  or enter the rule as @samp{apply(f, [x])
26189  @xref{Conditional Rewrite Rules}.  @xref{Conditional Rewrite Rules}.
26190    
26191  @item select(x)  @item select(x)
26192  @c @starindex  @ignore
26193    @starindex
26194    @end ignore
26195  @tindex select  @tindex select
26196  This is used for applying rules to formulas with selections;  This is used for applying rules to formulas with selections;
26197  @pxref{Selections with Rewrite Rules}.  @pxref{Selections with Rewrite Rules}.
# Line 25884  is converted to a function call.  Once a Line 26239  is converted to a function call.  Once a
26239  is also a regular Calc function.  is also a regular Calc function.
26240    
26241  @item eval(x)  @item eval(x)
26242  @c @starindex  @ignore
26243    @starindex
26244    @end ignore
26245  @tindex eval  @tindex eval
26246  The formula @cite{x} is handled in the usual way, then the  The formula @cite{x} is handled in the usual way, then the
26247  default simplifications are applied to it even if they have  default simplifications are applied to it even if they have
# Line 25895  with default simplifications off will be Line 26252  with default simplifications off will be
26252  whereas @samp{eval(cons(2+3, []))} will be converted to @samp{[5]}.  whereas @samp{eval(cons(2+3, []))} will be converted to @samp{[5]}.
26253    
26254  @item evalsimp(x)  @item evalsimp(x)
26255  @c @starindex  @ignore
26256    @starindex
26257    @end ignore
26258  @tindex evalsimp  @tindex evalsimp
26259  The formula @cite{x} has meta-variables substituted in the usual  The formula @cite{x} has meta-variables substituted in the usual
26260  way, then algebraically simplified as if by the @kbd{a s} command.  way, then algebraically simplified as if by the @kbd{a s} command.
26261    
26262  @item evalextsimp(x)  @item evalextsimp(x)
26263  @c @starindex  @ignore
26264    @starindex
26265    @end ignore
26266  @tindex evalextsimp  @tindex evalextsimp
26267  The formula @cite{x} has meta-variables substituted in the normal  The formula @cite{x} has meta-variables substituted in the normal
26268  way, then ``extendedly'' simplified as if by the @kbd{a e} command.  way, then ``extendedly'' simplified as if by the @kbd{a e} command.
# Line 25914  There are also some special functions yo Line 26275  There are also some special functions yo
26275    
26276  @table @samp  @table @samp
26277  @item let(v := x)  @item let(v := x)
26278  @c @starindex  @ignore
26279    @starindex
26280    @end ignore
26281  @tindex let  @tindex let
26282  The expression @cite{x} is evaluated with meta-variables substituted.  The expression @cite{x} is evaluated with meta-variables substituted.
26283  The @kbd{a s} command's simplifications are @emph{not} applied by  The @kbd{a s} command's simplifications are @emph{not} applied by
# Line 25961  the coefficients @code{a} and @code{b} f Line 26324  the coefficients @code{a} and @code{b} f
26324  righthand side instead, but using @samp{sin(y)/b} avoids gratuitous  righthand side instead, but using @samp{sin(y)/b} avoids gratuitous
26325  rearrangement of the argument of the sine.)@refill  rearrangement of the argument of the sine.)@refill
26326    
26327  @c @starindex  @ignore
26328    @starindex
26329    @end ignore
26330  @tindex ierf  @tindex ierf
26331  Similarly, here is a rule that implements an inverse-@code{erf}  Similarly, here is a rule that implements an inverse-@code{erf}
26332  function.  It uses @code{root} to search for a solution.  If  function.  It uses @code{root} to search for a solution.  If
# Line 26014  be added to the rule set and will contin Line 26379  be added to the rule set and will contin
26379  @code{eatfoo} is later changed to 0.  @code{eatfoo} is later changed to 0.
26380    
26381  @item remember(c)  @item remember(c)
26382  @c @starindex  @ignore
26383    @starindex
26384    @end ignore
26385  @tindex remember  @tindex remember
26386  Remember the match as described above, but only if condition @cite{c}  Remember the match as described above, but only if condition @cite{c}
26387  is true.  For example, @samp{remember(n % 4 = 0)} in the above factorial  is true.  For example, @samp{remember(n % 4 = 0)} in the above factorial
# Line 26051  This does the same thing, but is arguabl Line 26418  This does the same thing, but is arguabl
26418  f(a +/- b, a +/- b)  :=  g(a +/- b)  f(a +/- b, a +/- b)  :=  g(a +/- b)
26419  @end example  @end example
26420    
26421  @c @starindex  @ignore
26422    @starindex
26423    @end ignore
26424  @tindex ends  @tindex ends
26425  Here's another interesting example:  Here's another interesting example:
26426    
# Line 26080  The pattern @samp{@var{p1} ||| @var{p2}} Line 26449  The pattern @samp{@var{p1} ||| @var{p2}}
26449  matches either @var{p1} or @var{p2}.  Calc first tries matching  matches either @var{p1} or @var{p2}.  Calc first tries matching
26450  against @var{p1}; if that fails, it goes on to try @var{p2}.  against @var{p1}; if that fails, it goes on to try @var{p2}.
26451    
26452  @c @starindex  @ignore
26453    @starindex
26454    @end ignore
26455  @tindex curve  @tindex curve
26456  A simple example of @samp{|||} is  A simple example of @samp{|||} is
26457    
# Line 26230  In particular, @kbd{M-1 a r} applies onl Line 26601  In particular, @kbd{M-1 a r} applies onl
26601  useful when you are first testing your rule (or just if repeated  useful when you are first testing your rule (or just if repeated
26602  rewriting is not what is called for by your application).  rewriting is not what is called for by your application).
26603    
26604  @c @starindex  @ignore
26605  @c @mindex iter@idots  @starindex
26606    @end ignore
26607    @ignore
26608    @mindex iter@idots
26609    @end ignore
26610  @tindex iterations  @tindex iterations
26611  You can also put a ``function call'' @samp{iterations(@var{n})}  You can also put a ``function call'' @samp{iterations(@var{n})}
26612  in place of a rule anywhere in your rules vector (but usually at  in place of a rule anywhere in your rules vector (but usually at
# Line 26276  During each phase, certain rules will be Line 26651  During each phase, certain rules will be
26651  will be disabled.  A @dfn{phase schedule} controls the order in which  will be disabled.  A @dfn{phase schedule} controls the order in which
26652  phases occur during the rewriting process.  phases occur during the rewriting process.
26653    
26654  @c @starindex  @ignore
26655    @starindex
26656    @end ignore
26657  @tindex phase  @tindex phase
26658  @vindex all  @vindex all
26659  If a call to the marker function @code{phase} appears in the rules  If a call to the marker function @code{phase} appears in the rules
# Line 26290  If you do not explicitly schedule the ph Line 26667  If you do not explicitly schedule the ph
26667  numbers that appear in the rule set and executes the phases in  numbers that appear in the rule set and executes the phases in
26668  ascending order.  For example, the rule set  ascending order.  For example, the rule set
26669    
 @group  
26670  @example  @example
26671    @group
26672  [ f0(x) := g0(x),  [ f0(x) := g0(x),
26673    phase(1),    phase(1),
26674    f1(x) := g1(x),    f1(x) := g1(x),
# Line 26301  ascending order.  For example, the rule Line 26678  ascending order.  For example, the rule
26678    f3(x) := g3(x),    f3(x) := g3(x),
26679    phase(1,2),    phase(1,2),
26680    f4(x) := g4(x) ]    f4(x) := g4(x) ]
 @end example  
26681  @end group  @end group
26682    @end example
26683    
26684  @noindent  @noindent
26685  has three phases, 1 through 3.  Phase 1 consists of the @code{f0},  has three phases, 1 through 3.  Phase 1 consists of the @code{f0},
# Line 26327  way down to the parts, then goes back to Line 26704  way down to the parts, then goes back to
26704  The phase 2 rules do not begin until no phase 1 rules apply anywhere  The phase 2 rules do not begin until no phase 1 rules apply anywhere
26705  in the formula.  in the formula.
26706    
26707  @c @starindex  @ignore
26708    @starindex
26709    @end ignore
26710  @tindex schedule  @tindex schedule
26711  A @code{schedule} marker appearing in the rule set (anywhere, but  A @code{schedule} marker appearing in the rule set (anywhere, but
26712  conventionally at the top) changes the default schedule of phases.  conventionally at the top) changes the default schedule of phases.
# Line 26490  all the positive vector elements. Line 26869  all the positive vector elements.
26869  With the Inverse flag [@code{matchnot}], this command extracts all  With the Inverse flag [@code{matchnot}], this command extracts all
26870  vector elements which do @emph{not} match the given pattern.  vector elements which do @emph{not} match the given pattern.
26871    
26872  @c @starindex  @ignore
26873    @starindex
26874    @end ignore
26875  @tindex matches  @tindex matches
26876  There is also a function @samp{matches(@var{x}, @var{p})} which  There is also a function @samp{matches(@var{x}, @var{p})} which
26877  evaluates to 1 if expression @var{x} matches pattern @var{p}, or  evaluates to 1 if expression @var{x} matches pattern @var{p}, or
26878  to 0 otherwise.  This is sometimes useful for including into the  to 0 otherwise.  This is sometimes useful for including into the
26879  conditional clauses of other rewrite rules.  conditional clauses of other rewrite rules.
26880    
26881  @c @starindex  @ignore
26882    @starindex
26883    @end ignore
26884  @tindex vmatches  @tindex vmatches
26885  The function @code{vmatches} is just like @code{matches}, except  The function @code{vmatches} is just like @code{matches}, except
26886  that if the match succeeds it returns a vector of assignments to  that if the match succeeds it returns a vector of assignments to
# Line 26522  to @samp{sin(b) cos(a) + cos(b) sin(a)} Line 26905  to @samp{sin(b) cos(a) + cos(b) sin(a)}
26905  similarly for @samp{cos(a + b)}.  The corresponding rewrite rule  similarly for @samp{cos(a + b)}.  The corresponding rewrite rule
26906  set would be,  set would be,
26907    
 @group  
26908  @smallexample  @smallexample
26909    @group
26910  [ sin(a + b)  :=  cos(a) sin(b) + sin(a) cos(b),  [ sin(a + b)  :=  cos(a) sin(b) + sin(a) cos(b),
26911    cos(a + b)  :=  cos(a) cos(b) - sin(a) sin(b) ]    cos(a + b)  :=  cos(a) cos(b) - sin(a) sin(b) ]
 @end smallexample  
26912  @end group  @end group
26913    @end smallexample
26914    
26915  To apply these manually, you could put them in a variable called  To apply these manually, you could put them in a variable called
26916  @code{trigexp} and then use @kbd{a r trigexp} every time you wanted  @code{trigexp} and then use @kbd{a r trigexp} every time you wanted
# Line 26641  particularly true of rules where the top Line 27024  particularly true of rules where the top
27024  function, or is not fixed.  The rule @samp{f(n) := n f(n-1) :: n>0} will  function, or is not fixed.  The rule @samp{f(n) := n f(n-1) :: n>0} will
27025  only activate the rewrite mechanism for calls to the function @code{f},  only activate the rewrite mechanism for calls to the function @code{f},
27026  but @samp{lg(n) + lg(m) := lg(n m)} will check every @samp{+} operator.  but @samp{lg(n) + lg(m) := lg(n m)} will check every @samp{+} operator.
27027  And @samp{apply(f, [a*b]) := apply(f, [a]) + apply(f, [b]) ::  
27028  in(f, [ln, log10])} may seem more ``efficient'' than two separate  @smallexample
27029  rules for @code{ln} and @code{log10}, but actually it is vastly less  apply(f, [a*b]) := apply(f, [a]) + apply(f, [b]) :: in(f, [ln, log10])
27030  efficient because rules with @code{apply} as the top-level pattern  @end smallexample
27031  must be tested against @emph{every} function call that is simplified.  
27032    @noindent
27033    may seem more ``efficient'' than two separate rules for @code{ln} and
27034    @code{log10}, but actually it is vastly less efficient because rules
27035    with @code{apply} as the top-level pattern must be tested against
27036    @emph{every} function call that is simplified.
27037    
27038  @cindex @code{AlgSimpRules} variable  @cindex @code{AlgSimpRules} variable
27039  @vindex AlgSimpRules  @vindex AlgSimpRules
# Line 26729  to apply these rules repeatedly.  After Line 27117  to apply these rules repeatedly.  After
27117  stop with 15 on the stack.  Once these rules are debugged, it would probably  stop with 15 on the stack.  Once these rules are debugged, it would probably
27118  be most useful to add them to @code{EvalRules} so that Calc will evaluate  be most useful to add them to @code{EvalRules} so that Calc will evaluate
27119  the new @code{tri} function automatically.  We could then use @kbd{Z K} on  the new @code{tri} function automatically.  We could then use @kbd{Z K} on
27120  the keyboard macro @kbd{' tri($) RET} to make a command that applies  the keyboard macro @kbd{' tri($) @key{RET}} to make a command that applies
27121  @code{tri} to the value on the top of the stack.  @xref{Programming}.  @code{tri} to the value on the top of the stack.  @xref{Programming}.
27122    
27123  @cindex Quaternions  @cindex Quaternions
# Line 26830  to hit the apostrophe key every time you Line 27218  to hit the apostrophe key every time you
27218    
27219  @kindex u s  @kindex u s
27220  @pindex calc-simplify-units  @pindex calc-simplify-units
27221  @c @mindex usimpl@idots  @ignore
27222    @mindex usimpl@idots
27223    @end ignore
27224  @tindex usimplify  @tindex usimplify
27225  The @kbd{u s} (@code{calc-simplify-units}) [@code{usimplify}] command  The @kbd{u s} (@code{calc-simplify-units}) [@code{usimplify}] command
27226  simplifies a units  simplifies a units
# Line 26911  If the value on the stack does not conta Line 27301  If the value on the stack does not conta
27301  prompt first for the old units which this value should be considered  prompt first for the old units which this value should be considered
27302  to have, then for the new units.  Assuming the old and new units you  to have, then for the new units.  Assuming the old and new units you
27303  give are consistent with each other, the result also will not contain  give are consistent with each other, the result also will not contain
27304  any units.  For example, @kbd{@w{u c} cm RET in RET} converts the number  any units.  For example, @kbd{@w{u c} cm @key{RET} in @key{RET}} converts the number
27305  2 on the stack to 5.08.  2 on the stack to 5.08.
27306    
27307  @kindex u b  @kindex u b
# Line 27256  for trail and time/date commands.) Line 27646  for trail and time/date commands.)
27646    
27647  @kindex s +  @kindex s +
27648  @kindex s -  @kindex s -
27649  @c @mindex @idots  @ignore
27650    @mindex @idots
27651    @end ignore
27652  @kindex s *  @kindex s *
27653  @c @mindex @null  @ignore
27654    @mindex @null
27655    @end ignore
27656  @kindex s /  @kindex s /
27657  @c @mindex @null  @ignore
27658    @mindex @null
27659    @end ignore
27660  @kindex s ^  @kindex s ^
27661  @c @mindex @null  @ignore
27662    @mindex @null
27663    @end ignore
27664  @kindex s |  @kindex s |
27665  @c @mindex @null  @ignore
27666    @mindex @null
27667    @end ignore
27668  @kindex s n  @kindex s n
27669  @c @mindex @null  @ignore
27670    @mindex @null
27671    @end ignore
27672  @kindex s &  @kindex s &
27673  @c @mindex @null  @ignore
27674    @mindex @null
27675    @end ignore
27676  @kindex s [  @kindex s [
27677  @c @mindex @null  @ignore
27678    @mindex @null
27679    @end ignore
27680  @kindex s ]  @kindex s ]
27681  @pindex calc-store-plus  @pindex calc-store-plus
27682  @pindex calc-store-minus  @pindex calc-store-minus
# Line 27300  useful if matrix multiplication is invol Line 27706  useful if matrix multiplication is invol
27706  arithmetic stores use formulas designed to behave usefully both  arithmetic stores use formulas designed to behave usefully both
27707  forwards and backwards:  forwards and backwards:
27708    
 @group  
27709  @example  @example
27710    @group
27711  s +        v := v + a          v := a + v  s +        v := v + a          v := a + v
27712  s -        v := v - a          v := a - v  s -        v := v - a          v := a - v
27713  s *        v := v * a          v := a * v  s *        v := v * a          v := a * v
# Line 27312  s n        v := v / (-1)       v := (-1) Line 27718  s n        v := v / (-1)       v := (-1)
27718  s &        v := v ^ (-1)       v := (-1) ^ v  s &        v := v ^ (-1)       v := (-1) ^ v
27719  s [        v := v - 1          v := 1 - v  s [        v := v - 1          v := 1 - v
27720  s ]        v := v - (-1)       v := (-1) - v  s ]        v := v - (-1)       v := (-1) - v
 @end example  
27721  @end group  @end group
27722    @end example
27723    
27724  In the last four cases, a numeric prefix argument will be used in  In the last four cases, a numeric prefix argument will be used in
27725  place of the number one.  (For example, @kbd{M-2 s ]} increases  place of the number one.  (For example, @kbd{M-2 s ]} increases
# Line 27456  as a side effect of putting the value on Line 27862  as a side effect of putting the value on
27862    
27863  @kindex s A  @kindex s A
27864  @kindex s D  @kindex s D
27865  @c @mindex @idots  @ignore
27866    @mindex @idots
27867    @end ignore
27868  @kindex s E  @kindex s E
27869  @c @mindex @null  @ignore
27870    @mindex @null
27871    @end ignore
27872  @kindex s F  @kindex s F
27873  @c @mindex @null  @ignore
27874    @mindex @null
27875    @end ignore
27876  @kindex s G  @kindex s G
27877  @c @mindex @null  @ignore
27878    @mindex @null
27879    @end ignore
27880  @kindex s H  @kindex s H
27881  @c @mindex @null  @ignore
27882    @mindex @null
27883    @end ignore
27884  @kindex s I  @kindex s I
27885  @c @mindex @null  @ignore
27886    @mindex @null
27887    @end ignore
27888  @kindex s L  @kindex s L
27889  @c @mindex @null  @ignore
27890    @mindex @null
27891    @end ignore
27892  @kindex s P  @kindex s P
27893  @c @mindex @null  @ignore
27894    @mindex @null
27895    @end ignore
27896  @kindex s R  @kindex s R
27897  @c @mindex @null  @ignore
27898    @mindex @null
27899    @end ignore
27900  @kindex s T  @kindex s T
27901  @c @mindex @null  @ignore
27902    @mindex @null
27903    @end ignore
27904  @kindex s U  @kindex s U
27905  @c @mindex @null  @ignore
27906    @mindex @null
27907    @end ignore
27908  @kindex s X  @kindex s X
27909  @pindex calc-store-AlgSimpRules  @pindex calc-store-AlgSimpRules
27910  @pindex calc-store-Decls  @pindex calc-store-Decls
# Line 27589  a vector of equations or assignments, in Line 28017  a vector of equations or assignments, in
28017  analogous to the case of @kbd{s t @key{RET}}.  @xref{Storing Variables}.  analogous to the case of @kbd{s t @key{RET}}.  @xref{Storing Variables}.
28018    
28019  Also, you can answer the variable-name prompt with an equation or  Also, you can answer the variable-name prompt with an equation or
28020  assignment:  @kbd{s l b=3 RET} is the same as storing 3 on the stack  assignment:  @kbd{s l b=3 @key{RET}} is the same as storing 3 on the stack
28021  and typing @kbd{s l b RET}.  and typing @kbd{s l b @key{RET}}.
28022    
28023  The @kbd{a b} (@code{calc-substitute}) command is another way to substitute  The @kbd{a b} (@code{calc-substitute}) command is another way to substitute
28024  a variable with a value in a formula.  It does an actual substitution  a variable with a value in a formula.  It does an actual substitution
# Line 27693  to that variable.  But this change is te Line 28121  to that variable.  But this change is te
28121  that the next command that causes Calc to look at those stack  that the next command that causes Calc to look at those stack
28122  entries will make them revert to the old variable value.  entries will make them revert to the old variable value.
28123    
 @group  
28124  @smallexample  @smallexample
28125    @group
28126  2:  a => a             2:  a => 17         2:  a => a  2:  a => a             2:  a => 17         2:  a => a
28127  1:  a + 1 => a + 1     1:  a + 1 => 18     1:  a + 1 => a + 1  1:  a + 1 => a + 1     1:  a + 1 => 18     1:  a + 1 => a + 1
28128      .                      .                   .      .                      .                   .
28129    
28130                             17 s l a RET        p 8 RET                             17 s l a @key{RET}        p 8 @key{RET}
 @end smallexample  
28131  @end group  @end group
28132    @end smallexample
28133    
28134  Here the @kbd{p 8} command changes the current precision,  Here the @kbd{p 8} command changes the current precision,
28135  thus causing the @samp{=>} forms to be recomputed after the  thus causing the @samp{=>} forms to be recomputed after the
28136  influence of the ``let'' is gone.  The @kbd{d SPC} command  influence of the ``let'' is gone.  The @kbd{d @key{SPC}} command
28137  (@code{calc-refresh}) is a handy way to force the @samp{=>}  (@code{calc-refresh}) is a handy way to force the @samp{=>}
28138  operators on the stack to be recomputed without any other  operators on the stack to be recomputed without any other
28139  side effects.  side effects.
# Line 27792  Calc guesses at a reasonable number of d Line 28220  Calc guesses at a reasonable number of d
28220  @kbd{g N} command below.  (The ``x'' values must be either a vector  @kbd{g N} command below.  (The ``x'' values must be either a vector
28221  or an interval if ``y'' is a formula.)  or an interval if ``y'' is a formula.)
28222    
28223  @c @starindex  @ignore
28224    @starindex
28225    @end ignore
28226  @tindex xy  @tindex xy
28227  If ``y'' is (or evaluates to) a formula of the form  If ``y'' is (or evaluates to) a formula of the form
28228  @samp{xy(@var{x}, @var{y})} then the result is a  @samp{xy(@var{x}, @var{y})} then the result is a
# Line 27879  order; the first takes on values from `` Line 28309  order; the first takes on values from ``
28309  values from ``y'' to form a matrix of results that are graphed as a  values from ``y'' to form a matrix of results that are graphed as a
28310  3D surface.  3D surface.
28311    
28312  @c @starindex  @ignore
28313    @starindex
28314    @end ignore
28315  @tindex xyz  @tindex xyz
28316  If the ``z'' formula evaluates to a call to the fictitious function  If the ``z'' formula evaluates to a call to the fictitious function
28317  @samp{xyz(@var{x}, @var{y}, @var{z})}, then the result is a  @samp{xyz(@var{x}, @var{y}, @var{z})}, then the result is a
# Line 28218  altogether.  If there are more curves th Line 28650  altogether.  If there are more curves th
28650  last few curves will continue to have the default styles.  Of course,  last few curves will continue to have the default styles.  Of course,
28651  you can later use @kbd{g s} and @kbd{g S} to change any of these styles.  you can later use @kbd{g s} and @kbd{g S} to change any of these styles.
28652    
28653  For example, @kbd{'[2 -1 3] RET s t LineStyles} causes the first curve  For example, @kbd{'[2 -1 3] @key{RET} s t LineStyles} causes the first curve
28654  to have lines in style number 2, the second curve to have no connecting  to have lines in style number 2, the second curve to have no connecting
28655  lines, and the third curve to have lines in style 3.  Point styles will  lines, and the third curve to have lines in style 3.  Point styles will
28656  still be assigned automatically, but you could store another vector in  still be assigned automatically, but you could store another vector in
# Line 28279  the output file used by GNUPLOT.  For so Line 28711  the output file used by GNUPLOT.  For so
28711  there is no output file and this information is not used.  Many other  there is no output file and this information is not used.  Many other
28712  ``devices'' are really file formats like @code{postscript}; in these  ``devices'' are really file formats like @code{postscript}; in these
28713  cases the output in the desired format goes into the file you name  cases the output in the desired format goes into the file you name
28714  with @kbd{g O}.  Type @kbd{g O stdout RET} to set GNUPLOT to write  with @kbd{g O}.  Type @kbd{g O stdout @key{RET}} to set GNUPLOT to write
28715  to its standard output stream, i.e., to @samp{*Gnuplot Trail*}.  to its standard output stream, i.e., to @samp{*Gnuplot Trail*}.
28716  This is the default setting.  This is the default setting.
28717    
# Line 28380  you have to add them to the @samp{*Gnupl Line 28812  you have to add them to the @samp{*Gnupl
28812  yourself, then use @w{@kbd{g p}} to replot using these new commands.  Note  yourself, then use @w{@kbd{g p}} to replot using these new commands.  Note
28813  that your commands must appear @emph{before} the @code{plot} command.  that your commands must appear @emph{before} the @code{plot} command.
28814  To get help on any GNUPLOT feature, type, e.g., @kbd{g C help set label}.  To get help on any GNUPLOT feature, type, e.g., @kbd{g C help set label}.
28815  You may have to type @kbd{g C RET} a few times to clear the  You may have to type @kbd{g C @key{RET}} a few times to clear the
28816  ``press return for more'' or ``subtopic of @dots{}'' requests.  ``press return for more'' or ``subtopic of @dots{}'' requests.
28817  Note that Calc always sends commands (like @samp{set nolabel}) to  Note that Calc always sends commands (like @samp{set nolabel}) to
28818  reset all plotting parameters to the defaults before each plot, so  reset all plotting parameters to the defaults before each plot, so
# Line 28735  original buffer. Line 29167  original buffer.
29167  @node Keypad Main Menu, Keypad Functions Menu, Keypad Mode, Keypad Mode  @node Keypad Main Menu, Keypad Functions Menu, Keypad Mode, Keypad Mode
29168  @section Main Menu  @section Main Menu
29169    
 @group  
29170  @smallexample  @smallexample
29171    @group
29172  |----+-----Calc 2.00-----+----1  |----+-----Calc 2.00-----+----1
29173  |FLR |CEIL|RND |TRNC|CLN2|FLT |  |FLR |CEIL|RND |TRNC|CLN2|FLT |
29174  |----+----+----+----+----+----|  |----+----+----+----+----+----|
# Line 28754  original buffer. Line 29186  original buffer.
29186  |-----+-----+-----+-----+-----|  |-----+-----+-----+-----+-----|
29187  | OFF |  0  |  .  | PI  |  +  |  | OFF |  0  |  .  | PI  |  +  |
29188  |-----+-----+-----+-----+-----+  |-----+-----+-----+-----+-----+
 @end smallexample  
29189  @end group  @end group
29190    @end smallexample
29191    
29192  @noindent  @noindent
29193  This is the menu that appears the first time you start Keypad Mode.  This is the menu that appears the first time you start Keypad Mode.
# Line 28784  duplicates the top entry on the stack. Line 29216  duplicates the top entry on the stack.
29216    
29217  The @key{UNDO} key undoes the most recent Calc operation.  The @key{UNDO} key undoes the most recent Calc operation.
29218  @kbd{INV UNDO} is the ``redo'' command, and @kbd{HYP UNDO} is  @kbd{INV UNDO} is the ``redo'' command, and @kbd{HYP UNDO} is
29219  ``last arguments'' (@kbd{M-RET}).  ``last arguments'' (@kbd{M-@key{RET}}).
29220    
29221  The @key{<-} key acts as a ``backspace'' during numeric entry.  The @key{<-} key acts as a ``backspace'' during numeric entry.
29222  At other times it removes the top stack entry.  @kbd{INV <-}  At other times it removes the top stack entry.  @kbd{INV <-}
# Line 28866  command line that started Emacs), then @ Line 29298  command line that started Emacs), then @
29298  @node Keypad Functions Menu, Keypad Binary Menu, Keypad Main Menu, Keypad Mode  @node Keypad Functions Menu, Keypad Binary Menu, Keypad Main Menu, Keypad Mode
29299  @section Functions Menu  @section Functions Menu
29300    
 @group  
29301  @smallexample  @smallexample
29302    @group
29303  |----+----+----+----+----+----2  |----+----+----+----+----+----2
29304  |IGAM|BETA|IBET|ERF |BESJ|BESY|  |IGAM|BETA|IBET|ERF |BESJ|BESY|
29305  |----+----+----+----+----+----|  |----+----+----+----+----+----|
# Line 28875  command line that started Emacs), then @ Line 29307  command line that started Emacs), then @
29307  |----+----+----+----+----+----|  |----+----+----+----+----+----|
29308  |GCD |FACT|DFCT|BNOM|PERM|NXTP|  |GCD |FACT|DFCT|BNOM|PERM|NXTP|
29309  |----+----+----+----+----+----|  |----+----+----+----+----+----|
 @end smallexample  
29310  @end group  @end group
29311    @end smallexample
29312    
29313  @noindent  @noindent
29314  This menu provides various operations from the @kbd{f} and @kbd{k}  This menu provides various operations from the @kbd{f} and @kbd{k}
# Line 28908  finds the previous prime. Line 29340  finds the previous prime.
29340  @node Keypad Binary Menu, Keypad Vectors Menu, Keypad Functions Menu, Keypad Mode  @node Keypad Binary Menu, Keypad Vectors Menu, Keypad Functions Menu, Keypad Mode
29341  @section Binary Menu  @section Binary Menu
29342    
 @group  
29343  @smallexample  @smallexample
29344    @group
29345  |----+----+----+----+----+----3  |----+----+----+----+----+----3
29346  |AND | OR |XOR |NOT |LSH |RSH |  |AND | OR |XOR |NOT |LSH |RSH |
29347  |----+----+----+----+----+----|  |----+----+----+----+----+----|
# Line 28917  finds the previous prime. Line 29349  finds the previous prime.
29349  |----+----+----+----+----+----|  |----+----+----+----+----+----|
29350  | A  | B  | C  | D  | E  | F  |  | A  | B  | C  | D  | E  | F  |
29351  |----+----+----+----+----+----|  |----+----+----+----+----+----|
 @end smallexample  
29352  @end group  @end group
29353    @end smallexample
29354    
29355  @noindent  @noindent
29356  The keys in this menu perform operations on binary integers.  The keys in this menu perform operations on binary integers.
# Line 28941  The initial word size is 32 bits. Line 29373  The initial word size is 32 bits.
29373  @node Keypad Vectors Menu, Keypad Modes Menu, Keypad Binary Menu, Keypad Mode  @node Keypad Vectors Menu, Keypad Modes Menu, Keypad Binary Menu, Keypad Mode
29374  @section Vectors Menu  @section Vectors Menu
29375    
 @group  
29376  @smallexample  @smallexample
29377    @group
29378  |----+----+----+----+----+----4  |----+----+----+----+----+----4
29379  |SUM |PROD|MAX |MAP*|MAP^|MAP$|  |SUM |PROD|MAX |MAP*|MAP^|MAP$|
29380  |----+----+----+----+----+----|  |----+----+----+----+----+----|
# Line 28950  The initial word size is 32 bits. Line 29382  The initial word size is 32 bits.
29382  |----+----+----+----+----+----|  |----+----+----+----+----+----|
29383  |PACK|UNPK|INDX|BLD |LEN |... |  |PACK|UNPK|INDX|BLD |LEN |... |
29384  |----+----+----+----+----+----|  |----+----+----+----+----+----|
 @end smallexample  
29385  @end group  @end group
29386    @end smallexample
29387    
29388  @noindent  @noindent
29389  The keys in this menu operate on vectors and matrices.  The keys in this menu operate on vectors and matrices.
# Line 29023  With @key{INV}, @key{HYP}, or @key{INV} Line 29455  With @key{INV}, @key{HYP}, or @key{INV}
29455  @node Keypad Modes Menu, , Keypad Vectors Menu, Keypad Mode  @node Keypad Modes Menu, , Keypad Vectors Menu, Keypad Mode
29456  @section Modes Menu  @section Modes Menu
29457    
 @group  
29458  @smallexample  @smallexample
29459    @group
29460  |----+----+----+----+----+----5  |----+----+----+----+----+----5
29461  |FLT |FIX |SCI |ENG |GRP |    |  |FLT |FIX |SCI |ENG |GRP |    |
29462  |----+----+----+----+----+----|  |----+----+----+----+----+----|
# Line 29032  With @key{INV}, @key{HYP}, or @key{INV} Line 29464  With @key{INV}, @key{HYP}, or @key{INV}
29464  |----+----+----+----+----+----|  |----+----+----+----+----+----|
29465  |SWAP|RLL3|RLL4|OVER|STO |RCL |  |SWAP|RLL3|RLL4|OVER|STO |RCL |
29466  |----+----+----+----+----+----|  |----+----+----+----+----+----|
 @end smallexample  
29467  @end group  @end group
29468    @end smallexample
29469    
29470  @noindent  @noindent
29471  The keys in this menu manipulate modes, variables, and the stack.  The keys in this menu manipulate modes, variables, and the stack.
# Line 29211  We define $F_n = F_(n-1)+F_(n-2)$ for al Line 29643  We define $F_n = F_(n-1)+F_(n-2)$ for al
29643  The @kbd{M-# o} command is a useful way to open a Calc window  The @kbd{M-# o} command is a useful way to open a Calc window
29644  without actually selecting that window.  Giving this command  without actually selecting that window.  Giving this command
29645  verifies that @samp{2 < n} is also on the Calc stack.  Typing  verifies that @samp{2 < n} is also on the Calc stack.  Typing
29646  @kbd{17 RET} would produce:  @kbd{17 @key{RET}} would produce:
29647    
29648  @example  @example
29649  We define $F_n = F_(n-1)+F_(n-2)$ for all $17$.  We define $F_n = F_(n-1)+F_(n-2)$ for all $17$.
# Line 29382  The derivative of Line 29814  The derivative of
29814    
29815  @noindent  @noindent
29816  with the second copy of the formula enabled in Embedded mode.  with the second copy of the formula enabled in Embedded mode.
29817  You can now press @kbd{a d x RET} to take the derivative, and  You can now press @kbd{a d x @key{RET}} to take the derivative, and
29818  @kbd{M-# d M-# d} to make two more copies of the derivative.  @kbd{M-# d M-# d} to make two more copies of the derivative.
29819  To complete the computations, type @kbd{3 s l x RET} to evaluate  To complete the computations, type @kbd{3 s l x @key{RET}} to evaluate
29820  the last formula, then move up to the second-to-last formula  the last formula, then move up to the second-to-last formula
29821  and type @kbd{2 s l x RET}.  and type @kbd{2 s l x @key{RET}}.
29822    
29823  Finally, you would want to press @kbd{M-# e} to exit Embedded  Finally, you would want to press @kbd{M-# e} to exit Embedded
29824  mode, then go up and insert the necessary text in between the  mode, then go up and insert the necessary text in between the
# Line 29491  foo + 7 => foo + 7 Line 29923  foo + 7 => foo + 7
29923    
29924  The right thing to do is first to use a selection command (@kbd{j 2}  The right thing to do is first to use a selection command (@kbd{j 2}
29925  will do the trick) to select the righthand side of the assignment.  will do the trick) to select the righthand side of the assignment.
29926  Then, @kbd{17 TAB DEL} will swap the 17 into place (@pxref{Selecting  Then, @kbd{17 @key{TAB} @key{DEL}} will swap the 17 into place (@pxref{Selecting
29927  Subformulas}, to see how this works).  Subformulas}, to see how this works).
29928    
29929  @kindex M-# j  @kindex M-# j
# Line 30156  the definition stored on the key, or, to Line 30588  the definition stored on the key, or, to
30588    
30589  If you give a negative numeric prefix argument to @kbd{Z E}, the keyboard  If you give a negative numeric prefix argument to @kbd{Z E}, the keyboard
30590  macro is edited in spelled-out keystroke form.  For example, the editing  macro is edited in spelled-out keystroke form.  For example, the editing
30591  buffer might contain the nine characters @w{@samp{1 RET 2 +}}.  When you press  buffer might contain the nine characters @w{@samp{1 @key{RET} 2 +}}.  When you press
30592  @kbd{M-# M-#}, the @code{read-kbd-macro} feature of the @file{macedit}  @kbd{M-# M-#}, the @code{read-kbd-macro} feature of the @file{macedit}
30593  package is used to reinterpret these key names.  The  package is used to reinterpret these key names.  The
30594  notations @code{RET}, @code{LFD}, @code{TAB}, @code{SPC}, @code{DEL}, and  notations @code{RET}, @code{LFD}, @code{TAB}, @code{SPC}, @code{DEL}, and
# Line 30164  notations @code{RET}, @code{LFD}, @code{ Line 30596  notations @code{RET}, @code{LFD}, @code{
30596  and @code{M-}.  Spaces and line breaks are ignored.  Other characters are  and @code{M-}.  Spaces and line breaks are ignored.  Other characters are
30597  copied verbatim into the keyboard macro.  Basically, the notation is the  copied verbatim into the keyboard macro.  Basically, the notation is the
30598  same as is used in all of this manual's examples, except that the manual  same as is used in all of this manual's examples, except that the manual
30599  takes some liberties with spaces:  When we say @kbd{' [1 2 3] RET}, we take  takes some liberties with spaces:  When we say @kbd{' [1 2 3] @key{RET}}, we take
30600  it for granted that it is clear we really mean @kbd{' [1 SPC 2 SPC 3] RET},  it for granted that it is clear we really mean @kbd{' [1 @key{SPC} 2 @key{SPC} 3] @key{RET}},
30601  which is what @code{read-kbd-macro} wants to see.@refill  which is what @code{read-kbd-macro} wants to see.@refill
30602    
30603  If @file{macedit} is not available, @kbd{Z E} edits the keyboard macro  If @file{macedit} is not available, @kbd{Z E} edits the keyboard macro
# Line 30903  buffer if necessary, say, because the co Line 31335  buffer if necessary, say, because the co
31335  the @samp{*Calc Trail*} window.  the @samp{*Calc Trail*} window.
31336    
31337  @findex calc-set-command-flag  @findex calc-set-command-flag
31338  You can call, for example, @code{(calc-set-command-flag 'no-align)} to set  You can call, for example, @code{(calc-set-command-flag 'no-align)} to
31339  the above-mentioned command flags.  The following command flags are  set the above-mentioned command flags.  Calc routines recognize the
31340  recognized by Calc routines:  following command flags:
31341    
31342  @table @code  @table @code
31343  @item renum-stack  @item renum-stack
# Line 31206  These programs make use of some of the C Line 31638  These programs make use of some of the C
31638  @subsubsection Bit-Counting  @subsubsection Bit-Counting
31639    
31640  @noindent  @noindent
31641  @c @starindex  @ignore
31642    @starindex
31643    @end ignore
31644  @tindex bcount  @tindex bcount
31645  Calc does not include a built-in function for counting the number of  Calc does not include a built-in function for counting the number of
31646  ``one'' bits in a binary integer.  It's easy to invent one using @kbd{b u}  ``one'' bits in a binary integer.  It's easy to invent one using @kbd{b u}
# Line 31246  recall that Calc stores integers in deci Line 31680  recall that Calc stores integers in deci
31680  involve actual division.  involve actual division.
31681    
31682  To gain a bit more efficiency, we could divide the integer into  To gain a bit more efficiency, we could divide the integer into
31683  @i{n}-bit chunks, each of which can be handled quickly because  @var{n}-bit chunks, each of which can be handled quickly because
31684  they fit into Lisp integers.  It turns out that Calc's arithmetic  they fit into Lisp integers.  It turns out that Calc's arithmetic
31685  routines are especially fast when dividing by an integer less than  routines are especially fast when dividing by an integer less than
31686  1000, so we can set @i{n = 9} bits and use repeated division by 512:  1000, so we can set @var{n = 9} bits and use repeated division by 512:
31687    
31688  @smallexample  @smallexample
31689  (defmath bcount ((natnum n))  (defmath bcount ((natnum n))
# Line 31288  same thing with a single division by 512 Line 31722  same thing with a single division by 512
31722  @subsubsection The Sine Function  @subsubsection The Sine Function
31723    
31724  @noindent  @noindent
31725  @c @starindex  @ignore
31726    @starindex
31727    @end ignore
31728  @tindex mysin  @tindex mysin
31729  A somewhat limited sine function could be defined as follows, using the  A somewhat limited sine function could be defined as follows, using the
31730  well-known Taylor series expansion for @c{$\sin x$}  well-known Taylor series expansion for @c{$\sin x$}
# Line 32834  form; this is really just a special case Line 33270  form; this is really just a special case
33270  @end defun  @end defun
33271    
33272  @defun build-vector args  @defun build-vector args
33273  Return a Calc vector with the zero-or-more @var{args} as elements.  Return a Calc vector with @var{args} as elements.
33274  For example, @samp{(build-vector 1 2 3)} returns the Calc vector  For example, @samp{(build-vector 1 2 3)} returns the Calc vector
33275  @samp{[1, 2, 3]}, stored internally as the list @samp{(vec 1 2 3)}.  @samp{[1, 2, 3]}, stored internally as the list @samp{(vec 1 2 3)}.
33276  @end defun  @end defun
# Line 33889  autoloading of the extensions modules. Line 34325  autoloading of the extensions modules.
34325  Calculator can exit.  Calculator can exit.
34326    
34327  You may also wish to test the GNUPLOT interface; to plot a sine wave,  You may also wish to test the GNUPLOT interface; to plot a sine wave,
34328  type @kbd{' [0 ..@: 360], sin(x) RET g f}.  Type @kbd{g q} when you  type @kbd{' [0 ..@: 360], sin(x) @key{RET} g f}.  Type @kbd{g q} when you
34329  are done viewing the plot.  are done viewing the plot.
34330    
34331  Calc is now ready to use.  If you wish to go through the Calc Tutorial,  Calc is now ready to use.  If you wish to go through the Calc Tutorial,
# Line 33963  keystrokes are not listed in this summar Line 34399  keystrokes are not listed in this summar
34399  \gdef\sumrow#1{\sumrowx#1\relax}%  \gdef\sumrow#1{\sumrowx#1\relax}%
34400  \gdef\sumrowx#1\:#2\:#3\:#4\:#5\:#6\relax{%  \gdef\sumrowx#1\:#2\:#3\:#4\:#5\:#6\relax{%
34401  \leavevmode%  \leavevmode%
34402  \hbox to5em{\indsl\hss#1}%  {\smallfonts
34403  \hbox to5em{\ninett#2\hss}%  \hbox to5em{\sl\hss#1}%
34404  \hbox to4em{\indsl#3\hss}%  \hbox to5em{\tt#2\hss}%
34405  \hbox to5em{\indrm\hss#4}%  \hbox to4em{\sl#3\hss}%
34406    \hbox to5em{\rm\hss#4}%
34407  \thinspace%  \thinspace%
34408  {\ninett#5}%  {\tt#5}%
34409  {\indsl#6}%  {\sl#6}%
34410  }%  }}%
34411  \gdef\sumlpar{{\indrm(}}%  \gdef\sumlpar{{\rm(}}%
34412  \gdef\sumrpar{{\indrm)}}%  \gdef\sumrpar{{\rm)}}%
34413  \gdef\sumcomma{{\indrm,\thinspace}}%  \gdef\sumcomma{{\rm,\thinspace}}%
34414  \gdef\sumexcl{{\indrm!}}%  \gdef\sumexcl{{\rm!}}%
34415  \gdef\sumbreak{\vskip-2.5\baselineskip\goodbreak}%  \gdef\sumbreak{\vskip-2.5\baselineskip\goodbreak}%
34416  \gdef\minus#1{{\tt-}}%  \gdef\minus#1{{\tt-}}%
34417  @end tex  @end tex
# Line 33988  keystrokes are not listed in this summar Line 34425  keystrokes are not listed in this summar
34425  @format  @format
34426  @iftex  @iftex
34427  @advance@baselineskip-2.5pt  @advance@baselineskip-2.5pt
 @let@tt@ninett  
34428  @let@c@sumbreak  @let@c@sumbreak
34429  @end iftex  @end iftex
34430  @r{       @:     M-# a  @:             @:    33  @:calc-embedded-activate@:}  @r{       @:     M-# a  @:             @:    33  @:calc-embedded-activate@:}
# Line 34056  keystrokes are not listed in this summar Line 34492  keystrokes are not listed in this summar
34492  @r{      a@:      M-%   @:             @:        @:percent@:(a)  a%}  @r{      a@:      M-%   @:             @:        @:percent@:(a)  a%}
34493    
34494  @c  @c
34495  @r{  ... a@:      RET   @:             @:     1  @:@:... a a}  @r{  ... a@:      @key{RET}   @:             @:     1  @:@:... a a}
34496  @r{  ... a@:      SPC   @:             @:     1  @:@:... a a}  @r{  ... a@:      @key{SPC}   @:             @:     1  @:@:... a a}
34497  @r{... a b@:      TAB   @:             @:     3  @:@:... b a}  @r{... a b@:      @key{TAB}   @:             @:     3  @:@:... b a}
34498  @r{. a b c@:      M-TAB @:             @:     3  @:@:... b c a}  @r{. a b c@:      M-@key{TAB} @:             @:     3  @:@:... b c a}
34499  @r{... a b@:      LFD   @:             @:     1  @:@:... a b a}  @r{... a b@:      @key{LFD}   @:             @:     1  @:@:... a b a}
34500  @r{  ... a@:      DEL   @:             @:     1  @:@:...}  @r{  ... a@:      @key{DEL}   @:             @:     1  @:@:...}
34501  @r{... a b@:      M-DEL @:             @:     1  @:@:... b}  @r{... a b@:      M-@key{DEL} @:             @:     1  @:@:... b}
34502  @r{       @:      M-RET @:             @:     4  @:calc-last-args@:}  @r{       @:      M-@key{RET} @:             @:     4  @:calc-last-args@:}
34503  @r{      a@:      `     @:editing      @:  1,30  @:calc-edit@:}  @r{      a@:      `     @:editing      @:  1,30  @:calc-edit@:}
34504    
34505  @c  @c
# Line 34295  keystrokes are not listed in this summar Line 34731  keystrokes are not listed in this summar
34731  @r{       @:      d [   @:             @:     4  @:calc-truncate-up@:}  @r{       @:      d [   @:             @:     4  @:calc-truncate-up@:}
34732  @r{       @:      d ]   @:             @:     4  @:calc-truncate-down@:}  @r{       @:      d ]   @:             @:     4  @:calc-truncate-down@:}
34733  @r{       @:      d "   @:             @: 12,50  @:calc-display-strings@:}  @r{       @:      d "   @:             @: 12,50  @:calc-display-strings@:}
34734  @r{       @:      d SPC @:             @:        @:calc-refresh@:}  @r{       @:      d @key{SPC} @:             @:        @:calc-refresh@:}
34735  @r{       @:      d RET @:             @:     1  @:calc-refresh-top@:}  @r{       @:      d @key{RET} @:             @:     1  @:calc-refresh-top@:}
34736    
34737  @c  @c
34738  @r{       @:      d 0   @:             @:    50  @:calc-decimal-radix@:}  @r{       @:      d 0   @:             @:    50  @:calc-decimal-radix@:}
# Line 34432  keystrokes are not listed in this summar Line 34868  keystrokes are not listed in this summar
34868    
34869  @c  @c
34870  @r{       @:      j 1-9 @:             @:        @:calc-select-part@:}  @r{       @:      j 1-9 @:             @:        @:calc-select-part@:}
34871  @r{       @:      j RET @:             @:    27  @:calc-copy-selection@:}  @r{       @:      j @key{RET} @:             @:    27  @:calc-copy-selection@:}
34872  @r{       @:      j DEL @:             @:    27  @:calc-del-selection@:}  @r{       @:      j @key{DEL} @:             @:    27  @:calc-del-selection@:}
34873  @r{       @:      j '   @:formula      @:    27  @:calc-enter-selection@:}  @r{       @:      j '   @:formula      @:    27  @:calc-enter-selection@:}
34874  @r{       @:      j `   @:editing      @: 27,30  @:calc-edit-selection@:}  @r{       @:      j `   @:editing      @: 27,30  @:calc-edit-selection@:}
34875  @r{       @:      j "   @:             @:  7,27  @:calc-sel-expand-formula@:}  @r{       @:      j "   @:             @:  7,27  @:calc-sel-expand-formula@:}
# Line 34814  NOTES Line 35250  NOTES
35250  Positive prefix arguments apply to @cite{n} stack entries.  Positive prefix arguments apply to @cite{n} stack entries.
35251  Negative prefix arguments apply to the @cite{-n}th stack entry.  Negative prefix arguments apply to the @cite{-n}th stack entry.
35252  A prefix of zero applies to the entire stack.  (For @key{LFD} and  A prefix of zero applies to the entire stack.  (For @key{LFD} and
35253  @kbd{M-DEL}, the meaning of the sign is reversed.)  @kbd{M-@key{DEL}}, the meaning of the sign is reversed.)
35254    
35255  @c 2  @c 2
35256  @item  @item
# Line 34925  input data set.  Each entry may be a sin Line 35361  input data set.  Each entry may be a sin
35361    
35362  @c 20  @c 20
35363  @item  @item
35364  With a prefix argument of 1, take a single @c{$N\times2$}  With a prefix argument of 1, take a single @c{$@var{n}\times2$}
35365  @asis{Nx2} matrix from the  @i{@var{N}x2} matrix from the
35366  stack instead of two separate data vectors.  stack instead of two separate data vectors.
35367    
35368  @c 21  @c 21
# Line 35135  assigns @c{$x \coloneq a-x$} Line 35571  assigns @c{$x \coloneq a-x$}
35571  Press @kbd{?} repeatedly to see how to choose a model.  Answer the  Press @kbd{?} repeatedly to see how to choose a model.  Answer the
35572  variables prompt with @cite{iv} or @cite{iv;pv} to specify  variables prompt with @cite{iv} or @cite{iv;pv} to specify
35573  independent and parameter variables.  A positive prefix argument  independent and parameter variables.  A positive prefix argument
35574  takes @i{N+1} vectors from the stack; a zero prefix takes a matrix  takes @i{@var{n}+1} vectors from the stack; a zero prefix takes a matrix
35575  and a vector from the stack.  and a vector from the stack.
35576    
35577  @c 49  @c 49

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26