Author: George Gesslein II

# Mathomatic Command Reference

## Topics:

1. Introduction
2. Selecting Expressions
3. Solving Equations

## Commands:

> Approximate Calculate Clear Code Compare Copy Derivative Display | Divide Echo Edit Eliminate Extrema Factor Fraction Help | Imaginary Integrate Laplace Limit List NIntegrate Optimize Pause | Product Push Quit Read Real Replace Roots Save | Set Simplify Solve Sum Tally Taylor Unfactor Variables | Version

## Introduction

LHS is shorthand for the Left-Hand Side of an equation. Similarly, RHS used here always means the Right-Hand Side.

At the Mathomatic main prompt, you may enter:

- a numerical expression, which is instantly evaluated and displayed (autocalc),
- an algebraic expression or equation, which is stored and made the current equation,
- a variable to solve the current equation for (autosolve),
- an equation number to select as the current equation,
- a Mathomatic command (listed in this document),
- a question mark (?) for quick, short help (same as help command),
- a semicolon (;) followed by a comment (everything on a line after a semicolon is ignored),
- or an exclamation point (!) followed by a shell (or system) command.

Mathomatic has about 40 commands. They are simple English words and are described below, in alphabetical order. If the command is longer than 4 letters, you only need to type in the first 4 letters for Mathomatic to recognize the command. The command is not executed until you press the Enter key. Most commands operate on the current expression or equation by default. Some commands only operate on the current expression or the RHS of the current equation.

Many commands have an equation number range argument. An equation number range may be a single equation number, a range of equation numbers separated by a dash (like "1-7"), or the word "all", which specifies all stored expressions and equations. If omitted, the current expression or equation is assumed.

A greater-than character (>) may be appended to any command line, followed by a file name. This will redirect command output to a file. If the file already exists, it will be overwritten without asking. Two greater-than characters (>>) next to each other will append command output to a file. For example:

    list export all >filename

will output all stored expressions and equations to a file in exportable, single-line per equation format, so they can be read in by a different math program.

## Selecting Expressions

Syntax: #["+" or "−"]equation-number

