Skip to main content

What is Mathsys?

Mathsys is a hybrid language that combines the clarity of mathematical notation with the power of computation. While LaTeX excels at typesetting mathematics, it cannot be reliably parsed or executed. Mathsys bridges this gap by providing a language that outputs beautiful LaTeX typesetting while remaining fully runnable and computable.

Try Mathsys Online

The easiest way to get started with Mathsys is through our live playground: Visit the Mathsys Playground → This interactive environment lets you write and run Mathsys code directly in your browser without any installation.

File Extensions

Mathsys uses version-specific file extensions:
  • .ms1 - Mathsys v1
  • .ms2 - Mathsys v2
  • .ms3 - Mathsys v3
  • .msd - Mathsys dev version (latest deployment)
  • And so on for future versions…
When creating new Mathsys files, use .msd for the latest development version or the appropriate version-specific extension. The development version isn’t always stable and is changing all the time, for more stability, choose a numbered file extension. The following Learn Mathsys guide is especifically designed for Mathsys v3.12.1.

Syntax

Mathsys syntax is designed to be expressive, high-density and intuitive. Here are some examples.
1 + 2
# Results in 3

10 - 3
# Results in 7

4 * 5
# Results in 20

15 / 3
# Results in 5
x = 5
y = 3

x + y
# Results in 8
In this guide you’ll learn the syntax with it’s caveats and quirks.

LaTeX Output

All Mathsys code is directly transpilable to LaTeX, producing beautiful mathematical typesetting. For example:
2x^2^ + 3x + 1
Is rendered as: 2x2+3x+12x^{2}+3x+1

Why Mathsys?

Mathsys is designed for teaching mathematics digitally in a way that feels natural, intuitive, and directly computable. Students can write mathematics just as they think about it, while teachers get an environment where mathematical expressions are immediately runnable.

Formal reference

Mathsys formal syntax, as of this version, is the following:
start: (_S | _L)* (level1 _S? (_L+ level1)*)? (_S | _L)*

declaration: (OBJECT _S)? variable _S? _EQUALITY _S?  expression
definition: (OBJECT _S)? variable _S? _BINDING _S? expression
annotation: OBJECT _S variable
node: expression
equation: expression _S? _EQUALITY _S? expression
comment: _COMMAND _S? QUOTE?
use: _USE _S MODULE

expression: (SIGNS _S?)? level3 (_S? SIGNS _S? level3)*

term: level4 ((_S? OPERATOR)? _S? level4)*

factor: level5 (_EXPONENTIATION _S? expression _S? _EXPONENTIATION)?
limit: _LIM _S variable _S? _TO _S? expression SIGN? _S _OF _S nest (_EXPONENTIATION _S? expression _S? _EXPONENTIATION)?

variable: IDENTIFIER
infinite: _INF
nest: _OPEN _S? expression? _S? _CLOSE
tensor: _ENTER _S? (expression (_S? _COMMA _S? expression)* _S?)? _EXIT
number: NUMBER (_DOT NUMBER)?


level1: (declaration | definition | annotation | node | equation | comment | use)
level2: (expression)
level3: (term)
level4: (factor | limit)
level5: (variable | infinite | nest | tensor | number)


_LIM: /\blim\b/
_TO: /->/
_OF: /\bof\b/
_USE: /\buse\b/
_COMMAND: /\#/
QUOTE: /[^\n]+/
MODULE: /[a-z]+/
OBJECT: /\b(Any|Infinite|Nexists|Number|Tensor|Undefined|Variable)\b/
IDENTIFIER: /(?i)(?!\b(?:inf|of|use|lim|Any|Infinite|Nexists|Number|Tensor|Undefined|Variable)\b)[A-Za-zº$%]+/
_INF: /\binf\b/
_EXPONENTIATION: /\^/
NUMBER: /[0-9]+/
_DOT: /\./
_BINDING: /==/
_EQUALITY: /=/
OPERATOR: /[\*\/]/
SIGNS: /[+-]+(\s*[+-]+)*/
SIGN: /[+-]/
_OPEN: /\(/
_CLOSE: /\)/
_ENTER: /\[/
_COMMA: /,/
_EXIT: /\]/
_S: / +/
_L: /\n/
This is public and intended so that users can understand better how to write Mathsys files.