Mathics3 can be used to calculate basic stuff:
1 + 2
To submit a command to Mathics3, press Shift+Return
in the Web interface or Return
in the console interface. The result will be printed in a new line below your query.
The result of the previous query to Mathics3 can be accessed by %
:
% ^ 2
Mathics3 understands all basic arithmetic operators and applies the usual operator precedence. Use parentheses when needed:
1 - 2 * (3 + 5) / 4
The multiplication can be omitted:
1 - 2 (3 + 5) / 4
2 4
Powers can be entered using ^
:
3 ^ 4
Integer divisions yield rational numbers:
6 / 4
To convert the result to a floating point number, apply the function N
:
N[6 / 4]
As you can see, functions are applied using square braces [
and ]
, in contrast to the common notation of (
and )
. At first hand, this might seem strange, but this distinction between function application and precedence change is necessary to allow some general syntax structures, as you will see later.
Mathics3 provides many common mathematical functions and constants, e.g.:
Log[E]
Sin[Pi]
Cos[0.5]
When entering floating point numbers in your query, Mathics3 will perform a numerical evaluation and present a numerical result, pretty much like if you had applied N
.
Of course, Mathics3 has complex numbers:
Sqrt[-4]
I ^ 2
(3 + 2 I) ^ 4
(3 + 2 I) ^ (2.5 - I)
Tan[I + 0.5]
Abs
calculates absolute values:
Abs[-3]
Abs[3 + 4 I]
Mathics3 can operate with pretty huge numbers:
55! (* Also known as Factorial[55] *)
We could easily use a number larger than 55, but the digits will just run off the page.
The precision of numerical evaluation can be set:
N[Pi, 30]
Division by zero gives an error:
1 / 0
But zero division returns value ComplexInfinity
and that can be used as a value:
Cos[ComplexInfinity]
ComplexInfinity
is a shorthand though for DirectedInfinty[]
.
Similarly, expressions using Infinity
as a value are allowed and are evaluated:
Infinity + 2 Infinity
There is also the value, Indeterminate
:
0 ^ 0