Mathomatic Version 12.3 User's Manual

Introduction

Mathomatic is a symbolic interpreter that can:

Mathomatic was originally written in Microsoft C for MS-DOS. The C source code is highly portable and will compile and run under any operating system. The memory requirements are about 10 megabytes.


Startup

SYNOPSIS
mathomatic [-c] [-h] [-m number] [input_files]

To start the Mathomatic interpreter, type "mathomatic" at the shell prompt.

ANSI color mode is enabled by default. Color mode can be toggled by the "-c" option. ANSI color mode outputs ANSI escape sequences to make each level of parentheses a different color, to improve readability.

HTML color mode is enabled by the "-h" option. This makes Mathomatic output suitable for inclusion in a web page. A black background is recommended.

"-m" is the memory size multiplier option. It sets the memory size of equation spaces. It is followed by a floating point number which is a multiplier of the default equation size. Please don't set this higher than 10, unless you know what you are doing.

After any options, file names may be specified on the command line that will be read in with the "read" command.


Equations

Mathomatic equations are entered into equation spaces. The number of available equation spaces is displayed every time Mathomatic starts up (usually 40).

The Mathomatic prompt contains the number of the current equation space (origin 1).

To enter an equation into the first available equation space, simply type the equation at the prompt. Equations consist of a Left Hand Side (LHS) and a Right Hand Side (RHS). The equation sides are separated by one, and only one, equals sign (=). An equation side consists of an algebraic mathematical expression, which is a mix of variables, constants, and operators, mostly in infix notation. Parentheses are used to override operator precedence and group things together.

Shown below is a valid equation with its parts labeled:

                equation
        -----------------------
        | variables   constant|
        |--------------     | |
        ||     |      |     | |
         a  =  b  -  (c  +  2)
        | |   |   |      |    |
        | |   |   --------    |
        | |   |   operators   |
        ---   -----------------
        LHS          RHS

In the above equation, the variable (a) is called the dependent variable because its value depends on the variables (b) and (c). (b) and (c) are called independent variables. In Mathomatic, any variable can be made the dependent variable by simply typing the variable name in at the prompt. This will solve the equation for that variable and, if successful, make that variable the LHS.

Here is the above equation entered into Mathomatic and solved for (b):

1-> a=b-(c+2)

#1: a = b - c - 2

1-> b

#1: b = 2 + c + a

1-> 

Constants

Constants are decimal, IEEE double precision (14 digit) floating point numbers. They may be entered in normal, scientific, or hexadecimal notation. They are displayed in normal or scientific notation, whichever is shortest.

To enter a constant in hexadecimal, prepend it with "0x".

Examples of equivalent constants follow:

Normal Notation Scientific Notation Hexadecimal Notation
10 1e1 (1.0 times 101) 0xa
.125 1.25e-1 (1.25 times 10-1) 0x.2
255 2.55e2 (2.55 times 102) 0xff

Mathomatic results are almost always accurate to 12 digits. It is possible to get a result that is accurate to less digits, due to floating point inexactness, but you would have to really try.

The infinity constant is entered by typing "inf" or "infinity".

Variables

Variables are what Mathomatic is all about. That is where the term "symbolic" comes from, because variables are symbolic in nature. They can represent known or unknown values, or any expression.

Variables consist of any combination of letters, digits, underscores (_), and backslashes (\). They never start with a digit. Variables may be up to 80 characters long.

The following variables are predefined and are not normal variables:

e# - The universal constant e (2.718281828...).
p# or pi - The universal constant pi (3.1415926...).
i# - The imaginary number (square root of -1).
sign, sign1, sign2, sign3, ... - may be +1 or -1.
integer - may be any integer.

By default, upper case letters in variable names are automatically converted to lower case. To allow upper and lower case letters in variable names, use the "set case" command.

To automatically enter a unique (sign) variable, precede any expression with "+/-".

Operators

Operators have precedence decreasing as indicated:

- negate                               (unary prefix operator)
! factorial                            (unary postfix operator)
^ power                                (binary infix operator)
* multiply    / divide      % modulus  (binary infix operators)
+ add         - subtract               (binary infix operators)
= equate                               (signifies equivalence)

Operators in the same precedence level are evaluated left to right.

The negate operator "-" may precede any expression. The negate operator has the highest precedence of all operators. This is different from many math programs, where negate has been erroneously given the same precedence as times/divide. So things like "-2^x" will give the expected -2 to the power of x, and not "-1*(2^x)", which are completely different.

The default operator for variables is multiply ("*"). If a variable is entered when an operator is expected, a multiply operator is automatically inserted.

The modulus operator "a % b" gives the numerical remainder of the division "a / b".

Standard absolute value notation is allowed. "|x|" is converted to "(x^2)^.5". This doesn't always work as expected, but works enough to be useful.

The following example shows why operator precedence is important. Given the equation:

a = 64/-2^4 + 6*(3+1)

Mathomatic will first parenthesize the highest precedence operator (power) and then the lower precedence operators (times and divide). Addition and subtraction are the lowest precedence, so no need to parenthesize them. The result will be:

a = (64/(-2^4)) + (6*(3+1))

Mathomatic will evaluate this by combining constants from left to right on the same level of parentheses, deepest levels first. So the calculations are performed in the following order:

a = (64/16) + (6*4)   Combine deepest level parentheses first.

a = 4 + 24            Divided 64 by 16 and then multiplied 6 by 4.

a = 28                Added 24 to 4.

If the calculations were performed in a different order, the result would be different.

Complex Numbers

Mathomatic can perform complex number addition, subtraction, multiplication, and division. It can also do roots and powers of complex numbers.

Complex numbers are in the form:

a + b*i#

where "a" is the "real part" and "b" is the "imaginary part". "a" and "b" may be constants, variables, or expressions. "i#" represents the square root of -1.

The imaginary number "i#" may appear anywhere within an equation, as many times as you want. Mathomatic will handle it properly.


Commands

Please consult the Mathomatic Command Reference, for detailed information on commands. It is available in the file "am.htm".


Copyright © 2005 George Gesslein II


Up to the Mathomatic Home Page