# Mathics

Implementation of programming language Wolfram Mathematica

Mathics is a free computer algebra system, compatible with Mathematica. It is developed by a team led by Jan Pöschko. Mathics is written in Python and uses SymPy and mpmath for calculations and MathJax for results display. It is distributed under GNU GPL and is marketed as a free alternative to Mathematica, usable for educational purposes.

Differences from Mathematica:

• Mathics is lightweight; its capabilities are limited (for example, it lacks functions from graph theory and relativity), but a lot of Mathematica programs work without any modifications;
• Mathics is slower;
• but it has an interactive interface available from several browsers;
• Mathics allows to create and display graphics in .svg format right in the online interface;
• results can be exported to LaTeX (plots are exported using Asymptote including 3D plots);
• new functions can be defined using Python.

## Examples:

### Hello, World!:

Example for versions Mathics 0.5, Wolfram Mathematica 8.0.4

Evaluation of this expression results in a string “Hello, World!” itself; since it is not followed by a semicolon, it will be printed as a separate Out, which is not always convenient.

"Hello, World!"


### Hello, World!:

Example for versions Mathics 0.5, Wolfram Mathematica 8.0.4

Print function outputs its argument(s) to the main output stream. Streams can nest, so for convenience it’s recommended to to use a single stream for all output throughout the program.

Print["Hello, World!"];


### Factorial:

Example for versions Mathics 0.5, Wolfram Mathematica 8.0.4

This example uses built-in factorial function !.
Do is one of the ways to run a loop — it evaluates its first argument for a sequence of numbers defined by the second argument. In this case it’s all values of i from 0 to 16, inclusive, with step of 1.

Do[Print[i, "! = ", i!] , {i, 0, 16, 1}]


### Fibonacci numbers:

Example for versions Mathics 0.5, Wolfram Mathematica 8.0.4

Print always outputs a newline after the output, so to prints the numbers in a single line, one has to accumulate them into a string and print it. <> is concatenation operator, it works only on strings, so the result of Fibonacci call must be converted to string explicitly using ToString function.

msg = "";
Do[msg = msg <> ToString[Fibonacci[i]] <> ", " , {i, 16} ];
Print[msg, "..."];


### Fibonacci numbers:

Example for versions Mathics 0.5

This example uses Riffle function which in this case alternates elements of the array containing Fibonacci numbers and the separator string “,”.

StringJoin[Riffle[Map[ToString, Table[Fibonacci[i], {i,16}]], ", "]] <> "..."