Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 86c3d80c4d6e905f610c100030811165 > files > 15

mathomatic-14.5.5-1mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>Mathomatic User's Manual</title>

<meta name="description" content="The User Manual for the Mathomatic computer algebra system.">
<meta name="author" content="George Gesslein II">

<link rel="home" href="http://mathomatic.org">
<link rel="toc" href="index.html">
<link rel="author" href="http://www.google.com/profiles/georgegesslein">
<link rel="copyright" href="http://www.opensource.org/licenses/lgpl-2.1.php">
<link rel="next" href="am.html">
<link rel="previous" href="index.html">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="doc.css">
</head>

<body>
<center>
<h1>Mathomatic User's Manual</h1>
<img src="greenfade.png" alt="decoration">
</center>

<h3>Table of Contents</h3>

<ol>
<li>
<a href="#introduction">Introduction</a>
<li>
<a href="#history">History</a>
<li>
<a href="#requirements">Requirements</a>
<li>
<a href="#startup">Startup</a>
<li>
<a href="#equations">Equations and Expressions</a>
<ol type="a">
<li>
<a href="#constants">Constants</a>
<li>
<a href="#variables">Variables</a>
<li>
<a href="#operators">Operators</a>
<ol>
<li>
<a href="#order">Order of Operations example</a>
</ol>
<li>
<a href="#complex">Complex Numbers</a>
</ol>
<li>
<a href="#commands">Commands</a>
</ol>

<p>
<a href="am.html">Mathomatic Command Reference</a>

<hr>

<a name="introduction"></a>
<h2>Introduction</h2>
<p>
Mathomatic is an interactive symbolic-numeric math interpreter that can:

<ul>
<li>
combine and solve equations containing many variables;
<li>
completely simplify and compare mathematical expressions and equations;
<li>
do simple calculus transformations and series;
<li>
perform simultaneous real number, imaginary number, and polynomial arithmetic;
<li>
generate efficient C, Java, or Python language code from simplified equations;
<li>
carry out quick formula calculations, etc.
</ul>

<hr>

<a name="history"></a>
<h2>History</h2>
<p>
Mathomatic development started in the year 1986,
originally using the Microsoft C compiler for MS-DOS,
and was first released as a Dynacomp product and as shareware.
It was later ported to the GNU C Compiler (GCC) under Linux and became free software by
publishing under the GNU Lesser General Public License (LGPL version 2.1).
It is now fully functional
and available compiled and ready to run for Linux,
Mac OS X, and Microsoft Windows.

<hr>

<a name="requirements"></a>
<h2>Requirements</h2>
<p>
Building from source requires a C compiler with the standard C libraries.
If compiled with the <a href="http://gcc.gnu.org">GCC</a> C compiler
for a Unix-like operating system,
no changes need to be made to the source code.
<p>
Mathomatic can easily be ported to any computer with at least 1 megabyte of free RAM.
In the standard distribution,
found on the <a href="http://mathomatic.org">Mathomatic home page</a>,
the maximum memory usage defaults to 200 megabytes
(the <a href="am.html#version">version command</a> tells this).
Maximum memory usage is not reached unless all equation spaces are filled.
The default maximum memory usage should be less than the amount of free RAM,
and is adjusted by changing the DEFAULT_N_TOKENS define
in the C include file <i>am.h</i> and recompiling.
<p>
Very little disk space is required to compile, install, and run Mathomatic.
A readline library must be installed to use readline input editing and history.

<hr>

<a name="startup"></a>
<h2>Startup</h2>
<dl>
<dt>
SYNOPSIS
<dd>
<b>mathomatic [ options ] [ input_files ]</b>
<br>
<b>rmath [ input_files ]</b>
</dl>
<p>
To start the interactive Mathomatic interpreter,
run a terminal emulator which opens a shell window,
and type "mathomatic" at the shell prompt.
If m4 (macro) Mathomatic was installed, you may type "rmath" instead, to
use Mathomatic with input of functions like <tt>sin(x)</tt> and <tt>sqrt(x)</tt>
allowed and automatically expanded to equivalent algebraic expressions.
Logarithm function input is currently not available.
<p>
Color mode is toggled by the <b>-c</b> option on the shell command line,
like this:

