@abuenameh/compute-engine
Advanced tools
Changelog
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 cheks that _x
is a
number literal:
{
match: ["Add", "_x", "_x"],
replace: ["Multiply", 2, "_x"],
condition: (_x) => _x.numericValue !== null
}
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.