
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
@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.22.0 2023-11-13
Rule Syntax
The syntax to describe rules has changed. The syntax for a rule was previously
a tuple [lhs, rhs, {condition} ]
. The new syntax is an object with the
properties match
, replace
and condition
. For example:
[["Add", "_x", "_x"], ["Multiply", 2, "_x"]]
{match: ["Add", "_x", "_x"], replace: ["Multiply", 2, "_x"]}
The condition
property is optional, and is either a boxed function or a
JavaScript function. For example, to add a condition that checks that _x
is
a number literal:
{
match: ["Add", "_x", "_x"],
replace: ["Multiply", 2, "_x"],
condition: ({_x}) => _x.isNumberLiteral
}
CanonicalForm
The CanonicalOrder
function has been replaced by the more flexible
CanonicalForm
function. The CanonicalForm
function takes an expression and
a list of transformations to apply. To apply the same transformations as
CanonicalOrder
, use:
['CanonicalForm', expr, 'Order']
These canonical forms can also be specified with box()
and parse()
options:
ce.box(expr, { canonical: "Order" });
ce.parse("x^2 + 2x + 1", { canonical: "Order" });
Rank
, Shape
,Reshape
, Flatten
, Determinant
,
Trace
, Transpose
, ConjugateTranspose
, Inverse
. See the
Linear Algebra reference guide.
Some of these function may not yet return correct result in all cases.expr.print()
method as a synonym for console.log(expr.toString())
.exact
option (false by default) to the expr.match()
pattern
matching method. When true
some additional patterns are automatically
recognized, for example, x
will match ["Multiply", '_a', 'x']
when exact
is false
, but not when exact
is true
.expr.solve()
has been improved and can now solve
more equations.FAQs
Symbolic computing and numeric evaluations for JavaScript and Node.js
The npm package @cortex-js/compute-engine receives a total of 34,824 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.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.