<pre class="indent">
$ mathomatic -c
</pre>

ANSI color mode outputs ANSI terminal escape sequences
to make each level of parentheses a different color, to improve readability.
ANSI color mode is on by default, requiring an ANSI compatible terminal emulator.
If the colors are hard to see,
use the <b>-b</b> option (bold colors) instead,
to enable color mode and increase the brightness.
<p>
The other options are described in the <a href="mathomatic.1.html">man page</a>.
After any options, file names may be specified
that will be read in with the <a href="am.html#read">read command</a>.
<p>
It is recommended that the name <i>mathomatic</i> be shortened to <i>am</i>
for quicker and easier access from the shell command line.
This can be done in the Bash shell by adding the following line to your <i>~/.bashrc</i> file:

<pre class="indent">
alias am=mathomatic
</pre>

<p>
Then just typing "am" at the shell prompt will bring up Mathomatic.
If color mode doesn't work right, use this instead:

<pre class="indent">
alias am="mathomatic -c"
</pre>

<p>
to turn off color.  "am" stands for algebraic manipulator.

<hr>

<a name="equations"></a>
<h2>Equations and Expressions</h2>
<p>
Algebraic equations and expressions are entered
into <strong>equation spaces</strong> by typing
or <a href="am.html#read">reading</a> them in.
The maximum number and size of available equation spaces is displayed
every time Mathomatic starts up.
When an expression grows larger than half the equation space size,
processing stops and the "Expression too large" message is displayed,
returning you to the main prompt.
<p>
Each equation space is successively numbered with an <strong>equation number</strong> (starting at 1).
The main prompt "<tt>1&mdash;&gt;&nbsp;</tt>" contains the equation number of the current equation space.
This current equation number can be changed by typing an existing equation number at the main prompt,
or by entering another equation or expression.
<p>
To enter an equation into the first available equation space
and make it the current equation, simply type it in at the main prompt.
Each equation space consists of two equation sides,
called the Left Hand Side (LHS) and the Right Hand Side (RHS),
separated by an equals sign (<b>=</b>).
An equation side consists of an algebraic expression,
which is a mix of <a href="#constants">constants</a>,
<a href="#variables">variables</a>, and <a href="#operators">operators</a>,
mostly in standard infix notation.
Parentheses are used to override operator precedence and group things together.
Valid parentheses characters are <b>()</b> and <b>{}</b>.
<p>
Note that the equals sign does not make an assignment to any variables,
it only signifies equality (sameness) between the results of evaluating the LHS and RHS.
Shown here is a valid equation with its parts labeled:

<pre class="indent">
       equation
-----------------------
| variables   constant|
|--------------     | |
||     |      |     | |
<b> a  =  b  -  (c  +  2)</b>
| |   |   |      |    |
| |   |   --------    |
| |   |   operators   |
---   -----------------
LHS          RHS
</pre>

<p>
In the above equation, the variable <b>a</b> is called the <strong>dependent</strong>
variable because its value depends on the <strong>independent</strong> variables <b>b</b> and <b>c</b>.
In Mathomatic,
any variable can be made the dependent variable by simply typing
the variable name in at the prompt.
This will <a href="am.html#solving">solve</a> the current equation
for that variable and, if successful, make that variable the LHS.
<p>
Here is the above equation entered into Mathomatic and solved for <b>b</b>,
then <a href="am.html#calculate">calculated</a> for the values <b>a=1</b> and <b>c=1</b>:

<pre class="sample">
1&mdash;&gt; a=b-(c+2)

#1: a = b &minus; c &minus; 2

1&mdash;&gt; b

