Skip to main content

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
ArithmeticAdd Multiply Power Exp Log ExponentialE ImaginaryUnit...
CalculusD Derivative Integrate...
CollectionsList Reverse Filter...
ComplexReal Conjugate, ComplexRoots...
Control StructuresIf Block Loop ...
CoreDeclare Assign Error LatexString...
FunctionsFunction Apply Return ...
LogicAnd Or Not True False ForAll ...
SetsUnion Intersection EmptySet RealNumbers Integers ...
Special FunctionsGamma Factorial...
StatisticsStandardDeviation Mean Erf...
StylingDelimiter Style...
TrigonometryPi 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.