How to use Mathomatic inside of another program?

Created by George Gesslein II on on 2009-08-28
API embed Mathomatic C symbolic math library
Last updated by:
George Gesslein II on on 2011-04-04

Mathomatic consists of 21,000 lines of commented C code, and can easily be included in other programs using the simple and small symbolic math library interface (API) written in the C programming language. It is released under the GNU Lesser General Public License, so that even proprietary, closed-source software can make use of it.

Importing the Mathomatic source code into your project is not recommended, because many things will break or go wrong. Linking with the Mathomatic symbolic math library and API takes care of all of those problems and makes using the Mathomatic algebra engine very easy and reliable. Simply pass the API an ASCII mathematical expression or command and it returns the result as an ASCII string. The symbolic math library is at least able to be run anywhere the main Mathomatic application can be run, and does not require an operating system beyond the ability to allocate memory on the heap with malloc(3). The library is created separately, then linked with your program.

An alternative to linking to the symbolic math library is to run Mathomatic as a sub-process and command Mathomatic through the use of Unix pipes. All input and output of the main Mathomatic application is line at a time ASCII text. Input can either be expressions and commands on the command line using the -e option, or input can just be standard input, and all output goes to standard output or whatever file the output is redirected to, making it easy to control and use Mathomatic from a completely different Unix program that is not C compatible.

Examples, documentation, and the simple Application Programming Interface (API) for using the symbolic math engine as a linkable library are in the directory "lib" in the Mathomatic source distribution. Please read the files "lib/README.txt" and "README.txt" for more developer information.

This FAQ has been written by the chief author of Mathomatic: George Gesslein II.