[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/man/calc.texi
From: |
Richard M. Stallman |
Subject: |
[Emacs-diffs] Changes to emacs/man/calc.texi |
Date: |
Thu, 03 Jan 2002 18:38:49 -0500 |
Index: emacs/man/calc.texi
diff -c emacs/man/calc.texi:1.7 emacs/man/calc.texi:1.8
*** emacs/man/calc.texi:1.7 Tue Dec 25 12:20:00 2001
--- emacs/man/calc.texi Thu Jan 3 18:38:47 2002
***************
*** 26,36 ****
\gdef\citexxx#1{#1$\Etex}
\global\let\oldxrefX=\xrefX
\gdef\xrefX[#1]{\begingroup\let\cite=\dfn\oldxrefX[#1]\endgroup}
! %
! % 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
! %
% Redefine @c{tex-stuff} \n @whatever{info-stuff}.
\gdef\c{\futurelet\next\mycxxx}
\gdef\mycxxx{%
--- 26,32 ----
\gdef\citexxx#1{#1$\Etex}
\global\let\oldxrefX=\xrefX
\gdef\xrefX[#1]{\begingroup\let\cite=\dfn\oldxrefX[#1]\endgroup}
!
% Redefine @c{tex-stuff} \n @whatever{info-stuff}.
\gdef\c{\futurelet\next\mycxxx}
\gdef\mycxxx{%
***************
*** 62,171 ****
@iftex
@finalout
@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
@tex
\gdef\coloneq{\mathrel{\mathord:\mathord=}}
! \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
\gdef\beforedisplay{\vskip-10pt}
\gdef\afterdisplay{\vskip-5pt}
\gdef\beforedisplayh{\vskip-25pt}
\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...}}
@end tex
@address@hidden @kyvpos=0pt
@address@hidden @kyhpos=0pt
@address@hidden @calcclubpenalty=1000
@address@hidden
@address@hidden @address@hidden
@address@hidden@address@hidden
--- 58,75 ----
@iftex
@finalout
@mathcode`@:=`@: @c Make Calc fractions come out right in math mode
@tex
\gdef\coloneq{\mathrel{\mathord:\mathord=}}
!
\gdef\beforedisplay{\vskip-10pt}
\gdef\afterdisplay{\vskip-5pt}
\gdef\beforedisplayh{\vskip-25pt}
\gdef\afterdisplayh{\vskip-10pt}
@end tex
@address@hidden @kyvpos=0pt
@address@hidden @kyhpos=0pt
@address@hidden @calcclubpenalty=1000
+ @ignore
@address@hidden
@address@hidden @address@hidden
@address@hidden@address@hidden
***************
*** 174,179 ****
--- 78,84 ----
@address@hidden address@hidden
address@hidden
address@hidden @address@hidden@active
+ @end ignore
@end iftex
@ifinfo
***************
*** 574,580 ****
@item
Number theoretical features such as prime factorization and arithmetic
! modulo @i{M} for any @i{M}.
@item
Algebraic manipulation features, including symbolic calculus.
--- 479,485 ----
@item
Number theoretical features such as prime factorization and arithmetic
! modulo @var{m} for any @var{m}.
@item
Algebraic manipulation features, including symbolic calculus.
***************
*** 601,608 ****
first few sections of the tutorial. As you become more comfortable with
the program you can learn its additional features. In terms of efficiency,
scope and depth, Calc cannot replace a powerful tool like Mathematica.
- @c Removed this per RMS' request:
- @c address@hidden @asis{ (tm)}.
But Calc has the advantages of convenience, portability, and availability
of the source code. And, of course, it's free!
--- 506,511 ----
***************
*** 691,700 ****
the @kbd{C-j} and @kbd{C-i} keys are equivalent to them, respectively.
If you don't have a Meta key, look for Alt or Extend Char. You can
also press @key{ESC} or @key{C-[} first to get the same effect, so
! that @kbd{M-x}, @kbd{ESC x}, and @kbd{C-[ x} are all equivalent.)
Sometimes the @key{RET} key is not shown when it is ``obvious''
! that you must press @kbd{RET} to proceed. For example, the @key{RET}
is usually omitted in key sequences like @kbd{M-x calc-keypad @key{RET}}.
Commands are generally shown like this: @kbd{p} (@code{calc-precision})
--- 594,603 ----
the @kbd{C-j} and @kbd{C-i} keys are equivalent to them, respectively.
If you don't have a Meta key, look for Alt or Extend Char. You can
also press @key{ESC} or @key{C-[} first to get the same effect, so
! that @kbd{M-x}, @address@hidden x}, and @kbd{C-[ x} are all equivalent.)
Sometimes the @key{RET} key is not shown when it is ``obvious''
! that you must press @key{RET} to proceed. For example, the @key{RET}
is usually omitted in key sequences like @kbd{M-x calc-keypad @key{RET}}.
Commands are generally shown like this: @kbd{p} (@code{calc-precision})
***************
*** 722,740 ****
Tutorial.
To begin, start Emacs if necessary (usually the command @code{emacs}
! does this), and type @kbd{M-# c} (or @kbd{ESC # c}) to start the
Calculator. (@xref{Starting Calc}, if this doesn't work for you.)
Be sure to type all the sample input exactly, especially noting the
difference between lower-case and upper-case letters. Remember,
! @kbd{RET}, @kbd{TAB}, @kbd{DEL}, and @kbd{SPC} are the Return, Tab,
Delete, and Space keys.
@strong{RPN calculation.} In RPN, you type the input number(s) first,
then the command to operate on the numbers.
@noindent
! Type @kbd{2 RET 3 + Q} to compute @c{$\sqrt{2+3} = 2.2360679775$}
@asis{the square root of 2+3, which is 2.2360679775}.
@noindent
--- 625,643 ----
Tutorial.
To begin, start Emacs if necessary (usually the command @code{emacs}
! does this), and type @kbd{M-# c} (or @address@hidden # c}) to start the
Calculator. (@xref{Starting Calc}, if this doesn't work for you.)
Be sure to type all the sample input exactly, especially noting the
difference between lower-case and upper-case letters. Remember,
! @key{RET}, @key{TAB}, @key{DEL}, and @key{SPC} are the Return, Tab,
Delete, and Space keys.
@strong{RPN calculation.} In RPN, you type the input number(s) first,
then the command to operate on the numbers.
@noindent
! Type @kbd{2 @key{RET} 3 + Q} to compute @c{$\sqrt{2+3} = 2.2360679775$}
@asis{the square root of 2+3, which is 2.2360679775}.
@noindent
***************
*** 742,771 ****
@asis{the value of `pi' squared, 9.86960440109}.
@noindent
! Type @kbd{TAB} to exchange the order of these two results.
@noindent
Type @kbd{- I H S} to subtract these results and compute the Inverse
Hyperbolic sine of the difference, 2.72996136574.
@noindent
! Type @kbd{DEL} to erase this result.
@strong{Algebraic calculation.} You can also enter calculations using
conventional ``algebraic'' notation. To enter an algebraic formula,
use the apostrophe key.
@noindent
! Type @kbd{' sqrt(2+3) RET} to compute @c{$\sqrt{2+3}$}
@asis{the square root of 2+3}.
@noindent
! Type @kbd{' pi^2 RET} to enter @c{$\pi^2$}
@asis{`pi' squared}. To evaluate this symbolic
formula as a number, type @kbd{=}.
@noindent
! Type @kbd{' arcsinh($ - $$) RET} to subtract the second-most-recent
result from the most-recent and compute the Inverse Hyperbolic sine.
@strong{Keypad mode.} If you are using the X window system, press
--- 645,674 ----
@asis{the value of `pi' squared, 9.86960440109}.
@noindent
! Type @key{TAB} to exchange the order of these two results.
@noindent
Type @kbd{- I H S} to subtract these results and compute the Inverse
Hyperbolic sine of the difference, 2.72996136574.
@noindent
! Type @key{DEL} to erase this result.
@strong{Algebraic calculation.} You can also enter calculations using
conventional ``algebraic'' notation. To enter an algebraic formula,
use the apostrophe key.
@noindent
! Type @kbd{' sqrt(2+3) @key{RET}} to compute @c{$\sqrt{2+3}$}
@asis{the square root of 2+3}.
@noindent
! Type @kbd{' pi^2 @key{RET}} to enter @c{$\pi^2$}
@asis{`pi' squared}. To evaluate this symbolic
formula as a number, type @kbd{=}.
@noindent
! Type @kbd{' arcsinh($ - $$) @key{RET}} to subtract the second-most-recent
result from the most-recent and compute the Inverse Hyperbolic sine.
@strong{Keypad mode.} If you are using the X window system, press
***************
*** 791,809 ****
@strong{Grabbing data.} Type @kbd{M-# x} if necessary to exit Calc.
Now select the following numbers as an Emacs region: ``Mark'' the
! front of the list by typing address@hidden or address@hidden@@} there,
then move to the other end of the list. (Either get this list from
the on-line copy of this manual, accessed by @address@hidden i}}, or just
type these numbers into a scratch file.) Now type @kbd{M-# g} to
``grab'' these numbers into Calc.
- @group
@example
1.23 1.97
1.6 2
1.19 1.08
- @end example
@end group
@noindent
The result @samp{[1.23, 1.97, 1.6, 2, 1.19, 1.08]} is a Calc ``vector.''
--- 694,712 ----
@strong{Grabbing data.} Type @kbd{M-# x} if necessary to exit Calc.
Now select the following numbers as an Emacs region: ``Mark'' the
! front of the list by typing @address@hidden or @kbd{C-@@} there,
then move to the other end of the list. (Either get this list from
the on-line copy of this manual, accessed by @address@hidden i}}, or just
type these numbers into a scratch file.) Now type @kbd{M-# g} to
``grab'' these numbers into Calc.
@example
+ @group
1.23 1.97
1.6 2
1.19 1.08
@end group
+ @end example
@noindent
The result @samp{[1.23, 1.97, 1.6, 2, 1.19, 1.08]} is a Calc ``vector.''
***************
*** 823,845 ****
@asis{3x2} matrix into a @c{$2\times3$}
@asis{2x3} matrix. Type
@address@hidden u}} to unpack the rows into two separate vectors. Now type
! @address@hidden R + TAB V R +}} to compute the sums of the two original
columns.
(There is also a special grab-and-sum-columns command, @kbd{M-# :}.)
@strong{Units conversion.} Units are entered algebraically.
! Type @address@hidden' 43 mi/hr RET}} to enter the quantity 43 miles-per-hour.
! Type @address@hidden c km/hr RET}}. Type @address@hidden c m/s RET}}.
@strong{Date arithmetic.} Type @kbd{t N} to get the current date and
time. Type @kbd{90 +} to find the date 90 days from now. Type
! @kbd{' <25 dec 87> RET} to enter a date, then @kbd{- 7 /} to see how
many weeks have passed since then.
@strong{Algebra.} Algebraic entries can also include formulas
! or equations involving variables. Type @address@hidden' [x + y} = a, x y =
1] RET}
to enter a pair of equations involving three variables.
(Note the leading apostrophe in this example; also, note that the space
! between @samp{x y} is required.) Type @address@hidden S x,y RET}} to solve
these equations for the variables @cite{x} and @address@hidden
@noindent
--- 726,748 ----
@asis{3x2} matrix into a @c{$2\times3$}
@asis{2x3} matrix. Type
@address@hidden u}} to unpack the rows into two separate vectors. Now type
! @address@hidden R + @key{TAB} V R +}} to compute the sums of the two original
columns.
(There is also a special grab-and-sum-columns command, @kbd{M-# :}.)
@strong{Units conversion.} Units are entered algebraically.
! Type @address@hidden' 43 mi/hr @key{RET}}} to enter the quantity 43
miles-per-hour.
! Type @address@hidden c km/hr @key{RET}}}. Type @address@hidden c m/s
@key{RET}}}.
@strong{Date arithmetic.} Type @kbd{t N} to get the current date and
time. Type @kbd{90 +} to find the date 90 days from now. Type
! @kbd{' <25 dec 87> @key{RET}} to enter a date, then @kbd{- 7 /} to see how
many weeks have passed since then.
@strong{Algebra.} Algebraic entries can also include formulas
! or equations involving variables. Type @address@hidden' [x + y} = a, x y =
1] @key{RET}}
to enter a pair of equations involving three variables.
(Note the leading apostrophe in this example; also, note that the space
! between @samp{x y} is required.) Type @address@hidden S x,y @key{RET}}} to
solve
these equations for the variables @cite{x} and @address@hidden
@noindent
***************
*** 849,873 ****
Type @kbd{d N} to return to normal notation.
@noindent
! Type @kbd{7.5}, then @kbd{s l a RET} to let @cite{a = 7.5} in these formulas.
(That's a letter @kbd{l}, not a numeral @kbd{1}.)
@iftex
@strong{Help functions.} You can read about any command in the on-line
manual. Type @kbd{M-# c} to return to Calc after each of these
commands: @kbd{h k t N} to read about the @kbd{t N} command,
! @kbd{h f sqrt RET} to read about the @code{sqrt} function, and
@kbd{h s} to read the Calc summary.
@end iftex
@ifinfo
@strong{Help functions.} You can read about any command in the on-line
manual. Remember to type the letter @kbd{l}, then @kbd{M-# c}, to
return here after each of these commands: @address@hidden k t N}} to read
! about the @address@hidden N}} command, @kbd{h f sqrt RET} to read about the
@code{sqrt} function, and @kbd{h s} to read the Calc summary.
@end ifinfo
! Press @kbd{DEL} repeatedly to remove any leftover results from the stack.
To exit from Calc, press @kbd{q} or @kbd{M-# c} again.
@node Using Calc, History and Acknowledgements, Demonstration of Calc,
Getting Started
--- 752,776 ----
Type @kbd{d N} to return to normal notation.
@noindent
! Type @kbd{7.5}, then @kbd{s l a @key{RET}} to let @cite{a = 7.5} in these
formulas.
(That's a letter @kbd{l}, not a numeral @kbd{1}.)
@iftex
@strong{Help functions.} You can read about any command in the on-line
manual. Type @kbd{M-# c} to return to Calc after each of these
commands: @kbd{h k t N} to read about the @kbd{t N} command,
! @kbd{h f sqrt @key{RET}} to read about the @code{sqrt} function, and
@kbd{h s} to read the Calc summary.
@end iftex
@ifinfo
@strong{Help functions.} You can read about any command in the on-line
manual. Remember to type the letter @kbd{l}, then @kbd{M-# c}, to
return here after each of these commands: @address@hidden k t N}} to read
! about the @address@hidden N}} command, @kbd{h f sqrt @key{RET}} to read about
the
@code{sqrt} function, and @kbd{h s} to read the Calc summary.
@end ifinfo
! Press @key{DEL} repeatedly to remove any leftover results from the stack.
To exit from Calc, press @kbd{q} or @kbd{M-# c} again.
@node Using Calc, History and Acknowledgements, Demonstration of Calc,
Getting Started
***************
*** 951,961 ****
to start the Calculator, the Emacs screen splits into two windows
with the file you were editing on top and Calc on the bottom.
- @group
@iftex
@address@hidden
@end iftex
@smallexample
...
--**-Emacs: myfile (Fundamental)----All----------------------
--- 854,864 ----
to start the Calculator, the Emacs screen splits into two windows
with the file you were editing on top and Calc on the bottom.
@iftex
@address@hidden
@end iftex
@smallexample
+ @group
...
--**-Emacs: myfile (Fundamental)----All----------------------
***************
*** 968,975 ****
| ->-5
|
--%%-Calc: 12 Deg (Calculator)----All----- --%%-Emacs: *Calc Trail*
- @end smallexample
@end group
In this figure, the mode-line for @file{myfile} has moved up and the
``Calculator'' window has appeared below it. As you can see, Calc
--- 871,878 ----
| ->-5
|
--%%-Calc: 12 Deg (Calculator)----All----- --%%-Emacs: *Calc Trail*
@end group
+ @end smallexample
In this figure, the mode-line for @file{myfile} has moved up and the
``Calculator'' window has appeared below it. As you can see, Calc
***************
*** 1185,1199 ****
editing buffer. Suppose you have a formula written as part of a
document like this:
- @group
@smallexample
The derivative of
ln(ln(x))
is
- @end smallexample
@end group
@noindent
and you wish to have Calc compute and format the derivative for
--- 1088,1102 ----
editing buffer. Suppose you have a formula written as part of a
document like this:
@smallexample
+ @group
The derivative of
ln(ln(x))
is
@end group
+ @end smallexample
@noindent
and you wish to have Calc compute and format the derivative for
***************
*** 1201,1208 ****
do this with Embedded Mode, first copy the formula down to where
you want the result to be:
- @group
@smallexample
The derivative of
ln(ln(x))
--- 1104,1111 ----
do this with Embedded Mode, first copy the formula down to where
you want the result to be:
@smallexample
+ @group
The derivative of
ln(ln(x))
***************
*** 1210,1217 ****
is
ln(ln(x))
- @end smallexample
@end group
Now, move the cursor onto this new formula and press @kbd{M-# e}.
Calc will read the formula (using the surrounding blank lines to
--- 1113,1120 ----
is
ln(ln(x))
@end group
+ @end smallexample
Now, move the cursor onto this new formula and press @kbd{M-# e}.
Calc will read the formula (using the surrounding blank lines to
***************
*** 1224,1231 ****
you get is copied from the stack back into the buffer. To take
the derivative, you would type @kbd{a d x @key{RET}}.
- @group
@smallexample
The derivative of
ln(ln(x))
--- 1127,1134 ----
you get is copied from the stack back into the buffer. To take
the derivative, you would type @kbd{a d x @key{RET}}.
@smallexample
+ @group
The derivative of
ln(ln(x))
***************
*** 1233,1246 ****
is
1 / ln(x) x
- @end smallexample
@end group
To make this look nicer, you might want to press @kbd{d =} to center
the formula, and even @kbd{d B} to use ``big'' display mode.
- @group
@smallexample
The derivative of
ln(ln(x))
--- 1136,1149 ----
is
1 / ln(x) x
@end group
+ @end smallexample
To make this look nicer, you might want to press @kbd{d =} to center
the formula, and even @kbd{d B} to use ``big'' display mode.
@smallexample
+ @group
The derivative of
ln(ln(x))
***************
*** 1252,1259 ****
1
-------
ln(x) x
- @end smallexample
@end group
Calc has added annotations to the file to help it remember the modes
that were used for this formula. They are formatted like comments
--- 1155,1162 ----
1
-------
ln(x) x
@end group
+ @end smallexample
Calc has added annotations to the file to help it remember the modes
that were used for this formula. They are formatted like comments
***************
*** 1263,1272 ****
of the way.)
As an extra flourish, we can add an equation number using a
! righthand label: Type @kbd{d @} (1) RET}.
- @group
@smallexample
% [calc-mode: justify: center]
% [calc-mode: language: big]
% [calc-mode: right-label: " (1)"]
--- 1166,1175 ----
of the way.)
As an extra flourish, we can add an equation number using a
! righthand label: Type @kbd{d @} (1) @key{RET}}.
@smallexample
+ @group
% [calc-mode: justify: center]
% [calc-mode: language: big]
% [calc-mode: right-label: " (1)"]
***************
*** 1274,1281 ****
1
------- (1)
ln(x) x
- @end smallexample
@end group
To leave Embedded Mode, type @kbd{M-# e} again. The mode line
and keyboard will revert to the way they were before. (If you have
--- 1177,1184 ----
1
------- (1)
ln(x) x
@end group
+ @end smallexample
To leave Embedded Mode, type @kbd{M-# e} again. The mode line
and keyboard will revert to the way they were before. (If you have
***************
*** 1384,1390 ****
@sp 2
@end iftex
- @group
@noindent
Commands for moving data into and out of the Calculator:
--- 1287,1292 ----
***************
*** 1407,1415 ****
@iftex
@sp 2
@end iftex
- @end group
- @group
@noindent
Commands for use with Embedded Mode:
--- 1309,1315 ----
***************
*** 1441,1449 ****
@iftex
@sp 2
@end iftex
- @end group
- @group
@noindent
Miscellaneous commands:
--- 1341,1347 ----
***************
*** 1463,1469 ****
are loaded only as they are needed.)
@item M
! Read a region of written keystroke names (like @samp{C-n a b c RET})
and record them as the current keyboard macro.
@item 0
--- 1361,1367 ----
are loaded only as they are needed.)
@item M
! Read a region of written keystroke names (like @kbd{C-n a b c @key{RET}})
and record them as the current keyboard macro.
@item 0
***************
*** 1471,1477 ****
its default state: Empty stack, and default mode settings.
With any prefix argument, reset everything but the stack.
@end table
- @end group
@node History and Acknowledgements, , Using Calc, Getting Started
@section History and Acknowledgements
--- 1369,1374 ----
***************
*** 1724,1738 ****
and pushes the result (5) back onto the stack. Here's how the stack
will look at various points throughout the calculation:@refill
- @group
@smallexample
. 1: 2 2: 2 1: 5 .
. 1: 3 .
.
! M-# c 2 RET 3 RET + DEL
! @end smallexample
@end group
The @samp{.} symbol is a marker that represents the top of the stack.
Note that the ``top'' of the stack is really shown at the bottom of
--- 1621,1635 ----
and pushes the result (5) back onto the stack. Here's how the stack
will look at various points throughout the calculation:@refill
@smallexample
+ @group
. 1: 2 2: 2 1: 5 .
. 1: 3 .
.
! M-# c 2 @key{RET} 3 @key{RET} +
@key{DEL}
@end group
+ @end smallexample
The @samp{.} symbol is a marker that represents the top of the stack.
Note that the ``top'' of the stack is really shown at the bottom of
***************
*** 1769,1783 ****
Examples in this tutorial will often omit @key{RET} even when the
stack displays shown would only happen if you did press @key{RET}:
- @group
@smallexample
1: 2 2: 2 1: 5
. 1: 3 .
.
! 2 RET 3 +
! @end smallexample
@end group
@noindent
Here, after pressing @kbd{3} the stack would really show @samp{1: 2}
--- 1666,1680 ----
Examples in this tutorial will often omit @key{RET} even when the
stack displays shown would only happen if you did press @key{RET}:
@smallexample
+ @group
1: 2 2: 2 1: 5
. 1: 3 .
.
! 2 @key{RET} 3 +
@end group
+ @end smallexample
@noindent
Here, after pressing @kbd{3} the stack would really show @samp{1: 2}
***************
*** 1830,1844 ****
If you press @key{RET} when you're not entering a number, the effect
is to duplicate the top number on the stack. Consider this calculation:
- @group
@smallexample
1: 3 2: 3 1: 9 2: 9 1: 81
. 1: 3 . 1: 9 .
. .
! 3 RET RET * RET *
! @end smallexample
@end group
@noindent
(Of course, an easier way to do this would be @kbd{3 @key{RET} 4 ^},
--- 1727,1741 ----
If you press @key{RET} when you're not entering a number, the effect
is to duplicate the top number on the stack. Consider this calculation:
@smallexample
+ @group
1: 3 2: 3 1: 9 2: 9 1: 81
. 1: 3 . 1: 9 .
. .
! 3 @key{RET} @key{RET} * @key{RET}
*
@end group
+ @end smallexample
@noindent
(Of course, an easier way to do this would be @kbd{3 @key{RET} 4 ^},
***************
*** 1854,1897 ****
to get 5, and then you realize what you really wanted to compute
was @cite{20 / (2+3)}.
- @group
@smallexample
1: 5 2: 5 2: 20 1: 4
. 1: 20 1: 5 .
. .
! 2 RET 3 + 20 TAB /
! @end smallexample
@end group
@noindent
Planning ahead, the calculation would have gone like this:
- @group
@smallexample
1: 20 2: 20 3: 20 2: 20 1: 4
. 1: 2 2: 2 1: 5 .
. 1: 3 .
.
! 20 RET 2 RET 3 + /
! @end smallexample
@end group
A related stack command is @address@hidden (hold @key{META} and type
@key{TAB}). It rotates the top three elements of the stack upward,
bringing the object in level 3 to the top.
- @group
@smallexample
1: 10 2: 10 3: 10 3: 20 3: 30
. 1: 20 2: 20 2: 30 2: 10
. 1: 30 1: 10 1: 20
. . .
! 10 RET 20 RET 30 RET M-TAB M-TAB
! @end smallexample
@end group
(@bullet{}) @strong{Exercise 3.} Suppose the numbers 10, 20, and 30 are
on the stack. Figure out how to add one to the number in level 2
--- 1751,1794 ----
to get 5, and then you realize what you really wanted to compute
was @cite{20 / (2+3)}.
@smallexample
+ @group
1: 5 2: 5 2: 20 1: 4
. 1: 20 1: 5 .
. .
! 2 @key{RET} 3 + 20 @key{TAB} /
@end group
+ @end smallexample
@noindent
Planning ahead, the calculation would have gone like this:
@smallexample
+ @group
1: 20 2: 20 3: 20 2: 20 1: 4
. 1: 2 2: 2 1: 5 .
. 1: 3 .
.
! 20 @key{RET} 2 @key{RET} 3 + /
@end group
+ @end smallexample
A related stack command is @address@hidden (hold @key{META} and type
@key{TAB}). It rotates the top three elements of the stack upward,
bringing the object in level 3 to the top.
@smallexample
+ @group
1: 10 2: 10 3: 10 3: 20 3: 30
. 1: 20 2: 20 2: 30 2: 10
. 1: 30 1: 10 1: 20
. . .
! 10 @key{RET} 20 @key{RET} 30 @key{RET}
address@hidden address@hidden
@end group
+ @end smallexample
(@bullet{}) @strong{Exercise 3.} Suppose the numbers 10, 20, and 30 are
on the stack. Figure out how to add one to the number in level 2
***************
*** 1903,1917 ****
@kbd{Q} (square root) pop a single number and push the result. You can
think of them as simply operating on the top element of the stack.
- @group
@smallexample
1: 3 1: 9 2: 9 1: 25 1: 5
. . 1: 16 . .
.
! 3 RET RET * 4 RET RET * + Q
! @end smallexample
@end group
@noindent
(Note that capital @kbd{Q} means to hold down the Shift key while
--- 1800,1814 ----
@kbd{Q} (square root) pop a single number and push the result. You can
think of them as simply operating on the top element of the stack.
@smallexample
+ @group
1: 3 1: 9 2: 9 1: 25 1: 5
. . 1: 16 . .
.
! 3 @key{RET} @key{RET} * 4 @key{RET} @key{RET} * +
Q
@end group
+ @end smallexample
@noindent
(Note that capital @kbd{Q} means to hold down the Shift key while
***************
*** 1923,1963 ****
@kbd{f h}, but let's suppose we can't remember the necessary keystrokes.
We can still enter it by its full name using @kbd{M-x} notation:
- @group
@smallexample
1: 3 2: 3 1: 5
. 1: 4 .
.
! 3 RET 4 RET M-x calc-hypot
! @end smallexample
@end group
All Calculator commands begin with the word @samp{calc-}. Since it
gets tiring to type this, Calc provides an @kbd{x} key which is just
like the regular Emacs @kbd{M-x} key except that it types the @samp{calc-}
prefix for you:
- @group
@smallexample
1: 3 2: 3 1: 5
. 1: 4 .
.
! 3 RET 4 RET x hypot
! @end smallexample
@end group
What happens if you take the square root of a negative number?
- @group
@smallexample
1: 4 1: -4 1: (0, 2)
. . .
! 4 RET n Q
! @end smallexample
@end group
@noindent
The notation @cite{(a, b)} represents a complex number.
--- 1820,1860 ----
@kbd{f h}, but let's suppose we can't remember the necessary keystrokes.
We can still enter it by its full name using @kbd{M-x} notation:
@smallexample
+ @group
1: 3 2: 3 1: 5
. 1: 4 .
.
! 3 @key{RET} 4 @key{RET} M-x calc-hypot
@end group
+ @end smallexample
All Calculator commands begin with the word @samp{calc-}. Since it
gets tiring to type this, Calc provides an @kbd{x} key which is just
like the regular Emacs @kbd{M-x} key except that it types the @samp{calc-}
prefix for you:
@smallexample
+ @group
1: 3 2: 3 1: 5
. 1: 4 .
.
! 3 @key{RET} 4 @key{RET} x hypot
@end group
+ @end smallexample
What happens if you take the square root of a negative number?
@smallexample
+ @group
1: 4 1: -4 1: (0, 2)
. . .
! 4 @key{RET} n Q
@end group
+ @end smallexample
@noindent
The notation @cite{(a, b)} represents a complex number.
***************
*** 1975,2003 ****
Complex numbers are entered in the notation shown. The @kbd{(} and
@kbd{,} and @kbd{)} keys manipulate ``incomplete complex numbers.''
- @group
@smallexample
1: ( ... 2: ( ... 1: (2, ... 1: (2, ... 1: (2, 3)
. 1: 2 . 3 .
. .
( 2 , 3 )
- @end smallexample
@end group
You can perform calculations while entering parts of incomplete objects.
However, an incomplete object cannot actually participate in a calculation:
- @group
@smallexample
1: ( ... 2: ( ... 3: ( ... 1: ( ... 1: ( ...
. 1: 2 2: 2 5 5
. 1: 3 . .
.
(error)
! ( 2 RET 3 + +
! @end smallexample
@end group
@noindent
Adding 5 to an incomplete object makes no sense, so the last command
--- 1872,1900 ----
Complex numbers are entered in the notation shown. The @kbd{(} and
@kbd{,} and @kbd{)} keys manipulate ``incomplete complex numbers.''
@smallexample
+ @group
1: ( ... 2: ( ... 1: (2, ... 1: (2, ... 1: (2, 3)
. 1: 2 . 3 .
. .
( 2 , 3 )
@end group
+ @end smallexample
You can perform calculations while entering parts of incomplete objects.
However, an incomplete object cannot actually participate in a calculation:
@smallexample
+ @group
1: ( ... 2: ( ... 3: ( ... 1: ( ... 1: ( ...
. 1: 2 2: 2 5 5
. 1: 3 . .
.
(error)
! ( 2 @key{RET} 3 + +
@end group
+ @end smallexample
@noindent
Adding 5 to an incomplete object makes no sense, so the last command
***************
*** 2006,2021 ****
Incomplete objects can't participate in arithmetic, but they can be
moved around by the regular stack commands.
- @group
@smallexample
2: 2 3: 2 3: 3 1: ( ... 1: (2, 3)
1: 3 2: 3 2: ( ... 2 .
. 1: ( ... 1: 2 3
. . .
! 2 RET 3 RET ( M-TAB M-TAB )
! @end smallexample
@end group
@noindent
Note that the @kbd{,} (comma) key did not have to be used here.
--- 1903,1918 ----
Incomplete objects can't participate in arithmetic, but they can be
moved around by the regular stack commands.
@smallexample
+ @group
2: 2 3: 2 3: 3 1: ( ... 1: (2, 3)
1: 3 2: 3 2: ( ... 2 .
. 1: ( ... 1: 2 3
. . .
! 2 @key{RET} 3 @key{RET} ( address@hidden
address@hidden )
@end group
+ @end smallexample
@noindent
Note that the @kbd{,} (comma) key did not have to be used here.
***************
*** 2041,2056 ****
prefix arguments in a variety of ways. For example, a numeric prefix
on the @kbd{+} operator adds any number of stack entries at once:
- @group
@smallexample
1: 10 2: 10 3: 10 3: 10 1: 60
. 1: 20 2: 20 2: 20 .
. 1: 30 1: 30
. .
! 10 RET 20 RET 30 RET C-u 3 +
! @end smallexample
@end group
For stack manipulation commands like @key{RET}, a positive numeric
prefix argument operates on the top @var{n} stack entries at once. A
--- 1938,1953 ----
prefix arguments in a variety of ways. For example, a numeric prefix
on the @kbd{+} operator adds any number of stack entries at once:
@smallexample
+ @group
1: 10 2: 10 3: 10 3: 10 1: 60
. 1: 20 2: 20 2: 20 .
. 1: 30 1: 30
. .
! 10 @key{RET} 20 @key{RET} 30 @key{RET} C-u 3
+
@end group
+ @end smallexample
For stack manipulation commands like @key{RET}, a positive numeric
prefix argument operates on the top @var{n} stack entries at once. A
***************
*** 2058,2078 ****
argument of zero operates on the entire stack. In this example, we copy
the second-to-top element of the stack:
- @group
@smallexample
1: 10 2: 10 3: 10 3: 10 4: 10
. 1: 20 2: 20 2: 20 3: 20
. 1: 30 1: 30 2: 30
. . 1: 20
.
! 10 RET 20 RET 30 RET C-u -2 RET
! @end smallexample
@end group
@cindex Clearing the stack
@cindex Emptying the stack
! Another common idiom is @kbd{M-0 DEL}, which clears the stack.
(The @kbd{M-0} numeric prefix tells @key{DEL} to operate on the
entire stack.)
--- 1955,1975 ----
argument of zero operates on the entire stack. In this example, we copy
the second-to-top element of the stack:
@smallexample
+ @group
1: 10 2: 10 3: 10 3: 10 4: 10
. 1: 20 2: 20 2: 20 3: 20
. 1: 30 1: 30 2: 30
. . 1: 20
.
! 10 @key{RET} 20 @key{RET} 30 @key{RET} C-u -2
@key{RET}
@end group
+ @end smallexample
@cindex Clearing the stack
@cindex Emptying the stack
! Another common idiom is @kbd{M-0 @key{DEL}}, which clears the stack.
(The @kbd{M-0} numeric prefix tells @key{DEL} to operate on the
entire stack.)
***************
*** 2117,2130 ****
or, in large mathematical notation,
@ifinfo
- @group
@example
3 * 4 * 5
2 + --------- - 9
8
6 * 7
- @end example
@end group
@end ifinfo
@tex
\turnoffactive
--- 2014,2027 ----
or, in large mathematical notation,
@ifinfo
@example
+ @group
3 * 4 * 5
2 + --------- - 9
8
6 * 7
@end group
+ @end example
@end ifinfo
@tex
\turnoffactive
***************
*** 2180,2194 ****
Still in algebraic mode, type:
- @group
@smallexample
1: (2, 3) 2: (2, 3) 1: (8, -1) 2: (8, -1) 1: (9, -1)
. 1: (1, -2) . 1: 1 .
. .
! (2,3) RET (1,-2) RET * 1 RET +
! @end smallexample
@end group
Algebraic mode allows us to enter complex numbers without pressing
an apostrophe first, but it also means we need to press @key{RET}
--- 2077,2091 ----
Still in algebraic mode, type:
@smallexample
+ @group
1: (2, 3) 2: (2, 3) 1: (8, -1) 2: (8, -1) 1: (9, -1)
. 1: (1, -2) . 1: 1 .
. .
! (2,3) @key{RET} (1,-2) @key{RET} * 1 @key{RET}
+
@end group
+ @end smallexample
Algebraic mode allows us to enter complex numbers without pressing
an apostrophe first, but it also means we need to press @key{RET}
***************
*** 2218,2231 ****
which on a traditional calculator would be done by pressing
@kbd{2 * 4 + 1 =} and then the square-root key.
- @group
@smallexample
1: 8 1: 9 1: 3
. . .
! ' 2*4 RET $+1 RET Q
! @end smallexample
@end group
@noindent
Notice that we didn't need to press an apostrophe for the @kbd{$+1},
--- 2115,2128 ----
which on a traditional calculator would be done by pressing
@kbd{2 * 4 + 1 =} and then the square-root key.
@smallexample
+ @group
1: 8 1: 9 1: 3
. . .
! ' 2*4 @key{RET} $+1 @key{RET} Q
@end group
+ @end smallexample
@noindent
Notice that we didn't need to press an apostrophe for the @kbd{$+1},
***************
*** 2237,2243 ****
@xref{Algebraic Answer 1, 1}. (@bullet{})
The notations @kbd{$$}, @kbd{$$$}, and so on stand for higher stack
! entries. For example, @kbd{' $$+$ RET} is just like typing @kbd{+}.
Algebraic formulas can include @dfn{variables}. To store in a
variable, press @kbd{s s}, then type the variable name, then press
--- 2134,2140 ----
@xref{Algebraic Answer 1, 1}. (@bullet{})
The notations @kbd{$$}, @kbd{$$$}, and so on stand for higher stack
! entries. For example, @kbd{' $$+$ @key{RET}} is just like typing @kbd{+}.
Algebraic formulas can include @dfn{variables}. To store in a
variable, press @kbd{s s}, then type the variable name, then press
***************
*** 2247,2260 ****
stores it in the variable.) A variable name should consist of one
or more letters or digits, beginning with a letter.
- @group
@smallexample
1: 17 . 1: a + a^2 1: 306
. . .
! 17 s t a RET ' a+a^2 RET =
! @end smallexample
@end group
@noindent
The @kbd{=} key @dfn{evaluates} a formula by replacing all its
--- 2144,2157 ----
stores it in the variable.) A variable name should consist of one
or more letters or digits, beginning with a letter.
@smallexample
+ @group
1: 17 . 1: a + a^2 1: 306
. . .
! 17 s t a @key{RET} ' a+a^2 @key{RET} =
@end group
+ @end smallexample
@noindent
The @kbd{=} key @dfn{evaluates} a formula by replacing all its
***************
*** 2264,2279 ****
stack either by entering its name as a formula and pressing @kbd{=},
or by using the @kbd{s r} command.
- @group
@smallexample
1: 17 2: 17 3: 17 2: 17 1: 306
. 1: 17 2: 17 1: 289 .
. 1: 2 .
.
! s r a RET ' a RET = 2 ^ +
! @end smallexample
@end group
If you press a single digit for a variable name (as in @kbd{s t 3}, you
get one of ten @dfn{quick variables} @code{q0} through @code{q9}.
--- 2161,2176 ----
stack either by entering its name as a formula and pressing @kbd{=},
or by using the @kbd{s r} command.
@smallexample
+ @group
1: 17 2: 17 3: 17 2: 17 1: 306
. 1: 17 2: 17 1: 289 .
. 1: 2 .
.
! s r a @key{RET} ' a @key{RET} = 2 ^ +
@end group
+ @end smallexample
If you press a single digit for a variable name (as in @kbd{s t 3}, you
get one of ten @dfn{quick variables} @code{q0} through @code{q9}.
***************
*** 2285,2310 ****
Any variables in an algebraic formula for which you have not stored
values are left alone, even when you evaluate the formula.
- @group
@smallexample
1: 2 a + 2 b 1: 34 + 2 b
. .
! ' 2a+2b RET =
! @end smallexample
@end group
Calls to function names which are undefined in Calc are also left
alone, as are calls for which the value is undefined.
- @group
@smallexample
1: 2 + log10(0) + log10(x) + log10(5, 6) + foo(3)
.
! ' log10(100) + log10(0) + log10(x) + log10(5,6) + foo(3) RET
! @end smallexample
@end group
@noindent
In this example, the first call to @code{log10} works, but the other
--- 2182,2207 ----
Any variables in an algebraic formula for which you have not stored
values are left alone, even when you evaluate the formula.
@smallexample
+ @group
1: 2 a + 2 b 1: 34 + 2 b
. .
! ' 2a+2b @key{RET} =
@end group
+ @end smallexample
Calls to function names which are undefined in Calc are also left
alone, as are calls for which the value is undefined.
@smallexample
+ @group
1: 2 + log10(0) + log10(x) + log10(5, 6) + foo(3)
.
! ' log10(100) + log10(0) + log10(x) + log10(5,6) + foo(3) @key{RET}
@end group
+ @end smallexample
@noindent
In this example, the first call to @code{log10} works, but the other
***************
*** 2341,2355 ****
between them. The lefthand formula is exactly like you typed it;
the righthand formula has been evaluated as if by typing @kbd{=}.
- @group
@smallexample
2: 2 + 3 => 5 2: 2 + 3 => 5
1: 2 a + 2 b => 34 + 2 b 1: 2 a + 2 b => 20 + 2 b
. .
! ' 2+3 => RET ' 2a+2b RET s = 10 s t a RET
! @end smallexample
@end group
@noindent
Notice that the instant we stored a new value in @code{a}, all
--- 2238,2252 ----
between them. The lefthand formula is exactly like you typed it;
the righthand formula has been evaluated as if by typing @kbd{=}.
@smallexample
+ @group
2: 2 + 3 => 5 2: 2 + 3 => 5
1: 2 a + 2 b => 34 + 2 b 1: 2 a + 2 b => 20 + 2 b
. .
! ' 2+3 => @key{RET} ' 2a+2b @key{RET} s = 10 s t a @key{RET}
@end group
+ @end smallexample
@noindent
Notice that the instant we stored a new value in @code{a}, all
***************
*** 2360,2374 ****
You can also ``unstore'' a variable when you are through with it:
- @group
@smallexample
2: 2 + 5 => 5
1: 2 a + 2 b => 2 a + 2 b
.
! s u a RET
! @end smallexample
@end group
We will encounter formulas involving variables and functions again
when we discuss the algebra and calculus features of the Calculator.
--- 2257,2271 ----
You can also ``unstore'' a variable when you are through with it:
@smallexample
+ @group
2: 2 + 5 => 5
1: 2 a + 2 b => 2 a + 2 b
.
! s u a @key{RET}
@end group
+ @end smallexample
We will encounter formulas involving variables and functions again
when we discuss the algebra and calculus features of the Calculator.
***************
*** 2378,2423 ****
@noindent
If you make a mistake, you can usually correct it by pressing address@hidden,
! the ``undo'' command. First, clear the stack (@kbd{M-0 DEL}) and exit
and restart Calc (@kbd{M-# M-# M-# M-#}) to make sure things start off
with a clean slate. Now:
- @group
@smallexample
1: 2 2: 2 1: 8 2: 2 1: 6
. 1: 3 . 1: 3 .
. .
! 2 RET 3 ^ U *
! @end smallexample
@end group
You can undo any number of times. Calc keeps a complete record of
all you have done since you last opened the Calc window. After the
above example, you could type:
- @group
@smallexample
1: 6 2: 2 1: 2 . .
. 1: 3 .
.
(error)
U U U U
- @end smallexample
@end group
You can also type @kbd{D} to ``redo'' a command that you have undone
mistakenly.
- @group
@smallexample
. 1: 2 2: 2 1: 6 1: 6
. 1: 3 . .
.
(error)
D D D D
- @end smallexample
@end group
@noindent
It was not possible to redo past the @cite{6}, since that was placed there
--- 2275,2320 ----
@noindent
If you make a mistake, you can usually correct it by pressing address@hidden,
! the ``undo'' command. First, clear the stack (@kbd{M-0 @key{DEL}}) and exit
and restart Calc (@kbd{M-# M-# M-# M-#}) to make sure things start off
with a clean slate. Now:
@smallexample
+ @group
1: 2 2: 2 1: 8 2: 2 1: 6
. 1: 3 . 1: 3 .
. .
! 2 @key{RET} 3 ^ U *
@end group
+ @end smallexample
You can undo any number of times. Calc keeps a complete record of
all you have done since you last opened the Calc window. After the
above example, you could type:
@smallexample
+ @group
1: 6 2: 2 1: 2 . .
. 1: 3 .
.
(error)
U U U U
@end group
+ @end smallexample
You can also type @kbd{D} to ``redo'' a command that you have undone
mistakenly.
@smallexample
+ @group
. 1: 2 2: 2 1: 6 1: 6
. 1: 3 . .
.
(error)
D D D D
@end group
+ @end smallexample
@noindent
It was not possible to redo past the @cite{6}, since that was placed there
***************
*** 2540,2552 ****
then entering a suitable number. Try pressing @kbd{p 30 @key{RET}},
then doing @kbd{1 @key{RET} 7 /} again:
- @group
@smallexample
1: 0.142857142857
2: 0.142857142857142857142857142857
.
- @end smallexample
@end group
Although the precision can be set arbitrarily high, Calc always
has to have @emph{some} value for the current precision. After
--- 2437,2449 ----
then entering a suitable number. Try pressing @kbd{p 30 @key{RET}},
then doing @kbd{1 @key{RET} 7 /} again:
@smallexample
+ @group
1: 0.142857142857
2: 0.142857142857142857142857142857
.
@end group
+ @end smallexample
Although the precision can be set arbitrarily high, Calc always
has to have @emph{some} value for the current precision. After
***************
*** 2564,2577 ****
key didn't round the number, because it doesn't do any calculation.
But the instant we pressed @kbd{+}, the number was rounded down.
- @group
@smallexample
1: 0.142857142857
2: 0.142857142857142857142857142857
3: 1.14285714286
.
- @end smallexample
@end group
@noindent
In fact, since we added a digit on the left, we had to lose one
--- 2461,2474 ----
key didn't round the number, because it doesn't do any calculation.
But the instant we pressed @kbd{+}, the number was rounded down.
@smallexample
+ @group
1: 0.142857142857
2: 0.142857142857142857142857142857
3: 1.14285714286
.
@end group
+ @end smallexample
@noindent
In fact, since we added a digit on the left, we had to lose one
***************
*** 2595,2609 ****
Let's try entering that last calculation:
- @group
@smallexample
1: 2. 2: 2. 1: 1.99506311689e3010
. 1: 10000 .
.
! 2.0 RET 10000 RET ^
! @end smallexample
@end group
@noindent
@cindex Scientific notation, entry of
--- 2492,2506 ----
Let's try entering that last calculation:
@smallexample
+ @group
1: 2. 2: 2. 1: 1.99506311689e3010
. 1: 10000 .
.
! 2.0 @key{RET} 10000 @key{RET} ^
@end group
+ @end smallexample
@noindent
@cindex Scientific notation, entry of
***************
*** 2612,2626 ****
number out fully would introduce more extra zeros than you probably
want to see. You can enter numbers in this notation, too.
- @group
@smallexample
1: 2. 2: 2. 1: 1.99506311678e3010
. 1: 10000. .
.
! 2.0 RET 1e4 RET ^
! @end smallexample
@end group
@cindex Round-off errors
@noindent
--- 2509,2523 ----
number out fully would introduce more extra zeros than you probably
want to see. You can enter numbers in this notation, too.
@smallexample
+ @group
1: 2. 2: 2. 1: 1.99506311678e3010
. 1: 10000. .
.
! 2.0 @key{RET} 1e4 @key{RET} ^
@end group
+ @end smallexample
@cindex Round-off errors
@noindent
***************
*** 2635,2649 ****
one should we trust? Let's raise the precision a bit and find
out:
- @group
@smallexample
. 1: 2. 2: 2. 1: 1.995063116880828e3010
. 1: 10000. .
.
! p 16 RET 2. RET 1e4 ^ p 12 RET
! @end smallexample
@end group
@noindent
@cindex Guard digits
--- 2532,2546 ----
one should we trust? Let's raise the precision a bit and find
out:
@smallexample
+ @group
. 1: 2. 2: 2. 1: 1.995063116880828e3010
. 1: 10000. .
.
! p 16 @key{RET} 2. @key{RET} 1e4 ^ p 12
@key{RET}
@end group
+ @end smallexample
@noindent
@cindex Guard digits
***************
*** 2672,2682 ****
supply a numeric prefix argument which says how many digits
should be displayed. As an example, let's put a few numbers
onto the stack and try some different display modes. First,
! use @kbd{M-0 DEL} to clear the stack, then enter the four
numbers shown here:
- @group
@smallexample
4: 12345 4: 12345 4: 12345 4: 12345 4: 12345
3: 12345. 3: 12300. 3: 1.2345e4 3: 1.23e4 3: 12345.000
2: 123.45 2: 123. 2: 1.2345e2 2: 1.23e2 2: 123.450
--- 2569,2579 ----
supply a numeric prefix argument which says how many digits
should be displayed. As an example, let's put a few numbers
onto the stack and try some different display modes. First,
! use @kbd{M-0 @key{DEL}} to clear the stack, then enter the four
numbers shown here:
@smallexample
+ @group
4: 12345 4: 12345 4: 12345 4: 12345 4: 12345
3: 12345. 3: 12300. 3: 1.2345e4 3: 1.23e4 3: 12345.000
2: 123.45 2: 123. 2: 1.2345e2 2: 1.23e2 2: 123.450
***************
*** 2684,2691 ****
. . . . .
d n M-3 d n d s M-3 d s M-3 d f
- @end smallexample
@end group
@noindent
Notice that when we typed @kbd{M-3 d n}, the numbers were rounded down
--- 2581,2588 ----
. . . . .
d n M-3 d n d s M-3 d s M-3 d f
@end group
+ @end smallexample
@noindent
Notice that when we typed @kbd{M-3 d n}, the numbers were rounded down
***************
*** 2706,2728 ****
prevent it from updating the stack. Anything Calc displays after the
mode-changing command will appear in the new format.
- @group
@smallexample
4: 12345 4: 12345 4: 12345 4: 12345 4: 12345
3: 12345.000 3: 12345.000 3: 12345.000 3: 1.2345e4 3: 12345.
2: 123.450 2: 123.450 2: 1.2345e1 2: 1.2345e1 2: 123.45
1: 12.345 1: 1.2345e1 1: 1.2345e2 1: 1.2345e2 1: 12.345
. . . . .
! H d s DEL U TAB d SPC d n
! @end smallexample
@end group
@noindent
Here the @kbd{H d s} command changes to scientific notation but without
updating the screen. Deleting the top stack entry and undoing it back
causes it to show up in the new format; swapping the top two stack
! entries reformats both entries. The @kbd{d SPC} command refreshes the
whole stack. The @kbd{d n} command changes back to the normal float
format; since it doesn't have an @kbd{H} prefix, it also updates all
the stack entries to be in @kbd{d n} format.
--- 2603,2625 ----
prevent it from updating the stack. Anything Calc displays after the
mode-changing command will appear in the new format.
@smallexample
+ @group
4: 12345 4: 12345 4: 12345 4: 12345 4: 12345
3: 12345.000 3: 12345.000 3: 12345.000 3: 1.2345e4 3: 12345.
2: 123.450 2: 123.450 2: 1.2345e1 2: 1.2345e1 2: 123.45
1: 12.345 1: 1.2345e1 1: 1.2345e2 1: 1.2345e2 1: 12.345
. . . . .
! H d s @key{DEL} U @key{TAB} d @key{SPC}
d n
@end group
+ @end smallexample
@noindent
Here the @kbd{H d s} command changes to scientific notation but without
updating the screen. Deleting the top stack entry and undoing it back
causes it to show up in the new format; swapping the top two stack
! entries reformats both entries. The @kbd{d @key{SPC}} command refreshes the
whole stack. The @kbd{d n} command changes back to the normal float
format; since it doesn't have an @kbd{H} prefix, it also updates all
the stack entries to be in @kbd{d n} format.
***************
*** 2864,2877 ****
a command that interprets a number as an angle, it will assume the
angle is measured in degrees. For example,
- @group
@smallexample
1: 45 1: 0.707106781187 1: 0.500000000001 1: 0.5
. . . .
45 S 2 ^ c 1
- @end smallexample
@end group
@noindent
The address@hidden command computes the sine of an angle. The sine
--- 2761,2774 ----
a command that interprets a number as an angle, it will assume the
angle is measured in degrees. For example,
@smallexample
+ @group
1: 45 1: 0.707106781187 1: 0.500000000001 1: 0.5
. . . .
45 S 2 ^ c 1
@end group
+ @end smallexample
@noindent
The address@hidden command computes the sine of an angle. The sine
***************
*** 2898,2923 ****
again, this is a shifted capital @kbd{P}. Remember, unshifted
@kbd{p} sets the precision.)
- @group
@smallexample
1: 3.14159265359 1: 0.785398163398 1: 0.707106781187
. . .
P 4 / m r S
- @end smallexample
@end group
Likewise, inverse trigonometric functions generate results in
either radians or degrees, depending on the current angular mode.
- @group
@smallexample
1: 0.707106781187 1: 0.785398163398 1: 45.
. . .
.5 Q m r I S m d U I S
- @end smallexample
@end group
@noindent
Here we compute the Inverse Sine of @c{$\sqrt{0.5}$}
--- 2795,2820 ----
again, this is a shifted capital @kbd{P}. Remember, unshifted
@kbd{p} sets the precision.)
@smallexample
+ @group
1: 3.14159265359 1: 0.785398163398 1: 0.707106781187
. . .
P 4 / m r S
@end group
+ @end smallexample
Likewise, inverse trigonometric functions generate results in
either radians or degrees, depending on the current angular mode.
@smallexample
+ @group
1: 0.707106781187 1: 0.785398163398 1: 45.
. . .
.5 Q m r I S m d U I S
@end group
+ @end smallexample
@noindent
Here we compute the Inverse Sine of @c{$\sqrt{0.5}$}
***************
*** 2927,2940 ****
Use @kbd{c d} and @kbd{c r} to convert a number from radians to degrees
and vice-versa.
- @group
@smallexample
1: 45 1: 0.785398163397 1: 45.
. . .
45 c r c d
- @end smallexample
@end group
Another interesting mode is @dfn{fraction mode}. Normally,
dividing two integers produces a floating-point result if the
--- 2824,2837 ----
Use @kbd{c d} and @kbd{c r} to convert a number from radians to degrees
and vice-versa.
@smallexample
+ @group
1: 45 1: 0.785398163397 1: 45.
. . .
45 c r c d
@end group
+ @end smallexample
Another interesting mode is @dfn{fraction mode}. Normally,
dividing two integers produces a floating-point result if the
***************
*** 2942,2956 ****
causes integer division to produce a fraction, i.e., a rational
number, instead.
- @group
@smallexample
2: 12 1: 1.33333333333 1: 4:3
1: 9 . .
.
! 12 RET 9 / m f U / m f
! @end smallexample
@end group
@noindent
In the first case, we get an approximate floating-point result.
--- 2839,2853 ----
causes integer division to produce a fraction, i.e., a rational
number, instead.
@smallexample
+ @group
2: 12 1: 1.33333333333 1: 4:3
1: 9 . .
.
! 12 @key{RET} 9 / m f U / m f
@end group
+ @end smallexample
@noindent
In the first case, we get an approximate floating-point result.
***************
*** 2975,2988 ****
evaluates-to operator you can get commands like @kbd{m f} to
recompute for you.
- @group
@smallexample
1: 12 / 9 => 1.33333333333 1: 12 / 9 => 1.333 1: 12 / 9 => 4:3
. . .
! ' 12/9 => RET p 4 RET m f
! @end smallexample
@end group
@noindent
In this example, the righthand side of the @samp{=>} operator
--- 2872,2885 ----
evaluates-to operator you can get commands like @kbd{m f} to
recompute for you.
@smallexample
+ @group
1: 12 / 9 => 1.33333333333 1: 12 / 9 => 1.333 1: 12 / 9 => 4:3
. . .
! ' 12/9 => @key{RET} p 4 @key{RET} m f
@end group
+ @end smallexample
@noindent
In this example, the righthand side of the @samp{=>} operator
***************
*** 3003,3016 ****
and pushes back a result. The @kbd{n} and @kbd{&} keys perform
change-sign and reciprocal operations, respectively.
- @group
@smallexample
1: 5 1: 0.2 1: 5. 1: -5. 1: 5.
. . . . .
5 & & n n
- @end smallexample
@end group
@cindex Binary operators
You can apply a ``binary operator'' like @kbd{+} across any number of
--- 2900,2913 ----
and pushes back a result. The @kbd{n} and @kbd{&} keys perform
change-sign and reciprocal operations, respectively.
@smallexample
+ @group
1: 5 1: 0.2 1: 5. 1: -5. 1: 5.
. . . . .
5 & & n n
@end group
+ @end smallexample
@cindex Binary operators
You can apply a ``binary operator'' like @kbd{+} across any number of
***************
*** 3018,3049 ****
pairwise to several stack elements along with the top one if you use
a negative prefix.
- @group
@smallexample
3: 2 1: 9 3: 2 4: 2 3: 12
2: 3 . 2: 3 3: 3 2: 13
1: 4 1: 4 2: 4 1: 14
. . 1: 10 .
.
! 2 RET 3 RET 4 M-3 + U 10 M-- M-3 +
! @end smallexample
@end group
@cindex Unary operators
You can apply a ``unary operator'' like @kbd{&} to the top @var{n}
stack entries with a numeric prefix, too.
- @group
@smallexample
3: 2 3: 0.5 3: 0.5
2: 3 2: 0.333333333333 2: 3.
1: 4 1: 0.25 1: 4.
. . .
! 2 RET 3 RET 4 M-3 & M-2 &
! @end smallexample
@end group
Notice that the results here are left in floating-point form.
We can convert them back to integers by pressing @kbd{F}, the
--- 2915,2946 ----
pairwise to several stack elements along with the top one if you use
a negative prefix.
@smallexample
+ @group
3: 2 1: 9 3: 2 4: 2 3: 12
2: 3 . 2: 3 3: 3 2: 13
1: 4 1: 4 2: 4 1: 14
. . 1: 10 .
.
! 2 @key{RET} 3 @key{RET} 4 M-3 + U 10 M--
M-3 +
@end group
+ @end smallexample
@cindex Unary operators
You can apply a ``unary operator'' like @kbd{&} to the top @var{n}
stack entries with a numeric prefix, too.
@smallexample
+ @group
3: 2 3: 0.5 3: 0.5
2: 3 2: 0.333333333333 2: 3.
1: 4 1: 0.25 1: 4.
. . .
! 2 @key{RET} 3 @key{RET} 4 M-3 & M-2 &
@end group
+ @end smallexample
Notice that the results here are left in floating-point form.
We can convert them back to integers by pressing @kbd{F}, the
***************
*** 3051,3058 ****
integer. There is also @kbd{R}, which rounds to the nearest
integer.
- @group
@smallexample
7: 2. 7: 2 7: 2
6: 2.4 6: 2 6: 2
5: 2.5 5: 2 5: 3
--- 2948,2955 ----
integer. There is also @kbd{R}, which rounds to the nearest
integer.
@smallexample
+ @group
7: 2. 7: 2 7: 2
6: 2.4 6: 2 6: 2
5: 2.5 5: 2 5: 3
***************
*** 3063,3070 ****
. . .
M-7 F U M-7 R
- @end smallexample
@end group
Since dividing-and-flooring (i.e., ``integer quotient'') is such a
common operation, Calc provides a special command for that purpose, the
--- 2960,2967 ----
. . .
M-7 F U M-7 R
@end group
+ @end smallexample
Since dividing-and-flooring (i.e., ``integer quotient'') is such a
common operation, Calc provides a special command for that purpose, the
***************
*** 3072,3098 ****
computes the remainder that would arise from a @kbd{\} operation, i.e.,
the ``modulo'' of two numbers. For example,
- @group
@smallexample
2: 1234 1: 12 2: 1234 1: 34
1: 100 . 1: 100 .
. .
! 1234 RET 100 \ U %
! @end smallexample
@end group
These commands actually work for any real numbers, not just integers.
- @group
@smallexample
2: 3.1415 1: 3 2: 3.1415 1: 0.1415
1: 1 . 1: 1 .
. .
! 3.1415 RET 1 \ U %
! @end smallexample
@end group
(@bullet{}) @strong{Exercise 1.} The @kbd{\} command would appear to be a
frill, since you could always do the same thing with @kbd{/ F}. Think
--- 2969,2995 ----
computes the remainder that would arise from a @kbd{\} operation, i.e.,
the ``modulo'' of two numbers. For example,
@smallexample
+ @group
2: 1234 1: 12 2: 1234 1: 34
1: 100 . 1: 100 .
. .
! 1234 @key{RET} 100 \ U %
@end group
+ @end smallexample
These commands actually work for any real numbers, not just integers.
@smallexample
+ @group
2: 3.1415 1: 3 2: 3.1415 1: 0.1415
1: 1 . 1: 1 .
. .
! 3.1415 @key{RET} 1 \ U %
@end group
+ @end smallexample
(@bullet{}) @strong{Exercise 1.} The @kbd{\} command would appear to be a
frill, since you could always do the same thing with @kbd{/ F}. Think
***************
*** 3112,3126 ****
arbitrarily pick @i{-64} degrees as a good value for @cite{x}. With
the angular mode set to degrees (type @address@hidden d}}), do:
- @group
@smallexample
2: -64 2: -64 2: -0.89879 2: -0.89879 1: 1.
1: -64 1: -0.89879 1: -64 1: 0.43837 .
. . . .
! 64 n RET RET S TAB C f h
! @end smallexample
@end group
@noindent
(For brevity, we're showing only five digits of the results here.
--- 3009,3023 ----
arbitrarily pick @i{-64} degrees as a good value for @cite{x}. With
the angular mode set to degrees (type @address@hidden d}}), do:
@smallexample
+ @group
2: -64 2: -64 2: -0.89879 2: -0.89879 1: 1.
1: -64 1: -0.89879 1: -64 1: 0.43837 .
. . . .
! 64 n @key{RET} @key{RET} S @key{TAB} C
f h
@end group
+ @end smallexample
@noindent
(For brevity, we're showing only five digits of the results here.
***************
*** 3131,3161 ****
Another identity is @c{$\displaystyle\tan x = {\sin x \over \cos x}$}
@cite{tan(x) = sin(x) / cos(x)}.
- @group
@smallexample
2: -0.89879 1: -2.0503 1: -64.
1: 0.43837 . .
.
U / I T
- @end smallexample
@end group
A physical interpretation of this calculation is that if you move
@cite{0.89879} units downward and @cite{0.43837} units to the right,
your direction of motion is @i{-64} degrees from horizontal. Suppose
we move in the opposite direction, up and to the left:
- @group
@smallexample
2: -0.89879 2: 0.89879 1: -2.0503 1: -64.
1: 0.43837 1: -0.43837 . .
. .
U U M-2 n / I T
- @end smallexample
@end group
@noindent
How can the angle be the same? The answer is that the @kbd{/} operation
--- 3028,3058 ----
Another identity is @c{$\displaystyle\tan x = {\sin x \over \cos x}$}
@cite{tan(x) = sin(x) / cos(x)}.
@smallexample
+ @group
2: -0.89879 1: -2.0503 1: -64.
1: 0.43837 . .
.
U / I T
@end group
+ @end smallexample
A physical interpretation of this calculation is that if you move
@cite{0.89879} units downward and @cite{0.43837} units to the right,
your direction of motion is @i{-64} degrees from horizontal. Suppose
we move in the opposite direction, up and to the left:
@smallexample
+ @group
2: -0.89879 2: 0.89879 1: -2.0503 1: -64.
1: 0.43837 1: -0.43837 . .
. .
U U M-2 n / I T
@end group
+ @end smallexample
@noindent
How can the angle be the same? The answer is that the @kbd{/} operation
***************
*** 3166,3181 ****
Since you feed it the two original numbers, it has enough information
to give you a full 360-degree answer.
- @group
@smallexample
2: 0.89879 1: 116. 3: 116. 2: 116. 1: 180.
1: -0.43837 . 2: -0.89879 1: -64. .
. 1: 0.43837 .
.
! U U f T M-RET M-2 n f T -
! @end smallexample
@end group
@noindent
The resulting angles differ by 180 degrees; in other words, they
--- 3063,3078 ----
Since you feed it the two original numbers, it has enough information
to give you a full 360-degree answer.
@smallexample
+ @group
2: 0.89879 1: 116. 3: 116. 2: 116. 1: 180.
1: -0.43837 . 2: -0.89879 1: -64. .
. 1: 0.43837 .
.
! U U f T address@hidden M-2 n f T -
@end group
+ @end smallexample
@noindent
The resulting angles differ by 180 degrees; in other words, they
***************
*** 3196,3210 ****
@cite{cosh(x)^2 - sinh(x)^2} that always equals one.
Let's try to verify this address@hidden
- @group
@smallexample
2: -64 2: -64 2: -64 2: 9.7192e54 2: 9.7192e54
1: -64 1: -3.1175e27 1: 9.7192e54 1: -64 1: 9.7192e54
. . . . .
! 64 n RET RET H C 2 ^ TAB H S 2 ^
! @end smallexample
@end group
@noindent
@cindex Roundoff errors, examples
--- 3093,3107 ----
@cite{cosh(x)^2 - sinh(x)^2} that always equals one.
Let's try to verify this address@hidden
@smallexample
+ @group
2: -64 2: -64 2: -64 2: 9.7192e54 2: 9.7192e54
1: -64 1: -3.1175e27 1: 9.7192e54 1: -64 1: 9.7192e54
. . . . .
! 64 n @key{RET} @key{RET} H C 2 ^ @key{TAB}
H S 2 ^
@end group
+ @end smallexample
@noindent
@cindex Roundoff errors, examples
***************
*** 3228,3241 ****
@cite{e} normally but use base-10 instead if you use the Hyperbolic
prefix.
- @group
@smallexample
1: 1000 1: 6.9077 1: 1000 1: 3
. . . .
1000 L U H L
- @end smallexample
@end group
@noindent
First, we mistakenly compute a natural logarithm. Then we undo
--- 3125,3138 ----
@cite{e} normally but use base-10 instead if you use the Hyperbolic
prefix.
@smallexample
+ @group
1: 1000 1: 6.9077 1: 1000 1: 3
. . . .
1000 L U H L
@end group
+ @end smallexample
@noindent
First, we mistakenly compute a natural logarithm. Then we undo
***************
*** 3244,3258 ****
The @kbd{B} key computes a general address@hidden logarithm for any
value of @var{b}.
- @group
@smallexample
2: 1000 1: 3 1: 1000. 2: 1000. 1: 6.9077
1: 10 . . 1: 2.71828 .
. .
! 1000 RET 10 B H E H P B
! @end smallexample
@end group
@noindent
Here we first use @kbd{B} to compute the base-10 logarithm, then use
--- 3141,3155 ----
The @kbd{B} key computes a general address@hidden logarithm for any
value of @var{b}.
@smallexample
+ @group
2: 1000 1: 3 1: 1000. 2: 1000. 1: 6.9077
1: 10 . . 1: 2.71828 .
. .
! 1000 @key{RET} 10 B H E H P B
@end group
+ @end smallexample
@noindent
Here we first use @kbd{B} to compute the base-10 logarithm, then use
***************
*** 3280,3293 ****
and statistics. You may be familiar with the @dfn{factorial} function,
which computes the product of all the integers up to a given number.
- @group
@smallexample
1: 100 1: 93326215443... 1: 100. 1: 9.3326e157
. . . .
100 ! U c f !
- @end smallexample
@end group
@noindent
Recall, the @kbd{c f} command converts the integer or fraction at the
--- 3177,3190 ----
and statistics. You may be familiar with the @dfn{factorial} function,
which computes the product of all the integers up to a given number.
@smallexample
+ @group
1: 100 1: 93326215443... 1: 100. 1: 9.3326e157
. . . .
100 ! U c f !
@end group
+ @end smallexample
@noindent
Recall, the @kbd{c f} command converts the integer or fraction at the
***************
*** 3303,3318 ****
@cite{gamma(n)}
(which is itself available as the @kbd{f g} command).
- @group
@smallexample
3: 4. 3: 24. 1: 5.5 1: 52.342777847
2: 4.5 2: 52.3427777847 . .
1: 5. 1: 120.
. .
! M-3 ! M-0 DEL 5.5 f g
! @end smallexample
@end group
@noindent
Here we verify the identity @c{$n! = \Gamma(n+1)$}
--- 3200,3215 ----
@cite{gamma(n)}
(which is itself available as the @kbd{f g} command).
@smallexample
+ @group
3: 4. 3: 24. 1: 5.5 1: 52.342777847
2: 4.5 2: 52.3427777847 . .
1: 5. 1: 120.
. .
! M-3 ! M-0 @key{DEL} 5.5 f g
@end group
+ @end smallexample
@noindent
Here we verify the identity @c{$n! = \Gamma(n+1)$}
***************
*** 3331,3345 ****
combinatorics and number theory. Here we compute the binomial
coefficient 30-choose-20, then determine its prime factorization.
- @group
@smallexample
2: 30 1: 30045015 1: [3, 3, 5, 7, 11, 13, 23, 29]
1: 20 . .
.
! 30 RET 20 k c k f
! @end smallexample
@end group
@noindent
You can verify these prime factors by using @kbd{v u} to ``unpack''
--- 3228,3242 ----
combinatorics and number theory. Here we compute the binomial
coefficient 30-choose-20, then determine its prime factorization.
@smallexample
+ @group
2: 30 1: 30045015 1: [3, 3, 5, 7, 11, 13, 23, 29]
1: 20 . .
.
! 30 @key{RET} 20 k c k f
@end group
+ @end smallexample
@noindent
You can verify these prime factors by using @kbd{v u} to ``unpack''
***************
*** 3352,3365 ****
10000 entries. It's best to use a prime number as the actual size
of a hash table. Calc can compute the next prime number after 10000:
- @group
@smallexample
1: 10000 1: 10007 1: 9973
. . .
10000 k n I k n
- @end smallexample
@end group
@noindent
Just for kicks we've also computed the next prime @emph{less} than
--- 3249,3262 ----
10000 entries. It's best to use a prime number as the actual size
of a hash table. Calc can compute the next prime number after 10000:
@smallexample
+ @group
1: 10000 1: 10007 1: 9973
. . .
10000 k n I k n
@end group
+ @end smallexample
@noindent
Just for kicks we've also computed the next prime @emph{less} than
***************
*** 3396,3410 ****
If you add two vectors, the result is a vector of the sums of the
elements, taken pairwise.
- @group
@smallexample
1: [1, 2, 3] 2: [1, 2, 3] 1: [8, 8, 3]
. 1: [7, 6, 0] .
.
[1,2,3] s 1 [7 6 0] s 2 +
- @end smallexample
@end group
@noindent
Note that we can separate the vector elements with either commas or
--- 3293,3307 ----
If you add two vectors, the result is a vector of the sums of the
elements, taken pairwise.
@smallexample
+ @group
1: [1, 2, 3] 2: [1, 2, 3] 1: [8, 8, 3]
. 1: [7, 6, 0] .
.
[1,2,3] s 1 [7 6 0] s 2 +
@end group
+ @end smallexample
@noindent
Note that we can separate the vector elements with either commas or
***************
*** 3416,3430 ****
of the elements taken pairwise. This is called the @dfn{dot product}
of the vectors.
- @group
@smallexample
2: [1, 2, 3] 1: 19
1: [7, 6, 0] .
.
r 1 r 2 *
- @end smallexample
@end group
@cindex Dot product
The dot product of two vectors is equal to the product of their
--- 3313,3327 ----
of the elements taken pairwise. This is called the @dfn{dot product}
of the vectors.
@smallexample
+ @group
2: [1, 2, 3] 1: 19
1: [7, 6, 0] .
.
r 1 r 2 *
@end group
+ @end smallexample
@cindex Dot product
The dot product of two vectors is equal to the product of their
***************
*** 3434,3449 ****
(absolute value) command can be used to compute the length of a
vector.
- @group
@smallexample
3: 19 3: 19 1: 0.550782 1: 56.579
2: [1, 2, 3] 2: 3.741657 . .
1: [7, 6, 0] 1: 9.219544
. .
! M-RET M-2 A * / I C
! @end smallexample
@end group
@noindent
First we recall the arguments to the dot product command, then
--- 3331,3346 ----
(absolute value) command can be used to compute the length of a
vector.
@smallexample
+ @group
3: 19 3: 19 1: 0.550782 1: 56.579
2: [1, 2, 3] 2: 3.741657 . .
1: [7, 6, 0] 1: 9.219544
. .
! address@hidden M-2 A * / I C
@end group
+ @end smallexample
@noindent
First we recall the arguments to the dot product command, then
***************
*** 3462,3477 ****
defined only for three-dimensional vectors. Let's double-check
our computation of the angle using the cross product.
- @group
@smallexample
2: [1, 2, 3] 3: [-18, 21, -8] 1: [-0.52, 0.61, -0.23] 1: 56.579
1: [7, 6, 0] 2: [1, 2, 3] . .
. 1: [7, 6, 0]
.
! r 1 r 2 V C s 3 M-RET M-2 A * / A I S
! @end smallexample
@end group
@noindent
First we recall the original vectors and compute their cross product,
--- 3359,3374 ----
defined only for three-dimensional vectors. Let's double-check
our computation of the angle using the cross product.
@smallexample
+ @group
2: [1, 2, 3] 3: [-18, 21, -8] 1: [-0.52, 0.61, -0.23] 1: 56.579
1: [7, 6, 0] 2: [1, 2, 3] . .
. 1: [7, 6, 0]
.
! r 1 r 2 V C s 3 address@hidden M-2 A * / A I S
@end group
+ @end smallexample
@noindent
First we recall the original vectors and compute their cross product,
***************
*** 3490,3504 ****
to get zero, since the cosine of 90 degrees is zero. Let's check
that the cross product is indeed perpendicular to both inputs:
- @group
@smallexample
2: [1, 2, 3] 1: 0 2: [7, 6, 0] 1: 0
1: [-18, 21, -8] . 1: [-18, 21, -8] .
. .
! r 1 r 3 * DEL r 2 r 3 *
! @end smallexample
@end group
@cindex Normalizing a vector
@cindex Unit vectors
--- 3387,3401 ----
to get zero, since the cosine of 90 degrees is zero. Let's check
that the cross product is indeed perpendicular to both inputs:
@smallexample
+ @group
2: [1, 2, 3] 1: 0 2: [7, 6, 0] 1: 0
1: [-18, 21, -8] . 1: [-18, 21, -8] .
. .
! r 1 r 3 * @key{DEL} r 2 r 3 *
@end group
+ @end smallexample
@cindex Normalizing a vector
@cindex Unit vectors
***************
*** 3523,3537 ****
also use the semicolon character to enter a matrix. We'll show
both methods here:
- @group
@smallexample
1: [ [ 1, 2, 3 ] 1: [ [ 1, 2, 3 ]
[ 4, 5, 6 ] ] [ 4, 5, 6 ] ]
. .
! [[1 2 3] [4 5 6]] ' [1 2 3; 4 5 6] RET
! @end smallexample
@end group
@noindent
We'll be using this matrix again, so type @kbd{s 4} to save it now.
--- 3420,3434 ----
also use the semicolon character to enter a matrix. We'll show
both methods here:
@smallexample
+ @group
1: [ [ 1, 2, 3 ] 1: [ [ 1, 2, 3 ]
[ 4, 5, 6 ] ] [ 4, 5, 6 ] ]
. .
! [[1 2 3] [4 5 6]] ' [1 2 3; 4 5 6] @key{RET}
@end group
+ @end smallexample
@noindent
We'll be using this matrix again, so type @kbd{s 4} to save it now.
***************
*** 3549,3563 ****
If we try to duplicate this matrix and multiply it by itself,
the dimensions are wrong and the multiplication cannot take place:
- @group
@smallexample
1: [ [ 1, 2, 3 ] * [ [ 1, 2, 3 ]
[ 4, 5, 6 ] ] [ 4, 5, 6 ] ]
.
! RET *
! @end smallexample
@end group
@noindent
Though rather hard to read, this is a formula which shows the product
--- 3446,3460 ----
If we try to duplicate this matrix and multiply it by itself,
the dimensions are wrong and the multiplication cannot take place:
@smallexample
+ @group
1: [ [ 1, 2, 3 ] * [ [ 1, 2, 3 ]
[ 4, 5, 6 ] ] [ 4, 5, 6 ] ]
.
! @key{RET} *
@end group
+ @end smallexample
@noindent
Though rather hard to read, this is a formula which shows the product
***************
*** 3566,3573 ****
We can multiply the matrices if we @dfn{transpose} one of them first.
- @group
@smallexample
2: [ [ 1, 2, 3 ] 1: [ [ 14, 32 ] 1: [ [ 17, 22, 27 ]
[ 4, 5, 6 ] ] [ 32, 77 ] ] [ 22, 29, 36 ]
1: [ [ 1, 4 ] . [ 27, 36, 45 ] ]
--- 3463,3470 ----
We can multiply the matrices if we @dfn{transpose} one of them first.
@smallexample
+ @group
2: [ [ 1, 2, 3 ] 1: [ [ 14, 32 ] 1: [ [ 17, 22, 27 ]
[ 4, 5, 6 ] ] [ 32, 77 ] ] [ 22, 29, 36 ]
1: [ [ 1, 4 ] . [ 27, 36, 45 ] ]
***************
*** 3575,3583 ****
[ 3, 6 ] ]
.
! U v t * U TAB *
! @end smallexample
@end group
Matrix multiplication is not commutative; indeed, switching the
order of the operands can even change the dimensions of the result
--- 3472,3480 ----
[ 3, 6 ] ]
.
! U v t * U @key{TAB} *
@end group
+ @end smallexample
Matrix multiplication is not commutative; indeed, switching the
order of the operands can even change the dimensions of the result
***************
*** 3588,3603 ****
on. The result is a plain vector which should also be interpreted
as a row or column as appropriate.
- @group
@smallexample
2: [ [ 1, 2, 3 ] 1: [14, 32]
[ 4, 5, 6 ] ] .
1: [1, 2, 3]
.
r 4 r 1 *
- @end smallexample
@end group
Multiplying in the other order wouldn't work because the number of
rows in the matrix is different from the number of elements in the
--- 3485,3500 ----
on. The result is a plain vector which should also be interpreted
as a row or column as appropriate.
@smallexample
+ @group
2: [ [ 1, 2, 3 ] 1: [14, 32]
[ 4, 5, 6 ] ] .
1: [1, 2, 3]
.
r 4 r 1 *
@end group
+ @end smallexample
Multiplying in the other order wouldn't work because the number of
rows in the matrix is different from the number of elements in the
***************
*** 3615,3622 ****
by an identity matrix, on the left or on the right, always produces
the original matrix.
- @group
@smallexample
1: [ [ 1, 2, 3 ] 2: [ [ 1, 2, 3 ] 1: [ [ 1, 2, 3 ]
[ 4, 5, 6 ] ] [ 4, 5, 6 ] ] [ 4, 5, 6 ] ]
. 1: [ [ 1, 0, 0 ] .
--- 3512,3519 ----
by an identity matrix, on the left or on the right, always produces
the original matrix.
@smallexample
+ @group
1: [ [ 1, 2, 3 ] 2: [ [ 1, 2, 3 ] 1: [ [ 1, 2, 3 ]
[ 4, 5, 6 ] ] [ 4, 5, 6 ] ] [ 4, 5, 6 ] ]
. 1: [ [ 1, 0, 0 ] .
***************
*** 3624,3648 ****
[ 0, 0, 1 ] ]
.
! r 4 v i 3 RET *
! @end smallexample
@end group
If a matrix is square, it is often possible to find its @dfn{inverse},
that is, a matrix which, when multiplied by the original matrix, yields
an identity matrix. The @kbd{&} (reciprocal) key also computes the
inverse of a matrix.
- @group
@smallexample
1: [ [ 1, 2, 3 ] 1: [ [ -2.4, 1.2, -0.2 ]
[ 4, 5, 6 ] [ 2.8, -1.4, 0.4 ]
[ 7, 6, 0 ] ] [ -0.73333, 0.53333, -0.2 ] ]
. .
r 4 r 2 | s 5 &
- @end smallexample
@end group
@noindent
The vertical bar @kbd{|} @dfn{concatenates} numbers, vectors, and
--- 3521,3545 ----
[ 0, 0, 1 ] ]
.
! r 4 v i 3 @key{RET} *
@end group
+ @end smallexample
If a matrix is square, it is often possible to find its @dfn{inverse},
that is, a matrix which, when multiplied by the original matrix, yields
an identity matrix. The @kbd{&} (reciprocal) key also computes the
inverse of a matrix.
@smallexample
+ @group
1: [ [ 1, 2, 3 ] 1: [ [ -2.4, 1.2, -0.2 ]
[ 4, 5, 6 ] [ 2.8, -1.4, 0.4 ]
[ 7, 6, 0 ] ] [ -0.73333, 0.53333, -0.2 ] ]
. .
r 4 r 2 | s 5 &
@end group
+ @end smallexample
@noindent
The vertical bar @kbd{|} @dfn{concatenates} numbers, vectors, and
***************
*** 3651,3666 ****
We can multiply these two matrices in either order to get an identity.
- @group
@smallexample
1: [ [ 1., 0., 0. ] 1: [ [ 1., 0., 0. ]
[ 0., 1., 0. ] [ 0., 1., 0. ]
[ 0., 0., 1. ] ] [ 0., 0., 1. ] ]
. .
! M-RET * U TAB *
! @end smallexample
@end group
@cindex Systems of linear equations
@cindex Linear equations, systems of
--- 3548,3563 ----
We can multiply these two matrices in either order to get an identity.
@smallexample
+ @group
1: [ [ 1., 0., 0. ] 1: [ [ 1., 0., 0. ]
[ 0., 1., 0. ] [ 0., 1., 0. ]
[ 0., 0., 1. ] ] [ 0., 0., 1. ] ]
. .
! address@hidden * U @key{TAB} *
@end group
+ @end smallexample
@cindex Systems of linear equations
@cindex Linear equations, systems of
***************
*** 3716,3723 ****
We can solve this system of equations by multiplying both sides by the
inverse of the matrix. Calc can do this all in one step:
- @group
@smallexample
2: [6, 2, 3] 1: [-12.6, 15.2, -3.93333]
1: [ [ 1, 2, 3 ] .
[ 4, 5, 6 ]
--- 3613,3620 ----
We can solve this system of equations by multiplying both sides by the
inverse of the matrix. Calc can do this all in one step:
@smallexample
+ @group
2: [6, 2, 3] 1: [-12.6, 15.2, -3.93333]
1: [ [ 1, 2, 3 ] .
[ 4, 5, 6 ]
***************
*** 3725,3732 ****
.
[6,2,3] r 5 /
- @end smallexample
@end group
@noindent
The result is the @cite{[a, b, c]} vector that solves the equations.
--- 3622,3629 ----
.
[6,2,3] r 5 /
@end group
+ @end smallexample
@noindent
The result is the @cite{[a, b, c]} vector that solves the equations.
***************
*** 3735,3751 ****
Let's verify this solution:
- @group
@smallexample
2: [ [ 1, 2, 3 ] 1: [6., 2., 3.]
[ 4, 5, 6 ] .
[ 7, 6, 0 ] ]
1: [-12.6, 15.2, -3.93333]
.
! r 5 TAB *
! @end smallexample
@end group
@noindent
Note that we had to be careful about the order in which we multiplied
--- 3632,3648 ----
Let's verify this solution:
@smallexample
+ @group
2: [ [ 1, 2, 3 ] 1: [6., 2., 3.]
[ 4, 5, 6 ] .
[ 7, 6, 0 ] ]
1: [-12.6, 15.2, -3.93333]
.
! r 5 @key{TAB} *
@end group
+ @end smallexample
@noindent
Note that we had to be careful about the order in which we multiplied
***************
*** 3851,3891 ****
You can pack and unpack stack entries into vectors:
- @group
@smallexample
3: 10 1: [10, 20, 30] 3: 10
2: 20 . 2: 20
1: 30 1: 30
. .
M-3 v p v u
- @end smallexample
@end group
You can also build vectors out of consecutive integers, or out
of many copies of a given value:
- @group
@smallexample
1: [1, 2, 3, 4] 2: [1, 2, 3, 4] 2: [1, 2, 3, 4]
. 1: 17 1: [17, 17, 17, 17]
. .
! v x 4 RET 17 v b 4 RET
! @end smallexample
@end group
You can apply an operator to every element of a vector using the
@dfn{map} command.
- @group
@smallexample
1: [17, 34, 51, 68] 1: [289, 1156, 2601, 4624] 1: [17, 34, 51, 68]
. . .
V M * 2 V M ^ V M Q
- @end smallexample
@end group
@noindent
In the first step, we multiply the vector of integers by the vector
--- 3748,3788 ----
You can pack and unpack stack entries into vectors:
@smallexample
+ @group
3: 10 1: [10, 20, 30] 3: 10
2: 20 . 2: 20
1: 30 1: 30
. .
M-3 v p v u
@end group
+ @end smallexample
You can also build vectors out of consecutive integers, or out
of many copies of a given value:
@smallexample
+ @group
1: [1, 2, 3, 4] 2: [1, 2, 3, 4] 2: [1, 2, 3, 4]
. 1: 17 1: [17, 17, 17, 17]
. .
! v x 4 @key{RET} 17 v b 4 @key{RET}
@end group
+ @end smallexample
You can apply an operator to every element of a vector using the
@dfn{map} command.
@smallexample
+ @group
1: [17, 34, 51, 68] 1: [289, 1156, 2601, 4624] 1: [17, 34, 51, 68]
. . .
V M * 2 V M ^ V M Q
@end group
+ @end smallexample
@noindent
In the first step, we multiply the vector of integers by the vector
***************
*** 3903,3916 ****
For example, reducing @samp{*} computes the product of all the
elements in the vector:
- @group
@smallexample
1: 123123 1: [3, 7, 11, 13, 41] 1: 123123
. . .
123123 k f V R *
- @end smallexample
@end group
@noindent
In this example, we decompose 123123 into its prime factors, then
--- 3800,3813 ----
For example, reducing @samp{*} computes the product of all the
elements in the vector:
@smallexample
+ @group
1: 123123 1: [3, 7, 11, 13, 41] 1: 123123
. . .
123123 k f V R *
@end group
+ @end smallexample
@noindent
In this example, we decompose 123123 into its prime factors, then
***************
*** 3919,3933 ****
We could compute a dot product ``by hand'' using mapping and
reduction:
- @group
@smallexample
2: [1, 2, 3] 1: [7, 12, 0] 1: 19
1: [7, 6, 0] . .
.
r 1 r 2 V M * V R +
- @end smallexample
@end group
@noindent
Recalling two vectors from the previous section, we compute the
--- 3816,3830 ----
We could compute a dot product ``by hand'' using mapping and
reduction:
@smallexample
+ @group
2: [1, 2, 3] 1: [7, 12, 0] 1: 19
1: [7, 6, 0] . .
.
r 1 r 2 V M * V R +
@end group
+ @end smallexample
@noindent
Recalling two vectors from the previous section, we compute the
***************
*** 3938,3951 ****
@kbd{V U}. This produces a vector of the intermediate results from
a corresponding reduction. Here we compute a table of factorials:
- @group
@smallexample
1: [1, 2, 3, 4, 5, 6] 1: [1, 2, 6, 24, 120, 720]
. .
! v x 6 RET V U *
! @end smallexample
@end group
Calc allows vectors to grow as large as you like, although it gets
rather slow if vectors have more than about a hundred elements.
--- 3835,3848 ----
@kbd{V U}. This produces a vector of the intermediate results from
a corresponding reduction. Here we compute a table of factorials:
@smallexample
+ @group
1: [1, 2, 3, 4, 5, 6] 1: [1, 2, 6, 24, 120, 720]
. .
! v x 6 @key{RET} V U *
@end group
+ @end smallexample
Calc allows vectors to grow as large as you like, although it gets
rather slow if vectors have more than about a hundred elements.
***************
*** 3954,3980 ****
(if your computer is very fast you may need to substitute a larger
vector size).
- @group
@smallexample
1: [1, 2, 3, 4, ... 1: [2, 3, 4, 5, ...
. .
! v x 500 RET 1 V M +
! @end smallexample
@end group
Now press @kbd{v .} (the letter @kbd{v}, then a period) and try the
experiment again. In @kbd{v .} mode, long vectors are displayed
``abbreviated'' like this:
- @group
@smallexample
1: [1, 2, 3, ..., 500] 1: [2, 3, 4, ..., 501]
. .
! v x 500 RET 1 V M +
! @end smallexample
@end group
@noindent
(where now the @samp{...} is actually part of the Calc display).
--- 3851,3877 ----
(if your computer is very fast you may need to substitute a larger
vector size).
@smallexample
+ @group
1: [1, 2, 3, 4, ... 1: [2, 3, 4, 5, ...
. .
! v x 500 @key{RET} 1 V M +
@end group
+ @end smallexample
Now press @kbd{v .} (the letter @kbd{v}, then a period) and try the
experiment again. In @kbd{v .} mode, long vectors are displayed
``abbreviated'' like this:
@smallexample
+ @group
1: [1, 2, 3, ..., 500] 1: [2, 3, 4, ..., 501]
. .
! v x 500 @key{RET} 1 V M +
@end group
+ @end smallexample
@noindent
(where now the @samp{...} is actually part of the Calc display).
***************
*** 4032,4051 ****
Position the cursor at the upper-left corner of this table, just
to the left of the @cite{1.34}. Press @kbd{C-@@} to set the mark.
! (On your system this may be @kbd{C-2}, @kbd{C-SPC}, or @kbd{NUL}.)
Now position the cursor to the lower-right, just after the @cite{1.354}.
You have now defined this region as an Emacs ``rectangle.'' Still
in the Info buffer, type @kbd{M-# r}. This command
(@code{calc-grab-rectangle}) will pop you back into the Calculator, with
the contents of the rectangle you specified in the form of a address@hidden
- @group
@smallexample
1: [ [ 1.34, 0.234 ]
[ 1.41, 0.298 ]
@dots{}
- @end smallexample
@end group
@noindent
(You may wish to use @kbd{v .} mode to abbreviate the display of this
--- 3929,3948 ----
Position the cursor at the upper-left corner of this table, just
to the left of the @cite{1.34}. Press @kbd{C-@@} to set the mark.
! (On your system this may be @kbd{C-2}, @address@hidden, or @kbd{NUL}.)
Now position the cursor to the lower-right, just after the @cite{1.354}.
You have now defined this region as an Emacs ``rectangle.'' Still
in the Info buffer, type @kbd{M-# r}. This command
(@code{calc-grab-rectangle}) will pop you back into the Calculator, with
the contents of the rectangle you specified in the form of a address@hidden
@smallexample
+ @group
1: [ [ 1.34, 0.234 ]
[ 1.41, 0.298 ]
@dots{}
@end group
+ @end smallexample
@noindent
(You may wish to use @kbd{v .} mode to abbreviate the display of this
***************
*** 4056,4082 ****
just a vector of vectors. So we can unpack the matrix into a pair
of row vectors on the stack.
- @group
@smallexample
1: [ [ 1.34, 1.41, 1.49, ... ] 2: [1.34, 1.41, 1.49, ... ]
[ 0.234, 0.298, 0.402, ... ] ] 1: [0.234, 0.298, 0.402, ... ]
. .
v t v u
- @end smallexample
@end group
@noindent
Let's store these in quick variables 1 and 2, respectively.
- @group
@smallexample
1: [1.34, 1.41, 1.49, ... ] .
.
t 2 t 1
- @end smallexample
@end group
@noindent
(Recall that @kbd{t 2} is a variant of @kbd{s 2} that removes the
--- 3953,3979 ----
just a vector of vectors. So we can unpack the matrix into a pair
of row vectors on the stack.
@smallexample
+ @group
1: [ [ 1.34, 1.41, 1.49, ... ] 2: [1.34, 1.41, 1.49, ... ]
[ 0.234, 0.298, 0.402, ... ] ] 1: [0.234, 0.298, 0.402, ... ]
. .
v t v u
@end group
+ @end smallexample
@noindent
Let's store these in quick variables 1 and 2, respectively.
@smallexample
+ @group
1: [1.34, 1.41, 1.49, ... ] .
.
t 2 t 1
@end group
+ @end smallexample
@noindent
(Recall that @kbd{t 2} is a variant of @kbd{s 2} that removes the
***************
*** 4104,4127 ****
sum a vector using a simple reduction. First, let's compute the four
different sums that this formula uses.
- @group
@smallexample
1: 41.63 1: 98.0003
. .
r 1 V R + t 3 r 1 2 V M ^ V R + t 4
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: 13.613 1: 33.36554
. .
r 2 V R + t 5 r 1 r 2 V M * V R + t 6
- @end smallexample
@end group
@ifinfo
@noindent
--- 4001,4024 ----
sum a vector using a simple reduction. First, let's compute the four
different sums that this formula uses.
@smallexample
+ @group
1: 41.63 1: 98.0003
. .
r 1 V R + t 3 r 1 2 V M ^ V R + t 4
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: 13.613 1: 33.36554
. .
r 2 V R + t 5 r 1 r 2 V M * V R + t 6
@end group
+ @end smallexample
@ifinfo
@noindent
***************
*** 4139,4179 ****
Finally, we also need @cite{N}, the number of data points. This is just
the length of either of our lists.
- @group
@smallexample
1: 19
.
r 1 v l t 7
- @end smallexample
@end group
@noindent
(That's @kbd{v} followed by a lower-case @kbd{l}.)
Now we grind through the formula:
- @group
@smallexample
1: 633.94526 2: 633.94526 1: 67.23607
. 1: 566.70919 .
.
r 7 r 6 * r 3 r 5 * -
- @end smallexample
@end group
@noindent
- @group
@smallexample
2: 67.23607 3: 67.23607 2: 67.23607 1: 0.52141679
1: 1862.0057 2: 1862.0057 1: 128.9488 .
. 1: 1733.0569 .
.
r 7 r 4 * r 3 2 ^ - / t 8
- @end smallexample
@end group
That gives us the slope @cite{m}. The y-intercept @cite{b} can now
be found with the simple formula,
--- 4036,4076 ----
Finally, we also need @cite{N}, the number of data points. This is just
the length of either of our lists.
@smallexample
+ @group
1: 19
.
r 1 v l t 7
@end group
+ @end smallexample
@noindent
(That's @kbd{v} followed by a lower-case @kbd{l}.)
Now we grind through the formula:
@smallexample
+ @group
1: 633.94526 2: 633.94526 1: 67.23607
. 1: 566.70919 .
.
r 7 r 6 * r 3 r 5 * -
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
2: 67.23607 3: 67.23607 2: 67.23607 1: 0.52141679
1: 1862.0057 2: 1862.0057 1: 128.9488 .
. 1: 1733.0569 .
.
r 7 r 4 * r 3 2 ^ - / t 8
@end group
+ @end smallexample
That gives us the slope @cite{m}. The y-intercept @cite{b} can now
be found with the simple formula,
***************
*** 4191,4217 ****
\vskip10pt
@end tex
- @group
@smallexample
1: 13.613 2: 13.613 1: -8.09358 1: -0.425978
. 1: 21.70658 . .
.
r 5 r 8 r 3 * - r 7 / t 9
- @end smallexample
@end group
Let's ``plot'' this straight line approximation, @c{$y \approx m x + b$}
@cite{m x + b}, and compare it with the original address@hidden
- @group
@smallexample
1: [0.699, 0.735, ... ] 1: [0.273, 0.309, ... ]
. .
r 1 r 8 * r 9 + s 0
- @end smallexample
@end group
@noindent
Notice that multiplying a vector by a constant, and adding a constant
--- 4088,4114 ----
\vskip10pt
@end tex
@smallexample
+ @group
1: 13.613 2: 13.613 1: -8.09358 1: -0.425978
. 1: 21.70658 . .
.
r 5 r 8 r 3 * - r 7 / t 9
@end group
+ @end smallexample
Let's ``plot'' this straight line approximation, @c{$y \approx m x + b$}
@cite{m x + b}, and compare it with the original address@hidden
@smallexample
+ @group
1: [0.699, 0.735, ... ] 1: [0.273, 0.309, ... ]
. .
r 1 r 8 * r 9 + s 0
@end group
+ @end smallexample
@noindent
Notice that multiplying a vector by a constant, and adding a constant
***************
*** 4222,4235 ****
We can subtract this vector from our original @cite{y} vector to get
a feel for the error of our fit. Let's find the maximum error:
- @group
@smallexample
1: [0.0387, 0.0112, ... ] 1: [0.0387, 0.0112, ... ] 1: 0.0897
. . .
r 2 - V M A V R X
- @end smallexample
@end group
@noindent
First we compute a vector of differences, then we take the absolute
--- 4119,4132 ----
We can subtract this vector from our original @cite{y} vector to get
a feel for the error of our fit. Let's find the maximum error:
@smallexample
+ @group
1: [0.0387, 0.0112, ... ] 1: [0.0387, 0.0112, ... ] 1: 0.0897
. . .
r 2 - V M A V R X
@end group
+ @end smallexample
@noindent
First we compute a vector of differences, then we take the absolute
***************
*** 4248,4267 ****
kind of display you have. Some GNUPLOT 2.0, non-X-windows systems
may require additional steps to view the graphs.)
! Let's start by plotting the original data. Recall the address@hidden'' and
address@hidden''
vectors onto the stack and press @kbd{g f}. This ``fast'' graphing
command does everything you need to do for simple, straightforward
plotting of data.
- @group
@smallexample
2: [1.34, 1.41, 1.49, ... ]
1: [0.234, 0.298, 0.402, ... ]
.
r 1 r 2 g f
- @end smallexample
@end group
If all goes well, you will shortly get a new window containing a graph
of the data. (If not, contact your GNUPLOT or Calc installer to find
--- 4145,4164 ----
kind of display you have. Some GNUPLOT 2.0, non-X-windows systems
may require additional steps to view the graphs.)
! Let's start by plotting the original data. Recall the address@hidden'' and
address@hidden''
vectors onto the stack and press @kbd{g f}. This ``fast'' graphing
command does everything you need to do for simple, straightforward
plotting of data.
@smallexample
+ @group
2: [1.34, 1.41, 1.49, ... ]
1: [0.234, 0.298, 0.402, ... ]
.
r 1 r 2 g f
@end group
+ @end smallexample
If all goes well, you will shortly get a new window containing a graph
of the data. (If not, contact your GNUPLOT or Calc installer to find
***************
*** 4272,4286 ****
Next, let's add the line we got from our least-squares fit:
- @group
@smallexample
2: [1.34, 1.41, 1.49, ... ]
1: [0.273, 0.309, 0.351, ... ]
.
! DEL r 0 g a g p
! @end smallexample
@end group
It's not very useful to get symbols to mark the data points on this
second curve; you can type @kbd{g S g p} to remove them. Type @kbd{g q}
--- 4169,4183 ----
Next, let's add the line we got from our least-squares fit:
@smallexample
+ @group
2: [1.34, 1.41, 1.49, ... ]
1: [0.273, 0.309, 0.351, ... ]
.
! @key{DEL} r 0 g a g p
@end group
+ @end smallexample
It's not very useful to get symbols to mark the data points on this
second curve; you can type @kbd{g S g p} to remove them. Type @kbd{g q}
***************
*** 4328,4351 ****
for \cite{n=6}.
@end tex
- @group
@smallexample
1: [1, 2, 3, 4, 5, 6, 7] 1: [0, 1, 2, 3, 4, 5, 6]
. .
! v x 7 RET 1 -
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: [1, -6, 15, -20, 15, -6, 1] 1: 0
. .
! V M ' (-1)^$ choose(6,$) RET V R +
! @end smallexample
@end group
The @kbd{V M '} command prompts you to enter any algebraic expression
to define the function to map over the vector. The symbol @samp{$}
--- 4225,4248 ----
for \cite{n=6}.
@end tex
@smallexample
+ @group
1: [1, 2, 3, 4, 5, 6, 7] 1: [0, 1, 2, 3, 4, 5, 6]
. .
! v x 7 @key{RET} 1 -
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: [1, -6, 15, -20, 15, -6, 1] 1: 0
. .
! V M ' (-1)^$ choose(6,$) @key{RET} V R +
@end group
+ @end smallexample
The @kbd{V M '} command prompts you to enter any algebraic expression
to define the function to map over the vector. The symbol @samp{$}
***************
*** 4354,4363 ****
substituting each element's value for the @samp{$} sign(s) in turn.
To define a two-argument function, use @samp{$$} for the first
! argument and @samp{$} for the second: @kbd{V M ' $$-$ RET} is
equivalent to @kbd{V M -}. This is analogous to regular algebraic
entry, where @samp{$$} would refer to the next-to-top stack entry
! and @samp{$} would refer to the top stack entry, and @kbd{' $$-$ RET}
would act exactly like @kbd{-}.
Notice that the @kbd{V M '} command has recorded two things in the
--- 4251,4260 ----
substituting each element's value for the @samp{$} sign(s) in turn.
To define a two-argument function, use @samp{$$} for the first
! argument and @samp{$} for the second: @kbd{V M ' $$-$ @key{RET}} is
equivalent to @kbd{V M -}. This is analogous to regular algebraic
entry, where @samp{$$} would refer to the next-to-top stack entry
! and @samp{$} would refer to the top stack entry, and @kbd{' $$-$ @key{RET}}
would act exactly like @kbd{-}.
Notice that the @kbd{V M '} command has recorded two things in the
***************
*** 4414,4445 ****
like the following diagram. (You may wish to use the @kbd{v /}
command to enable multi-line display of vectors.)
- @group
@smallexample
1: [ [1],
[1, 2],
[1, 2, 3],
[1, 2, 3, 4],
[1, 2, 3, 4, 5],
[1, 2, 3, 4, 5, 6] ]
- @end smallexample
@end group
@noindent
@xref{List Answer 6, 6}. (@bullet{})
(@bullet{}) @strong{Exercise 7.} Build the following list of lists.
- @group
@smallexample
1: [ [0],
[1, 2],
[3, 4, 5],
[6, 7, 8, 9],
[10, 11, 12, 13, 14],
[15, 16, 17, 18, 19, 20] ]
- @end smallexample
@end group
@noindent
@xref{List Answer 7, 7}. (@bullet{})
--- 4311,4342 ----
like the following diagram. (You may wish to use the @kbd{v /}
command to enable multi-line display of vectors.)
@smallexample
+ @group
1: [ [1],
[1, 2],
[1, 2, 3],
[1, 2, 3, 4],
[1, 2, 3, 4, 5],
[1, 2, 3, 4, 5, 6] ]
@end group
+ @end smallexample
@noindent
@xref{List Answer 6, 6}. (@bullet{})
(@bullet{}) @strong{Exercise 7.} Build the following list of lists.
@smallexample
+ @group
1: [ [0],
[1, 2],
[3, 4, 5],
[6, 7, 8, 9],
[10, 11, 12, 13, 14],
[15, 16, 17, 18, 19, 20] ]
@end group
+ @end smallexample
@noindent
@xref{List Answer 7, 7}. (@bullet{})
***************
*** 4476,4482 ****
is @c{$\pi$}
@cite{pi}. The area of the @c{$2\times2$}
@asis{2x2} square that encloses that
! circle is 4. So if we throw @i{N} darts at random points in the square,
about @c{$\pi/4$}
@cite{pi/4} of them will land inside the circle. This gives us
an entertaining way to estimate the value of @c{$\pi$}
--- 4373,4379 ----
is @c{$\pi$}
@cite{pi}. The area of the @c{$2\times2$}
@asis{2x2} square that encloses that
! circle is 4. So if we throw @var{n} darts at random points in the square,
about @c{$\pi/4$}
@cite{pi/4} of them will land inside the circle. This gives us
an entertaining way to estimate the value of @c{$\pi$}
***************
*** 4549,4563 ****
and are susceptible to roundoff error. Calc also supports @dfn{fractions},
which can exactly represent any rational number.
- @group
@smallexample
1: 3628800 2: 3628800 1: 518400:7 1: 518414:7 1: 7:518414
. 1: 49 . . .
.
! 10 ! 49 RET : 2 + &
! @end smallexample
@end group
@noindent
The @kbd{:} command divides two integers to get a fraction; @kbd{/}
--- 4446,4460 ----
and are susceptible to roundoff error. Calc also supports @dfn{fractions},
which can exactly represent any rational number.
@smallexample
+ @group
1: 3628800 2: 3628800 1: 518400:7 1: 518414:7 1: 7:518414
. 1: 49 . . .
.
! 10 ! 49 @key{RET} : 2 + &
@end group
+ @end smallexample
@noindent
The @kbd{:} command divides two integers to get a fraction; @kbd{/}
***************
*** 4569,4595 ****
You can convert between floating-point and fractional format using
@kbd{c f} and @kbd{c F}:
- @group
@smallexample
1: 1.35027217629e-5 1: 7:518414
. .
c f c F
- @end smallexample
@end group
The @kbd{c F} command replaces a floating-point number with the
``simplest'' fraction whose floating-point representation is the
same, to within the current precision.
- @group
@smallexample
1: 3.14159265359 1: 1146408:364913 1: 3.1416 1: 355:113
. . . .
! P c F DEL p 5 RET P c F
! @end smallexample
@end group
(@bullet{}) @strong{Exercise 1.} A calculation has produced the
result 1.26508260337. You suspect it is the square root of the
--- 4466,4492 ----
You can convert between floating-point and fractional format using
@kbd{c f} and @kbd{c F}:
@smallexample
+ @group
1: 1.35027217629e-5 1: 7:518414
. .
c f c F
@end group
+ @end smallexample
The @kbd{c F} command replaces a floating-point number with the
``simplest'' fraction whose floating-point representation is the
same, to within the current precision.
@smallexample
+ @group
1: 3.14159265359 1: 1146408:364913 1: 3.1416 1: 355:113
. . . .
! P c F @key{DEL} p 5 @key{RET} P c F
@end group
+ @end smallexample
(@bullet{}) @strong{Exercise 1.} A calculation has produced the
result 1.26508260337. You suspect it is the square root of the
***************
*** 4599,4612 ****
@dfn{Complex numbers} can be stored in both rectangular and polar form.
- @group
@smallexample
1: -9 1: (0, 3) 1: (3; 90.) 1: (6; 90.) 1: (2.4495; 45.)
. . . . .
9 n Q c p 2 * Q
- @end smallexample
@end group
@noindent
The square root of @i{-9} is by default rendered in rectangular form
--- 4496,4509 ----
@dfn{Complex numbers} can be stored in both rectangular and polar form.
@smallexample
+ @group
1: -9 1: (0, 3) 1: (3; 90.) 1: (6; 90.) 1: (2.4495; 45.)
. . . . .
9 n Q c p 2 * Q
@end group
+ @end smallexample
@noindent
The square root of @i{-9} is by default rendered in rectangular form
***************
*** 4622,4636 ****
real number. The word @code{inf} can only be input using
algebraic entry.
- @group
@smallexample
2: inf 2: -inf 2: -inf 2: -inf 1: nan
1: -17 1: -inf 1: -inf 1: inf .
. . . .
! ' inf RET 17 n * RET 72 + A +
! @end smallexample
@end group
@noindent
Since infinity is infinitely large, multiplying it by any finite
--- 4519,4533 ----
real number. The word @code{inf} can only be input using
algebraic entry.
@smallexample
+ @group
2: inf 2: -inf 2: -inf 2: -inf 1: nan
1: -17 1: -inf 1: -inf 1: inf .
. . . .
! ' inf @key{RET} 17 n * @key{RET} 72 + A +
@end group
+ @end smallexample
@noindent
Since infinity is infinitely large, multiplying it by any finite
***************
*** 4651,4666 ****
Calc to write an answer in terms of infinity by pressing @kbd{m i}
to turn on ``infinite mode.''
- @group
@smallexample
3: nan 2: nan 2: nan 2: nan 1: nan
2: 1 1: 1 / 0 1: uinf 1: uinf .
1: 0 . . .
.
! 1 RET 0 / m i U / 17 n * +
! @end smallexample
@end group
@noindent
Dividing by zero normally is left unevaluated, but after @kbd{m i}
--- 4548,4563 ----
Calc to write an answer in terms of infinity by pressing @kbd{m i}
to turn on ``infinite mode.''
@smallexample
+ @group
3: nan 2: nan 2: nan 2: nan 1: nan
2: 1 1: 1 / 0 1: uinf 1: uinf .
1: 0 . . .
.
! 1 @key{RET} 0 / m i U / 17 n * +
@end group
+ @end smallexample
@noindent
Dividing by zero normally is left unevaluated, but after @kbd{m i}
***************
*** 4694,4720 ****
@dfn{HMS forms} represent a value in terms of hours, minutes, and
seconds.
- @group
@smallexample
1: 2@@ 30' 0" 1: 3@@ 30' 0" 2: 3@@ 30' 0" 1: 2.
. . 1: 1@@ 45' 0." .
.
! 2@@ 30' RET 1 + RET 2 / /
! @end smallexample
@end group
HMS forms can also be used to hold angles in degrees, minutes, and
seconds.
- @group
@smallexample
1: 0.5 1: 26.56505 1: 26@@ 33' 54.18" 1: 0.44721
. . . .
0.5 I T c h S
- @end smallexample
@end group
@noindent
First we convert the inverse tangent of 0.5 to degrees-minutes-seconds
--- 4591,4617 ----
@dfn{HMS forms} represent a value in terms of hours, minutes, and
seconds.
@smallexample
+ @group
1: 2@@ 30' 0" 1: 3@@ 30' 0" 2: 3@@ 30' 0" 1: 2.
. . 1: 1@@ 45' 0." .
.
! 2@@ 30' @key{RET} 1 + @key{RET} 2 / /
@end group
+ @end smallexample
HMS forms can also be used to hold angles in degrees, minutes, and
seconds.
@smallexample
+ @group
1: 0.5 1: 26.56505 1: 26@@ 33' 54.18" 1: 0.44721
. . . .
0.5 I T c h S
@end group
+ @end smallexample
@noindent
First we convert the inverse tangent of 0.5 to degrees-minutes-seconds
***************
*** 4732,4746 ****
be entered using algebraic entry. Date forms are surrounded by
@samp{< >} symbols; most standard formats for dates are recognized.
- @group
@smallexample
2: <Sun Jan 13, 1991> 1: 2.25
1: <6:00pm Thu Jan 10, 1991> .
.
! ' <13 Jan 1991>, <1/10/91, 6pm> RET -
! @end smallexample
@end group
@noindent
In this example, we enter two dates, then subtract to find the
--- 4629,4643 ----
be entered using algebraic entry. Date forms are surrounded by
@samp{< >} symbols; most standard formats for dates are recognized.
@smallexample
+ @group
2: <Sun Jan 13, 1991> 1: 2.25
1: <6:00pm Thu Jan 10, 1991> .
.
! ' <13 Jan 1991>, <1/10/91, 6pm> @key{RET} -
@end group
+ @end smallexample
@noindent
In this example, we enter two dates, then subtract to find the
***************
*** 4748,4761 ****
HMS form or a number (of days) to a date form to get another
date form.
- @group
@smallexample
1: <4:45:59pm Mon Jan 14, 1991> 1: <2:50:59am Thu Jan 17, 1991>
. .
t N 2 + 10@@ 5' +
- @end smallexample
@end group
@c [fix-ref Date Arithmetic]
@noindent
--- 4645,4658 ----
HMS form or a number (of days) to a date form to get another
date form.
@smallexample
+ @group
1: <4:45:59pm Mon Jan 14, 1991> 1: <2:50:59am Thu Jan 17, 1991>
. .
t N 2 + 10@@ 5' +
@end group
+ @end smallexample
@c [fix-ref Date Arithmetic]
@noindent
***************
*** 4781,4795 ****
meters. What is the slope of a line from here to the top of the
pole, and what is the equivalent angle in degrees?
- @group
@smallexample
1: 8 +/- 0.2 2: 8 +/- 0.2 1: 0.266 +/- 0.011 1: 14.93 +/- 0.594
. 1: 30 +/- 1 . .
.
! 8 p .2 RET 30 p 1 / I T
! @end smallexample
@end group
@noindent
This means that the angle is about 15 degrees, and, assuming our
--- 4678,4692 ----
meters. What is the slope of a line from here to the top of the
pole, and what is the equivalent angle in degrees?
@smallexample
+ @group
1: 8 +/- 0.2 2: 8 +/- 0.2 1: 0.266 +/- 0.011 1: 14.93 +/- 0.594
. 1: 30 +/- 1 . .
.
! 8 p .2 @key{RET} 30 p 1 / I T
@end group
+ @end smallexample
@noindent
This means that the angle is about 15 degrees, and, assuming our
***************
*** 4811,4825 ****
our telephone pole is definitely between 28 and 31 meters away,
and that it is between 7.7 and 8.1 meters tall.
- @group
@smallexample
1: [7.7 .. 8.1] 2: [7.7 .. 8.1] 1: [0.24 .. 0.28] 1: [13.9 .. 16.1]
. 1: [28 .. 31] . .
.
[ 7.7 .. 8.1 ] [ 28 .. 31 ] / I T
- @end smallexample
@end group
@noindent
If our bounds were correct, then the angle to the top of the pole
--- 4708,4722 ----
our telephone pole is definitely between 28 and 31 meters away,
and that it is between 7.7 and 8.1 meters tall.
@smallexample
+ @group
1: [7.7 .. 8.1] 2: [7.7 .. 8.1] 1: [0.24 .. 0.28] 1: [13.9 .. 16.1]
. 1: [28 .. 31] . .
.
[ 7.7 .. 8.1 ] [ 28 .. 31 ] / I T
@end group
+ @end smallexample
@noindent
If our bounds were correct, then the angle to the top of the pole
***************
*** 4833,4847 ****
which is inclusive (``closed'') on one end and exclusive (``open'') on
the other.
- @group
@smallexample
1: [1 .. 10) 1: (0.1 .. 1] 2: (0.1 .. 1] 1: (0.2 .. 3)
. . 1: [2 .. 3) .
.
[ 1 .. 10 ) & [ 2 .. 3 ) *
- @end smallexample
@end group
@noindent
The Calculator automatically keeps track of which end values should
--- 4730,4744 ----
which is inclusive (``closed'') on one end and exclusive (``open'') on
the other.
@smallexample
+ @group
1: [1 .. 10) 1: (0.1 .. 1] 2: (0.1 .. 1] 1: (0.2 .. 3)
. . 1: [2 .. 3) .
.
[ 1 .. 10 ) & [ 2 .. 3 ) *
@end group
+ @end smallexample
@noindent
The Calculator automatically keeps track of which end values should
***************
*** 4856,4893 ****
@xref{Types Answer 8, 8}. (@bullet{})
(@bullet{}) @strong{Exercise 9.} Two easy ways of squaring a number
! are @kbd{RET *} and @address@hidden ^}}. Normally these produce the same
answer. Would you expect this still to hold true for interval forms?
If not, which of these will result in a larger interval?
@xref{Types Answer 9, 9}. (@bullet{})
! A @dfn{modulo form} is used for performing arithmetic modulo @i{M}.
For example, arithmetic involving time is generally done modulo 12
or 24 hours.
- @group
@smallexample
1: 17 mod 24 1: 3 mod 24 1: 21 mod 24 1: 9 mod 24
. . . .
! 17 M 24 RET 10 + n 5 /
! @end smallexample
@end group
@noindent
In this last step, Calc has found a new number which, when multiplied
! by 5 modulo 24, produces the original number, 21. If @i{M} is prime
! it is always possible to find such a number. For non-prime @i{M}
like 24, it is only sometimes possible.
- @group
@smallexample
1: 10 mod 24 1: 16 mod 24 1: 1000000... 1: 16
. . . .
! 10 M 24 RET 100 ^ 10 RET 100 ^ 24 %
! @end smallexample
@end group
@noindent
These two calculations get the same answer, but the first one is
--- 4753,4790 ----
@xref{Types Answer 8, 8}. (@bullet{})
(@bullet{}) @strong{Exercise 9.} Two easy ways of squaring a number
! are @address@hidden *} and @address@hidden ^}}. Normally these produce the
same
answer. Would you expect this still to hold true for interval forms?
If not, which of these will result in a larger interval?
@xref{Types Answer 9, 9}. (@bullet{})
! A @dfn{modulo form} is used for performing arithmetic modulo @var{m}.
For example, arithmetic involving time is generally done modulo 12
or 24 hours.
@smallexample
+ @group
1: 17 mod 24 1: 3 mod 24 1: 21 mod 24 1: 9 mod 24
. . . .
! 17 M 24 @key{RET} 10 + n 5 /
@end group
+ @end smallexample
@noindent
In this last step, Calc has found a new number which, when multiplied
! by 5 modulo 24, produces the original number, 21. If @var{m} is prime
! it is always possible to find such a number. For non-prime @var{m}
like 24, it is only sometimes possible.
@smallexample
+ @group
1: 10 mod 24 1: 16 mod 24 1: 1000000... 1: 16
. . . .
! 10 M 24 @key{RET} 100 ^ 10 @key{RET} 100 ^ 24 %
@end group
+ @end smallexample
@noindent
These two calculations get the same answer, but the first one is
***************
*** 4910,4923 ****
For example, the @code{calc-time} command pushes the current time
of day on the stack as an HMS/modulo form.
- @group
@smallexample
1: 17@@ 34' 45" mod 24@@ 0' 0" 1: 6@@ 22' 15" mod 24@@ 0' 0"
. .
! x time RET n
! @end smallexample
@end group
@noindent
This calculation tells me it is six hours and 22 minutes until midnight.
--- 4807,4820 ----
For example, the @code{calc-time} command pushes the current time
of day on the stack as an HMS/modulo form.
@smallexample
+ @group
1: 17@@ 34' 45" mod 24@@ 0' 0" 1: 6@@ 22' 15" mod 24@@ 0' 0"
. .
! x time @key{RET} n
@end group
+ @end smallexample
@noindent
This calculation tells me it is six hours and 22 minutes until midnight.
***************
*** 4940,4953 ****
suggestive names like @samp{cm} and @samp{in} to represent units
like centimeters and inches.
- @group
@smallexample
1: 2 in 1: 5.08 cm 1: 0.027778 fath 1: 0.0508 m
. . . .
! ' 2in RET u c cm RET u c fath RET u b
! @end smallexample
@end group
@noindent
We enter the quantity ``2 inches'' (actually an algebraic expression
--- 4837,4850 ----
suggestive names like @samp{cm} and @samp{in} to represent units
like centimeters and inches.
@smallexample
+ @group
1: 2 in 1: 5.08 cm 1: 0.027778 fath 1: 0.0508 m
. . . .
! ' 2in @key{RET} u c cm @key{RET} u c fath @key{RET} u b
@end group
+ @end smallexample
@noindent
We enter the quantity ``2 inches'' (actually an algebraic expression
***************
*** 4955,4978 ****
first to centimeters, then to fathoms, then finally to ``base'' units,
which in this case means meters.
- @group
@smallexample
1: 9 acre 1: 3 sqrt(acre) 1: 190.84 m 1: 190.84 m + 30 cm
. . . .
! ' 9 acre RET Q u s ' $+30 cm RET
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: 191.14 m 1: 36536.3046 m^2 1: 365363046 cm^2
. . .
u s 2 ^ u c cgs
- @end smallexample
@end group
@noindent
Since units expressions are really just formulas, taking the square
--- 4852,4875 ----
first to centimeters, then to fathoms, then finally to ``base'' units,
which in this case means meters.
@smallexample
+ @group
1: 9 acre 1: 3 sqrt(acre) 1: 190.84 m 1: 190.84 m + 30 cm
. . . .
! ' 9 acre @key{RET} Q u s ' $+30 cm @key{RET}
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: 191.14 m 1: 36536.3046 m^2 1: 365363046 cm^2
. . .
u s 2 ^ u c cgs
@end group
+ @end smallexample
@noindent
Since units expressions are really just formulas, taking the square
***************
*** 4987,5000 ****
There is a wide variety of units defined in the Calculator.
- @group
@smallexample
1: 55 mph 1: 88.5139 kph 1: 88.5139 km / hr 1: 8.201407e-8 c
. . . .
! ' 55 mph RET u c kph RET u c km/hr RET u c c RET
! @end smallexample
@end group
@noindent
We express a speed first in miles per hour, then in kilometers per
--- 4884,4897 ----
There is a wide variety of units defined in the Calculator.
@smallexample
+ @group
1: 55 mph 1: 88.5139 kph 1: 88.5139 km / hr 1: 8.201407e-8 c
. . . .
! ' 55 mph @key{RET} u c kph @key{RET} u c km/hr @key{RET}
u c c @key{RET}
@end group
+ @end smallexample
@noindent
We express a speed first in miles per hour, then in kilometers per
***************
*** 5008,5021 ****
as well as a scale factor and so there must be two explicit commands
for them.
- @group
@smallexample
1: 20 degF 1: 11.1111 degC 1: -20:3 degC 1: -6.666 degC
. . . .
! ' 20 degF RET u c degC RET U u t degC RET c f
! @end smallexample
@end group
@noindent
First we convert a change of 20 degrees Fahrenheit into an equivalent
--- 4905,4918 ----
as well as a scale factor and so there must be two explicit commands
for them.
@smallexample
+ @group
1: 20 degF 1: 11.1111 degC 1: -20:3 degC 1: -6.666 degC
. . . .
! ' 20 degF @key{RET} u c degC @key{RET} U u t degC @key{RET}
c f
@end group
+ @end smallexample
@noindent
First we convert a change of 20 degrees Fahrenheit into an equivalent
***************
*** 5029,5042 ****
When you use this method, you're responsible for remembering which
numbers are in which units:
- @group
@smallexample
1: 55 1: 88.5139 1: 8.201407e-8
. . .
! 55 u c mph RET kph RET u c km/hr RET c RET
! @end smallexample
@end group
To see a complete list of built-in units, type @kbd{u v}. Press
@address@hidden c}} again to re-enter the Calculator when you're done looking
--- 4926,4939 ----
When you use this method, you're responsible for remembering which
numbers are in which units:
@smallexample
+ @group
1: 55 1: 88.5139 1: 8.201407e-8
. . .
! 55 u c mph @key{RET} kph @key{RET} u c km/hr @key{RET} c
@key{RET}
@end group
+ @end smallexample
To see a complete list of built-in units, type @kbd{u v}. Press
@address@hidden c}} again to re-enter the Calculator when you're done looking
***************
*** 5079,5108 ****
the formula itself is pushed onto the stack. You can manipulate
formulas as regular data objects.
- @group
@smallexample
1: 2 x^2 - 6 1: 6 - 2 x^2 1: (6 - 2 x^2) (3 x^2 + y)
. . .
! ' 2x^2-6 RET n ' 3x^2+y RET *
! @end smallexample
@end group
! (@bullet{}) @strong{Exercise 1.} Do @kbd{' x RET Q 2 ^} and
! @kbd{' x RET 2 ^ Q} both wind up with the same result (@samp{x})?
Why or why not? @xref{Algebra Answer 1, 1}. (@bullet{})
There are also commands for doing common algebraic operations on
formulas. Continuing with the formula from the last example,
- @group
@smallexample
1: 18 x^2 + 6 y - 6 x^4 - 2 x^2 y 1: (18 - 2 y) x^2 - 6 x^4 + 6 y
. .
! a x a c x RET
! @end smallexample
@end group
@noindent
First we ``expand'' using the distributive law, then we ``collect''
--- 4976,5005 ----
the formula itself is pushed onto the stack. You can manipulate
formulas as regular data objects.
@smallexample
+ @group
1: 2 x^2 - 6 1: 6 - 2 x^2 1: (6 - 2 x^2) (3 x^2 + y)
. . .
! ' 2x^2-6 @key{RET} n ' 3x^2+y @key{RET} *
@end group
+ @end smallexample
! (@bullet{}) @strong{Exercise 1.} Do @kbd{' x @key{RET} Q 2 ^} and
! @kbd{' x @key{RET} 2 ^ Q} both wind up with the same result (@samp{x})?
Why or why not? @xref{Algebra Answer 1, 1}. (@bullet{})
There are also commands for doing common algebraic operations on
formulas. Continuing with the formula from the last example,
@smallexample
+ @group
1: 18 x^2 + 6 y - 6 x^4 - 2 x^2 y 1: (18 - 2 y) x^2 - 6 x^4 + 6 y
. .
! a x a c x @key{RET}
@end group
+ @end smallexample
@noindent
First we ``expand'' using the distributive law, then we ``collect''
***************
*** 5111,5124 ****
Let's find the value of this expression when @cite{x} is 2 and @cite{y}
is one-half.
- @group
@smallexample
1: 17 x^2 - 6 x^4 + 3 1: -25
. .
! 1:2 s l y RET 2 s l x RET
! @end smallexample
@end group
@noindent
The @kbd{s l} command means ``let''; it takes a number from the top of
--- 5008,5021 ----
Let's find the value of this expression when @cite{x} is 2 and @cite{y}
is one-half.
@smallexample
+ @group
1: 17 x^2 - 6 x^4 + 3 1: -25
. .
! 1:2 s l y @key{RET} 2 s l x @key{RET}
@end group
+ @end smallexample
@noindent
The @kbd{s l} command means ``let''; it takes a number from the top of
***************
*** 5129,5135 ****
(An earlier exercise in this tutorial involved storing a value in the
variable @code{x}; if this value is still there, you will have to
! unstore it with @kbd{s u x RET} before the above example will work
properly.)
@cindex Maximum of a function using Calculus
--- 5026,5032 ----
(An earlier exercise in this tutorial involved storing a value in the
variable @code{x}; if this value is still there, you will have to
! unstore it with @kbd{s u x @key{RET}} before the above example will work
properly.)
@cindex Maximum of a function using Calculus
***************
*** 5140,5176 ****
derivative of the function at that value of @cite{x} is negative,
the function has a local maximum there.
- @group
@smallexample
1: 17 x^2 - 6 x^4 + 3 1: 34 x - 24 x^3
. .
! U DEL s 1 a d x RET s 2
! @end smallexample
@end group
@noindent
Well, the derivative is clearly zero when @cite{x} is zero. To find
the other root(s), let's divide through by @cite{x} and then solve:
- @group
@smallexample
1: (34 x - 24 x^3) / x 1: 34 x / x - 24 x^3 / x 1: 34 - 24 x^2
. . .
! ' x RET / a x a s
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: 34 - 24 x^2 = 0 1: x = 1.19023
. .
! 0 a = s 3 a S x RET
! @end smallexample
@end group
@noindent
Notice the use of @kbd{a s} to ``simplify'' the formula. When the
--- 5037,5073 ----
derivative of the function at that value of @cite{x} is negative,
the function has a local maximum there.
@smallexample
+ @group
1: 17 x^2 - 6 x^4 + 3 1: 34 x - 24 x^3
. .
! U @key{DEL} s 1 a d x @key{RET} s 2
@end group
+ @end smallexample
@noindent
Well, the derivative is clearly zero when @cite{x} is zero. To find
the other root(s), let's divide through by @cite{x} and then solve:
@smallexample
+ @group
1: (34 x - 24 x^3) / x 1: 34 x / x - 24 x^3 / x 1: 34 - 24 x^2
. . .
! ' x @key{RET} / a x a s
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: 34 - 24 x^2 = 0 1: x = 1.19023
. .
! 0 a = s 3 a S x @key{RET}
@end group
+ @end smallexample
@noindent
Notice the use of @kbd{a s} to ``simplify'' the formula. When the
***************
*** 5179,5209 ****
Now we compute the second derivative and plug in our values of @cite{x}:
- @group
@smallexample
1: 1.19023 2: 1.19023 2: 1.19023
. 1: 34 x - 24 x^3 1: 34 - 72 x^2
. .
! a . r 2 a d x RET s 4
! @end smallexample
@end group
@noindent
(The @kbd{a .} command extracts just the righthand side of an equation.
Another method would have been to use @kbd{v u} to unpack the equation
! @address@hidden = 1.19}} to @samp{x} and @samp{1.19}, then use @kbd{M-- M-2
DEL}
to delete the @samp{x}.)
- @group
@smallexample
2: 34 - 72 x^2 1: -68. 2: 34 - 72 x^2 1: 34
1: 1.19023 . 1: 0 .
. .
! TAB s l x RET U DEL 0 s l x RET
! @end smallexample
@end group
@noindent
The first of these second derivatives is negative, so we know the function
--- 5076,5106 ----
Now we compute the second derivative and plug in our values of @cite{x}:
@smallexample
+ @group
1: 1.19023 2: 1.19023 2: 1.19023
. 1: 34 x - 24 x^3 1: 34 - 72 x^2
. .
! a . r 2 a d x @key{RET} s 4
@end group
+ @end smallexample
@noindent
(The @kbd{a .} command extracts just the righthand side of an equation.
Another method would have been to use @kbd{v u} to unpack the equation
! @address@hidden = 1.19}} to @samp{x} and @samp{1.19}, then use @kbd{M-- M-2
@key{DEL}}
to delete the @samp{x}.)
@smallexample
+ @group
2: 34 - 72 x^2 1: -68. 2: 34 - 72 x^2 1: 34
1: 1.19023 . 1: 0 .
. .
! @key{TAB} s l x @key{RET} U @key{DEL} 0
s l x @key{RET}
@end group
+ @end smallexample
@noindent
The first of these second derivatives is negative, so we know the function
***************
*** 5218,5231 ****
If it needs an arbitrary integer, it picks zero. We can get a full
solution by pressing @kbd{H} (the Hyperbolic flag) before @kbd{a S}.
- @group
@smallexample
1: 34 - 24 x^2 = 0 1: x = 1.19023 s1 1: x = -1.19023
. . .
! r 3 H a S x RET s 5 1 n s l s1 RET
! @end smallexample
@end group
@noindent
Calc has invented the variable @samp{s1} to represent an unknown sign;
--- 5115,5128 ----
If it needs an arbitrary integer, it picks zero. We can get a full
solution by pressing @kbd{H} (the Hyperbolic flag) before @kbd{a S}.
@smallexample
+ @group
1: 34 - 24 x^2 = 0 1: x = 1.19023 s1 1: x = -1.19023
. . .
! r 3 H a S x @key{RET} s 5 1 n s l s1 @key{RET}
@end group
+ @end smallexample
@noindent
Calc has invented the variable @samp{s1} to represent an unknown sign;
***************
*** 5237,5251 ****
To find the actual maximum value, we must plug our two values of @cite{x}
into the original formula.
- @group
@smallexample
2: 17 x^2 - 6 x^4 + 3 1: 24.08333 s1^2 - 12.04166 s1^4 + 3
1: x = 1.19023 s1 .
.
! r 1 r 5 s l RET
! @end smallexample
@end group
@noindent
(Here we see another way to use @kbd{s l}; if its input is an equation
--- 5134,5148 ----
To find the actual maximum value, we must plug our two values of @cite{x}
into the original formula.
@smallexample
+ @group
2: 17 x^2 - 6 x^4 + 3 1: 24.08333 s1^2 - 12.04166 s1^4 + 3
1: x = 1.19023 s1 .
.
! r 1 r 5 s l @key{RET}
@end group
+ @end smallexample
@noindent
(Here we see another way to use @kbd{s l}; if its input is an equation
***************
*** 5255,5269 ****
It's clear that this will have the same value for either sign of
@code{s1}, but let's work it out anyway, just for the exercise:
- @group
@smallexample
2: [-1, 1] 1: [15.04166, 15.04166]
1: 24.08333 s1^2 ... .
.
! [ 1 n , 1 ] TAB V M $ RET
! @end smallexample
@end group
@noindent
Here we have used a vector mapping operation to evaluate the function
--- 5152,5166 ----
It's clear that this will have the same value for either sign of
@code{s1}, but let's work it out anyway, just for the exercise:
@smallexample
+ @group
2: [-1, 1] 1: [15.04166, 15.04166]
1: 24.08333 s1^2 ... .
.
! [ 1 n , 1 ] @key{TAB} V M $ @key{RET}
@end group
+ @end smallexample
@noindent
Here we have used a vector mapping operation to evaluate the function
***************
*** 5301,5320 ****
symbolic form rather than giving a floating-point approximate answer.
Fraction mode (@kbd{m f}) is also useful when doing algebra.
- @group
@smallexample
2: 34 x - 24 x^3 2: 34 x - 24 x^3
1: 34 x - 24 x^3 1: [sqrt(51) / 6, sqrt(51) / -6, 0]
. .
! r 2 RET m s m f a P x RET
! @end smallexample
@end group
One more mode that makes reading formulas easier is ``Big mode.''
- @group
@smallexample
3
2: 34 x - 24 x
--- 5198,5217 ----
symbolic form rather than giving a floating-point approximate answer.
Fraction mode (@kbd{m f}) is also useful when doing algebra.
@smallexample
+ @group
2: 34 x - 24 x^3 2: 34 x - 24 x^3
1: 34 x - 24 x^3 1: [sqrt(51) / 6, sqrt(51) / -6, 0]
. .
! r 2 @key{RET} m s m f a P x @key{RET}
@end group
+ @end smallexample
One more mode that makes reading formulas easier is ``Big mode.''
@smallexample
+ @group
3
2: 34 x - 24 x
***************
*** 5326,5359 ****
.
d B
- @end smallexample
@end group
Here things like powers, square roots, and quotients and fractions
are displayed in a two-dimensional pictorial form. Calc has other
language modes as well, such as C mode, FORTRAN mode, and @TeX{} mode.
- @group
@smallexample
2: 34*x - 24*pow(x, 3) 2: 34*x - 24*x**3
1: @{sqrt(51) / 6, sqrt(51) / -6, address@hidden 1: /sqrt(51) / 6,
sqrt(51) / -6, 0/
. .
d C d F
- @end smallexample
@end group
@noindent
- @group
@smallexample
3: 34 x - 24 x^3
2: address@hidden@address@hidden \over address@hidden, @address@hidden@}
\over address@hidden, 0]
1: @{2 \over address@hidden address@hidden@}
.
! d T ' 2 address@hidden@} \over 3 RET
! @end smallexample
@end group
@noindent
As you can see, language modes affect both entry and display of
--- 5223,5256 ----
.
d B
@end group
+ @end smallexample
Here things like powers, square roots, and quotients and fractions
are displayed in a two-dimensional pictorial form. Calc has other
language modes as well, such as C mode, FORTRAN mode, and @TeX{} mode.
@smallexample
+ @group
2: 34*x - 24*pow(x, 3) 2: 34*x - 24*x**3
1: @{sqrt(51) / 6, sqrt(51) / -6, address@hidden 1: /sqrt(51) / 6,
sqrt(51) / -6, 0/
. .
d C d F
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
3: 34 x - 24 x^3
2: address@hidden@address@hidden \over address@hidden, @address@hidden@}
\over address@hidden, 0]
1: @{2 \over address@hidden address@hidden@}
.
! d T ' 2 address@hidden@} \over 3 @key{RET}
@end group
+ @end smallexample
@noindent
As you can see, language modes affect both entry and display of
***************
*** 5375,5401 ****
What is the area under the portion of this curve from @cite{x = 1} to
@cite{2}?
This is simply the integral of the function:
- @group
@smallexample
1: 17 x^2 - 6 x^4 + 3 1: 5.6666 x^3 - 1.2 x^5 + 3 x
. .
r 1 a i x
- @end smallexample
@end group
@noindent
We want to evaluate this at our two values for @cite{x} and subtract.
One way to do it is again with vector mapping and reduction:
- @group
@smallexample
2: [2, 1] 1: [12.93333, 7.46666] 1: 5.46666
1: 5.6666 x^3 ... . .
! [ 2 , 1 ] TAB V M $ RET V R -
! @end smallexample
@end group
(@bullet{}) @strong{Exercise 3.} Find the integral from 1 to @cite{y}
of @c{$x \sin \pi x$}
--- 5272,5298 ----
What is the area under the portion of this curve from @cite{x = 1} to
@cite{2}?
This is simply the integral of the function:
@smallexample
+ @group
1: 17 x^2 - 6 x^4 + 3 1: 5.6666 x^3 - 1.2 x^5 + 3 x
. .
r 1 a i x
@end group
+ @end smallexample
@noindent
We want to evaluate this at our two values for @cite{x} and subtract.
One way to do it is again with vector mapping and reduction:
@smallexample
+ @group
2: [2, 1] 1: [12.93333, 7.46666] 1: 5.46666
1: 5.6666 x^3 ... . .
! [ 2 , 1 ] @key{TAB} V M $ @key{RET} V R -
@end group
+ @end smallexample
(@bullet{}) @strong{Exercise 3.} Find the integral from 1 to @cite{y}
of @c{$x \sin \pi x$}
***************
*** 5407,5413 ****
others are beyond its capabilities. Suppose we wish to find the area
under the curve @c{$\sin x \ln x$}
@cite{sin(x) ln(x)} over the same range of @cite{x}. If
! you entered this formula and typed @kbd{a i x RET} (don't bother to try
this), Calc would work for a long time but would be unable to find a
solution. In fact, there is no closed-form solution to this integral.
Now what do we do?
--- 5304,5310 ----
others are beyond its capabilities. Suppose we wish to find the area
under the curve @c{$\sin x \ln x$}
@cite{sin(x) ln(x)} over the same range of @cite{x}. If
! you entered this formula and typed @kbd{a i x @key{RET}} (don't bother to try
this), Calc would work for a long time but would be unable to find a
solution. In fact, there is no closed-form solution to this integral.
Now what do we do?
***************
*** 5419,5458 ****
slow, though, since the sine and logarithm functions take a long time.
We can save some time by reducing the working precision.
- @group
@smallexample
3: 10 1: [1, 1.1, 1.2, ... , 1.8, 1.9]
2: 1 .
1: 0.1
.
! 10 RET 1 RET .1 RET C-u v x
! @end smallexample
@end group
@noindent
(Note that we have used the extended version of @kbd{v x}; we could
! also have used plain @kbd{v x} as follows: @kbd{v x 10 RET 9 + .1 *}.)
- @group
@smallexample
2: [1, 1.1, ... ] 1: [0., 0.084941, 0.16993, ... ]
1: sin(x) ln(x) .
.
! ' sin(x) ln(x) RET s 1 m r p 5 RET V M $ RET
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: 3.4195 0.34195
. .
V R + 0.1 *
- @end smallexample
@end group
@noindent
(If you got wildly different results, did you remember to switch
--- 5316,5355 ----
slow, though, since the sine and logarithm functions take a long time.
We can save some time by reducing the working precision.
@smallexample
+ @group
3: 10 1: [1, 1.1, 1.2, ... , 1.8, 1.9]
2: 1 .
1: 0.1
.
! 10 @key{RET} 1 @key{RET} .1 @key{RET} C-u v x
@end group
+ @end smallexample
@noindent
(Note that we have used the extended version of @kbd{v x}; we could
! also have used plain @kbd{v x} as follows: @kbd{v x 10 @key{RET} 9 + .1 *}.)
@smallexample
+ @group
2: [1, 1.1, ... ] 1: [0., 0.084941, 0.16993, ... ]
1: sin(x) ln(x) .
.
! ' sin(x) ln(x) @key{RET} s 1 m r p 5 @key{RET} V M $ @key{RET}
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: 3.4195 0.34195
. .
V R + 0.1 *
@end group
+ @end smallexample
@noindent
(If you got wildly different results, did you remember to switch
***************
*** 5468,5495 ****
The true value of this integral turns out to be about 0.374, so
we're not doing too well. Let's try another approach.
- @group
@smallexample
1: sin(x) ln(x) 1: 0.84147 x - 0.84147 + 0.11957 (x - 1)^2 - ...
. .
! r 1 a t x=1 RET 4 RET
! @end smallexample
@end group
@noindent
Here we have computed the Taylor series expansion of the function
about the point @cite{x=1}. We can now integrate this polynomial
approximation, since polynomials are easy to integrate.
- @group
@smallexample
1: 0.42074 x^2 + ... 1: [-0.0446, -0.42073] 1: 0.3761
. . .
! a i x RET [ 2 , 1 ] TAB V M $ RET V R -
! @end smallexample
@end group
@noindent
Better! By increasing the precision and/or asking for more terms
--- 5365,5392 ----
The true value of this integral turns out to be about 0.374, so
we're not doing too well. Let's try another approach.
@smallexample
+ @group
1: sin(x) ln(x) 1: 0.84147 x - 0.84147 + 0.11957 (x - 1)^2 - ...
. .
! r 1 a t x=1 @key{RET} 4 @key{RET}
@end group
+ @end smallexample
@noindent
Here we have computed the Taylor series expansion of the function
about the point @cite{x=1}. We can now integrate this polynomial
approximation, since polynomials are easy to integrate.
@smallexample
+ @group
1: 0.42074 x^2 + ... 1: [-0.0446, -0.42073] 1: 0.3761
. . .
! a i x @key{RET} [ 2 , 1 ] @key{TAB} V M $ @key{RET} V
R -
@end group
+ @end smallexample
@noindent
Better! By increasing the precision and/or asking for more terms
***************
*** 5577,5590 ****
Suppose we want to simplify this trigonometric formula:
- @group
@smallexample
1: 1 / cos(x) - sin(x) tan(x)
.
! ' 1/cos(x) - sin(x) tan(x) RET s 1
! @end smallexample
@end group
@noindent
If we were simplifying this by hand, we'd probably replace the
--- 5474,5487 ----
Suppose we want to simplify this trigonometric formula:
@smallexample
+ @group
1: 1 / cos(x) - sin(x) tan(x)
.
! ' 1/cos(x) - sin(x) tan(x) @key{RET} s 1
@end group
+ @end smallexample
@noindent
If we were simplifying this by hand, we'd probably replace the
***************
*** 5595,5608 ****
Rewrite rules are written with the @samp{:=} symbol.
- @group
@smallexample
1: 1 / cos(x) - sin(x)^2 / cos(x)
.
! a r tan(a) := sin(a)/cos(a) RET
! @end smallexample
@end group
@noindent
(The ``assignment operator'' @samp{:=} has several uses in Calc. All
--- 5492,5505 ----
Rewrite rules are written with the @samp{:=} symbol.
@smallexample
+ @group
1: 1 / cos(x) - sin(x)^2 / cos(x)
.
! a r tan(a) := sin(a)/cos(a) @key{RET}
@end group
+ @end smallexample
@noindent
(The ``assignment operator'' @samp{:=} has several uses in Calc. All
***************
*** 5625,5638 ****
To merge over a common denominator, we can use another simple rule:
- @group
@smallexample
1: (1 - sin(x)^2) / cos(x)
.
! a r a/x + b/x := (a+b)/x RET
! @end smallexample
@end group
This rule points out several interesting features of rewrite patterns.
First, if a meta-variable appears several times in a pattern, it must
--- 5522,5535 ----
To merge over a common denominator, we can use another simple rule:
@smallexample
+ @group
1: (1 - sin(x)^2) / cos(x)
.
! a r a/x + b/x := (a+b)/x @key{RET}
@end group
+ @end smallexample
This rule points out several interesting features of rewrite patterns.
First, if a meta-variable appears several times in a pattern, it must
***************
*** 5665,5678 ****
latter rule has a more general pattern so it will work in many other
situations, too.
- @group
@smallexample
1: (1 + cos(x)^2 - 1) / cos(x) 1: cos(x)
. .
! a r sin(x)^2 := 1 - cos(x)^2 RET a s
! @end smallexample
@end group
You may ask, what's the point of using the most general rule if you
have to type it in every time anyway? The answer is that Calc allows
--- 5562,5575 ----
latter rule has a more general pattern so it will work in many other
situations, too.
@smallexample
+ @group
1: (1 + cos(x)^2 - 1) / cos(x) 1: cos(x)
. .
! a r sin(x)^2 := 1 - cos(x)^2 @key{RET} a s
@end group
+ @end smallexample
You may ask, what's the point of using the most general rule if you
have to type it in every time anyway? The answer is that Calc allows
***************
*** 5683,5700 ****
can simply Undo, edit the variable, and run the rule again without
having to retype it.
- @group
@smallexample
! ' tan(x) := sin(x)/cos(x) RET s t tsc RET
! ' a/x + b/x := (a+b)/x RET s t merge RET
! ' sin(x)^2 := 1 - cos(x)^2 RET s t sinsqr RET
1: 1 / cos(x) - sin(x) tan(x) 1: cos(x)
. .
! r 1 a r tsc RET a r merge RET a r sinsqr RET a s
! @end smallexample
@end group
To edit a variable, type @kbd{s e} and the variable name, use regular
Emacs editing commands as necessary, then type @kbd{M-# M-#} or
--- 5580,5597 ----
can simply Undo, edit the variable, and run the rule again without
having to retype it.
@smallexample
! @group
! ' tan(x) := sin(x)/cos(x) @key{RET} s t tsc @key{RET}
! ' a/x + b/x := (a+b)/x @key{RET} s t merge @key{RET}
! ' sin(x)^2 := 1 - cos(x)^2 @key{RET} s t sinsqr @key{RET}
1: 1 / cos(x) - sin(x) tan(x) 1: cos(x)
. .
! r 1 a r tsc @key{RET} a r merge @key{RET} a r sinsqr
@key{RET} a s
@end group
+ @end smallexample
To edit a variable, type @kbd{s e} and the variable name, use regular
Emacs editing commands as necessary, then type @kbd{M-# M-#} or
***************
*** 5720,5743 ****
The @kbd{a r} command can also accept a vector of rewrite rules, or
a variable containing a vector of rules.
- @group
@smallexample
1: [tsc, merge, sinsqr] 1: [tan(x) := sin(x) / cos(x), ... ]
. .
! ' [tsc,merge,sinsqr] RET =
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: 1 / cos(x) - sin(x) tan(x) 1: cos(x)
. .
! s t trig RET r 1 a r trig RET a s
! @end smallexample
@end group
@c [fix-ref Nested Formulas with Rewrite Rules]
Calc tries all the rules you give against all parts of the formula,
--- 5617,5640 ----
The @kbd{a r} command can also accept a vector of rewrite rules, or
a variable containing a vector of rules.
@smallexample
+ @group
1: [tsc, merge, sinsqr] 1: [tan(x) := sin(x) / cos(x), ... ]
. .
! ' [tsc,merge,sinsqr] @key{RET} =
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: 1 / cos(x) - sin(x) tan(x) 1: cos(x)
. .
! s t trig @key{RET} r 1 a r trig @key{RET} a s
@end group
+ @end smallexample
@c [fix-ref Nested Formulas with Rewrite Rules]
Calc tries all the rules you give against all parts of the formula,
***************
*** 5751,5764 ****
to @kbd{a r} to specify any limit. In particular, @kbd{M-1 a r} does
only one rewrite at a time.
- @group
@smallexample
1: 1 / cos(x) - sin(x)^2 / cos(x) 1: (1 - sin(x)^2) / cos(x)
. .
! r 1 M-1 a r trig RET M-1 a r trig RET
! @end smallexample
@end group
You can type @kbd{M-0 a r} if you want no limit at all on the number
of rewrites that occur.
--- 5648,5661 ----
to @kbd{a r} to specify any limit. In particular, @kbd{M-1 a r} does
only one rewrite at a time.
@smallexample
+ @group
1: 1 / cos(x) - sin(x)^2 / cos(x) 1: (1 - sin(x)^2) / cos(x)
. .
! r 1 M-1 a r trig @key{RET} M-1 a r trig @key{RET}
@end group
+ @end smallexample
You can type @kbd{M-0 a r} if you want no limit at all on the number
of rewrites that occur.
***************
*** 5766,5789 ****
Rewrite rules can also be @dfn{conditional}. Simply follow the rule
with a @samp{::} symbol and the desired condition. For example,
- @group
@smallexample
1: exp(2 pi i) + exp(3 pi i) + exp(4 pi i)
.
! ' exp(2 pi i) + exp(3 pi i) + exp(4 pi i) RET
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: 1 + exp(3 pi i) + 1
.
! a r exp(k pi i) := 1 :: k % 2 = 0 RET
! @end smallexample
@end group
@noindent
(Recall, @samp{k % 2} is the remainder from dividing @samp{k} by 2,
--- 5663,5686 ----
Rewrite rules can also be @dfn{conditional}. Simply follow the rule
with a @samp{::} symbol and the desired condition. For example,
@smallexample
+ @group
1: exp(2 pi i) + exp(3 pi i) + exp(4 pi i)
.
! ' exp(2 pi i) + exp(3 pi i) + exp(4 pi i) @key{RET}
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: 1 + exp(3 pi i) + 1
.
! a r exp(k pi i) := 1 :: k % 2 = 0 @key{RET}
@end group
+ @end smallexample
@noindent
(Recall, @samp{k % 2} is the remainder from dividing @samp{k} by 2,
***************
*** 5799,5805 ****
only when the fifth argument is literally @address@hidden
@cindex Fibonacci numbers
! @c @starindex
@tindex fib
Rewrite rules provide an interesting way to define your own functions.
Suppose we want to define @samp{fib(n)} to produce the @var{n}th
--- 5696,5704 ----
only when the fifth argument is literally @address@hidden
@cindex Fibonacci numbers
! @ignore
! @starindex
! @end ignore
@tindex fib
Rewrite rules provide an interesting way to define your own functions.
Suppose we want to define @samp{fib(n)} to produce the @var{n}th
***************
*** 5807,5822 ****
later numbers are formed by summing the two preceding numbers in
the sequence. This is easy to express in a set of three rules:
- @group
@smallexample
! ' [fib(1) := 1, fib(2) := 1, fib(n) := fib(n-1) + fib(n-2)] RET s t fib
1: fib(7) 1: 13
. .
! ' fib(7) RET a r fib RET
! @end smallexample
@end group
One thing that is guaranteed about the order that rewrites are tried
is that, for any given subformula, earlier rules in the rule set will
--- 5706,5721 ----
later numbers are formed by summing the two preceding numbers in
the sequence. This is easy to express in a set of three rules:
@smallexample
! @group
! ' [fib(1) := 1, fib(2) := 1, fib(n) := fib(n-1) + fib(n-2)] @key{RET} s t fib
1: fib(7) 1: 13
. .
! ' fib(7) @key{RET} a r fib @key{RET}
@end group
+ @end smallexample
One thing that is guaranteed about the order that rewrites are tried
is that, for any given subformula, earlier rules in the rule set will
***************
*** 5830,5836 ****
Each of these will then be replaced to get @samp{fib(x-2) + 2 fib(x-3) +
fib(x-4)}, and so on, expanding forever. What we really want is to apply
the third rule only when @samp{n} is an integer greater than two. Type
! @address@hidden e fib RET}}, then edit the third rule to:
@smallexample
fib(n) := fib(n-1) + fib(n-2) :: integer(n) :: n > 2
--- 5729,5735 ----
Each of these will then be replaced to get @samp{fib(x-2) + 2 fib(x-3) +
fib(x-4)}, and so on, expanding forever. What we really want is to apply
the third rule only when @samp{n} is an integer greater than two. Type
! @address@hidden e fib @key{RET}}}, then edit the third rule to:
@smallexample
fib(n) := fib(n-1) + fib(n-2) :: integer(n) :: n > 2
***************
*** 5839,5881 ****
@noindent
Now:
- @group
@smallexample
1: fib(6) + fib(x) + fib(0) 1: 8 + fib(x) + fib(0)
. .
! ' fib(6)+fib(x)+fib(0) RET a r fib RET
! @end smallexample
@end group
@noindent
We've created a new function, @code{fib}, and a new command,
! @address@hidden r fib RET}}, which means ``evaluate all @code{fib} calls in
this formula.'' To make things easier still, we can tell Calc to
apply these rules automatically by storing them in the special
variable @code{EvalRules}.
- @group
@smallexample
1: [fib(1) := ...] . 1: [8, 13]
. .
! s r fib RET s t EvalRules RET ' [fib(6), fib(7)] RET
! @end smallexample
@end group
It turns out that this rule set has the problem that it does far
more work than it needs to when @samp{n} is large. Consider the
first few steps of the computation of @samp{fib(6)}:
- @group
@smallexample
fib(6) =
fib(5) + fib(4) =
fib(4) + fib(3) + fib(3) + fib(2) =
fib(3) + fib(2) + fib(2) + fib(1) + fib(2) + fib(1) + 1 = ...
- @end smallexample
@end group
@noindent
Note that @samp{fib(3)} appears three times here. Unless Calc's
--- 5738,5780 ----
@noindent
Now:
@smallexample
+ @group
1: fib(6) + fib(x) + fib(0) 1: 8 + fib(x) + fib(0)
. .
! ' fib(6)+fib(x)+fib(0) @key{RET} a r fib @key{RET}
@end group
+ @end smallexample
@noindent
We've created a new function, @code{fib}, and a new command,
! @address@hidden r fib @key{RET}}}, which means ``evaluate all @code{fib}
calls in
this formula.'' To make things easier still, we can tell Calc to
apply these rules automatically by storing them in the special
variable @code{EvalRules}.
@smallexample
+ @group
1: [fib(1) := ...] . 1: [8, 13]
. .
! s r fib @key{RET} s t EvalRules @key{RET} ' [fib(6), fib(7)]
@key{RET}
@end group
+ @end smallexample
It turns out that this rule set has the problem that it does far
more work than it needs to when @samp{n} is large. Consider the
first few steps of the computation of @samp{fib(6)}:
@smallexample
+ @group
fib(6) =
fib(5) + fib(4) =
fib(4) + fib(3) + fib(3) + fib(2) =
fib(3) + fib(2) + fib(2) + fib(1) + fib(2) + fib(1) + 1 = ...
@end group
+ @end smallexample
@noindent
Note that @samp{fib(3)} appears three times here. Unless Calc's
***************
*** 5897,5903 ****
example, if the rule rewrites @samp{fib(7)} to something that evaluates
to 13, then the rule @samp{fib(7) := 13} will be added to the rule set.
! Type @kbd{' fib(8) RET} to compute the eighth Fibonacci number, then
type @kbd{s E} again to see what has happened to the rule set.
With the @code{remember} feature, our rule set can now compute
--- 5796,5802 ----
example, if the rule rewrites @samp{fib(7)} to something that evaluates
to 13, then the rule @samp{fib(7) := 13} will be added to the rule set.
! Type @kbd{' fib(8) @key{RET}} to compute the eighth Fibonacci number, then
type @kbd{s E} again to see what has happened to the rule set.
With the @code{remember} feature, our rule set can now compute
***************
*** 5907,5913 ****
(and the results for all smaller @var{n}) later in just one step.
All Calc operations will run somewhat slower whenever @code{EvalRules}
! contains any rules. You should type @kbd{s u EvalRules RET} now to
un-store the variable.
(@bullet{}) @strong{Exercise 2.} Sometimes it is possible to reformulate
--- 5806,5812 ----
(and the results for all smaller @var{n}) later in just one step.
All Calc operations will run somewhat slower whenever @code{EvalRules}
! contains any rules. You should type @kbd{s u EvalRules @key{RET}} now to
un-store the variable.
(@bullet{}) @strong{Exercise 2.} Sometimes it is possible to reformulate
***************
*** 6045,6058 ****
the address@hidden prefix; the user commands they create use the lower
case @kbd{z} prefix.
- @group
@smallexample
1: 1 + x + x^2 / 2 + x^3 / 6 1: 1 + x + x^2 / 2 + x^3 / 6
. .
! ' 1 + x + x^2/2! + x^3/3! RET Z F e myexp RET RET RET y
! @end smallexample
@end group
This polynomial is a Taylor series approximation to @samp{exp(x)}.
The @kbd{Z F} command asks a number of questions. The above answers
--- 5944,5957 ----
the address@hidden prefix; the user commands they create use the lower
case @kbd{z} prefix.
@smallexample
+ @group
1: 1 + x + x^2 / 2 + x^3 / 6 1: 1 + x + x^2 / 2 + x^3 / 6
. .
! ' 1 + x + x^2/2! + x^3/3! @key{RET} Z F e myexp @key{RET}
@key{RET} @key{RET} y
@end group
+ @end smallexample
This polynomial is a Taylor series approximation to @samp{exp(x)}.
The @kbd{Z F} command asks a number of questions. The above answers
***************
*** 6063,6078 ****
answers the question ``leave it in symbolic form for non-constant
arguments?''
- @group
@smallexample
1: 1.3495 2: 1.3495 3: 1.3495
. 1: 1.34986 2: 1.34986
. 1: myexp(a + 1)
.
! .3 z e .3 E ' a+1 RET z e
! @end smallexample
@end group
@noindent
First we call our new @code{exp} approximation with 0.3 as an
--- 5962,5977 ----
answers the question ``leave it in symbolic form for non-constant
arguments?''
@smallexample
+ @group
1: 1.3495 2: 1.3495 3: 1.3495
. 1: 1.34986 2: 1.34986
. 1: myexp(a + 1)
.
! .3 z e .3 E ' a+1 @key{RET} z e
@end group
+ @end smallexample
@noindent
First we call our new @code{exp} approximation with 0.3 as an
***************
*** 6084,6090 ****
in @samp{a + 1} for @samp{x} in the defining formula.
@cindex Sine integral Si(x)
! @c @starindex
@tindex Si
(@bullet{}) @strong{Exercise 1.} The ``sine integral'' function
@c{${\rm Si}(x)$}
--- 5983,5991 ----
in @samp{a + 1} for @samp{x} in the defining formula.
@cindex Sine integral Si(x)
! @ignore
! @starindex
! @end ignore
@tindex Si
(@bullet{}) @strong{Exercise 1.} The ``sine integral'' function
@c{${\rm Si}(x)$}
***************
*** 6107,6125 ****
For example, if you find yourself typing @kbd{H a S x @key{RET}} often,
you may wish to program a keyboard macro to type this for you.
- @group
@smallexample
1: y = sqrt(x) 1: x = y^2
. .
! ' y=sqrt(x) RET C-x ( H a S x RET C-x )
1: y = cos(x) 1: x = s1 arccos(y) + 2 pi n1
. .
! ' y=cos(x) RET X
! @end smallexample
@end group
@noindent
When you type @kbd{C-x (}, Emacs begins recording. But it is also
--- 6008,6026 ----
For example, if you find yourself typing @kbd{H a S x @key{RET}} often,
you may wish to program a keyboard macro to type this for you.
@smallexample
+ @group
1: y = sqrt(x) 1: x = y^2
. .
! ' y=sqrt(x) @key{RET} C-x ( H a S x @key{RET} C-x )
1: y = cos(x) 1: x = s1 arccos(y) + 2 pi n1
. .
! ' y=cos(x) @key{RET} X
@end group
+ @end smallexample
@noindent
When you type @kbd{C-x (}, Emacs begins recording. But it is also
***************
*** 6130,6143 ****
You can give a name to your macro by typing @kbd{Z K}.
- @group
@smallexample
1: . 1: y = x^4 1: x = s2 sqrt(s1 sqrt(y))
. .
! Z K x RET ' y=x^4 RET z x
! @end smallexample
@end group
@noindent
Notice that we use address@hidden to define the command, and lower-case
--- 6031,6044 ----
You can give a name to your macro by typing @kbd{Z K}.
@smallexample
+ @group
1: . 1: y = x^4 1: x = s2 sqrt(s1 sqrt(y))
. .
! Z K x @key{RET} ' y=x^4 @key{RET} z x
@end group
+ @end smallexample
@noindent
Notice that we use address@hidden to define the command, and lower-case
***************
*** 6145,6158 ****
Keyboard macros can call other macros.
- @group
@smallexample
1: abs(x) 1: x = s1 y 1: 2 / x 1: x = 2 / y
. . . .
! ' abs(x) RET C-x ( ' y RET a = z x C-x ) ' 2/x RET X
! @end smallexample
@end group
(@bullet{}) @strong{Exercise 2.} Define a keyboard macro to negate
the item in level 3 of the stack, without disturbing the rest of
--- 6046,6059 ----
Keyboard macros can call other macros.
@smallexample
+ @group
1: abs(x) 1: x = s1 y 1: 2 / x 1: x = 2 / y
. . . .
! ' abs(x) @key{RET} C-x ( ' y @key{RET} a = z x C-x ) ' 2/x @key{RET}
X
@end group
+ @end smallexample
(@bullet{}) @strong{Exercise 2.} Define a keyboard macro to negate
the item in level 3 of the stack, without disturbing the rest of
***************
*** 6186,6200 ****
Calc has @dfn{looping} commands that allow this. Loops are useful
inside keyboard macros, but actually work at any time.
- @group
@smallexample
1: x^6 2: x^6 1: 360 x^2
. 1: 4 .
.
! ' x^6 RET 4 Z < a d x RET Z >
! @end smallexample
@end group
@noindent
Here we have computed the fourth derivative of @cite{x^6} by
--- 6087,6101 ----
Calc has @dfn{looping} commands that allow this. Loops are useful
inside keyboard macros, but actually work at any time.
@smallexample
+ @group
1: x^6 2: x^6 1: 360 x^2
. 1: 4 .
.
! ' x^6 @key{RET} 4 Z < a d x @key{RET} Z >
@end group
+ @end smallexample
@noindent
Here we have computed the fourth derivative of @cite{x^6} by
***************
*** 6208,6223 ****
@cindex Fibonacci numbers
Here's another example:
- @group
@smallexample
3: 1 2: 10946
2: 1 1: 17711
1: 20 .
.
! 1 RET RET 20 Z < TAB C-j + Z >
! @end smallexample
@end group
@noindent
The numbers in levels 2 and 1 should be the 21st and 22nd Fibonacci
--- 6109,6124 ----
@cindex Fibonacci numbers
Here's another example:
@smallexample
+ @group
3: 1 2: 10946
2: 1 1: 17711
1: 20 .
.
! 1 @key{RET} @key{RET} 20 Z < @key{TAB} C-j + Z >
@end group
+ @end smallexample
@noindent
The numbers in levels 2 and 1 should be the 21st and 22nd Fibonacci
***************
*** 6236,6249 ****
@cite{(1 + sqrt(5)) / 2}. (For convenience, this constant is available
from the @code{phi} variable, or the @kbd{I H P} command.)
- @group
@smallexample
1: 1.61803 1: 24476.0000409 1: 10945.9999817 1: 10946
. . . .
I H P 21 ^ 5 Q / R
- @end smallexample
@end group
@cindex Continued fractions
(@bullet{}) @strong{Exercise 5.} The @dfn{continued fraction}
--- 6137,6150 ----
@cite{(1 + sqrt(5)) / 2}. (For convenience, this constant is available
from the @code{phi} variable, or the @kbd{I H P} command.)
@smallexample
+ @group
1: 1.61803 1: 24476.0000409 1: 10945.9999817 1: 10946
. . . .
I H P 21 ^ 5 Q / R
@end group
+ @end smallexample
@cindex Continued fractions
(@bullet{}) @strong{Exercise 5.} The @dfn{continued fraction}
***************
*** 6270,6285 ****
we wish to compute the 20th ``harmonic'' number, which is equal to
the sum of the reciprocals of the integers from 1 to 20.
- @group
@smallexample
3: 0 1: 3.597739
2: 1 .
1: 20
.
! 0 RET 1 RET 20 Z ( & + 1 Z )
! @end smallexample
@end group
@noindent
The ``for'' loop pops two numbers, the lower and upper limits, then
--- 6171,6186 ----
we wish to compute the 20th ``harmonic'' number, which is equal to
the sum of the reciprocals of the integers from 1 to 20.
@smallexample
+ @group
3: 0 1: 3.597739
2: 1 .
1: 20
.
! 0 @key{RET} 1 @key{RET} 20 Z ( & + 1 Z )
@end group
+ @end smallexample
@noindent
The ``for'' loop pops two numbers, the lower and upper limits, then
***************
*** 6294,6308 ****
total as well as for the various loop housekeeping functions. If
you find this disorienting, you can sum in a variable instead:
- @group
@smallexample
1: 0 2: 1 . 1: 3.597739
. 1: 20 .
.
! 0 t 7 1 RET 20 Z ( & s + 7 1 Z ) r 7
! @end smallexample
@end group
@noindent
The @kbd{s +} command adds the top-of-stack into the value in a
--- 6195,6209 ----
total as well as for the various loop housekeeping functions. If
you find this disorienting, you can sum in a variable instead:
@smallexample
+ @group
1: 0 2: 1 . 1: 3.597739
. 1: 20 .
.
! 0 t 7 1 @key{RET} 20 Z ( & s + 7 1 Z ) r 7
@end group
+ @end smallexample
@noindent
The @kbd{s +} command adds the top-of-stack into the value in a
***************
*** 6325,6340 ****
caller was keeping in those same variables. This is easy to
fix, though:
- @group
@smallexample
. 1: 0.6667 1: 0.6667 3: 0.6667
. . 2: 3.597739
1: 0.6667
.
! Z ` p 4 RET 2 RET 3 / s 7 s s a RET Z ' r 7 s r a RET
! @end smallexample
@end group
@noindent
When we type @kbd{Z `} (that's a back-quote character), Calc saves
--- 6226,6241 ----
caller was keeping in those same variables. This is easy to
fix, though:
@smallexample
+ @group
. 1: 0.6667 1: 0.6667 3: 0.6667
. . 2: 3.597739
1: 0.6667
.
! 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 group
+ @end smallexample
@noindent
When we type @kbd{Z `} (that's a back-quote character), Calc saves
***************
*** 6358,6371 ****
this command is very slow for large @cite{n} since the higher
Bernoulli numbers are very large fractions.)
- @group
@smallexample
1: 10 1: 0.0756823
. .
! 10 C-x ( RET 2 % Z [ DEL 0 Z : ' 2 $! / (2 pi)^$ RET = Z ] C-x )
! @end smallexample
@end group
@noindent
You can read @kbd{Z [} as ``then,'' @kbd{Z :} as ``else,'' and
--- 6259,6272 ----
this command is very slow for large @cite{n} since the higher
Bernoulli numbers are very large fractions.)
@smallexample
+ @group
1: 10 1: 0.0756823
. .
! 10 C-x ( @key{RET} 2 % Z [ @key{DEL} 0 Z : ' 2 $! / (2 pi)^$
@key{RET} = Z ] C-x )
@end group
+ @end smallexample
@noindent
You can read @kbd{Z [} as ``then,'' @kbd{Z :} as ``else,'' and
***************
*** 6378,6407 ****
The actual tenth Bernoulli number is @cite{5/66}.
- @group
@smallexample
3: 0.0756823 1: 0 1: 0.25305 1: 0 1: 1.16659
2: 5:66 . . . .
1: 0.0757575
.
! 10 k b RET c f M-0 DEL 11 X DEL 12 X DEL 13 X DEL 14 X
! @end smallexample
@end group
Just to exercise loops a bit more, let's compute a table of even
Bernoulli numbers.
- @group
@smallexample
3: [] 1: [0.10132, 0.03079, 0.02340, 0.033197, ...]
2: 2 .
1: 30
.
! [ ] 2 RET 30 Z ( X | 2 Z )
! @end smallexample
@end group
@noindent
The vertical-bar @kbd{|} is the vector-concatenation command. When
--- 6279,6308 ----
The actual tenth Bernoulli number is @cite{5/66}.
@smallexample
+ @group
3: 0.0756823 1: 0 1: 0.25305 1: 0 1: 1.16659
2: 5:66 . . . .
1: 0.0757575
.
! 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 group
+ @end smallexample
Just to exercise loops a bit more, let's compute a table of even
Bernoulli numbers.
@smallexample
+ @group
3: [] 1: [0.10132, 0.03079, 0.02340, 0.033197, ...]
2: 2 .
1: 30
.
! [ ] 2 @key{RET} 30 Z ( X | 2 Z )
@end group
+ @end smallexample
@noindent
The vertical-bar @kbd{|} is the vector-concatenation command. When
***************
*** 6423,6440 ****
One technique is to enter a throwaway dummy definition for the macro,
then enter the real one in the edit command.
- @group
@smallexample
1: 3 1: 3 Keyboard Macro Editor.
! . . Original keys: 1 RET 2 +
type "1\r"
type "2"
calc-plus
! C-x ( 1 RET 2 + C-x ) Z K h RET Z E h
! @end smallexample
@end group
@noindent
This shows the screen display assuming you have the @file{macedit}
--- 6324,6341 ----
One technique is to enter a throwaway dummy definition for the macro,
then enter the real one in the edit command.
@smallexample
+ @group
1: 3 1: 3 Keyboard Macro Editor.
! . . Original keys: 1 @key{RET} 2 +
type "1\r"
type "2"
calc-plus
! C-x ( 1 @key{RET} 2 + C-x ) Z K h @key{RET} Z E h
@end group
+ @end smallexample
@noindent
This shows the screen display assuming you have the @file{macedit}
***************
*** 6460,6466 ****
calc-store-into # Store it in variable 1
type "1"
type "1" # Initial value for loop
! calc-roll-down # This is the TAB key; swap initial & final
calc-kbd-for # Begin "for" loop...
calc-inv # Take reciprocal
calc-store-plus # Add to accumulator
--- 6361,6367 ----
calc-store-into # Store it in variable 1
type "1"
type "1" # Initial value for loop
! calc-roll-down # This is the @key{TAB} key; swap initial & final
calc-kbd-for # Begin "for" loop...
calc-inv # Take reciprocal
calc-store-plus # Add to accumulator
***************
*** 6475,6488 ****
@noindent
Press @kbd{M-# M-#} to finish editing and return to the Calculator.
- @group
@smallexample
1: 20 1: 3.597739
. .
20 z h
- @end smallexample
@end group
If you don't know how to write a particular command in @file{macedit}
format, you can always write it as keystrokes in a @code{type} command.
--- 6376,6389 ----
@noindent
Press @kbd{M-# M-#} to finish editing and return to the Calculator.
@smallexample
+ @group
1: 20 1: 3.597739
. .
20 z h
@end group
+ @end smallexample
If you don't know how to write a particular command in @file{macedit}
format, you can always write it as keystrokes in a @code{type} command.
***************
*** 6492,6509 ****
of the current buffer as a sequence of keystroke names, and defines that
sequence on the @kbd{X} (and @kbd{C-x e}) key. Because this is so
useful, Calc puts this command on the @kbd{M-# m} key. Try reading in
! this macro in the following form: Press @kbd{C-@@} (or @kbd{C-SPC}) at
one end of the text below, then type @kbd{M-# m} at the other.
- @group
@example
Z ` 0 t 1
! 1 TAB
Z ( & s + 1 1 Z )
r 1
Z '
- @end example
@end group
(@bullet{}) @strong{Exercise 8.} A general algorithm for solving
equations numerically is @dfn{Newton's Method}. Given the equation
--- 6393,6410 ----
of the current buffer as a sequence of keystroke names, and defines that
sequence on the @kbd{X} (and @kbd{C-x e}) key. Because this is so
useful, Calc puts this command on the @kbd{M-# m} key. Try reading in
! this macro in the following form: Press @kbd{C-@@} (or @address@hidden) at
one end of the text below, then type @kbd{M-# m} at the other.
@example
+ @group
Z ` 0 t 1
! 1 @key{TAB}
Z ( & s + 1 1 Z )
r 1
Z '
@end group
+ @end example
(@bullet{}) @strong{Exercise 8.} A general algorithm for solving
equations numerically is @dfn{Newton's Method}. Given the equation
***************
*** 6667,6673 ****
This section includes answers to all the exercises in the Calc tutorial.
@menu
! * RPN Answer 1:: 1 RET 2 RET 3 RET 4 + * -
* RPN Answer 2:: 2*4 + 7*9.5 + 5/4
* RPN Answer 3:: Operating on levels 2 and 3
* RPN Answer 4:: Joe's complex problems
--- 6568,6574 ----
This section includes answers to all the exercises in the Calc tutorial.
@menu
! * RPN Answer 1:: 1 @key{RET} 2 @key{RET} 3 @key{RET} 4 + * -
* RPN Answer 2:: 2*4 + 7*9.5 + 5/4
* RPN Answer 3:: Operating on levels 2 and 3
* RPN Answer 4:: Joe's complex problems
***************
*** 6770,6812 ****
both of these results waiting on the stack you can then compute the
final term, then press @kbd{+ +} to add everything up.
- @group
@smallexample
2: 2 1: 8 3: 8 2: 8
1: 4 . 2: 7 1: 66.5
. 1: 9.5 .
.
! 2 RET 4 * 7 RET 9.5 *
- @end smallexample
@end group
@noindent
- @group
@smallexample
4: 8 3: 8 2: 8 1: 75.75
3: 66.5 2: 66.5 1: 67.75 .
2: 5 1: 1.25 .
1: 4 .
.
! 5 RET 4 / + +
! @end smallexample
@end group
Alternatively, you could add the first two terms before going on
with the third term.
- @group
@smallexample
2: 8 1: 74.5 3: 74.5 2: 74.5 1: 75.75
1: 66.5 . 2: 5 1: 1.25 .
. 1: 4 .
.
! ... + 5 RET 4 / +
! @end smallexample
@end group
On an old-style RPN calculator this second method would have the
advantage of using only three stack levels. But since Calc's stack
--- 6671,6713 ----
both of these results waiting on the stack you can then compute the
final term, then press @kbd{+ +} to add everything up.
@smallexample
+ @group
2: 2 1: 8 3: 8 2: 8
1: 4 . 2: 7 1: 66.5
. 1: 9.5 .
.
! 2 @key{RET} 4 * 7 @key{RET} 9.5 *
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
4: 8 3: 8 2: 8 1: 75.75
3: 66.5 2: 66.5 1: 67.75 .
2: 5 1: 1.25 .
1: 4 .
.
! 5 @key{RET} 4 / + +
@end group
+ @end smallexample
Alternatively, you could add the first two terms before going on
with the third term.
@smallexample
+ @group
2: 8 1: 74.5 3: 74.5 2: 74.5 1: 75.75
1: 66.5 . 2: 5 1: 1.25 .
. 1: 4 .
.
! ... + 5 @key{RET} 4 / +
@end group
+ @end smallexample
On an old-style RPN calculator this second method would have the
advantage of using only three stack levels. But since Calc's stack
***************
*** 6819,6848 ****
@noindent
The @key{TAB} key provides a way to operate on the number in level 2.
- @group
@smallexample
3: 10 3: 10 4: 10 3: 10 3: 10
2: 20 2: 30 3: 30 2: 30 2: 21
1: 30 1: 20 2: 20 1: 21 1: 30
. . 1: 1 . .
.
! TAB 1 + TAB
! @end smallexample
@end group
! Similarly, @key{M-TAB} gives you access to the number in level 3.
- @group
@smallexample
3: 10 3: 21 3: 21 3: 30 3: 11
2: 21 2: 30 2: 30 2: 11 2: 21
1: 30 1: 10 1: 11 1: 21 1: 30
. . . . .
! M-TAB 1 + M-TAB M-TAB
! @end smallexample
@end group
@node RPN Answer 4, Algebraic Answer 1, RPN Answer 3, Answers to Exercises
@subsection RPN Tutorial Exercise 4
--- 6720,6749 ----
@noindent
The @key{TAB} key provides a way to operate on the number in level 2.
@smallexample
+ @group
3: 10 3: 10 4: 10 3: 10 3: 10
2: 20 2: 30 3: 30 2: 30 2: 21
1: 30 1: 20 2: 20 1: 21 1: 30
. . 1: 1 . .
.
! @key{TAB} 1 + @key{TAB}
@end group
+ @end smallexample
! Similarly, @address@hidden gives you access to the number in level 3.
@smallexample
+ @group
3: 10 3: 21 3: 21 3: 30 3: 11
2: 21 2: 30 2: 30 2: 11 2: 21
1: 30 1: 10 1: 11 1: 21 1: 30
. . . . .
! address@hidden 1 + address@hidden
address@hidden
@end group
+ @end smallexample
@node RPN Answer 4, Algebraic Answer 1, RPN Answer 3, Answers to Exercises
@subsection RPN Tutorial Exercise 4
***************
*** 6851,6865 ****
Either @kbd{( 2 , 3 )} or @kbd{( 2 @key{SPC} 3 )} would have worked,
but using both the comma and the space at once yields:
- @group
@smallexample
1: ( ... 2: ( ... 1: (2, ... 2: (2, ... 2: (2, ...
. 1: 2 . 1: (2, ... 1: (2, 3)
. . .
! ( 2 , SPC 3 )
! @end smallexample
@end group
Joe probably tried to type @address@hidden @key{DEL}} to swap the
extra incomplete object to the top of the stack and delete it.
--- 6752,6766 ----
Either @kbd{( 2 , 3 )} or @kbd{( 2 @key{SPC} 3 )} would have worked,
but using both the comma and the space at once yields:
@smallexample
+ @group
1: ( ... 2: ( ... 1: (2, ... 2: (2, ... 2: (2, ...
. 1: 2 . 1: (2, ... 1: (2, 3)
. . .
! ( 2 , @key{SPC} 3 )
@end group
+ @end smallexample
Joe probably tried to type @address@hidden @key{DEL}} to swap the
extra incomplete object to the top of the stack and delete it.
***************
*** 6867,6885 ****
deletes just one component out of that object, so he had to press
@key{DEL} twice to finish the job.
- @group
@smallexample
2: (2, ... 2: (2, 3) 2: (2, 3) 1: (2, 3)
1: (2, 3) 1: (2, ... 1: ( ... .
. . .
! TAB DEL DEL
! @end smallexample
@end group
(As it turns out, deleting the second-to-top stack entry happens often
! enough that Calc provides a special key, @kbd{M-DEL}, to do just that.
! @kbd{M-DEL} is just like @kbd{TAB DEL}, except that it doesn't exhibit
the ``feature'' that tripped poor Joe.)
@node Algebraic Answer 1, Algebraic Answer 2, RPN Answer 4, Answers to
Exercises
--- 6768,6786 ----
deletes just one component out of that object, so he had to press
@key{DEL} twice to finish the job.
@smallexample
+ @group
2: (2, ... 2: (2, 3) 2: (2, 3) 1: (2, 3)
1: (2, 3) 1: (2, ... 1: ( ... .
. . .
! @key{TAB} @key{DEL} @key{DEL}
@end group
+ @end smallexample
(As it turns out, deleting the second-to-top stack entry happens often
! enough that Calc provides a special key, @address@hidden, to do just that.
! @address@hidden is just like @address@hidden @key{DEL}}, except that it
doesn't exhibit
the ``feature'' that tripped poor Joe.)
@node Algebraic Answer 1, Algebraic Answer 2, RPN Answer 4, Answers to
Exercises
***************
*** 6990,6996 ****
@samp{16#F.E8F*16.^15}. You can enter a number like this as an
algebraic entry. Also, pressing @kbd{e} without any digits before it
normally types @kbd{1e}, but in a high radix it types @kbd{16.^} and
! puts you in algebraic entry: @kbd{16#f.e8f RET e 15 RET *} is another
way to enter this number.
The reason Calc puts a decimal point in the @samp{16.^} is to prevent
--- 6891,6897 ----
@samp{16#F.E8F*16.^15}. You can enter a number like this as an
algebraic entry. Also, pressing @kbd{e} without any digits before it
normally types @kbd{1e}, but in a high radix it types @kbd{16.^} and
! puts you in algebraic entry: @kbd{16#f.e8f @key{RET} e 15 @key{RET} *} is
another
way to enter this number.
The reason Calc puts a decimal point in the @samp{16.^} is to prevent
***************
*** 7018,7041 ****
place (according to the current precision). They are useful for
determining facts like this.
- @group
@smallexample
1: 0.707106781187 1: 0.500000000001
. .
45 S 2 ^
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: 0.707106781187 1: 0.707106781186 1: 0.499999999999
. . .
! U DEL f [ 2 ^
! @end smallexample
@end group
A high-precision calculation must be carried out in high precision
all the way. The only number in the original problem which was known
--- 6919,6942 ----
place (according to the current precision). They are useful for
determining facts like this.
@smallexample
+ @group
1: 0.707106781187 1: 0.500000000001
. .
45 S 2 ^
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: 0.707106781187 1: 0.707106781186 1: 0.499999999999
. . .
! U @key{DEL} f [ 2 ^
@end group
+ @end smallexample
A high-precision calculation must be carried out in high precision
all the way. The only number in the original problem which was known
***************
*** 7102,7116 ****
Duplicate the vector, compute its length, then divide the vector
by its length: @address@hidden A /}.
- @group
@smallexample
1: [1, 2, 3] 2: [1, 2, 3] 1: [0.27, 0.53, 0.80] 1: 1.
. 1: 3.74165738677 . .
.
! r 1 RET A / A
! @end smallexample
@end group
The final @kbd{A} command shows that the normalized vector does
indeed have unit length.
--- 7003,7017 ----
Duplicate the vector, compute its length, then divide the vector
by its length: @address@hidden A /}.
@smallexample
+ @group
1: [1, 2, 3] 2: [1, 2, 3] 1: [0.27, 0.53, 0.80] 1: 1.
. 1: 3.74165738677 . .
.
! r 1 @key{RET} A / A
@end group
+ @end smallexample
The final @kbd{A} command shows that the normalized vector does
indeed have unit length.
***************
*** 7135,7146 ****
@subsection Matrix Tutorial Exercise 2
@ifinfo
- @group
@example
x + a y = 6
x + b y = 10
- @end example
@end group
@end ifinfo
@tex
\turnoffactive
--- 7036,7047 ----
@subsection Matrix Tutorial Exercise 2
@ifinfo
@example
+ @group
x + a y = 6
x + b y = 10
@end group
+ @end example
@end ifinfo
@tex
\turnoffactive
***************
*** 7154,7180 ****
Just enter the righthand side vector, then divide by the lefthand side
matrix as usual.
- @group
@smallexample
1: [6, 10] 2: [6, 10] 1: [6 - 4 a / (b - a), 4 / (b - a) ]
. 1: [ [ 1, a ] .
[ 1, b ] ]
.
! ' [6 10] RET ' [1 a; 1 b] RET /
! @end smallexample
@end group
This can be made more readable using @kbd{d B} to enable ``big'' display
mode:
- @group
@smallexample
4 a 4
1: [6 - -----, -----]
b - a b - a
- @end smallexample
@end group
Type @kbd{d N} to return to ``normal'' display mode afterwards.
--- 7055,7081 ----
Just enter the righthand side vector, then divide by the lefthand side
matrix as usual.
@smallexample
+ @group
1: [6, 10] 2: [6, 10] 1: [6 - 4 a / (b - a), 4 / (b - a) ]
. 1: [ [ 1, a ] .
[ 1, b ] ]
.
! ' [6 10] @key{RET} ' [1 a; 1 b] @key{RET} /
@end group
+ @end smallexample
This can be made more readable using @kbd{d B} to enable ``big'' display
mode:
@smallexample
+ @group
4 a 4
1: [6 - -----, -----]
b - a b - a
@end group
+ @end smallexample
Type @kbd{d N} to return to ``normal'' display mode afterwards.
***************
*** 7192,7205 ****
command.
@ifinfo
- @group
@example
a + 2b + 3c = 6
4a + 5b + 6c = 2
7a + 6b = 3
2a + 4b + 6c = 11
- @end example
@end group
@end ifinfo
@tex
\turnoffactive
--- 7093,7106 ----
command.
@ifinfo
@example
+ @group
a + 2b + 3c = 6
4a + 5b + 6c = 2
7a + 6b = 3
2a + 4b + 6c = 11
@end group
+ @end example
@end ifinfo
@tex
\turnoffactive
***************
*** 7222,7245 ****
@c{$B'$}
@cite{B2} vector.
- @group
@smallexample
1: [ [ 1, 2, 3 ] 2: [ [ 1, 4, 7, 2 ] 1: [57, 84, 96]
[ 4, 5, 6 ] [ 2, 5, 6, 4 ] .
[ 7, 6, 0 ] [ 3, 6, 0, 6 ] ]
[ 2, 4, 6 ] ] 1: [6, 2, 3, 11]
. .
! ' [1 2 3; 4 5 6; 7 6 0; 2 4 6] RET s 7 v t [6 2 3 11] *
! @end smallexample
@end group
@noindent
Now we compute the matrix @c{$A'$}
@cite{A2} and divide.
- @group
@smallexample
2: [57, 84, 96] 1: [-11.64, 14.08, -3.64]
1: [ [ 70, 72, 39 ] .
[ 72, 81, 60 ]
--- 7123,7146 ----
@c{$B'$}
@cite{B2} vector.
@smallexample
+ @group
1: [ [ 1, 2, 3 ] 2: [ [ 1, 4, 7, 2 ] 1: [57, 84, 96]
[ 4, 5, 6 ] [ 2, 5, 6, 4 ] .
[ 7, 6, 0 ] [ 3, 6, 0, 6 ] ]
[ 2, 4, 6 ] ] 1: [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 group
+ @end smallexample
@noindent
Now we compute the matrix @c{$A'$}
@cite{A2} and divide.
@smallexample
+ @group
2: [57, 84, 96] 1: [-11.64, 14.08, -3.64]
1: [ [ 70, 72, 39 ] .
[ 72, 81, 60 ]
***************
*** 7247,7254 ****
.
r 7 v t r 7 * /
- @end smallexample
@end group
@noindent
(The actual computed answer will be slightly inexact due to
--- 7148,7155 ----
.
r 7 v t r 7 * /
@end group
+ @end smallexample
@noindent
(The actual computed answer will be slightly inexact due to
***************
*** 7268,7275 ****
can't both be satisfied at once. Let's plug our answers back into
the original system of equations to see how well they match.
- @group
@smallexample
2: [-11.64, 14.08, -3.64] 1: [5.6, 2., 3., 11.2]
1: [ [ 1, 2, 3 ] .
[ 4, 5, 6 ]
--- 7169,7176 ----
can't both be satisfied at once. Let's plug our answers back into
the original system of equations to see how well they match.
@smallexample
+ @group
2: [-11.64, 14.08, -3.64] 1: [5.6, 2., 3., 11.2]
1: [ [ 1, 2, 3 ] .
[ 4, 5, 6 ]
***************
*** 7277,7285 ****
[ 2, 4, 6 ] ]
.
! r 7 TAB *
! @end smallexample
@end group
@noindent
This is reasonably close to our original @cite{B} vector,
--- 7178,7186 ----
[ 2, 4, 6 ] ]
.
! r 7 @key{TAB} *
@end group
+ @end smallexample
@noindent
This is reasonably close to our original @cite{B} vector,
***************
*** 7294,7321 ****
across the vector will accomplish this, although it turns out the
plain @samp{-} key will work just as well.
- @group
@smallexample
2: 2 2: 2
1: [1, 2, 3, 4, 5, 6, 7, 8, 9] 1: [-4, -3, -2, -1, 0, 1, 2, 3, 4]
. .
! 2 v x 9 RET 5 V M - or 5 -
! @end smallexample
@end group
@noindent
Now we use @kbd{V M ^} to map the exponentiation operator across the
vector.
- @group
@smallexample
1: [0.0625, 0.125, 0.25, 0.5, 1, 2, 4, 8, 16]
.
V M ^
- @end smallexample
@end group
@node List Answer 2, List Answer 3, List Answer 1, Answers to Exercises
@subsection List Tutorial Exercise 2
--- 7195,7222 ----
across the vector will accomplish this, although it turns out the
plain @samp{-} key will work just as well.
@smallexample
+ @group
2: 2 2: 2
1: [1, 2, 3, 4, 5, 6, 7, 8, 9] 1: [-4, -3, -2, -1, 0, 1, 2, 3, 4]
. .
! 2 v x 9 @key{RET} 5 V M - or 5 -
@end group
+ @end smallexample
@noindent
Now we use @kbd{V M ^} to map the exponentiation operator across the
vector.
@smallexample
+ @group
1: [0.0625, 0.125, 0.25, 0.5, 1, 2, 4, 8, 16]
.
V M ^
@end group
+ @end smallexample
@node List Answer 2, List Answer 3, List Answer 1, Answers to Exercises
@subsection List Tutorial Exercise 2
***************
*** 7341,7384 ****
ones as the other column. So, first we build the column of ones, then
we combine the two columns to form our @cite{A} matrix.
- @group
@smallexample
2: [1.34, 1.41, 1.49, ... ] 1: [ [ 1.34, 1 ]
1: [1, 1, 1, ...] [ 1.41, 1 ]
. [ 1.49, 1 ]
@dots{}
! r 1 1 v b 19 RET M-2 v p v t s 3
! @end smallexample
@end group
@noindent
Now we compute @c{$A^T y$}
@cite{trn(A) * y} and @c{$A^T A$}
@cite{trn(A) * A} and divide.
- @group
@smallexample
1: [33.36554, 13.613] 2: [33.36554, 13.613]
. 1: [ [ 98.0003, 41.63 ]
[ 41.63, 19 ] ]
.
v t r 2 * r 3 v t r 3 *
- @end smallexample
@end group
@noindent
(Hey, those numbers look familiar!)
- @group
@smallexample
1: [0.52141679, -0.425978]
.
/
- @end smallexample
@end group
Since we were solving equations of the form @c{$m \times x + b \times 1 = y$}
@cite{m*x + b*1 = y}, these
--- 7242,7285 ----
ones as the other column. So, first we build the column of ones, then
we combine the two columns to form our @cite{A} matrix.
@smallexample
+ @group
2: [1.34, 1.41, 1.49, ... ] 1: [ [ 1.34, 1 ]
1: [1, 1, 1, ...] [ 1.41, 1 ]
. [ 1.49, 1 ]
@dots{}
! r 1 1 v b 19 @key{RET} M-2 v p v t s 3
@end group
+ @end smallexample
@noindent
Now we compute @c{$A^T y$}
@cite{trn(A) * y} and @c{$A^T A$}
@cite{trn(A) * A} and divide.
@smallexample
+ @group
1: [33.36554, 13.613] 2: [33.36554, 13.613]
. 1: [ [ 98.0003, 41.63 ]
[ 41.63, 19 ] ]
.
v t r 2 * r 3 v t r 3 *
@end group
+ @end smallexample
@noindent
(Hey, those numbers look familiar!)
@smallexample
+ @group
1: [0.52141679, -0.425978]
.
/
@end group
+ @end smallexample
Since we were solving equations of the form @c{$m \times x + b \times 1 = y$}
@cite{m*x + b*1 = y}, these
***************
*** 7397,7436 ****
@subsection List Tutorial Exercise 3
@noindent
! Move to one end of the list and press @kbd{C-@@} (or @kbd{C-SPC} or
whatever) to set the mark, then move to the other end of the list
and type @address@hidden g}}.
- @group
@smallexample
1: [2.3, 6, 22, 15.1, 7, 15, 14, 7.5, 2.5]
.
- @end smallexample
@end group
To make things interesting, let's assume we don't know at a glance
how many numbers are in this list. Then we could type:
- @group
@smallexample
2: [2.3, 6, 22, ... ] 2: [2.3, 6, 22, ... ]
1: [2.3, 6, 22, ... ] 1: 126356422.5
. .
! RET V R *
- @end smallexample
@end group
@noindent
- @group
@smallexample
2: 126356422.5 2: 126356422.5 1: 7.94652913734
1: [2.3, 6, 22, ... ] 1: 9 .
. .
! TAB v l I ^
! @end smallexample
@end group
@noindent
(The @kbd{I ^} command computes the @var{n}th root of a number.
--- 7298,7337 ----
@subsection List Tutorial Exercise 3
@noindent
! Move to one end of the list and press @kbd{C-@@} (or @address@hidden or
whatever) to set the mark, then move to the other end of the list
and type @address@hidden g}}.
@smallexample
+ @group
1: [2.3, 6, 22, 15.1, 7, 15, 14, 7.5, 2.5]
.
@end group
+ @end smallexample
To make things interesting, let's assume we don't know at a glance
how many numbers are in this list. Then we could type:
@smallexample
+ @group
2: [2.3, 6, 22, ... ] 2: [2.3, 6, 22, ... ]
1: [2.3, 6, 22, ... ] 1: 126356422.5
. .
! @key{RET} V R *
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
2: 126356422.5 2: 126356422.5 1: 7.94652913734
1: [2.3, 6, 22, ... ] 1: 9 .
. .
! @key{TAB} v l I ^
@end group
+ @end smallexample
@noindent
(The @kbd{I ^} command computes the @var{n}th root of a number.
***************
*** 7445,7459 ****
@samp{n % j = 0}. The first
step is to get a vector that identifies the divisors.
- @group
@smallexample
2: 30 2: [0, 0, 0, 2, ...] 1: [1, 1, 1, 0, ...]
1: [1, 2, 3, 4, ...] 1: 0 .
. .
! 30 RET v x 30 RET s 1 V M % 0 V M a = s 2
! @end smallexample
@end group
@noindent
This vector has 1's marking divisors of 30 and 0's marking non-divisors.
--- 7346,7360 ----
@samp{n % j = 0}. The first
step is to get a vector that identifies the divisors.
@smallexample
+ @group
2: 30 2: [0, 0, 0, 2, ...] 1: [1, 1, 1, 0, ...]
1: [1, 2, 3, 4, ...] 1: 0 .
. .
! 30 @key{RET} v x 30 @key{RET} s 1 V M % 0 V M a = s 2
@end group
+ @end smallexample
@noindent
This vector has 1's marking divisors of 30 and 0's marking non-divisors.
***************
*** 7461,7476 ****
The zeroth divisor function is just the total number of divisors.
The first divisor function is the sum of the divisors.
- @group
@smallexample
1: 8 3: 8 2: 8 2: 8
2: [1, 2, 3, 4, ...] 1: [1, 2, 3, 0, ...] 1: 72
1: [1, 1, 1, 0, ...] . .
.
V R + r 1 r 2 V M * V R +
- @end smallexample
@end group
@noindent
Once again, the last two steps just compute a dot product for which
--- 7362,7377 ----
The zeroth divisor function is just the total number of divisors.
The first divisor function is the sum of the divisors.
@smallexample
+ @group
1: 8 3: 8 2: 8 2: 8
2: [1, 2, 3, 4, ...] 1: [1, 2, 3, 0, ...] 1: 72
1: [1, 1, 1, 0, ...] . .
.
V R + r 1 r 2 V M * V R +
@end group
+ @end smallexample
@noindent
Once again, the last two steps just compute a dot product for which
***************
*** 7485,7509 ****
they will be right next to each other. A suitable method is to compare
the list with a copy of itself shifted over by one.
- @group
@smallexample
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, 0] 1: [0, 3, 7, 7, 7, 19]
. .
! 19551 k f RET 0 | TAB 0 TAB |
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: [0, 0, 1, 1, 0, 0] 1: 2 1: 0
. . .
V M a = V R + 0 a =
- @end smallexample
@end group
@noindent
Note that we have to arrange for both vectors to have the same length
--- 7386,7410 ----
they will be right next to each other. A suitable method is to compare
the list with a copy of itself shifted over by one.
@smallexample
+ @group
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, 0] 1: [0, 3, 7, 7, 7, 19]
. .
! 19551 k f @key{RET} 0 | @key{TAB} 0
@key{TAB} |
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: [0, 0, 1, 1, 0, 0] 1: 2 1: 0
. . .
V M a = V R + 0 a =
@end group
+ @end smallexample
@noindent
Note that we have to arrange for both vectors to have the same length
***************
*** 7520,7526 ****
@subsection List Tutorial Exercise 6
@noindent
! First use @kbd{v x 6 RET} to get a list of integers, then @kbd{V M v x}
to get a list of lists of integers!
@node List Answer 7, List Answer 8, List Answer 6, Answers to Exercises
--- 7421,7427 ----
@subsection List Tutorial Exercise 6
@noindent
! First use @kbd{v x 6 @key{RET}} to get a list of integers, then @kbd{V M v x}
to get a list of lists of integers!
@node List Answer 7, List Answer 8, List Answer 6, Answers to Exercises
***************
*** 7530,7545 ****
Here's one solution. First, compute the triangular list from the previous
exercise and type @kbd{1 -} to subtract one from all the elements.
- @group
@smallexample
1: [ [0],
[0, 1],
[0, 1, 2],
@dots{}
1 -
- @end smallexample
@end group
The numbers down the lefthand edge of the list we desire are called
the ``triangular numbers'' (now you know why!). The @cite{n}th
--- 7431,7446 ----
Here's one solution. First, compute the triangular list from the previous
exercise and type @kbd{1 -} to subtract one from all the elements.
@smallexample
+ @group
1: [ [0],
[0, 1],
[0, 1, 2],
@dots{}
1 -
@end group
+ @end smallexample
The numbers down the lefthand edge of the list we desire are called
the ``triangular numbers'' (now you know why!). The @cite{n}th
***************
*** 7547,7568 ****
can be computed directly by the formula @c{$n (n+1) \over 2$}
@cite{n * (n+1) / 2}.
- @group
@smallexample
2: [ [0], [0, 1], ... ] 2: [ [0], [0, 1], ... ]
1: [0, 1, 2, 3, 4, 5] 1: [0, 1, 3, 6, 10, 15]
. .
! v x 6 RET 1 - V M ' $ ($+1)/2 RET
! @end smallexample
@end group
@noindent
Adding this list to the above list of lists produces the desired
result:
- @group
@smallexample
1: [ [0],
[1, 2],
[3, 4, 5],
--- 7448,7469 ----
can be computed directly by the formula @c{$n (n+1) \over 2$}
@cite{n * (n+1) / 2}.
@smallexample
+ @group
2: [ [0], [0, 1], ... ] 2: [ [0], [0, 1], ... ]
1: [0, 1, 2, 3, 4, 5] 1: [0, 1, 3, 6, 10, 15]
. .
! v x 6 @key{RET} 1 - V M ' $ ($+1)/2 @key{RET}
@end group
+ @end smallexample
@noindent
Adding this list to the above list of lists produces the desired
result:
@smallexample
+ @group
1: [ [0],
[1, 2],
[3, 4, 5],
***************
*** 7572,7594 ****
.
V M +
- @end smallexample
@end group
If we did not know the formula for triangular numbers, we could have
computed them using a @kbd{V U +} command. We could also have
gotten them the hard way by mapping a reduction across the original
triangular list.
- @group
@smallexample
2: [ [0], [0, 1], ... ] 2: [ [0], [0, 1], ... ]
1: [ [0], [0, 1], ... ] 1: [0, 1, 3, 6, 10, 15]
. .
! RET V M V R +
! @end smallexample
@end group
@noindent
(This means ``map a @kbd{V R +} command across the vector,'' and
--- 7473,7495 ----
.
V M +
@end group
+ @end smallexample
If we did not know the formula for triangular numbers, we could have
computed them using a @kbd{V U +} command. We could also have
gotten them the hard way by mapping a reduction across the original
triangular list.
@smallexample
+ @group
2: [ [0], [0, 1], ... ] 2: [ [0], [0, 1], ... ]
1: [ [0], [0, 1], ... ] 1: [0, 1, 3, 6, 10, 15]
. .
! @key{RET} V M V R +
@end group
+ @end smallexample
@noindent
(This means ``map a @kbd{V R +} command across the vector,'' and
***************
*** 7601,7641 ****
@noindent
The first step is to build a list of values of @cite{x}.
- @group
@smallexample
1: [1, 2, 3, ..., 21] 1: [0, 1, 2, ..., 20] 1: [0, 0.25, 0.5, ..., 5]
. . .
! v x 21 RET 1 - 4 / s 1
! @end smallexample
@end group
Next, we compute the Bessel function values.
- @group
@smallexample
1: [0., 0.124, 0.242, ..., -0.328]
.
! V M ' besJ(1,$) RET
! @end smallexample
@end group
@noindent
! (Another way to do this would be @kbd{1 TAB V M f j}.)
A way to isolate the maximum value is to compute the maximum using
@kbd{V R X}, then compare all the Bessel values with that maximum.
- @group
@smallexample
2: [0., 0.124, 0.242, ... ] 1: [0, 0, 0, ... ] 2: [0, 0, 0, ... ]
1: 0.5801562 . 1: 1
. .
! RET V R X V M a = RET V R + DEL
! @end smallexample
@end group
@noindent
It's a good idea to verify, as in the last step above, that only
--- 7502,7542 ----
@noindent
The first step is to build a list of values of @cite{x}.
@smallexample
+ @group
1: [1, 2, 3, ..., 21] 1: [0, 1, 2, ..., 20] 1: [0, 0.25, 0.5, ..., 5]
. . .
! v x 21 @key{RET} 1 - 4 / s 1
@end group
+ @end smallexample
Next, we compute the Bessel function values.
@smallexample
+ @group
1: [0., 0.124, 0.242, ..., -0.328]
.
! V M ' besJ(1,$) @key{RET}
@end group
+ @end smallexample
@noindent
! (Another way to do this would be @kbd{1 @key{TAB} V M f j}.)
A way to isolate the maximum value is to compute the maximum using
@kbd{V R X}, then compare all the Bessel values with that maximum.
@smallexample
+ @group
2: [0., 0.124, 0.242, ... ] 1: [0, 0, 0, ... ] 2: [0, 0, 0, ... ]
1: 0.5801562 . 1: 1
. .
! @key{RET} V R X V M a = @key{RET} V R
+ @key{DEL}
@end group
+ @end smallexample
@noindent
It's a good idea to verify, as in the last step above, that only
***************
*** 7647,7661 ****
the maximum value of @cite{x}. Now it is a simple matter to convert
this back into the corresponding value itself.
- @group
@smallexample
2: [0, 0, 0, ... ] 1: [0, 0., 0., ... ] 1: 1.75
1: [0, 0.25, 0.5, ... ] . .
.
r 1 V M * V R +
- @end smallexample
@end group
If @kbd{a =} had produced more than one @cite{1} value, this method
would have given the sum of all maximum @cite{x} values; not very
--- 7548,7562 ----
the maximum value of @cite{x}. Now it is a simple matter to convert
this back into the corresponding value itself.
@smallexample
+ @group
2: [0, 0, 0, ... ] 1: [0, 0., 0., ... ] 1: 1.75
1: [0, 0.25, 0.5, ... ] . .
.
r 1 V M * V R +
@end group
+ @end smallexample
If @kbd{a =} had produced more than one @cite{1} value, this method
would have given the sum of all maximum @cite{x} values; not very
***************
*** 7668,7682 ****
efficient methods. Just for illustration, let's use @kbd{a X}
to maximize @samp{besJ(1,x)} over this same interval.
- @group
@smallexample
2: besJ(1, x) 1: [1.84115, 0.581865]
1: [0 .. 5] .
.
! ' besJ(1,x), [0..5] RET a X x RET
! @end smallexample
@end group
@noindent
The output from @kbd{a X} is a vector containing the value of @cite{x}
--- 7569,7583 ----
efficient methods. Just for illustration, let's use @kbd{a X}
to maximize @samp{besJ(1,x)} over this same interval.
@smallexample
+ @group
2: besJ(1, x) 1: [1.84115, 0.581865]
1: [0 .. 5] .
.
! ' besJ(1,x), [0..5] @key{RET} a X x @key{RET}
@end group
+ @end smallexample
@noindent
The output from @kbd{a X} is a vector containing the value of @cite{x}
***************
*** 7689,7751 ****
@noindent
Step one is to convert our integer into vector notation.
- @group
@smallexample
1: 25129925999 3: 25129925999
. 2: 10
1: [11, 10, 9, ..., 1, 0]
.
! 25129925999 RET 10 RET 12 RET v x 12 RET -
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: 25129925999 1: [0, 2, 25, 251, 2512, ... ]
2: [100000000000, ... ] .
.
V M ^ s 1 V M \
- @end smallexample
@end group
@noindent
(Recall, the @kbd{\} command computes an integer quotient.)
- @group
@smallexample
1: [0, 2, 5, 1, 2, 9, 9, 2, 5, 9, 9, 9]
.
10 V M % s 2
- @end smallexample
@end group
Next we must increment this number. This involves adding one to
the last digit, plus handling carries. There is a carry to the
left out of a digit if that digit is a nine and all the digits to
the right of it are nines.
- @group
@smallexample
1: [0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1] 1: [1, 1, 1, 0, 0, 1, ... ]
. .
9 V M a = v v
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: [1, 1, 1, 0, 0, 0, ... ] 1: [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]
. .
V U * v v 1 |
- @end smallexample
@end group
@noindent
Accumulating @kbd{*} across a vector of ones and zeros will preserve
--- 7590,7652 ----
@noindent
Step one is to convert our integer into vector notation.
@smallexample
+ @group
1: 25129925999 3: 25129925999
. 2: 10
1: [11, 10, 9, ..., 1, 0]
.
! 25129925999 @key{RET} 10 @key{RET} 12 @key{RET} v x 12
@key{RET} -
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: 25129925999 1: [0, 2, 25, 251, 2512, ... ]
2: [100000000000, ... ] .
.
V M ^ s 1 V M \
@end group
+ @end smallexample
@noindent
(Recall, the @kbd{\} command computes an integer quotient.)
@smallexample
+ @group
1: [0, 2, 5, 1, 2, 9, 9, 2, 5, 9, 9, 9]
.
10 V M % s 2
@end group
+ @end smallexample
Next we must increment this number. This involves adding one to
the last digit, plus handling carries. There is a carry to the
left out of a digit if that digit is a nine and all the digits to
the right of it are nines.
@smallexample
+ @group
1: [0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1] 1: [1, 1, 1, 0, 0, 1, ... ]
. .
9 V M a = v v
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: [1, 1, 1, 0, 0, 0, ... ] 1: [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]
. .
V U * v v 1 |
@end group
+ @end smallexample
@noindent
Accumulating @kbd{*} across a vector of ones and zeros will preserve
***************
*** 7754,7768 ****
care of aligning the carries properly, and also adding one to the
rightmost digit.
- @group
@smallexample
2: [0, 0, 0, 0, ... ] 1: [0, 0, 2, 5, 1, 2, 9, 9, 2, 6, 0, 0, 0]
1: [0, 0, 2, 5, ... ] .
.
0 r 2 | V M + 10 V M %
- @end smallexample
@end group
@noindent
Here we have concatenated 0 to the @emph{left} of the original number;
--- 7655,7669 ----
care of aligning the carries properly, and also adding one to the
rightmost digit.
@smallexample
+ @group
2: [0, 0, 0, 0, ... ] 1: [0, 0, 2, 5, 1, 2, 9, 9, 2, 6, 0, 0, 0]
1: [0, 0, 2, 5, ... ] .
.
0 r 2 | V M + 10 V M %
@end group
+ @end smallexample
@noindent
Here we have concatenated 0 to the @emph{left} of the original number;
***************
*** 7771,7809 ****
Finally, we must convert this list back into an integer.
- @group
@smallexample
3: [0, 0, 2, 5, ... ] 2: [0, 0, 2, 5, ... ]
2: 1000000000000 1: [1000000000000, 100000000000, ... ]
1: [100000000000, ... ] .
.
! 10 RET 12 ^ r 1 |
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: [0, 0, 20000000000, 5000000000, ... ] 1: 25129926000
. .
V M * V R +
- @end smallexample
@end group
@noindent
Another way to do this final step would be to reduce the formula
@address@hidden $$ + $}} across the vector of digits.
- @group
@smallexample
1: [0, 0, 2, 5, ... ] 1: 25129926000
. .
! V R ' 10 $$ + $ RET
! @end smallexample
@end group
@node List Answer 10, List Answer 11, List Answer 9, Answers to Exercises
@subsection List Tutorial Exercise 10
--- 7672,7710 ----
Finally, we must convert this list back into an integer.
@smallexample
+ @group
3: [0, 0, 2, 5, ... ] 2: [0, 0, 2, 5, ... ]
2: 1000000000000 1: [1000000000000, 100000000000, ... ]
1: [100000000000, ... ] .
.
! 10 @key{RET} 12 ^ r 1 |
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: [0, 0, 20000000000, 5000000000, ... ] 1: 25129926000
. .
V M * V R +
@end group
+ @end smallexample
@noindent
Another way to do this final step would be to reduce the formula
@address@hidden $$ + $}} across the vector of digits.
@smallexample
+ @group
1: [0, 0, 2, 5, ... ] 1: 25129926000
. .
! V R ' 10 $$ + $ @key{RET}
@end group
+ @end smallexample
@node List Answer 10, List Answer 11, List Answer 9, Answers to Exercises
@subsection List Tutorial Exercise 10
***************
*** 7816,7840 ****
Here's a more correct method:
- @group
@smallexample
1: [7, 7, 7, 8, 7] 2: [7, 7, 7, 8, 7]
. 1: 7
.
! ' [7,7,7,8,7] RET RET v r 1 RET
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: [1, 1, 1, 0, 1] 1: 0
. .
V M a = V R *
- @end smallexample
@end group
@node List Answer 11, List Answer 12, List Answer 10, Answers to Exercises
@subsection List Tutorial Exercise 11
--- 7717,7741 ----
Here's a more correct method:
@smallexample
+ @group
1: [7, 7, 7, 8, 7] 2: [7, 7, 7, 8, 7]
. 1: 7
.
! ' [7,7,7,8,7] @key{RET} @key{RET} v r 1 @key{RET}
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: [1, 1, 1, 0, 1] 1: 0
. .
V M a = V R *
@end group
+ @end smallexample
@node List Answer 11, List Answer 12, List Answer 10, Answers to Exercises
@subsection List Tutorial Exercise 11
***************
*** 7847,7897 ****
We can make this go a bit faster by using the @kbd{v .} and @kbd{t .}
commands.
- @group
@smallexample
2: [2., 2., ..., 2.] 2: [2., 2., ..., 2.]
1: [2., 2., ..., 2.] 1: [1.16, 1.98, ..., 0.81]
. .
! v . t . 2. v b 100 RET RET V M k r
- @end smallexample
@end group
@noindent
- @group
@smallexample
2: [2., 2., ..., 2.] 1: [0.026, 0.96, ..., 0.036]
1: [0.026, 0.96, ..., 0.036] 2: [0.53, 0.81, ..., 0.094]
. .
! 1 - 2 V M ^ TAB V M k r 1 - 2 V M ^
! @end smallexample
@end group
Now we sum the @cite{x^2} and @cite{y^2} values, compare with 1 to
get a vector of 1/0 truth values, then sum the truth values.
- @group
@smallexample
1: [0.56, 1.78, ..., 0.13] 1: [1, 0, ..., 1] 1: 84
. . .
+ 1 V M a < V R +
- @end smallexample
@end group
@noindent
The ratio @cite{84/100} should approximate the ratio @c{$\pi/4$}
@cite{pi/4}.
- @group
@smallexample
1: 0.84 1: 3.36 2: 3.36 1: 1.0695
. . 1: 3.14159 .
100 / 4 * P /
- @end smallexample
@end group
@noindent
Our estimate, 3.36, is off by about 7%. We could get a better estimate
--- 7748,7798 ----
We can make this go a bit faster by using the @kbd{v .} and @kbd{t .}
commands.
@smallexample
+ @group
2: [2., 2., ..., 2.] 2: [2., 2., ..., 2.]
1: [2., 2., ..., 2.] 1: [1.16, 1.98, ..., 0.81]
. .
! v . t . 2. v b 100 @key{RET} @key{RET} V M k r
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
2: [2., 2., ..., 2.] 1: [0.026, 0.96, ..., 0.036]
1: [0.026, 0.96, ..., 0.036] 2: [0.53, 0.81, ..., 0.094]
. .
! 1 - 2 V M ^ @key{TAB} V M k r 1 - 2 V M ^
@end group
+ @end smallexample
Now we sum the @cite{x^2} and @cite{y^2} values, compare with 1 to
get a vector of 1/0 truth values, then sum the truth values.
@smallexample
+ @group
1: [0.56, 1.78, ..., 0.13] 1: [1, 0, ..., 1] 1: 84
. . .
+ 1 V M a < V R +
@end group
+ @end smallexample
@noindent
The ratio @cite{84/100} should approximate the ratio @c{$\pi/4$}
@cite{pi/4}.
@smallexample
+ @group
1: 0.84 1: 3.36 2: 3.36 1: 1.0695
. . 1: 3.14159 .
100 / 4 * P /
@end group
+ @end smallexample
@noindent
Our estimate, 3.36, is off by about 7%. We could get a better estimate
***************
*** 7939,8010 ****
We can make this go a bit faster by using the @kbd{v .} and @kbd{t .}
commands.
- @group
@smallexample
1: [0.52, 0.71, ..., 0.72] 2: [0.52, 0.71, ..., 0.72]
. 1: [78.4, 64.5, ..., -42.9]
.
! v . t . 1. v b 100 RET V M k r 180. v b 100 RET V M k r 90 -
! @end smallexample
@end group
@noindent
(The next step may be slow, depending on the speed of your computer.)
- @group
@smallexample
2: [0.52, 0.71, ..., 0.72] 1: [0.72, 1.14, ..., 1.45]
1: [0.20, 0.43, ..., 0.73] .
.
m d V M C +
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: [0, 1, ..., 1] 1: 0.64 1: 3.125
. . .
! 1 V M a > V R + 100 / 2 TAB /
! @end smallexample
@end group
Let's try the third method, too. We'll use random integers up to
one million. The @kbd{k r} command with an integer argument picks
a random integer.
- @group
@smallexample
2: [1000000, 1000000, ..., 1000000] 2: [78489, 527587, ..., 814975]
1: [1000000, 1000000, ..., 1000000] 1: [324014, 358783, ..., 955450]
. .
! 1000000 v b 100 RET RET V M k r TAB V M k r
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: [1, 1, ..., 25] 1: [1, 1, ..., 0] 1: 0.56
. . .
V M k g 1 V M a = V R + 100 /
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: 10.714 1: 3.273
. .
! 6 TAB / Q
! @end smallexample
@end group
For a proof of this property of the GCD function, see section 4.5.2,
exercise 10, of Knuth's @emph{Art of Computer Programming}, volume II.
--- 7840,7911 ----
We can make this go a bit faster by using the @kbd{v .} and @kbd{t .}
commands.
@smallexample
+ @group
1: [0.52, 0.71, ..., 0.72] 2: [0.52, 0.71, ..., 0.72]
. 1: [78.4, 64.5, ..., -42.9]
.
! v . t . 1. v b 100 @key{RET} V M k r 180. v b 100 @key{RET} V M k r 90 -
@end group
+ @end smallexample
@noindent
(The next step may be slow, depending on the speed of your computer.)
@smallexample
+ @group
2: [0.52, 0.71, ..., 0.72] 1: [0.72, 1.14, ..., 1.45]
1: [0.20, 0.43, ..., 0.73] .
.
m d V M C +
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: [0, 1, ..., 1] 1: 0.64 1: 3.125
. . .
! 1 V M a > V R + 100 / 2 @key{TAB} /
@end group
+ @end smallexample
Let's try the third method, too. We'll use random integers up to
one million. The @kbd{k r} command with an integer argument picks
a random integer.
@smallexample
+ @group
2: [1000000, 1000000, ..., 1000000] 2: [78489, 527587, ..., 814975]
1: [1000000, 1000000, ..., 1000000] 1: [324014, 358783, ..., 955450]
. .
! 1000000 v b 100 @key{RET} @key{RET} V M k r @key{TAB} V
M k r
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: [1, 1, ..., 25] 1: [1, 1, ..., 0] 1: 0.56
. . .
V M k g 1 V M a = V R + 100 /
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: 10.714 1: 3.273
. .
! 6 @key{TAB} / Q
@end group
+ @end smallexample
For a proof of this property of the GCD function, see section 4.5.2,
exercise 10, of Knuth's @emph{Art of Computer Programming}, volume II.
***************
*** 8018,8031 ****
@noindent
First, we put the string on the stack as a vector of ASCII codes.
- @group
@smallexample
1: [84, 101, 115, ..., 51]
.
! "Testing, 1, 2, 3 RET
! @end smallexample
@end group
@noindent
Note that the @kbd{"} key, like @kbd{$}, initiates algebraic entry so
--- 7919,7932 ----
@noindent
First, we put the string on the stack as a vector of ASCII codes.
@smallexample
+ @group
1: [84, 101, 115, ..., 51]
.
! "Testing, 1, 2, 3 @key{RET}
@end group
+ @end smallexample
@noindent
Note that the @kbd{"} key, like @kbd{$}, initiates algebraic entry so
***************
*** 8038,8063 ****
@cite{3 (3 (3a + b) + c) + d = 27a + 9b + 3c + d}. In other words,
it's a sum of descending powers of three times the ASCII codes.
- @group
@smallexample
2: [84, 101, 115, ..., 51] 2: [84, 101, 115, ..., 51]
1: 16 1: [15, 14, 13, ..., 0]
. .
! RET v l v x 16 RET -
- @end smallexample
@end group
@noindent
- @group
@smallexample
2: [84, 101, 115, ..., 51] 1: 1960915098 1: 121
1: [14348907, ..., 1] . .
.
! 3 TAB V M ^ * 511 %
! @end smallexample
@end group
@noindent
Once again, @kbd{*} elegantly summarizes most of the computation.
--- 7939,7964 ----
@cite{3 (3 (3a + b) + c) + d = 27a + 9b + 3c + d}. In other words,
it's a sum of descending powers of three times the ASCII codes.
@smallexample
+ @group
2: [84, 101, 115, ..., 51] 2: [84, 101, 115, ..., 51]
1: 16 1: [15, 14, 13, ..., 0]
. .
! @key{RET} v l v x 16 @key{RET} -
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
2: [84, 101, 115, ..., 51] 1: 1960915098 1: 121
1: [14348907, ..., 1] . .
.
! 3 @key{TAB} V M ^ * 511 %
@end group
+ @end smallexample
@noindent
Once again, @kbd{*} elegantly summarizes most of the computation.
***************
*** 8066,8079 ****
function of two arguments that computes its first argument times three
plus its second argument.
- @group
@smallexample
1: [84, 101, 115, ..., 51] 1: 1960915098
. .
! "Testing, 1, 2, 3 RET V R ' 3$$+$ RET
! @end smallexample
@end group
@noindent
If you did the decimal arithmetic exercise, this will be familiar.
--- 7967,7980 ----
function of two arguments that computes its first argument times three
plus its second argument.
@smallexample
+ @group
1: [84, 101, 115, ..., 51] 1: 1960915098
. .
! "Testing, 1, 2, 3 @key{RET} V R ' 3$$+$ @key{RET}
@end group
+ @end smallexample
@noindent
If you did the decimal arithmetic exercise, this will be familiar.
***************
*** 8087,8100 ****
arithmetic operations, the numbers we operate on remain small so
the operations are faster.
- @group
@smallexample
1: [84, 101, 115, ..., 51] 1: 121
. .
! "Testing, 1, 2, 3 RET V R ' (3$$+$)%511 RET
! @end smallexample
@end group
Why does this work? Think about a two-step computation:
@address@hidden (3a + b) + c}}. Taking a result modulo 511 basically means
--- 7988,8001 ----
arithmetic operations, the numbers we operate on remain small so
the operations are faster.
@smallexample
+ @group
1: [84, 101, 115, ..., 51] 1: 121
. .
! "Testing, 1, 2, 3 @key{RET} V R ' (3$$+$)%511 @key{RET}
@end group
+ @end smallexample
Why does this work? Think about a two-step computation:
@address@hidden (3a + b) + c}}. Taking a result modulo 511 basically means
***************
*** 8153,8159 ****
Later in the tutorial we will encounter @dfn{modulo forms}, which
basically automate the idea of reducing every intermediate result
! modulo some value @i{M}.
@node List Answer 14, Types Answer 1, List Answer 13, Answers to Exercises
@subsection List Tutorial Exercise 14
--- 8054,8060 ----
Later in the tutorial we will encounter @dfn{modulo forms}, which
basically automate the idea of reducing every intermediate result
! modulo some value @var{m}.
@node List Answer 14, Types Answer 1, List Answer 13, Answers to Exercises
@subsection List Tutorial Exercise 14
***************
*** 8162,8177 ****
step to an @cite{(x,y)} coordinate. The function is a bit long, but
otherwise the problem is quite straightforward.
- @group
@smallexample
2: [0, 0] 1: [ [ 0, 0 ]
1: 50 [ 0.4288, -0.1695 ]
. [ -0.4787, -0.9027 ]
...
! [0,0] 50 H V U ' <# + [random(2.0)-1, random(2.0)-1]> RET
! @end smallexample
@end group
Just as the text recommended, we used @samp{< >} nameless function
notation to keep the two @code{random} calls from being evaluated
--- 8063,8078 ----
step to an @cite{(x,y)} coordinate. The function is a bit long, but
otherwise the problem is quite straightforward.
@smallexample
+ @group
2: [0, 0] 1: [ [ 0, 0 ]
1: 50 [ 0.4288, -0.1695 ]
. [ -0.4787, -0.9027 ]
...
! [0,0] 50 H V U ' <# + [random(2.0)-1, random(2.0)-1]> @key{RET}
@end group
+ @end smallexample
Just as the text recommended, we used @samp{< >} nameless function
notation to keep the two @code{random} calls from being evaluated
***************
*** 8181,8195 ****
rules acts like a matrix. We can transpose this matrix and unpack
to get a pair of vectors, @cite{x} and @cite{y}, suitable for graphing.
- @group
@smallexample
2: [ 0, 0.4288, -0.4787, ... ]
1: [ 0, -0.1696, -0.9027, ... ]
.
v t v u g f
- @end smallexample
@end group
Incidentally, because the @cite{x} and @cite{y} are completely
independent in this case, we could have done two separate commands
--- 8082,8096 ----
rules acts like a matrix. We can transpose this matrix and unpack
to get a pair of vectors, @cite{x} and @cite{y}, suitable for graphing.
@smallexample
+ @group
2: [ 0, 0.4288, -0.4787, ... ]
1: [ 0, -0.1696, -0.9027, ... ]
.
v t v u g f
@end group
+ @end smallexample
Incidentally, because the @cite{x} and @cite{y} are completely
independent in this case, we could have done two separate commands
***************
*** 8200,8215 ****
length; in fact, the new nesting function is even briefer, though
we might want to lower the precision a bit for it.
- @group
@smallexample
2: [0, 0] 1: [ [ 0, 0 ]
1: 50 [ 0.1318, 0.9912 ]
. [ -0.5965, 0.3061 ]
...
! [0,0] 50 m d p 6 RET H V U ' <# + sincos(random(360.0))> RET
! @end smallexample
@end group
Another @kbd{v t v u g f} sequence will graph this new random walk.
--- 8101,8116 ----
length; in fact, the new nesting function is even briefer, though
we might want to lower the precision a bit for it.
@smallexample
+ @group
2: [0, 0] 1: [ [ 0, 0 ]
1: 50 [ 0.1318, 0.9912 ]
. [ -0.5965, 0.3061 ]
...
! [0,0] 50 m d p 6 @key{RET} H V U ' <# + sincos(random(360.0))>
@key{RET}
@end group
+ @end smallexample
Another @kbd{v t v u g f} sequence will graph this new random walk.
***************
*** 8229,8242 ****
then its square, divided by @c{$\pi$}
@cite{pi}, should be a rational number.
- @group
@smallexample
1: 1.26508260337 1: 0.509433962268 1: 2486645810:4881193627
. . .
2 ^ P / c F
- @end smallexample
@end group
@noindent
Technically speaking this is a rational number, but not one that is
--- 8130,8143 ----
then its square, divided by @c{$\pi$}
@cite{pi}, should be a rational number.
@smallexample
+ @group
1: 1.26508260337 1: 0.509433962268 1: 2486645810:4881193627
. . .
2 ^ P / c F
@end group
+ @end smallexample
@noindent
Technically speaking this is a rational number, but not one that is
***************
*** 8247,8260 ****
But perhaps our result was not quite exact. Let's reduce the
precision slightly and try again:
- @group
@smallexample
1: 0.509433962268 1: 27:53
. .
! U p 10 RET c F
! @end smallexample
@end group
@noindent
Aha! It's unlikely that an irrational number would equal a fraction
--- 8148,8161 ----
But perhaps our result was not quite exact. Let's reduce the
precision slightly and try again:
@smallexample
+ @group
1: 0.509433962268 1: 27:53
. .
! U p 10 @key{RET} c F
@end group
+ @end smallexample
@noindent
Aha! It's unlikely that an irrational number would equal a fraction
***************
*** 8327,8354 ****
@node Types Answer 4, Types Answer 5, Types Answer 3, Answers to Exercises
@subsection Types Tutorial Exercise 4
- @group
@smallexample
2: 0@@ 47' 26" 1: 0@@ 2' 47.411765"
1: 17 .
.
! 0@@ 47' 26" RET 17 /
! @end smallexample
@end group
@noindent
The average song length is two minutes and 47.4 seconds.
- @group
@smallexample
2: 0@@ 2' 47.411765" 1: 0@@ 3' 7.411765" 1: 0@@ 53' 6.000005"
1: 0@@ 0' 20" . .
.
20" + 17 *
- @end smallexample
@end group
@noindent
The album would be 53 minutes and 6 seconds long.
--- 8228,8255 ----
@node Types Answer 4, Types Answer 5, Types Answer 3, Answers to Exercises
@subsection Types Tutorial Exercise 4
@smallexample
+ @group
2: 0@@ 47' 26" 1: 0@@ 2' 47.411765"
1: 17 .
.
! 0@@ 47' 26" @key{RET} 17 /
@end group
+ @end smallexample
@noindent
The average song length is two minutes and 47.4 seconds.
@smallexample
+ @group
2: 0@@ 2' 47.411765" 1: 0@@ 3' 7.411765" 1: 0@@ 53' 6.000005"
1: 0@@ 0' 20" . .
.
20" + 17 *
@end group
+ @end smallexample
@noindent
The album would be 53 minutes and 6 seconds long.
***************
*** 8361,8374 ****
to keep trying 13ths of months until Calc reports a Friday.
We can do this by manually entering dates, or by using @kbd{t I}:
- @group
@smallexample
1: <Wed Feb 13, 1991> 1: <Wed Mar 13, 1991> 1: <Sat Apr 13, 1991>
. . .
! ' <2/13> RET DEL ' <3/13> RET t I
! @end smallexample
@end group
@noindent
(Calc assumes the current year if you don't say otherwise.)
--- 8262,8275 ----
to keep trying 13ths of months until Calc reports a Friday.
We can do this by manually entering dates, or by using @kbd{t I}:
@smallexample
+ @group
1: <Wed Feb 13, 1991> 1: <Wed Mar 13, 1991> 1: <Sat Apr 13, 1991>
. . .
! ' <2/13> @key{RET} @key{DEL} ' <3/13> @key{RET} t I
@end group
+ @end smallexample
@noindent
(Calc assumes the current year if you don't say otherwise.)
***************
*** 8379,8394 ****
``how-many-months'' argument, which defaults to one. This
argument is exactly what we want to map over:
- @group
@smallexample
2: <Sat Apr 13, 1991> 1: [<Mon May 13, 1991>, <Thu Jun 13, 1991>,
1: [1, 2, 3, 4, 5, 6] <Sat Jul 13, 1991>, <Tue Aug 13, 1991>,
. <Fri Sep 13, 1991>, <Sun Oct 13, 1991>]
.
! v x 6 RET V M t I
! @end smallexample
@end group
@ifinfo
@noindent
--- 8280,8295 ----
``how-many-months'' argument, which defaults to one. This
argument is exactly what we want to map over:
@smallexample
+ @group
2: <Sat Apr 13, 1991> 1: [<Mon May 13, 1991>, <Thu Jun 13, 1991>,
1: [1, 2, 3, 4, 5, 6] <Sat Jul 13, 1991>, <Tue Aug 13, 1991>,
. <Fri Sep 13, 1991>, <Sun Oct 13, 1991>]
.
! v x 6 @key{RET} V M t I
@end group
+ @end smallexample
@ifinfo
@noindent
***************
*** 8399,8412 ****
{\it Et voil{\accent"12 a}}, September 13, 1991 is a Friday.
@end tex
- @group
@smallexample
1: 242
.
! ' <sep 13> - <jan 14> RET
! @end smallexample
@end group
@noindent
And the answer to our original question: 242 days to go.
--- 8300,8313 ----
{\it Et voil{\accent"12 a}}, September 13, 1991 is a Friday.
@end tex
@smallexample
+ @group
1: 242
.
! ' <sep 13> - <jan 14> @key{RET}
@end group
+ @end smallexample
@noindent
And the answer to our original question: 242 days to go.
***************
*** 8428,8454 ****
number of years times 365. The number of extra days we find must be
equal to the number of leap years there were.
- @group
@smallexample
1: <Mon Jan 1, 10001> 2: <Mon Jan 1, 10001> 1: 2925593
. 1: <Tue Jan 1, 1991> .
.
! ' <jan 1 10001> RET ' <jan 1 1991> RET -
- @end smallexample
@end group
@noindent
- @group
@smallexample
3: 2925593 2: 2925593 2: 2925593 1: 1943
2: 10001 1: 8010 1: 2923650 .
1: 1991 . .
.
! 10001 RET 1991 - 365 * -
! @end smallexample
@end group
@c [fix-ref Date Forms]
@noindent
--- 8329,8355 ----
number of years times 365. The number of extra days we find must be
equal to the number of leap years there were.
@smallexample
+ @group
1: <Mon Jan 1, 10001> 2: <Mon Jan 1, 10001> 1: 2925593
. 1: <Tue Jan 1, 1991> .
.
! ' <jan 1 10001> @key{RET} ' <jan 1 1991> @key{RET} -
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
3: 2925593 2: 2925593 2: 2925593 1: 1943
2: 10001 1: 8010 1: 2923650 .
1: 1991 . .
.
! 10001 @key{RET} 1991 - 365 * -
@end group
+ @end smallexample
@c [fix-ref Date Forms]
@noindent
***************
*** 8464,8503 ****
The relative errors must be converted to absolute errors so that
@samp{+/-} notation may be used.
- @group
@smallexample
1: 1. 2: 1.
. 1: 0.2
.
! 20 RET .05 * 4 RET .05 *
! @end smallexample
@end group
Now we simply chug through the formula.
- @group
@smallexample
1: 19.7392088022 1: 394.78 +/- 19.739 1: 6316.5 +/- 706.21
. . .
! 2 P 2 ^ * 20 p 1 * 4 p .2 RET 2 ^ *
! @end smallexample
@end group
It turns out the @kbd{v u} command will unpack an error form as
well as a vector. This saves us some retyping of numbers.
- @group
@smallexample
3: 6316.5 +/- 706.21 2: 6316.5 +/- 706.21
2: 6316.5 1: 0.1118
1: 706.21 .
.
! RET v u TAB /
! @end smallexample
@end group
@noindent
Thus the volume is 6316 cubic centimeters, within about 11 percent.
--- 8365,8404 ----
The relative errors must be converted to absolute errors so that
@samp{+/-} notation may be used.
@smallexample
+ @group
1: 1. 2: 1.
. 1: 0.2
.
! 20 @key{RET} .05 * 4 @key{RET} .05 *
@end group
+ @end smallexample
Now we simply chug through the formula.
@smallexample
+ @group
1: 19.7392088022 1: 394.78 +/- 19.739 1: 6316.5 +/- 706.21
. . .
! 2 P 2 ^ * 20 p 1 * 4 p .2 @key{RET} 2 ^ *
@end group
+ @end smallexample
It turns out the @kbd{v u} command will unpack an error form as
well as a vector. This saves us some retyping of numbers.
@smallexample
+ @group
3: 6316.5 +/- 706.21 2: 6316.5 +/- 706.21
2: 6316.5 1: 0.1118
1: 706.21 .
.
! @key{RET} v u @key{TAB} /
@end group
+ @end smallexample
@noindent
Thus the volume is 6316 cubic centimeters, within about 11 percent.
***************
*** 8537,8551 ****
@node Types Answer 9, Types Answer 10, Types Answer 8, Answers to Exercises
@subsection Types Tutorial Exercise 9
- @group
@smallexample
1: [-3 .. 3] 2: [-3 .. 3] 2: [0 .. 9]
. 1: [0 .. 9] 1: [-9 .. 9]
. .
! [ 3 n .. 3 ] RET 2 ^ TAB RET *
! @end smallexample
@end group
@noindent
In the first case the result says, ``if a number is between @i{-3} and
--- 8438,8452 ----
@node Types Answer 9, Types Answer 10, Types Answer 8, Answers to Exercises
@subsection Types Tutorial Exercise 9
@smallexample
+ @group
1: [-3 .. 3] 2: [-3 .. 3] 2: [0 .. 9]
. 1: [0 .. 9] 1: [-9 .. 9]
. .
! [ 3 n .. 3 ] @key{RET} 2 ^ @key{TAB} @key{RET} *
@end group
+ @end smallexample
@noindent
In the first case the result says, ``if a number is between @i{-3} and
***************
*** 8564,8578 ****
@noindent
Testing the first number, we might arbitrarily choose 17 for @cite{x}.
- @group
@smallexample
1: 17 mod 811749613 2: 17 mod 811749613 1: 533694123 mod 811749613
. 811749612 .
.
! 17 M 811749613 RET 811749612 ^
! @end smallexample
@end group
@noindent
Since 533694123 is (considerably) different from 1, the number 811749613
--- 8465,8479 ----
@noindent
Testing the first number, we might arbitrarily choose 17 for @cite{x}.
@smallexample
+ @group
1: 17 mod 811749613 2: 17 mod 811749613 1: 533694123 mod 811749613
. 811749612 .
.
! 17 M 811749613 @key{RET} 811749612 ^
@end group
+ @end smallexample
@noindent
Since 533694123 is (considerably) different from 1, the number 811749613
***************
*** 8583,8597 ****
a vector mapping operation we can perform several tests at once. Let's
use this method to test the second number.
- @group
@smallexample
2: [17, 42, 100000] 1: [1 mod 15485863, 1 mod ... ]
1: 15485863 .
.
! [17 42 100000] 15485863 RET V M ' ($$ mod $)^($-1) RET
! @end smallexample
@end group
@noindent
The result is three ones (modulo @cite{n}), so it's very probable that
--- 8484,8498 ----
a vector mapping operation we can perform several tests at once. Let's
use this method to test the second number.
@smallexample
+ @group
2: [17, 42, 100000] 1: [1 mod 15485863, 1 mod ... ]
1: 15485863 .
.
! [17 42 100000] 15485863 @key{RET} V M ' ($$ mod $)^($-1) @key{RET}
@end group
+ @end smallexample
@noindent
The result is three ones (modulo @cite{n}), so it's very probable that
***************
*** 8614,8639 ****
One way to convert a number of seconds to an HMS form is simply to
multiply the number by an HMS form representing one second:
- @group
@smallexample
1: 31415926.5359 2: 31415926.5359 1: 8726@@ 38' 46.5359"
. 1: 0@@ 0' 1" .
.
P 1e7 * 0@@ 0' 1" *
- @end smallexample
@end group
@noindent
- @group
@smallexample
2: 8726@@ 38' 46.5359" 1: 6@@ 6' 2.5359" mod 24@@ 0' 0"
1: 15@@ 27' 16" mod 24@@ 0' 0" .
.
! x time RET +
! @end smallexample
@end group
@noindent
It will be just after six in the morning.
--- 8515,8540 ----
One way to convert a number of seconds to an HMS form is simply to
multiply the number by an HMS form representing one second:
@smallexample
+ @group
1: 31415926.5359 2: 31415926.5359 1: 8726@@ 38' 46.5359"
. 1: 0@@ 0' 1" .
.
P 1e7 * 0@@ 0' 1" *
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
2: 8726@@ 38' 46.5359" 1: 6@@ 6' 2.5359" mod 24@@ 0' 0"
1: 15@@ 27' 16" mod 24@@ 0' 0" .
.
! x time @key{RET} +
@end group
+ @end smallexample
@noindent
It will be just after six in the morning.
***************
*** 8641,8654 ****
The algebraic @code{hms} function can also be used to build an
HMS form:
- @group
@smallexample
1: hms(0, 0, 10000000. pi) 1: 8726@@ 38' 46.5359"
. .
! ' hms(0, 0, 1e7 pi) RET =
! @end smallexample
@end group
@noindent
The @kbd{=} key is necessary to evaluate the symbol @samp{pi} to
--- 8542,8555 ----
The algebraic @code{hms} function can also be used to build an
HMS form:
@smallexample
+ @group
1: hms(0, 0, 10000000. pi) 1: 8726@@ 38' 46.5359"
. .
! ' hms(0, 0, 1e7 pi) @key{RET} =
@end group
+ @end smallexample
@noindent
The @kbd{=} key is necessary to evaluate the symbol @samp{pi} to
***************
*** 8661,8685 ****
As we recall, there are 17 songs of about 2 minutes and 47 seconds
each.
- @group
@smallexample
2: 0@@ 2' 47" 1: [0@@ 3' 7" .. 0@@ 3' 47"]
1: [0@@ 0' 20" .. 0@@ 1' 0"] .
.
[ 0@@ 20" .. 0@@ 1' ] +
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: [0@@ 52' 59." .. 1@@ 4' 19."]
.
17 *
- @end smallexample
@end group
@noindent
No matter how long it is, the album will fit nicely on one CD.
--- 8562,8586 ----
As we recall, there are 17 songs of about 2 minutes and 47 seconds
each.
@smallexample
+ @group
2: 0@@ 2' 47" 1: [0@@ 3' 7" .. 0@@ 3' 47"]
1: [0@@ 0' 20" .. 0@@ 1' 0"] .
.
[ 0@@ 20" .. 0@@ 1' ] +
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: [0@@ 52' 59." .. 1@@ 4' 19."]
.
17 *
@end group
+ @end smallexample
@noindent
No matter how long it is, the album will fit nicely on one CD.
***************
*** 8688,8694 ****
@subsection Types Tutorial Exercise 13
@noindent
! Type @kbd{' 1 yr RET u c s RET}. The answer is 31557600 seconds.
@node Types Answer 14, Types Answer 15, Types Answer 13, Answers to Exercises
@subsection Types Tutorial Exercise 14
--- 8589,8595 ----
@subsection Types Tutorial Exercise 13
@noindent
! Type @kbd{' 1 yr @key{RET} u c s @key{RET}}. The answer is 31557600 seconds.
@node Types Answer 14, Types Answer 15, Types Answer 13, Answers to Exercises
@subsection Types Tutorial Exercise 14
***************
*** 8697,8723 ****
How long will it take for a signal to get from one end of the computer
to the other?
- @group
@smallexample
1: m / c 1: 3.3356 ns
. .
! ' 1 m / c RET u c ns RET
! @end smallexample
@end group
@noindent
(Recall, @samp{c} is a ``unit'' corresponding to the speed of light.)
- @group
@smallexample
1: 3.3356 ns 1: 0.81356 ns / ns 1: 0.81356
2: 4.1 ns . .
.
! ' 4.1 ns RET / u s
! @end smallexample
@end group
@noindent
Thus a signal could take up to 81 percent of a clock cycle just to
--- 8598,8624 ----
How long will it take for a signal to get from one end of the computer
to the other?
@smallexample
+ @group
1: m / c 1: 3.3356 ns
. .
! ' 1 m / c @key{RET} u c ns @key{RET}
@end group
+ @end smallexample
@noindent
(Recall, @samp{c} is a ``unit'' corresponding to the speed of light.)
@smallexample
+ @group
1: 3.3356 ns 1: 0.81356 ns / ns 1: 0.81356
2: 4.1 ns . .
.
! ' 4.1 ns @key{RET} / u s
@end group
+ @end smallexample
@noindent
Thus a signal could take up to 81 percent of a clock cycle just to
***************
*** 8731,8759 ****
The speed limit is 55 miles per hour on most highways. We want to
find the ratio of Sam's speed to the US speed limit.
- @group
@smallexample
1: 55 mph 2: 55 mph 3: 11 hr mph / yd
. 1: 5 yd / hr .
.
! ' 55 mph RET ' 5 yd/hr RET /
! @end smallexample
@end group
The @kbd{u s} command cancels out these units to get a plain
number. Now we take the logarithm base two to find the final
answer, assuming that each successive pill doubles his speed.
- @group
@smallexample
1: 19360. 2: 19360. 1: 14.24
. 1: 2 .
.
u s 2 B
- @end smallexample
@end group
@noindent
Thus Sam can take up to 14 pills without a worry.
--- 8632,8660 ----
The speed limit is 55 miles per hour on most highways. We want to
find the ratio of Sam's speed to the US speed limit.
@smallexample
+ @group
1: 55 mph 2: 55 mph 3: 11 hr mph / yd
. 1: 5 yd / hr .
.
! ' 55 mph @key{RET} ' 5 yd/hr @key{RET} /
@end group
+ @end smallexample
The @kbd{u s} command cancels out these units to get a plain
number. Now we take the logarithm base two to find the final
answer, assuming that each successive pill doubles his speed.
@smallexample
+ @group
1: 19360. 2: 19360. 1: 14.24
. 1: 2 .
.
u s 2 B
@end group
+ @end smallexample
@noindent
Thus Sam can take up to 14 pills without a worry.
***************
*** 8780,8813 ****
will do the job. We can use @kbd{a c x} to write this in a more
familiar form.
- @group
@smallexample
1: 34 x - 24 x^3 1: [1.19023, -1.19023, 0]
. .
! r 2 a P x RET
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: [x - 1.19023, x + 1.19023, x] 1: (x - 1.19023) (x + 1.19023) x
. .
! V M ' x-$ RET V R *
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: x^3 - 1.41666 x 1: 34 x - 24 x^3
. .
! a c x RET 24 n * a x
! @end smallexample
@end group
@noindent
Sure enough, our answer (multiplied by a suitable constant) is the
--- 8681,8714 ----
will do the job. We can use @kbd{a c x} to write this in a more
familiar form.
@smallexample
+ @group
1: 34 x - 24 x^3 1: [1.19023, -1.19023, 0]
. .
! r 2 a P x @key{RET}
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: [x - 1.19023, x + 1.19023, x] 1: (x - 1.19023) (x + 1.19023) x
. .
! V M ' x-$ @key{RET} V R *
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: x^3 - 1.41666 x 1: 34 x - 24 x^3
. .
! a c x @key{RET} 24 n * a x
@end group
+ @end smallexample
@noindent
Sure enough, our answer (multiplied by a suitable constant) is the
***************
*** 8816,8880 ****
@node Algebra Answer 3, Algebra Answer 4, Algebra Answer 2, Answers to
Exercises
@subsection Algebra Tutorial Exercise 3
- @group
@smallexample
1: x sin(pi x) 1: (sin(pi x) - pi x cos(pi x)) / pi^2
. .
! ' x sin(pi x) RET m r a i x RET
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: [y, 1]
2: (sin(pi x) - pi x cos(pi x)) / pi^2
.
! ' [y,1] RET TAB
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: [(sin(pi y) - pi y cos(pi y)) / pi^2, (sin(pi) - pi cos(pi)) / pi^2]
.
! V M $ RET
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: (sin(pi y) - pi y cos(pi y)) / pi^2 + (pi cos(pi) - sin(pi)) / pi^2
.
V R -
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: (sin(3.14159 y) - 3.14159 y cos(3.14159 y)) / 9.8696 - 0.3183
.
=
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: [0., -0.95493, 0.63662, -1.5915, 1.2732]
.
! v x 5 RET TAB V M $ RET
! @end smallexample
@end group
@node Algebra Answer 4, Rewrites Answer 1, Algebra Answer 3, Answers to
Exercises
@subsection Algebra Tutorial Exercise 4
--- 8717,8781 ----
@node Algebra Answer 3, Algebra Answer 4, Algebra Answer 2, Answers to
Exercises
@subsection Algebra Tutorial Exercise 3
@smallexample
+ @group
1: x sin(pi x) 1: (sin(pi x) - pi x cos(pi x)) / pi^2
. .
! ' x sin(pi x) @key{RET} m r a i x @key{RET}
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: [y, 1]
2: (sin(pi x) - pi x cos(pi x)) / pi^2
.
! ' [y,1] @key{RET} @key{TAB}
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: [(sin(pi y) - pi y cos(pi y)) / pi^2, (sin(pi) - pi cos(pi)) / pi^2]
.
! V M $ @key{RET}
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: (sin(pi y) - pi y cos(pi y)) / pi^2 + (pi cos(pi) - sin(pi)) / pi^2
.
V R -
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: (sin(3.14159 y) - 3.14159 y cos(3.14159 y)) / 9.8696 - 0.3183
.
=
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: [0., -0.95493, 0.63662, -1.5915, 1.2732]
.
! v x 5 @key{RET} @key{TAB} V M $ @key{RET}
@end group
+ @end smallexample
@node Algebra Answer 4, Rewrites Answer 1, Algebra Answer 3, Answers to
Exercises
@subsection Algebra Tutorial Exercise 4
***************
*** 8885,8947 ****
coefficients. So first we must come up with a vector of these
coefficients. Here's one way:
- @group
@smallexample
2: -1 2: 3 1: [4, 2, ..., 4]
1: [1, 2, ..., 9] 1: [-1, 1, ..., -1] .
. .
! 1 n v x 9 RET V M ^ 3 TAB -
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: [4, 2, ..., 4, 1] 1: [1, 4, 2, ..., 4, 1]
. .
! 1 | 1 TAB |
! @end smallexample
@end group
@noindent
Now we compute the function values. Note that for this method we need
eleven values, including both endpoints of the desired interval.
- @group
@smallexample
2: [1, 4, 2, ..., 4, 1]
1: [1, 1.1, 1.2, ... , 1.8, 1.9, 2.]
.
! 11 RET 1 RET .1 RET C-u v x
- @end smallexample
@end group
@noindent
- @group
@smallexample
2: [1, 4, 2, ..., 4, 1]
1: [0., 0.084941, 0.16993, ... ]
.
! ' sin(x) ln(x) RET m r p 5 RET V M $ RET
! @end smallexample
@end group
@noindent
Once again this calls for @kbd{V M * V R +}; a simple @kbd{*} does the
same thing.
- @group
@smallexample
1: 11.22 1: 1.122 1: 0.374
. . .
* .1 * 3 /
- @end smallexample
@end group
@noindent
Wow! That's even better than the result from the Taylor series method.
--- 8786,8848 ----
coefficients. So first we must come up with a vector of these
coefficients. Here's one way:
@smallexample
+ @group
2: -1 2: 3 1: [4, 2, ..., 4]
1: [1, 2, ..., 9] 1: [-1, 1, ..., -1] .
. .
! 1 n v x 9 @key{RET} V M ^ 3 @key{TAB} -
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: [4, 2, ..., 4, 1] 1: [1, 4, 2, ..., 4, 1]
. .
! 1 | 1 @key{TAB} |
@end group
+ @end smallexample
@noindent
Now we compute the function values. Note that for this method we need
eleven values, including both endpoints of the desired interval.
@smallexample
+ @group
2: [1, 4, 2, ..., 4, 1]
1: [1, 1.1, 1.2, ... , 1.8, 1.9, 2.]
.
! 11 @key{RET} 1 @key{RET} .1 @key{RET} C-u v x
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
2: [1, 4, 2, ..., 4, 1]
1: [0., 0.084941, 0.16993, ... ]
.
! ' sin(x) ln(x) @key{RET} m r p 5 @key{RET} V M $ @key{RET}
@end group
+ @end smallexample
@noindent
Once again this calls for @kbd{V M * V R +}; a simple @kbd{*} does the
same thing.
@smallexample
+ @group
1: 11.22 1: 1.122 1: 0.374
. . .
* .1 * 3 /
@end group
+ @end smallexample
@noindent
Wow! That's even better than the result from the Taylor series method.
***************
*** 8952,8959 ****
@noindent
We'll use Big mode to make the formulas more readable.
- @group
@smallexample
___
2 + V 2
1: (2 + sqrt(2)) / (1 + sqrt(2)) 1: --------
--- 8853,8860 ----
@noindent
We'll use Big mode to make the formulas more readable.
@smallexample
+ @group
___
2 + V 2
1: (2 + sqrt(2)) / (1 + sqrt(2)) 1: --------
***************
*** 8962,8994 ****
.
! ' (2+sqrt(2)) / (1+sqrt(2)) RET d B
! @end smallexample
@end group
@noindent
Multiplying by the conjugate helps because @cite{(a+b) (a-b) = a^2 - b^2}.
- @group
@smallexample
___ ___
1: (2 + V 2 ) (V 2 - 1)
.
! a r a/(b+c) := a*(b-c) / (b^2-c^2) RET
- @end smallexample
@end group
@noindent
- @group
@smallexample
___ ___
1: 2 + V 2 - 2 1: V 2
. .
a r a*(b+c) := a*b + a*c a s
- @end smallexample
@end group
@noindent
(We could have used @kbd{a x} instead of a rewrite rule for the
--- 8863,8895 ----
.
! ' (2+sqrt(2)) / (1+sqrt(2)) @key{RET} d B
@end group
+ @end smallexample
@noindent
Multiplying by the conjugate helps because @cite{(a+b) (a-b) = a^2 - b^2}.
@smallexample
+ @group
___ ___
1: (2 + V 2 ) (V 2 - 1)
.
! a r a/(b+c) := a*(b-c) / (b^2-c^2) @key{RET}
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
___ ___
1: 2 + V 2 - 2 1: V 2
. .
a r a*(b+c) := a*b + a*c a s
@end group
+ @end smallexample
@noindent
(We could have used @kbd{a x} instead of a rewrite rule for the
***************
*** 9004,9016 ****
@noindent
Here is the rule set:
- @group
@smallexample
[ fib(n) := fib(n, 1, 1) :: integer(n) :: n >= 1,
fib(1, x, y) := x,
fib(n, x, y) := fib(n-1, y, x+y) ]
- @end smallexample
@end group
@noindent
The first rule turns a one-argument @code{fib} that people like to write
--- 8905,8917 ----
@noindent
Here is the rule set:
@smallexample
+ @group
[ fib(n) := fib(n, 1, 1) :: integer(n) :: n >= 1,
fib(1, x, y) := x,
fib(n, x, y) := fib(n-1, y, x+y) ]
@end group
+ @end smallexample
@noindent
The first rule turns a one-argument @code{fib} that people like to write
***************
*** 9060,9075 ****
@subsection Rewrites Tutorial Exercise 4
@noindent
! @c @starindex
@tindex seq
Here is a suitable set of rules to solve the first part of the problem:
- @group
@smallexample
[ seq(n, c) := seq(n/2, c+1) :: n%2 = 0,
seq(n, c) := seq(3n+1, c+1) :: n%2 = 1 :: n > 1 ]
- @end smallexample
@end group
Given the initial formula @samp{seq(6, 0)}, application of these
rules produces the following sequence of formulas:
--- 8961,8978 ----
@subsection Rewrites Tutorial Exercise 4
@noindent
! @ignore
! @starindex
! @end ignore
@tindex seq
Here is a suitable set of rules to solve the first part of the problem:
@smallexample
+ @group
[ seq(n, c) := seq(n/2, c+1) :: n%2 = 0,
seq(n, c) := seq(3n+1, c+1) :: n%2 = 1 :: n > 1 ]
@end group
+ @end smallexample
Given the initial formula @samp{seq(6, 0)}, application of these
rules produces the following sequence of formulas:
***************
*** 9090,9102 ****
We can pretty this up a bit with a couple more rules:
- @group
@smallexample
[ seq(n) := seq(n, 0),
seq(1, c) := c,
... ]
- @end smallexample
@end group
@noindent
Now, given @samp{seq(6)} as the starting configuration, we get 8
--- 8993,9005 ----
We can pretty this up a bit with a couple more rules:
@smallexample
+ @group
[ seq(n) := seq(n, 0),
seq(1, c) := c,
... ]
@end group
+ @end smallexample
@noindent
Now, given @samp{seq(6)} as the starting configuration, we get 8
***************
*** 9104,9117 ****
The change to return a vector is quite simple:
- @group
@smallexample
[ seq(n) := seq(n, []) :: integer(n) :: n > 0,
seq(1, v) := v | 1,
seq(n, v) := seq(n/2, v | n) :: n%2 = 0,
seq(n, v) := seq(3n+1, v | n) :: n%2 = 1 ]
- @end smallexample
@end group
@noindent
Given @samp{seq(6)}, the result is @samp{[6, 3, 10, 5, 16, 8, 4, 2, 1]}.
--- 9007,9020 ----
The change to return a vector is quite simple:
@smallexample
+ @group
[ seq(n) := seq(n, []) :: integer(n) :: n > 0,
seq(1, v) := v | 1,
seq(n, v) := seq(n/2, v | n) :: n%2 = 0,
seq(n, v) := seq(3n+1, v | n) :: n%2 = 1 ]
@end group
+ @end smallexample
@noindent
Given @samp{seq(6)}, the result is @samp{[6, 3, 10, 5, 16, 8, 4, 2, 1]}.
***************
*** 9131,9148 ****
@subsection Rewrites Tutorial Exercise 5
@noindent
! @c @starindex
@tindex nterms
! If @cite{x} is the sum @cite{a + b}, then address@hidden(address@hidden@t{)}'
must
! be address@hidden(address@hidden@t{)}' plus
address@hidden(address@hidden@t{)}'. If @cite{x}
! is not a sum, then address@hidden(address@hidden@t{)}' = 1.
- @group
@smallexample
[ nterms(a + b) := nterms(a) + nterms(b),
nterms(x) := 1 ]
- @end smallexample
@end group
@noindent
Here we have taken advantage of the fact that earlier rules always
--- 9034,9053 ----
@subsection Rewrites Tutorial Exercise 5
@noindent
! @ignore
! @starindex
! @end ignore
@tindex nterms
! If @cite{x} is the sum @cite{a + b}, then address@hidden(address@hidden@t{)}'
must
! be address@hidden(address@hidden@t{)}' plus
address@hidden(address@hidden@t{)}'. If @cite{x}
! is not a sum, then address@hidden(address@hidden@t{)}' = 1.
@smallexample
+ @group
[ nterms(a + b) := nterms(a) + nterms(b),
nterms(x) := 1 ]
@end group
+ @end smallexample
@noindent
Here we have taken advantage of the fact that earlier rules always
***************
*** 9155,9182 ****
Just put the rule @samp{0^0 := 1} into @code{EvalRules}. For example,
before making this definition we have:
- @group
@smallexample
2: [-2, -1, 0, 1, 2] 1: [1, 1, 0^0, 1, 1]
1: 0 .
.
! v x 5 RET 3 - 0 V M ^
! @end smallexample
@end group
@noindent
But then:
- @group
@smallexample
2: [-2, -1, 0, 1, 2] 1: [1, 1, 1, 1, 1]
1: 0 .
.
! U ' 0^0:=1 RET s t EvalRules RET V M ^
! @end smallexample
@end group
Perhaps more surprisingly, this rule still works with infinite mode
turned on. Calc tries @code{EvalRules} before any built-in rules for
--- 9060,9087 ----
Just put the rule @samp{0^0 := 1} into @code{EvalRules}. For example,
before making this definition we have:
@smallexample
+ @group
2: [-2, -1, 0, 1, 2] 1: [1, 1, 0^0, 1, 1]
1: 0 .
.
! v x 5 @key{RET} 3 - 0 V M ^
@end group
+ @end smallexample
@noindent
But then:
@smallexample
+ @group
2: [-2, -1, 0, 1, 2] 1: [1, 1, 1, 1, 1]
1: 0 .
.
! U ' 0^0:=1 @key{RET} s t EvalRules @key{RET} V M ^
@end group
+ @end smallexample
Perhaps more surprisingly, this rule still works with infinite mode
turned on. Calc tries @code{EvalRules} before any built-in rules for
***************
*** 9194,9201 ****
@noindent
Here is a rule set that will do the job:
- @group
@smallexample
[ a*(b + c) := a*b + a*c,
opt(a) O(x^n) + opt(b) O(x^m) := O(x^n) :: n <= m
:: constant(a) :: constant(b),
--- 9099,9106 ----
@noindent
Here is a rule set that will do the job:
@smallexample
+ @group
[ a*(b + c) := a*b + a*c,
opt(a) O(x^n) + opt(b) O(x^m) := O(x^n) :: n <= m
:: constant(a) :: constant(b),
***************
*** 9204,9211 ****
a O(x^n) := O(x^n) :: constant(a),
x^opt(m) O(x^n) := O(x^(n+m)),
O(x^n) O(x^m) := O(x^(n+m)) ]
- @end smallexample
@end group
If we really want the @kbd{+} and @kbd{*} keys to operate naturally
on power series, we should put these rules in @code{EvalRules}. For
--- 9109,9116 ----
a O(x^n) := O(x^n) :: constant(a),
x^opt(m) O(x^n) := O(x^(n+m)),
O(x^n) O(x^m) := O(x^(n+m)) ]
@end group
+ @end smallexample
If we really want the @kbd{+} and @kbd{*} keys to operate naturally
on power series, we should put these rules in @code{EvalRules}. For
***************
*** 9273,9287 ****
change this to @samp{(x)} since @cite{t} is really a dummy variable
to be used within @code{ninteg}.
! The exact keystrokes are @kbd{Z F s Si RET RET C-b C-b DEL DEL RET y}.
! (The @kbd{C-b C-b DEL DEL} are what fix the argument list.)
@node Programming Answer 2, Programming Answer 3, Programming Answer 1,
Answers to Exercises
@subsection Programming Tutorial Exercise 2
@noindent
One way is to move the number to the top of the stack, operate on
! it, then move it back: @kbd{C-x ( M-TAB n M-TAB M-TAB C-x )}.
Another way is to negate the top three stack entries, then negate
again the top two stack entries: @kbd{C-x ( M-3 n M-2 n C-x )}.
--- 9178,9192 ----
change this to @samp{(x)} since @cite{t} is really a dummy variable
to be used within @code{ninteg}.
! The exact keystrokes are @kbd{Z F s Si @key{RET} @key{RET} C-b C-b @key{DEL}
@key{DEL} @key{RET} y}.
! (The @kbd{C-b C-b @key{DEL} @key{DEL}} are what fix the argument list.)
@node Programming Answer 2, Programming Answer 3, Programming Answer 1,
Answers to Exercises
@subsection Programming Tutorial Exercise 2
@noindent
One way is to move the number to the top of the stack, operate on
! it, then move it back: @kbd{C-x ( address@hidden n address@hidden
address@hidden C-x )}.
Another way is to negate the top three stack entries, then negate
again the top two stack entries: @kbd{C-x ( M-3 n M-2 n C-x )}.
***************
*** 9291,9297 ****
which is just what we want: @kbd{C-x ( M-- 3 n C-x )}.
Just for kicks, let's also do it algebraically:
! @address@hidden ( ' -$$$, $$, $ RET C-x )}}.
@node Programming Answer 3, Programming Answer 4, Programming Answer 2,
Answers to Exercises
@subsection Programming Tutorial Exercise 3
--- 9196,9202 ----
which is just what we want: @kbd{C-x ( M-- 3 n C-x )}.
Just for kicks, let's also do it algebraically:
! @address@hidden ( ' -$$$, $$, $ @key{RET} C-x )}}.
@node Programming Answer 3, Programming Answer 4, Programming Answer 2,
Answers to Exercises
@subsection Programming Tutorial Exercise 3
***************
*** 9304,9324 ****
Computing @c{$\displaystyle{\sin x \over x}$}
@cite{sin(x) / x}:
! Using the stack: @kbd{C-x ( RET S TAB / C-x )}.
! Using algebraic entry: @kbd{C-x ( ' sin($)/$ RET C-x )}.
@noindent
Computing the logarithm:
! Using the stack: @kbd{C-x ( TAB B C-x )}
! Using algebraic entry: @kbd{C-x ( ' log($,$$) RET C-x )}.
@noindent
Computing the vector of integers:
! Using the stack: @kbd{C-x ( 1 RET 1 C-u v x C-x )}. (Recall that
@kbd{C-u v x} takes the vector size, starting value, and increment
from the stack.)
--- 9209,9229 ----
Computing @c{$\displaystyle{\sin x \over x}$}
@cite{sin(x) / x}:
! Using the stack: @kbd{C-x ( @key{RET} S @key{TAB} / C-x )}.
! Using algebraic entry: @kbd{C-x ( ' sin($)/$ @key{RET} C-x )}.
@noindent
Computing the logarithm:
! Using the stack: @kbd{C-x ( @key{TAB} B C-x )}
! Using algebraic entry: @kbd{C-x ( ' log($,$$) @key{RET} C-x )}.
@noindent
Computing the vector of integers:
! Using the stack: @kbd{C-x ( 1 @key{RET} 1 C-u v x C-x )}. (Recall that
@kbd{C-u v x} takes the vector size, starting value, and increment
from the stack.)
***************
*** 9326,9351 ****
number from the stack and uses it as the prefix argument for the
next command.)
! Using algebraic entry: @kbd{C-x ( ' index($) RET C-x )}.
@node Programming Answer 4, Programming Answer 5, Programming Answer 3,
Answers to Exercises
@subsection Programming Tutorial Exercise 4
@noindent
! Here's one way: @kbd{C-x ( RET V R + TAB v l / C-x )}.
@node Programming Answer 5, Programming Answer 6, Programming Answer 4,
Answers to Exercises
@subsection Programming Tutorial Exercise 5
- @group
@smallexample
2: 1 1: 1.61803398502 2: 1.61803398502
1: 20 . 1: 1.61803398875
. .
! 1 RET 20 Z < & 1 + Z > I H P
! @end smallexample
@end group
@noindent
This answer is quite accurate.
--- 9231,9256 ----
number from the stack and uses it as the prefix argument for the
next command.)
! Using algebraic entry: @kbd{C-x ( ' index($) @key{RET} C-x )}.
@node Programming Answer 4, Programming Answer 5, Programming Answer 3,
Answers to Exercises
@subsection Programming Tutorial Exercise 4
@noindent
! Here's one way: @kbd{C-x ( @key{RET} V R + @key{TAB} v l / C-x )}.
@node Programming Answer 5, Programming Answer 6, Programming Answer 4,
Answers to Exercises
@subsection Programming Tutorial Exercise 5
@smallexample
+ @group
2: 1 1: 1.61803398502 2: 1.61803398502
1: 20 . 1: 1.61803398875
. .
! 1 @key{RET} 20 Z < & 1 + Z > I H P
@end group
+ @end smallexample
@noindent
This answer is quite accurate.
***************
*** 9366,9372 ****
and @cite{n+2}. Here's one program that does the job:
@example
! C-x ( ' [0, 1; 1, 1] ^ ($-1) * [1, 1] RET v u DEL C-x )
@end example
@noindent
--- 9271,9277 ----
and @cite{n+2}. Here's one program that does the job:
@example
! C-x ( ' [0, 1; 1, 1] ^ ($-1) * [1, 1] @key{RET} v u @key{DEL} C-x )
@end example
@noindent
***************
*** 9386,9400 ****
the loop counter itself accumulates the sum of reciprocals. We use
a separate variable to hold the integer counter.
- @group
@smallexample
1: 1 2: 1 1: .
. 1: 4
.
! 1 t 1 1 RET 4 Z ( t 2 r 1 1 + s 1 & Z )
! @end smallexample
@end group
@noindent
The body of the loop goes as follows: First save the harmonic sum
--- 9291,9305 ----
the loop counter itself accumulates the sum of reciprocals. We use
a separate variable to hold the integer counter.
@smallexample
+ @group
1: 1 2: 1 1: .
. 1: 4
.
! 1 t 1 1 @key{RET} 4 Z ( t 2 r 1 1 + s 1 & Z )
@end group
+ @end smallexample
@noindent
The body of the loop goes as follows: First save the harmonic sum
***************
*** 9405,9420 ****
the ``loop counter'' by that amount and keep going until the
loop counter exceeds 4.
- @group
@smallexample
2: 31 3: 31
1: 3.99498713092 2: 3.99498713092
. 1: 4.02724519544
.
! r 1 r 2 RET 31 & +
! @end smallexample
@end group
Thus we find that the 30th harmonic number is 3.99, and the 31st
harmonic number is 4.02.
--- 9310,9325 ----
the ``loop counter'' by that amount and keep going until the
loop counter exceeds 4.
@smallexample
+ @group
2: 31 3: 31
1: 3.99498713092 2: 3.99498713092
. 1: 4.02724519544
.
! r 1 r 2 @key{RET} 31 & +
@end group
+ @end smallexample
Thus we find that the 30th harmonic number is 3.99, and the 31st
harmonic number is 4.02.
***************
*** 9434,9528 ****
pretend Calc actually executed the keystrokes as you typed them,
just for purposes of illustration.)
- @group
@smallexample
2: sin(cos(x)) - 0.5 3: 4.5
1: 4.5 2: sin(cos(x)) - 0.5
. 1: -(sin(x) cos(cos(x)))
.
! ' sin(cos(x))-0.5 RET 4.5 m r C-x ( Z ` TAB RET a d x RET
- @end smallexample
@end group
@noindent
- @group
@smallexample
2: 4.5
1: x + (sin(cos(x)) - 0.5) / sin(x) cos(cos(x))
.
! / ' x RET TAB - t 1
! @end smallexample
@end group
Now, we enter the loop. We'll use a repeat loop with a 20-repetition
limit just in case the method fails to converge for some reason.
(Normally, the @address@hidden /}} command will stop the loop before all 20
repetitions are done.)
- @group
@smallexample
1: 4.5 3: 4.5 2: 4.5
. 2: x + (sin(cos(x)) ... 1: 5.24196456928
1: 4.5 .
.
! 20 Z < RET r 1 TAB s l x RET
! @end smallexample
@end group
This is the new guess for @cite{x}. Now we compare it with the
old one to see if we've converged.
- @group
@smallexample
3: 5.24196 2: 5.24196 1: 5.24196 1: 5.26345856348
2: 5.24196 1: 0 . .
1: 4.5 .
.
! RET M-TAB a = Z / Z > Z ' C-x )
! @end smallexample
@end group
The loop converges in just a few steps to this value. To check
the result, we can simply substitute it back into the equation.
- @group
@smallexample
2: 5.26345856348
1: 0.499999999997
.
! RET ' sin(cos($)) RET
! @end smallexample
@end group
Let's test the new definition again:
- @group
@smallexample
2: x^2 - 9 1: 3.
1: 1 .
.
! ' x^2-9 RET 1 X
! @end smallexample
@end group
Once again, here's the full Newton's Method definition:
- @group
@example
! C-x ( Z ` TAB RET a d x RET / ' x RET TAB - t 1
! 20 Z < RET r 1 TAB s l x RET
! RET M-TAB a = Z /
Z >
Z '
C-x )
- @end example
@end group
@c [fix-ref Nesting and Fixed Points]
It turns out that Calc has a built-in command for applying a formula
--- 9339,9433 ----
pretend Calc actually executed the keystrokes as you typed them,
just for purposes of illustration.)
@smallexample
+ @group
2: sin(cos(x)) - 0.5 3: 4.5
1: 4.5 2: sin(cos(x)) - 0.5
. 1: -(sin(x) cos(cos(x)))
.
! ' sin(cos(x))-0.5 @key{RET} 4.5 m r C-x ( Z ` @key{TAB} @key{RET} a d x
@key{RET}
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
2: 4.5
1: x + (sin(cos(x)) - 0.5) / sin(x) cos(cos(x))
.
! / ' x @key{RET} @key{TAB} - t 1
@end group
+ @end smallexample
Now, we enter the loop. We'll use a repeat loop with a 20-repetition
limit just in case the method fails to converge for some reason.
(Normally, the @address@hidden /}} command will stop the loop before all 20
repetitions are done.)
@smallexample
+ @group
1: 4.5 3: 4.5 2: 4.5
. 2: x + (sin(cos(x)) ... 1: 5.24196456928
1: 4.5 .
.
! 20 Z < @key{RET} r 1 @key{TAB} s l x @key{RET}
@end group
+ @end smallexample
This is the new guess for @cite{x}. Now we compare it with the
old one to see if we've converged.
@smallexample
+ @group
3: 5.24196 2: 5.24196 1: 5.24196 1: 5.26345856348
2: 5.24196 1: 0 . .
1: 4.5 .
.
! @key{RET} address@hidden a = Z / Z > Z '
C-x )
@end group
+ @end smallexample
The loop converges in just a few steps to this value. To check
the result, we can simply substitute it back into the equation.
@smallexample
+ @group
2: 5.26345856348
1: 0.499999999997
.
! @key{RET} ' sin(cos($)) @key{RET}
@end group
+ @end smallexample
Let's test the new definition again:
@smallexample
+ @group
2: x^2 - 9 1: 3.
1: 1 .
.
! ' x^2-9 @key{RET} 1 X
@end group
+ @end smallexample
Once again, here's the full Newton's Method definition:
@example
! @group
! C-x ( Z ` @key{TAB} @key{RET} a d x @key{RET} / ' x @key{RET} @key{TAB} -
t 1
! 20 Z < @key{RET} r 1 @key{TAB} s l x @key{RET}
! @key{RET} address@hidden a = Z /
Z >
Z '
C-x )
@end group
+ @end example
@c [fix-ref Nesting and Fixed Points]
It turns out that Calc has a built-in command for applying a formula
***************
*** 9553,9566 ****
pretend Calc actually executed the keystrokes as you typed them,
just for purposes of illustration.)
- @group
@smallexample
1: 1. 1: 1.
. .
! 1.0 RET C-x ( Z ` s 1 0 t 2
! @end smallexample
@end group
Here, variable 1 holds @cite{z} and variable 2 holds the adjustment
factor. If @cite{z < 5}, we use a loop to increase it.
--- 9458,9471 ----
pretend Calc actually executed the keystrokes as you typed them,
just for purposes of illustration.)
@smallexample
+ @group
1: 1. 1: 1.
. .
! 1.0 @key{RET} C-x ( Z ` s 1 0 t 2
@end group
+ @end smallexample
Here, variable 1 holds @cite{z} and variable 2 holds the adjustment
factor. If @cite{z < 5}, we use a loop to increase it.
***************
*** 9570,9655 ****
and will never converge because fractions compare equal only if they
are exactly equal, not just equal to within the current precision.)
- @group
@smallexample
3: 1. 2: 1. 1: 6.
2: 1. 1: 1 .
1: 5 .
.
! RET 5 a < Z [ 5 Z ( & s + 2 1 s + 1 1 Z ) r 1 Z ]
! @end smallexample
@end group
Now we compute the initial part of the sum: @c{$\ln z - {1 \over 2z}$}
@cite{ln(z) - 1/2z}
minus the adjustment factor.
- @group
@smallexample
2: 1.79175946923 2: 1.7084261359 1: -0.57490719743
1: 0.0833333333333 1: 2.28333333333 .
. .
L r 1 2 * & - r 2 -
- @end smallexample
@end group
Now we evaluate the series. We'll use another ``for'' loop counting
up the value of @cite{2 n}. (Calc does have a summation command,
@kbd{a +}, but we'll use loops just to get more practice with them.)
- @group
@smallexample
3: -0.5749 3: -0.5749 4: -0.5749 2: -0.5749
2: 2 2: 1:6 3: 1:6 1: 2.3148e-3
1: 40 1: 2 2: 2 .
. . 1: 36.
.
! 2 RET 40 Z ( RET k b TAB RET r 1 TAB ^ * /
- @end smallexample
@end group
@noindent
- @group
@smallexample
3: -0.5749 3: -0.5772 2: -0.5772 1: -0.577215664892
2: -0.5749 2: -0.5772 1: 0 .
1: 2.3148e-3 1: -0.5749 .
. .
! TAB RET M-TAB - RET M-TAB a = Z / 2 Z ) Z ' C-x )
! @end smallexample
@end group
This is the value of @c{$-\gamma$}
@cite{- gamma}, with a slight bit of roundoff error.
To get a full 12 digits, let's use a higher precision:
- @group
@smallexample
2: -0.577215664892 2: -0.577215664892
1: 1. 1: -0.577215664901532
! 1. RET p 16 RET X
! @end smallexample
@end group
Here's the complete sequence of keystrokes:
- @group
@example
C-x ( Z ` s 1 0 t 2
! RET 5 a < Z [ 5 Z ( & s + 2 1 s + 1 1 Z ) r 1 Z ]
L r 1 2 * & - r 2 -
! 2 RET 40 Z ( RET k b TAB RET r 1 TAB ^ * /
! TAB RET M-TAB - RET M-TAB a = Z /
2 Z )
Z '
C-x )
- @end example
@end group
@node Programming Answer 10, Programming Answer 11, Programming Answer 9,
Answers to Exercises
@subsection Programming Tutorial Exercise 10
--- 9475,9560 ----
and will never converge because fractions compare equal only if they
are exactly equal, not just equal to within the current precision.)
@smallexample
+ @group
3: 1. 2: 1. 1: 6.
2: 1. 1: 1 .
1: 5 .
.
! @key{RET} 5 a < Z [ 5 Z ( & s + 2 1 s + 1 1 Z ) r 1 Z ]
@end group
+ @end smallexample
Now we compute the initial part of the sum: @c{$\ln z - {1 \over 2z}$}
@cite{ln(z) - 1/2z}
minus the adjustment factor.
@smallexample
+ @group
2: 1.79175946923 2: 1.7084261359 1: -0.57490719743
1: 0.0833333333333 1: 2.28333333333 .
. .
L r 1 2 * & - r 2 -
@end group
+ @end smallexample
Now we evaluate the series. We'll use another ``for'' loop counting
up the value of @cite{2 n}. (Calc does have a summation command,
@kbd{a +}, but we'll use loops just to get more practice with them.)
@smallexample
+ @group
3: -0.5749 3: -0.5749 4: -0.5749 2: -0.5749
2: 2 2: 1:6 3: 1:6 1: 2.3148e-3
1: 40 1: 2 2: 2 .
. . 1: 36.
.
! 2 @key{RET} 40 Z ( @key{RET} k b @key{TAB} @key{RET} r 1
@key{TAB} ^ * /
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
3: -0.5749 3: -0.5772 2: -0.5772 1: -0.577215664892
2: -0.5749 2: -0.5772 1: 0 .
1: 2.3148e-3 1: -0.5749 .
. .
! @key{TAB} @key{RET} address@hidden - @key{RET} address@hidden a
= Z / 2 Z ) Z ' C-x )
@end group
+ @end smallexample
This is the value of @c{$-\gamma$}
@cite{- gamma}, with a slight bit of roundoff error.
To get a full 12 digits, let's use a higher precision:
@smallexample
+ @group
2: -0.577215664892 2: -0.577215664892
1: 1. 1: -0.577215664901532
! 1. @key{RET} p 16 @key{RET} X
@end group
+ @end smallexample
Here's the complete sequence of keystrokes:
@example
+ @group
C-x ( Z ` s 1 0 t 2
! @key{RET} 5 a < Z [ 5 Z ( & s + 2 1 s + 1 1 Z ) r 1 Z ]
L r 1 2 * & - r 2 -
! 2 @key{RET} 40 Z ( @key{RET} k b @key{TAB} @key{RET} r 1
@key{TAB} ^ * /
! @key{TAB} @key{RET} address@hidden - @key{RET}
address@hidden a = Z /
2 Z )
Z '
C-x )
@end group
+ @end example
@node Programming Answer 10, Programming Answer 11, Programming Answer 9,
Answers to Exercises
@subsection Programming Tutorial Exercise 10
***************
*** 9669,9751 ****
pretend Calc actually executed the keystrokes as you typed them,
just for purposes of illustration.)
- @group
@smallexample
2: 5 x^4 + (x + 1)^2 3: 5 x^4 + (x + 1)^2
1: 6 2: 0
. 1: 6
.
! ' 5 x^4 + (x+1)^2 RET 6 C-x ( Z ` [ ] t 1 0 TAB
! @end smallexample
@end group
@noindent
Variable 1 will accumulate the vector of coefficients.
- @group
@smallexample
2: 0 3: 0 2: 5 x^4 + ...
1: 5 x^4 + ... 2: 5 x^4 + ... 1: 1
. 1: 1 .
.
! Z ( TAB RET 0 s l x RET M-TAB ! / s | 1
! @end smallexample
@end group
@noindent
Note that @kbd{s | 1} appends the top-of-stack value to the vector
in a variable; it is completely analogous to @kbd{s + 1}. We could
! have written instead, @kbd{r 1 TAB | t 1}.
- @group
@smallexample
1: 20 x^3 + 2 x + 2 1: 0 1: [1, 2, 1, 0, 5, 0, 0]
. . .
! a d x RET 1 Z ) DEL r 1 Z ' C-x )
! @end smallexample
@end group
To convert back, a simple method is just to map the coefficients
against a table of powers of @cite{x}.
- @group
@smallexample
2: [1, 2, 1, 0, 5, 0, 0] 2: [1, 2, 1, 0, 5, 0, 0]
1: 6 1: [0, 1, 2, 3, 4, 5, 6]
. .
! 6 RET 1 + 0 RET 1 C-u v x
- @end smallexample
@end group
@noindent
- @group
@smallexample
2: [1, 2, 1, 0, 5, 0, 0] 2: 1 + 2 x + x^2 + 5 x^4
1: [1, x, x^2, x^3, ... ] .
.
! ' x RET TAB V M ^ *
! @end smallexample
@end group
Once again, here are the whole polynomial to/from vector programs:
- @group
@example
! C-x ( Z ` [ ] t 1 0 TAB
! Z ( TAB RET 0 s l x RET M-TAB ! / s | 1
! a d x RET
1 Z ) r 1
Z '
C-x )
! C-x ( 1 + 0 RET 1 C-u v x ' x RET TAB V M ^ * C-x )
! @end example
@end group
@node Programming Answer 11, Programming Answer 12, Programming Answer 10,
Answers to Exercises
@subsection Programming Tutorial Exercise 11
--- 9574,9656 ----
pretend Calc actually executed the keystrokes as you typed them,
just for purposes of illustration.)
@smallexample
+ @group
2: 5 x^4 + (x + 1)^2 3: 5 x^4 + (x + 1)^2
1: 6 2: 0
. 1: 6
.
! ' 5 x^4 + (x+1)^2 @key{RET} 6 C-x ( Z ` [ ] t 1 0 @key{TAB}
@end group
+ @end smallexample
@noindent
Variable 1 will accumulate the vector of coefficients.
@smallexample
+ @group
2: 0 3: 0 2: 5 x^4 + ...
1: 5 x^4 + ... 2: 5 x^4 + ... 1: 1
. 1: 1 .
.
! Z ( @key{TAB} @key{RET} 0 s l x @key{RET}
address@hidden ! / s | 1
@end group
+ @end smallexample
@noindent
Note that @kbd{s | 1} appends the top-of-stack value to the vector
in a variable; it is completely analogous to @kbd{s + 1}. We could
! have written instead, @kbd{r 1 @key{TAB} | t 1}.
@smallexample
+ @group
1: 20 x^3 + 2 x + 2 1: 0 1: [1, 2, 1, 0, 5, 0, 0]
. . .
! a d x @key{RET} 1 Z ) @key{DEL} r 1 Z ' C-x )
@end group
+ @end smallexample
To convert back, a simple method is just to map the coefficients
against a table of powers of @cite{x}.
@smallexample
+ @group
2: [1, 2, 1, 0, 5, 0, 0] 2: [1, 2, 1, 0, 5, 0, 0]
1: 6 1: [0, 1, 2, 3, 4, 5, 6]
. .
! 6 @key{RET} 1 + 0 @key{RET} 1 C-u v x
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
2: [1, 2, 1, 0, 5, 0, 0] 2: 1 + 2 x + x^2 + 5 x^4
1: [1, x, x^2, x^3, ... ] .
.
! ' x @key{RET} @key{TAB} V M ^ *
@end group
+ @end smallexample
Once again, here are the whole polynomial to/from vector programs:
@example
! @group
! C-x ( Z ` [ ] t 1 0 @key{TAB}
! Z ( @key{TAB} @key{RET} 0 s l x @key{RET} address@hidden ! / s |
1
! a d x @key{RET}
1 Z ) r 1
Z '
C-x )
! C-x ( 1 + 0 @key{RET} 1 C-u v x ' x @key{RET} @key{TAB} V M ^ * C-x )
@end group
+ @end example
@node Programming Answer 11, Programming Answer 12, Programming Answer 10,
Answers to Exercises
@subsection Programming Tutorial Exercise 11
***************
*** 9753,9770 ****
@noindent
First we define a dummy program to go on the @kbd{z s} key. The true
@address@hidden s}} key is supposed to take two numbers from the stack and
! return one number, so @kbd{DEL} as a dummy definition will make
sure the stack comes out right.
- @group
@smallexample
2: 4 1: 4 2: 4
1: 2 . 1: 2
. .
! 4 RET 2 C-x ( DEL C-x ) Z K s RET 2
! @end smallexample
@end group
The last step replaces the 2 that was eaten during the creation
of the dummy @kbd{z s} command. Now we move on to the real
--- 9658,9675 ----
@noindent
First we define a dummy program to go on the @kbd{z s} key. The true
@address@hidden s}} key is supposed to take two numbers from the stack and
! return one number, so @key{DEL} as a dummy definition will make
sure the stack comes out right.
@smallexample
+ @group
2: 4 1: 4 2: 4
1: 2 . 1: 2
. .
! 4 @key{RET} 2 C-x ( @key{DEL} C-x ) Z K s @key{RET} 2
@end group
+ @end smallexample
The last step replaces the 2 that was eaten during the creation
of the dummy @kbd{z s} command. Now we move on to the real
***************
*** 9774,9830 ****
(Because this definition is long, it will be repeated in concise form
below. You can use @kbd{M-# m} to load it from there.)
- @group
@smallexample
2: 4 4: 4 3: 4 2: 4
1: 2 3: 2 2: 2 1: 2
. 2: 4 1: 0 .
1: 2 .
.
! C-x ( M-2 RET a = Z [ DEL DEL 1 Z :
- @end smallexample
@end group
@noindent
- @group
@smallexample
4: 4 2: 4 2: 3 4: 3 4: 3 3: 3
3: 2 1: 2 1: 2 3: 2 3: 2 2: 2
2: 2 . . 2: 3 2: 3 1: 3
1: 0 1: 2 1: 1 .
. . .
! RET 0 a = Z [ DEL DEL 0 Z : TAB 1 - TAB M-2 RET 1 - z s
! @end smallexample
@end group
@noindent
(Note that the value 3 that our dummy @kbd{z s} produces is not correct;
it is merely a placeholder that will do just as well for now.)
- @group
@smallexample
3: 3 4: 3 3: 3 2: 3 1: -6
2: 3 3: 3 2: 3 1: 9 .
1: 2 2: 3 1: 3 .
. 1: 2 .
.
! M-TAB M-TAB TAB RET M-TAB z s * -
- @end smallexample
@end group
@noindent
- @group
@smallexample
1: -6 2: 4 1: 11 2: 11
. 1: 2 . 1: 11
. .
! Z ] Z ] C-x ) Z K s RET DEL 4 RET 2 z s M-RET k s
! @end smallexample
@end group
Even though the result that we got during the definition was highly
bogus, once the definition is complete the @kbd{z s} command gets
--- 9679,9735 ----
(Because this definition is long, it will be repeated in concise form
below. You can use @kbd{M-# m} to load it from there.)
@smallexample
+ @group
2: 4 4: 4 3: 4 2: 4
1: 2 3: 2 2: 2 1: 2
. 2: 4 1: 0 .
1: 2 .
.
! C-x ( M-2 @key{RET} a = Z [ @key{DEL} @key{DEL} 1 Z :
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
4: 4 2: 4 2: 3 4: 3 4: 3 3: 3
3: 2 1: 2 1: 2 3: 2 3: 2 2: 2
2: 2 . . 2: 3 2: 3 1: 3
1: 0 1: 2 1: 1 .
. . .
! @key{RET} 0 a = Z [ @key{DEL} @key{DEL} 0 Z : @key{TAB} 1 - @key{TAB}
M-2 @key{RET} 1 - z s
@end group
+ @end smallexample
@noindent
(Note that the value 3 that our dummy @kbd{z s} produces is not correct;
it is merely a placeholder that will do just as well for now.)
@smallexample
+ @group
3: 3 4: 3 3: 3 2: 3 1: -6
2: 3 3: 3 2: 3 1: 9 .
1: 2 2: 3 1: 3 .
. 1: 2 .
.
! address@hidden address@hidden @key{TAB} @key{RET} address@hidden
z s * -
@end group
+ @end smallexample
@noindent
@smallexample
+ @group
1: -6 2: 4 1: 11 2: 11
. 1: 2 . 1: 11
. .
! Z ] Z ] C-x ) Z K s @key{RET} @key{DEL} 4 @key{RET} 2 z s
address@hidden k s
@end group
+ @end smallexample
Even though the result that we got during the definition was highly
bogus, once the definition is complete the @kbd{z s} command gets
***************
*** 9832,9850 ****
Here's the full program once again:
- @group
@example
! C-x ( M-2 RET a =
! Z [ DEL DEL 1
! Z : RET 0 a =
! Z [ DEL DEL 0
! Z : TAB 1 - TAB M-2 RET 1 - z s
! M-TAB M-TAB TAB RET M-TAB z s * -
Z ]
Z ]
C-x )
- @end example
@end group
You can read this definition using @kbd{M-# m} (@code{read-kbd-macro})
followed by @kbd{Z K s}, without having to make a dummy definition
--- 9737,9755 ----
Here's the full program once again:
@example
! @group
! C-x ( M-2 @key{RET} a =
! Z [ @key{DEL} @key{DEL} 1
! Z : @key{RET} 0 a =
! Z [ @key{DEL} @key{DEL} 0
! Z : @key{TAB} 1 - @key{TAB} M-2 @key{RET} 1 - z s
! address@hidden address@hidden @key{TAB} @key{RET}
address@hidden z s * -
Z ]
Z ]
C-x )
@end group
+ @end example
You can read this definition using @kbd{M-# m} (@code{read-kbd-macro})
followed by @kbd{Z K s}, without having to make a dummy definition
***************
*** 9863,9869 ****
Stirling numbers in a convenient variable:
@smallexample
! s e StirlingRules RET
[ s(n,n) := 1 :: n >= 0,
s(n,0) := 0 :: n > 0,
s(n,m) := s(n-1,m-1) - (n-1) s(n-1,m) :: n >= m :: m >= 1 ]
--- 9768,9774 ----
Stirling numbers in a convenient variable:
@smallexample
! s e StirlingRules @key{RET}
[ s(n,n) := 1 :: n >= 0,
s(n,0) := 0 :: n > 0,
s(n,m) := s(n-1,m-1) - (n-1) s(n-1,m) :: n >= m :: m >= 1 ]
***************
*** 9872,9886 ****
Now, it's just a matter of applying the rules:
- @group
@smallexample
2: 4 1: s(4, 2) 1: 11
1: 2 . .
.
! 4 RET 2 C-x ( ' s($$,$) RET a r StirlingRules RET C-x )
! @end smallexample
@end group
As in the case of the @code{fib} rules, it would be useful to put these
rules in @code{EvalRules} and to add a @samp{:: remember} condition to
--- 9777,9791 ----
Now, it's just a matter of applying the rules:
@smallexample
+ @group
2: 4 1: s(4, 2) 1: 11
1: 2 . .
.
! 4 @key{RET} 2 C-x ( ' s($$,$) @key{RET} a r StirlingRules
@key{RET} C-x )
@end group
+ @end smallexample
As in the case of the @code{fib} rules, it would be useful to put these
rules in @code{EvalRules} and to add a @samp{:: remember} condition to
***************
*** 9942,9948 ****
@kindex M-# c
@kindex M-# M-#
! @c @mindex @null
@kindex M-# #
In most installations, the @kbd{M-# c} key sequence is a more
convenient way to start the Calculator. Also, @kbd{M-# M-#} and
--- 9847,9855 ----
@kindex M-# c
@kindex M-# M-#
! @ignore
! @mindex @null
! @end ignore
@kindex M-# #
In most installations, the @kbd{M-# c} key sequence is a more
convenient way to start the Calculator. Also, @kbd{M-# M-#} and
***************
*** 9999,10011 ****
tendency to drop you into the Calc Trail window instead, which
@kbd{M-# o} takes care not to do.)
! @c @mindex M-# q
For one quick calculation, you can type @kbd{M-# q} (@code{quick-calc})
which prompts you for a formula (like @samp{2+3/4}). The result is
displayed at the bottom of the Emacs screen without ever creating
any special Calculator windows. @xref{Quick Calculator}.
! @c @mindex M-# k
Finally, if you are using the X window system you may want to try
@kbd{M-# k} (@code{calc-keypad}) which runs Calc with a
``calculator keypad'' picture as well as a stack display. Click on
--- 9906,9922 ----
tendency to drop you into the Calc Trail window instead, which
@kbd{M-# o} takes care not to do.)
! @ignore
! @mindex M-# q
! @end ignore
For one quick calculation, you can type @kbd{M-# q} (@code{quick-calc})
which prompts you for a formula (like @samp{2+3/4}). The result is
displayed at the bottom of the Emacs screen without ever creating
any special Calculator windows. @xref{Quick Calculator}.
! @ignore
! @mindex M-# k
! @end ignore
Finally, if you are using the X window system you may want to try
@kbd{M-# k} (@code{calc-keypad}) which runs Calc with a
``calculator keypad'' picture as well as a stack display. Click on
***************
*** 10028,10042 ****
user interface (standard, Keypad, or Embedded) is currently active.
It also cancels @code{calc-edit} mode if used from there.
! @kindex d SPC
@pindex calc-refresh
@cindex Refreshing a garbled display
@cindex Garbled displays, refreshing
! The @kbd{d SPC} key sequence (@code{calc-refresh}) redraws the contents
of the Calculator buffer from memory. Use this if the contents of the
buffer have been damaged somehow.
! @c @mindex o
The @kbd{o} key (@code{calc-realign}) moves the cursor back to its
``home'' position at the bottom of the Calculator buffer.
--- 9939,9955 ----
user interface (standard, Keypad, or Embedded) is currently active.
It also cancels @code{calc-edit} mode if used from there.
! @kindex d @key{SPC}
@pindex calc-refresh
@cindex Refreshing a garbled display
@cindex Garbled displays, refreshing
! The @kbd{d @key{SPC}} key sequence (@code{calc-refresh}) redraws the contents
of the Calculator buffer from memory. Use this if the contents of the
buffer have been damaged somehow.
! @ignore
! @mindex o
! @end ignore
The @kbd{o} key (@code{calc-realign}) moves the cursor back to its
``home'' position at the bottom of the Calculator buffer.
***************
*** 10250,10256 ****
The @key{RET} (or equivalent @key{SPC}) key is only required to separate
two consecutive numbers.
(After all, if you typed @kbd{1 2} by themselves the Calculator
! would enter the number 12.) If you press @kbd{RET} or @kbd{SPC} @emph{not}
right after typing a number, the key duplicates the number on the top of
the stack. @address@hidden *} is thus a handy way to square a address@hidden
--- 10163,10169 ----
The @key{RET} (or equivalent @key{SPC}) key is only required to separate
two consecutive numbers.
(After all, if you typed @kbd{1 2} by themselves the Calculator
! would enter the number 12.) If you press @key{RET} or @key{SPC} @emph{not}
right after typing a number, the key duplicates the number on the top of
the stack. @address@hidden *} is thus a handy way to square a address@hidden
***************
*** 10294,10300 ****
These notations are described later in this manual with the corresponding
data types. @xref{Data Types}.
! During numeric entry, the only editing key available is @kbd{DEL}.
@node Algebraic Entry, Quick Calculator, Numeric Entry, Introduction
@section Algebraic Entry
--- 10207,10213 ----
These notations are described later in this manual with the corresponding
data types. @xref{Data Types}.
! During numeric entry, the only editing key available is @key{DEL}.
@node Algebraic Entry, Quick Calculator, Numeric Entry, Introduction
@section Algebraic Entry
***************
*** 10354,10360 ****
is the command to quit Calc, @kbd{M-p} sets the precision, and
@kbd{M-m t} (or @kbd{M-m M-t}, if you prefer) turns total algebraic
mode back off again. Meta keys also terminate algebraic entry, so
! that @kbd{2+3 M-S} is equivalent to @kbd{2+3 RET M-S}. The symbol
@samp{Alg*} will appear in the mode line whenever you are in this mode.
Pressing @kbd{'} (the apostrophe) a second time re-enters the previous
--- 10267,10273 ----
is the command to quit Calc, @kbd{M-p} sets the precision, and
@kbd{M-m t} (or @kbd{M-m M-t}, if you prefer) turns total algebraic
mode back off again. Meta keys also terminate algebraic entry, so
! that @kbd{2+3 M-S} is equivalent to @kbd{2+3 @key{RET} M-S}. The symbol
@samp{Alg*} will appear in the mode line whenever you are in this mode.
Pressing @kbd{'} (the apostrophe) a second time re-enters the previous
***************
*** 10394,10405 ****
@samp{$,$$} exchanges the top two elements of the stack, just like the
@key{TAB} key.
! You can finish an algebraic entry with @kbd{M-=} or @kbd{M-RET} instead
of @key{RET}. This uses @kbd{=} to evaluate the variables in each
formula that goes onto the stack. (Thus @kbd{' pi @key{RET}} pushes
! the variable @samp{pi}, but @kbd{' pi M-RET} pushes 3.1415.)
! If you finish your algebraic entry by pressing @kbd{LFD} (or @kbd{C-j})
instead of @key{RET}, Calc disables the default simplifications
(as if by @kbd{m O}; @pxref{Simplification Modes}) while the entry
is being pushed on the stack. Thus @kbd{' 1+2 @key{RET}} pushes 3
--- 10307,10318 ----
@samp{$,$$} exchanges the top two elements of the stack, just like the
@key{TAB} key.
! You can finish an algebraic entry with @kbd{M-=} or @address@hidden instead
of @key{RET}. This uses @kbd{=} to evaluate the variables in each
formula that goes onto the stack. (Thus @kbd{' pi @key{RET}} pushes
! the variable @samp{pi}, but @kbd{' pi address@hidden pushes 3.1415.)
! If you finish your algebraic entry by pressing @key{LFD} (or @kbd{C-j})
instead of @key{RET}, Calc disables the default simplifications
(as if by @kbd{m O}; @pxref{Simplification Modes}) while the entry
is being pushed on the stack. Thus @kbd{' 1+2 @key{RET}} pushes 3
***************
*** 10558,10564 ****
information, i.e., if you undo, then enter a number on the stack or make
any other change, then it will be too late to redo.
! @kindex M-RET
@pindex calc-last-args
@cindex Last-arguments feature
@cindex Arguments, restoring
--- 10471,10477 ----
information, i.e., if you undo, then enter a number on the stack or make
any other change, then it will be too late to redo.
! @kindex address@hidden
@pindex calc-last-args
@cindex Last-arguments feature
@cindex Arguments, restoring
***************
*** 11089,11095 ****
the complex conjugate of a vector is a vector of the complex conjugates
of its address@hidden
! @c @starindex
@tindex vec
Algebraic functions for building vectors include @samp{vec(a, b, c)}
to build @samp{[a, b, c]}, @samp{cvec(a, n, m)} to build an @c{$n\times m$}
--- 11002,11010 ----
the complex conjugate of a vector is a vector of the complex conjugates
of its address@hidden
! @ignore
! @starindex
! @end ignore
@tindex vec
Algebraic functions for building vectors include @samp{vec(a, b, c)}
to build @samp{[a, b, c]}, @samp{cvec(a, n, m)} to build an @c{$n\times m$}
***************
*** 11111,11118 ****
marks and backslashes are written @samp{\"} and @samp{\\}, respectively,
inside strings. Other notations introduced by backslashes are:
- @group
@example
\a 7 \^@@ 0
\b 8 \^a-z 1-26
\e 27 \^[ 27
--- 11026,11033 ----
marks and backslashes are written @samp{\"} and @samp{\\}, respectively,
inside strings. Other notations introduced by backslashes are:
@example
+ @group
\a 7 \^@@ 0
\b 8 \^a-z 1-26
\e 27 \^[ 27
***************
*** 11121,11128 ****
\r 13 \^^ 30
\t 9 \^_ 31
\^? 127
- @end example
@end group
@noindent
Finally, a backslash followed by three octal digits produces any
--- 11036,11043 ----
\r 13 \^^ 30
\t 9 \^_ 31
\^? 127
@end group
+ @end example
@noindent
Finally, a backslash followed by three octal digits produces any
***************
*** 11146,11152 ****
@pxref{Compositions}. Strings also provide a convenient
way to do conversions between ASCII characters and integers.
! @c @starindex
@tindex string
There is a @code{string} function which provides a different display
format for strings. Basically, @samp{string(@var{s})}, where @var{s}
--- 11061,11069 ----
@pxref{Compositions}. Strings also provide a convenient
way to do conversions between ASCII characters and integers.
! @ignore
! @starindex
! @end ignore
@tindex string
There is a @code{string} function which provides a different display
format for strings. Basically, @samp{string(@var{s})}, where @var{s}
***************
*** 11163,11169 ****
(same as shown above, but without the backslash). The quote and
backslash characters are left alone, as are characters 128 and above.
! @c @starindex
@tindex bstring
The @code{bstring} function is just like @code{string} except that
the resulting string is breakable across multiple lines if it doesn't
--- 11080,11088 ----
(same as shown above, but without the backslash). The quote and
backslash characters are left alone, as are characters 128 and above.
! @ignore
! @starindex
! @end ignore
@tindex bstring
The @code{bstring} function is just like @code{string} except that
the resulting string is breakable across multiple lines if it doesn't
***************
*** 11184,11200 ****
degrees, minutes, and seconds.
@kindex @@
! @c @mindex @null
@kindex ' (HMS forms)
! @c @mindex @null
@kindex " (HMS forms)
! @c @mindex @null
@kindex h (HMS forms)
! @c @mindex @null
@kindex o (HMS forms)
! @c @mindex @null
@kindex m (HMS forms)
! @c @mindex @null
@kindex s (HMS forms)
The default format for HMS values is
@address@hidden@@ @var{mins}' @var{secs}"}. During entry, the letters
--- 11103,11131 ----
degrees, minutes, and seconds.
@kindex @@
! @ignore
! @mindex @null
! @end ignore
@kindex ' (HMS forms)
! @ignore
! @mindex @null
! @end ignore
@kindex " (HMS forms)
! @ignore
! @mindex @null
! @end ignore
@kindex h (HMS forms)
! @ignore
! @mindex @null
! @end ignore
@kindex o (HMS forms)
! @ignore
! @mindex @null
! @end ignore
@kindex m (HMS forms)
! @ignore
! @mindex @null
! @end ignore
@kindex s (HMS forms)
The default format for HMS values is
@address@hidden@@ @var{mins}' @var{secs}"}. During entry, the letters
***************
*** 11343,11352 ****
@noindent
@cindex Modulo forms
A @dfn{modulo form} is a real number which is taken modulo (i.e., within
! an integer multiple of) some value @cite{M}. Arithmetic modulo @cite{M}
often arises in number theory. Modulo forms are written
! address@hidden @t{mod} @i{M}',
! where @cite{a} and @cite{M} are real numbers or HMS forms, and
@c{$0 \le a < M$}
@cite{0 <= a < @var{M}}.
In many applications @cite{a} and @cite{M} will be
--- 11274,11283 ----
@noindent
@cindex Modulo forms
A @dfn{modulo form} is a real number which is taken modulo (i.e., within
! an integer multiple of) some value @var{M}. Arithmetic modulo @var{M}
often arises in number theory. Modulo forms are written
! address@hidden @t{mod} @var{M}',
! where @var{a} and @var{M} are real numbers or HMS forms, and
@c{$0 \le a < M$}
@cite{0 <= a < @var{M}}.
In many applications @cite{a} and @cite{M} will be
***************
*** 11369,11390 ****
actually computing the power and then reducing.)
@cindex Modulo division
! Two modulo forms address@hidden @t{mod} @i{M}' and address@hidden @t{mod}
@i{M}'
can be divided if @cite{a}, @cite{b}, and @cite{M} are all
integers. The result is the modulo form which, when multiplied by
! address@hidden @t{mod} @i{M}', produces address@hidden @t{mod} @i{M}'. If
there is no solution to this equation (which can happen only when
@cite{M} is non-prime), or if any of the arguments are non-integers, the
division is left in symbolic form. Other operations, such as square
roots, are not yet supported for modulo forms. (Note that, although
! @address@hidden(address@hidden @t{mod} @address@hidden)^.5}'} will compute a
``modulo square root''
in the sense of reducing @c{$\sqrt a$}
@cite{sqrt(a)} modulo @cite{M}, this is not a
useful definition from the number-theoretical point of view.)@refill
! @c @mindex M
@kindex M (modulo forms)
! @c @mindex mod
@tindex mod (operator)
To create a modulo form during numeric entry, press the address@hidden
key to enter the word @samp{mod}. As a special convenience, pressing
--- 11300,11325 ----
actually computing the power and then reducing.)
@cindex Modulo division
! Two modulo forms address@hidden @t{mod} @var{M}' and address@hidden @t{mod}
@var{M}'
can be divided if @cite{a}, @cite{b}, and @cite{M} are all
integers. The result is the modulo form which, when multiplied by
! address@hidden @t{mod} @var{M}', produces address@hidden @t{mod} @var{M}'. If
there is no solution to this equation (which can happen only when
@cite{M} is non-prime), or if any of the arguments are non-integers, the
division is left in symbolic form. Other operations, such as square
roots, are not yet supported for modulo forms. (Note that, although
! @address@hidden(address@hidden @t{mod} @address@hidden)^.5}'} will compute a
``modulo square root''
in the sense of reducing @c{$\sqrt a$}
@cite{sqrt(a)} modulo @cite{M}, this is not a
useful definition from the number-theoretical point of view.)@refill
! @ignore
! @mindex M
! @end ignore
@kindex M (modulo forms)
! @ignore
! @mindex mod
! @end ignore
@tindex mod (operator)
To create a modulo form during numeric entry, press the address@hidden
key to enter the word @samp{mod}. As a special convenience, pressing
***************
*** 11408,11414 ****
enter the formula @samp{(x + 2) mod 5}, Calc propagates the modulus
to each of the coefficients: @samp{(1 mod 5) x + (2 mod 5)}.
! @c @starindex
@tindex makemod
The algebraic function @samp{makemod(a, m)} builds the modulo form
@address@hidden mod m}}.
--- 11343,11351 ----
enter the formula @samp{(x + 2) mod 5}, Calc propagates the modulus
to each of the coefficients: @samp{(1 mod 5) x + (2 mod 5)}.
! @ignore
! @starindex
! @end ignore
@tindex makemod
The algebraic function @samp{makemod(a, m)} builds the modulo form
@address@hidden mod m}}.
***************
*** 11421,11427 ****
@cindex Standard deviations
An @dfn{error form} is a number with an associated standard
deviation, as in @samp{2.3 +/- 0.12}. The notation
! address@hidden @t{+/-} @c{$\sigma$}
@asis{sigma}' stands for an uncertain value which follows a normal or
Gaussian distribution of mean @cite{x} and standard deviation or
``error'' @c{$\sigma$}
--- 11358,11364 ----
@cindex Standard deviations
An @dfn{error form} is a number with an associated standard
deviation, as in @samp{2.3 +/- 0.12}. The notation
! address@hidden @t{+/-} @c{$\sigma$}
@asis{sigma}' stands for an uncertain value which follows a normal or
Gaussian distribution of mean @cite{x} and standard deviation or
``error'' @c{$\sigma$}
***************
*** 11464,11473 ****
of standard deviations. Actual errors often are neither Gaussian-distributed
nor uncorrelated, and the above formulas are valid only when errors
are small. As an example, the error arising from
! address@hidden(address@hidden @t{+/-} @c{$\sigma$}
! @address@hidden)}' is
address@hidden
! @i{sigma} @t{abs(cos(address@hidden@t{))}'. When @cite{x} is close to zero,
@c{$\cos x$}
@cite{cos(x)} is
close to one so the error in the sine is close to @c{$\sigma$}
--- 11401,11410 ----
of standard deviations. Actual errors often are neither Gaussian-distributed
nor uncorrelated, and the above formulas are valid only when errors
are small. As an example, the error arising from
! address@hidden(address@hidden @t{+/-} @c{$\sigma$}
! @address@hidden)}' is
address@hidden
! @var{sigma} @t{abs(cos(address@hidden@t{))}'. When @cite{x} is close to zero,
@c{$\cos x$}
@cite{cos(x)} is
close to one so the error in the sine is close to @c{$\sigma$}
***************
*** 11485,11491 ****
in @cite{x} had been small, the error in @c{$\sin x$}
@cite{sin(x)} would indeed have been address@hidden
! @c @mindex p
@kindex p (error forms)
@tindex +/-
To enter an error form during regular numeric entry, use the @kbd{p}
--- 11422,11430 ----
in @cite{x} had been small, the error in @c{$\sin x$}
@cite{sin(x)} would indeed have been address@hidden
! @ignore
! @mindex p
! @end ignore
@kindex p (error forms)
@tindex +/-
To enter an error form during regular numeric entry, use the @kbd{p}
***************
*** 11506,11512 ****
Error forms may also be composed of HMS forms. For best results, both
the mean and the error should be HMS forms if either one is.
! @c @starindex
@tindex sdev
The algebraic function @samp{sdev(a, b)} builds the error form @samp{a +/- b}.
--- 11445,11453 ----
Error forms may also be composed of HMS forms. For best results, both
the mean and the error should be HMS forms if either one is.
! @ignore
! @starindex
! @end ignore
@tindex sdev
The algebraic function @samp{sdev(a, b)} builds the error form @samp{a +/- b}.
***************
*** 11585,11595 ****
While it may seem that intervals and error forms are similar, they are
based on entirely different concepts of inexact quantities. An error
! form address@hidden @t{+/-} @c{$\sigma$}
! @i{sigma}' means a variable is random, and its value could
be anything but is ``probably'' within one @c{$\sigma$}
! @i{sigma} of the mean value @cite{x}.
! An interval address@hidden@i{a} @t{..@:} @address@hidden' means a variable's
value
is unknown, but guaranteed to lie in the specified range. Error forms
are statistical or ``average case'' approximations; interval arithmetic
tends to produce ``worst case'' bounds on an address@hidden
--- 11526,11536 ----
While it may seem that intervals and error forms are similar, they are
based on entirely different concepts of inexact quantities. An error
! form address@hidden @t{+/-} @c{$\sigma$}
! @var{sigma}' means a variable is random, and its value could
be anything but is ``probably'' within one @c{$\sigma$}
! @var{sigma} of the mean value @cite{x}.
! An interval address@hidden@var{a} @t{..@:} @address@hidden' means a
variable's value
is unknown, but guaranteed to lie in the specified range. Error forms
are statistical or ``average case'' approximations; interval arithmetic
tends to produce ``worst case'' bounds on an address@hidden
***************
*** 11600,11606 ****
@xref{Set Operations}, for commands that interpret interval forms
as subsets of the set of real numbers.
! @c @starindex
@tindex intv
The algebraic function @samp{intv(n, a, b)} builds an interval form
from @samp{a} to @samp{b}; @samp{n} is an integer code which must
--- 11541,11549 ----
@xref{Set Operations}, for commands that interpret interval forms
as subsets of the set of real numbers.
! @ignore
! @starindex
! @end ignore
@tindex intv
The algebraic function @samp{intv(n, a, b)} builds an interval form
from @samp{a} to @samp{b}; @samp{n} is an integer code which must
***************
*** 11622,11635 ****
@section Incomplete Objects
@noindent
! @c @mindex [ ]
@kindex [
! @c @mindex ( )
@kindex (
@kindex ,
! @c @mindex @null
@kindex ]
! @c @mindex @null
@kindex )
@cindex Incomplete vectors
@cindex Incomplete complex numbers
--- 11565,11586 ----
@section Incomplete Objects
@noindent
! @ignore
! @mindex [ ]
! @end ignore
@kindex [
! @ignore
! @mindex ( )
! @end ignore
@kindex (
@kindex ,
! @ignore
! @mindex @null
! @end ignore
@kindex ]
! @ignore
! @mindex @null
! @end ignore
@kindex )
@cindex Incomplete vectors
@cindex Incomplete complex numbers
***************
*** 11919,11926 ****
@section Stack Manipulation Commands
@noindent
! @kindex RET
! @kindex SPC
@pindex calc-enter
@cindex Duplicating stack entries
To duplicate the top object on the stack, press @key{RET} or @key{SPC}
--- 11870,11877 ----
@section Stack Manipulation Commands
@noindent
! @kindex @key{RET}
! @kindex @key{SPC}
@pindex calc-enter
@cindex Duplicating stack entries
To duplicate the top object on the stack, press @key{RET} or @key{SPC}
***************
*** 11936,11942 ****
@kbd{C-u - 2 @key{RET}} creates @samp{10 20 30 20}, and
@kbd{C-u 0 @key{RET}} creates @samp{10 20 30 10 20 address@hidden
! @kindex LFD
@pindex calc-over
The @key{LFD} (@code{calc-over}) command (on a key marked Line-Feed if you
have it, else on @kbd{C-j}) is like @code{calc-enter}
--- 11887,11893 ----
@kbd{C-u - 2 @key{RET}} creates @samp{10 20 30 20}, and
@kbd{C-u 0 @key{RET}} creates @samp{10 20 30 10 20 address@hidden
! @kindex @key{LFD}
@pindex calc-over
The @key{LFD} (@code{calc-over}) command (on a key marked Line-Feed if you
have it, else on @kbd{C-j}) is like @code{calc-enter}
***************
*** 11946,11952 ****
are both equivalent to @kbd{C-u - 2 @key{RET}}, producing
@samp{10 20 30 address@hidden
! @kindex DEL
@kindex C-d
@pindex calc-pop
@cindex Removing stack entries
--- 11897,11903 ----
are both equivalent to @kbd{C-u - 2 @key{RET}}, producing
@samp{10 20 30 address@hidden
! @kindex @key{DEL}
@kindex C-d
@pindex calc-pop
@cindex Removing stack entries
***************
*** 11964,11979 ****
@kbd{C-u - 2 @key{DEL}} leaves @samp{10 30}, and
@kbd{C-u 0 @key{DEL}} leaves an empty address@hidden
! @kindex M-DEL
@pindex calc-pop-above
! The @key{M-DEL} (@code{calc-pop-above}) command is to @key{DEL} what
@key{LFD} is to @key{RET}: It interprets the sign of the numeric
prefix argument in the opposite way, and the default argument is 2.
! Thus @key{M-DEL} by itself removes the second-from-top stack element,
! leaving the first, third, fourth, and so on; @kbd{M-3 M-DEL} deletes
the third stack element.
! @kindex TAB
@pindex calc-roll-down
To exchange the top two elements of the stack, press @key{TAB}
(@code{calc-roll-down}). Given a positive numeric prefix argument, the
--- 11915,11930 ----
@kbd{C-u - 2 @key{DEL}} leaves @samp{10 30}, and
@kbd{C-u 0 @key{DEL}} leaves an empty address@hidden
! @kindex address@hidden
@pindex calc-pop-above
! The @address@hidden (@code{calc-pop-above}) command is to @key{DEL} what
@key{LFD} is to @key{RET}: It interprets the sign of the numeric
prefix argument in the opposite way, and the default argument is 2.
! Thus @address@hidden by itself removes the second-from-top stack element,
! leaving the first, third, fourth, and so on; @kbd{M-3 address@hidden deletes
the third stack element.
! @kindex @key{TAB}
@pindex calc-roll-down
To exchange the top two elements of the stack, press @key{TAB}
(@code{calc-roll-down}). Given a positive numeric prefix argument, the
***************
*** 11987,12016 ****
@kbd{C-u - 2 @key{TAB}} creates @samp{40 50 10 20 30}, and
@kbd{C-u 0 @key{TAB}} creates @samp{50 40 30 20 address@hidden
! @kindex M-TAB
@pindex calc-roll-up
! The command @key{M-TAB} (@code{calc-roll-up}) is analogous to @key{TAB}
except that it rotates upward instead of downward. Also, the default
with no prefix argument is to rotate the top 3 elements.
For example, with @samp{10 20 30 40 50} on the stack,
! @key{M-TAB} creates @samp{10 20 40 50 30},
! @kbd{C-u 4 @key{M-TAB}} creates @samp{10 30 40 50 20},
! @kbd{C-u - 2 @key{M-TAB}} creates @samp{30 40 50 10 20}, and
! @kbd{C-u 0 @key{M-TAB}} creates @samp{50 40 30 20 address@hidden
! A good way to view the operation of @key{TAB} and @key{M-TAB} is in
terms of moving a particular element to a new position in the stack.
! With a positive argument @i{n}, @key{TAB} moves the top stack
! element down to level @i{n}, making room for it by pulling all the
! intervening stack elements toward the top. @key{M-TAB} moves the
! element at level @i{n} up to the top. (Compare with @key{LFD},
! which copies instead of moving the element in level @i{n}.)
!
! With a negative argument @i{-n}, @key{TAB} rotates the stack
! to move the object in level @i{n} to the deepest place in the
! stack, and the object in level @i{n+1} to the top. @key{M-TAB}
rotates the deepest stack element to be in level @i{n}, also
! putting the top stack element in level @i{n+1}.
@xref{Selecting Subformulas}, for a way to apply these commands to
any portion of a vector or formula on the stack.
--- 11938,11967 ----
@kbd{C-u - 2 @key{TAB}} creates @samp{40 50 10 20 30}, and
@kbd{C-u 0 @key{TAB}} creates @samp{50 40 30 20 address@hidden
! @kindex address@hidden
@pindex calc-roll-up
! The command @address@hidden (@code{calc-roll-up}) is analogous to @key{TAB}
except that it rotates upward instead of downward. Also, the default
with no prefix argument is to rotate the top 3 elements.
For example, with @samp{10 20 30 40 50} on the stack,
! @address@hidden creates @samp{10 20 40 50 30},
! @kbd{C-u 4 address@hidden creates @samp{10 30 40 50 20},
! @kbd{C-u - 2 address@hidden creates @samp{30 40 50 10 20}, and
! @kbd{C-u 0 address@hidden creates @samp{50 40 30 20 address@hidden
! A good way to view the operation of @key{TAB} and @address@hidden is in
terms of moving a particular element to a new position in the stack.
! With a positive argument @var{n}, @key{TAB} moves the top stack
! element down to level @var{n}, making room for it by pulling all the
! intervening stack elements toward the top. @address@hidden moves the
! element at level @var{n} up to the top. (Compare with @key{LFD},
! which copies instead of moving the element in level @var{n}.)
!
! With a negative argument @address@hidden, @key{TAB} rotates the stack
! to move the object in level @var{n} to the deepest place in the
! stack, and the object in level @address@hidden to the top. @address@hidden
rotates the deepest stack element to be in level @i{n}, also
! putting the top stack element in level @address@hidden
@xref{Selecting Subformulas}, for a way to apply these commands to
any portion of a vector or formula on the stack.
***************
*** 12208,12217 ****
simplified version of the formula onto the stack after the original
formula (rather than replacing the original formula).
! Note that you could get the same effect by typing @kbd{RET a s},
copying the formula and then simplifying the copy. One difference
is that for a very large formula the time taken to format the
! intermediate copy in @kbd{RET a s} could be noticeable; @kbd{K a s}
would avoid this extra work.
Even stack manipulation commands are affected. @key{TAB} works by
--- 12159,12168 ----
simplified version of the formula onto the stack after the original
formula (rather than replacing the original formula).
! Note that you could get the same effect by typing @address@hidden a s},
copying the formula and then simplifying the copy. One difference
is that for a very large formula the time taken to format the
! intermediate copy in @address@hidden a s} could be noticeable; @kbd{K a s}
would avoid this extra work.
Even stack manipulation commands are affected. @key{TAB} works by
***************
*** 12385,12391 ****
If you need to work with a particular fixed accuracy (say, dollars and
cents with two digits after the decimal point), one solution is to work
with integers and an ``implied'' decimal point. For example, $8.99
! divided by 6 would be entered @kbd{899 RET 6 /}, yielding 149.833
(actually $1.49833 with our implied decimal point); pressing @kbd{R}
would round this to 150 cents, i.e., $1.50.
--- 12336,12342 ----
If you need to work with a particular fixed accuracy (say, dollars and
cents with two digits after the decimal point), one solution is to work
with integers and an ``implied'' decimal point. For example, $8.99
! divided by 6 would be entered @kbd{899 @key{RET} 6 /}, yielding 149.833
(actually $1.49833 with our implied decimal point); pressing @kbd{R}
would round this to 150 cents, i.e., $1.50.
***************
*** 12832,12842 ****
A declaration is in general a vector of @dfn{type symbols} and
@dfn{range} values. If there is only one type symbol or range value,
you can write it directly rather than enclosing it in a vector.
! For example, @kbd{s d foo RET real RET} declares @code{foo} to
! be a real number, and @kbd{s d bar RET [int, const, [1..6]] RET}
declares @code{bar} to be a constant integer between 1 and 6.
(Actually, you can omit the outermost brackets and Calc will
! provide them for you: @kbd{s d bar RET int, const, [1..6] RET}.)
@cindex @code{Decls} variable
@vindex Decls
--- 12783,12793 ----
A declaration is in general a vector of @dfn{type symbols} and
@dfn{range} values. If there is only one type symbol or range value,
you can write it directly rather than enclosing it in a vector.
! For example, @kbd{s d foo @key{RET} real @key{RET}} declares @code{foo} to
! be a real number, and @kbd{s d bar @key{RET} [int, const, [1..6]] @key{RET}}
declares @code{bar} to be a constant integer between 1 and 6.
(Actually, you can omit the outermost brackets and Calc will
! provide them for you: @kbd{s d bar @key{RET} int, const, [1..6] @key{RET}}.)
@cindex @code{Decls} variable
@vindex Decls
***************
*** 12858,12870 ****
For example, the declaration matrix
- @group
@smallexample
[ [ foo, real ]
[ [j, k, n], int ]
[ f(1,2,3), [0 .. inf) ] ]
- @end smallexample
@end group
@noindent
declares that @code{foo} represents a real number, @code{j}, @code{k}
--- 12809,12821 ----
For example, the declaration matrix
@smallexample
+ @group
[ [ foo, real ]
[ [j, k, n], int ]
[ f(1,2,3), [0 .. inf) ] ]
@end group
+ @end smallexample
@noindent
declares that @code{foo} represents a real number, @code{j}, @code{k}
***************
*** 12890,12902 ****
more intervals or numbers that represent the set of possible values
for the variable.
- @group
@smallexample
[ [ a, [1, 2, 3, 4, 5] ]
[ b, [1 .. 5] ]
[ c, [int, 1 .. 5] ] ]
- @end smallexample
@end group
Here @code{a} is declared to contain one of the five integers shown;
@code{b} is any number in the interval from 1 to 5 (any real number
--- 12841,12853 ----
more intervals or numbers that represent the set of possible values
for the variable.
@smallexample
+ @group
[ [ a, [1, 2, 3, 4, 5] ]
[ b, [1 .. 5] ]
[ c, [int, 1 .. 5] ] ]
@end group
+ @end smallexample
Here @code{a} is declared to contain one of the five integers shown;
@code{b} is any number in the interval from 1 to 5 (any real number
***************
*** 12968,12975 ****
One instance of this simplification is @samp{sqrt(x^2)} (since the
@code{sqrt} function is effectively a one-half power). Normally
Calc leaves this formula alone. After the command
! @kbd{s d x RET real RET}, however, it can simplify the formula to
! @samp{abs(x)}. And after @kbd{s d x RET nonneg RET}, Calc can
simplify this formula all the way to @samp{x}.
If there are any intervals or real numbers in the type specifier,
--- 12919,12926 ----
One instance of this simplification is @samp{sqrt(x^2)} (since the
@code{sqrt} function is effectively a one-half power). Normally
Calc leaves this formula alone. After the command
! @kbd{s d x @key{RET} real @key{RET}}, however, it can simplify the formula to
! @samp{abs(x)}. And after @kbd{s d x @key{RET} nonneg @key{RET}}, Calc can
simplify this formula all the way to @samp{x}.
If there are any intervals or real numbers in the type specifier,
***************
*** 13088,13098 ****
Calc consults knowledge of its own built-in functions as well as your
own declarations: @samp{dint(floor(x))} returns 1.
! @c @starindex
@tindex dint
! @c @starindex
@tindex dnumint
! @c @starindex
@tindex dnatnum
The @code{dint} function checks if its argument is an integer.
The @code{dnatnum} function checks if its argument is a natural
--- 13039,13055 ----
Calc consults knowledge of its own built-in functions as well as your
own declarations: @samp{dint(floor(x))} returns 1.
! @ignore
! @starindex
! @end ignore
@tindex dint
! @ignore
! @starindex
! @end ignore
@tindex dnumint
! @ignore
! @starindex
! @end ignore
@tindex dnatnum
The @code{dint} function checks if its argument is an integer.
The @code{dnatnum} function checks if its argument is a natural
***************
*** 13103,13129 ****
suitable elements, and that real infinities @samp{inf} and @samp{-inf}
are considered to be integers for the purposes of these functions.
! @c @starindex
@tindex drat
The @code{drat} function checks if its argument is rational, i.e.,
an integer or fraction. Infinities count as rational, but intervals
and error forms do not.
! @c @starindex
@tindex dreal
The @code{dreal} function checks if its argument is real. This
includes integers, fractions, floats, real error forms, and intervals.
! @c @starindex
@tindex dimag
The @code{dimag} function checks if its argument is imaginary,
i.e., is mathematically equal to a real number times @cite{i}.
! @c @starindex
@tindex dpos
! @c @starindex
@tindex dneg
! @c @starindex
@tindex dnonneg
The @code{dpos} function checks for positive (but nonzero) reals.
The @code{dneg} function checks for negative reals. The @code{dnonneg}
--- 13060,13098 ----
suitable elements, and that real infinities @samp{inf} and @samp{-inf}
are considered to be integers for the purposes of these functions.
! @ignore
! @starindex
! @end ignore
@tindex drat
The @code{drat} function checks if its argument is rational, i.e.,
an integer or fraction. Infinities count as rational, but intervals
and error forms do not.
! @ignore
! @starindex
! @end ignore
@tindex dreal
The @code{dreal} function checks if its argument is real. This
includes integers, fractions, floats, real error forms, and intervals.
! @ignore
! @starindex
! @end ignore
@tindex dimag
The @code{dimag} function checks if its argument is imaginary,
i.e., is mathematically equal to a real number times @cite{i}.
! @ignore
! @starindex
! @end ignore
@tindex dpos
! @ignore
! @starindex
! @end ignore
@tindex dneg
! @ignore
! @starindex
! @end ignore
@tindex dnonneg
The @code{dpos} function checks for positive (but nonzero) reals.
The @code{dneg} function checks for negative reals. The @code{dnonneg}
***************
*** 13134,13140 ****
so the actual functions @code{dpos}, @code{dneg}, and @code{dnonneg}
are rarely necessary.
! @c @starindex
@tindex dnonzero
The @code{dnonzero} function checks that its argument is nonzero.
This includes all nonzero real or complex numbers, all intervals that
--- 13103,13111 ----
so the actual functions @code{dpos}, @code{dneg}, and @code{dnonneg}
are rarely necessary.
! @ignore
! @starindex
! @end ignore
@tindex dnonzero
The @code{dnonzero} function checks that its argument is nonzero.
This includes all nonzero real or complex numbers, all intervals that
***************
*** 13144,13152 ****
represent values which could be anything including zero. (This is
also the set of objects considered ``true'' in conditional contexts.)
! @c @starindex
@tindex deven
! @c @starindex
@tindex dodd
The @code{deven} function returns 1 if its argument is known to be
an even integer (or integer-valued float); it returns 0 if its argument
--- 13115,13127 ----
represent values which could be anything including zero. (This is
also the set of objects considered ``true'' in conditional contexts.)
! @ignore
! @starindex
! @end ignore
@tindex deven
! @ignore
! @starindex
! @end ignore
@tindex dodd
The @code{deven} function returns 1 if its argument is known to be
an even integer (or integer-valued float); it returns 0 if its argument
***************
*** 13154,13160 ****
The @kbd{a s} command uses this to simplify a test of the form
@samp{x % 2 = 0}. There is also an analogous @code{dodd} function.
! @c @starindex
@tindex drange
The @code{drange} function returns a set (an interval or a vector
of intervals and/or numbers; @pxref{Set Operations}) that describes
--- 13129,13137 ----
The @kbd{a s} command uses this to simplify a test of the form
@samp{x % 2 = 0}. There is also an analogous @code{dodd} function.
! @ignore
! @starindex
! @end ignore
@tindex drange
The @code{drange} function returns a set (an interval or a vector
of intervals and/or numbers; @pxref{Set Operations}) that describes
***************
*** 13166,13172 ****
the expression is not provably real, the @code{drange} function
remains unevaluated.
! @c @starindex
@tindex dscalar
The @code{dscalar} function returns 1 if its argument is provably
scalar, or 0 if its argument is provably non-scalar. It is left
--- 13143,13151 ----
the expression is not provably real, the @code{drange} function
remains unevaluated.
! @ignore
! @starindex
! @end ignore
@tindex dscalar
The @code{dscalar} function returns 1 if its argument is provably
scalar, or 0 if its argument is provably non-scalar. It is left
***************
*** 13196,13215 ****
will appear in the mode line when Calc thinks the stack display may not
reflect the latest mode settings.
! @kindex d RET
@pindex calc-refresh-top
! The @kbd{d RET} (@code{calc-refresh-top}) command reformats the
top stack entry according to all the current modes. Positive prefix
arguments reformat the top @var{n} entries; negative prefix arguments
reformat the specified entry, and a prefix of zero is equivalent to
! @kbd{d SPC} (@code{calc-refresh}), which reformats the entire stack.
! For example, @kbd{H d s M-2 d RET} changes to scientific notation
but reformats only the top two stack entries in the new mode.
The @kbd{I} prefix has another effect on the display modes. The mode
is set only temporarily; the top stack entry is reformatted according
to that mode, then the original mode setting is restored. In other
! words, @kbd{I d s} is equivalent to @kbd{H d s d RET H d (@var{old mode})}.
@menu
* Radix Modes::
--- 13175,13194 ----
will appear in the mode line when Calc thinks the stack display may not
reflect the latest mode settings.
! @kindex d @key{RET}
@pindex calc-refresh-top
! The @kbd{d @key{RET}} (@code{calc-refresh-top}) command reformats the
top stack entry according to all the current modes. Positive prefix
arguments reformat the top @var{n} entries; negative prefix arguments
reformat the specified entry, and a prefix of zero is equivalent to
! @kbd{d @key{SPC}} (@code{calc-refresh}), which reformats the entire stack.
! For example, @kbd{H d s M-2 d @key{RET}} changes to scientific notation
but reformats only the top two stack entries in the new mode.
The @kbd{I} prefix has another effect on the display modes. The mode
is set only temporarily; the top stack entry is reformatted according
to that mode, then the original mode setting is restored. In other
! words, @kbd{I d s} is equivalent to @kbd{H d s d @key{RET} H d (@var{old
mode})}.
@menu
* Radix Modes::
***************
*** 13829,13835 ****
address@hidden
If you change the width of the Calculator window you may have to type
! @kbd{d SPC} (@code{calc-refresh}) to re-align right-justified or centered
text.
Right-justification is especially useful together with fixed-point
--- 13808,13814 ----
address@hidden
If you change the width of the Calculator window you may have to type
! @kbd{d @key{SPC}} (@code{calc-refresh}) to re-align right-justified or
centered
text.
Right-justification is especially useful together with fixed-point
***************
*** 14200,14230 ****
@address@hidden@calcindexernoshow @c Suppress marginal notes
@address@hidden@calcindexernoshow
@end iftex
! @c @starindex
@tindex acute
! @c @starindex
@tindex bar
! @c @starindex
@tindex breve
! @c @starindex
@tindex check
! @c @starindex
@tindex dot
! @c @starindex
@tindex dotdot
! @c @starindex
@tindex dyad
! @c @starindex
@tindex grave
! @c @starindex
@tindex hat
! @c @starindex
@tindex Prime
! @c @starindex
@tindex tilde
! @c @starindex
@tindex under
! @c @starindex
@tindex Vec
@iftex
@endgroup
--- 14179,14235 ----
@address@hidden@calcindexernoshow @c Suppress marginal notes
@address@hidden@calcindexernoshow
@end iftex
! @ignore
! @starindex
! @end ignore
@tindex acute
! @ignore
! @starindex
! @end ignore
@tindex bar
! @ignore
! @starindex
! @end ignore
@tindex breve
! @ignore
! @starindex
! @end ignore
@tindex check
! @ignore
! @starindex
! @end ignore
@tindex dot
! @ignore
! @starindex
! @end ignore
@tindex dotdot
! @ignore
! @starindex
! @end ignore
@tindex dyad
! @ignore
! @starindex
! @end ignore
@tindex grave
! @ignore
! @starindex
! @end ignore
@tindex hat
! @ignore
! @starindex
! @end ignore
@tindex Prime
! @ignore
! @starindex
! @end ignore
@tindex tilde
! @ignore
! @starindex
! @end ignore
@tindex under
! @ignore
! @starindex
! @end ignore
@tindex Vec
@iftex
@endgroup
***************
*** 14294,14360 ****
@iftex
Here are some examples of how various Calc formulas are formatted in @TeX{}:
- @group
@example
sin(a^2 / b_i)
\sin\left( {a^2 \over b_i} \right)
@end example
@tex
\let\rm\goodrm
$$ \sin\left( a^2 \over b_i \right) $$
@end tex
@sp 1
- @end group
- @group
@example
[(3, 4), 3:4, 3 +/- 4, [3 .. inf)]
[3 + 4i, @{3 \over address@hidden, 3 \pm 4, [3 \ldots \infty)]
@end example
@tex
\turnoffactive
$$ [3 + 4i, {3 \over 4}, 3 \pm 4, [ 3 \ldots \infty)] $$
@end tex
@sp 1
- @end group
- @group
@example
[abs(a), abs(a / b), floor(a), ceil(a / b)]
[|a|, \left| a \over b \right|,
\lfloor a \rfloor, \left\lceil a \over b \right\rceil]
@end example
@tex
$$ [|a|, \left| a \over b \right|,
\lfloor a \rfloor, \left\lceil a \over b \right\rceil] $$
@end tex
@sp 1
- @end group
- @group
@example
[sin(a), sin(2 a), sin(2 + a), sin(a / b)]
address@hidden@}, address@hidden address@hidden, \sin(2 + a),
\sin\left( @{a \over address@hidden \right)]
@end example
@tex
\turnoffactive\let\rm\goodrm
$$ [\sin{a}, \sin{2 a}, \sin(2 + a), \sin\left( {a \over b} \right)] $$
@end tex
@sp 2
- @end group
- @group
First with plain @kbd{d T}, then with @kbd{C-u d T}, then finally with
@kbd{C-u - d T} (using the example definition
@address@hidden F(#1)@}}:
@example
!
[f(a), foo(bar), sin(pi)]
[f(a), foo(bar), \sin{\pi}]
[f(a), address@hidden@}(address@hidden@}), address@hidden@}]
[f(a), address@hidden@address@hidden@}, address@hidden@}]
@end example
@tex
\let\rm\goodrm
--- 14299,14365 ----
@iftex
Here are some examples of how various Calc formulas are formatted in @TeX{}:
@example
+ @group
sin(a^2 / b_i)
\sin\left( {a^2 \over b_i} \right)
+ @end group
@end example
@tex
\let\rm\goodrm
$$ \sin\left( a^2 \over b_i \right) $$
@end tex
@sp 1
@example
+ @group
[(3, 4), 3:4, 3 +/- 4, [3 .. inf)]
[3 + 4i, @{3 \over address@hidden, 3 \pm 4, [3 \ldots \infty)]
+ @end group
@end example
@tex
\turnoffactive
$$ [3 + 4i, {3 \over 4}, 3 \pm 4, [ 3 \ldots \infty)] $$
@end tex
@sp 1
@example
+ @group
[abs(a), abs(a / b), floor(a), ceil(a / b)]
[|a|, \left| a \over b \right|,
\lfloor a \rfloor, \left\lceil a \over b \right\rceil]
+ @end group
@end example
@tex
$$ [|a|, \left| a \over b \right|,
\lfloor a \rfloor, \left\lceil a \over b \right\rceil] $$
@end tex
@sp 1
@example
+ @group
[sin(a), sin(2 a), sin(2 + a), sin(a / b)]
address@hidden@}, address@hidden address@hidden, \sin(2 + a),
\sin\left( @{a \over address@hidden \right)]
+ @end group
@end example
@tex
\turnoffactive\let\rm\goodrm
$$ [\sin{a}, \sin{2 a}, \sin(2 + a), \sin\left( {a \over b} \right)] $$
@end tex
@sp 2
First with plain @kbd{d T}, then with @kbd{C-u d T}, then finally with
@kbd{C-u - d T} (using the example definition
@address@hidden F(#1)@}}:
@example
! @group
[f(a), foo(bar), sin(pi)]
[f(a), foo(bar), \sin{\pi}]
[f(a), address@hidden@}(address@hidden@}), address@hidden@}]
[f(a), address@hidden@address@hidden@}, address@hidden@}]
+ @end group
@end example
@tex
\let\rm\goodrm
***************
*** 14363,14377 ****
$$ [f(a), \tilde F(\hbox{bar}), \sin{\pi}] $$
@end tex
@sp 2
- @end group
- @group
First with @address@hidden@}}, then with @address@hidden@}}:
@example
!
2 + 3 => 5
\evalto 2 + 3 \to 5
@end example
@tex
\turnoffactive
--- 14368,14381 ----
$$ [f(a), \tilde F(\hbox{bar}), \sin{\pi}] $$
@end tex
@sp 2
First with @address@hidden@}}, then with @address@hidden@}}:
@example
! @group
2 + 3 => 5
\evalto 2 + 3 \to 5
+ @end group
@end example
@tex
\turnoffactive
***************
*** 14379,14393 ****
$$ 5 $$
@end tex
@sp 2
- @end group
- @group
First with standard @code{\to}, then with @samp{\let\to\Rightarrow}:
@example
!
[2 + 3 => 5, a / 2 => (b + c) / 2]
address@hidden + 3 \to address@hidden, @address@hidden \over address@hidden
\to @{b + c \over address@hidden@}]
@end example
@tex
\turnoffactive
--- 14383,14396 ----
$$ 5 $$
@end tex
@sp 2
First with standard @code{\to}, then with @samp{\let\to\Rightarrow}:
@example
! @group
[2 + 3 => 5, a / 2 => (b + c) / 2]
address@hidden + 3 \to address@hidden, @address@hidden \over address@hidden
\to @{b + c \over address@hidden@}]
+ @end group
@end example
@tex
\turnoffactive
***************
*** 14396,14411 ****
$$ [{2 + 3 \to 5}, {{a \over 2} \to {b + c \over 2}}] $$}
@end tex
@sp 2
- @end group
- @group
Matrices normally, then changing @code{\matrix} to @code{\pmatrix}:
@example
!
[ [ a / b, 0 ], [ 0, 2^(x + 1) ] ]
address@hidden @{a \over address@hidden & 0 \\ 0 & address@hidden(x + 1)@} @}
address@hidden @{a \over address@hidden & 0 \\ 0 & address@hidden(x + 1)@} @}
@end example
@tex
\turnoffactive
--- 14399,14413 ----
$$ [{2 + 3 \to 5}, {{a \over 2} \to {b + c \over 2}}] $$}
@end tex
@sp 2
Matrices normally, then changing @code{\matrix} to @code{\pmatrix}:
@example
! @group
[ [ a / b, 0 ], [ 0, 2^(x + 1) ] ]
address@hidden @{a \over address@hidden & 0 \\ 0 & address@hidden(x + 1)@} @}
address@hidden @{a \over address@hidden & 0 \\ 0 & address@hidden(x + 1)@} @}
+ @end group
@end example
@tex
\turnoffactive
***************
*** 14413,14419 ****
$$ \pmatrix{ {a \over b} & 0 \cr 0 & 2^{(x + 1)} } $$
@end tex
@sp 2
- @end group
@end iftex
@node Eqn Language Mode, Mathematica Language Mode, TeX Language Mode,
Language Modes
--- 14415,14420 ----
***************
*** 14602,14615 ****
decide how formulas should be positioned relative to one another.
For example, in the Big mode formula
- @group
@example
2
a + b
17 + ------
c
- @end example
@end group
@noindent
the second term of the sum is four lines tall and has line three as
--- 14603,14616 ----
decide how formulas should be positioned relative to one another.
For example, in the Big mode formula
@example
+ @group
2
a + b
17 + ------
c
@end group
+ @end example
@noindent
the second term of the sum is four lines tall and has line three as
***************
*** 14669,14675 ****
Right-associative operators like @samp{^} format the lefthand argument
with one-higher precedence.
! @c @starindex
@tindex cprec
The @code{cprec} function formats an expression with an arbitrary
precedence. For example, @samp{cprec(abc, 185)} will combine into
--- 14670,14678 ----
Right-associative operators like @samp{^} format the lefthand argument
with one-higher precedence.
! @ignore
! @starindex
! @end ignore
@tindex cprec
The @code{cprec} function formats an expression with an arbitrary
precedence. For example, @samp{cprec(abc, 185)} will combine into
***************
*** 14700,14711 ****
it can use an earlier break point from an ``outer'' formula instead.
For example, a vector of sums might be formatted as:
- @group
@example
[ a + b + c, d + e + f,
g + h + i, j + k + l, m ]
- @end example
@end group
@noindent
If the @samp{m} can fit, then so, it seems, could the @samp{g}.
--- 14703,14714 ----
it can use an earlier break point from an ``outer'' formula instead.
For example, a vector of sums might be formatted as:
@example
+ @group
[ a + b + c, d + e + f,
g + h + i, j + k + l, m ]
@end group
+ @end example
@noindent
If the @samp{m} can fit, then so, it seems, could the @samp{g}.
***************
*** 14733,14751 ****
@subsubsection Horizontal Compositions
@noindent
! @c @starindex
@tindex choriz
The @code{choriz} function takes a vector of objects and composes
them horizontally. For example, @samp{choriz([17, a b/c, d])} formats
as @address@hidden b / cd}} in normal language mode, or as
- @group
@example
a b
17---d
c
- @end example
@end group
@noindent
in Big language mode. This is actually one case of the general
--- 14736,14756 ----
@subsubsection Horizontal Compositions
@noindent
! @ignore
! @starindex
! @end ignore
@tindex choriz
The @code{choriz} function takes a vector of objects and composes
them horizontally. For example, @samp{choriz([17, a b/c, d])} formats
as @address@hidden b / cd}} in normal language mode, or as
@example
+ @group
a b
17---d
c
@end group
+ @end example
@noindent
in Big language mode. This is actually one case of the general
***************
*** 14775,14781 ****
@subsubsection Vertical Compositions
@noindent
! @c @starindex
@tindex cvert
The @code{cvert} function makes a vertical composition. Each
component of the vector is centered in a column. The baseline of
--- 14780,14788 ----
@subsubsection Vertical Compositions
@noindent
! @ignore
! @starindex
! @end ignore
@tindex cvert
The @code{cvert} function makes a vertical composition. Each
component of the vector is centered in a column. The baseline of
***************
*** 14783,14798 ****
For example, @samp{f(cvert([a, bb, ccc]), cvert([a^2 + 1, b^2]))}
formats in Big mode as
- @group
@example
f( a , 2 )
bb a + 1
ccc 2
b
- @end example
@end group
! @c @starindex
@tindex cbase
There are several special composition functions that work only as
components of a vertical composition. The @code{cbase} function
--- 14790,14807 ----
For example, @samp{f(cvert([a, bb, ccc]), cvert([a^2 + 1, b^2]))}
formats in Big mode as
@example
+ @group
f( a , 2 )
bb a + 1
ccc 2
b
@end group
+ @end example
! @ignore
! @starindex
! @end ignore
@tindex cbase
There are several special composition functions that work only as
components of a vertical composition. The @code{cbase} function
***************
*** 14801,14819 ****
in @code{cbase}. Thus @samp{f(cvert([a, cbase(bb), ccc]),
cvert([a^2 + 1, cbase(b^2)]))} displays as
- @group
@example
2
a + 1
a 2
f(bb , b )
ccc
- @end example
@end group
! @c @starindex
@tindex ctbase
! @c @starindex
@tindex cbbase
There are also @code{ctbase} and @code{cbbase} functions which
make the baseline of the vertical composition equal to the top
--- 14810,14832 ----
in @code{cbase}. Thus @samp{f(cvert([a, cbase(bb), ccc]),
cvert([a^2 + 1, cbase(b^2)]))} displays as
@example
+ @group
2
a + 1
a 2
f(bb , b )
ccc
@end group
+ @end example
! @ignore
! @starindex
! @end ignore
@tindex ctbase
! @ignore
! @starindex
! @end ignore
@tindex cbbase
There are also @code{ctbase} and @code{cbbase} functions which
make the baseline of the vertical composition equal to the top
***************
*** 14821,14835 ****
Thus @samp{cvert([cbase(a / b)]) + cvert([ctbase(a / b)]) +
cvert([cbbase(a / b)])} gives
- @group
@example
a
a -
- + a + b
b -
b
- @end example
@end group
There should be only one @code{cbase}, @code{ctbase}, or @code{cbbase}
function in a given vertical composition. These functions can also
--- 14834,14848 ----
Thus @samp{cvert([cbase(a / b)]) + cvert([ctbase(a / b)]) +
cvert([cbbase(a / b)])} gives
@example
+ @group
a
a -
- + a + b
b -
b
@end group
+ @end example
There should be only one @code{cbase}, @code{ctbase}, or @code{cbbase}
function in a given vertical composition. These functions can also
***************
*** 14838,14844 ****
@samp{cbbase()} means the baseline is the bottom line of the preceding
item.
! @c @starindex
@tindex crule
The @code{crule} function builds a ``rule,'' or horizontal line,
across a vertical composition. By itself @samp{crule()} uses @samp{-}
--- 14851,14859 ----
@samp{cbbase()} means the baseline is the bottom line of the preceding
item.
! @ignore
! @starindex
! @end ignore
@tindex crule
The @code{crule} function builds a ``rule,'' or horizontal line,
across a vertical composition. By itself @samp{crule()} uses @samp{-}
***************
*** 14848,14878 ****
width of the widest item in the stack. For example, a quotient
with a thick line is @samp{cvert([a + 1, cbase(crule("=")), b^2])}:
- @group
@example
a + 1
=====
2
b
- @end example
@end group
! @c @starindex
@tindex clvert
! @c @starindex
@tindex crvert
Finally, the functions @code{clvert} and @code{crvert} act exactly
like @code{cvert} except that the items are left- or right-justified
in the stack. Thus @samp{clvert([a, bb, ccc]) + crvert([a, bb, ccc])}
gives:
- @group
@example
a + a
bb bb
ccc ccc
- @end example
@end group
Like @code{choriz}, the vertical compositions accept a second argument
which gives the precedence to use when formatting the components.
--- 14863,14897 ----
width of the widest item in the stack. For example, a quotient
with a thick line is @samp{cvert([a + 1, cbase(crule("=")), b^2])}:
@example
+ @group
a + 1
=====
2
b
@end group
+ @end example
! @ignore
! @starindex
! @end ignore
@tindex clvert
! @ignore
! @starindex
! @end ignore
@tindex crvert
Finally, the functions @code{clvert} and @code{crvert} act exactly
like @code{cvert} except that the items are left- or right-justified
in the stack. Thus @samp{clvert([a, bb, ccc]) + crvert([a, bb, ccc])}
gives:
@example
+ @group
a + a
bb bb
ccc ccc
@end group
+ @end example
Like @code{choriz}, the vertical compositions accept a second argument
which gives the precedence to use when formatting the components.
***************
*** 14882,14888 ****
@subsubsection Other Compositions
@noindent
! @c @starindex
@tindex csup
The @code{csup} function builds a superscripted expression. For
example, @samp{csup(a, b)} looks the same as @samp{a^b} does in Big
--- 14901,14909 ----
@subsubsection Other Compositions
@noindent
! @ignore
! @starindex
! @end ignore
@tindex csup
The @code{csup} function builds a superscripted expression. For
example, @samp{csup(a, b)} looks the same as @samp{a^b} does in Big
***************
*** 14890,14896 ****
@samp{a} and @samp{b}, where @samp{b} is shifted up so that its
bottom line is one above the baseline.
! @c @starindex
@tindex csub
Likewise, the @code{csub} function builds a subscripted expression.
This shifts @samp{b} down so that its top line is one below the
--- 14911,14919 ----
@samp{a} and @samp{b}, where @samp{b} is shifted up so that its
bottom line is one above the baseline.
! @ignore
! @starindex
! @end ignore
@tindex csub
Likewise, the @code{csub} function builds a subscripted expression.
This shifts @samp{b} down so that its top line is one below the
***************
*** 14898,14904 ****
@code{csup}). Other arrangements can be obtained by using
@code{choriz} and @code{cvert} directly.
! @c @starindex
@tindex cflat
The @code{cflat} function formats its argument in ``flat'' mode,
as obtained by @samp{d O}, if the current language mode is normal
--- 14921,14929 ----
@code{csup}). Other arrangements can be obtained by using
@code{choriz} and @code{cvert} directly.
! @ignore
! @starindex
! @end ignore
@tindex cflat
The @code{cflat} function formats its argument in ``flat'' mode,
as obtained by @samp{d O}, if the current language mode is normal
***************
*** 14906,14912 ****
@samp{a^(b/c)} is formatted by Big mode like @samp{csup(a, cflat(b/c))}
to improve its readability.
! @c @starindex
@tindex cspace
The @code{cspace} function creates horizontal space. For example,
@samp{cspace(4)} is effectively the same as @samp{string(" ")}.
--- 14931,14939 ----
@samp{a^(b/c)} is formatted by Big mode like @samp{csup(a, cflat(b/c))}
to improve its readability.
! @ignore
! @starindex
! @end ignore
@tindex cspace
The @code{cspace} function creates horizontal space. For example,
@samp{cspace(4)} is effectively the same as @samp{string(" ")}.
***************
*** 14916,14932 ****
it is formatted in the normal way and then several copies of that
are composed together: @samp{cspace(4, a^2)} yields
- @group
@example
2 2 2 2
a a a a
- @end example
@end group
@noindent
If the number argument is zero, this is a zero-width object.
! @c @starindex
@tindex cvspace
The @code{cvspace} function creates vertical space, or a vertical
stack of copies of a certain string or formatted object. The
--- 14943,14961 ----
it is formatted in the normal way and then several copies of that
are composed together: @samp{cspace(4, a^2)} yields
@example
+ @group
2 2 2 2
a a a a
@end group
+ @end example
@noindent
If the number argument is zero, this is a zero-width object.
! @ignore
! @starindex
! @end ignore
@tindex cvspace
The @code{cvspace} function creates vertical space, or a vertical
stack of copies of a certain string or formatted object. The
***************
*** 14934,14942 ****
argument of zero will produce an object which contributes zero
height if used in a vertical composition.
! @c @starindex
@tindex ctspace
! @c @starindex
@tindex cbspace
There are also @code{ctspace} and @code{cbspace} functions which
create vertical space with the baseline the same as the baseline
--- 14963,14975 ----
argument of zero will produce an object which contributes zero
height if used in a vertical composition.
! @ignore
! @starindex
! @end ignore
@tindex ctspace
! @ignore
! @starindex
! @end ignore
@tindex cbspace
There are also @code{ctspace} and @code{cbspace} functions which
create vertical space with the baseline the same as the baseline
***************
*** 14944,14951 ****
Thus @samp{cvspace(2, a/b) + ctspace(2, a/b) + cbspace(2, a/b)}
displays as:
- @group
@example
a
-
a b
--- 14977,14984 ----
Thus @samp{cvspace(2, a/b) + ctspace(2, a/b) + cbspace(2, a/b)}
displays as:
@example
+ @group
a
-
a b
***************
*** 14955,14962 ****
- a
b -
b
- @end example
@end group
@node Information about Compositions, User-Defined Compositions, Other
Compositions, Compositions
@subsubsection Information about Compositions
--- 14988,14995 ----
- a
b -
b
@end group
+ @end example
@node Information about Compositions, User-Defined Compositions, Other
Compositions, Compositions
@subsubsection Information about Compositions
***************
*** 14966,14972 ****
arguments according to the current language and other display modes,
then return a certain measurement of the composition as an integer.
! @c @starindex
@tindex cwidth
The @code{cwidth} function measures the width, in characters, of a
composition. For example, @samp{cwidth(a + b)} is 5, and
--- 14999,15007 ----
arguments according to the current language and other display modes,
then return a certain measurement of the composition as an integer.
! @ignore
! @starindex
! @end ignore
@tindex cwidth
The @code{cwidth} function measures the width, in characters, of a
composition. For example, @samp{cwidth(a + b)} is 5, and
***************
*** 14974,14987 ****
@TeX{} mode (for @address@hidden \over address@hidden). The argument may
involve
the composition functions described in this section.
! @c @starindex
@tindex cheight
The @code{cheight} function measures the height of a composition.
This is the total number of lines in the argument's printed form.
! @c @starindex
@tindex cascent
! @c @starindex
@tindex cdescent
The functions @code{cascent} and @code{cdescent} measure the amount
of the height that is above (and including) the baseline, or below
--- 15009,15028 ----
@TeX{} mode (for @address@hidden \over address@hidden). The argument may
involve
the composition functions described in this section.
! @ignore
! @starindex
! @end ignore
@tindex cheight
The @code{cheight} function measures the height of a composition.
This is the total number of lines in the argument's printed form.
! @ignore
! @starindex
! @end ignore
@tindex cascent
! @ignore
! @starindex
! @end ignore
@tindex cdescent
The functions @code{cascent} and @code{cdescent} measure the amount
of the height that is above (and including) the baseline, or below
***************
*** 15031,15053 ****
For example, the default format for the binomial coefficient function
@samp{choose(n, m)} in the Big language mode is
- @group
@example
n
( )
m
- @end example
@end group
@noindent
You might prefer the notation,
- @group
@example
C
n m
- @end example
@end group
@noindent
To define this notation, first make sure you are in Big mode,
--- 15072,15094 ----
For example, the default format for the binomial coefficient function
@samp{choose(n, m)} in the Big language mode is
@example
+ @group
n
( )
m
@end group
+ @end example
@noindent
You might prefer the notation,
@example
+ @group
C
n m
@end group
+ @end example
@noindent
To define this notation, first make sure you are in Big mode,
***************
*** 15065,15076 ****
off with @kbd{m O} and enter @samp{choose(a,b) + choose(7,3)}
as an algebraic entry.
- @group
@example
C + C
a b 7 3
- @end example
@end group
As another example, let's define the usual notation for Stirling
numbers of the first kind, @samp{stir1(n, m)}. This is just like
--- 15106,15117 ----
off with @kbd{m O} and enter @samp{choose(a,b) + choose(7,3)}
as an algebraic entry.
@example
+ @group
C + C
a b 7 3
@end group
+ @end example
As another example, let's define the usual notation for Stirling
numbers of the first kind, @samp{stir1(n, m)}. This is just like
***************
*** 15386,15395 ****
@end example
@noindent
! will parse @samp{foo(1,2,3,4)} as @samp{bar([1,2,3,4])}, and
! @samp{foo(1,2;3,4)} as @samp{matrix([[1,2],[3,4]])}. Also, after
some thought it's easy to see how this pair of rules will parse
! @samp{foo(1,2,3)} as @samp{matrix([[1,2,3]])}, since the first
rule will only match an even number of arguments. The rule
@example
--- 15427,15436 ----
@end example
@noindent
! will parse @samp{foo(1, 2, 3, 4)} as @samp{bar([1, 2, 3, 4])}, and
! @samp{foo(1, 2; 3, 4)} as @samp{matrix([[1, 2], [3, 4]])}. Also, after
some thought it's easy to see how this pair of rules will parse
! @samp{foo(1, 2, 3)} as @samp{matrix([[1, 2, 3]])}, since the first
rule will only match an even number of arguments. The rule
@example
***************
*** 15417,15423 ****
Another variant is @address@hidden ... @}?$}, which means the body is
optional only at the end of the input formula. All built-in syntax
rules in Calc use this for closing delimiters, so that during
! algebraic entry you can type @kbd{[sqrt(2), sqrt(3 RET}, omitting
the closing parenthesis and bracket. Calc does this automatically
for trailing @samp{)}, @samp{]}, and @samp{>} tokens in syntax
rules, but you can use @address@hidden ... @}?$} explicitly to get
--- 15458,15464 ----
Another variant is @address@hidden ... @}?$}, which means the body is
optional only at the end of the input formula. All built-in syntax
rules in Calc use this for closing delimiters, so that during
! algebraic entry you can type @kbd{[sqrt(2), sqrt(3 @key{RET}}, omitting
the closing parenthesis and bracket. Calc does this automatically
for trailing @samp{)}, @samp{]}, and @samp{>} tokens in syntax
rules, but you can use @address@hidden ... @}?$} explicitly to get
***************
*** 15546,15552 ****
@cindex @code{Modes} variable
@vindex Modes
The modes vector is also available in the special variable
! @code{Modes}. In other words, @kbd{m g} is like @kbd{s r Modes RET}.
It will not work to store into this variable; in fact, if you do,
@code{Modes} will cease to track the current modes. (The @kbd{m g}
command will continue to work, however.)
--- 15587,15593 ----
@cindex @code{Modes} variable
@vindex Modes
The modes vector is also available in the special variable
! @code{Modes}. In other words, @kbd{m g} is like @kbd{s r Modes @key{RET}}.
It will not work to store into this variable; in fact, if you do,
@code{Modes} will cease to track the current modes. (The @kbd{m g}
command will continue to work, however.)
***************
*** 15600,15607 ****
@item
Matrix/scalar mode. Default value is @i{-1}. Value is 0 for scalar
! mode, @i{-2} for matrix mode, or @i{N} for @c{$N\times N$}
! @i{NxN} matrix mode. Command is @kbd{m v}.
@item
Simplification mode. Default is 1. Value is @i{-1} for off (@kbd{m O}),
--- 15641,15648 ----
@item
Matrix/scalar mode. Default value is @i{-1}. Value is 0 for scalar
! mode, @i{-2} for matrix mode, or @var{N} for @c{$N\times N$}
! @address@hidden matrix mode. Command is @kbd{m v}.
@item
Simplification mode. Default is 1. Value is @i{-1} for off (@kbd{m O}),
***************
*** 15613,15625 ****
or 0 if the mode is on with positive zeros. Command is @kbd{m i}.
@end enumerate
! For example, the sequence @kbd{M-1 m g RET 2 + ~ p} increases the
precision by two, leaving a copy of the old precision on the stack.
Later, @kbd{~ p} will restore the original precision using that
stack value. (This sequence might be especially useful inside a
keyboard macro.)
! As another example, @kbd{M-3 m g 1 - ~ DEL} deletes all but the
oldest (bottommost) stack entry.
Yet another example: The HP-48 ``round'' command rounds a number
--- 15654,15666 ----
or 0 if the mode is on with positive zeros. Command is @kbd{m i}.
@end enumerate
! For example, the sequence @kbd{M-1 m g @key{RET} 2 + ~ p} increases the
precision by two, leaving a copy of the old precision on the stack.
Later, @kbd{~ p} will restore the original precision using that
stack value. (This sequence might be especially useful inside a
keyboard macro.)
! As another example, @kbd{M-3 m g 1 - ~ @key{DEL}} deletes all but the
oldest (bottommost) stack entry.
Yet another example: The HP-48 ``round'' command rounds a number
***************
*** 15878,15884 ****
@noindent
@kindex +
@pindex calc-plus
! @c @mindex @null
@tindex +
The @kbd{+} (@code{calc-plus}) command adds two numbers. The numbers may
be any of the standard Calc data types. The resulting sum is pushed back
--- 15919,15927 ----
@noindent
@kindex +
@pindex calc-plus
! @ignore
! @mindex @null
! @end ignore
@tindex +
The @kbd{+} (@code{calc-plus}) command adds two numbers. The numbers may
be any of the standard Calc data types. The resulting sum is pushed back
***************
*** 15942,15948 ****
@kindex -
@pindex calc-minus
! @c @mindex @null
@tindex -
The @kbd{-} (@code{calc-minus}) command subtracts two values. The top
number on the stack is subtracted from the one behind it, so that the
--- 15985,15993 ----
@kindex -
@pindex calc-minus
! @ignore
! @mindex @null
! @end ignore
@tindex -
The @kbd{-} (@code{calc-minus}) command subtracts two values. The top
number on the stack is subtracted from the one behind it, so that the
***************
*** 15951,15957 ****
@kindex *
@pindex calc-times
! @c @mindex @null
@tindex *
The @kbd{*} (@code{calc-times}) command multiplies two numbers. If one
argument is a vector and the other a scalar, the scalar is multiplied by
--- 15996,16004 ----
@kindex *
@pindex calc-times
! @ignore
! @mindex @null
! @end ignore
@tindex *
The @kbd{*} (@code{calc-times}) command multiplies two numbers. If one
argument is a vector and the other a scalar, the scalar is multiplied by
***************
*** 15974,15980 ****
@kindex /
@pindex calc-divide
! @c @mindex @null
@tindex /
The @kbd{/} (@code{calc-divide}) command divides two numbers. When
dividing a scalar @cite{B} by a square matrix @cite{A}, the computation
--- 16021,16029 ----
@kindex /
@pindex calc-divide
! @ignore
! @mindex @null
! @end ignore
@tindex /
The @kbd{/} (@code{calc-divide}) command divides two numbers. When
dividing a scalar @cite{B} by a square matrix @cite{A}, the computation
***************
*** 16000,16006 ****
@kindex ^
@pindex calc-power
! @c @mindex @null
@tindex ^
The @kbd{^} (@code{calc-power}) command raises a number to a power. If
the power is an integer, an exact result is computed using repeated
--- 16049,16057 ----
@kindex ^
@pindex calc-power
! @ignore
! @mindex @null
! @end ignore
@tindex ^
The @kbd{^} (@code{calc-power}) command raises a number to a power. If
the power is an integer, an exact result is computed using repeated
***************
*** 16012,16024 ****
@kindex I ^
@tindex nroot
If you press the @kbd{I} (inverse) key first, the @kbd{I ^} command
! computes an Nth root: @kbd{125 RET 3 I ^} computes the number 5.
! (This is entirely equivalent to @kbd{125 RET 1:3 ^}.)
@kindex \
@pindex calc-idiv
@tindex idiv
! @c @mindex @null
@tindex \
The @kbd{\} (@code{calc-idiv}) command divides two numbers on the stack
to produce an integer result. It is equivalent to dividing with
--- 16063,16077 ----
@kindex I ^
@tindex nroot
If you press the @kbd{I} (inverse) key first, the @kbd{I ^} command
! computes an Nth root: @kbd{125 @key{RET} 3 I ^} computes the number 5.
! (This is entirely equivalent to @kbd{125 @key{RET} 1:3 ^}.)
@kindex \
@pindex calc-idiv
@tindex idiv
! @ignore
! @mindex @null
! @end ignore
@tindex \
The @kbd{\} (@code{calc-idiv}) command divides two numbers on the stack
to produce an integer result. It is equivalent to dividing with
***************
*** 16029,16035 ****
@kindex %
@pindex calc-mod
! @c @mindex @null
@tindex %
The @kbd{%} (@code{calc-mod}) command performs a ``modulo'' (or ``remainder'')
operation. Mathematically, @samp{a%b = a - (a\b)*b}, and is defined
--- 16082,16090 ----
@kindex %
@pindex calc-mod
! @ignore
! @mindex @null
! @end ignore
@tindex %
The @kbd{%} (@code{calc-mod}) command performs a ``modulo'' (or ``remainder'')
operation. Mathematically, @samp{a%b = a - (a\b)*b}, and is defined
***************
*** 16207,16213 ****
@pindex calc-floor
@tindex floor
@tindex ffloor
! @c @mindex @null
@kindex H F
The @kbd{F} (@code{calc-floor}) address@hidden or @code{ffloor}] command
truncates a real number to the next lower integer, i.e., toward minus
--- 16262,16270 ----
@pindex calc-floor
@tindex floor
@tindex ffloor
! @ignore
! @mindex @null
! @end ignore
@kindex H F
The @kbd{F} (@code{calc-floor}) address@hidden or @code{ffloor}] command
truncates a real number to the next lower integer, i.e., toward minus
***************
*** 16218,16224 ****
@pindex calc-ceiling
@tindex ceil
@tindex fceil
! @c @mindex @null
@kindex H I F
The @kbd{I F} (@code{calc-ceiling}) address@hidden or @code{fceil}]
command truncates toward positive infinity. Thus @kbd{3.6 I F} produces
--- 16275,16283 ----
@pindex calc-ceiling
@tindex ceil
@tindex fceil
! @ignore
! @mindex @null
! @end ignore
@kindex H I F
The @kbd{I F} (@code{calc-ceiling}) address@hidden or @code{fceil}]
command truncates toward positive infinity. Thus @kbd{3.6 I F} produces
***************
*** 16228,16234 ****
@pindex calc-round
@tindex round
@tindex fround
! @c @mindex @null
@kindex H R
The @kbd{R} (@code{calc-round}) address@hidden or @code{fround}] command
rounds to the nearest integer. When the fractional part is .5 exactly,
--- 16287,16295 ----
@pindex calc-round
@tindex round
@tindex fround
! @ignore
! @mindex @null
! @end ignore
@kindex H R
The @kbd{R} (@code{calc-round}) address@hidden or @code{fround}] command
rounds to the nearest integer. When the fractional part is .5 exactly,
***************
*** 16240,16246 ****
@pindex calc-trunc
@tindex trunc
@tindex ftrunc
! @c @mindex @null
@kindex H I R
The @kbd{I R} (@code{calc-trunc}) address@hidden or @code{ftrunc}]
command truncates toward zero. In other words, it ``chops off''
--- 16301,16309 ----
@pindex calc-trunc
@tindex trunc
@tindex ftrunc
! @ignore
! @mindex @null
! @end ignore
@kindex H I R
The @kbd{I R} (@code{calc-trunc}) address@hidden or @code{ftrunc}]
command truncates toward zero. In other words, it ``chops off''
***************
*** 16254,16266 ****
Applied to a date form, they operate on the internal numerical
representation of dates, converting a date/time form into a pure date.
! @c @starindex
@tindex rounde
! @c @starindex
@tindex roundu
! @c @starindex
@tindex frounde
! @c @starindex
@tindex froundu
There are two more rounding functions which can only be entered in
algebraic notation. The @code{roundu} function is like @code{round}
--- 16317,16337 ----
Applied to a date form, they operate on the internal numerical
representation of dates, converting a date/time form into a pure date.
! @ignore
! @starindex
! @end ignore
@tindex rounde
! @ignore
! @starindex
! @end ignore
@tindex roundu
! @ignore
! @starindex
! @end ignore
@tindex frounde
! @ignore
! @starindex
! @end ignore
@tindex froundu
There are two more rounding functions which can only be entered in
algebraic notation. The @code{roundu} function is like @code{round}
***************
*** 16288,16294 ****
@cindex Fractional part of a number
To compute the fractional part of a number (i.e., the amount which, when
! added to address@hidden(address@hidden@t{)}', will produce @cite{N}) just
take @cite{N}
modulo 1 using the @code{%} address@hidden
Note also the @kbd{\} (integer quotient), @kbd{f I} (integer logarithm),
--- 16359,16365 ----
@cindex Fractional part of a number
To compute the fractional part of a number (i.e., the amount which, when
! added to address@hidden(address@hidden@t{)}', will produce @var{n}) just take
@var{n}
modulo 1 using the @code{%} address@hidden
Note also the @kbd{\} (integer quotient), @kbd{f I} (integer logarithm),
***************
*** 16315,16322 ****
The @kbd{G} (@code{calc-argument}) address@hidden command computes the
``argument'' or polar angle of a complex number. For a number in polar
notation, this is simply the second component of the pair
! address@hidden(address@hidden@t{;address@hidden
! @address@hidden)}'.
The result is expressed according to the current angular mode and will
be in the range @i{-180} degrees (exclusive) to @i{+180} degrees
(inclusive), or the equivalent range in address@hidden
--- 16386,16393 ----
The @kbd{G} (@code{calc-argument}) address@hidden command computes the
``argument'' or polar angle of a complex number. For a number in polar
notation, this is simply the second component of the pair
! address@hidden(address@hidden@t{;address@hidden
! @address@hidden)}'.
The result is expressed according to the current angular mode and will
be in the range @i{-180} degrees (exclusive) to @i{+180} degrees
(inclusive), or the equivalent range in address@hidden
***************
*** 16342,16348 ****
by its imaginary part; real numbers are converted to zero. With a vector
or matrix argument, these functions operate address@hidden
! @c @mindex v p
@kindex v p (complex)
@pindex calc-pack
The @kbd{v p} (@code{calc-pack}) command can pack the top two numbers on
--- 16413,16421 ----
by its imaginary part; real numbers are converted to zero. With a vector
or matrix argument, these functions operate address@hidden
! @ignore
! @mindex v p
! @end ignore
@kindex v p (complex)
@pindex calc-pack
The @kbd{v p} (@code{calc-pack}) command can pack the top two numbers on
***************
*** 16351,16357 ****
with an argument of @i{-2}, it produces a polar complex number.
(Also, @pxref{Building Vectors}.)
! @c @mindex v u
@kindex v u (complex)
@pindex calc-unpack
The @kbd{v u} (@code{calc-unpack}) command takes the complex number
--- 16424,16432 ----
with an argument of @i{-2}, it produces a polar complex number.
(Also, @pxref{Building Vectors}.)
! @ignore
! @mindex v u
! @end ignore
@kindex v u (complex)
@pindex calc-unpack
The @kbd{v u} (@code{calc-unpack}) command takes the complex number
***************
*** 16617,16623 ****
converts a date form into a Unix time value, which is the number of
seconds since midnight on Jan 1, 1970, or vice-versa. The numeric result
will be an integer if the current precision is 12 or less; for higher
! precisions, the result may be a float with (@address@hidden)
digits after the decimal. Just as for @kbd{t J}, the numeric time
is interpreted in the GMT time zone and the date form is interpreted
in the current or specified zone. Some systems use Unix-like
--- 16692,16698 ----
converts a date form into a Unix time value, which is the number of
seconds since midnight on Jan 1, 1970, or vice-versa. The numeric result
will be an integer if the current precision is 12 or less; for higher
! precisions, the result may be a float with (@address@hidden)
digits after the decimal. Just as for @kbd{t J}, the numeric time
is interpreted in the GMT time zone and the date form is interpreted
in the current or specified zone. Some systems use Unix-like
***************
*** 16751,16757 ****
the time to midnight; hint:@: how can @code{newweek} be defined in terms
of the @code{weekday} function?).
! @c @starindex
@tindex pwday
The @samp{pwday(@var{date})} function (not on any key) computes the
day-of-month number of the Sunday on or before @var{date}. With
--- 16826,16834 ----
the time to midnight; hint:@: how can @code{newweek} be defined in terms
of the @code{weekday} function?).
! @ignore
! @starindex
! @end ignore
@tindex pwday
The @samp{pwday(@var{date})} function (not on any key) computes the
day-of-month number of the Sunday on or before @var{date}. With
***************
*** 16779,16785 ****
the same results (@samp{<Mar 28, 1991>} versus @samp{<Mar 31, 1991>}
in this case).
! @c @starindex
@tindex incyear
The @samp{incyear(@var{date}, @var{step})} function increases
a date form by the specified number of years, which may be
--- 16856,16864 ----
the same results (@samp{<Mar 28, 1991>} versus @samp{<Mar 31, 1991>}
in this case).
! @ignore
! @starindex
! @end ignore
@tindex incyear
The @samp{incyear(@var{date}, @var{step})} function increases
a date form by the specified number of years, which may be
***************
*** 16931,16937 ****
might come out a bit differently, since @kbd{t +} is incapable of
producing a date that falls on a weekend or holiday.)
! @c @starindex
@tindex holiday
There is a @code{holiday} function, not on any keys, that takes
any date form and returns 1 if that date falls on a weekend or
--- 17010,17018 ----
might come out a bit differently, since @kbd{t +} is incapable of
producing a date that falls on a weekend or holiday.)
! @ignore
! @starindex
! @end ignore
@tindex holiday
There is a @code{holiday} function, not on any keys, that takes
any date form and returns 1 if that date falls on a weekend or
***************
*** 16970,16976 ****
days between two dates without taking daylight savings into account.
@pindex calc-time-zone
! @c @starindex
@tindex tzone
The @code{calc-time-zone} address@hidden command converts the time
zone specified by its numeric prefix argument into a number of
--- 17051,17059 ----
days between two dates without taking daylight savings into account.
@pindex calc-time-zone
! @ignore
! @starindex
! @end ignore
@tindex tzone
The @code{calc-time-zone} address@hidden command converts the time
zone specified by its numeric prefix argument into a number of
***************
*** 16995,17002 ****
another for daylight savings time, and a third for ``generalized'' time
in which the daylight savings adjustment is computed from context.
- @group
@smallexample
YST PST MST CST EST AST NST GMT WET MET MEZ
9 8 7 6 5 4 3.5 0 -1 -2 -2
--- 17078,17085 ----
another for daylight savings time, and a third for ``generalized'' time
in which the daylight savings adjustment is computed from context.
@smallexample
+ @group
YST PST MST CST EST AST NST GMT WET MET MEZ
9 8 7 6 5 4 3.5 0 -1 -2 -2
***************
*** 17005,17012 ****
YGT PGT MGT CGT EGT AGT NGT BGT WEGT MEGT MEGZ
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
@end group
@vindex math-tzone-names
To define time zone names that do not appear in the above table,
--- 17088,17095 ----
YGT PGT MGT CGT EGT AGT NGT BGT WEGT MEGT MEGZ
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 group
+ @end smallexample
@vindex math-tzone-names
To define time zone names that do not appear in the above table,
***************
*** 17015,17027 ****
structure is best explained by an example. The three entries for
Pacific Time look like this:
- @group
@smallexample
( ( "PST" 8 0 ) ; Name as an upper-case string, then standard
( "PDT" 8 -1 ) ; adjustment, then daylight savings adjustment.
( "PGT" 8 "PST" "PDT" ) ) ; Generalized time zone.
- @end smallexample
@end group
@cindex @code{TimeZone} variable
@vindex TimeZone
--- 17098,17110 ----
structure is best explained by an example. The three entries for
Pacific Time look like this:
@smallexample
+ @group
( ( "PST" 8 0 ) ; Name as an upper-case string, then standard
( "PDT" 8 -1 ) ; adjustment, then daylight savings adjustment.
( "PGT" 8 "PST" "PDT" ) ) ; Generalized time zone.
@end group
+ @end smallexample
@cindex @code{TimeZone} variable
@vindex TimeZone
***************
*** 17163,17169 ****
local time, not in the GMT time that a numeric @var{date}
is typically represented in.
! @c @starindex
@tindex dsadj
The @samp{dsadj(@var{date}, @var{zone})} function computes the
daylight savings adjustment that is appropriate for @var{date} in
--- 17246,17254 ----
local time, not in the GMT time that a numeric @var{date}
is typically represented in.
! @ignore
! @starindex
! @end ignore
@tindex dsadj
The @samp{dsadj(@var{date}, @var{zone})} function computes the
daylight savings adjustment that is appropriate for @var{date} in
***************
*** 17239,17245 ****
represents a rate of 540 percent!
The key sequence @kbd{M-% *} effectively means ``percent-of.''
! For example, @kbd{68 RET 25 M-% *} computes 17, which is 25% of
68 (and also 68% of 25, which comes out to the same thing).
@kindex c %
--- 17324,17330 ----
represents a rate of 540 percent!
The key sequence @kbd{M-% *} effectively means ``percent-of.''
! For example, @kbd{68 @key{RET} 25 M-% *} computes 17, which is 25% of
68 (and also 68% of 25, which comes out to the same thing).
@kindex c %
***************
*** 17253,17259 ****
to convert a formula like @samp{8%} back to numeric form, 0.08.
To compute what percentage one quantity is of another quantity,
! use @kbd{/ c %}. For example, @address@hidden RET 68 / c %}} displays
@samp{25%}.
@kindex b %
--- 17338,17344 ----
to convert a formula like @samp{8%} back to numeric form, 0.08.
To compute what percentage one quantity is of another quantity,
! use @kbd{/ c %}. For example, @address@hidden @key{RET} 68 / c %}} displays
@samp{25%}.
@kindex b %
***************
*** 17261,17273 ****
@tindex relch
The @kbd{b %} (@code{calc-percent-change}) address@hidden command
calculates the percentage change from one number to another.
! For example, @kbd{40 RET 50 b %} produces the answer @samp{25%},
since 50 is 25% larger than 40. A negative result represents a
! decrease: @kbd{50 RET 40 b %} produces @samp{-20%}, since 40 is
20% smaller than 50. (The answers are different in magnitude
because, in the first case, we're increasing by 25% of 40, but
in the second case, we're decreasing by 20% of 50.) The effect
! of @kbd{40 RET 50 b %} is to compute @cite{(50-40)/40}, converting
the answer to percentage form as if by @kbd{c %}.
@node Future Value, Present Value, Percentages, Financial Functions
--- 17346,17358 ----
@tindex relch
The @kbd{b %} (@code{calc-percent-change}) address@hidden command
calculates the percentage change from one number to another.
! For example, @kbd{40 @key{RET} 50 b %} produces the answer @samp{25%},
since 50 is 25% larger than 40. A negative result represents a
! decrease: @kbd{50 @key{RET} 40 b %} produces @samp{-20%}, since 40 is
20% smaller than 50. (The answers are different in magnitude
because, in the first case, we're increasing by 25% of 40, but
in the second case, we're decreasing by 20% of 50.) The effect
! of @kbd{40 @key{RET} 50 b %} is to compute @cite{(50-40)/40}, converting
the answer to percentage form as if by @kbd{c %}.
@node Future Value, Present Value, Percentages, Financial Functions
***************
*** 17297,17303 ****
in the account after five years? @code{fvb(5.4%, 5, 1000) = 5870.73}.
Thus you will have earned $870 worth of interest over the years.
Using the stack, this calculation would have been
! @kbd{5.4 M-% 5 RET 1000 I b F}. Note that the rate is expressed
as a number between 0 and 1, @emph{not} as a percentage.
@kindex H b F
--- 17382,17388 ----
in the account after five years? @code{fvb(5.4%, 5, 1000) = 5870.73}.
Thus you will have earned $870 worth of interest over the years.
Using the stack, this calculation would have been
! @kbd{5.4 M-% 5 @key{RET} 1000 I b F}. Note that the rate is expressed
as a number between 0 and 1, @emph{not} as a percentage.
@kindex H b F
***************
*** 17552,17569 ****
For example, pushing the vector @cite{[1,2,3,4,5]} (perhaps with @kbd{v x 5})
and then mapping @kbd{V M ' [sln(12000,2000,5,$), syd(12000,2000,5,$),
! ddb(12000,2000,5,$)] RET} produces a matrix that allows us to compare
the three depreciation methods:
- @group
@example
[ [ 2000, 3333, 4800 ]
[ 2000, 2667, 2880 ]
[ 2000, 2000, 1728 ]
[ 2000, 1333, 592 ]
[ 2000, 667, 0 ] ]
- @end example
@end group
@noindent
(Values have been rounded to nearest integers in this figure.)
--- 17637,17654 ----
For example, pushing the vector @cite{[1,2,3,4,5]} (perhaps with @kbd{v x 5})
and then mapping @kbd{V M ' [sln(12000,2000,5,$), syd(12000,2000,5,$),
! ddb(12000,2000,5,$)] @key{RET}} produces a matrix that allows us to compare
the three depreciation methods:
@example
+ @group
[ [ 2000, 3333, 4800 ]
[ 2000, 2667, 2880 ]
[ 2000, 2000, 1728 ]
[ 2000, 1333, 592 ]
[ 2000, 667, 0 ] ]
@end group
+ @end example
@noindent
(Values have been rounded to nearest integers in this figure.)
***************
*** 17850,17860 ****
@kindex H b l
@kindex H b r
! @c @mindex @idots
@kindex H b L
! @c @mindex @null
@kindex H b R
! @c @mindex @null
@kindex H b t
The @kbd{H b l} command also does a left shift, but it takes two arguments
from the stack (the value to shift, and, at top-of-stack, the number of
--- 17935,17951 ----
@kindex H b l
@kindex H b r
! @ignore
! @mindex @idots
! @end ignore
@kindex H b L
! @ignore
! @mindex @null
! @end ignore
@kindex H b R
! @ignore
! @mindex @null
! @end ignore
@kindex H b t
The @kbd{H b l} command also does a left shift, but it takes two arguments
from the stack (the value to shift, and, at top-of-stack, the number of
***************
*** 17906,17912 ****
Another interesting use of the set representation of binary integers
is to reverse the bits in, say, a 32-bit integer. Type @kbd{b u} to
! unpack; type @kbd{31 TAB -} to replace each bit-number in the set
with 31 minus that bit-number; type @kbd{b p} to pack the set back
into a binary integer.
--- 17997,18003 ----
Another interesting use of the set representation of binary integers
is to reverse the bits in, say, a 32-bit integer. Type @kbd{b u} to
! unpack; type @kbd{31 @key{TAB} -} to replace each bit-number in the set
with 31 minus that bit-number; type @kbd{b p} to pack the set back
into a binary integer.
***************
*** 17948,17955 ****
actual variables @samp{pi}, @samp{e}, @samp{gamma}, and @samp{phi},
respectively, instead of their values; @pxref{Symbolic address@hidden
! @c @mindex Q
! @c @mindex I Q
@kindex I Q
@tindex sqr
The @kbd{Q} (@code{calc-sqrt}) address@hidden function is described elsewhere;
--- 18039,18050 ----
actual variables @samp{pi}, @samp{e}, @samp{gamma}, and @samp{phi},
respectively, instead of their values; @pxref{Symbolic address@hidden
! @ignore
! @mindex Q
! @end ignore
! @ignore
! @mindex I Q
! @end ignore
@kindex I Q
@tindex sqr
The @kbd{Q} (@code{calc-sqrt}) address@hidden function is described elsewhere;
***************
*** 17977,17983 ****
@kindex L
@pindex calc-ln
@tindex ln
! @c @mindex @null
@kindex I E
The address@hidden (@code{calc-ln}) address@hidden command computes the
natural
logarithm of the real or complex number on the top of the stack. With
--- 18072,18080 ----
@kindex L
@pindex calc-ln
@tindex ln
! @ignore
! @mindex @null
! @end ignore
@kindex I E
The address@hidden (@code{calc-ln}) address@hidden command computes the
natural
logarithm of the real or complex number on the top of the stack. With
***************
*** 17987,17993 ****
@kindex E
@pindex calc-exp
@tindex exp
! @c @mindex @null
@kindex I L
The address@hidden (@code{calc-exp}) address@hidden command computes the
exponential, i.e., @cite{e} raised to the power of the number on the stack.
--- 18084,18092 ----
@kindex E
@pindex calc-exp
@tindex exp
! @ignore
! @mindex @null
! @end ignore
@kindex I L
The address@hidden (@code{calc-exp}) address@hidden command computes the
exponential, i.e., @cite{e} raised to the power of the number on the stack.
***************
*** 17999,18007 ****
@pindex calc-log10
@tindex log10
@tindex exp10
! @c @mindex @null
@kindex H I L
! @c @mindex @null
@kindex H I E
The @kbd{H L} (@code{calc-log10}) address@hidden command computes the common
(base-10) logarithm of a number. (With the Inverse flag address@hidden,
--- 18098,18110 ----
@pindex calc-log10
@tindex log10
@tindex exp10
! @ignore
! @mindex @null
! @end ignore
@kindex H I L
! @ignore
! @mindex @null
! @end ignore
@kindex H I E
The @kbd{H L} (@code{calc-log10}) address@hidden command computes the common
(base-10) logarithm of a number. (With the Inverse flag address@hidden,
***************
*** 18113,18152 ****
@kindex C
@pindex calc-cos
@tindex cos
! @c @mindex @idots
@kindex I C
@pindex calc-arccos
! @c @mindex @null
@tindex arccos
! @c @mindex @null
@kindex H C
@pindex calc-cosh
! @c @mindex @null
@tindex cosh
! @c @mindex @null
@kindex H I C
@pindex calc-arccosh
! @c @mindex @null
@tindex arccosh
! @c @mindex @null
@kindex T
@pindex calc-tan
! @c @mindex @null
@tindex tan
! @c @mindex @null
@kindex I T
@pindex calc-arctan
! @c @mindex @null
@tindex arctan
! @c @mindex @null
@kindex H T
@pindex calc-tanh
! @c @mindex @null
@tindex tanh
! @c @mindex @null
@kindex H I T
@pindex calc-arctanh
! @c @mindex @null
@tindex arctanh
The address@hidden (@code{calc-cos}) address@hidden command computes the
cosine
of an angle or complex number, and address@hidden (@code{calc-tan})
address@hidden
--- 18216,18283 ----
@kindex C
@pindex calc-cos
@tindex cos
! @ignore
! @mindex @idots
! @end ignore
@kindex I C
@pindex calc-arccos
! @ignore
! @mindex @null
! @end ignore
@tindex arccos
! @ignore
! @mindex @null
! @end ignore
@kindex H C
@pindex calc-cosh
! @ignore
! @mindex @null
! @end ignore
@tindex cosh
! @ignore
! @mindex @null
! @end ignore
@kindex H I C
@pindex calc-arccosh
! @ignore
! @mindex @null
! @end ignore
@tindex arccosh
! @ignore
! @mindex @null
! @end ignore
@kindex T
@pindex calc-tan
! @ignore
! @mindex @null
! @end ignore
@tindex tan
! @ignore
! @mindex @null
! @end ignore
@kindex I T
@pindex calc-arctan
! @ignore
! @mindex @null
! @end ignore
@tindex arctan
! @ignore
! @mindex @null
! @end ignore
@kindex H T
@pindex calc-tanh
! @ignore
! @mindex @null
! @end ignore
@tindex tanh
! @ignore
! @mindex @null
! @end ignore
@kindex H I T
@pindex calc-arctanh
! @ignore
! @mindex @null
! @end ignore
@tindex arctanh
The address@hidden (@code{calc-cos}) address@hidden command computes the
cosine
of an angle or complex number, and address@hidden (@code{calc-tan})
address@hidden
***************
*** 18168,18177 ****
@samp{arctan2(0,0)=0}.
@pindex calc-sincos
! @c @starindex
@tindex sincos
! @c @starindex
! @c @mindex address@hidden
@tindex arcsincos
The @code{calc-sincos} address@hidden command computes the sine and
cosine of a number, returning them as a vector of the form
--- 18299,18314 ----
@samp{arctan2(0,0)=0}.
@pindex calc-sincos
! @ignore
! @starindex
! @end ignore
@tindex sincos
! @ignore
! @starindex
! @end ignore
! @ignore
! @mindex address@hidden
! @end ignore
@tindex arcsincos
The @code{calc-sincos} address@hidden command computes the sine and
cosine of a number, returning them as a vector of the form
***************
*** 18209,18226 ****
@kindex f G
@tindex gammaP
! @c @mindex @idots
@kindex I f G
! @c @mindex @null
@kindex H f G
! @c @mindex @null
@kindex H I f G
@pindex calc-inc-gamma
! @c @mindex @null
@tindex gammaQ
! @c @mindex @null
@tindex gammag
! @c @mindex @null
@tindex gammaG
The @kbd{f G} (@code{calc-inc-gamma}) address@hidden command computes
the incomplete gamma function, denoted @samp{P(a,x)}. This is defined by
--- 18346,18375 ----
@kindex f G
@tindex gammaP
! @ignore
! @mindex @idots
! @end ignore
@kindex I f G
! @ignore
! @mindex @null
! @end ignore
@kindex H f G
! @ignore
! @mindex @null
! @end ignore
@kindex H I f G
@pindex calc-inc-gamma
! @ignore
! @mindex @null
! @end ignore
@tindex gammaQ
! @ignore
! @mindex @null
! @end ignore
@tindex gammag
! @ignore
! @mindex @null
! @end ignore
@tindex gammaG
The @kbd{f G} (@code{calc-inc-gamma}) address@hidden command computes
the incomplete gamma function, denoted @samp{P(a,x)}. This is defined by
***************
*** 18481,18491 ****
every other call to this function will be especially fast.
If @cite{M} is an error form @c{$m$ @code{+/-} $\sigma$}
! @samp{m +/- s} where @i{m}
and @c{$\sigma$}
! @i{s} are both real numbers, the result uses a Gaussian
! distribution with mean @i{m} and standard deviation @c{$\sigma$}
! @i{s}.
If @cite{M} is an interval form, the lower and upper bounds specify the
acceptable limits of the random numbers. If both bounds are integers,
--- 18630,18640 ----
every other call to this function will be especially fast.
If @cite{M} is an error form @c{$m$ @code{+/-} $\sigma$}
! @samp{m +/- s} where @var{m}
and @c{$\sigma$}
! @var{s} are both real numbers, the result uses a Gaussian
! distribution with mean @var{m} and standard deviation @c{$\sigma$}
! @var{s}.
If @cite{M} is an interval form, the lower and upper bounds specify the
acceptable limits of the random numbers. If both bounds are integers,
***************
*** 18695,18701 ****
@kindex !
@pindex calc-factorial
@tindex fact
! @c @mindex @null
@tindex !
The @kbd{!} (@code{calc-factorial}) address@hidden command computes the
factorial of the number at the top of the stack. If the number is an
--- 18844,18852 ----
@kindex !
@pindex calc-factorial
@tindex fact
! @ignore
! @mindex @null
! @end ignore
@tindex !
The @kbd{!} (@code{calc-factorial}) address@hidden command computes the
factorial of the number at the top of the stack. If the number is an
***************
*** 18710,18716 ****
@kindex k d
@pindex calc-double-factorial
@tindex dfact
! @c @mindex @null
@tindex !!
The @kbd{k d} (@code{calc-double-factorial}) address@hidden command
computes the ``double factorial'' of an integer. For an even integer,
--- 18861,18869 ----
@kindex k d
@pindex calc-double-factorial
@tindex dfact
! @ignore
! @mindex @null
! @end ignore
@tindex !!
The @kbd{k d} (@code{calc-double-factorial}) address@hidden command
computes the ``double factorial'' of an integer. For an even integer,
***************
*** 18796,18802 ****
the number will be reported as definitely prime or non-prime if possible,
or otherwise ``probably'' prime with a certain probability of error.
! @c @starindex
@tindex prime
The normal @kbd{k p} command performs one iteration of the primality
test. Pressing @kbd{k p} repeatedly for the same integer will perform
--- 18949,18957 ----
the number will be reported as definitely prime or non-prime if possible,
or otherwise ``probably'' prime with a certain probability of error.
! @ignore
! @starindex
! @end ignore
@tindex prime
The normal @kbd{k p} command performs one iteration of the primality
test. Pressing @kbd{k p} repeatedly for the same integer will perform
***************
*** 18820,18826 ****
@kindex k n
@pindex calc-next-prime
! @c @mindex address@hidden
@tindex nextprime
The @kbd{k n} (@code{calc-next-prime}) address@hidden command finds
the next prime above a given number. Essentially, it searches by calling
--- 18975,18983 ----
@kindex k n
@pindex calc-next-prime
! @ignore
! @mindex address@hidden
! @end ignore
@tindex nextprime
The @kbd{k n} (@code{calc-next-prime}) address@hidden command finds
the next prime above a given number. Essentially, it searches by calling
***************
*** 18836,18842 ****
@kindex I k n
@pindex calc-prev-prime
! @c @mindex address@hidden
@tindex prevprime
The @kbd{I k n} (@code{calc-prev-prime}) address@hidden command
analogously finds the next prime less than a given number.
--- 18993,19001 ----
@kindex I k n
@pindex calc-prev-prime
! @ignore
! @mindex address@hidden
! @end ignore
@tindex prevprime
The @kbd{I k n} (@code{calc-prev-prime}) address@hidden command
analogously finds the next prime less than a given number.
***************
*** 18907,18915 ****
@kindex k C
@pindex calc-utpc
@tindex utpc
! @c @mindex @idots
@kindex I k C
! @c @mindex @null
@tindex ltpc
The @samp{utpc(x,v)} function uses the chi-square distribution with
@c{$\nu$}
--- 19066,19078 ----
@kindex k C
@pindex calc-utpc
@tindex utpc
! @ignore
! @mindex @idots
! @end ignore
@kindex I k C
! @ignore
! @mindex @null
! @end ignore
@tindex ltpc
The @samp{utpc(x,v)} function uses the chi-square distribution with
@c{$\nu$}
***************
*** 18919,18927 ****
@kindex k F
@pindex calc-utpf
@tindex utpf
! @c @mindex @idots
@kindex I k F
! @c @mindex @null
@tindex ltpf
The @samp{utpf(F,v1,v2)} function uses the F distribution, used in
various statistical tests. The parameters @c{$\nu_1$}
--- 19082,19094 ----
@kindex k F
@pindex calc-utpf
@tindex utpf
! @ignore
! @mindex @idots
! @end ignore
@kindex I k F
! @ignore
! @mindex @null
! @end ignore
@tindex ltpf
The @samp{utpf(F,v1,v2)} function uses the F distribution, used in
various statistical tests. The parameters @c{$\nu_1$}
***************
*** 18933,18941 ****
@kindex k N
@pindex calc-utpn
@tindex utpn
! @c @mindex @idots
@kindex I k N
! @c @mindex @null
@tindex ltpn
The @samp{utpn(x,m,s)} function uses a normal (Gaussian) distribution
with mean @cite{m} and standard deviation @c{$\sigma$}
--- 19100,19112 ----
@kindex k N
@pindex calc-utpn
@tindex utpn
! @ignore
! @mindex @idots
! @end ignore
@kindex I k N
! @ignore
! @mindex @null
! @end ignore
@tindex ltpn
The @samp{utpn(x,m,s)} function uses a normal (Gaussian) distribution
with mean @cite{m} and standard deviation @c{$\sigma$}
***************
*** 18946,18954 ****
@kindex k P
@pindex calc-utpp
@tindex utpp
! @c @mindex @idots
@kindex I k P
! @c @mindex @null
@tindex ltpp
The @samp{utpp(n,x)} function uses a Poisson distribution with
mean @cite{x}. It is the probability that @cite{n} or more such
--- 19117,19129 ----
@kindex k P
@pindex calc-utpp
@tindex utpp
! @ignore
! @mindex @idots
! @end ignore
@kindex I k P
! @ignore
! @mindex @null
! @end ignore
@tindex ltpp
The @samp{utpp(n,x)} function uses a Poisson distribution with
mean @cite{x}. It is the probability that @cite{n} or more such
***************
*** 18957,18965 ****
@kindex k T
@pindex calc-ltpt
@tindex utpt
! @c @mindex @idots
@kindex I k T
! @c @mindex @null
@tindex ltpt
The @samp{utpt(t,v)} function uses the Student's ``t'' distribution
with @c{$\nu$}
--- 19132,19144 ----
@kindex k T
@pindex calc-ltpt
@tindex utpt
! @ignore
! @mindex @idots
! @end ignore
@kindex I k T
! @ignore
! @mindex @null
! @end ignore
@tindex ltpt
The @samp{utpt(t,v)} function uses the Student's ``t'' distribution
with @c{$\nu$}
***************
*** 19133,19139 ****
Also, @samp{[-4, -10]} will convert four integers into an
error form consisting of two fractions: @samp{a:b +/- c:d}.
! @c @starindex
@tindex pack
There is an equivalent algebraic function,
@samp{pack(@var{mode}, @var{items})} where @var{mode} is a
--- 19312,19320 ----
Also, @samp{[-4, -10]} will convert four integers into an
error form consisting of two fractions: @samp{a:b +/- c:d}.
! @ignore
! @starindex
! @end ignore
@tindex pack
There is an equivalent algebraic function,
@samp{pack(@var{mode}, @var{items})} where @var{mode} is a
***************
*** 19192,19198 ****
to unpack a matrix, say, or a vector of error forms. Higher
unpacking modes unpack the input even more deeply.
! @c @starindex
@tindex unpack
There are two algebraic functions analogous to @kbd{v u}.
The @samp{unpack(@var{mode}, @var{item})} function unpacks the
--- 19373,19381 ----
to unpack a matrix, say, or a vector of error forms. Higher
unpacking modes unpack the input even more deeply.
! @ignore
! @starindex
! @end ignore
@tindex unpack
There are two algebraic functions analogous to @kbd{v u}.
The @samp{unpack(@var{mode}, @var{item})} function unpacks the
***************
*** 19201,19207 ****
integer, not a vector. For example, @samp{unpack(-4, a +/- b)}
returns @samp{[a, b]}, as does @samp{unpack(1, a +/- b)}.
! @c @starindex
@tindex unpackt
The @code{unpackt} function is like @code{unpack} but instead
of returning a simple vector of items, it returns a vector of
--- 19384,19392 ----
integer, not a vector. For example, @samp{unpack(-4, a +/- b)}
returns @samp{[a, b]}, as does @samp{unpack(1, a +/- b)}.
! @ignore
! @starindex
! @end ignore
@tindex unpackt
The @code{unpackt} function is like @code{unpack} but instead
of returning a simple vector of items, it returns a vector of
***************
*** 19227,19233 ****
@kindex |
@pindex calc-concat
! @c @mindex @null
@tindex |
The @kbd{|} (@code{calc-concat}) command ``concatenates'' two vectors
into one. For example, after @address@hidden 1 , 2 ]} [ 3 , 4 ] |}, the stack
--- 19412,19420 ----
@kindex |
@pindex calc-concat
! @ignore
! @mindex @null
! @end ignore
@tindex |
The @kbd{|} (@code{calc-concat}) command ``concatenates'' two vectors
into one. For example, after @address@hidden 1 , 2 ]} [ 3 , 4 ] |}, the stack
***************
*** 19254,19260 ****
@kindex H I |
The @kbd{I |} and @kbd{H I |} commands are similar, but they use their
two stack arguments in the opposite order. Thus @kbd{I |} is equivalent
! to @kbd{TAB |}, but possibly more convenient and also a bit faster.
@kindex v d
@pindex calc-diag
--- 19441,19447 ----
@kindex H I |
The @kbd{I |} and @kbd{H I |} commands are similar, but they use their
two stack arguments in the opposite order. Thus @kbd{I |} is equivalent
! to @address@hidden |}, but possibly more convenient and also a bit faster.
@kindex v d
@pindex calc-diag
***************
*** 19349,19361 ****
@kindex H v h
@tindex rhead
! @c @mindex @idots
@kindex H I v h
! @c @mindex @null
@kindex H v k
! @c @mindex @null
@tindex rtail
! @c @mindex @null
@tindex rcons
Each of these three functions also accepts the Hyperbolic flag address@hidden,
@code{rtail}, @code{rcons}] in which case @var{t} instead represents
--- 19536,19556 ----
@kindex H v h
@tindex rhead
! @ignore
! @mindex @idots
! @end ignore
@kindex H I v h
! @ignore
! @mindex @null
! @end ignore
@kindex H v k
! @ignore
! @mindex @null
! @end ignore
@tindex rtail
! @ignore
! @mindex @null
! @end ignore
@tindex rcons
Each of these three functions also accepts the Hyperbolic flag address@hidden,
@code{rtail}, @code{rcons}] in which case @var{t} instead represents
***************
*** 19581,19587 ****
@cindex Histograms
@kindex V H
@pindex calc-histogram
! @c @mindex address@hidden
@tindex histogram
The @kbd{V H} (@code{calc-histogram}) address@hidden command builds a
histogram of a vector of numbers. Vector elements are assumed to be
--- 19776,19784 ----
@cindex Histograms
@kindex V H
@pindex calc-histogram
! @ignore
! @mindex address@hidden
! @end ignore
@tindex histogram
The @kbd{V H} (@code{calc-histogram}) address@hidden command builds a
histogram of a vector of numbers. Vector elements are assumed to be
***************
*** 19683,19692 ****
The @kbd{V J} (@code{calc-conj-transpose}) address@hidden command computes
the conjugate transpose of its argument, i.e., @samp{conj(trn(x))}.
! @c @mindex A
@kindex A (vectors)
@pindex calc-abs (vectors)
! @c @mindex abs
@tindex abs (vectors)
The @kbd{A} (@code{calc-abs}) address@hidden command computes the
Frobenius norm of a vector or matrix argument. This is the square
--- 19880,19893 ----
The @kbd{V J} (@code{calc-conj-transpose}) address@hidden command computes
the conjugate transpose of its argument, i.e., @samp{conj(trn(x))}.
! @ignore
! @mindex A
! @end ignore
@kindex A (vectors)
@pindex calc-abs (vectors)
! @ignore
! @mindex abs
! @end ignore
@tindex abs (vectors)
The @kbd{A} (@code{calc-abs}) address@hidden command computes the
Frobenius norm of a vector or matrix argument. This is the square
***************
*** 19722,19731 ****
right-handed cross product of two vectors, each of which must have
exactly three elements.
! @c @mindex &
@kindex & (matrices)
@pindex calc-inv (matrices)
! @c @mindex inv
@tindex inv (matrices)
The @kbd{&} (@code{calc-inv}) address@hidden command computes the
inverse of a square matrix. If the matrix is singular, the inverse
--- 19923,19936 ----
right-handed cross product of two vectors, each of which must have
exactly three elements.
! @ignore
! @mindex &
! @end ignore
@kindex & (matrices)
@pindex calc-inv (matrices)
! @ignore
! @mindex inv
! @end ignore
@tindex inv (matrices)
The @kbd{&} (@code{calc-inv}) address@hidden command computes the
inverse of a square matrix. If the matrix is singular, the inverse
***************
*** 20068,20074 ****
weight is completely negligible.)
This function also works for distributions (error forms or
! intervals). The mean of an error form address@hidden @t{+/-} @i{b}' is simply
@cite{a}. The mean of an interval is the mean of the minimum
and maximum values of the interval.
--- 20273,20279 ----
weight is completely negligible.)
This function also works for distributions (error forms or
! intervals). The mean of an error form address@hidden @t{+/-} @var{b}' is
simply
@cite{a}. The mean of an interval is the mean of the minimum
and maximum values of the interval.
***************
*** 20136,20142 ****
@cindex Geometric mean
The @kbd{u G} (@code{calc-vector-geometric-mean}) address@hidden
command computes the geometric mean of the data values. This
! is the @i{N}th root of the product of the values. This is also
equal to the @code{exp} of the arithmetic mean of the logarithms
of the data values.
@tex
--- 20341,20347 ----
@cindex Geometric mean
The @kbd{u G} (@code{calc-vector-geometric-mean}) address@hidden
command computes the geometric mean of the data values. This
! is the @var{n}th root of the product of the values. This is also
equal to the @code{exp} of the arithmetic mean of the logarithms
of the data values.
@tex
***************
*** 20223,20229 ****
squares of the deviations of the data values from the mean.
(This definition also applies when the argument is a distribution.)
! @c @starindex
@tindex vflat
The @code{vflat} algebraic function returns a vector of its
arguments, interpreted in the same way as the other functions
--- 20428,20436 ----
squares of the deviations of the data values from the mean.
(This definition also applies when the argument is a distribution.)
! @ignore
! @starindex
! @end ignore
@tindex vflat
The @code{vflat} algebraic function returns a vector of its
arguments, interpreted in the same way as the other functions
***************
*** 20343,20349 ****
can't figure it out on its own (say, because you named a function that
is currently undefined). It is also possible to type a digit key before
the function name to specify the number of arguments, e.g.,
! @kbd{V M 3 x f RET} calls @code{f} with three arguments even if it
looks like it ought to have only two. This technique may be necessary
if the function allows a variable number of arguments. For example,
the @kbd{v e} address@hidden function accepts two or three arguments;
--- 20550,20556 ----
can't figure it out on its own (say, because you named a function that
is currently undefined). It is also possible to type a digit key before
the function name to specify the number of arguments, e.g.,
! @kbd{V M 3 x f @key{RET}} calls @code{f} with three arguments even if it
looks like it ought to have only two. This technique may be necessary
if the function allows a variable number of arguments. For example,
the @kbd{v e} address@hidden function accepts two or three arguments;
***************
*** 20381,20389 ****
argument minus the second argument.'' The symbols @samp{#1} and @samp{#2}
are placeholders for the arguments. You can use any names for these
placeholders if you wish, by including an argument list followed by a
! colon: @samp{<x, y : x - y>}. When you type @kbd{V A ' $$ + 2$^$$ RET},
Calc builds the nameless function @samp{<#1 + 2 #2^#1>} as the function
! to map across the vectors. When you type @kbd{V A ' x + 2y^x RET RET},
Calc builds the nameless function @address@hidden<x, y : x + 2 y^x>}}. In
both
cases, Calc also writes the nameless function to the Trail so that you
can get it back later if you wish.
--- 20588,20596 ----
argument minus the second argument.'' The symbols @samp{#1} and @samp{#2}
are placeholders for the arguments. You can use any names for these
placeholders if you wish, by including an argument list followed by a
! colon: @samp{<x, y : x - y>}. When you type @kbd{V A ' $$ + 2$^$$
@key{RET}},
Calc builds the nameless function @samp{<#1 + 2 #2^#1>} as the function
! to map across the vectors. When you type @kbd{V A ' x + 2y^x @key{RET}
@key{RET}},
Calc builds the nameless function @address@hidden<x, y : x + 2 y^x>}}. In
both
cases, Calc also writes the nameless function to the Trail so that you
can get it back later if you wish.
***************
*** 20399,20409 ****
argument list in this case, since the nameless function specifies the
argument list as well as the function itself. In @kbd{V A '}, you can
omit the @samp{< >} marks if you use @samp{#} notation for the arguments,
! so that @kbd{V A ' #1+#2 RET} is the same as @kbd{V A ' <#1+#2> RET},
! which in turn is the same as @kbd{V A ' $$+$ RET}.
@cindex Lambda expressions
! @c @starindex
@tindex lambda
The internal format for @samp{<x, y : x + y>} is @samp{lambda(x, y, x + y)}.
(The word @code{lambda} derives from Lisp notation and the theory of
--- 20606,20618 ----
argument list in this case, since the nameless function specifies the
argument list as well as the function itself. In @kbd{V A '}, you can
omit the @samp{< >} marks if you use @samp{#} notation for the arguments,
! so that @kbd{V A ' #1+#2 @key{RET}} is the same as @kbd{V A ' <#1+#2>
@key{RET}},
! which in turn is the same as @kbd{V A ' $$+$ @key{RET}}.
@cindex Lambda expressions
! @ignore
! @starindex
! @end ignore
@tindex lambda
The internal format for @samp{<x, y : x + y>} is @samp{lambda(x, y, x + y)}.
(The word @code{lambda} derives from Lisp notation and the theory of
***************
*** 20420,20436 ****
@tindex add
@tindex sub
! @c @mindex @idots
@tindex mul
! @c @mindex @null
@tindex div
! @c @mindex @null
@tindex pow
! @c @mindex @null
@tindex neg
! @c @mindex @null
@tindex mod
! @c @mindex @null
@tindex vconcat
As usual, commands like @kbd{V A} have algebraic function name equivalents.
For example, @kbd{V A k g} with an argument of @samp{v} is equivalent to
--- 20629,20657 ----
@tindex add
@tindex sub
! @ignore
! @mindex @idots
! @end ignore
@tindex mul
! @ignore
! @mindex @null
! @end ignore
@tindex div
! @ignore
! @mindex @null
! @end ignore
@tindex pow
! @ignore
! @mindex @null
! @end ignore
@tindex neg
! @ignore
! @mindex @null
! @end ignore
@tindex mod
! @ignore
! @mindex @null
! @end ignore
@tindex vconcat
As usual, commands like @kbd{V A} have algebraic function name equivalents.
For example, @kbd{V A k g} with an argument of @samp{v} is equivalent to
***************
*** 20441,20447 ****
@code{mul}, @code{div}, @code{pow}, @code{neg}, @code{mod}, and
@address@hidden
! @c @starindex
@tindex call
The @code{call} function builds a function call out of several arguments:
@samp{call(gcd, x, y)} is the same as @samp{apply(gcd, [x, y])}, which
--- 20662,20670 ----
@code{mul}, @code{div}, @code{pow}, @code{neg}, @code{mod}, and
@address@hidden
! @ignore
! @starindex
! @end ignore
@tindex call
The @code{call} function builds a function call out of several arguments:
@samp{call(gcd, x, y)} is the same as @samp{apply(gcd, [x, y])}, which
***************
*** 20675,20681 ****
to a fixed point. To find the square root of five starting with an
initial guess, Newton's method would look for a fixed point of the
function @samp{(x + 5/x) / 2}. Putting a guess of 1 on the stack
! and typing @kbd{H I V R ' ($ + 5/$)/2 RET} quickly yields the result
2.23607. This is equivalent to using the @kbd{a R} (@code{calc-find-root})
command to find a root of the equation @samp{x^2 = 5}.
--- 20898,20904 ----
to a fixed point. To find the square root of five starting with an
initial guess, Newton's method would look for a fixed point of the
function @samp{(x + 5/x) / 2}. Putting a guess of 1 on the stack
! and typing @kbd{H I V R ' ($ + 5/$)/2 @key{RET}} quickly yields the result
2.23607. This is equivalent to using the @kbd{a R} (@code{calc-find-root})
command to find a root of the equation @samp{x^2 = 5}.
***************
*** 20788,20824 ****
The default format is @samp{RO}. (Before Calc 2.00, the format
was fixed at @samp{ROC}.) Here are some example matrices:
- @group
@example
[ [ 123, 0, 0 ] [ [ 123, 0, 0 ],
[ 0, 123, 0 ] [ 0, 123, 0 ],
[ 0, 0, 123 ] ] [ 0, 0, 123 ] ]
RO ROC
- @end example
@end group
@noindent
- @group
@example
[ 123, 0, 0 [ 123, 0, 0 ;
0, 123, 0 0, 123, 0 ;
0, 0, 123 ] 0, 0, 123 ]
O OC
- @end example
@end group
@noindent
- @group
@example
[ 123, 0, 0 ] 123, 0, 0
[ 0, 123, 0 ] 0, 123, 0
[ 0, 0, 123 ] 0, 0, 123
R @r{blank}
- @end example
@end group
@noindent
Note that of the formats shown here, @samp{RO}, @samp{ROC}, and
--- 21011,21047 ----
The default format is @samp{RO}. (Before Calc 2.00, the format
was fixed at @samp{ROC}.) Here are some example matrices:
@example
+ @group
[ [ 123, 0, 0 ] [ [ 123, 0, 0 ],
[ 0, 123, 0 ] [ 0, 123, 0 ],
[ 0, 0, 123 ] ] [ 0, 0, 123 ] ]
RO ROC
@end group
+ @end example
@noindent
@example
+ @group
[ 123, 0, 0 [ 123, 0, 0 ;
0, 123, 0 0, 123, 0 ;
0, 0, 123 ] 0, 0, 123 ]
O OC
@end group
+ @end example
@noindent
@example
+ @group
[ 123, 0, 0 ] 123, 0, 0
[ 0, 123, 0 ] 0, 123, 0
[ 0, 0, 123 ] 0, 0, 123
R @r{blank}
@end group
+ @end example
@noindent
Note that of the formats shown here, @samp{RO}, @samp{ROC}, and
***************
*** 20950,20977 ****
display mode but is perhaps easiest in ``big'' (@kbd{d B}) mode.
Suppose you enter the following formula:
- @group
@smallexample
3 ___
(a + b) + V c
1: ---------------
2 x + 1
- @end smallexample
@end group
@noindent
(by typing @kbd{' ((a+b)^3 + sqrt(c)) / (2x+1)}). If you move the
cursor to the letter @samp{b} and press @address@hidden s}}, the display
changes
to
- @group
@smallexample
. ...
.. . b. . . .
1* ...............
. . . .
- @end smallexample
@end group
@noindent
Every character not part of the sub-formula @samp{b} has been changed
--- 21173,21200 ----
display mode but is perhaps easiest in ``big'' (@kbd{d B}) mode.
Suppose you enter the following formula:
@smallexample
+ @group
3 ___
(a + b) + V c
1: ---------------
2 x + 1
@end group
+ @end smallexample
@noindent
(by typing @kbd{' ((a+b)^3 + sqrt(c)) / (2x+1)}). If you move the
cursor to the letter @samp{b} and press @address@hidden s}}, the display
changes
to
@smallexample
+ @group
. ...
.. . b. . . .
1* ...............
. . . .
@end group
+ @end smallexample
@noindent
Every character not part of the sub-formula @samp{b} has been changed
***************
*** 20984,20997 ****
If you had instead placed the cursor on the parenthesis immediately to
the right of the @samp{b}, the selection would have been:
- @group
@smallexample
. ...
(a + b) . . .
1* ...............
. . . .
- @end smallexample
@end group
@noindent
The portion selected is always large enough to be considered a complete
--- 21207,21220 ----
If you had instead placed the cursor on the parenthesis immediately to
the right of the @samp{b}, the selection would have been:
@smallexample
+ @group
. ...
(a + b) . . .
1* ...............
. . . .
@end group
+ @end smallexample
@noindent
The portion selected is always large enough to be considered a complete
***************
*** 21102,21115 ****
@address@hidden m}} (@code{calc-select-more}) command. If @samp{a + b} is
selected, pressing @address@hidden m}} repeatedly works as follows:
- @group
@smallexample
3 ... 3 ___ 3 ___
(a + b) . . . (a + b) + V c (a + b) + V c
1* ............... 1* ............... 1* ---------------
. . . . . . . . 2 x + 1
- @end smallexample
@end group
@noindent
In the last example, the entire formula is selected. This is roughly
--- 21325,21338 ----
@address@hidden m}} (@code{calc-select-more}) command. If @samp{a + b} is
selected, pressing @address@hidden m}} repeatedly works as follows:
@smallexample
+ @group
3 ... 3 ___ 3 ___
(a + b) . . . (a + b) + V c (a + b) + V c
1* ............... 1* ............... 1* ---------------
. . . . . . . . 2 x + 1
@end group
+ @end smallexample
@noindent
In the last example, the entire formula is selected. This is roughly
***************
*** 21193,21206 ****
to the other style in which the selected portion itself is obscured
by @samp{#} signs:
- @group
@smallexample
3 ... # ___
(a + b) . . . ## # ## + V c
1* ............... 1* ---------------
. . . . 2 x + 1
- @end smallexample
@end group
@node Operating on Selections, Rearranging with Selections, Displaying
Selections, Selecting Subformulas
@subsection Operating on Selections
--- 21416,21429 ----
to the other style in which the selected portion itself is obscured
by @samp{#} signs:
@smallexample
+ @group
3 ... # ___
(a + b) . . . ## # ## + V c
1* ............... 1* ---------------
. . . . 2 x + 1
@end group
+ @end smallexample
@node Operating on Selections, Rearranging with Selections, Displaying
Selections, Selecting Subformulas
@subsection Operating on Selections
***************
*** 21232,21239 ****
the selected portion of the formula, returning the old selected
portion to the top of the stack.
- @group
@smallexample
3 ... ... ___
(a + b) . . . 17 x y . . . 17 x y + V c
2* ............... 2* ............. 2: -------------
--- 21455,21462 ----
the selected portion of the formula, returning the old selected
portion to the top of the stack.
@smallexample
+ @group
3 ... ... ___
(a + b) . . . 17 x y . . . 17 x y + V c
2* ............... 2* ............. 2: -------------
***************
*** 21241,21248 ****
3 3
1: 17 x y 1: (a + b) 1: (a + b)
- @end smallexample
@end group
In this example we select a sub-formula of our original example,
enter a new formula, @key{TAB} it into place, then deselect to see
--- 21464,21471 ----
3 3
1: 17 x y 1: (a + b) 1: (a + b)
@end group
+ @end smallexample
In this example we select a sub-formula of our original example,
enter a new formula, @key{TAB} it into place, then deselect to see
***************
*** 21275,21288 ****
it uses the constant one instead. The @key{DEL} key automatically
deselects and re-simplifies the entire formula afterwards. Thus:
- @group
@smallexample
###
17 x y + # # 17 x y 17 # y 17 y
1* ------------- 1: ------- 1* ------- 1: -------
2 x + 1 2 x + 1 2 x + 1 2 x + 1
- @end smallexample
@end group
In this example, we first delete the @samp{sqrt(c)} term; Calc
accomplishes this by replacing @samp{sqrt(c)} with zero and
--- 21498,21511 ----
it uses the constant one instead. The @key{DEL} key automatically
deselects and re-simplifies the entire formula afterwards. Thus:
@smallexample
+ @group
###
17 x y + # # 17 x y 17 # y 17 y
1* ------------- 1: ------- 1* ------- 1: -------
2 x + 1 2 x + 1 2 x + 1 2 x + 1
@end group
+ @end smallexample
In this example, we first delete the @samp{sqrt(c)} term; Calc
accomplishes this by replacing @samp{sqrt(c)} with zero and
***************
*** 21294,21300 ****
element is deleted from the vector. If you delete one side of
an equation or inequality, only the opposite side remains.
! @kindex j DEL
@pindex calc-del-selection
The @kbd{j @key{DEL}} (@code{calc-del-selection}) command is like
@key{DEL} but with the auto-selecting behavior of @kbd{j '} and
--- 21517,21523 ----
element is deleted from the vector. If you delete one side of
an equation or inequality, only the opposite side remains.
! @kindex j @key{DEL}
@pindex calc-del-selection
The @kbd{j @key{DEL}} (@code{calc-del-selection}) command is like
@key{DEL} but with the auto-selecting behavior of @kbd{j '} and
***************
*** 21302,21308 ****
indicated by the cursor, or, in the absence of a selection, it
deletes the sub-formula indicated by the cursor position.
! @kindex j RET
@pindex calc-grab-selection
(There is also an auto-selecting @kbd{j @key{RET}}
(@code{calc-copy-selection})
command.)
--- 21525,21531 ----
indicated by the cursor, or, in the absence of a selection, it
deletes the sub-formula indicated by the cursor position.
! @kindex j @key{RET}
@pindex calc-grab-selection
(There is also an auto-selecting @kbd{j @key{RET}}
(@code{calc-copy-selection})
command.)
***************
*** 21312,21325 ****
denominator, press @kbd{n} to negate the denominator, then
press @kbd{Q} to take the square root.
- @group
@smallexample
.. . .. . .. . .. .
1* ....... 1* ....... 1* ....... 1* ..........
2 x + 1 2 x - 4 4 - 2 x _________
V 4 - 2 x
- @end smallexample
@end group
Certain types of operations on selections are not allowed. For
example, for an arithmetic function like @kbd{-} no more than one of
--- 21535,21548 ----
denominator, press @kbd{n} to negate the denominator, then
press @kbd{Q} to take the square root.
@smallexample
+ @group
.. . .. . .. . .. .
1* ....... 1* ....... 1* ....... 1* ..........
2 x + 1 2 x - 4 4 - 2 x _________
V 4 - 2 x
@end group
+ @end smallexample
Certain types of operations on selections are not allowed. For
example, for an arithmetic function like @kbd{-} no more than one of
***************
*** 21334,21347 ****
of our sample formula by selecting it and pressing @kbd{n}
(@code{calc-change-sign})address@hidden
- @group
@smallexample
.. . .. .
1* .......... 1* ...........
......... ..........
. . . 2 x . . . -2 x
- @end smallexample
@end group
Unselecting the sub-formula reveals that the minus sign, which would
normally have cancelled out with the subtraction automatically, has
--- 21557,21570 ----
of our sample formula by selecting it and pressing @kbd{n}
(@code{calc-change-sign})address@hidden
@smallexample
+ @group
.. . .. .
1* .......... 1* ...........
......... ..........
. . . 2 x . . . -2 x
@end group
+ @end smallexample
Unselecting the sub-formula reveals that the minus sign, which would
normally have cancelled out with the subtraction automatically, has
***************
*** 21350,21363 ****
any other mathematical operation on the whole formula will cause it
to be simplified.
- @group
@smallexample
17 y 17 y
1: ----------- 1: ----------
__________ _________
V 4 - -2 x V 4 + 2 x
- @end smallexample
@end group
@node Rearranging with Selections, , Operating on Selections, Selecting
Subformulas
@subsection Rearranging Formulas using Selections
--- 21573,21586 ----
any other mathematical operation on the whole formula will cause it
to be simplified.
@smallexample
+ @group
17 y 17 y
1: ----------- 1: ----------
__________ _________
V 4 - -2 x V 4 + 2 x
@end group
+ @end smallexample
@node Rearranging with Selections, , Operating on Selections, Selecting
Subformulas
@subsection Rearranging Formulas using Selections
***************
*** 21370,21376 ****
selection is one term of a sum or product; the sum or product is
rearranged according to the commutative laws of algebra.
! As with @kbd{j '} and @kbd{j DEL}, the term under the cursor is used
if there is no selection in the current formula. All commands described
in this section share this property. In this example, we place the
cursor on the @samp{a} and type @kbd{j R}, then repeat.
--- 21593,21599 ----
selection is one term of a sum or product; the sum or product is
rearranged according to the commutative laws of algebra.
! As with @kbd{j '} and @kbd{j @key{DEL}}, the term under the cursor is used
if there is no selection in the current formula. All commands described
in this section share this property. In this example, we place the
cursor on the @samp{a} and type @kbd{j R}, then repeat.
***************
*** 22106,22113 ****
value in the Calc variable @samp{e}; but this would be a bad idea
in any case if you were also using natural logarithms!
! Among the logical functions, @address@hidden(a} @t{<=} @i{b)} changes to
! @cite{a > b} and so on. Equations and inequalities where both sides
are either negative-looking or zero are simplified by negating both sides
and reversing the inequality. While it might seem reasonable to simplify
@cite{!!x} to @cite{x}, this would not be valid in general because
--- 22329,22336 ----
value in the Calc variable @samp{e}; but this would be a bad idea
in any case if you were also using natural logarithms!
! Among the logical functions, @t{(@var{a} <= @var{b})} changes to
! @address@hidden > @var{b}} and so on. Equations and inequalities where both
sides
are either negative-looking or zero are simplified by negating both sides
and reversing the inequality. While it might seem reasonable to simplify
@cite{!!x} to @cite{x}, this would not be valid in general because
***************
*** 22346,22352 ****
@cindex Extended simplification
@kindex a e
@pindex calc-simplify-extended
! @c @mindex address@hidden
@tindex esimplify
The @kbd{a e} (@code{calc-simplify-extended}) address@hidden command
is like @kbd{a s}
--- 22569,22577 ----
@cindex Extended simplification
@kindex a e
@pindex calc-simplify-extended
! @ignore
! @mindex address@hidden
! @end ignore
@tindex esimplify
The @kbd{a e} (@code{calc-simplify-extended}) address@hidden command
is like @kbd{a s}
***************
*** 22543,22552 ****
version of Calc.)
@vindex FactorRules
! @c @starindex
@tindex thecoefs
! @c @starindex
! @c @mindex @idots
@tindex thefactors
The rewrite-based factorization method uses rules stored in the variable
@code{FactorRules}. @xref{Rewrite Rules}, for a discussion of the
--- 22768,22783 ----
version of Calc.)
@vindex FactorRules
! @ignore
! @starindex
! @end ignore
@tindex thecoefs
! @ignore
! @starindex
! @end ignore
! @ignore
! @mindex @idots
! @end ignore
@tindex thefactors
The rewrite-based factorization method uses rules stored in the variable
@code{FactorRules}. @xref{Rewrite Rules}, for a discussion of the
***************
*** 22664,22670 ****
of the screen and is also placed in the Trail along with the quotient.
Using @code{pdiv} in algebraic notation, you can specify the particular
! variable to be used as the base:
address@hidden(address@hidden@t{,address@hidden@t{,address@hidden@t{)}'.
If @code{pdiv} is given only two arguments (as is always the case with
the @kbd{a \} command), then it does a multivariate division as outlined
above.
--- 22895,22901 ----
of the screen and is also placed in the Trail along with the quotient.
Using @code{pdiv} in algebraic notation, you can specify the particular
! variable to be used as the base: @code{pdiv(@var{a},@var{b},@var{x})}.
If @code{pdiv} is given only two arguments (as is always the case with
the @kbd{a \} command), then it does a multivariate division as outlined
above.
***************
*** 22893,22899 ****
in your @code{IntegRules}.
@cindex Exponential integral Ei(x)
! @c @starindex
@tindex Ei
As a more serious example, the expression @samp{exp(x)/x} cannot be
integrated in terms of the standard functions, so the ``exponential
--- 23124,23132 ----
in your @code{IntegRules}.
@cindex Exponential integral Ei(x)
! @ignore
! @starindex
! @end ignore
@tindex Ei
As a more serious example, the expression @samp{exp(x)/x} cannot be
integrated in terms of the standard functions, so the ``exponential
***************
*** 23129,23137 ****
@cindex @code{GenCount} variable
@vindex GenCount
! @c @starindex
@tindex an
! @c @starindex
@tindex as
If you store a positive integer in the Calc variable @code{GenCount},
then Calc will generate formulas of the form @samp{as(@var{n})} for
--- 23362,23374 ----
@cindex @code{GenCount} variable
@vindex GenCount
! @ignore
! @starindex
! @end ignore
@tindex an
! @ignore
! @starindex
! @end ignore
@tindex as
If you store a positive integer in the Calc variable @code{GenCount},
then Calc will generate formulas of the form @samp{as(@var{n})} for
***************
*** 23231,23237 ****
solve any system of linear equations, and also many kinds of
nonlinear systems.
! @c @starindex
@tindex elim
Normally there will be as many variables as equations. If you
give fewer variables than equations (an ``over-determined'' system
--- 23468,23476 ----
solve any system of linear equations, and also many kinds of
nonlinear systems.
! @ignore
! @starindex
! @end ignore
@tindex elim
Normally there will be as many variables as equations. If you
give fewer variables than equations (an ``over-determined'' system
***************
*** 23269,23275 ****
@subsection Decomposing Polynomials
@noindent
! @c @starindex
@tindex poly
The @code{poly} function takes a polynomial and a variable as
arguments, and returns a vector of polynomial coefficients (constant
--- 23508,23516 ----
@subsection Decomposing Polynomials
@noindent
! @ignore
! @starindex
! @end ignore
@tindex poly
The @code{poly} function takes a polynomial and a variable as
arguments, and returns a vector of polynomial coefficients (constant
***************
*** 23292,23298 ****
returns @samp{[1, 4, 6, 4, 1]}, so @samp{poly((x+1)^4, x)_(2+1)}
gives the @cite{x^2} coefficient of this polynomial, 6.
! @c @starindex
@tindex gpoly
One important feature of the solver is its ability to recognize
formulas which are ``essentially'' polynomials. This ability is
--- 23533,23541 ----
returns @samp{[1, 4, 6, 4, 1]}, so @samp{poly((x+1)^4, x)_(2+1)}
gives the @cite{x^2} coefficient of this polynomial, 6.
! @ignore
! @starindex
! @end ignore
@tindex gpoly
One important feature of the solver is its ability to recognize
formulas which are ``essentially'' polynomials. This ability is
***************
*** 23343,23349 ****
@samp{gpoly(@var{expr}, @var{var}, 4)} to discover whether @var{expr}
can be treated by its linear, quadratic, cubic, or quartic formulas.
! @c @starindex
@tindex pdeg
The @code{pdeg} function computes the degree of a polynomial;
@samp{pdeg(p,x)} is the highest power of @code{x} that appears in
--- 23586,23594 ----
@samp{gpoly(@var{expr}, @var{var}, 4)} to discover whether @var{expr}
can be treated by its linear, quadratic, cubic, or quartic formulas.
! @ignore
! @starindex
! @end ignore
@tindex pdeg
The @code{pdeg} function computes the degree of a polynomial;
@samp{pdeg(p,x)} is the highest power of @code{x} that appears in
***************
*** 23358,23364 ****
the degree of the constant zero is considered to be @code{-inf}
(minus infinity).
! @c @starindex
@tindex plead
The @code{plead} function finds the leading term of a polynomial.
Thus @samp{plead(p,x)} is equivalent to @samp{poly(p,x)_vlen(poly(p,x))},
--- 23603,23611 ----
the degree of the constant zero is considered to be @code{-inf}
(minus infinity).
! @ignore
! @starindex
! @end ignore
@tindex plead
The @code{plead} function finds the leading term of a polynomial.
Thus @samp{plead(p,x)} is equivalent to @samp{poly(p,x)_vlen(poly(p,x))},
***************
*** 23366,23372 ****
returns 1024 without expanding out the list of coefficients. The
value of @code{plead(p,x)} will be zero only if @cite{p = 0}.
! @c @starindex
@tindex pcont
The @code{pcont} function finds the @dfn{content} of a polynomial. This
is the greatest common divisor of all the coefficients of the polynomial.
--- 23613,23621 ----
returns 1024 without expanding out the list of coefficients. The
value of @code{plead(p,x)} will be zero only if @cite{p = 0}.
! @ignore
! @starindex
! @end ignore
@tindex pcont
The @code{pcont} function finds the @dfn{content} of a polynomial. This
is the greatest common divisor of all the coefficients of the polynomial.
***************
*** 23389,23395 ****
numerators. The numerical content of a polynomial is negative only
if all the coefficients in the polynomial are negative.
! @c @starindex
@tindex pprim
The @code{pprim} function finds the @dfn{primitive part} of a
polynomial, which is simply the polynomial divided (using @code{pdiv}
--- 23638,23646 ----
numerators. The numerical content of a polynomial is negative only
if all the coefficients in the polynomial are negative.
! @ignore
! @starindex
! @end ignore
@tindex pprim
The @code{pprim} function finds the @dfn{primitive part} of a
polynomial, which is simply the polynomial divided (using @code{pdiv}
***************
*** 23539,23547 ****
you should set the precision to twice as many digits as you need in your
answer.
! @c @mindex address@hidden
@tindex wminimize
! @c @mindex address@hidden
@tindex wmaximize
The @kbd{H a N} address@hidden command, analogously to @kbd{H a R},
expands the guess interval to enclose a minimum rather than requiring
--- 23790,23802 ----
you should set the precision to twice as many digits as you need in your
answer.
! @ignore
! @mindex address@hidden
! @end ignore
@tindex wminimize
! @ignore
! @mindex address@hidden
! @end ignore
@tindex wmaximize
The @kbd{H a N} address@hidden command, analogously to @kbd{H a R},
expands the guess interval to enclose a minimum rather than requiring
***************
*** 23661,23672 ****
For example, suppose the data matrix
@ifinfo
- @group
@example
[ [ 1, 2, 3, 4, 5 ]
[ 5, 7, 9, 11, 13 ] ]
- @end example
@end group
@end ifinfo
@tex
\turnoffactive
--- 23916,23927 ----
For example, suppose the data matrix
@ifinfo
@example
+ @group
[ [ 1, 2, 3, 4, 5 ]
[ 5, 7, 9, 11, 13 ] ]
@end group
+ @end example
@end ifinfo
@tex
\turnoffactive
***************
*** 23680,23686 ****
@noindent
is on the stack and we wish to do a simple linear fit. Type
! @kbd{a F}, then @kbd{1} for the model, then @kbd{RET} to use
the default names. The result will be the formula @cite{3 + 2 x}
on the stack. Calc has created the model expression @kbd{a + b x},
then found the optimal values of @cite{a} and @cite{b} to fit the
--- 23935,23941 ----
@noindent
is on the stack and we wish to do a simple linear fit. Type
! @kbd{a F}, then @kbd{1} for the model, then @key{RET} to use
the default names. The result will be the formula @cite{3 + 2 x}
on the stack. Calc has created the model expression @kbd{a + b x},
then found the optimal values of @cite{a} and @cite{b} to fit the
***************
*** 23696,23703 ****
to move this vector to the stack; see @ref{Trail Commands}.
Specifying a different independent variable name will affect the
! resulting formula: @kbd{a F 1 k RET} produces @kbd{3 + 2 k}.
! Changing the parameter names (say, @kbd{a F 1 k;b,m RET}) will affect
the equations that go into the trail.
@tex
--- 23951,23958 ----
to move this vector to the stack; see @ref{Trail Commands}.
Specifying a different independent variable name will affect the
! resulting formula: @kbd{a F 1 k @key{RET}} produces @kbd{3 + 2 k}.
! Changing the parameter names (say, @kbd{a F 1 k;b,m @key{RET}}) will affect
the equations that go into the trail.
@tex
***************
*** 23712,23725 ****
2.6 + 2.2 x
@end example
! Evaluating this formula, say with @kbd{v x 5 RET TAB V M $ RET}, shows
a reasonably close match to the y-values in the data.
@example
[4.8, 7., 9.2, 11.4, 13.6]
@end example
! Since there is no line which passes through all the @i{N} data points,
Calc has chosen a line that best approximates the data points using
the method of least squares. The idea is to define the @dfn{chi-square}
error measure
--- 23967,23980 ----
2.6 + 2.2 x
@end example
! Evaluating this formula, say with @kbd{v x 5 @key{RET} @key{TAB} V M $
@key{RET}}, shows
a reasonably close match to the y-values in the data.
@example
[4.8, 7., 9.2, 11.4, 13.6]
@end example
! Since there is no line which passes through all the @var{n} data points,
Calc has chosen a line that best approximates the data points using
the method of least squares. The idea is to define the @dfn{chi-square}
error measure
***************
*** 23754,23766 ****
@end tex
A numeric prefix argument causes the @kbd{a F} command to take the
! data in some other form than one big matrix. A positive argument @i{N}
! will take @i{N} items from the stack, corresponding to the @i{N} rows
! of a data matrix. In the linear case, @i{N} must be 2 since there
is always one independent variable and one dependent variable.
A prefix of zero or plain @kbd{C-u} is a compromise; Calc takes two
! items from the stack, an @i{N}-row matrix of @cite{x} values, and a
vector of @cite{y} values. If there is only one independent variable,
the @cite{x} values can be either a one-row matrix or a plain vector,
in which case the @kbd{C-u} prefix is the same as a @address@hidden 2}}
prefix.
--- 24009,24021 ----
@end tex
A numeric prefix argument causes the @kbd{a F} command to take the
! data in some other form than one big matrix. A positive argument @var{n}
! will take @var{N} items from the stack, corresponding to the @var{n} rows
! of a data matrix. In the linear case, @var{n} must be 2 since there
is always one independent variable and one dependent variable.
A prefix of zero or plain @kbd{C-u} is a compromise; Calc takes two
! items from the stack, an @var{n}-row matrix of @cite{x} values, and a
vector of @cite{y} values. If there is only one independent variable,
the @cite{x} values can be either a one-row matrix or a plain vector,
in which case the @kbd{C-u} prefix is the same as a @address@hidden 2}}
prefix.
***************
*** 23773,23779 ****
digits @kbd{2} through @kbd{9} when prompted for a model. For example,
we could fit the original data matrix from the previous section
(with 13, not 14) to a parabola instead of a line by typing
! @kbd{a F 2 RET}.
@example
2.00000000001 x - 1.5e-12 x^2 + 2.99999999999
--- 24028,24034 ----
digits @kbd{2} through @kbd{9} when prompted for a model. For example,
we could fit the original data matrix from the previous section
(with 13, not 14) to a parabola instead of a line by typing
! @kbd{a F 2 @key{RET}}.
@example
2.00000000001 x - 1.5e-12 x^2 + 2.99999999999
***************
*** 23797,23804 ****
@end example
An important result from the theory of polynomial fitting is that it
! is always possible to fit @i{N} data points exactly using a polynomial
! of degree @i{N-1}, sometimes called an @dfn{interpolating polynomial}.
Using the modified (14) data matrix, a model number of 4 gives
a polynomial that exactly matches all five data points:
--- 24052,24059 ----
@end example
An important result from the theory of polynomial fitting is that it
! is always possible to fit @var{n} data points exactly using a polynomial
! of degree @address@hidden, sometimes called an @dfn{interpolating polynomial}.
Using the modified (14) data matrix, a model number of 4 gives
a polynomial that exactly matches all five data points:
***************
*** 23837,23852 ****
Given the data matrix,
- @group
@example
[ [ 1, 2, 3, 4, 5 ]
[ 7, 2, 3, 5, 2 ]
[ 14.5, 15, 18.5, 22.5, 24 ] ]
- @end example
@end group
@noindent
! the command @kbd{a F 1 RET} will call the first row @cite{x} and the
second row @cite{y}, and will fit the values in the third row to the
model @cite{a + b x + c y}.
--- 24092,24107 ----
Given the data matrix,
@example
+ @group
[ [ 1, 2, 3, 4, 5 ]
[ 7, 2, 3, 5, 2 ]
[ 14.5, 15, 18.5, 22.5, 24 ] ]
@end group
+ @end example
@noindent
! the command @kbd{a F 1 @key{RET}} will call the first row @cite{x} and the
second row @cite{y}, and will fit the values in the third row to the
model @cite{a + b x + c y}.
***************
*** 23903,23910 ****
or all be plain numbers. Error forms can go anywhere but generally
go on the numbers in the last row of the data matrix. If the last
row contains error forms
! address@hidden@w{ @t{+/-} address@hidden
! @i{sigma_i}', then the @c{$\chi^2$}
@cite{chi^2}
statistic is now,
--- 24158,24165 ----
or all be plain numbers. Error forms can go anywhere but generally
go on the numbers in the last row of the data matrix. If the last
row contains error forms
! address@hidden@w{ @t{+/-} address@hidden
! @var{sigma_i}', then the @c{$\chi^2$}
@cite{chi^2}
statistic is now,
***************
*** 23973,23979 ****
@item
The covariance matrix @cite{C} computed from the fit. This is
! an @address@hidden symmetric matrix; the diagonal elements
@c{$C_{jj}$}
@cite{C_j_j} are the variances @c{$\sigma_j^2$}
@cite{sigma_j^2} of the parameters.
--- 24228,24234 ----
@item
The covariance matrix @cite{C} computed from the fit. This is
! an @address@hidden symmetric matrix; the diagonal elements
@c{$C_{jj}$}
@cite{C_j_j} are the variances @c{$\sigma_j^2$}
@cite{sigma_j^2} of the parameters.
***************
*** 24268,24274 ****
graphing them, by examining the goodness-of-fit measures returned by
@kbd{I a F}, or by some other method suitable to your application.
Note that some models can be linearized in several ways. The
! address@hidden model can be linearized by setting @cite{d}
(the background) to a constant, or by setting @cite{b} (the standard
deviation) and @cite{c} (the mean) to constants.
--- 24523,24529 ----
graphing them, by examining the goodness-of-fit measures returned by
@kbd{I a F}, or by some other method suitable to your application.
Note that some models can be linearized in several ways. The
! address@hidden model can be linearized by setting @cite{d}
(the background) to a constant, or by setting @cite{b} (the standard
deviation) and @cite{c} (the mean) to constants.
***************
*** 24384,24402 ****
@xref{Rewrite Rules}, for a discussion of rewrite rules.
! @c @starindex
@tindex fitvar
! @c @starindex
! @c @mindex @idots
@tindex fitparam
! @c @starindex
! @c @mindex @null
@tindex fitmodel
! @c @starindex
! @c @mindex @null
@tindex fitsystem
! @c @starindex
! @c @mindex @null
@tindex fitdummy
Calc uses @code{FitRules} as follows. First, it converts the model
to an equation if necessary and encloses the model equation in a
--- 24639,24675 ----
@xref{Rewrite Rules}, for a discussion of rewrite rules.
! @ignore
! @starindex
! @end ignore
@tindex fitvar
! @ignore
! @starindex
! @end ignore
! @ignore
! @mindex @idots
! @end ignore
@tindex fitparam
! @ignore
! @starindex
! @end ignore
! @ignore
! @mindex @null
! @end ignore
@tindex fitmodel
! @ignore
! @starindex
! @end ignore
! @ignore
! @mindex @null
! @end ignore
@tindex fitsystem
! @ignore
! @starindex
! @end ignore
! @ignore
! @mindex @null
! @end ignore
@tindex fitdummy
Calc uses @code{FitRules} as follows. First, it converts the model
to an equation if necessary and encloses the model equation in a
***************
*** 24408,24418 ****
is the highest-numbered @code{fitvar}. For example, the power law
model @cite{a x^b} is converted to @cite{y = a x^b}, then to
- @group
@smallexample
fitmodel(fitvar(2) = fitparam(1) fitvar(1)^fitparam(2))
- @end smallexample
@end group
Calc then applies the rewrites as if by @samp{C-u 0 a r FitRules}.
(The zero prefix means that rewriting should continue until no further
--- 24681,24691 ----
is the highest-numbered @code{fitvar}. For example, the power law
model @cite{a x^b} is converted to @cite{y = a x^b}, then to
@smallexample
+ @group
fitmodel(fitvar(2) = fitparam(1) fitvar(1)^fitparam(2))
@end group
+ @end smallexample
Calc then applies the rewrites as if by @samp{C-u 0 a r FitRules}.
(The zero prefix means that rewriting should continue until no further
***************
*** 24436,24448 ****
The power law model eventually boils down to
- @group
@smallexample
fitsystem(ln(fitvar(2)),
[1, ln(fitvar(1))],
[exp(fitdummy(1)), fitdummy(2)])
- @end smallexample
@end group
The actual implementation of @code{FitRules} is complicated; it
proceeds in four phases. First, common rearrangements are done
--- 24709,24721 ----
The power law model eventually boils down to
@smallexample
+ @group
fitsystem(ln(fitvar(2)),
[1, ln(fitvar(1))],
[exp(fitdummy(1)), fitdummy(2)])
@end group
+ @end smallexample
The actual implementation of @code{FitRules} is complicated; it
proceeds in four phases. First, common rearrangements are done
***************
*** 24492,24502 ****
to obtain the three-argument @code{fitsystem} that the linear
least-squares solver wants to see.
! @c @starindex
! @c @mindex address@hidden
@tindex hasfitparams
! @c @starindex
! @c @mindex @null
@tindex hasfitvars
Two functions which are useful in connection with @code{FitRules}
are @samp{hasfitparams(x)} and @samp{hasfitvars(x)}, which check
--- 24765,24783 ----
to obtain the three-argument @code{fitsystem} that the linear
least-squares solver wants to see.
! @ignore
! @starindex
! @end ignore
! @ignore
! @mindex address@hidden
! @end ignore
@tindex hasfitparams
! @ignore
! @starindex
! @end ignore
! @ignore
! @mindex @null
! @end ignore
@tindex hasfitvars
Two functions which are useful in connection with @code{FitRules}
are @samp{hasfitparams(x)} and @samp{hasfitvars(x)}, which check
***************
*** 24613,24619 ****
sum (any formula), and the upper limit of the sum. If you
enter a blank line at any of these prompts, that prompt and
any later ones are answered by reading additional elements from
! the stack. Thus, @kbd{' k^2 RET ' k RET 1 RET 5 RET a + RET}
produces the result 55.
@tex
\turnoffactive
--- 24894,24900 ----
sum (any formula), and the upper limit of the sum. If you
enter a blank line at any of these prompts, that prompt and
any later ones are answered by reading additional elements from
! the stack. Thus, @kbd{' k^2 @key{RET} ' k @key{RET} 1 @key{RET} 5 @key{RET}
a + @key{RET}}
produces the result 55.
@tex
\turnoffactive
***************
*** 24627,24637 ****
as a value. If you pressed @kbd{=} on a sum over @code{i}, it would
be changed to a nonsensical sum over the ``variable'' @cite{(0, 1)}!
If you really want to use @code{i} as an index variable, use
! @address@hidden u i RET}} first to ``unstore'' this variable.
(@xref{Storing Variables}.)
A numeric prefix argument steps the index by that amount rather
! than by one. Thus @kbd{' a_k RET C-u -2 a + k RET 10 RET 0 RET}
yields @samp{a_10 + a_8 + a_6 + a_4 + a_2 + a_0}. A prefix
argument of plain @kbd{C-u} causes @kbd{a +} to prompt for the
step value, in which case you can enter any formula or enter
--- 24908,24918 ----
as a value. If you pressed @kbd{=} on a sum over @code{i}, it would
be changed to a nonsensical sum over the ``variable'' @cite{(0, 1)}!
If you really want to use @code{i} as an index variable, use
! @address@hidden u i @key{RET}}} first to ``unstore'' this variable.
(@xref{Storing Variables}.)
A numeric prefix argument steps the index by that amount rather
! than by one. Thus @kbd{' a_k @key{RET} C-u -2 a + k @key{RET} 10 @key{RET} 0
@key{RET}}
yields @samp{a_10 + a_8 + a_6 + a_4 + a_2 + a_0}. A prefix
argument of plain @kbd{C-u} causes @kbd{a +} to prompt for the
step value, in which case you can enter any formula or enter
***************
*** 24823,24851 ****
@kindex a <
@tindex lt
! @c @mindex @idots
@kindex a >
! @c @mindex @null
@kindex a [
! @c @mindex @null
@kindex a ]
@pindex calc-less-than
@pindex calc-greater-than
@pindex calc-less-equal
@pindex calc-greater-equal
! @c @mindex @null
@tindex gt
! @c @mindex @null
@tindex leq
! @c @mindex @null
@tindex geq
! @c @mindex @null
@tindex <
! @c @mindex @null
@tindex >
! @c @mindex @null
@tindex <=
! @c @mindex @null
@tindex >=
The @kbd{a <} (@code{calc-less-than}) address@hidden(a,b)} or @samp{a < b}]
operation is true if @cite{a} is less than @cite{b}. Similar functions
--- 25104,25152 ----
@kindex a <
@tindex lt
! @ignore
! @mindex @idots
! @end ignore
@kindex a >
! @ignore
! @mindex @null
! @end ignore
@kindex a [
! @ignore
! @mindex @null
! @end ignore
@kindex a ]
@pindex calc-less-than
@pindex calc-greater-than
@pindex calc-less-equal
@pindex calc-greater-equal
! @ignore
! @mindex @null
! @end ignore
@tindex gt
! @ignore
! @mindex @null
! @end ignore
@tindex leq
! @ignore
! @mindex @null
! @end ignore
@tindex geq
! @ignore
! @mindex @null
! @end ignore
@tindex <
! @ignore
! @mindex @null
! @end ignore
@tindex >
! @ignore
! @mindex @null
! @end ignore
@tindex <=
! @ignore
! @mindex @null
! @end ignore
@tindex >=
The @kbd{a <} (@code{calc-less-than}) address@hidden(a,b)} or @samp{a < b}]
operation is true if @cite{a} is less than @cite{b}. Similar functions
***************
*** 24908,24916 ****
@kindex a :
@pindex calc-logical-if
@tindex if
! @c @mindex ? :
@tindex ?
! @c @mindex @null
@tindex :
@cindex Arguments, not evaluated
The @kbd{a :} (@code{calc-logical-if}) address@hidden(a,b,c)} or @samp{a ? b
:@: c}]
--- 25209,25221 ----
@kindex a :
@pindex calc-logical-if
@tindex if
! @ignore
! @mindex ? :
! @end ignore
@tindex ?
! @ignore
! @mindex @null
! @end ignore
@tindex :
@cindex Arguments, not evaluated
The @kbd{a :} (@code{calc-logical-if}) address@hidden(a,b,c)} or @samp{a ? b
:@: c}]
***************
*** 24948,24954 ****
@xref{Set Operations}, for a group of commands that manipulate sets
of this sort.
! @c @starindex
@tindex typeof
The @samp{typeof(a)} function produces an integer or variable which
characterizes @cite{a}. If @cite{a} is a number, vector, or variable,
--- 25253,25261 ----
@xref{Set Operations}, for a group of commands that manipulate sets
of this sort.
! @ignore
! @starindex
! @end ignore
@tindex typeof
The @samp{typeof(a)} function produces an integer or variable which
characterizes @cite{a}. If @cite{a} is a number, vector, or variable,
***************
*** 24975,24985 ****
Otherwise, @cite{a} is a formula, and the result is a variable which
represents the name of the top-level function call.
! @c @starindex
@tindex integer
! @c @starindex
@tindex real
! @c @starindex
@tindex constant
The @samp{integer(a)} function returns true if @cite{a} is an integer.
The @samp{real(a)} function
--- 25282,25298 ----
Otherwise, @cite{a} is a formula, and the result is a variable which
represents the name of the top-level function call.
! @ignore
! @starindex
! @end ignore
@tindex integer
! @ignore
! @starindex
! @end ignore
@tindex real
! @ignore
! @starindex
! @end ignore
@tindex constant
The @samp{integer(a)} function returns true if @cite{a} is an integer.
The @samp{real(a)} function
***************
*** 24997,25003 ****
@samp{integer(floor(x))} does not because @samp{floor(x)} is not
literally an integer constant.
! @c @starindex
@tindex refers
The @samp{refers(a,b)} function is true if the variable (or sub-expression)
@cite{b} appears in @cite{a}, or false otherwise. Unlike the other
--- 25310,25318 ----
@samp{integer(floor(x))} does not because @samp{floor(x)} is not
literally an integer constant.
! @ignore
! @starindex
! @end ignore
@tindex refers
The @samp{refers(a,b)} function is true if the variable (or sub-expression)
@cite{b} appears in @cite{a}, or false otherwise. Unlike the other
***************
*** 25006,25012 ****
@code{refers} will be left unevaluated is if @cite{a} is a plain
variable (different from @cite{b}).
! @c @starindex
@tindex negative
The @samp{negative(a)} function returns true if @cite{a} ``looks'' negative,
because it is a negative number, because it is of the form @cite{-x},
--- 25321,25329 ----
@code{refers} will be left unevaluated is if @cite{a} is a plain
variable (different from @cite{b}).
! @ignore
! @starindex
! @end ignore
@tindex negative
The @samp{negative(a)} function returns true if @cite{a} ``looks'' negative,
because it is a negative number, because it is of the form @cite{-x},
***************
*** 25017,25030 ****
first with @kbd{m O} (or if it appears in an unevaluated context such
as a rewrite rule condition).
! @c @starindex
@tindex variable
The @samp{variable(a)} function is true if @cite{a} is a variable,
or false if not. If @cite{a} is a function call, this test is left
in symbolic form. Built-in variables like @code{pi} and @code{inf}
are considered variables like any others by this test.
! @c @starindex
@tindex nonvar
The @samp{nonvar(a)} function is true if @cite{a} is a non-variable.
If its argument is a variable it is left unsimplified; it never
--- 25334,25351 ----
first with @kbd{m O} (or if it appears in an unevaluated context such
as a rewrite rule condition).
! @ignore
! @starindex
! @end ignore
@tindex variable
The @samp{variable(a)} function is true if @cite{a} is a variable,
or false if not. If @cite{a} is a function call, this test is left
in symbolic form. Built-in variables like @code{pi} and @code{inf}
are considered variables like any others by this test.
! @ignore
! @starindex
! @end ignore
@tindex nonvar
The @samp{nonvar(a)} function is true if @cite{a} is a non-variable.
If its argument is a variable it is left unsimplified; it never
***************
*** 25032,25044 ****
commands consider ``false'' anything not provably true, this is
often good enough.
! @c @starindex
@tindex lin
! @c @starindex
@tindex linnt
! @c @starindex
@tindex islin
! @c @starindex
@tindex islinnt
@cindex Linearity testing
The functions @code{lin}, @code{linnt}, @code{islin}, and @code{islinnt}
--- 25353,25373 ----
commands consider ``false'' anything not provably true, this is
often good enough.
! @ignore
! @starindex
! @end ignore
@tindex lin
! @ignore
! @starindex
! @end ignore
@tindex linnt
! @ignore
! @starindex
! @end ignore
@tindex islin
! @ignore
! @starindex
! @end ignore
@tindex islinnt
@cindex Linearity testing
The functions @code{lin}, @code{linnt}, @code{islin}, and @code{islinnt}
***************
*** 25076,25082 ****
@code{linnt} accept plain constants as linear in the one-argument
case: @samp{islin(2,x)} is true, but @samp{islin(2)} is false.
! @c @starindex
@tindex istrue
The @samp{istrue(a)} function returns 1 if @cite{a} is a nonzero
number or provably nonzero formula, or 0 if @cite{a} is anything else.
--- 25405,25413 ----
@code{linnt} accept plain constants as linear in the one-argument
case: @samp{islin(2,x)} is true, but @samp{islin(2)} is false.
! @ignore
! @starindex
! @end ignore
@tindex istrue
The @samp{istrue(a)} function returns 1 if @cite{a} is a nonzero
number or provably nonzero formula, or 0 if @cite{a} is anything else.
***************
*** 25155,25167 ****
@enumerate
@item
! With a rule: @kbd{f(x) := g(x) RET}.
@item
! With a vector of rules: @kbd{[f1(x) := g1(x), f2(x) := g2(x)] RET}.
(You can omit the enclosing square brackets if you wish.)
@item
With the name of a variable that contains the rule or rules vector:
! @kbd{myrules RET}.
@item
With any formula except a rule, a vector, or a variable name; this
will be interpreted as the @var{old} half of a rewrite rule,
--- 25486,25498 ----
@enumerate
@item
! With a rule: @kbd{f(x) := g(x) @key{RET}}.
@item
! With a vector of rules: @kbd{[f1(x) := g1(x), f2(x) := g2(x)] @key{RET}}.
(You can omit the enclosing square brackets if you wish.)
@item
With the name of a variable that contains the rule or rules vector:
! @kbd{myrules @key{RET}}.
@item
With any formula except a rule, a vector, or a variable name; this
will be interpreted as the @var{old} half of a rewrite rule,
***************
*** 25363,25369 ****
will take whichever suitable pair it discovers first.
In general, a pattern using an associative operator like @samp{a + b}
! will try @i{2 n} different ways to match a sum of @i{n} terms
like @samp{x + y + z - w}. First, @samp{a} is matched against each
of @samp{x}, @samp{y}, @samp{z}, and @samp{-w} in turn, with @samp{b}
being matched to the remainders @samp{y + z - w}, @samp{x + z - w}, etc.
--- 25694,25700 ----
will take whichever suitable pair it discovers first.
In general, a pattern using an associative operator like @samp{a + b}
! will try @var{2 n} different ways to match a sum of @var{n} terms
like @samp{x + y + z - w}. First, @samp{a} is matched against each
of @samp{x}, @samp{y}, @samp{z}, and @samp{-w} in turn, with @samp{b}
being matched to the remainders @samp{y + z - w}, @samp{x + z - w}, etc.
***************
*** 25670,25676 ****
markers that work inside a pattern; then come the markers that
work in the righthand side of a rule.
! @c @starindex
@tindex import
One kind of marker, @samp{import(x)}, takes the place of a whole
rule. Here @cite{x} is the name of a variable containing another
--- 26001,26009 ----
markers that work inside a pattern; then come the markers that
work in the righthand side of a rule.
! @ignore
! @starindex
! @end ignore
@tindex import
One kind of marker, @samp{import(x)}, takes the place of a whole
rule. Here @cite{x} is the name of a variable containing another
***************
*** 25697,25703 ****
@table @samp
@item quote(x)
! @c @starindex
@tindex quote
This pattern matches exactly @cite{x}; variable names in @cite{x} are
not interpreted as meta-variables. The only flexibility is that
--- 26030,26038 ----
@table @samp
@item quote(x)
! @ignore
! @starindex
! @end ignore
@tindex quote
This pattern matches exactly @cite{x}; variable names in @cite{x} are
not interpreted as meta-variables. The only flexibility is that
***************
*** 25709,25715 ****
as a result in this case.)
@item plain(x)
! @c @starindex
@tindex plain
Here @cite{x} must be a function call @samp{f(x1,x2,@dots{})}. This
pattern matches a call to function @cite{f} with the specified
--- 26044,26052 ----
as a result in this case.)
@item plain(x)
! @ignore
! @starindex
! @end ignore
@tindex plain
Here @cite{x} must be a function call @samp{f(x1,x2,@dots{})}. This
pattern matches a call to function @cite{f} with the specified
***************
*** 25721,25727 ****
@samp{plain(plain(@w{-a}) + plain(b c))}.
@item opt(x,def)
! @c @starindex
@tindex opt
Here @cite{x} must be a variable name. This must appear as an
argument to a function or an element of a vector; it specifies that
--- 26058,26066 ----
@samp{plain(plain(@w{-a}) + plain(b c))}.
@item opt(x,def)
! @ignore
! @starindex
! @end ignore
@tindex opt
Here @cite{x} must be a variable name. This must appear as an
argument to a function or an element of a vector; it specifies that
***************
*** 25744,25757 ****
In other words, the default @var{def} is effectively quoted.
@item condition(x,c)
! @c @starindex
@tindex condition
@tindex ::
This matches the pattern @cite{x}, with the attached condition
@cite{c}. It is the same as @samp{x :: c}.
@item pand(x,y)
! @c @starindex
@tindex pand
@tindex &&&
This matches anything that matches both pattern @cite{x} and
--- 26083,26100 ----
In other words, the default @var{def} is effectively quoted.
@item condition(x,c)
! @ignore
! @starindex
! @end ignore
@tindex condition
@tindex ::
This matches the pattern @cite{x}, with the attached condition
@cite{c}. It is the same as @samp{x :: c}.
@item pand(x,y)
! @ignore
! @starindex
! @end ignore
@tindex pand
@tindex &&&
This matches anything that matches both pattern @cite{x} and
***************
*** 25759,25779 ****
@pxref{Composing Patterns in Rewrite Rules}.
@item por(x,y)
! @c @starindex
@tindex por
@tindex |||
This matches anything that matches either pattern @cite{x} or
pattern @cite{y}. It is the same as @address@hidden ||| y}}.
@item pnot(x)
! @c @starindex
@tindex pnot
@tindex !!!
This matches anything that does not match pattern @cite{x}.
It is the same as @samp{!!! x}.
@item cons(h,t)
! @c @mindex cons
@tindex cons (rewrites)
This matches any vector of one or more elements. The first
element is matched to @cite{h}; a vector of the remaining
--- 26102,26128 ----
@pxref{Composing Patterns in Rewrite Rules}.
@item por(x,y)
! @ignore
! @starindex
! @end ignore
@tindex por
@tindex |||
This matches anything that matches either pattern @cite{x} or
pattern @cite{y}. It is the same as @address@hidden ||| y}}.
@item pnot(x)
! @ignore
! @starindex
! @end ignore
@tindex pnot
@tindex !!!
This matches anything that does not match pattern @cite{x}.
It is the same as @samp{!!! x}.
@item cons(h,t)
! @ignore
! @mindex cons
! @end ignore
@tindex cons (rewrites)
This matches any vector of one or more elements. The first
element is matched to @cite{h}; a vector of the remaining
***************
*** 25783,25796 ****
to the rule @samp{[a,b] := [a+b]}.
@item rcons(t,h)
! @c @mindex rcons
@tindex rcons (rewrites)
This is like @code{cons}, except that the @emph{last} element
is matched to @cite{h}, with the remaining elements matched
to @cite{t}.
@item apply(f,args)
! @c @mindex apply
@tindex apply (rewrites)
This matches any function call. The name of the function, in
the form of a variable, is matched to @cite{f}. The arguments
--- 26132,26149 ----
to the rule @samp{[a,b] := [a+b]}.
@item rcons(t,h)
! @ignore
! @mindex rcons
! @end ignore
@tindex rcons (rewrites)
This is like @code{cons}, except that the @emph{last} element
is matched to @cite{h}, with the remaining elements matched
to @cite{t}.
@item apply(f,args)
! @ignore
! @mindex apply
! @end ignore
@tindex apply (rewrites)
This matches any function call. The name of the function, in
the form of a variable, is matched to @cite{f}. The arguments
***************
*** 25836,25842 ****
@xref{Conditional Rewrite Rules}.
@item select(x)
! @c @starindex
@tindex select
This is used for applying rules to formulas with selections;
@pxref{Selections with Rewrite Rules}.
--- 26189,26197 ----
@xref{Conditional Rewrite Rules}.
@item select(x)
! @ignore
! @starindex
! @end ignore
@tindex select
This is used for applying rules to formulas with selections;
@pxref{Selections with Rewrite Rules}.
***************
*** 25884,25890 ****
is also a regular Calc function.
@item eval(x)
! @c @starindex
@tindex eval
The formula @cite{x} is handled in the usual way, then the
default simplifications are applied to it even if they have
--- 26239,26247 ----
is also a regular Calc function.
@item eval(x)
! @ignore
! @starindex
! @end ignore
@tindex eval
The formula @cite{x} is handled in the usual way, then the
default simplifications are applied to it even if they have
***************
*** 25895,25907 ****
whereas @samp{eval(cons(2+3, []))} will be converted to @samp{[5]}.
@item evalsimp(x)
! @c @starindex
@tindex evalsimp
The formula @cite{x} has meta-variables substituted in the usual
way, then algebraically simplified as if by the @kbd{a s} command.
@item evalextsimp(x)
! @c @starindex
@tindex evalextsimp
The formula @cite{x} has meta-variables substituted in the normal
way, then ``extendedly'' simplified as if by the @kbd{a e} command.
--- 26252,26268 ----
whereas @samp{eval(cons(2+3, []))} will be converted to @samp{[5]}.
@item evalsimp(x)
! @ignore
! @starindex
! @end ignore
@tindex evalsimp
The formula @cite{x} has meta-variables substituted in the usual
way, then algebraically simplified as if by the @kbd{a s} command.
@item evalextsimp(x)
! @ignore
! @starindex
! @end ignore
@tindex evalextsimp
The formula @cite{x} has meta-variables substituted in the normal
way, then ``extendedly'' simplified as if by the @kbd{a e} command.
***************
*** 25914,25920 ****
@table @samp
@item let(v := x)
! @c @starindex
@tindex let
The expression @cite{x} is evaluated with meta-variables substituted.
The @kbd{a s} command's simplifications are @emph{not} applied by
--- 26275,26283 ----
@table @samp
@item let(v := x)
! @ignore
! @starindex
! @end ignore
@tindex let
The expression @cite{x} is evaluated with meta-variables substituted.
The @kbd{a s} command's simplifications are @emph{not} applied by
***************
*** 25961,25967 ****
righthand side instead, but using @samp{sin(y)/b} avoids gratuitous
rearrangement of the argument of the sine.)@refill
! @c @starindex
@tindex ierf
Similarly, here is a rule that implements an address@hidden
function. It uses @code{root} to search for a solution. If
--- 26324,26332 ----
righthand side instead, but using @samp{sin(y)/b} avoids gratuitous
rearrangement of the argument of the sine.)@refill
! @ignore
! @starindex
! @end ignore
@tindex ierf
Similarly, here is a rule that implements an address@hidden
function. It uses @code{root} to search for a solution. If
***************
*** 26014,26020 ****
@code{eatfoo} is later changed to 0.
@item remember(c)
! @c @starindex
@tindex remember
Remember the match as described above, but only if condition @cite{c}
is true. For example, @samp{remember(n % 4 = 0)} in the above factorial
--- 26379,26387 ----
@code{eatfoo} is later changed to 0.
@item remember(c)
! @ignore
! @starindex
! @end ignore
@tindex remember
Remember the match as described above, but only if condition @cite{c}
is true. For example, @samp{remember(n % 4 = 0)} in the above factorial
***************
*** 26051,26057 ****
f(a +/- b, a +/- b) := g(a +/- b)
@end example
! @c @starindex
@tindex ends
Here's another interesting example:
--- 26418,26426 ----
f(a +/- b, a +/- b) := g(a +/- b)
@end example
! @ignore
! @starindex
! @end ignore
@tindex ends
Here's another interesting example:
***************
*** 26080,26086 ****
matches either @var{p1} or @var{p2}. Calc first tries matching
against @var{p1}; if that fails, it goes on to try @var{p2}.
! @c @starindex
@tindex curve
A simple example of @samp{|||} is
--- 26449,26457 ----
matches either @var{p1} or @var{p2}. Calc first tries matching
against @var{p1}; if that fails, it goes on to try @var{p2}.
! @ignore
! @starindex
! @end ignore
@tindex curve
A simple example of @samp{|||} is
***************
*** 26230,26237 ****
useful when you are first testing your rule (or just if repeated
rewriting is not what is called for by your application).
! @c @starindex
! @c @mindex address@hidden
@tindex iterations
You can also put a ``function call'' @samp{iterations(@var{n})}
in place of a rule anywhere in your rules vector (but usually at
--- 26601,26612 ----
useful when you are first testing your rule (or just if repeated
rewriting is not what is called for by your application).
! @ignore
! @starindex
! @end ignore
! @ignore
! @mindex address@hidden
! @end ignore
@tindex iterations
You can also put a ``function call'' @samp{iterations(@var{n})}
in place of a rule anywhere in your rules vector (but usually at
***************
*** 26276,26282 ****
will be disabled. A @dfn{phase schedule} controls the order in which
phases occur during the rewriting process.
! @c @starindex
@tindex phase
@vindex all
If a call to the marker function @code{phase} appears in the rules
--- 26651,26659 ----
will be disabled. A @dfn{phase schedule} controls the order in which
phases occur during the rewriting process.
! @ignore
! @starindex
! @end ignore
@tindex phase
@vindex all
If a call to the marker function @code{phase} appears in the rules
***************
*** 26290,26297 ****
numbers that appear in the rule set and executes the phases in
ascending order. For example, the rule set
- @group
@example
[ f0(x) := g0(x),
phase(1),
f1(x) := g1(x),
--- 26667,26674 ----
numbers that appear in the rule set and executes the phases in
ascending order. For example, the rule set
@example
+ @group
[ f0(x) := g0(x),
phase(1),
f1(x) := g1(x),
***************
*** 26301,26308 ****
f3(x) := g3(x),
phase(1,2),
f4(x) := g4(x) ]
- @end example
@end group
@noindent
has three phases, 1 through 3. Phase 1 consists of the @code{f0},
--- 26678,26685 ----
f3(x) := g3(x),
phase(1,2),
f4(x) := g4(x) ]
@end group
+ @end example
@noindent
has three phases, 1 through 3. Phase 1 consists of the @code{f0},
***************
*** 26327,26333 ****
The phase 2 rules do not begin until no phase 1 rules apply anywhere
in the formula.
! @c @starindex
@tindex schedule
A @code{schedule} marker appearing in the rule set (anywhere, but
conventionally at the top) changes the default schedule of phases.
--- 26704,26712 ----
The phase 2 rules do not begin until no phase 1 rules apply anywhere
in the formula.
! @ignore
! @starindex
! @end ignore
@tindex schedule
A @code{schedule} marker appearing in the rule set (anywhere, but
conventionally at the top) changes the default schedule of phases.
***************
*** 26490,26503 ****
With the Inverse flag address@hidden, this command extracts all
vector elements which do @emph{not} match the given pattern.
! @c @starindex
@tindex matches
There is also a function @samp{matches(@var{x}, @var{p})} which
evaluates to 1 if expression @var{x} matches pattern @var{p}, or
to 0 otherwise. This is sometimes useful for including into the
conditional clauses of other rewrite rules.
! @c @starindex
@tindex vmatches
The function @code{vmatches} is just like @code{matches}, except
that if the match succeeds it returns a vector of assignments to
--- 26869,26886 ----
With the Inverse flag address@hidden, this command extracts all
vector elements which do @emph{not} match the given pattern.
! @ignore
! @starindex
! @end ignore
@tindex matches
There is also a function @samp{matches(@var{x}, @var{p})} which
evaluates to 1 if expression @var{x} matches pattern @var{p}, or
to 0 otherwise. This is sometimes useful for including into the
conditional clauses of other rewrite rules.
! @ignore
! @starindex
! @end ignore
@tindex vmatches
The function @code{vmatches} is just like @code{matches}, except
that if the match succeeds it returns a vector of assignments to
***************
*** 26522,26533 ****
similarly for @samp{cos(a + b)}. The corresponding rewrite rule
set would be,
- @group
@smallexample
[ sin(a + b) := cos(a) sin(b) + sin(a) cos(b),
cos(a + b) := cos(a) cos(b) - sin(a) sin(b) ]
- @end smallexample
@end group
To apply these manually, you could put them in a variable called
@code{trigexp} and then use @kbd{a r trigexp} every time you wanted
--- 26905,26916 ----
similarly for @samp{cos(a + b)}. The corresponding rewrite rule
set would be,
@smallexample
+ @group
[ sin(a + b) := cos(a) sin(b) + sin(a) cos(b),
cos(a + b) := cos(a) cos(b) - sin(a) sin(b) ]
@end group
+ @end smallexample
To apply these manually, you could put them in a variable called
@code{trigexp} and then use @kbd{a r trigexp} every time you wanted
***************
*** 26641,26651 ****
function, or is not fixed. The rule @samp{f(n) := n f(n-1) :: n>0} will
only activate the rewrite mechanism for calls to the function @code{f},
but @samp{lg(n) + lg(m) := lg(n m)} will check every @samp{+} operator.
! And @samp{apply(f, [a*b]) := apply(f, [a]) + apply(f, [b]) ::
! in(f, [ln, log10])} may seem more ``efficient'' than two separate
! rules for @code{ln} and @code{log10}, but actually it is vastly less
! efficient because rules with @code{apply} as the top-level pattern
! must be tested against @emph{every} function call that is simplified.
@cindex @code{AlgSimpRules} variable
@vindex AlgSimpRules
--- 27024,27039 ----
function, or is not fixed. The rule @samp{f(n) := n f(n-1) :: n>0} will
only activate the rewrite mechanism for calls to the function @code{f},
but @samp{lg(n) + lg(m) := lg(n m)} will check every @samp{+} operator.
!
! @smallexample
! apply(f, [a*b]) := apply(f, [a]) + apply(f, [b]) :: in(f, [ln, log10])
! @end smallexample
!
! @noindent
! may seem more ``efficient'' than two separate rules for @code{ln} and
! @code{log10}, but actually it is vastly less efficient because rules
! with @code{apply} as the top-level pattern must be tested against
! @emph{every} function call that is simplified.
@cindex @code{AlgSimpRules} variable
@vindex AlgSimpRules
***************
*** 26729,26735 ****
stop with 15 on the stack. Once these rules are debugged, it would probably
be most useful to add them to @code{EvalRules} so that Calc will evaluate
the new @code{tri} function automatically. We could then use @kbd{Z K} on
! the keyboard macro @kbd{' tri($) RET} to make a command that applies
@code{tri} to the value on the top of the stack. @xref{Programming}.
@cindex Quaternions
--- 27117,27123 ----
stop with 15 on the stack. Once these rules are debugged, it would probably
be most useful to add them to @code{EvalRules} so that Calc will evaluate
the new @code{tri} function automatically. We could then use @kbd{Z K} on
! the keyboard macro @kbd{' tri($) @key{RET}} to make a command that applies
@code{tri} to the value on the top of the stack. @xref{Programming}.
@cindex Quaternions
***************
*** 26830,26836 ****
@kindex u s
@pindex calc-simplify-units
! @c @mindex address@hidden
@tindex usimplify
The @kbd{u s} (@code{calc-simplify-units}) address@hidden command
simplifies a units
--- 27218,27226 ----
@kindex u s
@pindex calc-simplify-units
! @ignore
! @mindex address@hidden
! @end ignore
@tindex usimplify
The @kbd{u s} (@code{calc-simplify-units}) address@hidden command
simplifies a units
***************
*** 26911,26917 ****
prompt first for the old units which this value should be considered
to have, then for the new units. Assuming the old and new units you
give are consistent with each other, the result also will not contain
! any units. For example, @address@hidden c} cm RET in RET} converts the number
2 on the stack to 5.08.
@kindex u b
--- 27301,27307 ----
prompt first for the old units which this value should be considered
to have, then for the new units. Assuming the old and new units you
give are consistent with each other, the result also will not contain
! any units. For example, @address@hidden c} cm @key{RET} in @key{RET}}
converts the number
2 on the stack to 5.08.
@kindex u b
***************
*** 27256,27276 ****
@kindex s +
@kindex s -
! @c @mindex @idots
@kindex s *
! @c @mindex @null
@kindex s /
! @c @mindex @null
@kindex s ^
! @c @mindex @null
@kindex s |
! @c @mindex @null
@kindex s n
! @c @mindex @null
@kindex s &
! @c @mindex @null
@kindex s [
! @c @mindex @null
@kindex s ]
@pindex calc-store-plus
@pindex calc-store-minus
--- 27646,27682 ----
@kindex s +
@kindex s -
! @ignore
! @mindex @idots
! @end ignore
@kindex s *
! @ignore
! @mindex @null
! @end ignore
@kindex s /
! @ignore
! @mindex @null
! @end ignore
@kindex s ^
! @ignore
! @mindex @null
! @end ignore
@kindex s |
! @ignore
! @mindex @null
! @end ignore
@kindex s n
! @ignore
! @mindex @null
! @end ignore
@kindex s &
! @ignore
! @mindex @null
! @end ignore
@kindex s [
! @ignore
! @mindex @null
! @end ignore
@kindex s ]
@pindex calc-store-plus
@pindex calc-store-minus
***************
*** 27300,27307 ****
arithmetic stores use formulas designed to behave usefully both
forwards and backwards:
- @group
@example
s + v := v + a v := a + v
s - v := v - a v := a - v
s * v := v * a v := a * v
--- 27706,27713 ----
arithmetic stores use formulas designed to behave usefully both
forwards and backwards:
@example
+ @group
s + v := v + a v := a + v
s - v := v - a v := a - v
s * v := v * a v := a * v
***************
*** 27312,27319 ****
s & v := v ^ (-1) v := (-1) ^ v
s [ v := v - 1 v := 1 - v
s ] v := v - (-1) v := (-1) - v
- @end example
@end group
In the last four cases, a numeric prefix argument will be used in
place of the number one. (For example, @kbd{M-2 s ]} increases
--- 27718,27725 ----
s & v := v ^ (-1) v := (-1) ^ v
s [ v := v - 1 v := 1 - v
s ] v := v - (-1) v := (-1) - v
@end group
+ @end example
In the last four cases, a numeric prefix argument will be used in
place of the number one. (For example, @kbd{M-2 s ]} increases
***************
*** 27456,27482 ****
@kindex s A
@kindex s D
! @c @mindex @idots
@kindex s E
! @c @mindex @null
@kindex s F
! @c @mindex @null
@kindex s G
! @c @mindex @null
@kindex s H
! @c @mindex @null
@kindex s I
! @c @mindex @null
@kindex s L
! @c @mindex @null
@kindex s P
! @c @mindex @null
@kindex s R
! @c @mindex @null
@kindex s T
! @c @mindex @null
@kindex s U
! @c @mindex @null
@kindex s X
@pindex calc-store-AlgSimpRules
@pindex calc-store-Decls
--- 27862,27910 ----
@kindex s A
@kindex s D
! @ignore
! @mindex @idots
! @end ignore
@kindex s E
! @ignore
! @mindex @null
! @end ignore
@kindex s F
! @ignore
! @mindex @null
! @end ignore
@kindex s G
! @ignore
! @mindex @null
! @end ignore
@kindex s H
! @ignore
! @mindex @null
! @end ignore
@kindex s I
! @ignore
! @mindex @null
! @end ignore
@kindex s L
! @ignore
! @mindex @null
! @end ignore
@kindex s P
! @ignore
! @mindex @null
! @end ignore
@kindex s R
! @ignore
! @mindex @null
! @end ignore
@kindex s T
! @ignore
! @mindex @null
! @end ignore
@kindex s U
! @ignore
! @mindex @null
! @end ignore
@kindex s X
@pindex calc-store-AlgSimpRules
@pindex calc-store-Decls
***************
*** 27589,27596 ****
analogous to the case of @kbd{s t @key{RET}}. @xref{Storing Variables}.
Also, you can answer the variable-name prompt with an equation or
! assignment: @kbd{s l b=3 RET} is the same as storing 3 on the stack
! and typing @kbd{s l b RET}.
The @kbd{a b} (@code{calc-substitute}) command is another way to substitute
a variable with a value in a formula. It does an actual substitution
--- 28017,28024 ----
analogous to the case of @kbd{s t @key{RET}}. @xref{Storing Variables}.
Also, you can answer the variable-name prompt with an equation or
! assignment: @kbd{s l b=3 @key{RET}} is the same as storing 3 on the stack
! and typing @kbd{s l b @key{RET}}.
The @kbd{a b} (@code{calc-substitute}) command is another way to substitute
a variable with a value in a formula. It does an actual substitution
***************
*** 27693,27711 ****
that the next command that causes Calc to look at those stack
entries will make them revert to the old variable value.
- @group
@smallexample
2: a => a 2: a => 17 2: a => a
1: a + 1 => a + 1 1: a + 1 => 18 1: a + 1 => a + 1
. . .
! 17 s l a RET p 8 RET
! @end smallexample
@end group
Here the @kbd{p 8} command changes the current precision,
thus causing the @samp{=>} forms to be recomputed after the
! influence of the ``let'' is gone. The @kbd{d SPC} command
(@code{calc-refresh}) is a handy way to force the @samp{=>}
operators on the stack to be recomputed without any other
side effects.
--- 28121,28139 ----
that the next command that causes Calc to look at those stack
entries will make them revert to the old variable value.
@smallexample
+ @group
2: a => a 2: a => 17 2: a => a
1: a + 1 => a + 1 1: a + 1 => 18 1: a + 1 => a + 1
. . .
! 17 s l a @key{RET} p 8 @key{RET}
@end group
+ @end smallexample
Here the @kbd{p 8} command changes the current precision,
thus causing the @samp{=>} forms to be recomputed after the
! influence of the ``let'' is gone. The @kbd{d @key{SPC}} command
(@code{calc-refresh}) is a handy way to force the @samp{=>}
operators on the stack to be recomputed without any other
side effects.
***************
*** 27792,27798 ****
@kbd{g N} command below. (The ``x'' values must be either a vector
or an interval if ``y'' is a formula.)
! @c @starindex
@tindex xy
If ``y'' is (or evaluates to) a formula of the form
@samp{xy(@var{x}, @var{y})} then the result is a
--- 28220,28228 ----
@kbd{g N} command below. (The ``x'' values must be either a vector
or an interval if ``y'' is a formula.)
! @ignore
! @starindex
! @end ignore
@tindex xy
If ``y'' is (or evaluates to) a formula of the form
@samp{xy(@var{x}, @var{y})} then the result is a
***************
*** 27879,27885 ****
values from ``y'' to form a matrix of results that are graphed as a
3D surface.
! @c @starindex
@tindex xyz
If the ``z'' formula evaluates to a call to the fictitious function
@samp{xyz(@var{x}, @var{y}, @var{z})}, then the result is a
--- 28309,28317 ----
values from ``y'' to form a matrix of results that are graphed as a
3D surface.
! @ignore
! @starindex
! @end ignore
@tindex xyz
If the ``z'' formula evaluates to a call to the fictitious function
@samp{xyz(@var{x}, @var{y}, @var{z})}, then the result is a
***************
*** 28218,28224 ****
last few curves will continue to have the default styles. Of course,
you can later use @kbd{g s} and @kbd{g S} to change any of these styles.
! For example, @kbd{'[2 -1 3] RET s t LineStyles} causes the first curve
to have lines in style number 2, the second curve to have no connecting
lines, and the third curve to have lines in style 3. Point styles will
still be assigned automatically, but you could store another vector in
--- 28650,28656 ----
last few curves will continue to have the default styles. Of course,
you can later use @kbd{g s} and @kbd{g S} to change any of these styles.
! For example, @kbd{'[2 -1 3] @key{RET} s t LineStyles} causes the first curve
to have lines in style number 2, the second curve to have no connecting
lines, and the third curve to have lines in style 3. Point styles will
still be assigned automatically, but you could store another vector in
***************
*** 28279,28285 ****
there is no output file and this information is not used. Many other
``devices'' are really file formats like @code{postscript}; in these
cases the output in the desired format goes into the file you name
! with @kbd{g O}. Type @kbd{g O stdout RET} to set GNUPLOT to write
to its standard output stream, i.e., to @samp{*Gnuplot Trail*}.
This is the default setting.
--- 28711,28717 ----
there is no output file and this information is not used. Many other
``devices'' are really file formats like @code{postscript}; in these
cases the output in the desired format goes into the file you name
! with @kbd{g O}. Type @kbd{g O stdout @key{RET}} to set GNUPLOT to write
to its standard output stream, i.e., to @samp{*Gnuplot Trail*}.
This is the default setting.
***************
*** 28380,28386 ****
yourself, then use @address@hidden p}} to replot using these new commands.
Note
that your commands must appear @emph{before} the @code{plot} command.
To get help on any GNUPLOT feature, type, e.g., @kbd{g C help set label}.
! You may have to type @kbd{g C RET} a few times to clear the
``press return for more'' or ``subtopic of @dots{}'' requests.
Note that Calc always sends commands (like @samp{set nolabel}) to
reset all plotting parameters to the defaults before each plot, so
--- 28812,28818 ----
yourself, then use @address@hidden p}} to replot using these new commands.
Note
that your commands must appear @emph{before} the @code{plot} command.
To get help on any GNUPLOT feature, type, e.g., @kbd{g C help set label}.
! You may have to type @kbd{g C @key{RET}} a few times to clear the
``press return for more'' or ``subtopic of @dots{}'' requests.
Note that Calc always sends commands (like @samp{set nolabel}) to
reset all plotting parameters to the defaults before each plot, so
***************
*** 28735,28742 ****
@node Keypad Main Menu, Keypad Functions Menu, Keypad Mode, Keypad Mode
@section Main Menu
- @group
@smallexample
|----+-----Calc 2.00-----+----1
|FLR |CEIL|RND |TRNC|CLN2|FLT |
|----+----+----+----+----+----|
--- 29167,29174 ----
@node Keypad Main Menu, Keypad Functions Menu, Keypad Mode, Keypad Mode
@section Main Menu
@smallexample
+ @group
|----+-----Calc 2.00-----+----1
|FLR |CEIL|RND |TRNC|CLN2|FLT |
|----+----+----+----+----+----|
***************
*** 28754,28761 ****
|-----+-----+-----+-----+-----|
| OFF | 0 | . | PI | + |
|-----+-----+-----+-----+-----+
- @end smallexample
@end group
@noindent
This is the menu that appears the first time you start Keypad Mode.
--- 29186,29193 ----
|-----+-----+-----+-----+-----|
| OFF | 0 | . | PI | + |
|-----+-----+-----+-----+-----+
@end group
+ @end smallexample
@noindent
This is the menu that appears the first time you start Keypad Mode.
***************
*** 28784,28790 ****
The @key{UNDO} key undoes the most recent Calc operation.
@kbd{INV UNDO} is the ``redo'' command, and @kbd{HYP UNDO} is
! ``last arguments'' (@kbd{M-RET}).
The @key{<-} key acts as a ``backspace'' during numeric entry.
At other times it removes the top stack entry. @kbd{INV <-}
--- 29216,29222 ----
The @key{UNDO} key undoes the most recent Calc operation.
@kbd{INV UNDO} is the ``redo'' command, and @kbd{HYP UNDO} is
! ``last arguments'' (@address@hidden).
The @key{<-} key acts as a ``backspace'' during numeric entry.
At other times it removes the top stack entry. @kbd{INV <-}
***************
*** 28866,28873 ****
@node Keypad Functions Menu, Keypad Binary Menu, Keypad Main Menu, Keypad Mode
@section Functions Menu
- @group
@smallexample
|----+----+----+----+----+----2
|IGAM|BETA|IBET|ERF |BESJ|BESY|
|----+----+----+----+----+----|
--- 29298,29305 ----
@node Keypad Functions Menu, Keypad Binary Menu, Keypad Main Menu, Keypad Mode
@section Functions Menu
@smallexample
+ @group
|----+----+----+----+----+----2
|IGAM|BETA|IBET|ERF |BESJ|BESY|
|----+----+----+----+----+----|
***************
*** 28875,28882 ****
|----+----+----+----+----+----|
|GCD |FACT|DFCT|BNOM|PERM|NXTP|
|----+----+----+----+----+----|
- @end smallexample
@end group
@noindent
This menu provides various operations from the @kbd{f} and @kbd{k}
--- 29307,29314 ----
|----+----+----+----+----+----|
|GCD |FACT|DFCT|BNOM|PERM|NXTP|
|----+----+----+----+----+----|
@end group
+ @end smallexample
@noindent
This menu provides various operations from the @kbd{f} and @kbd{k}
***************
*** 28908,28915 ****
@node Keypad Binary Menu, Keypad Vectors Menu, Keypad Functions Menu, Keypad
Mode
@section Binary Menu
- @group
@smallexample
|----+----+----+----+----+----3
|AND | OR |XOR |NOT |LSH |RSH |
|----+----+----+----+----+----|
--- 29340,29347 ----
@node Keypad Binary Menu, Keypad Vectors Menu, Keypad Functions Menu, Keypad
Mode
@section Binary Menu
@smallexample
+ @group
|----+----+----+----+----+----3
|AND | OR |XOR |NOT |LSH |RSH |
|----+----+----+----+----+----|
***************
*** 28917,28924 ****
|----+----+----+----+----+----|
| A | B | C | D | E | F |
|----+----+----+----+----+----|
- @end smallexample
@end group
@noindent
The keys in this menu perform operations on binary integers.
--- 29349,29356 ----
|----+----+----+----+----+----|
| A | B | C | D | E | F |
|----+----+----+----+----+----|
@end group
+ @end smallexample
@noindent
The keys in this menu perform operations on binary integers.
***************
*** 28941,28948 ****
@node Keypad Vectors Menu, Keypad Modes Menu, Keypad Binary Menu, Keypad Mode
@section Vectors Menu
- @group
@smallexample
|----+----+----+----+----+----4
|SUM |PROD|MAX |MAP*|MAP^|MAP$|
|----+----+----+----+----+----|
--- 29373,29380 ----
@node Keypad Vectors Menu, Keypad Modes Menu, Keypad Binary Menu, Keypad Mode
@section Vectors Menu
@smallexample
+ @group
|----+----+----+----+----+----4
|SUM |PROD|MAX |MAP*|MAP^|MAP$|
|----+----+----+----+----+----|
***************
*** 28950,28957 ****
|----+----+----+----+----+----|
|PACK|UNPK|INDX|BLD |LEN |... |
|----+----+----+----+----+----|
- @end smallexample
@end group
@noindent
The keys in this menu operate on vectors and matrices.
--- 29382,29389 ----
|----+----+----+----+----+----|
|PACK|UNPK|INDX|BLD |LEN |... |
|----+----+----+----+----+----|
@end group
+ @end smallexample
@noindent
The keys in this menu operate on vectors and matrices.
***************
*** 29023,29030 ****
@node Keypad Modes Menu, , Keypad Vectors Menu, Keypad Mode
@section Modes Menu
- @group
@smallexample
|----+----+----+----+----+----5
|FLT |FIX |SCI |ENG |GRP | |
|----+----+----+----+----+----|
--- 29455,29462 ----
@node Keypad Modes Menu, , Keypad Vectors Menu, Keypad Mode
@section Modes Menu
@smallexample
+ @group
|----+----+----+----+----+----5
|FLT |FIX |SCI |ENG |GRP | |
|----+----+----+----+----+----|
***************
*** 29032,29039 ****
|----+----+----+----+----+----|
|SWAP|RLL3|RLL4|OVER|STO |RCL |
|----+----+----+----+----+----|
- @end smallexample
@end group
@noindent
The keys in this menu manipulate modes, variables, and the stack.
--- 29464,29471 ----
|----+----+----+----+----+----|
|SWAP|RLL3|RLL4|OVER|STO |RCL |
|----+----+----+----+----+----|
@end group
+ @end smallexample
@noindent
The keys in this menu manipulate modes, variables, and the stack.
***************
*** 29211,29217 ****
The @kbd{M-# o} command is a useful way to open a Calc window
without actually selecting that window. Giving this command
verifies that @samp{2 < n} is also on the Calc stack. Typing
! @kbd{17 RET} would produce:
@example
We define $F_n = F_(n-1)+F_(n-2)$ for all $17$.
--- 29643,29649 ----
The @kbd{M-# o} command is a useful way to open a Calc window
without actually selecting that window. Giving this command
verifies that @samp{2 < n} is also on the Calc stack. Typing
! @kbd{17 @key{RET}} would produce:
@example
We define $F_n = F_(n-1)+F_(n-2)$ for all $17$.
***************
*** 29382,29392 ****
@noindent
with the second copy of the formula enabled in Embedded mode.
! You can now press @kbd{a d x RET} to take the derivative, and
@kbd{M-# d M-# d} to make two more copies of the derivative.
! To complete the computations, type @kbd{3 s l x RET} to evaluate
the last formula, then move up to the second-to-last formula
! and type @kbd{2 s l x RET}.
Finally, you would want to press @kbd{M-# e} to exit Embedded
mode, then go up and insert the necessary text in between the
--- 29814,29824 ----
@noindent
with the second copy of the formula enabled in Embedded mode.
! You can now press @kbd{a d x @key{RET}} to take the derivative, and
@kbd{M-# d M-# d} to make two more copies of the derivative.
! To complete the computations, type @kbd{3 s l x @key{RET}} to evaluate
the last formula, then move up to the second-to-last formula
! and type @kbd{2 s l x @key{RET}}.
Finally, you would want to press @kbd{M-# e} to exit Embedded
mode, then go up and insert the necessary text in between the
***************
*** 29491,29497 ****
The right thing to do is first to use a selection command (@kbd{j 2}
will do the trick) to select the righthand side of the assignment.
! Then, @kbd{17 TAB DEL} will swap the 17 into place (@pxref{Selecting
Subformulas}, to see how this works).
@kindex M-# j
--- 29923,29929 ----
The right thing to do is first to use a selection command (@kbd{j 2}
will do the trick) to select the righthand side of the assignment.
! Then, @kbd{17 @key{TAB} @key{DEL}} will swap the 17 into place
(@pxref{Selecting
Subformulas}, to see how this works).
@kindex M-# j
***************
*** 30156,30162 ****
If you give a negative numeric prefix argument to @kbd{Z E}, the keyboard
macro is edited in spelled-out keystroke form. For example, the editing
! buffer might contain the nine characters @address@hidden RET 2 +}}. When you
press
@kbd{M-# M-#}, the @code{read-kbd-macro} feature of the @file{macedit}
package is used to reinterpret these key names. The
notations @code{RET}, @code{LFD}, @code{TAB}, @code{SPC}, @code{DEL}, and
--- 30588,30594 ----
If you give a negative numeric prefix argument to @kbd{Z E}, the keyboard
macro is edited in spelled-out keystroke form. For example, the editing
! buffer might contain the nine characters @address@hidden @key{RET} 2 +}}.
When you press
@kbd{M-# M-#}, the @code{read-kbd-macro} feature of the @file{macedit}
package is used to reinterpret these key names. The
notations @code{RET}, @code{LFD}, @code{TAB}, @code{SPC}, @code{DEL}, and
***************
*** 30164,30171 ****
and @code{M-}. Spaces and line breaks are ignored. Other characters are
copied verbatim into the keyboard macro. Basically, the notation is the
same as is used in all of this manual's examples, except that the manual
! takes some liberties with spaces: When we say @kbd{' [1 2 3] RET}, we take
! it for granted that it is clear we really mean @kbd{' [1 SPC 2 SPC 3] RET},
which is what @code{read-kbd-macro} wants to address@hidden
If @file{macedit} is not available, @kbd{Z E} edits the keyboard macro
--- 30596,30603 ----
and @code{M-}. Spaces and line breaks are ignored. Other characters are
copied verbatim into the keyboard macro. Basically, the notation is the
same as is used in all of this manual's examples, except that the manual
! takes some liberties with spaces: When we say @kbd{' [1 2 3] @key{RET}}, we
take
! it for granted that it is clear we really mean @kbd{' [1 @key{SPC} 2
@key{SPC} 3] @key{RET}},
which is what @code{read-kbd-macro} wants to address@hidden
If @file{macedit} is not available, @kbd{Z E} edits the keyboard macro
***************
*** 30903,30911 ****
the @samp{*Calc Trail*} window.
@findex calc-set-command-flag
! You can call, for example, @code{(calc-set-command-flag 'no-align)} to set
! the above-mentioned command flags. The following command flags are
! recognized by Calc routines:
@table @code
@item renum-stack
--- 31335,31343 ----
the @samp{*Calc Trail*} window.
@findex calc-set-command-flag
! You can call, for example, @code{(calc-set-command-flag 'no-align)} to
! set the above-mentioned command flags. Calc routines recognize the
! following command flags:
@table @code
@item renum-stack
***************
*** 31206,31212 ****
@subsubsection Bit-Counting
@noindent
! @c @starindex
@tindex bcount
Calc does not include a built-in function for counting the number of
``one'' bits in a binary integer. It's easy to invent one using @kbd{b u}
--- 31638,31646 ----
@subsubsection Bit-Counting
@noindent
! @ignore
! @starindex
! @end ignore
@tindex bcount
Calc does not include a built-in function for counting the number of
``one'' bits in a binary integer. It's easy to invent one using @kbd{b u}
***************
*** 31246,31255 ****
involve actual division.
To gain a bit more efficiency, we could divide the integer into
! @i{n}-bit chunks, each of which can be handled quickly because
they fit into Lisp integers. It turns out that Calc's arithmetic
routines are especially fast when dividing by an integer less than
! 1000, so we can set @i{n = 9} bits and use repeated division by 512:
@smallexample
(defmath bcount ((natnum n))
--- 31680,31689 ----
involve actual division.
To gain a bit more efficiency, we could divide the integer into
! @var{n}-bit chunks, each of which can be handled quickly because
they fit into Lisp integers. It turns out that Calc's arithmetic
routines are especially fast when dividing by an integer less than
! 1000, so we can set @var{n = 9} bits and use repeated division by 512:
@smallexample
(defmath bcount ((natnum n))
***************
*** 31288,31294 ****
@subsubsection The Sine Function
@noindent
! @c @starindex
@tindex mysin
A somewhat limited sine function could be defined as follows, using the
well-known Taylor series expansion for @c{$\sin x$}
--- 31722,31730 ----
@subsubsection The Sine Function
@noindent
! @ignore
! @starindex
! @end ignore
@tindex mysin
A somewhat limited sine function could be defined as follows, using the
well-known Taylor series expansion for @c{$\sin x$}
***************
*** 32834,32840 ****
@end defun
@defun build-vector args
! Return a Calc vector with the zero-or-more @var{args} as elements.
For example, @samp{(build-vector 1 2 3)} returns the Calc vector
@samp{[1, 2, 3]}, stored internally as the list @samp{(vec 1 2 3)}.
@end defun
--- 33270,33276 ----
@end defun
@defun build-vector args
! Return a Calc vector with @var{args} as elements.
For example, @samp{(build-vector 1 2 3)} returns the Calc vector
@samp{[1, 2, 3]}, stored internally as the list @samp{(vec 1 2 3)}.
@end defun
***************
*** 33889,33895 ****
Calculator can exit.
You may also wish to test the GNUPLOT interface; to plot a sine wave,
! type @kbd{' [0 ..@: 360], sin(x) RET g f}. Type @kbd{g q} when you
are done viewing the plot.
Calc is now ready to use. If you wish to go through the Calc Tutorial,
--- 34325,34331 ----
Calculator can exit.
You may also wish to test the GNUPLOT interface; to plot a sine wave,
! type @kbd{' [0 ..@: 360], sin(x) @key{RET} g f}. Type @kbd{g q} when you
are done viewing the plot.
Calc is now ready to use. If you wish to go through the Calc Tutorial,
***************
*** 33963,33980 ****
\gdef\sumrow#1{\sumrowx#1\relax}%
\gdef\sumrowx#1\:#2\:#3\:#4\:#5\:#6\relax{%
\leavevmode%
! \hbox to5em{\indsl\hss#1}%
! \hbox to5em{\ninett#2\hss}%
! \hbox to4em{\indsl#3\hss}%
! \hbox to5em{\indrm\hss#4}%
\thinspace%
! {\ninett#5}%
! {\indsl#6}%
! }%
! \gdef\sumlpar{{\indrm(}}%
! \gdef\sumrpar{{\indrm)}}%
! \gdef\sumcomma{{\indrm,\thinspace}}%
! \gdef\sumexcl{{\indrm!}}%
\gdef\sumbreak{\vskip-2.5\baselineskip\goodbreak}%
\gdef\minus#1{{\tt-}}%
@end tex
--- 34399,34417 ----
\gdef\sumrow#1{\sumrowx#1\relax}%
\gdef\sumrowx#1\:#2\:#3\:#4\:#5\:#6\relax{%
\leavevmode%
! {\smallfonts
! \hbox to5em{\sl\hss#1}%
! \hbox to5em{\tt#2\hss}%
! \hbox to4em{\sl#3\hss}%
! \hbox to5em{\rm\hss#4}%
\thinspace%
! {\tt#5}%
! {\sl#6}%
! }}%
! \gdef\sumlpar{{\rm(}}%
! \gdef\sumrpar{{\rm)}}%
! \gdef\sumcomma{{\rm,\thinspace}}%
! \gdef\sumexcl{{\rm!}}%
\gdef\sumbreak{\vskip-2.5\baselineskip\goodbreak}%
\gdef\minus#1{{\tt-}}%
@end tex
***************
*** 33988,33994 ****
@format
@iftex
@address@hidden
- @address@hidden@ninett
@address@hidden@sumbreak
@end iftex
@r{ @: M-# a @: @: 33 @:calc-embedded-activate@:}
--- 34425,34430 ----
***************
*** 34056,34069 ****
@r{ a@: M-% @: @: @:percent@:(a) a%}
@c
! @r{ ... a@: RET @: @: 1 @:@:... a a}
! @r{ ... a@: SPC @: @: 1 @:@:... a a}
! @r{... a b@: TAB @: @: 3 @:@:... b a}
! @r{. a b c@: M-TAB @: @: 3 @:@:... b c a}
! @r{... a b@: LFD @: @: 1 @:@:... a b a}
! @r{ ... a@: DEL @: @: 1 @:@:...}
! @r{... a b@: M-DEL @: @: 1 @:@:... b}
! @r{ @: M-RET @: @: 4 @:calc-last-args@:}
@r{ a@: ` @:editing @: 1,30 @:calc-edit@:}
@c
--- 34492,34505 ----
@r{ a@: M-% @: @: @:percent@:(a) a%}
@c
! @r{ ... a@: @key{RET} @: @: 1 @:@:... a a}
! @r{ ... a@: @key{SPC} @: @: 1 @:@:... a a}
! @r{... a b@: @key{TAB} @: @: 3 @:@:... b a}
! @r{. a b c@: address@hidden @: @: 3 @:@:... b c a}
! @r{... a b@: @key{LFD} @: @: 1 @:@:... a b a}
! @r{ ... a@: @key{DEL} @: @: 1 @:@:...}
! @r{... a b@: address@hidden @: @: 1 @:@:... b}
! @r{ @: address@hidden @: @: 4 @:calc-last-args@:}
@r{ a@: ` @:editing @: 1,30 @:calc-edit@:}
@c
***************
*** 34295,34302 ****
@r{ @: d [ @: @: 4 @:calc-truncate-up@:}
@r{ @: d ] @: @: 4 @:calc-truncate-down@:}
@r{ @: d " @: @: 12,50 @:calc-display-strings@:}
! @r{ @: d SPC @: @: @:calc-refresh@:}
! @r{ @: d RET @: @: 1 @:calc-refresh-top@:}
@c
@r{ @: d 0 @: @: 50 @:calc-decimal-radix@:}
--- 34731,34738 ----
@r{ @: d [ @: @: 4 @:calc-truncate-up@:}
@r{ @: d ] @: @: 4 @:calc-truncate-down@:}
@r{ @: d " @: @: 12,50 @:calc-display-strings@:}
! @r{ @: d @key{SPC} @: @: @:calc-refresh@:}
! @r{ @: d @key{RET} @: @: 1 @:calc-refresh-top@:}
@c
@r{ @: d 0 @: @: 50 @:calc-decimal-radix@:}
***************
*** 34432,34439 ****
@c
@r{ @: j 1-9 @: @: @:calc-select-part@:}
! @r{ @: j RET @: @: 27 @:calc-copy-selection@:}
! @r{ @: j DEL @: @: 27 @:calc-del-selection@:}
@r{ @: j ' @:formula @: 27 @:calc-enter-selection@:}
@r{ @: j ` @:editing @: 27,30 @:calc-edit-selection@:}
@r{ @: j " @: @: 7,27 @:calc-sel-expand-formula@:}
--- 34868,34875 ----
@c
@r{ @: j 1-9 @: @: @:calc-select-part@:}
! @r{ @: j @key{RET} @: @: 27
@:calc-copy-selection@:}
! @r{ @: j @key{DEL} @: @: 27 @:calc-del-selection@:}
@r{ @: j ' @:formula @: 27 @:calc-enter-selection@:}
@r{ @: j ` @:editing @: 27,30 @:calc-edit-selection@:}
@r{ @: j " @: @: 7,27 @:calc-sel-expand-formula@:}
***************
*** 34814,34820 ****
Positive prefix arguments apply to @cite{n} stack entries.
Negative prefix arguments apply to the @cite{-n}th stack entry.
A prefix of zero applies to the entire stack. (For @key{LFD} and
! @kbd{M-DEL}, the meaning of the sign is reversed.)
@c 2
@item
--- 35250,35256 ----
Positive prefix arguments apply to @cite{n} stack entries.
Negative prefix arguments apply to the @cite{-n}th stack entry.
A prefix of zero applies to the entire stack. (For @key{LFD} and
! @address@hidden, the meaning of the sign is reversed.)
@c 2
@item
***************
*** 34925,34932 ****
@c 20
@item
! With a prefix argument of 1, take a single @c{$N\times2$}
! @asis{Nx2} matrix from the
stack instead of two separate data vectors.
@c 21
--- 35361,35368 ----
@c 20
@item
! With a prefix argument of 1, take a single @address@hidden
! @address@hidden matrix from the
stack instead of two separate data vectors.
@c 21
***************
*** 35135,35141 ****
Press @kbd{?} repeatedly to see how to choose a model. Answer the
variables prompt with @cite{iv} or @cite{iv;pv} to specify
independent and parameter variables. A positive prefix argument
! takes @i{N+1} vectors from the stack; a zero prefix takes a matrix
and a vector from the stack.
@c 49
--- 35571,35577 ----
Press @kbd{?} repeatedly to see how to choose a model. Answer the
variables prompt with @cite{iv} or @cite{iv;pv} to specify
independent and parameter variables. A positive prefix argument
! takes @address@hidden vectors from the stack; a zero prefix takes a matrix
and a vector from the stack.
@c 49
- [Emacs-diffs] Changes to emacs/man/calc.texi,
Richard M. Stallman <=