#1: b = 2 + c + a

1&mdash;&gt; calculate
Enter a: 1
Enter c: 1

 b = 4

1&mdash;&gt; 
</pre>

<p>
The "<tt>#1:</tt>" listed in front of each displayed equation
always indicates the equation space number it is stored in.
<p>
Mathomatic automatically does both symbolic and numerical computations
during any manipulations.
This means that it can handle algebraic formulas, as well as numbers.
What follows is an example of the result of both types of computations
working together during equation simplification and solving:

<pre class="sample">
1&mdash;&gt; 3(x-1) + 1 = 2x + 1 

#1: (3&middot;(x &minus; 1)) + 1 = (2&middot;x) + 1

1&mdash;&gt; simplify

#1: (3&middot;x) &minus; 2 = (2&middot;x) + 1

1&mdash;&gt; solve for x

#1: x = 3

1&mdash;&gt; 
</pre>

<p>
Non-equations, that is any mathematical expression without an equals sign,
may be entered into equation spaces, too.
However, if the expression entered at the main prompt contains no variables,
it will only be <a href="am.html#calculate">calculated</a> and displayed without storing,
unless the <a href="am.html#set">autocalc or auto</a> option is turned off.
Non-equations cannot be solved.

<a name="constants"></a>
<h3>Constants</h3>
<p>
In Mathomatic, numerical arithmetic is double precision floating point
with up to 14 decimal digits accuracy.
Many results will be exact.
<p>
Constants are approximated real numbers stored internally as
IEEE 754 standard 64-bit (8 bytes) double precision floating point values.
They may be entered as normal decimal (base 10) numbers or in scientific notation
(also called exponential notation).
Constants may also be entered using hexadecimal (base 16) notation
by prepending it with "0x".
<p>
Constants are displayed in decimal (rounded to 14 digits) in normal or scientific notation,
whichever is shortest.
Results are usually accurate from 12 to 14 digits, due to accumulated round-off error,
because all constants are stored as double precision floats.
The amount of round-off error is not tracked.
<p>
Excepting constants with a name (like "inf" for the infinity constant),
constants always start with a decimal digit (0..9) or a period.
<p>
Examples of equivalent constants follow:
</p>

<table summary="constant notation examples" border=1 cellpadding=5>
<tr>
<th>
Normal Notation (base 10)
</th>
<th>
Scientific Notation (base 10)
</th>
<th>
Hexadecimal Notation (base 16)
</th>
</tr>
<tr>
<td>
10
</td>
<td>
1e1 (1.0 times 10<sup>1</sup>)
</td>
<td>
0xa
</td>
</tr>
<tr>
<td>
.125
</td>
<td>
1.25e-1 (1.25 times 10<sup>-1</sup>)
</td>
<td>
0x.2
</td>
</tr>
<tr>
<td>
255
</td>
<td>
2.55e2 (2.55 times 10<sup>2</sup>)
</td>
<td>
0xff
</td>
</tr>
</table>

<p>
The exact syntax to enter constants as above may be found by
looking up the C library <code>strtod(3)</code> function.
In the Unix shell, <tt>"man strtod"</tt> will do this.

<ul>
<li>
The largest value of a constant is &plusmn;1.7e+308.
<li>
The smallest value of a constant is &plusmn;2.3e-308.
</ul>
<p>
The infinity constant is entered by typing "inf".
Positive and negative infinity are distinct and understood,
however division by zero produces one infinity value,
not the two-valued &plusmn;infinity which would be more correct.
Also, floating point overflow produces either positive or negative infinity.

<pre class="sample">
1&mdash;&gt; 1/0
Warning: Division by zero.

 answer = inf

1&mdash;&gt; 0/0
Warning: Division by zero.

 answer = nan

1&mdash;&gt;
</pre>

