At the Mathomatic prompt, you can enter:
Mathomatic has about 35 different commands. They 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 equation by default.
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 (-), or the word "all", which specifies all equations. If omitted, the operation is performed on the current equation.
A greater-than symbol (>) may be appended to any command line, followed by a file name. This will redirect equation output to a file. Two greater-than symbols (>>) next to each other will append equation output to a file. For example:
list export all >filename
will output all equations to a file in exportable, single-line per equation format, so they can be read in by a different math program.
Syntax: #equation-number-to-select [new-equation]
To change the current equation number, type a pound sign (#) followed by the number of the equation you wish to select. If the number is followed by a space and a new equation, the equation at the number is replaced with the new equation.
Syntax: variable-to-solve-for
Mathomatic can solve the current equation for any single variable or for zero.
To solve for a variable, just type the variable in at the prompt. Mathomatic will proceed to manipulate the current equation until all of the solutions for the specified variable are determined. If successful, the solutions are stored in the current equation and displayed. Cubic and quintic equation solving is not supported. Quartic equations (fourth degree polynomials) can be solved if they are bi-quadratic (only degree four and degree two terms).
To solve for zero, type in "0" at the prompt. Zero solving is a special solve that will always be successful and will eliminate most divide operators from the 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-> b ; solve for "b" Equation was quadratic. 1 (a - ((((a^2) - 4)^-)*sign1)) 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->
Syntax: calculate [variable number-of-iterations]
This command prompts you for the values of each variable in the RHS (Right Hand Side) of the current equation. It then simplifies the result and automatically substitutes "sign" variables with all possible 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 the values for. The equation is not modified by this command.
This command is used to approximate the RHS and expand confusing "sign" variables in a solved equation. 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 you are using Mathomatic!
If a variable and number of iterations are supplied, 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.
1-> y=x^2+x #1: y = (x^2) + x 1-> 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-> a=b+1 ; an example of iteration #2: a = b + 1 2-> calc b 10 Enter initial b: b a = b + 10 2->
Syntax: clear [equation-number-range]
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.
Syntax: code ["c" or "java" or "integer"] [equation-number-range]
This command displays the current or specified equations in C or Java language code. The default is C code. This output should compile correctly and emulate the equation from Mathomatic. Just define and assign the independent variables used in the C or Java program.
With "code integer", integer arithmetic is assumed, otherwise double precision floating point arithmetic is assumed.
To represent factorials, the user supplied function "fact()" is called, since there is no equivalent function or operator in the C or Java language.
For the most efficient code, use the "simplify" and "optimize" commands on your equation before running this command.
Syntax: compare equation-number ["with" equation-number]
This command compares two equations 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 are identical, then the equations are definitely identical. If this command says the equations may differ, then the equations might be identical if one of the equations is too hard for Mathomatic to simplify completely.
This command first compares the Right Hand Sides of both equations, if they are solved for a variable. If they are not equal, it solves both equations for zero, so it can compare the whole equations.
1-> y=e#^x #1: y = e#^x 1-> derivative x #2: y' = e#^x 2-> compare 1 with 2 Comparing equation #1 with #2... Variable (y) in the first equation is equal to (y') in the second equation. 2->
Syntax: copy [equation-number-range]
This command simply duplicates the current or specified equations and displays them.
Syntax: derivative [variable or "all"] [order]
This command computes the symbolic derivative of a function with respect to the specified variable, using the Right Hand Side of the current equation as the function. 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 all at once. The default is to differentiate only once (order = 1).
Some examples:
1-> y=x^3+x^2+x+1 #1: y = (x^3) + (x^2) + x + 1 1-> derivative x #2: y' = (3*(x^2)) + (2*x) + 1 2-> y=a*x^n ; Show a general rule of differentiation. #3: y = a*(x^n) 3-> derivative x #4: y' = a*n*(x^(n - 1)) 4->
Syntax: divide [variable]
This command is for doing and experimenting with polynomial, complex number, and numerical division and Greatest Common Divisors (GCD). Mathomatic has a symbolic polynomial division routine which this command calls without any other processing.
This command prompts for the dividend (the main polynomial) and the divisor (what you want to divide the main polynomial by). The quotient and remainder are displayed. Then the GCD is displayed. If just numbers were entered, the LCM (Least Common Multiple) is also displayed. The LCM is the same as the Lowest Common Denominator.
A variable may be specified on the command line as the base variable of the two polynomials, but it is usually not necessary because Mathomatic automatically selects a base variable.
The Greatest Common Divisor of "a" and "b" is defined as the greatest number or polynomial that evenly divides both "a" and "b". The Euclidean algorithm is used by Mathomatic to compute the GCD for both numbers and polynomials.
The GCD is the best way to reduce any fraction to its simplest form. Just divide the numerator and denominator by the GCD, and replace them with the quotients (there will be no remainder), and your 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. Multivariate polynomials usually require something more.
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 Found polynomial Greatest Common Divisor (iterations = 1): (x^2) - (2*x) + 2 1->
Syntax: edit [file-name]
This command invokes the editor specified in the "EDITOR" environment variable.
Just type "edit" at the Mathomatic prompt to edit all 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, just specify the file name on the "edit" command line.
Syntax: eliminate variables or "all" ["using" equation-number]
This command is used to combine simultaneous equations. It will replace all occurrences of the specified variables in the current equation with solved equations, essentially eliminating the specified variables from the current equation. If you are eliminating only one variable, the equation to solve can be specified using the "using" argument. If the "using" equation number 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 Right Hand Side 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.
Here is a simple example of combining two equations:
1-> ; This input to Mathomatic arrives at the distance between two points 1-> ; in 3D space from the Pythagorean theorem (distance between two points 1-> ; in 2D space). 1-> 1-> l^2=(x1-x2)^2+(y1-y2)^2 ; Distance formula for 2D space. #1: l^2 = ((x1 - x2)^2) + ((y1 - y2)^2) 1-> d^2=l^2+(z1-z2)^2 ; Add another leg. #2: d^2 = (l^2) + ((z1 - z2)^2) 2-> eliminate l ; Combine the two equations. Solving equation #1 for (l)... #2: d^2 = ((x1 - x2)^2) + ((y1 - y2)^2) + ((z1 - z2)^2) 2-> d ; Solve to get the distance formula for 3D space. 1 #2: d = ((((x1 - x2)^2) + ((y1 - y2)^2) + ((z1 - z2)^2))^-)*sign2 2 2-> ; The coordinate of point 1 is (x1, y1, z1) and point 2 is (x2, y2, z2).
Syntax: extrema variable
This command computes the minimums and maximums of the current equation. The current equation must be a solved equation. The result is placed in the next available equation space and displayed. The current equation is not modified.
"y=f(x)" where f(x) is the RHS, 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.
The extrema of a function are simply the values of x when the slope equals zero.
1-> y=x^2 #1: y = x^2 1-> extrema x #2: x = 0 2->
This function is a parabola, with a minimum at (x = 0).
Syntax: factor ["number" [integers]] or [equation-number-range] [variables]
This command will factor integers or equations.
"factor number" will prompt for integers to factor, which may be up to 14 digits. The integers should be separated with spaces. Otherwise, the "factor" command factors variables in the current or specified equations.
When factoring an equation, it does some basic simplification and trivially factors any variables it can, unless variables are specified on the command line, in which case only those variables are factored out.
For example, with the following equation:
a = (b*c)+(b*d)
variable "b" factors out and the result of this command is:
a = 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. For example:
1-> y=b^2+b #1: y = (b^2) + b 1-> factor #1: y = b*(b + 1) 1->
This command usually cannot factor polynomials. To factor polynomials, use the "simplify" command.
Syntax: flist ["factor"] [equation-number-range]
This command displays equations in fraction format. This is the default for equation display.
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, including the numerator and denominator of fractions.
Syntax: help [topic or command-name]
This command is provided as a quick reference. If the argument is a command name, a one line description and syntax of that command is displayed. The command name may be abbreviated.
Entering this command by itself will display a list of topics and commands.
Syntax: imaginary [equation-number]
This command copies the imaginary part of a complex equation to the next available equation space. If the RHS is not complex, it will tell you and abort. A complex equation is an equation that contains both imaginary and real parts. To copy the real part, see the "real" command.
The equation to be separated should first be solved and simplified. If you want to exclude "i#" from the result, type the following command after the "imaginary" command:
replace i# with 1
Syntax: integrate variable [order]
This command computes the symbolic anti-derivative (indefinite integral) of a function with respect to the specified variable, using the Right Hand Side of the current equation as the function. If successful, the indefinite integral is placed in the next available equation space, displayed, and becomes the current equation.
Specifying the order allows you to repeatedly integrate all at once. The default is to integrate only once (order = 1).
This command is not very sophisticated and is mostly for integrating polynomials.
1-> y=x^3+x^2+x+1 #1: y = (x^3) + (x^2) + x + 1 1-> integrate x (x^4) (x^3) (x^2) #2: y = ----- + ----- + ----- + x 4 3 2 2-> derivative x ; Check the result. #3: y' = (x^3) + (x^2) + x + 1 3->
Syntax: laplace ["inverse"] variable
This command computes the Laplace transform of a function with respect to the specified variable, using the Right Hand Side of the current equation as the function. If successful, the transform is placed in the next available equation space, displayed, and becomes the current equation.
This command is mostly for polynomials and is not complete.
Inverse Laplace transforms are done with the "inverse" option.
1-> y=a*x^n #1: y = a*(x^n) 1-> laplace x a*(n!) #2: y = ----------- (x^(n + 1)) 2-> laplace inverse x #3: y = a*(x^n) 3->
Syntax: limit variable expression
This command takes the limit of the current equation as "variable" goes to "expression". "expression" may be anything, including infinity. The current equation must be a solved equation. If successful, the current equation will contain the result and be displayed.
1-> ; Compute the derivative of (x^.5) using limits: 1-> a=((x+h)^.5-x^.5)/h 1 1 (((x + h)^-) - (x^-)) 2 2 #1: a = --------------------- h 1-> limit h 0 Raising both sides to the power of 2 and unfactoring... Removing possible solution: "h = 0". 1 #1: a = --------- 1 (2*(x^-)) 2 1->
Syntax: list ["export"] [equation-number-range]
This command displays equations 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. This option has been tested with the program Maxima.
This command simply outputs equations as stored internally by Mathomatic. There is no simplification and nothing more is done.
To display equations in fraction format, see the "flist" command.
Syntax: nintegrate ["trapezoidal"] variable [partitions]
This is a numerical integrate command and it will not generally compute the exact symbolic integral except for the simplest of expressions. This command will prompt you for the lower and upper limits to perform numerical definite integration on the RHS of the current equation with respect to the specified variable. These limits may be any expression not containing infinity.
Accuracy varies widely, depending on the expression integrated and the interval. This command uses Simpson's rule to do the approximation. If "trapezoidal" is specified on the command line, the trapezoidal method is used instead, which is usually less accurate than Simpson's rule. The way the trapezoidal method works is the interval from the lower limit to the upper limit 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 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 (anti-derivative) 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. Result = -0.162561171857 1->
This example avoids the singularity at x = 1 and is accurate to 12 digits.
Syntax: optimize [equation-number-range]
This command splits the specified equations into smaller multiple equations with no repeated expressions. Each repeated expression becomes a new equation solved for a temporary variable ("temp"). Note that this command will only work if the whole expression (anything within parentheses) is repeated. It should work with partial expressions, too, to be perfect.
To undo this command and substitute the split up equations into the original equation, use the "eliminate" command.
1-> y=(a+b+c)^(a+b+c) #1: y = (a + b + c)^(a + b + c) 1-> optimize #2: temp = a + b + c #1: y = temp^temp 1-> eliminate temp ; undo the optimization Solving equation #2 for (temp)... #1: y = (a + b + c)^(a + b + c) 1->
Syntax: pause [text]
This command waits for the user the 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.
Syntax: product variable low high
This command performs a mathematical product of the RHS of the current equation as the index "variable" varies from "low" to "high". "low" and "high" should be integers. The result is stored and displayed as a new equation. 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->
Syntax: push [equation-number]
This command pushes the current or specified equation into the readline history, for easy editing and re-entry. After this command, the equation is accessed by using the cursor UP key once.
Syntax: quit
Type in this command to exit Mathomatic. All equations are discarded.
To save your equations, see the "save" 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".
Syntax: real [equation-number]
This command copies the real part of a complex equation to the next available equation space. If the RHS is not complex, it will tell you and abort. A complex equation is an equation that contains both imaginary and real parts. To copy the imaginary part, see the "imaginary" command.
The equation should be solved and simplified before this command is executed. There will be no imaginary numbers in the result.
Syntax: replace ["constants"] [variables ["with" expression]]
By default, this command prompts you for a replacement expression for each variable in the current equation. If an empty line is entered for a variable, the variable remains unchanged. The result is placed in the current equation and displayed.
This command is very useful for renaming or substituting variables in an equation. 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, all variables specified will be replaced with the expression that follows.
"replace constants" substitutes pi and e# in the current equation with their respective floating point values. This allows them to combine with other constants and may help at times.
Syntax: roots
This command displays all complex roots of a given root of a complex or real number. The number of the root is prompted for, which also equals the number of correct solutions. For example, "3" would give the 3 roots of the cubed root. Next, the real and imaginary parts of the complex number are prompted for. Just enter an empty line if the value is zero. Then each root is displayed, along with an "Inverse Check" value, which should equal the original complex number.
1-> roots Enter root (positive integer): 3 Enter real part: 8 Enter imaginary part: The 3 roots of 8^(1/3) are: 2 Inverse Check: 8 -1 +1.73205080757*i# Inverse Check: 8 -5.17814957579e-15*i# -1 -1.73205080757*i# Inverse Check: 8 -1.23388712442e-14*i# 1->
Note in the above example that slight floating point errors are introduced, due to many arithmetic operations being performed.
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.
Syntax: set ["no"] [option]
This command sets various options for the current session. They remain in effect until you exit Mathomatic. Typing "set" with no arguments shows you the current option settings.
To change the default settings of Mathomatic, put your set options in the file "$HOME/.mathomaticrc". It should be a text file with one set option per line.
"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 no 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 columns" followed by a positive integer sets the number of character columns on the screen. When an equation 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, instead of fraction format. 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). By default, equations are displayed in fraction format for easier reading.
"set preserve" will set "preserve_roots" mode, which suppresses approximation of roots of rational numbers, if the result will be irrational. For example, "2^.5" will remain "2^.5" in all Mathomatic operations.
"set true_modulus" will set true modulus mode, which is 100% mathematically correct. Pseudo-modulus mode is used by default, which is the modulus used by computer languages. Pseudo-modulus only gives the remainder of the division, which may be negative and will sometimes fail the simplification rules employed by Mathomatic. True modulus always gives a positive value or zero. This mode only affects modulus operator calculations. All true modulus simplification rules are enabled, regardless of this mode.
"set finance" sets finance mode, which displays all constants with exactly 2 digits after the decimal point (for example: "2.00"). Displayed constants are always rounded to the nearest cent, though internally there is no loss of accuracy.
"set directory" followed by a directory name will change the current working directory to that directory. This command can be shortened to "set dir".
Syntax: simplify ["symbolic" or "quick" or "poly"] [equation-number-range]
This command completely simplifies the current or specified equations.
Use this command whenever you think an equation is not completely simplified or if you don't like the way an equation is factored.
More than one option may be specified at a time.
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) only when using this option.
The "poly" option treats expressions like polynomials and sometimes simplifies better. The only difference for now is that polynomial division is tried before smart division.
This command applies some algebraic transformations and then tries to reduce fractions by finding and dividing by the GCD. Then smart (heuristic) and polynomial division are tried on any divides. Polynomials with repeated or symbolic factors are factored.
Smart division is like polynomial division, but it tries every term in the dividend, instead of just the term raised to the highest power, to make the expression smaller.
Syntax: sum variable low high
This command performs a mathematical summation of the RHS of the current equation as the index "variable" varies from "low" to "high". "low" and "high" should be integers. The result is stored and displayed as a new equation. 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->
Syntax: tally
This command prompts for a value, adds it to a running total, simplifies, displays the running total, and repeats. No equations are modified. It is a convenient way of adding and subtracting many numbers. Enter an empty line to end.
Syntax: taylor variable
This command computes the Taylor series expansion of the current equation with respect to the variable specified on the command line. The expansion is performed on the expression to the right of the equals sign only.
It prompts you for the "point" of expansion, which is usually a variable or 0, but may be any expression. Then it prompts you for the order of the series, which is an integer indicating how many derivatives to take in the expansion. The result is placed in the next available equation space, displayed, and becomes the current equation.
1-> y=e#^x #1: y = e#^x 1-> taylor x Taylor approximation of current equation about x = point. Enter point: 0 Enter order (number of derivatives to take): 10 (x^2) (x^3) (x^4) (x^5) (x^6) (x^7) (x^8) (x^9) (x^10) #2: y = 1 + x + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ------ + ------- 2 6 24 120 720 5040 40320 362880 3628800 2->
Syntax: unfactor ["fully"] [equation-number-range]
This command algebraically expands equations.
"unfactor fully" will fully expand algebraic fractions. Use this if just plain "unfactor" doesn't do enough.
Unfactoring is known as "expanding" or "multiplying out". 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.
Copyright © 2005 George Gesslein II