Jan Rheinländer, 13.05.2018. This handbook describes EQC Version 1.4.20
The LaTeX Equation Compiler is a preprocessor for LaTeX files that enables numeric and symbolic calculations. It reads equations specified by special keywords in the LaTeX file and uses them to calculate the numeric value of variables. Symbolic calculation capabilities are also implemented, for example, adding two equations or substituting a variable with a numerical or symbolic value into an equation. EQC makes use of the GiNaC library.
The development of EQC was prompted by a problem which I often encountered doing calculations in my profession as a mechanical engineer. I would first begin writing out the problem on paper, putting together the necessary equations, and then turn to a spreadsheet to do the actual calculations. EQC is meant to integrate this process in a single Latex source file.
Programming language: C++, bison, flex. Implemented on Linux. Cross-compiled to Windows, but not extensively tested there.
EQC makes use of the GiNaC library for numeric and symbolic calculations, and of course needs a Latex installation to be useful. If you wish to use physical units, the SIunits.sty package is required as well.
EQC is hosted at SourceForge
You can download binary and source packages from the [EQC project page}(http://sourceforge.net/projects/eqc).
To use EQC, the GiNaC and CLN libraries are required (not for the Windows binary). Information about these libraries can be found at the GiNaC library homepage . Of course, a Latex installation is necessary, and the SIunits.sty package should be present if you wish to use physical units in your equations.
Use the binary packages in .deb format
Unpack the corresponding zip file and sort the files into your favourite directories:
The search path to eqc.sty is compiled into the eqc binary. To adapt the path to your local installation, you should add a command
\eqcoptions{path="\path\to\where\you\put\eqc.sty\"}
before the first EQC commands.
If you want to look at the docs and examples on Windows, you might have to change the pathnames of the \input statements to fit your directory structure.
In a normal document, you should always include the following EQC files:
% in the preamble
\usepackage{eqc}
%
% soon after \begin{document}
\input mathconstants.tex
\input units.tex
These files are essential for EQC to function properly. Only very special cases would warrant not including these files.
In xemacs, choose Options-Advanced (Customize)-Group from the menu, and enter the group name auctex. Open the Command group, and under List:, add the following entry:
[INS] [DEL] Name: EQC
Command: eqc %t; %l "%(mode)\input{%s.eqc}"
How: [Value Menu] TeX-run-LaTeX
Create a process for NAME using COMMAND to format FILE with TeX.
Create a process for NAME using COMMAND to process FILE. *
Return the new process.
Prompt: [Toggle] off (nil)
Modes: [Value Menu] Set:
* Plain TeX
* LaTeX
* DocTeX
* ConTeXt
* Texinfo
* AmSTeX
Menu elements:
[INS] [DEL] Lisp expression: :help
[INS] [DEL] Lisp expression: "Run EQC, then LaTeX"
[INS]
Choose save from the top of the buffer. To run EQC, followed by LaTeX, hit Ctrl-C twice in the buffer, and when asked for the command to run, say eqc (just typing "e" usually is sufficient)
Refer to the [Detailed compilation instructions]
Known bugs
These are not really bugs, but they might seem so
** The former unit \l was removed because it collides with a letter in the Polish alphabet. Use \litre instead. This can lead to weird errors if you don't change it!
** If your \makepspicture graphics fail because the equations do not resolve to numerics, add a second \val statement to them. This became necessary with the introduction of symbols that represent matrices.
The option eqsplit must be the last one in a list, for example: \eq[eqsplit=2; eqraw=true]{a + b = c}
will not work correctly, but \eq[eqraw=true; eqsplit=2]{a + b = c}
will. The reason for this is that eqsplit takes an expression as an argument, and the definition of an expression allows for a list separated by semicolons. Therefore, an ambiguity occurs.
Please report all bugs via the Sourceforge bug tracker. You should include the following information:
\eqcoptions{debug=4}
at the beginning of your file. For Linux, you can also call eqc with -d<number>. Larger values than 4 are possible, but might give too much detail.</number>EQC reads LaTeX files from the command line and writes its output to corresponding .eqc files. One output file is generated for each file given on the command line. Note that files included with \input directives are directly included in the output file. EQC keywords contained in the input files are processed, everything else is written out unchanged. The resulting .eqc files can then be processed like any regular LaTeX file (don't forget to give the .eqc file extension to latex).
An auxiliary package needs to be included with \usepackage{eqc}. It takes an optional argument english or german which defines how numbers are read (whether a comma or a point is expected as the decimal marker). English is the default.
Inside the Latex file, equations can now be defined and registered. EQC will read the equation, produce Latex output, and store it for later manipulation or evalution. For example:
\documentclass{article}
\usepackage{eqc}
\begin{document}
\input mathconstants.tex
$$\eq[eq:myequation]{x = a \sin(b)}$$
$$\eq{a = 3}$$
$$\eq{b = 3.141/2}$$
$$\printeq{"eq:myequation"} = \val{x}$$
\end{document}
This would produce the following Latex output (without the preamble created by including mathconstants.tex):
$$x = a sin(b)$$
$$a = 3$$
$$b = 1.57$$
$$x = a sin(b) = 3$$
In order to determine the value of the variable x, EQC automatically uses the three equations that were registered with the keyword \eq. Note that only equations that have in this way been explicitly registered with EQC will be used! Any other equations present in the file are ignored. To see what else is possible in EQC have a look at the example and the reference section.
Because EQC was developed to tackle mechanical engineering problems, it supports physical units. The Latex side is handled by SIunits.sty, which needs to be present on your system (it is included, for example, in the tetex distribution). Units inside equations are designated by their Latex macro names, e.g., \mm. Variable values can take on four different forms:
The \val keyword used in the example above prints the fourth kind of variable value. If we had wished to ensure that a numerical value is printed, we would have used \numval. EQC will then print a warning if the value of the variable does not have this form.
The file substitutions.tex contains a growing library of equations that are useful for working with symbolic equations, for example, \sin(\alpha + \beta) = \sin\alpha \cos\beta + \cos\alpha \sin\beta or \sin(\pi - \alpha) = \sin\alpha
. By substitution, they can be adapted to special cases:
$$\eq{\cos\phi = \sin(\phi + \psi)}$$
$$\eqsubst{"prev"}{"lib:trig:sina+b"}$$
which would produce the following output:
$$\cos\phi = \sin(\phi + \psi)$$
$$\cos\phi = \sin\phi \cos\psi + \cos\phi \sin\psi$$
There are several options available to control how floating point numbers are printed. The precision can be set to a specific number of digits with \eqcoptions{precision = 'num'}.Two different concepts of precision are implemented, these can be selected by \eqcoptions{precision_type = fixed_marker} or \eqcoptions{precision_type = fixed_digits}.
Very large and very small numbers should be printed in scientific format (mantissa * 10^exponent) for the sake of readability. The limits which determine what a "very large" or "very small" number is can be set with \eqcoptions{scientific_limit_low = 'num'} and \eqcoptions{scientific_limit_high = 'num'}.
Using the command \eqcoptions{eqraw = true/false} in you Latex input file makes it possible to choose whether \eq statements should be formatted the way you typed them or whether EQC should use it's own output function to format them. Note that any equations obtained by \eqadd etc. will always have the EQC formatting, as EQC can hardly foresee what you would have typed if you had written this equation yourself.
EQC formats equations inside certain environments (eqnarray, align etc.) automatically, that is, the correct number of ampersands (&) is added before/after the equal sign. You can override the formatting by setting the eqalign option manually.
Refer to the [Reference section].
The EQC tour gives an overview of EQC functionality. It was created with the following commands on the source file eqc-tour.tex:
eqc eqc-tour.tex
latex eqc-tour.eqc
If you do not have a DVI viewer installed, try the eqc-tour.pdf produced with pdflatex. In case you are curious what your Latex source looks like after EQC has had a go at it, have a look at the intermediate file eqc-tour.eqc
\eq[eq:Plive]{P_L = \unit{1500}{\kN}}
\eq[eq:sello]{H = \unit{2}{\m}}
\eq[eq:Pcomb]{P_{comb} = H L^2}
\eq[eq:Ptot]{P = P_L + P_{comb}}
P_{comb} & = & \val{P_{comb}}\
P & = &\val{P}
\eqsubst{"eq:Ptot"}{P_{comb} = \val{P_{comb}}}
\eq[eq:Ptot_]{P = \val{\rhs{"prev"}}}
eqraw = false
either globally or locally\val{2+2}
. You can put anything you like into a \val
command, and EQC will try to reduce it to a numeric value.\eqcoptions{debug=-1}
will silence EQC almost completely. Higher values up to 13 will make it more verbose. For Unix platforms, you can also use the command line argument -d
or --debug=
. However, that when something goes wrong, reading the console output is very useful to find problems.a = x(b;
and then complained about the missing second argument. EQC does not require function arguments to be enclosed in brackets, so you can write \cos\alpha
instead of \cos{\alpha}
. There are several ways to solve your problem:\eqcoptions{cleancomments=true}
to remove comment lines (that is, lines beginning with a percent character). Other comments are not removed because sometimes they are necessary for LaTeX to process the file correctly.EQC Copyright 2002-2018 Jan Rheinländer, jrheinlaender@users.sourceforge.net
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Wiki: Detailed compilation instructions
Wiki: History of Changes
Wiki: Reference section