MathJSON Standard Library

The MathJSON standard library defines the vocabulary used by a MathJSON expression.

This library defines the meaning of the identifiers used in a MathJSON expression. It is independent of the syntax used to parse/serialize from another language such as LaTeX.

It includes definitions such as:

  • Pi is a transcendental number whose value is approximately 3.14159265…
  • The Add function is associative, commutative, pure, idempotent and can be applied to arbitrary number of Real or Complex numbers”.

Topics

The MathJSON Standard Library is organized by topics, each topic is a separate page in the documentation.

Topic
Arithmetic Add Multiply Power Exp Log ExponentialE ImaginaryUnit
Calculus D Derivative Integrate
Collections List Reverse Filter
Complex Real Conjugate, ComplexRoots
Control Structures If Block Loop
Core Declare, Assign, Error LatexString
Domains Anything Nothing Numbers Integers
Functions Function Apply Return
Logic And Or Not True False Maybe
Sets Union Intersection EmptySet
Special Functions Gamma Factorial
Statistics StandardDeviation Mean Erf
Styling Delimiter Style
Trigonometry Pi Cos Sin Tan

Extending the MathJSON Standard Library

The MathJSON Standard Library can be extended by defining new functions:

// Declare that the identifier "f" is a function, 
// but without giving it a definition
ce.declare("f", "Function");

// Define a new function `double` that returns twice its input
ce.assign("double(x)", ["Multiply", "x", 2]);

// LaTeX can be used for the definition as well...
ce.assign("half(x)", ce.parse("\\frac{x}{2}"));

You can also customize the LaTeX syntax, that is how to parse and serialize LaTeX to MathJSON.