There are two categories of keywords recognized by EQC: Keywords in the Latex file, and keywords inside equation statements. The syntax used to describe the keywords is:
keyword [optarg1] [optarg2] ... {argument1} {argument2} ...
Arguments in square brackets are optional.
The following abbreviations for the different types of arguments are used:
A mathematical expression like x + sin(y).
An equation created by equating two mathematical expressions.
Same as before, but inside an equation array. Other positions of the &
are possible
as well.
EQC optionally accepts an equation label in any place where an equation is required. Labels
must be enclosed in double quotes. The special equation label "prev'
references the
last equation that was registered with EQC.
Either a single equation or a list of equations separated by colons.
A list of physical unit names like \mm; \N, separated by colons.
A list of expressions like x; y; z^2, separated by colons.
A list of strings describing simplifications to be performed on an equation.
A vector beginning at start
and ending at end
, with steps of
step
. If end - start
is not a multiple of step
, the
last element of the vector will be smaller than end
. If you don't care about the size
of the step, give a value of 0: EQC will make the vector have the number of elements defined
by the option vecautosize
(default 20).
A vector or a matrix of arbitrary expressions. The brackets are important, but not the type of bracket. A matrix can be used anywhere an expression is allowed.
Numbers can have the imaginary unit i
, which on the other hand means that you cannot use
i
as a variable name.
All these keywords take several optional arguments. The asterisk form suppresses printing the
equation. A label may be given to the equation in square brackets. In addition, all the options listed
for the keyword eqcoptions
can be used and will then apply for this equation only. Note that
if only an equation label and no further option is provided the square brackets, the key label =
can be omitted, and the label does not need to be quoted (""
).
Registers a constant with EQC. Constants are not erased by
\clearequations
. This makes it possible to specify general constants only once in
the file and reuse them for several different calculations. The value assigned to this constant
is automatically used when calculating the value of variables. The asterix form suppresses printing of
the constant equation in the Latex output file.
Registers an equation with EQC. Only equations that have been
registered are used to calculate the values of variables. The asterix form suppresses printing of
the equation in the Latex output file. The equation can be assigned an optional label which may be used
to reference it later on in the file. The Latex \ref{}
command will also work with this label.
Note that here the label may not be surrounded by quotes!
For the special case of the equation label starting with lib:
, the equation will
not be erased by \clearequations
. This is useful for building a library of generic
equations, as for example in the file substitutions.tex
.
Removes an equation such that it has no influence on future searches for variable values. Note that since LaTeX does not support removing labels, the label itself will be not be re-usable!
Adds an expression to the equation. A label may be assigned to the result. The resulting equation is only registered with the EQC if it has been assigned a label. The reason for this is that the equation is usually redundant in terms of using it for calculating the value of variables. The asterix form suppresses printing of the resulting equation.
Divides the equation by an expression. The asterix suppresses Latex output, the label enables the equation to be referenced later and causes it to be registered with the EQC.
Multiplies the equation with an expression. The asterix suppresses Latex output, the label enables the equation to be referenced later and causes it to be registered with the EQC.
Raises both sides of the equation to the
power of an expression. Beware: This ignores alternative results, as in the case of
\eqpow{x^2}{1/2}
, which might evaluate to +x
or -x
. Only use this
function if you are sure that you want the first possible result!
Applies the expression, which must be a valid function name (without parameters), to both sides of the equation.
Subtracts an expression from the equation. The asterix suppresses Latex output, the label enables the equation to be referenced later and causes it to be registered with the EQC.
Swaps left hand side and right hand side of the equation. The asterix suppresses Latex output, the label enables the equation to be referenced later and causes it to be registered with the EQC.
Substitutes expressions inside an equation. The
eqlist
argument is a list of equations separated by ';'. Any occurences of the left hand side of
these equations is replaced by the right hand side. The asterix
suppresses Latex output, the label enables the equation to be referenced later and causes it to be
registered with the EQC.
Simplifies both sides of the equation according to the simplifications given in a list. Possible values are:
Fully expands all expressions, including function arguments.
Only expand function definition, not arguments.
Numerically evaluate the equation as far as possible.
Normalize the equation (see description of GiNaC normal() method).
Collect common factors (see description of GiNaC collect_common_factors() method).
Does unsafe simplifications, for example
\sqrt{x^2} => x
\arctan\tan{x} => x
. Note that the opposite \tan\arctan{x}
is
not an unsafe evaluation and is thus done automatically (by GiNaC).Evaluates differential function \diff
.
Evaluates sum functions \sum
.
Gathers single square roots under one root symbol.
Symbolically integrates any integrals in the expression (if possible)
Solves the equation for a given variable. The last argument indicates which solution is requested (in case there are several solutions, like for a quadratic equation). The function returns an assignment for the variable.
Returns the left hand side of the equation.
Returns the right hand side of the equation.
EQC replaces this keyword with the value of the specified expression (which
usually is, but need not be, a variable). EQC tries to derive the value from the given equations
in the form of a physical quantity. If this is not successful, a symbolic expression will be printed instead. Any
floating point numbers will be printed with an optional precision. If the quantity should be expressed in other units
than those set by \preferredunits
, a list of units can be passed as an optional parameter.
\eq*[eq:temp_1]{assignment_1}%
...
\eq*[eq:temp_n]{assignment_n}%
\val{exp}
\deleq{"eq:temp_1"; ... "eq:temp_n}%
Same as val, but an error is printed if the value of the variable is no quantity. Any floating point numbers will be printed with an optional precision.
Same as val, but an error is printed if the value of the variable is no number. Any floating point numbers will be printed with an optional precision.
Same as val, but an error is printed if the value of the variable is no unit or a multiplication of several units and/or powers of units. Any floating point numbers will be printed with an optional precision.
Evaluates the first equation to a matrix of
values. The second equation needs to have the form sym = vector
. The symbol
is treated as the independent variable, and the equation is evaluated for all values of the symbol
given in the vector. The result is a 2x2 matrix, with the values of the independant variable in the
first column and the evaluation results in the second column. For example:
\eqeval{y = x^2}{x = 1:5:1}
would become (1; 4; 9; 16; 25)
Evaluate a function given in parameter form
to a matrix of values. Example (the evolvent function):
\eqevalp{x = R (\cos t + t \sin t)}{y = R(sin t - t \cos t)}{t = 0:90\degree:5\degree}
Returns the numerator of the expression.
Returns the denominator of the expression.
Creates a differential of the expression with respect to var
to
the degree of num
. It can be evaluated using \eqsimpf{exp}{diff}
The sum function. The first equation is the lower bound, the second the upper
bound, the third the expression to sum up. Example: \sum{n=1;3;n}
. Note that the bounds must become integer values when the
function is evaluated with \eqsimpf{exp}{sum}
.
Creates a Taylor series for the first expression. The second
parameter must have the form sym = number
. The series is created for the dependant variable
sym
around number
. The third parameter must be an integer defining the degree of
the series expansion.
Return the numeric value of the expression, rounded up to the nearest integer with the given number of digits after the decimal point.
Return the numeric value of the expression, rounded down to the nearest integer with the given number of digits after the decimal point.
Defines a new unit. The macro
is the name of the
unit, this must begin with a backslash because a Latex macro will be created with this name for
referencing the unit later on. The expression defines the unit in terms of units already known to the EQC.
If this expression contains data types apart from units, powers of units, numerics, or constants already
known to EQC, a warning is issued, but the unit definition is created anyway.
To suppress the generation of the Latex command for this unit, use the asterix form. If you wish the Latex macro to output something other than the expression, supply this as an optional argument. It will be printed in the mathrm font.
Registers a user-defined function with EQC. The function has
the arguments given in the explist. Example: \function{f}{x;y}
. The function may be
used in equations and expressions with or without arguments. The following hints are possible:
This is a library function. It will not be erased by
\clearequations
.
This is a trigonometric function. It will be printed as sin²x instead of (sin(x))² (for example).
This functions needs no brackets when printed (for example, the
sqrt()
function).
The function will be expanded immediately (provided it has been given
a definition). This is useful for example with square()
und cubic()
Define an expression which will be used to evaluate the function,
for example, \deffunc{f}{ax^2+bx+c}
. Without the asterix, this command will produce
output like f(x) = ax^2 + bx + c
.
Prints the equation (this will usually be an equation label)
Prints a vector in the format required by pstricks.sty.
Write an equation to a file. The equation has the label as given. This is useful to create a file of equations, which can then be included into another document and reused there. A typical usage would be
\printoptions{eqparse}%Turn off pretty-printing of equations \newwrite\eqfile% \immediate\openout\eqfile filename.tex% \eqwrite\eqfile{\printeq{"eq:example"}}{eq:example}% \immediate\closeout\eqfile% \printoptions{eqnoparse}%This file could then be reused as follows:
\input filename.tex Equation \eqcref{"eq:example"} in 'whatever original file it came from' states \begin{equation} \printeq{"eq:example"} \end{equation}
All options are handled by the common keyword \eqcoptions
. It takes a list of key-value pairs
string
Specifies a label for the equation, the label must be enclosed in quotes (""
).Specifies what precision is to be used for printing floating point numbers. The precision is the absolute number of digits printed, more digits are rounded away. The precisions is 4 by default.
Specifies whether floating point numbers should be printed with a fixed number of digits after the decimal marker or with a fixed number of digits in total. The default is fixed_digits.
Defines the low limit beyond which
floating point numbers are printed as mantissa * 10^exponent
.
Defines the high limit beyond which
floating point numbers are printed as mantissa * 10^exponent
.
Specifies a list of units separated by ';' preferred for printing
physical quantities.
If no such list is specified, the SI base units are used. This usually makes for ugly output, for example,
when printing forces the unit Newton. A useful list of preferred units for mechanical engineering might be
{\mm; \N; \Nm; \Nosqmm}
. The order in which the preferred units are specified is important! Simple
units should be specified first, more complex ones later on. The reason is that the complex units usually
imply the simpler ones, for example, \N
implies \mm
because 1 \N
equals
1 kg m/s^2
.
Omit the left hand side in chains of equations, in cases where only the rhs changed from one line to the next.
Raw formatting of \eq
statements means that
the equations are printed exactly as you typed them in. This of course only works until
you manipulate the equation with \eqadd
etc. The other options is to have EQC format
your equations.
Turns of some pretty-printing features that make the LaTeX output of EQC difficult to re-parse. For example, cos^2(x) is printed as (cos(x))^2.
Change the LaTeX alignment type of an equation. Values
for type
are 'onlyleft' (alignment will be &=
, for ams math), 'both' (&=&
, for eqnarray environment), 'none'.
If no alignment type is specified, EQC automatically formats depending on the environment.
Split the equation after the nth operand. The count starts at the left hand side of
the equation. Operands are those parts of the equation that are separated either by addition/subtraction or multiplication symbols.
At the given position, \\\notag
or \\\nonumber
are printed, depending on
the environment
The text to interject after the split (in quotes ""
). By default,
this tries to align the second part of the equation to the right of the equals sign.
Set the path for the EQC-specific data files (default
"/usr/share/texmf/tex/latex/eqc/"
on Unix systems).
Changes the language which EQC expects the input file to use. At the moment,
this only has an effect on parsing floating point numbers, i.e., the decimal separator is set to ',' for
"german"
and to '.' for "english"
or any other language.
Further key-value pairs to \eqcoptions
are:
Specifies the size of a vector when no step count is given (i.e., the count is zero,
x = 10:20:0
. In this case, the vector will have the number of elements as given with this option (default 20).
Clears the list of equations and variables. Constants are not cleared. Functions are cleared except for those declared in the file mathconstants.tex.
Includes the specified file. There is no difference to the Latex \include
command. All include files are written to one output .eqc file. The extension .tex need not be given.
Write a list of all equations known to the compiler into the output file. The
list is sorted by variable name (for assignments) and includes the equation label and number.
This list is very useful in larger projects where it is difficult to remember the label of a specific
equation and where it was defined. Note: This command requires AMS maths to be loaded and sets
allowdisplaybreaks[1]
!
This command must be used in the Latex preamble to include some
EQC-specific commands. For the meaning of the language
parameter, see \eqlang
.
EQC does not parse all of the possible Latex mathematical keywords. The following keywords and tokens are recognized:
Apart from the basic addition, subtraction, multiplication and division symbols, EQC interprets the '^' and '_' symbols in the same way as Latex does. Note that the '*' multiplication symbol may be omitted, just as in Latex.
The functions listed below are recognized. All of these are defined in the
file mathconstants.tex, which needs to be included. Further functions may be defined at
runtime with the \function
and \deffunc
keywords.
All the standard Latex brackets are recognized: {, \lbrace, (, [, \lbrack, \lfloor, \lceil, \langle
and
of course the corresponding right brackets. The brackets may be modified in their size by \left, \bigl,
\Bigl, \biggl, \Biggl
and \right
etc. EQC checks for bracket mismatches and issues a warning. Note
that EQC does not preserve your bracket types, but creates its own brackets and bracket sizes in the Latex output.
The Latex keywords \over
and \frac
are recognized.
Equations may be accessed using the \lhs
and \rhs
keywords. This will provide
the left hand side resp. the left hand side of the equation. An equation label may be given
instead of an equation.
Variable evaluation with the keywords \val
, quantity
, \numval
and \units
can take place inside equations. For details on how this works, see the corresponding keywords in the
description above.
Constants
EQC has the following built-in constants:
\eqlang
keyword, or by
the language parameter to \usepackage[language}{eqc}
.
begin:end:step
. For example, x = 1:3:1
will create a vector with three rows, containing the number 1, 2 and 3.
\integral(x=a; b; f(x))
where x is the integration
variable, a the lower and b the upper bound, and f a function in the integration variable. Note that if f(x) does
not explicitly mention x, then the result will not be what you expected.
\clearequations
command is read. Any Latex macros that are not known to EQC are also
interpreted as variable names, e.g., \phi
.
\mm
. Any units other than the
base SI units need to be defined with \defunit
(include the file units.tex
to get
the most common physical unit definitions).
\percent
keyword.
None as of now