Introduction
Welcome to the official documentation for MathFlow!
What is MathFlow?
MathFlow is a lightweight, expressive JavaScript library for mathematical expressions and calculations. It provides a simple, intuitive syntax for arithmetic, algebra, trigonometry, logarithms, and more.
What MathFlow is not
WARNING
- MathFlow is not a general-purpose programming language. It is focused on mathematical computation and basic scripting.
Main Objectives
MathFlow aims for expressiveness, focus, and simplicity, making it ideal for math-centric applications, calculators, and educational tools.
How it Works
MathFlow exposes an API for evaluating code, solving equations, rendering, and more. The typical evaluation process:
- A global scope for variables is created.
- Source code is split into statements, whitespace is trimmed, and composite terms like
2x
are expanded to2*x
. - Variable declarations are executed and stored in the scope.
- Each statement is tokenized, parsed into an AST, and interpreted.
- The result of the last statement is returned, along with the final scope.