To change the current equation number at the main prompt, type a pound sign (#) followed by the equation number you wish to select. The equation number may be preceded by plus (+) or minus (−), to select an equation relative to the current equation. This syntax also works when prompted for an expression, the RHS or expression at that equation number is substituted.

New feature: Selecting equations is now possible by typing only the equation number at the main prompt.

## Solving Equations

Syntax: variable or "0"

Mathomatic can solve the current equation for any single variable or for zero. Solving is usually accomplished internally by applying identical mathematical operations to both sides of the equation. The Mathomatic solve algorithm is the best possible for general algebra, however the result is not automatically verified by plugging the solutions into the original equation, this can be done manually if needed.

To automatically solve for a variable, type the variable name at the main prompt. Mathomatic will proceed to manipulate the current equation until all of the solutions for the specified variable are determined. If successful, the current equation is replaced with the solutions and then displayed. Cubic and quintic equation solving is not supported. Quartic equations (fourth degree polynomials) can be solved if they are biquadratic (only degree four and degree two terms).

Prefix the variable name with "=" to solve and swap equation sides. Typing "=" by itself will only swap equation sides of the current equation.

To solve for zero, type in "0" at the main prompt. Zero solving is a special solve that will always be successful and will transform most divide operators into equivalent multiplications and subtractions, so that the result will more likely be a valid polynomial equation.

To see all the steps performed during a solve operation, type "set debug 2" before solving.

An example of solving:

    1—> a=b+1/b

                1
    #1: a = b + -
                b

    1—> 0 ; solve for zero

    #1: 0 = (b*(b - a)) + 1

    1—> unfactor ; show that it is a quadratic polynomial equation in "b"

    #1: 0 = (b^2) - (b*a) + 1

    1—> b ; solve for "b"
    Equation was quadratic.

                           1
            (((((a^2) - 4)^-)*sign1) + a)
                           2
    #1: b = -----------------------------
                          2

    1—> a ; solve for "a", to check the answer
    Raising both sides to the power of 2 and unfactoring...

            ((b^2) + 1)
    #1: a = -----------
                 b

    1—> simplify

                1
    #1: a = b + -
                b

    1—>

## Approximate command

Syntax: approximate [equation-number-ranges]

This command substitutes pi# and e# with their respective floating point values and approximates all constants. This allows them to combine with other constants and may help with simplification and comparisons.

## Calculate command

Syntax: calculate ["repeat"] ["factor"] [variable number-of-iterations]

This command prompts for the value of each variable in the current expression or the RHS of the current equation. It then simplifies, approximates, and substitutes all "sign" variables with all possible combinations of values, displaying each solution as it does so. If all variables are supplied with constant values, then each solution will be a constant, otherwise the result will contain the variables you didn't enter values for. Nothing is modified by this command.

This command is used to temporarily plug in values and approximate expressions and expand "sign" variables. It is also automatically invoked when you type in a numeric expression, without any variables, at the Mathomatic prompt. No need to get out your calculator when using Mathomatic!

If a variable and number of iterations are specified on the command line, you will be prompted for the initial value of the variable, and the calculation will be iterated, with the result repeatedly plugged back into the specified variable. This will be done until convergence (the output equals the input) or the number of iterations is performed.

"calculate factor" factors all integers and variables before display.

"calculate repeat" causes this command to repeat until an empty line is entered.

Examples of using the calculate command:

    1—> y=x^2+x ; the simplest quadratic equation

    #1: y = (x^2) + x

    1—> x ; solve for x
    Equation was quadratic.

                                  1
            -1*(1 + (((1 + (4*y))^-)*sign1))
                                  2
    #1: x = --------------------------------
                           2

    1—> calculate
    Enter y: 0
    Solution #1 with sign1 = 1:
     x = -1
    Solution #2 with sign1 = -1:
     x = 0
    1—>

An example of iteration:

    1—> x_new=(x_old+(y/x_old))/2 ; iterative formula for calculating the square root of y

                           y
                (x_old + -----)
                         x_old
    #2: x_new = ---------------
                       2

    2—> calculate x_old 1000 ; iterate up to 1000 times to calculate the square root of 100
    Enter y: 100
    Enter initial x_old: 1
    Convergence reached after 9 iterations.

     x_new = 10

    2—>

## Clear command

Syntax: clear [equation-number-ranges]

This command clears equation spaces so that they can be reused. The specified equations are deleted from memory.

"clear all" clears all memory, as if Mathomatic was restarted.

Multiple equation numbers and/or ranges may be specified, separated by spaces, for ease in clearing out equation spaces.

## Code command

Syntax: code ["c" or "java" or "python" or "integer"] [equation-number-ranges]

This command outputs the current or specified equations as assignment statements in C, Java, or Python programming language code. The default is C code. This output should compile correctly and emulate the equation from Mathomatic.

With "code integer", integer arithmetic is assumed, otherwise double precision floating point arithmetic is assumed. "code integer" is more generic and should work with any language.

To represent factorials, the user supplied function "fact()" is called, since there is no equivalent function or operator in these languages. "fact()" functions for several languages are supplied in the directory "factorial" in the Mathomatic source distribution.

Complex number arithmetic is supported with Python only. In C and Java, complex number arithmetic as generated by this command may fail to compile or work correctly, because it has not been anticipated or tested.

For the most efficient code, use the simplify and optimize commands on your equations before running this code command.

## Compare command

Syntax: compare equation-number ["with" equation-number]

This command compares two equations or expressions for equality. If only one argument is supplied, the comparison is between the current equation and the specified equation. The comparison will be faster and more accurate if both equations are previously solved for the same variable.

If this command says the equations or expressions are identical, then they are definitely identical. If this command says the equations or expressions differ, then they might be identical if they are too hard for Mathomatic to simplify completely.

## Copy command

Syntax: copy [equation-number-range]

This command simply duplicates the current or specified equations and displays them.

## Derivative command

Syntax: derivative [variable or "all"] [order]
Alternate command name: differentiate

This command computes the exact symbolic derivative of a function with respect to the specified variable, using the current expression or RHS of the current equation as the function. It does this by recursively applying the proper rule of differentiation for each operator encountered and fully simplifying. If successful, the derivative is placed in the next available equation space, displayed, and becomes the current equation. The original equation is not modified.

Specifying "all" computes the derivative with respect to all normal variables. It is equivalent to adding together the derivatives with respect to each variable.

Specifying the order allows you to repeatedly differentiate. The default is to differentiate once (order = 1).

If differentiation fails, it is probably because symbolic logarithms are required. Symbolic logarithms are not implemented in Mathomatic. Also, factorial and modulus cannot be differentiated.

Some examples:

    1—> x^3+x^2+x+1

    #1: (x^3) + (x^2) + x + 1

    1—> derivative ; no need to specify the variable if there is only one
    Differentiating with respect to (x) and simplifying...

    #2: (3*(x^2)) + (2*x) + 1

    2—> a*x^n

    #3: a*(x^n) ; show a general rule of differentiation

    3—> derivative x
    Differentiating with respect to (x) and simplifying...

    #4: a*n*(x^(n - 1))

    4—> integrate x ; undo the differentiation

    #5: a*(x^n)

    5—>

## Display command

Syntax: display ["factor"] [equation-number-range]

This command displays stored expressions in multi-line fraction format, where division is displayed as a numerator over a fractional line (made up of dashes) over a denominator.

Non-integer constants are converted to reduced fractions, if they are exactly equal to a fraction and it would improve readability.

The "factor" option causes all integers, less than or equal to 14 digits long, to be factored into their prime factors before display, including the numerator and denominator of fractions. To always factor integers before display, use the "set factor_integers" option.

## Divide command

Syntax: divide [variable]

This command is for doing and experimenting with polynomial, complex number, and numerical division and Greatest Common Divisors (GCD). Mathomatic has general symbolic polynomial division and GCD routines which this command calls without any other processing.

This command prompts for the dividend (the main polynomial) and then the divisor (what you want to divide the main polynomial by). The quotient, remainder, and GCD are displayed. The power of the highest power term in the dividend must be greater than or equal to the power of the highest power term in the divisor, otherwise the polynomial division will fail. In other words, the degree of the divisor polynomial must be less than or equal to the degree of the dividend polynomial. A variable may be specified on the command line as the base variable of the two polynomials, but is usually not necessary because a base variable is automatically selected.

If two numbers are entered, the result of the division, the GCD, and the Least Common Multiple (LCM) are displayed. The LCM is the smallest positive number that can be evenly divided by both numbers separately, without remainder. The LCM is the same as the Lowest Common Denominator (LCD) of two fractions and is the two numbers multiplied together, divided by the GCD.

The Greatest Common Divisor of a and b (gcd(a, b)) is defined as the greatest positive number or polynomial that evenly divides both a and b without remainder. The Euclidean algorithm is used by Mathomatic to compute the GCD for numbers and polynomials. The polynomial GCD result in Mathomatic will not necessarily be a monic polynomial, however the coefficient of the term closest to zero will be unity, and all other coefficients will have an absolute value greater than or equal to 1.

The GCD is the best way to reduce any fraction to its simplest form. Just divide the numerator and denominator by their GCD, and replace them with the quotients (there will be no remainder), and the fraction is completely reduced. The GCD is also used when factoring polynomials and for simplifying.

The Euclidean algorithm of successive divides is the best way to compute the GCD for numbers and univariate polynomials (polynomials in one variable). Multivariate polynomials (polynomials in several variables) usually require recursion of the GCD algorithm or other methods.

An example of polynomial division:

    1—> divide
    Enter dividend: (x^4) - (7*(x^3)) + (18*(x^2)) - (22*x) + 12
    Enter divisor: (x^2) - (2*x) + 2

    Polynomial division successful using variable (x).
    The quotient is:
    6 + (x^2) - (5*x)

    The remainder is:
    0

    Polynomial Greatest Common Divisor (iterations = 1):
    (x^2) - (2*x) + 2
    1—>

The number of iterations displayed is the number of polynomial divides done to compute the GCD.

## Echo command

Syntax: echo [text]

This command outputs a line of text, followed by a newline. The following characters cannot be echoed: ";>".

## Edit command

Syntax: edit [file-name]

This command invokes the editor specified in the "EDITOR" environment variable. Access to shell ("/bin/sh") is required for this.

Type "edit" at the Mathomatic prompt to edit all expressions and equations stored in the equation spaces. When you are done editing Mathomatic equations and commands, save and exit the editor to have them automatically read in by Mathomatic. If Mathomatic gets an error reading in its new input, observe where the error is and continue, to automatically re-enter the editor.

To edit an existing file and have it read in, specify the file name on the edit command line.

## Eliminate command

Syntax: eliminate ["repeat"] variables or "all" ["using" equation-number]

This command is used to combine simultaneous equations. It will scan the command line from left to right, replacing all occurrences of the specified variables in the current equation with the RHS of solved equations. If you are eliminating only one variable, the equation to solve can be specified with the "using" argument. If "using" is not specified, Mathomatic will search backwards, starting at the current equation minus one, for the first equation that contains the specified variable.

The equation to solve is solved for the specified variable, then the RHS is inserted at every occurrence of the specified variable in the current equation. This effectively eliminates the specified variable from the current equation, resulting in one less unknown.

There is an advantage to eliminating multiple variables in one command: each equation will be used only once. If the same equation is solved and substituted into the current equation more than once, it will cancel out.

"eliminate all" is shorthand for specifying all normal variables on the command line. "eliminate repeat all" will eliminate all variables repeatedly until nothing more can be substituted, using each equation only once.

Here is a simple example of combining two equations:

    1—> ; This arrives at the distance between two points in 3D space from the
    1—> ; Pythagorean theorem (distance between two points on a 2D plane).
    1—> ; The coordinate of point 1, 2D: (x1, y1), 3D: (x1, y1, z1).
    1—> ; The coordinate of point 2, 2D: (x2, y2), 3D: (x2, y2, z2).
    1—>
    1—> L^2=(x1-x2)^2+(y1-y2)^2 ; Distance formula for a 2D Cartesian plane.

    #1: L^2 = ((x1 − x2)^2) + ((y1 − y2)^2)

    1—> distance^2=L^2+(z1-z2)^2 ; Add another leg.

    #2: distance^2 = (L^2) + ((z1 − z2)^2)

    2—> eliminate L ; Combine the two equations.
    Solving equation #1 for (L) and substituting into the current equation...

    #2: distance^2 = ((x1 − x2)^2) + ((y1 − y2)^2) + ((z1 − z2)^2)

    2—> distance ; Solve to get the distance formula for 3D space.

                                                                    1
    #2: distance = ((((x1 − x2)^2) + ((y1 − y2)^2) + ((z1 − z2)^2))^—)·sign2
                                                                    2

    Finished reading file "pyth3d.in".
    2—>

## Extrema command

Syntax: extrema [variable] [order]
Alternate command name: stationary

This command computes possible extrema (minimums and maximums) or possible inflection points of the current expression or equation. The result is placed in the next available equation space, displayed, and becomes the current equation. The original expression is not modified.

By default this command computes stationary points. The stationary points of function f(x) are the values of x when the slope (derivative) equals zero. Stationary points are likely the local minimums and maximums of the function, unless the point is determined to be an inflection point.

y = f(x), where f(x) is the RHS and x is the specified variable, this command gives the values of x that make the minimums and maximums of y. This is computed by taking the derivative of f(x), setting it equal to zero, and then solving for x. Results that contain the imaginary number (i#) are not extrema, and should be ignored.

The number of derivatives to take can be specified by the order parameter (default is 1). When order is 2, possible points of inflection are determined. A point of inflection is a point on a curve at which the second derivative changes sign.

    1—> y=x^2

    #1: y = x^2

    1—> extrema x

    #2: x = 0

    2—>

This function is a parabola, with the minimum at x = 0.

## Factor command

Syntax: factor ["number" [integers]] or [equation-number-range] [variables]

This command will factor manually entered integers or trivially factor expressions containing variables in equation spaces. To factor integers in equation spaces and display, use the "display factor" command.

"factor number" will prompt for integers to factor, which may be up to 14 digits. The integers should be separated with spaces. The plural "factor numbers" will repeatedly prompt for integers to factor.

When factoring expressions, it does some basic simplification and factors out any common sub-expressions it can, unless variables are specified on the command line, in which case only common sub-expressions containing those variables are factored out.

For example, with the following expression:

    (b*c) + (b*d)

variable "b" factors out and the result of this command is:

    b*(c + d)

If no variables are specified on the command line, this command factors even more. All equal bases raised to any power are factored. This is called Horner factoring or Horner's rule. For example:

    1—> x^3+2x^2+3x+4

    #1: (x^3) + (2*(x^2)) + (3*x) + 4

    1—> factor

    #1: (x*((x*(x + 2)) + 3)) + 4

    1—>

To undo the factoring, use the unfactor command.

This command cannot factor polynomials. To factor polynomials with repeated or symbolic factors, use the simplify command.

## Fraction command

Syntax: fraction [equation-number-range]

This command converts expressions with any algebraic fractions in them into a single simple algebraic fraction (usually the ratio of two polynomials). It does this by combining all algebraic fractions added together with like and unlike denominators. Note that algebraic fractions added together with like denominators are automatically combined by any Mathomatic command.

Example:

    1—> 1/x+1/y+1/z

        1   1   1
    #1: - + - + -
        x   y   z

    1—> fraction

        (((y + x)*z) + (x*y))
    #1: ---------------------
               (x*y*z)

    1—> unfactor

        ((y*z) + (x*z) + (x*y))
    #1: -----------------------
                (x*y*z)

    1—> unfactor fully

        1   1   1
    #1: - + - + -
        x   y   z

    1—>

## Help command

Syntax: help [topic or command-names]

This command is provided as a quick reference while using Mathomatic. If the argument is a command name, a one line description and one line syntax of that command are displayed. Command names may be abbreviated.

Entering this command by itself will display a list of topics and commands.

To create a Mathomatic command quick reference text file, type:

    help all >quick_ref.txt

A question mark (?) is shorthand for this help command.

## Imaginary command

Syntax: imaginary [variable]

This command copies the imaginary part of a complex expression to the next available equation space. If the expression or RHS of the equation is not complex, it will tell you and abort. A complex expression contains both imaginary and real parts. To copy the real part, see the real command.

The separation variable may be specified on the command line, the default is i#. i# is really a mathematical constant equal to the square root of -1, but it can often be specified where variables are required in Mathomatic.

If successful, the result will contain one or more of i# or the specified separation variable. If you want to exclude i# from the result, type the following command after the imaginary command:

    replace i with 1

For example:

    1—> (a+b*i#)/(c+d*i#)

        (a + (b*i#))
    #1: ------------
        (c + (d*i#))

    1—> imaginary

        ((b*i#*c) - (a*d*i#))
    #2: ---------------------
           ((c^2) + (d^2))

    2—> replace i with 1

        ((b*c) - (a*d))
    #2: ---------------
        ((c^2) + (d^2))

    2—>

## Integrate command

Syntax: integrate ["constant" or "definite"] variable [order]
Alternate command name: integral

This command computes the exact symbolic integral of a polynomial function with respect to the specified variable, using the current expression or RHS of the current equation as the function. If successful, the integral is placed in the next available equation space, displayed, and becomes the current equation.

The default is to compute and display the indefinite integral, also known as the antiderivative or primitive. The antiderivative is the inverse transformation of the derivative.

"integrate constant" simply adds a uniquely named constant of integration ("C_1", "C_2", etc.) to each integration result. The constants of integration here are actually variables that may be set to any constant.

"integrate definite" also integrates, but prompts you for the lower and upper bounds for definite integration. If g(x) is the indefinite integral (antiderivative) of f(x), the definite integral is:

    g(upper_bound) - g(lower_bound)

Specifying the order allows you to repeatedly integrate. The default is to integrate once (order = 1).

This command is not very sophisticated and is only for integrating polynomials.

    1—> x^3+x^2+x+1

    #1: (x^3) + (x^2) + x + 1

    1—> integrate x

        (x^4)   (x^3)   (x^2)
    #2: ----- + ----- + ----- + x
          4       3       2

    2—> derivative x ; check the result
    Differentiating with respect to (x) and simplifying...

    #3: (x^3) + (x^2) + x + 1

    3—> compare 1
    Comparing #1 with #3...
    Expressions are identical.
    3—>

## Laplace command

Syntax: laplace ["inverse"] variable

This command computes the Laplace transform of a polynomial function of the specified variable, using the current expression or RHS of the current equation as the function. If successful, the transformed function is placed in the next available equation space, displayed, and becomes the current equation.

This command currently only works with polynomials.

A Laplace transform can be undone by applying the inverse Laplace transform. This is accomplished by specifying the "inverse" option.

    1—> y=1

    #1: y = 1

    1—> laplace x ; compute the Laplace transform of 1

            1
    #2: y = -
            x

    2—> a*x^n ; a general polynomial term

    #3: a*(x^n)

    3—> laplace x

          a*(n!)
    #4: -----------
        (x^(n + 1))

    4—> laplace inverse x

    #5: a*(x^n)

    5—>

## Limit command

Syntax: limit variable expression

This command takes the limit of the current expression or equation as variable goes to expression. The result is placed in the next available equation space and displayed.

L'Hopital's rule for taking limits is not used by this command. Instead the limit is taken by simplifying, solving, and substituting. This command is experimental and does not know about negative infinity and occasionally gives the wrong answer when dealing with infinities.

    1—> 2x/(x+1)

          2·x
    #1: ———————
        (x + 1)

    1—> limit x inf ; take the limit as x goes to infinity
    Solving...

    #2: answer = 2

    1—>

## List command

Syntax: list ["export" or "maxima"] [equation-number-ranges]

This command displays stored expressions in single line format.

The "export" option allows display in exportable, single line format. You can cut-and-paste the equations or redirect them to a file, so they can be read in with a different math program. "list maxima" is for making output compatible with the CAS program Maxima.

This command simply outputs expressions and equations as stored internally by Mathomatic. There is no simplification and nothing more is done.

To display equation spaces in multi-line fraction format, see the display command.

## NIntegrate command

Syntax: nintegrate ["trapezoid"] variable [partitions]

This is a numerical integrate command that will work with almost any expression and will not generally compute the exact symbolic integral except for the simplest of expressions. This command will prompt you for the lower and upper bounds to perform numerical definite integration on the current expression or the RHS of the current equation, with respect to the specified variable. These bounds may be any expression not containing infinity.

This command uses Simpson's rule to do the approximation. Accuracy varies widely, depending on the expression integrated and the interval.

If "trapezoid" (can be shortened to "trap") is specified on the command line, the trapezoid method is used instead, which is usually less accurate than Simpson's rule. The way the trapezoid method works is the interval from the lower bound to the upper bound is divided into 1000 partitions to produce 1000 trapezoids. Then the area of each trapezoid is added together to produce the result. This means that the accuracy usually decreases as the interval increases. Simpson's rule uses the same method, except parabolas are used, instead of trapezoids.

If the integration fails, chances of success are greater if you reduce the number of variables involved in the integration.

If there are any singularities between the bounds of integration, the computed result will be wrong.

    1—> y=x+1

    #1: y = x + 1

    1—> nintegrate x
    Enter lower bound: 0
    Enter upper bound: x
    Approximating the definite integral using Simpson's rule...
    Integration successful.

                (x^2)
    #2: y = x + -----
                  2

    2—>

This works because if g(x) is the indefinite integral (antiderivative) of f(x), the definite integral is:

    g(upper_bound) - g(lower_bound)

In this case, it is g(x) - g(0), which is g(x) - 0, which is simply g(x).

    1—> y=x^0.5/(1-x^3)

                  1
               (x^-)
                  2
    #1: y = -----------
            (1 - (x^3))

    1—> nintegrate x
    Warning: Singularity detected, result of numerical integration may be wrong.
    Enter lower bound: 2
    Enter upper bound: 4
    Approximating the definite integral using Simpson's rule...
    Integration successful.

    #2: y = -0.162561171857

    2—>

This example avoids the singularity at x = 1 and is accurate to 12 digits.

## Optimize command

Syntax: optimize [equation-number-range]

This command splits the specified equations into smaller multiple equations with no repeated expressions. Each repeated sub-expression becomes a new equation solved for a temporary variable (named "temp"). Note that this command will only work if a whole sub-expression (anything within parentheses) is repeated within the same equation. It should work with partial sub-expressions and with single identical sub-expressions in different equations, to be perfect, but does not. Note that the resulting assignment statements may be in the wrong order for inclusion in a computer program with the code command, the order should be manually checked.

To undo this command and substitute the split up equations into the original equation, use the eliminate command.

    1—> y = (a+b+c+d)^(a+b+c+d)

    #1: y = (a + b + c + d)^(a + b + c + d)

    1—> optimize

    #2: temp = a + b + c + d

    #1: y = temp^temp

    1—> eliminate temp ; undo the optimization
    Solving equation #2 for (temp)...

    #1: y = (a + b + c + d)^(a + b + c + d)

    1—>

## Pause command

Syntax: pause [text]

This command waits for the user to press the Enter key. It is useful in text files that are read in to Mathomatic. Optionally, a one line text message may be displayed.

Typing "quit" or "exit" before pressing the Enter key will fail this command and abort the current script.

## Product command

Syntax: product variable start end [step]

This command performs a mathematical product of the current expression or the RHS of the current equation as the index variable goes from start to end in steps of step (default 1). The result is stored and displayed. The current equation is not modified.

    1—> y=a*x

    #1: y = a*x

    1—> product
    Enter variable: x
    x = 1
    To: 10

    #2: y = 3628800*(a^10)

    1—> 10!
     Answer = 3628800
    1—>

## Push command

Syntax: push [equation-number-range]

This command pushes the current or specified expressions into the readline history, for easy editing and re-entry. After this command, the pushed expressions are accessed by using the cursor UP key.

This command only exists if Mathomatic was compiled with readline support.

## Quit command

Syntax: quit
Alternate command name: exit

Type in this command to exit Mathomatic. All equations and expressions in memory are discarded. To save your stored equations and expressions beforehand, use the save command.

Another way to quickly exit Mathomatic is to enter your operating system's End-Of-File (EOF) character at the beginning of an input line. The EOF character for Unix-like operating systems is Control-D.

## Read command

Syntax: read file-name

This command reads in a text file as if you typed the text of the file in at the prompts. The text file should contain Mathomatic equations and commands. Read commands may be nested. If any command or operation returns with an error, the read operation is aborted.

Equations saved with the save command are restored using this read command.

This command is automatically executed when you start up Mathomatic with file names on the command line.

The default file name extension for Mathomatic input files is ".in". A file name extension is not required.

## Real command

Syntax: real [variable]

This command copies the real part of a complex expression to the next available equation space. If the expression or RHS of the equation is not complex, it will tell you and abort. A complex expression contains both imaginary and real parts. To copy the imaginary part, see the imaginary command.

The separation variable may be specified on the command line, the default is i#.

There will be no imaginary numbers in the result.

    2—> (a+b*i#)/(c+d*i#)

        (a + (b*i#))
    #3: ------------
        (c + (d*i#))

    3—> real

        ((a*c) + (b*d))
    #4: ---------------
        ((c^2) + (d^2))

    4—>

## Replace command

Syntax: replace [variables ["with" expression]]

By default, this command prompts you for a replacement expression for each variable in the current expression or equation. If an empty line is entered for a variable, that variable remains unchanged. The result is placed in the current expression or equation and displayed.

This command is very useful for renaming or substituting variables. It is smart enough to do variable interchange.

If variables are specified on the command line, you will be prompted for those variables only and all other variables will be left unchanged.

If "with" is specified, you won't be prompted and all variables specified will be replaced with the expression that follows.

## Roots command

Syntax: roots root real-part imaginary-part

This command displays all complex number roots of a given positive integer root of a complex number. The number of the root equals the number of correct solutions. For example, "3" would give the 3 roots of the cubed root. This command will also convert rectangular coordinates to polar coordinates.

The floating point real part (X coordinate) and imaginary part (Y coordinate) of the complex number are prompted for. Just enter an empty line if the value is zero. The polar coordinates of the complex number are displayed first, which consist of an amplitude (distance from the origin) and an angle (direction). Then each root is displayed, along with an "Inverse check" value, which should equal the original complex number. The "Inverse check" is calculated by repeated complex number multiplication of the root times itself.

Since double precision floating point is used, the results are only accurate from 10 to 12 decimal digits.

    1—> roots
    Enter root (positive integer): 3
    Enter real part (X): 8
    Enter imaginary part (Y):

    The polar coordinates are:
    8 amplitude and 0 radians (0 degrees).

    The 3 roots of (8)^(1/3) are:

    2
    Inverse check: 8

    -1 +1.73205080757*i
    Inverse check: 8

    -1 -1.73205080757*i
    Inverse check: 8

    1—>

## Save command

Syntax: save file-name

This command saves all equations in the specified text file. If the file exists, Mathomatic will ask you if you want to overwrite it. The saved equations can be reloaded at a later time by using the read command. You can edit the saved equations with your favorite ASCII text editor.

## Set command

Syntax: set [["no"] option]

This command sets various options listed below, for the current session. They remain in effect until you exit Mathomatic. Typing "set" without arguments shows the current option settings.

The specified option is turned on, unless it is preceded by "no", which turns it off.

To change the default settings of Mathomatic, set options can be put in the file "~/.mathomaticrc" (for Windows: "mathomatic.rc" in the same directory as the Mathomatic executable). It should be a text file with one set option per line, without the word "set". This file is loaded every time Mathomatic starts up, when not in test or secure mode.

### Options:

> "set no autosolve" will disable solving by typing the variable at the prompt. This allows entry of single variable expressions. When disabled, use the solve command.

> "set no autocalc" will disable automatic approximation (calculation) of purely numerical input. Instead, numerical input will be entered into equation spaces, so it can be operated on by commands.

> "set debug" followed by an integer sets the debug level number. The initial debug level is 0, for no debugging. If the level number is 2, Mathomatic will show you how it solves equations. Level 4 debugs the simplify command and its polynomial routines. Levels 5 and 6 show all intermediate expressions. Set the debug level to -1 for suppression of unnecessary helpful messages.

> "set case" will set alphabetic case sensitive mode, while "set no case" will set case insensitive mode (all alphabetic characters will be converted to lower case). "set case" is the default.

> "set color" enables color mode. When color mode is on, ANSI color escape sequences are output to make equations easier to read. Requires a terminal emulator that supports ANSI color escape sequences.

> "set bold_colors" enables highlighting in ANSI color mode. It makes all output brighter. Use this if any colors are difficult to see. This command can be shortened to "set bold".

> "set columns" followed by a positive integer sets the number of character columns on the screen. When an expression is displayed in fraction format and it is wider than the number of screen columns, single line format is used, instead. "set no columns" does no checking for screen size and always displays in fraction format. In most cases, this value is set automatically on startup.

> "set no display2d" will set the display mode to single line format (one dimensional), instead of the default fraction format (two dimensional). Single line format is useful when feeding Mathomatic output into another program. An additional effect of "set no display2d" is constants will not be converted to fractions (i.e.: 1/2 will display as 0.5).

> "set preserve" will set "preserve_roots" mode, which suppresses approximation of roots of real rational numbers, if the result will be irrational. For example, 2^.5 will remain 2^.5 unless explicitly approximated. This is the default.

> "set true_modulus" sets true modulus mode, which is 100% mathematically correct and the modulus used in number theory. Pseudo-modulus mode is used by default, which is the modulus used by the C and Java computer languages. Pseudo-modulus only gives the remainder of the division, which may be negative when the dividend is negative, and will sometimes fail the simplification rules employed by Mathomatic. True modulus always gives a positive value or zero. This mode only affects modulo operator calculations. All true modulus simplification rules are enabled, regardless of this mode.

> "set finance" sets finance mode (fixed point display), which displays all constants with 2 digits after the decimal point (for example: "2.00"). Displayed constants are rounded to the nearest cent, though internally there is no loss of accuracy. The number of digits to display after the decimal point may be specified, the maximum is 50. This is not truly fixed point arithmetic, it is floating point displayed as fixed point. With double precision floating point, only the most significant 14 decimal digits will ever be correct. The default is no fixed point display (finance = 0).

> "set factor_integers" sets automatic factoring of integers for all displayed expressions. When set, all integers up to 14 digits are factored into their prime factors before the result of any command is displayed. This command can be shortened to "set factor".

> "set right_associative_power" associates power operators from right to left, in the absence of parentheses, so that x^a^b is interpreted as x^(a^b). The default is "set no right", which associates power operators the same as all other operators, from left to right, resulting in (x^a)^b which is x^(a*b).

> "set special_variable_character" followed by an ASCII character will allow Mathomatic to use that character in variable names. For example, "set special $" will allow variable names like "$a" and "a$". The default is backslash (\).

> "set directory" followed by a directory name will change the current working directory to that directory. Not specifying a directory name defaults to your home directory. This command can be shortened to "set dir".

## Simplify command

Syntax: simplify ["symbolic"] ["quick"] ["fraction"] [equation-number-range]

This command fully simplifies expressions in place. The result is usually the smallest possible, easily readable expression.

Use this command whenever you think an expression is not completely simplified or if you don't like the way an expression is factored.

More than one option may be specified at a time.

### Options:

> The "symbolic" option indicates (a^n)^m should always be reduced to a^(n*m). This removes any absolute value operations: ((a^2)^.5 = a^(2*.5) = a^1 = a).

> The "quick" option skips expanding expressions raised to the power of 2 or higher, like (x+1)^5. Algebraic fractions are kept simple (no fractions within fractions) when using this option.

> The "fraction" option fully simplifies any expression with division in it down to the ratio of two polynomials or expressions, like Maxima's ratsimp() function does. The result will be a single simple algebraic fraction, like the fraction command produces, the difference here being it will be completely simplified. This is accomplished by full simplification without doing polynomial or smart division on the divide operators.

This command applies many algebraic transformations and their inverses (for example, unfactor and factor) and then tries to combine and reduce algebraic fractions and rationalize their denominators. Complex fractions are converted to simple fractions by making the denominators of fractions added together the same, combining and simplifying. Polynomials with repeated or symbolic factors are factored next. Then smart (heuristic) and polynomial division are tried on any divides, possibly making complex fractions if it reduces the expression size. Lastly, the expressions are nicely factored and displayed.

Smart division (heuristic division) is like polynomial division, but it tries every term in the dividend, instead of the term raised to the highest power, to make the expression smaller.

    1—> (x+2^.5)^3 ; an irrational polynomial with repeated factors

                1
    #1: (x + (2^-))^3
                2

    1—> unfactor ; multiply it out

                            1                   1
    #1: (x^3) + (3*(x^2)*(2^-)) + (6*x) + (2*(2^-))
                            2                   2

    1—> simplify ; put it back together, since factored is its simplest form

                1
    #1: (x + (2^-))^3
                2

    1—>

## Solve command

Syntax: solve variable or "0"

This command automatically solves the current equation for the specified variable or for zero. The current equation is replaced with the result. See Solving Equations.

## Sum command

Syntax: sum variable start end [step]

This command performs a mathematical summation of the current expression or the RHS of the current equation as the index variable goes from start to end in steps of step (default 1). The result is stored and displayed. The current equation is not modified.

    1—> y=a*x

    #1: y = a*x

    1—> sum
    Enter variable: x
    x = 1
    To: 10

    #2: y = 55*a

    1—>

## Tally command

Syntax: tally ["average"]

This command prompts for a value, adds it to a running (grand) total, simplifies and displays the running total and optional average, and repeats. The average is the arithmetic mean, that is the running total divided by the number of entries. No equation spaces are used.

It is a convenient way of adding, subtracting, and averaging many numbers and/or variables. Enter a minus sign (−) before each value you wish to subtract. Enter an empty line to end.

## Taylor command

Syntax: taylor [variable] [order] [point]

This command computes the Taylor series expansion of the current expression or RHS of the current equation, with respect to the specified variable. The Taylor series uses differentiation and is often used to approximate expressions near the specified point.

The Taylor series of f(x) at point a is the power series:

    f(a) + f'(a)*(x-a)/1! + f''(a)*(x-a)^2/2! + f'''(a)*(x-a)^3/3! + ...

where f'(x) is the first derivative of f(x) with respect to x, f''(x) is the second derivative, etc.

This command prompts you for the point of expansion, which is usually a variable or 0, but may be any expression. Typically 0 is used to generate Maclaurin polynomials.

Then it prompts you for the order of the series, which is an integer indicating how many derivatives to take in the expansion (default is infinity, until the derivative reaches 0).

The result is placed in the next available equation space, displayed, and becomes the current equation. The original expression is not modified.

    1—> e^x

    #1: e#^x

    1—> taylor
    Taylor series expansion around x = point.
    Enter point: 0
    Enter order (number of derivatives to take): 10
    10 derivatives applied.

                (x^2)   (x^3)   (x^4)   (x^5)   (x^6)   (x^7)   (x^8)   (x^9)    (x^10)
    #2: 1 + x + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ------ + -------
                  2       6      24      120     720    5040    40320   362880   3628800

    2—>

## Unfactor command

Syntax: unfactor ["fully"] [equation-number-range]
Alternate command name: expand

This command algebraically expands expressions by multiplying out products of sums and exponentiated sums.

"unfactor fully" fully expands by also expanding algebraic fractions, separating each fraction with a sum in the numerator into smaller fractions with the same denominator for each term in numerator.

To illustrate what unfactoring does, suppose you have the following equations:

    1—> a=b*(c+d)

    #1: a = b*(c + d)

    1—> z=(x+y)^2

    #2: z = (x + y)^2

    2—> unfactor all

    #1: a = (b*c) + (b*d)

    #2: z = (x^2) + (2*x*y) + (y^2)

    2—>

(x+y)^2 is converted to (x+y)*(x+y) and then multiplied out.

## Variables command

Syntax: variables ["c" or "java" or "integer"] [equation-number-range]

Output all variable names within the specified equations, from most frequent to least frequently occurring. The programming language options output the variable definitions required to make code from the specified equations. This does not initialize any variables.

## Version command

Syntax: version

Outputs the Mathomatic version number, compile flags used, and maximum memory usage for the currently running version of Mathomatic. The maximum memory usage displayed does not include stack size (which varies) or executable size.

Copyright © 1987-2008 George Gesslein II

Mathomatic Home Page