Debian Codegraph @

doc/manual.html

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