MathShell Reference

This document tries to provide a complete and up-to-date reference for the syntax and features of the mathshell language.

Commands

Commands control the stuff that does not belong within the language itself. Any input starting with a \ (backslash) symbol is treated as a command.

Command Description
\bg color Set the background color of the mathshell. Any valid css color is ok.
\clear Clear all output.
\env List all declared variables.
\fg color Set the font color of the mathshell. Any valid css color is ok.
\help Show help information.
\load Load local mathshell script from file (launches file dialog, chrome only for now).

Arithmetic operators

Symbol Description
+ Addition. Operands may be numbers, vectors or matrices.
- Subtraction. Operands may be numbers, vectors or matrices.
* Multiplication. Operands may be numbers, or vectors/matrices of suitable sizes under the rules of linear algebra.
/ Division. Operands are numbers.
// Division, as above, but output displayed with a horizontal fraction bar.
% Modulo. Operands are numbers
^ Exponentiation. Operands are numbers.
! Factorial. Operand is a non-negative integer.

Logical operators

Symbol Description
~ NOT.
& AND.
| OR.
-> Imply.

Comparison operators

Symbol Description
== Equality.
< Less than.
> Greater than.
<= Less than or equal to.
>= Greater than or equal to.

Other operators

Symbol Description
|| Concatenation. Defined for strings and integers.

Constants

Name Value Description
pi 3.1415926... Ratio of a circles circumfrence to its diameter.
e 2.7182818... Eulers number.

Built-in functions

The following functions are built into the language and can not be redefined.
The object types Set, RVector, CVector and Matrix are collectively refered to as container structures.

Objects

Errors

Six types of errors are thrown by mathshell. Five of them will blame you for the mistake, and the last one should never happen.

Error typeThrown when ...
ParseErrorthe input is not valid mathshell syntax.
ArityErrorillegal number of arguments are given to a function.
ArgumentErrorillegal arguments are given to a function.
ComputeErrorthe computation for some reason was not possible. Like divsion by zero or trying to multiply matrices of incompatible sizes.
NotDefinedErrorattempt to use an undefined function. If algebraic computation is disabled, it will also be thrown for undefined variables.
InternalErrorsomething bad and inconceivable happened within the mathshell core. Please mail me your input.