Cortex Compute Engine
Symbolic manipulation and numeric evaluation of MathJSON expressions
MathJSON is a lightweight mathematical notation interchange format based on JSON.
The Cortex Compute Engine can parse LaTeX to MathJSON, serialize MathJSON to
LaTeX, format, simplify and evaluate MathJSON expressions.
Reference documentation and guides at
cortexjs.io/compute-engine.
Using Compute Engine
$ npm install --save @cortex-js/compute-engine
import { parse, evaluate } from '@cortex-js/compute-engine';
const expr = parse('2^{11}-1 \\in \\P');
console.log(expr);
console.log(evaluate(expr));
More
Related Projects
- MathJSON
- A lightweight mathematical notation interchange format
- MathLive (on GitHub)
- A Web Component for math input.
- Cortex (on GitHub)
- A programming language for scientific computing
Support the Project
License
This project is licensed under the MIT License.
0.21.0 2023-11-02
New Features
-
#125 Parse and serialize environemnts, i.e.
\begin{matrix} 1 & 2 \\ 3 & 4 \end{matrix}
will be parsed as
["Matrix", ["List", ["List", 1, 2], ["List", 3, 4]]]
.
A new section on
Linear Algebra has
some details on the supported formats.
The linear algebra operations are limited at the moment, but will be expanded
in the future.
-
Added IsSame
function, which is the function expression corresponding to
expr.isSame()
.
-
<s>Added CanonicalOrder
function, which sorts the arguments of commutative
functions into canonical order. This is useful to compare two non-canonical
expressions for equality.</s>
ce.box(["CanonicalOrder", ["Add", 1, "x"]]).isSame(
ce.box(["CanonicalOrder", ["Add", "x", 1]])
);
// -> true
Issue Resolved
- When evaluating a sum (
\sum
) with a bound that is not a number, return the
sum expression instead of an error.