<p>
<i>nan</i> or <i>NaN</i> stands for <b>Not a Number</b> and it
means an invalid or indeterminate floating point arithmetic result.
<i>NaN</i> cannot be directly entered into Mathomatic.
The appearance of <i>NaN</i> in an expression means the expression is unusable.
<p>
Fractions (such as <b>100/101</b>) are preserved if
the numerator and denominator are not large.
Fractions are always presented in fully reduced form;
for example, <b>6/9</b> is converted to the irreducible fraction <b>2/3</b>.
Constants which are exactly equal to a fraction are converted and displayed
as fully reduced fractions; for example, <b>0.5</b> converts to <b>1/2</b>.
Mathomatic internally converts a fraction to a single floating point value,
then may convert it back to a fraction for display
after all floating point arithmetic has been done,
if the result is equal to a fraction.
<p>
Irrational numbers, such as the square root of two (<b>2^(1/2)</b>) and <b>pi</b>,
are preserved and simplified,
unless explicitly approximated.
<p>
Denominators are usually rationalized in Mathomatic, so <b>1/(2^(1/2))</b> becomes
the equivalent <b>(2^(1/2))/2</b>.

<a name="variables"></a>
<h3>Variables</h3>
<p>
Variables are what Mathomatic is all about.
That is where the term "symbolic" comes from,
because variables are symbolic in nature.
They are symbols that can represent known or unknown values,
or any expression.
Variables need not be defined in Mathomatic,
just entering the variable name is enough.
<p>
Variable names consist of any combination of letters (a..z),
digits (0..9), and underscores (_).
They never start with a digit.
By using the "<a href="am.html#set">set</a> special_variable_characters" command,
you can add to the allowed variable name characters.
By default, letters in variable names are case sensitive,
meaning the alphabetic case of each letter in the variable name is important.
For example, variables named "A1" and "a1" represent two different variables,
unless "<a href="am.html#set">set</a> no case" is entered beforehand.
<p>
The following variables are predefined and are not normal variables:

<pre class="indent">
<b>e</b> or <b>e#</b> - the universal constant e (2.718281828&hellip;)
<b>pi</b> or <b>pi#</b> - the universal constant pi (3.1415926&hellip;)
<b>i</b> or <b>i#</b> - the imaginary unit (square root of -1)
<b>sign</b>, <b>sign1</b>, <b>sign2</b>, &hellip; - may only be +1 or -1
<b>integer</b> - may only be an integer value
</pre>

<p>
To automatically enter multiplication by a unique, two-valued "sign" variable,
precede any expression with "+/&minus;".

<a name="operators"></a>
<h3>Operators</h3>
<p>
Mathomatic implements the standard rules of algebra for
addition (<b>+</b>), subtraction (<b>&minus;</b>), multiplication (<b>*</b>),
division (<b>/</b>), modulo division (<b>%</b>), and all forms of exponentiation (<b>^</b> or <b>**</b>).
An example of a rule of algebra is <b>2*x + 3*x</b> being simplified to <b>5*x</b>.
<p>
All available operators are at least numerically capable and
have precedence decreasing as indicated:

<pre class="indent">
- negate (highest precedence)
! factorial (gamma function)
** or ^ power (exponentiation)
* multiply      / divide        % modulus       // integral divide
+ add           &minus; subtract
= equate (lowest precedence)
</pre>

