
Security News
Bun 1.2.19 Adds Isolated Installs for Better Monorepo Support
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
@cortex-js/compute-engine
Advanced tools
Symbolic computing and numeric evaluations for JavaScript and Node.js
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.
$ 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);
// ➔ ["Element", ["Subtract", ["Power", 2, 11] , 1], "PrimeNumber"]
console.log(evaluate(expr));
// ➔ "False"
This project is licensed under the MIT License.
0.18.0 2023-10-16
\max
, \min
, \sup
, \inf
and \lim
functionsSupremum
and Infimum
functionsBlock
expressions, local variables, return statements and
conditionals If
.Limit
functions and NLimit
functions, using a Richardson Extrapolation.console.info(ce.parse("\\lim_{x\\to0} \\frac{\\sin x}{x}").N().json);
// -> 1
console.info(
ce.box(["NLimit", ["Divide", ["Sin", "_"], "_"], 0]).evaluate().json
);
// -> 1
console.info(ce.parse("\\lim_{x\\to \\infty} \\cos \\frac{1}{x}").N().json);
// -> 1
Added Assign
and Declare
functions to assign values to symbols and declare
symbols with a domain.
Block
evaluations with local variables work now. For example:
ce.box(["Block", ["Assign", "c", 5], ["Multiply", "c", 2]]).evaluate().json;
// -> 10
When decimal numbers are parsed they are interpreted as inexact numbers by
default, i.e. "1.2" -> {num: "1.2"}
. To force the number to be interpreted
as a rational number, set ce.latexOptions.parseNumbers = "rational"
. In that
case, "1.2" -> ["Rational", 12, 10]
, an exact number.
While regular decimals are considered "inexact" numbers (i.e. they are assumed to be an approximation), rationals are assumed to be exact. In most cases, the safest thing to do is to consider decimal numbers as inexact to avoid introducing errors in calculations. If you know that the decimal numbers you parse are exact, you can use this option to consider them as exact numbers.
4^{}
is interpreted
as 4
.FAQs
Symbolic computing and numeric evaluations for JavaScript and Node.js
The npm package @cortex-js/compute-engine receives a total of 34,463 weekly downloads. As such, @cortex-js/compute-engine popularity was classified as popular.
We found that @cortex-js/compute-engine demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
Security News
Popular npm packages like eslint-config-prettier were compromised after a phishing attack stole a maintainer’s token, spreading malicious updates.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.