home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-11-01 | 55.5 KB | 1,525 lines |
- Newsgroups: comp.sources.misc
- From: daveg@synaptics.com (David Gillespie)
- Subject: v24i088: gnucalc - GNU Emacs Calculator, v2.00, Part40/56
- Message-ID: <1991Nov1.183620.20727@sparky.imd.sterling.com>
- X-Md4-Signature: 6ad8483a57dad31381f25e9c86e0cfb3
- Date: Fri, 1 Nov 1991 18:36:20 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: daveg@synaptics.com (David Gillespie)
- Posting-number: Volume 24, Issue 88
- Archive-name: gnucalc/part40
- Environment: Emacs
- Supersedes: gmcalc: Volume 13, Issue 27-45
-
- ---- Cut Here and unpack ----
- #!/bin/sh
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file calc.texinfo continued
- #
- if test ! -r _shar_seq_.tmp; then
- echo 'Please unpack part 1 first!'
- exit 1
- fi
- (read Scheck
- if test "$Scheck" != 40; then
- echo Please unpack part "$Scheck" next!
- exit 1
- else
- exit 0
- fi
- ) < _shar_seq_.tmp || exit 1
- if test ! -f _shar_wnt_.tmp; then
- echo 'x - still skipping calc.texinfo'
- else
- echo 'x - continuing file calc.texinfo'
- sed 's/^X//' << 'SHAR_EOF' >> 'calc.texinfo' &&
- The @kbd{d b} (@code{calc-line-breaking}) command turns this line-breaking
- feature on and off. (It works independently of the current language.)
- If you give a numeric prefix argument of five or greater to the @kbd{d b}
- command, that argument will specify the line width used when breaking
- long lines.
- X
- @kindex d B
- @pindex calc-big-language
- The @kbd{d B} (@code{calc-big-language}) command selects a language
- which uses textual approximations to various mathematical notations,
- such as powers, quotients, and square roots:
- X
- @example
- X ____________
- X | a + 1 2
- X | ----- + c
- \| b
- @end example
- X
- @noindent
- in place of @samp{sqrt((a+1)/b + c^2)}.
- X
- Subscripts like @samp{a_i} are displayed as actual subscripts in ``big''
- mode. Double subscripts, @samp{a_i_j} (@samp{subscr(subscr(a, i), j)})
- are displayed as @samp{a} with subscripts separated by commas:
- @samp{i, j}. They must still be entered in the usual underscore
- notation.
- X
- One slight ambiguity of Big notation is that
- X
- @example
- X 3
- - -
- X 4
- @end example
- X
- @noindent
- can represent either the negative rational number @cite{-3:4}, or the
- actual expression @samp{-(3/4)}; but the latter formula would normally
- never be displayed because it would immediately be evaluated to
- @cite{-3:4} or @cite{-0.75}, so this ambiguity is not a problem in
- typical use.
- X
- Non-decimal numbers are displayed with subscripts. Thus there is no
- way to tell the difference between @samp{16#C2} and @samp{C2_16},
- though generally you will know which interpretation is correct.
- Logarithms @samp{log(x,b)} and @samp{log10(x)} also use subscripts
- in Big mode.
- X
- In Big mode, stack entries often take up several lines. To aid
- readability, stack entries are separated by a blank line in this mode.
- You may find it useful to expand the Calc window's height using
- @kbd{C-x ^} (@code{enlarge-window}) or to make the Calc window the only
- one on the screen with @kbd{C-x 1} (@code{delete-other-windows}).
- X
- Long lines are currently not rearranged to fit the window width in
- Big mode, so you may need to use the @kbd{<} and @kbd{>} keys
- to scroll across a wide formula. For really big formulas, you may
- even need to use @kbd{@{} and @kbd{@}} to scroll up and down.
- X
- @kindex d U
- @pindex calc-unformatted-language
- The @kbd{d U} (@code{calc-unformatted-language}) command altogether disables
- the use of operator notation in formulas. In this mode, the formula
- shown above would be displayed:
- X
- @example
- sqrt(add(div(add(a, 1), b), pow(c, 2)))
- @end example
- X
- These four modes differ only in display format, not in the format
- expected for algebraic entry. The standard Calc operators work in
- all four modes, and unformatted notation works in any language mode
- (except that Mathematica mode expects square brackets instead of
- parentheses).
- X
- @node C FORTRAN Pascal, TeX Language Mode, Normal Language Modes, Language Modes
- @subsection C, FORTRAN, and Pascal Modes
- X
- @noindent
- @kindex d C
- @pindex calc-c-language
- @cindex C language
- The @kbd{d C} (@code{calc-c-language}) command selects the conventions
- of the C language for display and entry of formulas. This differs from
- the normal language mode in a variety of (mostly minor) ways. In
- particular, C language operators and operator precedences are used in
- place of Calc's usual ones. For example, @samp{a^b} means @samp{xor(a,b)}
- in C mode; a value raised to a power is written as a function call,
- @samp{pow(a,b)}.
- X
- In C mode, vectors and matrices use curly braces instead of brackets.
- Octal and hexadecimal values are written with leading @samp{0} or @samp{0x}
- rather than using the @samp{#} symbol. Array subscripting is
- translated into @code{subscr} calls, so that @samp{a[i]} in C
- mode is the same as @samp{a_i} in normal mode. Assignments
- turn into the @code{assign} function, which Calc normally displays
- using the @samp{:=} symbol even though the @code{assign} function is
- not given any actual meaning by the rest of Calc (except for rewrite
- rules and Embedded Mode).
- X
- The variables @code{var-pi} and @code{var-e} would be displayed @samp{pi}
- and @samp{e} in normal mode, but in C mode they are displayed as
- @samp{M_PI} and @samp{M_E}, corresponding to the names of constants
- typically provided in the @file{<math.h>} header. Functions whose
- names are different in C are translated automatically for entry and
- display purposes. For example, entering @samp{asin(x)} will push the
- formula @samp{arcsin(x)} onto the stack; this formula will be displayed
- as @samp{asin(x)} as long as C mode is in effect.
- X
- @kindex d P
- @pindex calc-pascal-language
- @cindex Pascal language
- The @kbd{d P} (@code{calc-pascal-language}) command selects Pascal
- conventions. Like C mode, Pascal mode interprets array brackets and uses
- a different table of operators. Hexadecimal numbers are entered and
- displayed with a preceding dollar sign. (Thus the regular meaning of
- @kbd{$2} during algebraic entry does not work in Pascal mode, though
- @kbd{$} (and @kbd{$$}, etc.) not followed by digits works the same as
- always.) No special provisions are made for other non-decimal numbers,
- vectors, and so on, since there is no universally accepted standard way
- of handling these in Pascal.
- X
- @kindex d F
- @pindex calc-fortran-language
- @cindex FORTRAN language
- The @kbd{d F} (@code{calc-fortran-language}) command selects FORTRAN
- conventions. Various function names are transformed into FORTRAN
- equivalents. Vectors are written as @samp{/1, 2, 3/}, and may be
- entered this way or using square brackets. Since FORTRAN uses round
- parentheses for both function calls and array subscripts, Calc displays
- both in the same way; @samp{a(i)} is interpreted as a function call
- upon reading, and subscripts must be entered as @samp{subscr(a, i)}.
- However, you can almost always enter @samp{a(i)} and it will work
- just as well as a subscript, as long as the array name @samp{a} doesn't
- accidentally correspond to any built-in one-argument Calc function.
- (Another time that the distinction could matter is when you are planning
- to switch the expression to another language like Pascal after entering
- it in FORTRAN.)
- X
- Underscores are allowed in variable names in all of these language
- modes. The underscore here is equivalent to the @samp{#} in normal
- mode, or to hyphens in the underlying Emacs Lisp variable names.
- X
- FORTRAN and Pascal modes normally do not adjust the case of letters in
- formulas. Most built-in Calc names use lower-case letters. If you use a
- positive numeric prefix argument with @kbd{d P} or @kbd{d F}, these
- modes will use upper-case letters exclusively for display, and will
- convert to lower-case on input. With a negative prefix, these modes
- convert to lower-case for display and input.
- X
- @node TeX Language Mode, Eqn Language Mode, C FORTRAN Pascal, Language Modes
- @subsection @TeX{} Language Mode
- X
- @noindent
- @kindex d T
- @pindex calc-tex-language
- @cindex TeX language
- The @kbd{d T} (@code{calc-tex-language}) command selects the conventions
- of ``math mode'' in the @TeX{} typesetting language, by Donald Knuth.
- Formulas are entered
- and displayed in @TeX{} notation, as in @samp{\sin\left( a \over b \right)}.
- Math formulas are usually enclosed by @samp{$ $} signs in @TeX{}; these
- should be omitted when interfacing with Calc. To Calc, the @samp{$} sign
- has the same meaning it always does in algebraic formulas (a reference to
- an existing entry on the stack).@refill
- X
- Complex numbers are displayed as in @samp{3 + 4i}. Fractions and
- quotients are written using @code{\over};
- binomial coefficients are written with @code{\choose}.
- Interval forms are written with @code{\ldots}, and
- error forms are written with @code{\pm}.
- Absolute values are written as in @samp{|x + 1|}, and the floor and
- ceiling functions are written with @code{\lfloor}, @code{\rfloor}, etc.
- The words @code{\left} and @code{\right} are ignored when reading
- formulas in @TeX{} mode. Both @code{inf} and @code{uinf} are written
- as @code{\infty}; when read, @code{\infty} always translates to
- @code{inf}.@refill
- X
- Function calls are written the usual way, with the function name followed
- by the arguments in parentheses. However, functions for which @TeX{} has
- special names (like @code{\sin}) will use curly braces instead of
- parentheses for very simple arguments. During input, curly braces and
- parentheses work equally well for grouping, but when the document is
- formatted the curly braces will be invisible. Thus the printed result is
- @c{$\sin{2 x}$}
- @cite{sin 2x} but @c{$\sin(2 + x)$}
- @cite{sin(2 + x)}.
- X
- Function and variable names not treated specially by @TeX{} are simply
- written out as-is, which will cause them to come out in italic letters
- in the printed document. If you invoke @kbd{d T} with a positive numeric
- prefix argument, names of more than one character will instead be written
- @samp{\hbox@{@var{name}@}}. The @samp{\hbox@{ @}} notation is ignored
- during reading. If you use a negative prefix argument, such function
- names are written @samp{\@var{name}}, and function names that begin
- with @code{\} during reading have the @code{\} removed. (Note that
- in this mode, long variable names are still written with @code{\hbox}.
- However, you can always make an actual variable name like @code{\bar}
- in any @TeX{} mode.)
- X
- During reading, text of the form @samp{\matrix@{ ...@: @}} is replaced
- by @samp{[ ...@: ]}. The same also applies to @code{\pmatrix} and
- @code{\bmatrix}. The symbol @samp{&} is interpreted as a comma,
- and the symbols @samp{\cr} and @samp{\\} are interpreted as semicolons.
- During output, matrices are displayed in @samp{\matrix@{ a & b \\ c & d@}}
- format; you may need to edit this afterwards to change @code{\matrix}
- to @code{\pmatrix} or @code{\\} to @code{\cr}.
- X
- Accents like @code{\tilde} and @code{\bar} translate into function
- calls internally (@samp{tilde(x)}, @samp{bar(x)}). The @code{\underline}
- sequence is treated as an accent. The @code{\vec} accent corresponds
- to the function name @code{Vec}, because @code{vec} is the name of
- a built-in Calc function. The following table shows the accents
- in Calc, @TeX{}, and @dfn{eqn} (described in the next section):
- X
- @tindex acute
- @tindex bar
- @tindex breve
- @tindex check
- @tindex dot
- @tindex dotdot
- @tindex dyad
- @tindex grave
- @tindex hat
- @tindex Prime
- @tindex tilde
- @tindex under
- @tindex Vec
- @example
- Calc TeX eqn
- ---- --- ---
- acute \acute
- bar \bar bar
- breve \breve
- check \check
- dot \dot dot
- dotdot \ddot dotdot
- dyad dyad
- grave \grave
- hat \hat hat
- Prime prime
- tilde \tilde tilde
- under \underline under
- Vec \vec vec
- @end example
- X
- The @samp{=>} (evaluates-to) operator appears as a @code{\to} symbol:
- @samp{@{@var{a} \to @var{b}@}}. @TeX{} defines @code{\to} as an
- alias for @code{\rightarrow}. However, if the @samp{=>} is the
- top-level expression being formatted, a slightly different notation
- is used: @samp{\evalto @var{a} \to @var{b}}. The @code{\evalto}
- word is ignored by Calc's input routines, and is undefined in @TeX{}.
- You will typically want to include one of the following definitions
- at the top of a @TeX{} file that uses @code{\evalto}:
- X
- @example
- \def\evalto@{@}
- \def\evalto#1\to@{@}
- @end example
- X
- The first definition formats evaluates-to operators in the usual
- way. The second causes only the @var{b} part to appear in the
- printed document; the @var{a} part and the arrow are hidden.
- Another definition you may wish to use is @samp{\let\to=\Rightarrow}
- which causes @code{\to} to appear more like Calc's @samp{=>} symbol.
- @xref{Evaluates-To Operator}, for a discussion of @code{evalto}.
- X
- The complete set of @TeX{} control sequences that are ignored during
- reading is:
- X
- @example
- \hbox \mbox \text \left \right
- \, \> \: \; \! \quad \qquad \hfil \hfill
- \displaystyle \textstyle \dsize \tsize
- \scriptstyle \scriptscriptstyle \ssize \ssize
- \rm \bf \it \sl \roman \bold \italic \slanted
- \cal \mit \Cal \Bbb \frak \goth
- \evalto
- @end example
- X
- Note that, because these symbols are ignored, reading a @TeX{} formula
- into Calc and writing it back out may lose spacing and font information.
- X
- Also, the ``discretionary multiplication sign'' @samp{\*} is read
- the same as @samp{*}.
- X
- @ifinfo
- The @TeX{} version of this manual includes some printed examples at the
- end of this section.
- @end ifinfo
- @iftex
- Here are some examples of how various Calc formulas are formatted in @TeX{}:
- X
- @group
- @example
- sin(a^2 / subscr(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
- X
- @group
- @example
- [(3, 4), 3:4, 3 +/- 4, [3 .. inf)]
- [3 + 4i, @{3 \over 4@}, 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
- X
- @group
- @example
- [abs(a), abs(a / b), floor(a), ceil(a / b)]
- [|a|, \left| a \over b \right|,
- X \lfloor a \rfloor, \left\lceil a \over b \right\rceil]
- @end example
- @tex
- $$ [|a|, \left| a \over b \right|,
- X \lfloor a \rfloor, \left\lceil a \over b \right\rceil] $$
- @end tex
- @sp 1
- @end group
- X
- @group
- @example
- [sin(a), sin(2 a), sin(2 + a), sin(a / b)]
- [\sin@{a@}, \sin@{2 a@}, \sin(2 + a),
- X \sin\left( @{a \over b@} \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
- X
- @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
- @samp{\def\foo#1@{\tilde F(#1)@}}:
- X
- @example
- [f(a), foo(bar), sin(pi)]
- [f(a), foo(bar), \sin{\pi}]
- [f(a), \hbox@{foo@}(\hbox@{bar@}), \sin@{\pi@}]
- [f(a), \foo@{\hbox@{bar@}@}, \sin@{\pi@}]
- @end example
- @tex
- \let\rm\goodrm
- $$ [f(a), foo(bar), \sin{\pi}] $$
- $$ [f(a), \hbox{foo}(\hbox{bar}), \sin{\pi}] $$
- $$ [f(a), \tilde F(\hbox{bar}), \sin{\pi}] $$
- @end tex
- @sp 2
- @end group
- X
- @group
- First with @samp{\def\evalto@{@}}, then with @samp{\def\evalto#1\to@{@}}:
- X
- @example
- 2 + 3 => 5
- \evalto 2 + 3 \to 5
- @end example
- @tex
- \turnoffactive
- $$ 2 + 3 \to 5 $$
- $$ 5 $$
- @end tex
- @sp 2
- @end group
- X
- @group
- First with standard @code{\to}, then with @samp{\let\to\Rightarrow}:
- X
- @example
- [2 + 3 => 5, a / 2 => (b + c) / 2]
- [@{2 + 3 \to 5@}, @{@{a \over 2@} \to @{b + c \over 2@}@}]
- @end example
- @tex
- \turnoffactive
- $$ [{2 + 3 \to 5}, {{a \over 2} \to {b + c \over 2}}] $$
- {\let\to\Rightarrow
- $$ [{2 + 3 \to 5}, {{a \over 2} \to {b + c \over 2}}] $$}
- @end tex
- @sp 2
- @end group
- X
- @group
- Matrices normally, then changing @code{\matrix} to @code{\pmatrix}:
- X
- @example
- [ [ a / b, 0 ], [ 0, 2^(x + 1) ] ]
- \matrix@{ @{a \over b@} & 0 \\ 0 & 2^@{(x + 1)@} @}
- \pmatrix@{ @{a \over b@} & 0 \\ 0 & 2^@{(x + 1)@} @}
- @end example
- @tex
- \turnoffactive
- $$ \matrix{ {a \over b} & 0 \cr 0 & 2^{(x + 1)} } $$
- $$ \pmatrix{ {a \over b} & 0 \cr 0 & 2^{(x + 1)} } $$
- @end tex
- @sp 2
- @end group
- @end iftex
- X
- @node Eqn Language Mode, Mathematica Language Mode, TeX Language Mode, Language Modes
- @subsection Eqn Language Mode
- X
- @noindent
- @kindex d E
- @pindex calc-eqn-language
- @dfn{Eqn} is another popular formatter for math formulas. It is
- designed for use with the TROFF text formatter, and comes standard
- with many versions of Unix. The @kbd{d E} (@code{calc-eqn-language})
- command selects @dfn{eqn} notation.
- X
- The @dfn{eqn} language's main idiosyncrasy is that whitespace plays
- a significant part in the parsing of the language. For example,
- @samp{sqrt x+1 + y} treats @samp{x+1} as the argument of the
- @code{sqrt} operator. @dfn{Eqn} also understands more conventional
- grouping using curly braces: @samp{sqrt@{x+1@} + y}. Braces are
- required only when the argument contains spaces.
- X
- In Calc's @dfn{eqn} mode, however, curly braces are required to
- delimit arguments of operators like @code{sqrt}. The first of the
- above examples would treat only the @samp{x} as the argument of
- @code{sqrt}, and in fact @samp{sin x+1} would be interpreted as
- @samp{sin * x + 1}, because @code{sin} is not a special operator
- in the @dfn{eqn} language. If you always surround the argument
- with curly braces, Calc will never misunderstand.
- X
- Calc also understands parentheses as grouping characters. Another
- peculiarity of @dfn{eqn}'s syntax makes it advisable to separate
- words with spaces from any surrounding characters that aren't curly
- braces, so Calc writes @samp{sin ( x + y )} in @dfn{eqn} mode.
- (The spaces around @code{sin} are important to make @dfn{eqn}
- recognize that @code{sin} should be typeset in a roman font, and
- the spaces around @code{x} and @code{y} are a good idea just in
- case the @dfn{eqn} document has defined special meanings for these
- names, too.)
- X
- Powers and subscripts are written with the @code{sub} and @code{sup}
- operators, respectively. Note that the caret symbol @samp{^} is
- treated the same as a space in @dfn{eqn} mode, as is the @samp{~}
- symbol (these are used to introduce spaces of various widths into
- the typeset output of @dfn{eqn}).
- X
- As in @TeX{} mode, Calc's formatter omits parentheses around the
- arguments of functions like @code{ln} and @code{sin} if they are
- ``simple-looking''; in this case Calc surrounds the argument with
- braces, separated by a @samp{~} from the function name: @samp{sin~@{x@}}.
- X
- Font change codes (like @samp{roman @var{x}}) and positioning codes
- (like @samp{~} and @samp{down @var{n} @var{x}}) are ignored by the
- @dfn{eqn} reader. Also ignored are the words @code{left}, @code{right},
- @code{mark}, and @code{lineup}. Quotation marks in @dfn{eqn} mode input
- are treated the same as curly braces: @samp{sqrt "1+x"} is equivalent to
- @samp{sqrt @{1+x@}}; this is only an approximation to the true meaning
- of quotes in @dfn{eqn}, but it is good enough for most uses.
- X
- Accent codes (@samp{@var{x} dot}) are handled by treating them as
- function calls (@samp{dot(@var{x})}) internally. @xref{TeX Language
- Mode} for a table of these accent functions. The @code{prime} accent
- is treated specially if it occurs on a variable or function name:
- @samp{f prime prime ( x prime )} is stored internally as @samp{f''(x')}.
- For example, taking the derivative of @samp{f(2 x)} with @kbd{a d x}
- will produce @samp{2 f'(2 x)}, which @dfn{eqn} mode will display as
- @samp{2 f prime ( 2 x )}.
- X
- Assignments are written with the @samp{<-} (left-arrow) symbol,
- and @code{evalto} operators are written with @samp{->} or
- @samp{evalto ... ->} (@pxref{TeX Language Mode}, for a discussion
- of this). The regular Calc symbols @samp{:=} and @samp{=>} are also
- recognized for these operators during reading.
- X
- Vectors in @dfn{eqn} mode use regular Calc square brackets, but
- matrices are formatted as @samp{matrix @{ ccol @{ a above b @} ... @}}.
- The words @code{lcol} and @code{rcol} are recognized as synonyms
- for @code{ccol} during input, and are generated instead of @code{ccol}
- if the matrix justification mode so specifies.
- X
- @node Mathematica Language Mode, Maple Language Mode, Eqn Language Mode, Language Modes
- @subsection Mathematica Language Mode
- X
- @noindent
- @kindex d M
- @pindex calc-mathematica-language
- @cindex Mathematica language
- The @kbd{d M} (@code{calc-mathematica-language}) command selects the
- conventions of Mathematica, a powerful and popular mathematical tool
- from Wolfram Research, Inc. Notable differences in Mathematica mode
- are that the names of built-in functions are capitalized, and function
- calls use square brackets instead of parentheses. Thus the Calc
- formula @samp{sin(2 x)} is entered and displayed @samp{Sin[2 x]} in
- Mathematica mode.
- X
- Vectors and matrices use curly braces in Mathematica. Complex numbers
- are written @samp{3 + 4 I}. The standard special constants in Calc are
- written @code{Pi}, @code{E}, @code{I}, @code{GoldenRatio}, @code{EulerGamma},
- @code{Infinity}, @code{ComplexInfinity}, and @code{Indeterminate} in
- Mathematica mode.
- Non-decimal numbers are written, e.g., @samp{16^^7fff}. Floating-point
- numbers in scientific notation are written @samp{1.23*10.^3}.
- Subscripts use double square brackets: @samp{a[[i]]}.@refill
- X
- @node Maple Language Mode, Compositions, Mathematica Language Mode, Language Modes
- @subsection Maple Language Mode
- X
- @noindent
- @kindex d W
- @pindex calc-maple-language
- @cindex Maple language
- The @kbd{d W} (@code{calc-maple-language}) command selects the
- conventions of Maple, another mathematical tool from the University
- of Waterloo.
- X
- Maple's language is much like C. Underscores are allowed in symbol
- names; square brackets are used for subscripts; explicit @samp{*}s for
- multiplications are required. Use either @samp{^} or @samp{**} to
- denote powers.
- X
- Maple uses square brackets for lists and curly braces for sets. Calc
- interprets both notations as vectors, and displays vectors with square
- brackets. This means Maple sets will be converted to lists when they
- pass through Calc. As a special case, matrices are written as calls
- to the function @code{matrix}, given a list of lists as the argument,
- and can be read in this form or with all-capitals @code{MATRIX}.
- X
- The Maple interval notation @samp{2 .. 3} has no surrounding brackets;
- Calc reads @samp{2 .. 3} as the closed interval @samp{[2 .. 3]}, and
- writes any kind of interval as @samp{2 .. 3}. This means you cannot
- see the difference between an open and a closed interval while in
- Maple display mode.
- X
- Maple writes complex numbers as @samp{3 + 4*I}. Its special constants
- are @code{Pi}, @code{E}, @code{I}, and @code{infinity} (all three of
- @code{inf}, @code{uinf}, and @code{nan} display as @code{infinity}).
- Floating-point numbers are written @samp{1.23*10.^3}.
- X
- Among things not currently handled by Calc's Maple mode are the
- various quote symbols, procedures and functional operators, and
- inert (@samp{&}) operators.
- X
- @node Compositions, , Maple Language Mode, Language Modes
- @subsection Compositions
- X
- @noindent
- @cindex Compositions
- There are several @dfn{composition functions} which allow you to get
- displays in a variety of formats similar to those in Big language
- mode. Most of these functions do not evaluate to anything; they are
- placeholders which are left in symbolic form by Calc's evaluator but
- are recognized by Calc's display formatting routines.
- X
- Two of these, @code{string} and @code{bstring}, are described elsewhere.
- @xref{Strings}. For example, @samp{string("ABC")} is displayed as
- @samp{ABC}. When viewed on the stack it will be indistinguishable from
- the variable @code{ABC}, but internally it will be stored as
- @samp{string([65, 66, 67])} and can still be manipulated this way; for
- example, the selection and vector commands @kbd{j 1 v v j u} would
- select the vector portion of this object and reverse the elements, then
- deselect to reveal a string whose characters have been reversed.
- X
- The composition functions do the same thing in all language modes
- (although their components will of course be formatted in the current
- language mode). The one exception is Unformatted mode (@kbd{d U}),
- which does not give the composition functions any special treatment.
- The functions are discussed here because of their relationship to
- the language modes.
- X
- @menu
- * Composition Basics::
- * Horizontal Compositions::
- * Vertical Compositions::
- * Other Compositions::
- * Information about Compositions::
- * User-Defined Compositions::
- @end menu
- X
- @node Composition Basics, Horizontal Compositions, Compositions, Compositions
- @subsubsection Compositions
- X
- @noindent
- Compositions are generally formed by stacking formulas together
- horizontally or vertically in various ways. Those formulas are
- themselves compositions. @TeX{} users will find this analogous
- to @TeX{}'s ``boxes.'' Each multi-line composition has a
- @dfn{baseline}; horizontal compositions use the baselines to
- decide how formulas should be positioned relative to one another.
- For example, in the Big mode formula
- X
- @group
- @example
- X 2
- X a + b
- 17 + ------
- X c
- @end example
- @end group
- X
- @noindent
- the second term of the sum is four lines tall and has line three as
- its baseline. Thus when the term is combined with 17, line three
- is placed on the same level as the baseline of 17.
- X
- @tex
- \bigskip
- @end tex
- X
- Another important composition concept is @dfn{precedence}. This is
- an integer that represents the binding strength of various operators.
- For example, @samp{*} has higher precedence (195) than @samp{+} (180),
- which means that @samp{(a * b) + c} will be formatted without the
- parentheses, but @samp{a * (b + c)} will keep the parentheses.
- X
- The operator table used by normal and Big language modes has the
- following precedences:
- X
- @example
- _ 1200 @r{(subscripts)}
- % 1100 @r{(as in n}%@r{)}
- - 1000 @r{(as in }-@r{n)}
- ! 1000 @r{(as in }!@r{n)}
- mod 400
- +/- 300
- !! 210 @r{(as in n}!!@r{)}
- ! 210 @r{(as in n}!@r{)}
- ^ 200
- * 195 @r{(or implicit multiplication)}
- / % \ 190
- + - 180 @r{(as in a}+@r{b)}
- | 170
- < = 160 @r{(and other relations)}
- && 110
- || 100
- ? : 90
- !!! 85
- &&& 80
- ||| 75
- := 50
- :: 45
- => 40
- @end example
- X
- The general rule is that if an operator with precedence @cite{n}
- occurs as an argument to an operator with precedence @cite{m}, then
- the argument is enclosed in parentheses if @cite{n < m}. Top-level
- expressions and expressions which are function arguments, vector
- components, etc., are formatted with precedence zero (so that they
- normally never get additional parentheses).
- X
- For binary left-associative operators like @samp{+}, the righthand
- argument is actually formatted with one-higher precedence than shown
- in the table. This makes sure @samp{(a + b) + c} omits the parentheses,
- but the unnatural form @samp{a + (b + c)} keeps its parentheses.
- Right-associative operators like @samp{^} format the lefthand argument
- with one-higher precedence.
- X
- @tindex cprec
- The @code{cprec} function formats an expression with an arbitrary
- precedence. For example, @samp{cprec(abc, 185)} will combine into
- sums and products as follows: @samp{7 + abc}, @samp{7 (abc)} (because
- this @code{cprec} form has higher precedence than addition, but lower
- precedence than multiplication).
- X
- @tex
- \bigskip
- @end tex
- X
- A final composition issue is @dfn{line breaking}. Calc uses two
- different strategies for ``flat'' and ``non-flat'' compositions.
- A non-flat composition is anything that appears on multiple lines
- (not counting line breaking). Examples would be matrices, and Big
- mode powers and quotients. Non-flat compositions are displayed
- exactly as specified. If they come out wider than the current
- window, you must use horizontal scrolling (@kbd{<} and @kbd{>}) to
- view them.
- X
- Flat compositions, on the other hand, will be broken across several
- lines if they are too wide to fit the window. Certain points in a
- composition are noted internally as @dfn{break points}. Calc's
- general strategy is to fill each line as much as possible, then to
- move down to the next line starting at the first break point that
- didn't fit. However, the line breaker understands the hierarchical
- structure of formulas. It will not break an ``inner'' formula if
- it can use an earlier break point from an ``outer'' formula instead.
- For example, a vector of sums might be formatted as:
- X
- @group
- @example
- [ a + b + c, d + e + f,
- X g + h + i, j + k + l, m ]
- @end example
- @end group
- X
- @noindent
- If the @samp{m} can fit, then so, it seems, could the @samp{g}.
- But Calc prefers to break at the comma since the comma is part
- of a ``more outer'' formula. Calc would break at a plus sign
- only if it had to, say, if the very first sum in the vector had
- itself been too large to fit.
- X
- Of the composition functions described below, only @code{choriz}
- generates break points. The @code{bstring} function (@pxref{Strings})
- also generates breakable items: A break point is added after every
- space (or group of spaces) except for spaces at the very beginning or
- end of the string.
- X
- Composition functions themselves count as levels in the formula
- hierarchy, so a @code{choriz} that is a component of a larger
- @code{choriz} will be less likely to be broken. As a special case,
- if a @code{bstring} occurs as a component of a @code{choriz} or
- @code{choriz}-like object (such as a vector or a list of arguments
- in a function call), then the break points in that @code{bstring}
- will be on the same level as the break points of the surrounding
- object.
- X
- @node Horizontal Compositions, Vertical Compositions, Composition Basics, Compositions
- @subsubsection Horizontal Compositions
- X
- @noindent
- @tindex choriz
- The @code{choriz} function takes a vector of objects and composes
- them horizontally. For example, @samp{choriz([17, a b/c, d])} formats
- as @w{@samp{17a b / cd}} in normal language mode, or as
- X
- @group
- @example
- X a b
- 17---d
- X c
- @end example
- @end group
- X
- @noindent
- in Big language mode. This is actually one case of the general
- function @samp{choriz(@var{vec}, @var{sep}, @var{prec})}, where
- either or both of @var{sep} and @var{prec} may be omitted.
- @var{Prec} gives the @dfn{precedence} to use when formatting
- each of the components of @var{vec}. The default precedence is
- the precedence from the surrounding environment.
- X
- @var{Sep} is a string (i.e., a vector of character codes as might
- be entered with @code{" "} notation) which should separate components
- of the composition. Also, if @var{sep} is given, the line breaker
- will allow lines to be broken after each occurrence of @var{sep}.
- If @var{sep} is omitted, the composition will not be breakable
- (unless any of its component compositions are breakable).
- X
- For example, @samp{2 choriz([a, b c, d = e], " + ", 180)} is
- formatted as @samp{2 a + b c + (d = e)}. To get the @code{choriz}
- to have precedence 180 ``outwards'' as well as ``inwards'',
- enclose it in a @code{cprec} form: @samp{2 cprec(choriz(...), 180)}
- formats as @samp{2 (a + b c + (d = e))}.
- X
- The baseline of a horizontal composition is the same as the
- baselines of the component compositions, which are all aligned.
- X
- @node Vertical Compositions, Other Compositions, Horizontal Compositions, Compositions
- @subsubsection Vertical Compositions
- X
- @noindent
- @tindex cvert
- The @code{cvert} function makes a vertical composition. Each
- component of the vector is centered in a column. The baseline of
- the result is by default the top line of the resulting composition.
- For example, @samp{f(cvert([a, bb, ccc]), cvert([a^2 + 1, b^2]))}
- formats in Big mode as
- X
- @group
- @example
- f( a , 2 )
- X bb a + 1
- X ccc 2
- X b
- @end example
- @end group
- X
- @tindex cbase
- There are several special composition functions that work only as
- components of a vertical composition. The @code{cbase} function
- controls the baseline of the vertical composition; the baseline
- will be the same as the baseline of whatever component is enclosed
- in @code{cbase}. Thus @samp{f(cvert([a, cbase(bb), ccc]),
- cvert([a^2 + 1, cbase(b^2)]))} displays as
- X
- @group
- @example
- X 2
- X a + 1
- X a 2
- f(bb , b )
- X ccc
- @end example
- @end group
- X
- @tindex ctbase
- @tindex cbbase
- There are also @code{ctbase} and @code{cbbase} functions which
- make the baseline of the vertical composition equal to the top
- or bottom line (rather than the baseline) of that component.
- Thus @samp{cvert([cbase(a / b)]) + cvert([ctbase(a / b)]) +
- cvert([cbbase(a / b)])} gives
- X
- @group
- @example
- X a
- a -
- - + a + b
- b -
- X b
- @end example
- @end group
- X
- There should be only one @code{cbase}, @code{ctbase}, or @code{cbbase}
- function in a given vertical composition. These functions can also
- be written with no arguments: @samp{ctbase()} is a zero-height object
- which means the baseline is the top line of the following item, and
- @samp{cbbase()} means the baseline is the bottom line of the preceding
- item.
- X
- @tindex crule
- The @code{crule} function builds a ``rule,'' or horizontal line,
- across a vertical composition. By itself @samp{crule()} uses @samp{-}
- characters to build the rule. You can specify any other character,
- e.g., @samp{crule("=")}. The argument must be a character code or
- vector of exactly one character code. It is repeated to match the
- 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])}:
- X
- @group
- @example
- a + 1
- =====
- X 2
- X b
- @end example
- @end group
- X
- @tindex clvert
- @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:
- X
- @group
- @example
- a + a
- bb bb
- ccc ccc
- @end example
- @end group
- X
- Like @code{choriz}, the vertical compositions accept a second argument
- which gives the precedence to use when formatting the components.
- Vertical compositions do not support separator strings.
- X
- @node Other Compositions, Information about Compositions, Vertical Compositions, Compositions
- @subsubsection Other Compositions
- X
- @noindent
- @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
- language mode. This is essentially a horizontal composition of
- @samp{a} and @samp{b}, where @samp{b} is shifted up so that its
- bottom line is one above the baseline.
- X
- @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
- bottom line of @samp{a} (note that this is not quite analogous to
- @code{csup}). Other arrangements can be obtained by using
- @code{choriz} and @code{cvert} directly.
- X
- @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
- or Big. It is invisible in other language modes. For example,
- @samp{a^(b/c)} is formatted by Big mode like @samp{csup(a, cflat(b/c))}
- to improve its readability.
- X
- @tindex cspace
- The @code{cspace} function creates horizontal space. For example,
- @samp{cspace(4)} is effectively the same as @samp{string(" ")}.
- A second string (i.e., vector of characters) argument is repeated
- instead of the space character. For example, @samp{cspace(4, "ab")}
- looks like @samp{abababab}. If the second argument is not a string,
- it is formatted in the normal way and then several copies of that
- are composed together: @samp{cspace(4, a^2)} yields
- X
- @group
- @example
- X 2 2 2 2
- a a a a
- @end example
- @end group
- X
- @noindent
- If the number argument is zero, this is a zero-width object.
- X
- @tindex cvspace
- The @code{cvspace} function creates vertical space, or a vertical
- stack of copies of a certain string or formatted object. The
- baseline is the center line of the resulting stack. A numerical
- argument of zero will produce an object which contributes zero
- height if used in a vertical composition.
- X
- @tindex ctspace
- @tindex cbspace
- There are also @code{ctspace} and @code{cbspace} functions which
- create vertical space with the baseline the same as the baseline
- of the top or bottom copy, respectively, of the second argument.
- Thus @samp{cvspace(2, a/b) + ctspace(2, a/b) + cbspace(2, a/b)}
- displays as:
- X
- @group
- @example
- X a
- X -
- a b
- - a a
- b + - + -
- a b b
- - a
- b -
- X b
- @end example
- @end group
- X
- @node Information about Compositions, User-Defined Compositions, Other Compositions, Compositions
- @subsubsection Information about Compositions
- X
- @noindent
- The functions in this section are actual functions; they compose their
- arguments according to the current language and other display modes,
- then return a certain measurement of the composition as an integer.
- X
- @tindex cwidth
- The @code{cwidth} function measures the width, in characters, of a
- composition. For example, @samp{cwidth(a + b)} is 5, and
- @samp{cwidth(a / b)} is 5 in normal mode, 1 in Big mode, and 11 in
- @TeX{} mode (for @samp{@{a \over b@}}). The argument may involve
- the composition functions described in this section.
- X
- @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.
- X
- @tindex cascent
- @tindex cdescent
- The functions @code{cascent} and @code{cdescent} measure the amount
- of the height that is above (and including) the baseline, or below
- the baseline, respectively. Thus @samp{cascent(@var{x}) + cdescent(@var{x})}
- always equals @samp{cheight(@var{x})}. For a one-line formula like
- @samp{a + b}, @code{cascent} returns 1 and @code{cdescent} returns 0.
- For @samp{a / b} in Big mode, @code{cascent} returns 2 and @code{cdescent}
- returns 1. The only formula for which @code{cascent} will return zero
- is @samp{cvspace(0)} or equivalents.
- X
- @node User-Defined Compositions, , Information about Compositions, Compositions
- @subsubsection User-Defined Compositions
- X
- @noindent
- @kindex Z C
- @pindex calc-user-define-composition
- The @kbd{Z C} (@code{calc-user-define-composition}) command lets you
- define the display format for any algebraic function. You provide a
- formula containing a certain number of argument variables on the stack.
- Any time Calc formats a call to the specified function in the current
- language mode and with that number of arguments, Calc effectively
- replaces the function call with that formula with the arguments
- replaced.
- X
- Calc builds the default argument list by sorting all the variable names
- that appear in the formula into alphabetical order. You can edit this
- argument list before pressing @key{RET} if you wish. Any variables in
- the formula that do not appear in the argument list will be displayed
- literally; any arguments that do not appear in the formula will not
- affect the display at all.
- X
- You can define formats for built-in functions, for functions you have
- defined with @kbd{Z F} (@pxref{Algebraic Definitions}), or for functions
- which have no definitions but are being used as purely syntactic objects.
- You can define different formats for each language mode, and for each
- number of arguments, using a succession of @kbd{Z C} commands. When
- Calc formats a function call, it first searches for a format defined
- for the current language mode (and number of arguments); if there is
- none, it uses the format defined for the Normal language mode. If
- neither format exists, Calc uses its built-in standard format for that
- function (usually just @samp{@var{func}(@var{args})}).
- X
- If you execute @kbd{Z C} with the number 0 on the stack instead of a
- formula, any defined formats for the function in the current language
- mode will be removed. The function will revert to its standard format.
- X
- For example, the default format for the binomial coefficient function
- @samp{choose(n, m)} in the Big language mode is
- X
- @group
- @example
- X n
- ( )
- X m
- @end example
- @end group
- X
- You might prefer the notation,
- X
- @group
- @example
- X C
- n m
- @end example
- @end group
- X
- To define this notation, first make sure you are in Big mode,
- then put the formula
- X
- @smallexample
- choriz([cvert([cvspace(1), n]), C, cvert([cvspace(1), m])])
- @end smallexample
- X
- @noindent
- on the stack and type @kbd{Z C}. Answer the first prompt with
- @code{choose}. The second prompt will be the default argument list
- of @samp{(C m n)}. Edit this list to be @samp{(n m)} and press
- @key{RET}. Now, try it out: For example, turn simplification
- off with @kbd{m O} and enter @samp{choose(a,b) + choose(7,3)}
- as an algebraic entry.
- X
- @group
- @example
- X C + C
- a b 7 3
- @end example
- @end group
- X
- As another example, let's define the usual notation for Stirling
- numbers of the first kind, @samp{stir1(n, m)}. This is just like
- the regular format for binomial coefficients but with square brackets
- instead of parentheses.
- X
- @smallexample
- choriz([string("["), cvert([n, cbase(cvspace(1)), m]), string("]")])
- @end smallexample
- X
- Now type @kbd{Z C stir1 @key{RET}}, edit the argument list to
- @samp{(n m)}, and type @key{RET}.
- X
- The formula provided to @kbd{Z C} usually will involve composition
- functions, but it doesn't have to. Putting the formula @samp{a + b + c}
- onto the stack and typing @kbd{Z C foo @key{RET} @key{RET}} would define
- the function @samp{foo(x,y,z)} to display like @samp{x + y + z}.
- This ``sum'' will act exactly like a real sum for all formatting
- purposes (it will be parenthesized the same, and so on). However
- it will be computationally unrelated to a sum. For example, the
- formula @samp{2 * foo(1, 2, 3)} will display as @samp{2 (1 + 2 + 3)}.
- Operator precedences have caused the ``sum'' to be written in
- parentheses, but the arguments have not actually been summed.
- (Generally a display format like this would be undesirable, since
- it can easily be confused with a real sum.)
- X
- The special function @code{eval} can be used inside a @kbd{Z C}
- composition formula to cause all or part of the formula to be
- evaluated at display time. For example, if the formula is
- @samp{a + eval(b + c)}, then @samp{foo(1, 2, 3)} will be displayed
- as @samp{1 + 5}. Evaluation will use the default simplifications,
- regardless of the current simplification mode. There are also
- @code{evalsimp} and @code{evalextsimp} which simplify as if by
- @kbd{a s} and @kbd{a e} (respectively). Note that these ``functions''
- operate only in the context of composition formulas (and also in
- rewrite rules, where they serve a similar purpose; @pxref{Rewrite
- Rules}). On the stack, a call to @code{eval} will be left in
- symbolic form.
- X
- It is not a good idea to use @code{eval} except as a last resort.
- It can cause the display of formulas to be extremely slow. For
- example, while @samp{eval(a + b)} might seem quite fast and simple,
- there are several situations where it could be slow. For example,
- @samp{a} and/or @samp{b} could be polar complex numbers, in which
- case doing the sum requires trigonometry. Or, @samp{a} could be
- the factorial @samp{fact(100)} which is unevaluated because the
- user has typed @kbd{m O}; @code{eval} will evaluate it anyway to
- produce a large, unwieldy integer.
- X
- You can save your display formats permanently using the @kbd{Z P}
- command (@pxref{Creating User Keys}).
- X
- @node Calc Mode Line, , Language Modes, Mode Settings
- @section The Calc Mode Line
- X
- @noindent
- @cindex Mode line indicators
- This section is a summary of all symbols that can appear on the
- Calc mode line, the highlighted bar that appears under the Calc
- stack window (or under an editing window in Embedded Mode).
- X
- The basic mode line format is:
- X
- @example
- --%%-Calc: 12 Deg @var{other modes} (Calculator)
- @end example
- X
- The @samp{%%} is the Emacs symbol for ``read-only''; it shows that
- regular Emacs commands are not allowed to edit the stack buffer
- as if it were text.
- X
- The word @samp{Calc:} changes to @samp{CalcEmbed:} if Embedded Mode
- is enabled. The words after this describe the various Calc modes
- that are in effect.
- X
- The first mode is always the current precision, an integer.
- The second mode is always the angular mode, either @code{Deg},
- @code{Rad}, or @code{Hms}.
- X
- Here is a complete list of the remaining symbols that can appear
- on the mode line:
- X
- @table @code
- @item Alg
- Algebraic mode (@kbd{m a}; @pxref{Algebraic Entry}).
- X
- @item Alg[(
- Incomplete algebraic mode (@kbd{C-u m a}).
- X
- @item Alg*
- Total algebraic mode (@kbd{m t}).
- X
- @item Symb
- Symbolic mode (@kbd{m s}; @pxref{Symbolic Mode}).
- X
- @item Matrix
- Matrix mode (@kbd{m v}; @pxref{Matrix Mode}).
- X
- @item Matrix@var{n}
- Dimensioned matrix mode (@kbd{C-u @var{n} m v}).
- X
- @item Scalar
- Scalar mode (@kbd{m v}; @pxref{Matrix Mode}).
- X
- @item Polar
- Polar complex mode (@kbd{m p}; @pxref{Polar Mode}).
- X
- @item Frac
- Fraction mode (@kbd{m f}; @pxref{Fraction Mode}).
- X
- @item Inf
- Infinite mode (@kbd{m i}; @pxref{Infinite Mode}).
- X
- @item +Inf
- Positive infinite mode (@kbd{C-u 0 m i}).
- X
- @item NoSimp
- Default simplifications off (@kbd{m O}; @pxref{Simplification Modes}).
- X
- @item NumSimp
- Default simplifications for numeric arguments only (@kbd{m N}).
- X
- @item BinSimp@var{w}
- Binary-integer simplification mode; word size @var{w} (@kbd{m B}).
- X
- @item AlgSimp
- Algebraic simplification mode (@kbd{m A}).
- X
- @item ExtSimp
- Extended algebraic simplification mode (@kbd{m E}).
- X
- @item UnitSimp
- Units simplification mode (@kbd{m U}).
- X
- @item Bin
- Current radix is 2 (@kbd{d 2}; @pxref{Radix Modes}).
- X
- @item Oct
- Current radix is 8 (@kbd{d 8}).
- X
- @item Hex
- Current radix is 16 (@kbd{d 6}).
- X
- @item Radix@var{n}
- Current radix is @var{n} (@kbd{d r}).
- X
- @item Zero
- Leading zeros (@kbd{d z}; @pxref{Radix Modes}).
- X
- @item Flat
- One-line normal language mode (@kbd{d O}; @pxref{Normal Language Modes}).
- X
- @item Big
- Big language mode (@kbd{d B}).
- X
- @item Unform
- Unformatted language mode (@kbd{d U}).
- X
- @item C
- C language mode (@kbd{d C}; @pxref{C FORTRAN Pascal}).
- X
- @item Pascal
- Pascal language mode (@kbd{d P}).
- X
- @item Fortran
- FORTRAN language mode (@kbd{d F}).
- X
- @item TeX
- @TeX{} language mode (@kbd{d T}; @pxref{TeX Language Mode}).
- X
- @item Eqn
- @dfn{Eqn} language mode (@kbd{d E}; @pxref{Eqn Language Mode}).
- X
- @item Math
- Mathematica language mode (@kbd{d M}; @pxref{Mathematica Language Mode}).
- X
- @item Maple
- Maple language mode (@kbd{d W}; @pxref{Maple Language Mode}).
- X
- @item Norm@var{n}
- Normal float mode with @var{n} digits (@kbd{d n}; @pxref{Float Formats}).
- X
- @item Fix@var{n}
- Fixed point mode with @var{n} digits after the point (@kbd{d f}).
- X
- @item Sci
- Scientific notation mode (@kbd{d s}).
- X
- @item Sci@var{n}
- Scientific notation with @var{n} digits (@kbd{d s}).
- X
- @item Eng
- Engineering notation mode (@kbd{d e}).
- X
- @item Eng@var{n}
- Engineering notation with @var{n} digits (@kbd{d e}).
- X
- @item Left@var{n}
- Left-justified display indented by @var{n} (@kbd{d <}; @pxref{Justification}).
- X
- @item Right
- Right-justified display (@kbd{d >}).
- X
- @item Right@var{n}
- Right-justified display with width @var{n} (@kbd{d >}).
- X
- @item Center
- Centered display (@kbd{d =}).
- X
- @item Center@var{n}
- Centered display with center column @var{n} (@kbd{d =}).
- X
- @item Wid@var{n}
- Line breaking with width @var{n} (@kbd{d b}; @pxref{Normal Language Modes}).
- X
- @item Wide
- No line breaking (@kbd{d b}).
- X
- @item Break
- Selections show deep structure (@kbd{j b}; @pxref{Making Selections}).
- X
- @item Save
- Record modes in @file{~/.emacs} (@kbd{m R}; @pxref{General Mode Commands}).
- X
- @item Local
- Record modes in Embedded buffer (@kbd{m R}).
- X
- @item LocEdit
- Record modes as editing-only in Embedded buffer (@kbd{m R}).
- X
- @item LocPerm
- Record modes as permanent-only in Embedded buffer (@kbd{m R}).
- X
- @item Global
- Record modes as global in Embedded buffer (@kbd{m R}).
- X
- @item Manual
- Automatic recomputation turned off (@kbd{m C}; @pxref{Automatic
- Recomputation}).
- X
- @item Graph
- GNUPLOT process is alive in background (@pxref{Graphics}).
- X
- @item Sel
- Top-of-stack has a selection (Embedded only; @pxref{Making Selections}).
- X
- @item Dirty
- The stack display may not be up-to-date (@pxref{Display Modes}).
- X
- @item Inv
- ``Inverse'' prefix was pressed (@kbd{I}; @pxref{Inverse and Hyperbolic}).
- X
- @item Hyp
- ``Hyperbolic'' prefix was pressed (@kbd{H}).
- X
- @item Keep
- ``Keep-arguments'' prefix was pressed (@kbd{K}).
- X
- @item Narrow
- Stack is truncated (@kbd{d t}; @pxref{Truncating the Stack}).
- @end table
- X
- In addition, the symbols @code{Active} and @code{~Active} can appear
- as minor modes on an Embedded buffer's mode line. @xref{Embedded Mode}.
- X
- @node Arithmetic, Scientific Functions, Mode Settings, Top
- @chapter Arithmetic Functions
- X
- @noindent
- This chapter describes the Calc commands for doing simple calculations
- on numbers, such as addition, absolute value, and square roots. These
- commands work by removing the top one or two values from the stack,
- performing the desired operation, and pushing the result back onto the
- stack. If the operation cannot be performed, the result pushed is a
- formula instead of a number, such as @samp{2/0} (because division by zero
- is illegal) or @samp{sqrt(x)} (because the argument @samp{x} is a formula).
- X
- Most of the commands described here can be invoked by a single keystroke.
- Some of the more obscure ones are two-letter sequences beginning with
- the @kbd{f} (``functions'') prefix key.
- X
- @xref{Prefix Arguments}, for a discussion of the effect of numeric
- prefix arguments on commands in this chapter which do not otherwise
- interpret a prefix argument.
- X
- @menu
- * Basic Arithmetic::
- * Integer Truncation::
- * Complex Number Functions::
- * Conversions::
- * Date Arithmetic::
- * Financial Functions::
- * Binary Functions::
- @end menu
- X
- @node Basic Arithmetic, Integer Truncation, Arithmetic, Arithmetic
- @section Basic Arithmetic
- X
- @noindent
- @kindex +
- @pindex calc-plus
- @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
- onto the stack.
- X
- If both arguments of @kbd{+} are vectors or matrices (of matching dimensions),
- the result is a vector or matrix sum. If one argument is a vector and the
- other a scalar (i.e., a non-vector), the scalar is added to each of the
- elements of the vector to form a new vector. If the scalar is not a
- number, the operation is left in symbolic form: Suppose you added @samp{x}
- to the vector @samp{[1,2]}. You may want the result @samp{[1+x,2+x]}, or
- you may plan to substitute a 2-vector for @samp{x} in the future. Since
- the Calculator can't tell which interpretation you want, it makes the
- safest assumption. @xref{Reducing and Mapping}, for a way to add @samp{x}
- to every element of a vector.
- X
- If either argument of @kbd{+} is a complex number, the result will in general
- be complex. If one argument is in rectangular form and the other polar,
- the current Polar Mode determines the form of the result. If Symbolic
- Mode is enabled, the sum may be left as a formula if the necessary
- conversions for polar addition are non-trivial.
- X
- If both arguments of @kbd{+} are HMS forms, the forms are added according to
- the usual conventions of hours-minutes-seconds notation. If one argument
- is an HMS form and the other is a number, that number is converted from
- degrees or radians (depending on the current Angular Mode) to HMS format
- and then the two HMS forms are added.
- X
- If one argument of @kbd{+} is a date form, the other can be either a
- real number, which advances the date by a certain number of days, or
- an HMS form, which advances the date by a certain amount of time.
- Subtracting two date forms yields the number of days between them.
- Adding two date forms is meaningless, but Calc interprets it as the
- subtraction of one date form and the negative of the other. (The
- negative of a date form can be understood by remembering that dates
- are stored as the number of days before or after Jan 1, 1 AD.)
- X
- If both arguments of @kbd{+} are error forms, the result is an error form
- with an appropriately computed standard deviation. If one argument is an
- error form and the other is a number, the number is taken to have zero error.
- Error forms may have symbolic formulas as their mean and/or error parts;
- adding these will produce a symbolic error form result. However, adding an
- error form to a plain symbolic formula (as in @samp{(a +/- b) + c}) will not
- work, for the same reasons just mentioned for vectors. Instead you must
- write @samp{(a +/- b) + (c +/- 0)}.
- X
- If both arguments of @kbd{+} are modulo forms with equal values of @cite{M},
- or if one argument is a modulo form and the other a plain number, the
- result is a modulo form which represents the sum, modulo @cite{M}, of
- the two values.
- X
- If both arguments of @kbd{+} are intervals, the result is an interval
- which describes all possible sums of the possible input values. If one
- argument is a plain number, it is treated as the interval @samp{[x ..@: x]}.
- X
- If one argument of @kbd{+} is an infinity and the other is not, the
- result is that same infinity. If both arguments are infinite and in
- the same direction, the result is the same infinity, but if they are
- infinite in different directions the result is @code{nan}.
- X
- @kindex -
- @pindex calc-minus
- @tindex -
- The @kbd{-} (@code{calc-minus}) command subtracts two values. The top
- number on the stack is subtracted from the one behind it, so that the
- computation @kbd{5 @key{RET} 2 -} produces 3, not @i{-3}. All options
- available for @kbd{+} are available for @kbd{-} as well.
- X
- @kindex *
- @pindex calc-times
- @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
- the elements of the vector to produce a new vector. If both arguments
- are vectors, the interpretation depends on the dimensions of the
- vectors: If both arguments are matrices, a matrix multiplication is
- done. If one argument is a matrix and the other a plain vector, the
- vector is interpreted as a row vector or column vector, whichever is
- dimensionally correct. If both arguments are plain vectors, the result
- is a single scalar number which is the dot product of the two vectors.
- X
- If one argument of @kbd{*} is an HMS form and the other a number, the
- HMS form is multiplied by that amount. It is an error to multiply two
- HMS forms together, or to attempt any multiplication involving date
- forms. Error forms, modulo forms, and intervals can be multiplied;
- see the comments for addition of those forms. When two error forms
- or intervals are multiplied they are considered to be statistically
- independent; thus, @samp{[-2 ..@: 3] * [-2 ..@: 3]} is @samp{[-6 ..@: 9]},
- whereas @samp{[-2 ..@: 3] ^ 2} is @samp{[0 ..@: 9]}.
- X
- @kindex /
- @pindex calc-divide
- @tindex /
- The @kbd{/} (@code{calc-divide}) command divides two numbers. When
- dividing a scalar @cite{B} by a square matrix @cite{A}, the computation
- performed is @cite{B} times the inverse of @cite{A}. This also occurs
- if @cite{B} is itself a vector or matrix, in which case the effect is
- to solve the set of linear equations represented by @cite{B}. If @cite{B}
- is a matrix with the same number of rows as @cite{A}, or a plain vector
- (which is interpreted here as a column vector), then the equation
- @cite{A X = B} is solved for the vector or matrix @cite{X}. Otherwise,
- if @cite{B} is a non-square matrix with the same number of @emph{columns}
- as @cite{A}, the equation @cite{X A = B} is solved. If you wish a vector
- @cite{B} to be interpreted as a row vector to be solved as @cite{X A = B},
- make it into a one-row matrix with @kbd{C-u 1 v p} first. To force a
- left-handed solution with a square matrix @cite{B}, transpose @cite{A} and
- @cite{B} before dividing, then transpose the result.
- X
- HMS forms can be divided by real numbers or by other HMS forms. Error
- forms can be divided in any combination of ways. Modulo forms where both
- values and the modulo are integers can be divided to get an integer modulo
- form result. Intervals can be divided; dividing by an interval that
- encompasses zero or has zero as a limit will result in an infinite
- interval.
- X
- @kindex ^
- @pindex calc-power
- @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
- multiplications. For non-integer powers, Calc uses Newton's method or
- logarithms and exponentials. Square matrices can be raised to integer
- powers. If either argument is an error (or interval or modulo) form,
- the result is also an error (or interval or modulo) form.
- X
- @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.
- SHAR_EOF
- true || echo 'restore of calc.texinfo failed'
- fi
- echo 'End of part 40'
- echo 'File calc.texinfo is continued in part 41'
- echo 41 > _shar_seq_.tmp
- exit 0
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-