Debian Codegraph @

doc/manual.html

raw ◀ ▶
1 Debian patch touch this file
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
6 <title>Mathomatic User Guide</title>
7
8 <meta name="description" content="The User Guide for the Mathomatic computer algebra system.">
9 <meta name="author" content="George Gesslein II">
10 <meta name="distribution" content="global">
11 <meta name="rating" content="general">
12 <meta name="copyright" content="&copy; 1987-2012 George Gesslein II">
13
14 <link rel="author" href="http://www.google.com/profiles/georgegesslein">
15 <link rel="license" href="http://www.gnu.org/licenses/fdl-1.3.html">
•16 <!-- <link rel="home" href="https://launchpad.net/mathomatic"> -->
17 <link rel="contents" href="index.html">
18 <link rel="index" href="index.html">
19 <link rel="next" href="am.html">
20 <link rel="previous" href="index.html">
21 <link rel="start" title="The first page of the Mathomatic User Guide" type="text/html" href="index.html">
•22 <!--
23 <LINK media="print" title="The Mathomatic User Guide and Command Reference in PDF format"
24 type="application/pdf"
25 rel="alternate"
26 href="http://mathomatic.org/manual.pdf">
•27 -->
28
29 <link rel="shortcut icon" href="/favicon.ico">
30
31 <link rel="stylesheet" type="text/css" href="doc.css">
32 </head>
33
34 <body>
35 <center>
36 <h1>Mathomatic User Guide</h1>
37 <img src="greenfade.png" alt="decoration line">
38 </center>
39
40 <h3>Table of Contents</h3>
41
42 <ol>
43 <li>
44 <a href="#introduction">Introduction and Features</a>
45 <li>
46 <a href="#history">History</a>
47 <li>
48 <a href="#developer">Developer Information</a>
49 <li>
50 <a href="#startup">Startup</a>
51 <li>
52 <a href="#equations">Equations and Expressions</a>
53 <ol type="a">
54 <li>
55 <a href="#equationsonly">Equations</a>
56 <li>
57 <a href="#nonequations">Non-Equations</a>
58 <li>
59 <a href="#constants">Constants</a>
60 <li>
61 <a href="#symbols">Variables</a>
62 <li>
63 <a href="#operators">Operators</a>
64 <ol>
65 <li>
66 <a href="#order">Order of Operations example</a>
67 </ol>
68 <li>
69 <a href="#complex">Complex Numbers</a>
70 </ol>
71 <li>
72 <a href="#commands">Commands</a>
73 <li>
74 <a href="#license">Documentation License</a>
75 </ol>
76
77 <p>
78 <a href="am.html">Mathomatic Command Reference</a>
79
80 <br>
81 <br>
82 <hr>
83
84 <a name="introduction"></a>
85 <h2>Introduction and Features</h2>
86 <p>
87 Mathomatic is an easy to use and colorful algebra calculator that can symbolically:
88
89 <ul>
90 <li>
91 combine and solve equations containing many variables,
92
93 <li>
94 completely simplify and compare mathematical expressions and equations,
95
96 <li>
97 do simple calculus transformations and series, sum (&sum;) and product (&prod;),
98
99 <li>
100 perform generalized real number, complex number, modular, and polynomial arithmetic,
101
102 <li>
103 generate efficient C, Java, or Python language code from simplified equations,
104
105 <li>
106 plot expressions with <a target="_blank" rel="nofollow" href="http://gnuplot.sourceforge.net">gnuplot</a> in two or three dimensions, etc.
107 </ul>
108
109 <p>
110 The name "Mathomatic" is a portmanteau of "math" and "automatic".
111 It is a unique computer algebra system (CAS),
112 in that all <a href="#constants">constants</a> are one or more floating point values.
113 All numeric arithmetic is IEEE standard floating point arithmetic,
114 which most computers do very quickly.
115 Mathomatic is written entirely in C,
116 which is like a CAS written in assembly language,
117 running as fast as the computer allows
118 without any high-level language overhead.
119 <p>
120 Mathomatic is exceptionally good at solving, differentiating,
121 simplifying, calculating, and visualizing elementary algebra.
122 It is a console mode application using a color command-line interface (CLI)
123 with pretty-print output that runs in a terminal emulator under any operating system.
124 "The console interface is very simple and requires little more
125 than learning the basic algebra notation to get started,"
126 a Mathomatic user says joyfully on
127 <a target="_blank" title="Wikipedia article on Mathomatic" href="http://en.wikipedia.org/wiki/Mathomatic#Features">Wikipedia</a>.
128 All input and output is line at a time ASCII text.
129 By default, input is standard input and output is standard output.
130 Mathomatic can be compiled with editline or GNU readline for easier line input.
131 The pretty-print output is even prettier in HTML output mode, which supports color too.
132
133 <br>
134 <br>
135 <hr>
136
137 <a name="history"></a>
138 <h2>History</h2>
139 <p>
140 Mathomatic has been developed and supported almost every day by George Gesslein II,
141 with help from the Internet community.
142 <p>
143 Mathomatic development started in the year 1986 to test new ideas
144 and as an experiment in computerized mathematics,
145 originally using the Microsoft C compiler for DOS and the author's own text editor as the only development tools.
146 Versions 1 and 2 were published by Dynacomp
147 of Rochester, New York in 1987 and 1988 as a scientific software product for DOS.
148 Afterwards it was released as shareware and then emailware,
149 with a 2D equation graphing program that could find asymptotes,
150 written in Microsoft C for DOS.
151 At the turn of the century, Mathomatic was ported
152 to the GNU C Compiler (gcc) under Linux and became
153 free and open source software by publishing under the
154 GNU Lesser General Public License
155 (<a target="_blank" rel="nofollow" href="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL version 2.1</a>).
156 The graphing program was discontinued;
157 2D/3D graphing of equations is now accomplished with gnuplot.
158 <p>
159 Mathomatic is currently developed and maintained on a Linux x86-64-bit computer
160 and now stands at 23,000 lines of code (including comments).
161 It has been optimized for speed, by using Linux debugging
162 utilities that tell where Mathomatic spends most of its time.
163
164 <br>
165 <br>
166 <hr>
167
168 <a name="developer"></a>
169 <h2>Developer Information</h2>
170 <p>
171 Building Mathomatic from source requires a C compiler with the standard C libraries.
172 If compiled with the <a target="_blank" rel="nofollow" href="http://gcc.gnu.org">GCC</a> C compiler
173 or the Tiny C Compiler for a Unix-like operating system,
174 no changes need to be made to the source code.
•175 See the file <a rel="nofollow" href="README.txt"><i>README.txt</i></a>
176 for compilation instructions.
177 Mathomatic uses no special GCC only code, so it will usually compile easily with any C compiler.
178 <p>
179 Mathomatic can easily be ported to any computer with at least 1 megabyte of free RAM.
180 In the standard distribution,
•181 found on the <a href="https://launchpad.net/mathomatic">interim Mathomatic home page</a>,
182 the maximum memory usage defaults to 400 megabytes
183 (the "<a href="am.html#version">version</a> status" command tells this).
184 Maximum memory usage is not reached unless all equation spaces are filled.
185 The default maximum memory usage should be less than the amount of free RAM,
186 and can be easily reduced by compiling with the "<b>-DHANDHELD</b>" compiler command-line option,
187 which reduces the memory requirements to 1/6th of the default size.
188 Memory usage can also be dynamically changed at startup with the
189 <a href="mathomatic.1.html"><b>-m</b> option</a>.
190 <p>
191 The Mathomatic source code can also be compiled
192 as a symbolic math library that is callable
193 from any C compatible program and is mostly operating system independent.
194 See the file <i>lib/README.txt</i> for more developer information
195 and how to include Mathomatic in your free software or proprietary program.
196 <p>
197 Very little disk space (a few megabytes) is required to compile, install, and run
198 the Mathomatic application.
199 <p>
200 A <b>readline</b> library must be installed to compile-in and use readline capabilities,
201 which allows editing and history recall of all
202 Mathomatic line input by pressing the cursor keys.
203 We use <b>editline</b> instead of GNU readline,
204 which is in a free Linux package called: "libeditline-dev".
205 It is more compact and license compatible, than GNU readline.
206
207 <br>
208 <br>
209 <hr>
210
211 <a name="startup"></a>
212 <h2>Startup</h2>
213 <dl>
214 <dt>
215 SYNOPSIS
216 <dd>
217 <b>mathomatic</b> [ options ] [ input_files or input ]
218 <br>
219 <b>rmath</b> [ input_files ]
220 </dl>
221 <p>
222 To start the compiled, interactive Mathomatic application,
223 run a terminal emulator which opens a shell window,
224 and type "mathomatic" at the shell prompt (without double quotes).
225 If m4 (macro) Mathomatic was installed, you may type "rmath" instead, to
226 use Mathomatic with input of functions like <tt>sin(x)</tt> and <tt>sqrt(x)</tt>
227 allowed and automatically expanded to equivalent algebraic expressions.
228 Logarithm function input is currently not available,
229 because the logarithm function has not yet been implemented
230 in the Mathomatic symbolic math engine.
231 <p>
232 If you are wondering what to try first in Mathomatic,
233 type "help examples" at the Mathomatic prompt.
234 <p>
235 Color mode is toggled by the <b>-c</b> option on the shell command-line,
236 like this:
237
238 <pre class="indent">
239 $ mathomatic -c
240 </pre>
241
242 ANSI color mode is the default, which outputs ANSI terminal escape sequences
243 to make each level of parentheses a different color, improving readability.
244 If ANSI color mode is on, an ANSI compatible terminal emulator is required.
245 If the colors are hard to see,
246 use the <b>-b</b> option instead, which will always turn on
247 bold color mode, increasing the color brightness.
248 <p>
249 The other options are described in the
250 <a href="mathomatic.1.html">Unix/Linux man page for Mathomatic</a>.
251 After any options, text files may be specified on the shell command-line
252 that will be automatically read in with the <a href="am.html#read">read command</a>,
253 unless the <b>-e</b> option is specified, in which case
254 mathematical expressions and Mathomatic commands are expected,
255 separated by unquoted space characters.
256 <p>
257 It is recommended that the name <i>mathomatic</i> be shortened to <i>am</i>
258 and <i>e</i> for quicker and easier access from the shell command-line.
259 This can be done in the Bash shell by adding the following two lines to your <i>~/.bashrc</i> file:
260
261 <pre class="indent">
262 alias am=mathomatic
263 alias e="mathomatic -e --"
264 </pre>
265
266 <p>
267 Then just typing "am" at the shell prompt will run Mathomatic as an interactive application.
268 Typing "e" followed by a quoted mathematical expression at the shell prompt will
269 quickly and silently bring up Mathomatic and calculate and display the result.
270 "am" stands for "algebraic manipulator", and "e" stands for "evaluate".
271
272 <br>
273 <br>
274 <hr>
275
276 <a name="equations"></a>
277 <h2>Equations and Expressions</h2>
278 <p>
279 On the World Wide Web are some simple algebra texts:
280 <a target="_blank" rel="nofollow" href="http://www.mathsisfun.com/algebra/definitions.html">like those at MathsIsFun.com
281 for some basic algebra definitions, suitable for children</a>, and of course
282 <a href="https://secure.wikimedia.org/wikipedia/simple/wiki/Algebra">The Simple English Wikipedia</a>,
283 which is usually easier to understand than The English Wikipedia.
284 The English Wikipedia contains much more advanced mathematics.
285 <p>
286 Mathematical equations and expressions are entered
287 into Mathomatic <strong>equation spaces</strong> by typing, pasting,
288 or <a href="am.html#read">reading</a> them in at the main prompt.
289 The maximum number and size of available equation spaces is displayed
290 every time Mathomatic starts up.
291 When an expression grows larger than half the equation space size,
292 processing stops and the "Expression too large" message is displayed,
293 returning you to the main prompt.
294 The reason it does this is because each equation space consists of two equation sides,
295 which are fixed size arrays that are easily manipulated by the software.
296 <p>
297 Each equation space is successively numbered with an <strong>equation number</strong> (starting at 1).
298 The main prompt "1&mdash;&gt;&nbsp;" contains the equation number of the current equation space.
299 The current equation can be changed by typing a valid equation number at the main prompt
300 (called <a href="am.html#selecting">selecting an equation space</a>),
301 or by entering another equation or expression, which becomes the current equation.
302 <p>
303 Any previously entered expression can be automatically entered again by entering a "#"
304 followed by the relative or absolute equation space number of that expression.
305 If this is entered first thing at the main prompt,
306 it means something entirely different, that you are <a href="am.html#selecting">selecting that equation space</a>;
307 Otherwise, the RHS or expression at that equation space is substituted, for your convenience.
308
309 <a name="equationsonly"></a>
310 <h3>Equations</h3>
311 <p>
312 To enter an equation into the first available equation space
313 and make it the current equation, simply type or copy/paste it in at the main prompt.
314 Each equation space consists of two equation sides,
315 called the Left-Hand Side (LHS) and the Right-Hand Side (RHS),
316 separated by an equals sign (<b>=</b>).
317 Each equation side consists of a mathematical expression,
318 which is a mix of <a href="#constants">constants</a>,
319 <a href="#symbols">variables</a>, and <a href="#operators">operators</a>,
320 mostly in standard algebraic infix notation.
321 Parentheses are used to override operator precedence and group things together.
322 Valid parentheses characters are <b>()</b> and <b>{}</b>.
323 <b>[]</b> are reserved for array subscripts in variable names.
324 <p>
325 Note that the equals sign does not make an assignment to any variables,
326 it only signifies equality (sameness) between the results of evaluating the LHS and RHS.
327 Shown here is a valid equation with its parts labeled:
328
329 <pre class="indent">
330 equation
331 -----------------------
332 | variables constant|
333 |-------------- | |
334 || | | | |
335 <b> a = b - (c + 2)</b>
336 | | | | | |
337 | | | -------- |
338 | | | operators |
339 --- -----------------
340 LHS RHS
341 </pre>
342
343 <p>
344 In the above equation, the variable <b>a</b> is called the <strong>dependent</strong>
345 variable because its value depends on the <strong>independent</strong> variables <b>b</b> and <b>c</b>.
346 In Mathomatic,
347 any variable can be made the dependent variable by simply typing
348 the variable name in at the prompt.
349 This will <a href="am.html#solving">solve</a> the current equation
350 for that variable and, if successful, make that variable the LHS.
351 <p>
352 Here is the above equation entered into Mathomatic and solved for <b>b</b>,
353 then <a href="am.html#calculate">calculated</a> for the values <b>a=1</b> and <b>c=1</b>:
354
355 <pre class="sample">
356 1&mdash;&gt; a=b-(c+2)
357
358 #1: a = b &minus; c &minus; 2
359
360 1&mdash;&gt; b
361
362 #1: b = 2 + c + a
363
364 1&mdash;&gt; calculate
365 Enter a: 1
366 Enter c: 1
367
368 b = 4
369
370 1&mdash;&gt;
371 </pre>
372
373 <p>
374 The "#1:" listed in front of each displayed equation
375 always indicates the equation space number it is stored in.
376 <p>
377 Mathomatic automatically does both symbolic and numeric
378 mathematics computations during any manipulations.
379 This means that it can handle algebraic formulas, as well as numbers.
380 What follows is a simple example of the result of both types of computations
381 working together during equation simplification and solving:
382
383 <pre class="sample">
384 1&mdash;&gt; 3*(x-1) + 1 = 2x + 1
385
386 #1: (3&middot;(x &minus; 1)) + 1 = (2&middot;x) + 1
387
388 1&mdash;&gt; simplify
389
390 #1: (3&middot;x) &minus; 2 = (2&middot;x) + 1
391
392 1&mdash;&gt; solve verify x
393
394 #1: x = 3
395
396 Solution verified.
397 1&mdash;&gt;
398 </pre>
399
400 <p>
401 The "solve verify" command, used above, solves the current equation
402 and then verifies the result by plugging the result into the original equation
403 and simplifying.
404 If an identity results (the LHS is identical to the RHS),
405 a "Solution verified" message is displayed,
406 otherwise "Solution might be incorrect" is displayed.
407
408 <a name="nonequations"></a>
409 <h3>Expressions that are not equations</h3>
410 <p>
411 Non-equations, that is any mathematical expression without an equals sign,
412 may be entered into equation spaces too.
413 However, if the expression entered at the main prompt contains no variables,
414 it will be calculated and displayed with the <a href="am.html#calculate">calculate command</a>,
415 unless the <a href="am.html#set">autocalc or auto</a> option is turned off.
416 <p>
417 Non-equations cannot be solved,
418 unless you set them equal to zero or something,
419 then they become an equation.
420 Non-equations are stored in the first equation side (LHS) for that equation space.
421 The RHS will be empty (size 0).
422
423 <a name="constants"></a>
424 <h3>Constants</h3>
425 <p>
426 In Mathomatic, numeric arithmetic is double precision floating point
427 with about 14 decimal digits accuracy.
428 Many results will be exact, because symbolic math is an exact math,
429 and because multiple floating point numbers
430 can be combined for a single mathematical value; for example: <b>2^(1/3)</b>,
431 which is the cube root of 2 exactly.
432 <p>
433 Constants are approximated real numbers stored internally as
434 IEEE 754 standard 64-bit (8 bytes) double precision floating point values.
435 They may be entered as decimal (base 10) numbers in normal notation or in scientific notation
436 (also called exponential notation).
437 Constants may also be entered in hexadecimal (base 16)
438 by starting them with "0x".
439 <p>
440 Constants are displayed in decimal (base 10, rounded to 14 digits)
441 using either normal or scientific notation,
442 whichever is shortest.
443 Results are usually accurate from 12 to 14 digits,
444 due to accumulated round-off error,
445 because all constants are stored internally
446 as double precision (rounded to 15 decimal digits) floats.
447 And the amount of round-off error is not tracked, making Mathomatic
448 unsuitable for applications requiring high precision,
449 like astronomical calculations.
450 <p>
451 Excepting constants with a name (like "inf" for the infinity constant),
452 constants always start with a decimal digit (0..9), a period, or a dash (-).
453 <p>
454 Examples of equivalent constants follow:
455 </p>
456
457 <table summary="constant notation examples" border=1 cellpadding=5>
458 <tr>
459 <th>
460 Normal Notation (base 10)
461 </th>
462 <th>
463 Scientific Notation (base 10)
464 </th>
465 <th>
466 Hexadecimal Notation (base 16)
467 </th>
468 </tr>
469 <tr>
470 <td>
471 10
472 </td>
473 <td>
474 1e1 (1.0 times 10<sup>1</sup>)
475 </td>
476 <td>
477 0xa
478 </td>
479 </tr>
480 <tr>
481 <td>
482 .125
483 </td>
484 <td>
485 1.25e-1 (1.25 times 10<sup>-1</sup>)
486 </td>
487 <td>
488 0x.2
489 </td>
490 </tr>
491 <tr>
492 <td>
493 255
494 </td>
495 <td>
496 2.55e2 (2.55 times 10<sup>2</sup>)
497 </td>
498 <td>
499 0xff
500 </td>
501 </tr>
502 </table>
503
504 <p>
505 The exact syntax to enter constants as above may be found by
506 looking up the C library function <code>strtod(3)</code>.
507 In the Unix shell, <tt>"man strtod"</tt> will do that.
508 <p>
509 Double precision floating point limits:
510
511 <ul>
512 <li>
513 The largest valid constant is <b>&plusmn;1.797693e+308</b> (slightly less than 2^1024).
514 <li>
515 The smallest valid constant is <b>&plusmn;2.225074e-308</b> or 0.
516 </ul>
517 <p>
518 The infinity constant is entered by typing "inf".
519 Positive and negative infinity are distinct and understood,
520 however division by zero produces one infinity value,
521 not the two-valued &plusmn;infinity which would be more correct.
522 Also, floating point overflow produces either positive or negative infinity.
523
524 <pre class="sample">
525 1&mdash;&gt; 1/0
526 Warning: Division by zero.
527
528 answer = inf
529
530 1&mdash;&gt; 0/0
531 Warning: Division by zero.
532
533 answer = nan
534
535 1&mdash;&gt;
536 </pre>
537
538 <p>
539 <i>nan</i> or <i>NaN</i> stands for <b>Not a Number</b> and it
540 means an invalid or indeterminate floating point arithmetic result.
541 <i>NaN</i> cannot be directly entered into Mathomatic.
542 The appearance of the constant <i>NaN</i> in an expression
543 means the expression is unusable.
544 <p>
545 Fractions (such as <b>100/101</b>) are preserved if
546 the numerator and denominator are not large.
547 Fractions are always presented in fully reduced form;
548 for example, <b>6/9</b> is converted to the irreducible fraction <b>2/3</b>.
549 Constants which are exactly equal to a fraction are converted and displayed
550 as fully reduced fractions; for example, <b>0.5</b> converts to <b>1/2</b>.
551 Mathomatic internally converts a fraction to a single floating point value,
552 then may convert it back to a fraction for display
553 after all floating point arithmetic has been done,
554 if the result is equal to a fraction.
555 <p>
556 Irrational numbers, such as the square root of two (<b>2^(1/2)</b>) and <b>pi</b>,
557 are preserved and simplified for exactness,
558 unless explicitly approximated.
559 <p>
560 Denominators of fractions are usually rationalized in Mathomatic; for example, <b>1/(2^(1/2))</b> becomes
561 the equivalent <b>(2^(1/2))/2</b> upon simplification.
562 This can be turned off with the command "<a href="am.html#set">set</a> no rationalize_denominators".
563
564 <a name="symbols"></a>
565 <h3>Variables</h3>
566 <p>
567 Variables are what Mathomatic is all about.
568 That is where the term "symbolic" comes from,
569 because variables are symbolic in nature.
570 They are symbols that can represent known or unknown values,
571 or any expression.
572 Variables need not be defined in Mathomatic,
573 just entering the variable name is enough.
574 <p>
575 Variable names consist of any combination of letters (a..z),
576 digits (0..9), and underscores (_).
577 They never start with a digit.
578 By using the "<a href="am.html#set">set</a> special_variable_characters" command,
579 you can add to the allowed variable name characters.
580 By default, letters in variable names are case sensitive,
581 meaning the alphabetic case of each letter in the variable name is important.
582 For example, variables named "A1" and "a1" represent two different variables,
583 unless "<a href="am.html#set">set</a> no case_sensitive" is entered beforehand.
584 <p>
585 The following variables are predefined and are not normal variables:
586
587 <div class="indent">
588 <b>e</b>, <b>&ecirc;</b>, or <b>e#</b> - the universal constant e (2.718281828&hellip;)<br>
589 <b>pi</b> or <b>pi#</b> - the universal constant pi (3.1415926&hellip;)<br>
590 <b>i</b>, <b>&icirc;</b>, or <b>i#</b> - the imaginary unit (square root of -1)<br>
591 <b>sign</b>, <b>sign1</b>, <b>sign2</b>, &hellip; - may only be +1 or -1<br>
592 <b>integer</b>, <b>integer1</b>, &hellip; - may be any integer value
593 </div>
594
595 <p>
596 The above can be used anywhere variables are required.
597 <p>
598 To automatically enter multiplication by a unique, two-valued "sign" variable,
599 precede any expression with "+/&minus;".
600
601 <a name="operators"></a>
602 <h3>Operators</h3>
603 <p>
604 Mathomatic implements the standard rules of algebra for
605 addition (<b>+</b>), subtraction (<b>&minus;</b>), multiplication (<b>*</b>),
606 division (<b>/</b>), modulus (<b>%</b>), and all forms of exponentiation (<b>^</b> or <b>**</b>).
607 An example of a rule of algebra is <b>2*x + 3*x</b> being simplified to <b>5*x</b>.
608 <p>
609 All available operators are at least numerically capable
610 (most are symbolically capable too, see above paragraph) and
611 have precedence decreasing as indicated:
612
613 <pre class="indent">
614 <b>!</b> factorial (same as gamma(x+1) function; highest precedence)
615 <b>**</b> or <b>^</b> power (exponentiation; high precedence)
616 <b>*</b> multiply <b>/</b> divide <b>%</b> modulus <b>//</b> integral divide
617 <b>+</b> add <b>&minus;</b> subtract or negate
618 <b>=</b> equate (denotes equivalence; lowest precedence)
619 </pre>
620
621 <p>
622 Higher precedence operators are grouped (or evaluated) first,
623 then multiple operators of the same precedence level are grouped left to right.
624 This is called the "<a href="#order">order of operations</a>".
625 To group power operators from right to left, like most math programs do,
626 enter "<a href="am.html#set">set</a> right_associative_power" at the main prompt.
627 <p>
628 The default operator is multiply (<b>*</b>).
629 If an expression (operand) is entered when an operator is expected,
630 a multiply operator is automatically inserted.
631 For example, entering <b>2x</b>, <b>2(x)</b>, <b>(2)x</b>, and <b>(2)(x)</b>
632 all result in the expression <b>2*x</b>.
633 <p>
634 <a name="modular"></a>
635 The modulus operator <b>(a % b)</b> (spoken as "a modulo b")
636 gives the remainder of the division <b>(a / b)</b>,
637 which allows modular arithmetic;
638 also known as clock arithmetic, because the numbers wrap around, after they reach the modulus.
639 Mathomatic can simplify, calculate, and sometimes even solve modular arithmetic.
640 Using "integer" variables allows further modulus simplification
641 when using the <a href="am.html#simplify">simplify command</a>.
642 An integer variable is specified by using a variable name that starts with "integer",
643 like "integer1", "integer_x", etc.
644 The resulting sign of any numerical modulus operation depends
645 upon the "<a href="am.html#set">set</a> modulus_mode" option.
646 <p>
647 The integral divide operator <b>(a // b)</b> divides <b>a</b> by <b>b</b>
648 and then truncates by zeroing the fractional part to make the result an integer.
649 For example, <b>(8 // 3)</b> results in 2, which is useful when doing integer arithmetic.
650 This operator currently implements no rules of algebra,
651 and will not evaluate if an operand is a complex number.
652 <p>
653 Factorials <b>x!</b> use the gamma function <b>gamma(x+1)</b>,
654 so that the factorial operator works with any real number,
655 not just the positive integers.
656 The factorial operator currently implements no rules of algebra,
657 and will not evaluate for complex numbers or if an overflow happens.
658 <p>
659 Absolute value notation is allowed,
660 <b>|x|</b> is always converted to <b>(x^2)^.5</b>.
661 This is not the same as standard absolute value
662 where the real and imaginary parts of complex numbers are separated out and then
663 plugged into the distance formula (the Pythagorean theorem),
664 returning a real distance value,
665 but it works the same when given real number values with no imaginary units.
666 The absolute value operation <b>|x|</b> results in a positive value for any <b>x</b> value;
667 that is, if -1 is a factor, it is removed.
668 With Mathomatic, if <b>x</b> is imaginary, you may get an unwanted imaginary result,
669 but it will be positive!
670
671 <a name="order"></a>
672 <h4>Order of Operations example</h4>
673 <p>
674 The following example shows why operator precedence is important.
675 Given the numerical expression:
676
677 <pre class="indent">
678 64/(-2)^4 + 6*(3+1)
679 </pre>
680
681 <p>
682 Mathomatic will parenthesize the highest precedence operators first:
683 power, then times and divide.
684 Addition and subtraction are the lowest precedence, so no need
685 to parenthesize them.
686 The result will be:
687
688 <pre class="indent">
689 (64/((-2)^4)) + (6*(3+1))
690 </pre>
691
692 <p>
693 This is evaluated by combining constants from left to right
694 on the same level of parentheses, deepest levels first.
695 So the calculations are performed in the following order:
696
697 <pre class="indent">
698 (64/16) + (6*4) Combine deepest level parentheses first.
699 4 + 24 Divided 64 by 16 and multiplied 6 by 4.
700 28 Added 24 to 4.
701 </pre>
702
703 <p>
704 If the calculations were performed in a different order,
705 the result would be different.
706
707 <a name="complex"></a>
708 <h3>Complex Numbers</h3>
709 <p>
710 Mathomatic automatically performs complex number addition, subtraction,
711 multiplication, division, and exponentiation.
712 It can also approximate roots of real and complex numbers,
713 giving a single result;
714 when multiple results are possible,
715 the first real number result is chosen.
716 To view all roots of a complex number,
717 use the <a href="am.html#roots">roots command</a>.
718 <p>
719 Complex numbers are usually of the form:
720
721 <pre class="indent">
722 a + b*i
723 </pre>
724
725 <p>
726 where <b>a</b> is the <a href="am.html#real">real part</a> (a real number)
727 and <b>b</b> is the <a href="am.html#imaginary">imaginary part</a> (an imaginary number).
728 <b>i</b> is the "imaginary unit" and it represents the square root of -1
729 ("<b>(-1)^.5</b>" in Mathomatic notation; additionally "<b>sqrt(-1)</b>" in m4 Mathomatic notation).
730
731 <pre class="indent">
732 a + b*i
733 </pre>
734
735 <p>
736 is the rectangular coordinate form of a complex number.
737 To view the polar coordinate form, use the <a href="am.html#roots">roots command</a>.
738 <p>
739 The imaginary unit <b>i</b> may appear anywhere within an expression,
740 as many times as you want, Mathomatic will handle and simplify it properly.
741 <p>
742 As an example of imaginary numbers being produced, <b>(-2)^.5</b> will be converted
743 to <b>(2^.5)*i</b>.
744 <p>
745 Roots of complex numbers, such as <b>i^.5</b> and <b>.5^i</b>, will be approximated, and
746 only a single root will be produced,
747 even though there may be many roots (see the <a href="am.html#roots">roots command</a>).
748 That single root is called the "principal value",
749 which may be unexpected and will often be inexact.
750 <p>
751 Because <b>1/i</b> correctly simplifies to <b>-i</b>, after significant manipulation
752 different numerical results might be produced with complex numbers and division.
753 This is normal, so the sooner the result of a complex expression is calculated, the better.
754 <p>
755 Conjugation of all complex numbers in the current equation
756 is accomplished by typing the following command:
757
758 <pre class="indent">
759 replace i with -i
760 </pre>
761
762 <br>
763 <br>
764 <hr>
765
766 <a name="commands"></a>
767 <h2>Commands</h2>
768 <p>
769 Mathomatic has about <a href="quickrefcard.html">43 simple English commands</a> that may be typed at the main prompt.
770 Please consult the <a href="am.html">Mathomatic Command Reference</a>,
771 for detailed information on all commands.
772
773 <br>
774 <br>
775 <hr>
776
777 <a name="license"></a>
778 <h2>Documentation License</h2>
779 <p>
780 <a target="_blank" rel="nofollow" href="http://www.gnu.org/copyleft/fdl.html"><img src="gnu-fdl.png" alt="GFDL logo"></a>
781 <font color="red">Mathomatic documentation copyright &copy; 1987-2012 George Gesslein II</font>
782 <p>
783 Permission is granted to copy, distribute and/or modify this document
784 under the terms of the GNU Free Documentation License, Version 1.3
785 or any later version published by the Free Software Foundation;
786 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
787 A copy of the license is included <a href="fdl-1.3-standalone.html">here</a>
788 in the Mathomatic documentation directory.
789
790 <br>
791 <br>
792 <hr>
793 <a class="left" href="index.html">Up to the documentation index</a>
•794 <a class="right" href="https://launchpad.net/mathomatic" title="Go to the interim Mathomatic home page"><img src="mathomatic16x16.png" alt="Mathomatic icon">https://launchpad.net/mathomatic</a>
795
796 </body>
797 </html>