calc: Eqn Language Mode
7.8.4 Eqn Language Mode
-----------------------
“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 ‘d E’ (‘calc-eqn-language’) command selects “eqn”
notation.
The “eqn” language’s main idiosyncrasy is that whitespace plays a
significant part in the parsing of the language. For example, ‘sqrt x+1
+ y’ treats ‘x+1’ as the argument of the ‘sqrt’ operator. “Eqn” also
understands more conventional grouping using curly braces: ‘sqrt{x+1} +
y’. Braces are required only when the argument contains spaces.
In Calc’s “eqn” mode, however, curly braces are required to delimit
arguments of operators like ‘sqrt’. The first of the above examples
would treat only the ‘x’ as the argument of ‘sqrt’, and in fact ‘sin
x+1’ would be interpreted as ‘sin * x + 1’, because ‘sin’ is not a
special operator in the “eqn” language. If you always surround the
argument with curly braces, Calc will never misunderstand.
Calc also understands parentheses as grouping characters. Another
peculiarity of “eqn”’s syntax makes it advisable to separate words with
spaces from any surrounding characters that aren’t curly braces, so Calc
writes ‘sin ( x + y )’ in “eqn” mode. (The spaces around ‘sin’ are
important to make “eqn” recognize that ‘sin’ should be typeset in a
roman font, and the spaces around ‘x’ and ‘y’ are a good idea just in
case the “eqn” document has defined special meanings for these names,
too.)
Powers and subscripts are written with the ‘sub’ and ‘sup’ operators,
respectively. Note that the caret symbol ‘^’ is treated the same as a
space in “eqn” mode, as is the ‘~’ symbol (these are used to introduce
spaces of various widths into the typeset output of “eqn”).
As in LaTeX mode, Calc’s formatter omits parentheses around the
arguments of functions like ‘ln’ and ‘sin’ if they are “simple-looking”;
in this case Calc surrounds the argument with braces, separated by a ‘~’
from the function name: ‘sin~{x}’.
Font change codes (like ‘roman X’) and positioning codes (like ‘~’
and ‘down N X’) are ignored by the “eqn” reader. Also ignored are the
words ‘left’, ‘right’, ‘mark’, and ‘lineup’. Quotation marks in “eqn”
mode input are treated the same as curly braces: ‘sqrt "1+x"’ is
equivalent to ‘sqrt {1+x}’; this is only an approximation to the true
meaning of quotes in “eqn”, but it is good enough for most uses.
Accent codes (‘X dot’) are handled by treating them as function calls
(‘dot(X)’) internally. TeX and LaTeX Language Modes, for a
table of these accent functions. The ‘prime’ accent is treated
specially if it occurs on a variable or function name: ‘f prime prime
( x prime )’ is stored internally as ‘f''(x')’. For example, taking the
derivative of ‘f(2 x)’ with ‘a d x’ will produce ‘2 f'(2 x)’, which
“eqn” mode will display as ‘2 f prime ( 2 x )’.
Assignments are written with the ‘<-’ (left-arrow) symbol, and
‘evalto’ operators are written with ‘->’ or ‘evalto ... ->’ (TeX
and LaTeX Language Modes, for a discussion of this). The regular Calc
symbols ‘:=’ and ‘=>’ are also recognized for these operators during
reading.
Vectors in “eqn” mode use regular Calc square brackets, but matrices
are formatted as ‘matrix { ccol { a above b } ... }’. The words ‘lcol’
and ‘rcol’ are recognized as synonyms for ‘ccol’ during input, and are
generated instead of ‘ccol’ if the matrix justification mode so
specifies.