<p>
Higher precedence operators are grouped (or evaluated) first,
then multiple operators of the same precedence level are grouped left to right.
This is called the "<a href="#order">order of operations</a>".
<p>
The negate operator (<b>-x</b>) may precede any expression and
has the highest precedence of all operators,
similar to the C programming language.
This is different from other math programs, where negate
has been given the same precedence as times and divide.
So in Mathomatic <b>-2^x</b> will give the expected <b>(-2)^x</b>,
and not <b>-1*(2^x)</b>, which are completely different.
This behavior is now configurable with the
"<a href="am.html#set">set</a> negate_highest_precedence" option.
<p>
The default operator is multiply (<b>*</b>).
If an expression (operand) is entered when an operator is expected,
a multiply operator is automatically inserted.
For example, entering <b>2x</b>, <b>2(x)</b>, and <b>(2)(x)</b>
all result in the expression <b>2*x</b>.
<p>
The modulo operator <b>a % b</b> (spoken as "a modulo b")
gives the remainder of the division <b>a / b</b>.
The sign of the result depends
on the "<a href="am.html#set">set</a> modulus_mode" option.
Using the "integer" variable allows further simplification here.
<p>
The integral divide operator <b>a // b</b> divides <b>a</b> by <b>b</b>
and then truncates by zeroing the fractional part to make the result an integer.
For example, <b>8 // 3</b> results in 2, which is useful when doing integer arithmetic.
<p>
Factorials <b>x!</b> use the gamma function <b>gamma(x+1)</b>,
so that they work with any real number, not just the positive integers.
<p>
Currently no rules of algebra are implemented for the integral divide operator (<b>//</b>)
and factorials (<b>!</b>), and these two operators will not evaluate if an operand is a complex number.
<p>
Absolute value notation is allowed, <b>|x|</b> is converted to <b>(x^2)^.5</b>.
This is not the same as standard absolute value
where the real and imaginary parts of complex numbers are separated and then squared,
but it works the same when given real (non-complex) number values.

<a name="order"></a>
<h4>Order of Operations example</h4>
<p>
The following example shows why operator precedence is important.
Given the numerical expression:

<pre class="indent">
64/-2^4 + 6*(3+1)
</pre>

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

<pre class="indent">
(64/((-2)^4)) + (6*(3+1))
</pre>

<p>
This is evaluated 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:

<pre class="indent">
(64/16) + (6*4)   Combine deepest level parentheses first.
4 + 24            Divided 64 by 16 and multiplied 6 by 4.
28                Added 24 to 4.
</pre>

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

<a name="complex"></a>
<h3>Complex Numbers</h3>
<p>
Mathomatic automatically performs complex number addition, subtraction,
multiplication, division, and exponentiation.
It will also approximate roots of complex numbers.
<p>
Complex numbers are in the form:

<pre class="indent">
a + b*i#
</pre>

<p>
where <b>a</b> is the <a href="am.html#real">real part</a> (a real number)
and <b>b</b> is the <a href="am.html#imaginary">imaginary part</a> (an imaginary number).
<b>i#</b> represents the square root of -1
("<tt>-1^.5</tt>" in Mathomatic notation),
and may be entered into Mathomatic as "<tt>i</tt>";
it will be displayed as "<tt>i#</tt>".
<p>
The imaginary unit <b>i#</b> may appear anywhere within an expression,
as many times as you want, Mathomatic will handle and simplify it properly.
<p>
As an example of imaginary numbers being produced, <b>-2^.5</b> will be converted
to <b>(2^.5)*i#</b>.
<p>
Roots of complex numbers, such as <b>i#^.5</b> and <b>.5^i#</b>, will be approximated, and
only a single root will be produced, even though there may be many roots (see the <a href="am.html#roots">roots command</a>).
This is called the "principal value" and may be unexpected and will often be inexact, therefore
a warning is displayed when this is done.
<p>
Conjugation of all complex numbers in the current equation
is accomplished by typing the following command:

<pre class="indent">
replace i with -i
</pre>

<hr>

<a name="commands"></a>
<h2>Commands</h2>
<p>
Mathomatic has about 40 simple English commands that may be typed at the main prompt.
Please consult the <a href="am.html">Mathomatic Command Reference</a>,
for detailed information on all commands.

<hr>
<font color="red">Copyright &copy; 1987-2009 George Gesslein II</font>

<hr>
<span style="float:left"><a href="index.html">Up to the documentation index</a></span>
<span style="float:right"><a href="http://mathomatic.org"><img src="mathomatic16x16.png" alt="Mathomatic icon"> mathomatic.org</a></span>

</body>
</html>