@cortex-js/compute-engine 0.20.1 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compute-engine.esm.js +679 -220
- package/dist/compute-engine.js +679 -220
- package/dist/compute-engine.min.esm.js +10 -10
- package/dist/compute-engine.min.js +10 -10
- package/dist/math-json.esm.js +2 -2
- package/dist/math-json.js +2 -2
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.js +2 -2
- package/dist/types/common/ansi-codes.d.ts +1 -1
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/common/utils.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +8 -2
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
- package/dist/types/compute-engine/collection-utils.d.ts +1 -1
- package/dist/types/compute-engine/compile.d.ts +1 -1
- package/dist/types/compute-engine/compute-engine.d.ts +265 -29
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/domain-utils.d.ts +1 -1
- package/dist/types/compute-engine/function-utils.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +2 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/public.d.ts +5 -2
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-add.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +1 -1
- package/dist/types/compute-engine/library/complex.d.ts +1 -1
- package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
- package/dist/types/compute-engine/library/core.d.ts +1 -1
- package/dist/types/compute-engine/library/domains.d.ts +1 -1
- package/dist/types/compute-engine/library/library.d.ts +1 -1
- package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/library/logic.d.ts +1 -1
- package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
- package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
- package/dist/types/compute-engine/library/sets.d.ts +1 -1
- package/dist/types/compute-engine/library/statistics.d.ts +1 -1
- package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/library/utils.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +3 -3
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
- package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
- package/dist/types/compute-engine/public.d.ts +8 -260
- package/dist/types/compute-engine/rules.d.ts +1 -1
- package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/solve.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/product.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/sum.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
- package/dist/types/compute-engine.d.ts +2 -2
- package/dist/types/math-json/math-json-format.d.ts +1 -1
- package/dist/types/math-json/utils.d.ts +1 -1
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +2 -1
package/dist/compute-engine.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** CortexJS Compute Engine 0.
|
|
1
|
+
/** CortexJS Compute Engine 0.21.0 */
|
|
2
2
|
(function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ComputeEngine = {}));})(this, (function (exports) { 'use strict';
|
|
3
3
|
var ComputeEngine = (() => {
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1093,7 +1093,7 @@ var ComputeEngine = (() => {
|
|
|
1093
1093
|
}
|
|
1094
1094
|
|
|
1095
1095
|
// src/compute-engine/compute-engine.ts
|
|
1096
|
-
var import_complex20 = __toESM(require_complex());
|
|
1096
|
+
var import_complex20 = __toESM(require_complex(), 1);
|
|
1097
1097
|
|
|
1098
1098
|
// node_modules/decimal.js/decimal.mjs
|
|
1099
1099
|
var EXP_LIMIT = 9e15;
|
|
@@ -5965,23 +5965,7 @@ var ComputeEngine = (() => {
|
|
|
5965
5965
|
kind: "environment",
|
|
5966
5966
|
name: "Which",
|
|
5967
5967
|
identifierTrigger: "cases",
|
|
5968
|
-
parse:
|
|
5969
|
-
const tabular = parser.parseTabular();
|
|
5970
|
-
if (!tabular)
|
|
5971
|
-
return ["Which"];
|
|
5972
|
-
const result = ["Which"];
|
|
5973
|
-
for (const row of tabular) {
|
|
5974
|
-
if (row.length === 1) {
|
|
5975
|
-
result.push("True");
|
|
5976
|
-
result.push(row[0]);
|
|
5977
|
-
} else if (row.length === 2) {
|
|
5978
|
-
const s = stringValue(row[1]);
|
|
5979
|
-
result.push(s ? "True" : stripText(row[1]) ?? "True");
|
|
5980
|
-
result.push(row[0]);
|
|
5981
|
-
}
|
|
5982
|
-
}
|
|
5983
|
-
return result;
|
|
5984
|
-
},
|
|
5968
|
+
parse: parseWhich,
|
|
5985
5969
|
serialize: (serialize, expr) => {
|
|
5986
5970
|
const rows = [];
|
|
5987
5971
|
const args = ops(expr);
|
|
@@ -5995,6 +5979,16 @@ var ComputeEngine = (() => {
|
|
|
5995
5979
|
}
|
|
5996
5980
|
return joinLatex(["\\begin{cases}", rows.join("\\\\"), "\\end{cases}"]);
|
|
5997
5981
|
}
|
|
5982
|
+
},
|
|
5983
|
+
{
|
|
5984
|
+
kind: "environment",
|
|
5985
|
+
identifierTrigger: "dcases",
|
|
5986
|
+
parse: parseWhich
|
|
5987
|
+
},
|
|
5988
|
+
{
|
|
5989
|
+
kind: "environment",
|
|
5990
|
+
identifierTrigger: "rcases",
|
|
5991
|
+
parse: parseWhich
|
|
5998
5992
|
}
|
|
5999
5993
|
];
|
|
6000
5994
|
function parseTextRun(parser, style) {
|
|
@@ -6315,6 +6309,23 @@ var ComputeEngine = (() => {
|
|
|
6315
6309
|
}
|
|
6316
6310
|
return ["Assign", lhs, rhs];
|
|
6317
6311
|
}
|
|
6312
|
+
function parseWhich(parser) {
|
|
6313
|
+
const tabular = parser.parseTabular();
|
|
6314
|
+
if (!tabular)
|
|
6315
|
+
return ["Which"];
|
|
6316
|
+
const result = ["Which"];
|
|
6317
|
+
for (const row of tabular) {
|
|
6318
|
+
if (row.length === 1) {
|
|
6319
|
+
result.push("True");
|
|
6320
|
+
result.push(row[0]);
|
|
6321
|
+
} else if (row.length === 2) {
|
|
6322
|
+
const s = stringValue(row[1]);
|
|
6323
|
+
result.push(s ? "True" : stripText(row[1]) ?? "True");
|
|
6324
|
+
result.push(row[0]);
|
|
6325
|
+
}
|
|
6326
|
+
}
|
|
6327
|
+
return result;
|
|
6328
|
+
}
|
|
6318
6329
|
|
|
6319
6330
|
// src/compute-engine/latex-syntax/dictionary/definitions-inequalities.ts
|
|
6320
6331
|
var DEFINITIONS_INEQUALITIES = [
|
|
@@ -6723,103 +6734,239 @@ var ComputeEngine = (() => {
|
|
|
6723
6734
|
// The third, optional, argument is the column specification.
|
|
6724
6735
|
{
|
|
6725
6736
|
name: "Matrix",
|
|
6726
|
-
// https://ctan.math.illinois.edu/macros/latex/required/tools/array.pdf
|
|
6727
6737
|
serialize: (serializer, expr) => {
|
|
6728
|
-
const
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
if (
|
|
6801
|
-
return
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6738
|
+
const rows = ops(op(expr, 1)) ?? [];
|
|
6739
|
+
return serializeTabular(
|
|
6740
|
+
serializer,
|
|
6741
|
+
rows,
|
|
6742
|
+
stringValue(op(expr, 2)),
|
|
6743
|
+
stringValue(op(expr, 3))
|
|
6744
|
+
);
|
|
6745
|
+
}
|
|
6746
|
+
},
|
|
6747
|
+
// Vector is a specialized collection to represent a column vector.
|
|
6748
|
+
{
|
|
6749
|
+
name: "Vector",
|
|
6750
|
+
serialize: (serializer, expr) => {
|
|
6751
|
+
const columns = ops(expr) ?? [];
|
|
6752
|
+
return serializeTabular(
|
|
6753
|
+
serializer,
|
|
6754
|
+
columns.map((column) => ["List", column]),
|
|
6755
|
+
stringValue(op(expr, 2)),
|
|
6756
|
+
stringValue(op(expr, 3))
|
|
6757
|
+
);
|
|
6758
|
+
}
|
|
6759
|
+
},
|
|
6760
|
+
{
|
|
6761
|
+
kind: "environment",
|
|
6762
|
+
identifierTrigger: "pmatrix",
|
|
6763
|
+
parse: (parser) => {
|
|
6764
|
+
const columns = parseColumnFormat(parser);
|
|
6765
|
+
const [head2, cells] = parseCells(parser);
|
|
6766
|
+
if (columns)
|
|
6767
|
+
return [head2, cells, { str: "()" }, { str: columns }];
|
|
6768
|
+
return [head2, cells];
|
|
6769
|
+
}
|
|
6770
|
+
},
|
|
6771
|
+
{
|
|
6772
|
+
kind: "environment",
|
|
6773
|
+
identifierTrigger: "bmatrix",
|
|
6774
|
+
parse: (parser) => {
|
|
6775
|
+
const columns = parseColumnFormat(parser);
|
|
6776
|
+
const [head2, cells] = parseCells(parser);
|
|
6777
|
+
if (columns)
|
|
6778
|
+
return [head2, cells, { str: "[]" }, { str: columns }];
|
|
6779
|
+
return [head2, cells, { str: "[]" }];
|
|
6780
|
+
}
|
|
6781
|
+
},
|
|
6782
|
+
{
|
|
6783
|
+
kind: "environment",
|
|
6784
|
+
identifierTrigger: "Bmatrix",
|
|
6785
|
+
parse: (parser) => {
|
|
6786
|
+
const columns = parseColumnFormat(parser);
|
|
6787
|
+
const [head2, cells] = parseCells(parser);
|
|
6788
|
+
if (columns)
|
|
6789
|
+
return [head2, cells, { str: "{}" }, { str: columns }];
|
|
6790
|
+
return [head2, cells, { str: "{}" }];
|
|
6791
|
+
}
|
|
6792
|
+
},
|
|
6793
|
+
{
|
|
6794
|
+
kind: "environment",
|
|
6795
|
+
identifierTrigger: "vmatrix",
|
|
6796
|
+
parse: (parser) => {
|
|
6797
|
+
const columns = parseColumnFormat(parser);
|
|
6798
|
+
const [head2, cells] = parseCells(parser);
|
|
6799
|
+
if (columns)
|
|
6800
|
+
return [head2, cells, { str: "||" }, { str: columns }];
|
|
6801
|
+
return [head2, cells, { str: "||" }];
|
|
6802
|
+
}
|
|
6803
|
+
},
|
|
6804
|
+
{
|
|
6805
|
+
kind: "environment",
|
|
6806
|
+
identifierTrigger: "Vmatrix",
|
|
6807
|
+
parse: (parser) => {
|
|
6808
|
+
const columns = parseColumnFormat(parser);
|
|
6809
|
+
const [head2, cells] = parseCells(parser);
|
|
6810
|
+
if (columns)
|
|
6811
|
+
return [head2, cells, { str: "\u2016\u2016" }, { str: columns }];
|
|
6812
|
+
return [head2, cells, { str: "\u2016\u2016" }];
|
|
6813
|
+
}
|
|
6814
|
+
},
|
|
6815
|
+
{
|
|
6816
|
+
kind: "environment",
|
|
6817
|
+
identifierTrigger: "smallmatrix",
|
|
6818
|
+
parse: (parser) => {
|
|
6819
|
+
const columns = parseColumnFormat(parser);
|
|
6820
|
+
const [head2, cells] = parseCells(parser);
|
|
6821
|
+
if (columns)
|
|
6822
|
+
return [head2, cells, { str: "()" }, { str: columns }];
|
|
6823
|
+
return [head2, cells];
|
|
6824
|
+
}
|
|
6825
|
+
},
|
|
6826
|
+
{
|
|
6827
|
+
kind: "environment",
|
|
6828
|
+
identifierTrigger: "array",
|
|
6829
|
+
parse: (parser) => {
|
|
6830
|
+
const columns = parseColumnFormat(parser, false);
|
|
6831
|
+
const [head2, cells] = parseCells(parser);
|
|
6832
|
+
if (columns)
|
|
6833
|
+
return [head2, cells, { str: ".." }, { str: columns }];
|
|
6834
|
+
return [head2, cells, { str: ".." }];
|
|
6835
|
+
}
|
|
6836
|
+
},
|
|
6837
|
+
{
|
|
6838
|
+
kind: "environment",
|
|
6839
|
+
identifierTrigger: "matrix",
|
|
6840
|
+
parse: (parser) => {
|
|
6841
|
+
const columns = parseColumnFormat(parser);
|
|
6842
|
+
const [head2, cells] = parseCells(parser);
|
|
6843
|
+
if (columns)
|
|
6844
|
+
return [head2, cells, { str: ".." }, { str: columns }];
|
|
6845
|
+
return [head2, cells, { str: ".." }];
|
|
6846
|
+
}
|
|
6847
|
+
},
|
|
6848
|
+
{
|
|
6849
|
+
kind: "environment",
|
|
6850
|
+
identifierTrigger: "matrix*",
|
|
6851
|
+
parse: (parser) => {
|
|
6852
|
+
const columns = parseColumnFormat(parser);
|
|
6853
|
+
const [head2, cells] = parseCells(parser);
|
|
6854
|
+
if (columns)
|
|
6855
|
+
return [head2, cells, { str: ".." }, { str: columns }];
|
|
6856
|
+
return [head2, cells, { str: ".." }];
|
|
6820
6857
|
}
|
|
6821
6858
|
}
|
|
6822
6859
|
];
|
|
6860
|
+
function parseCells(parser) {
|
|
6861
|
+
const tabular = parser.parseTabular();
|
|
6862
|
+
if (!tabular)
|
|
6863
|
+
return ["", null];
|
|
6864
|
+
return [
|
|
6865
|
+
"Matrix",
|
|
6866
|
+
["List", ...tabular.map((row) => ["List", row])]
|
|
6867
|
+
];
|
|
6868
|
+
}
|
|
6869
|
+
function parseColumnFormat(parser, optional = true) {
|
|
6870
|
+
const colFormat = parser.parseStringGroup(optional)?.trim();
|
|
6871
|
+
if (!colFormat)
|
|
6872
|
+
return "";
|
|
6873
|
+
let result = "";
|
|
6874
|
+
for (const c of colFormat) {
|
|
6875
|
+
if (c === "c")
|
|
6876
|
+
result += "=";
|
|
6877
|
+
if (c === "l")
|
|
6878
|
+
result += "<";
|
|
6879
|
+
if (c === "r")
|
|
6880
|
+
result += ">";
|
|
6881
|
+
if (c === "|")
|
|
6882
|
+
result += "|";
|
|
6883
|
+
if (c === ":")
|
|
6884
|
+
result += ":";
|
|
6885
|
+
}
|
|
6886
|
+
return result;
|
|
6887
|
+
}
|
|
6888
|
+
function serializeTabular(serializer, rows, delims, colSpec) {
|
|
6889
|
+
delims ?? (delims = "()");
|
|
6890
|
+
let [open, close] = ["", ""];
|
|
6891
|
+
if (typeof delims === "string" && delims.length === 2)
|
|
6892
|
+
[open, close] = delims;
|
|
6893
|
+
let columns = "";
|
|
6894
|
+
if (colSpec) {
|
|
6895
|
+
for (const c of colSpec) {
|
|
6896
|
+
if (c === "<")
|
|
6897
|
+
columns += "l";
|
|
6898
|
+
else if (c === ">")
|
|
6899
|
+
columns += "r";
|
|
6900
|
+
else if (c === "=")
|
|
6901
|
+
columns += "c";
|
|
6902
|
+
else if (c === "|")
|
|
6903
|
+
columns += "|";
|
|
6904
|
+
else if (c === ":")
|
|
6905
|
+
columns += ":";
|
|
6906
|
+
}
|
|
6907
|
+
}
|
|
6908
|
+
const serializedRows = [];
|
|
6909
|
+
for (const row of rows ?? []) {
|
|
6910
|
+
const cells = [];
|
|
6911
|
+
for (const cell of ops(row) ?? [])
|
|
6912
|
+
cells.push(serializer.serialize(cell));
|
|
6913
|
+
serializedRows.push(cells.join(" & "));
|
|
6914
|
+
}
|
|
6915
|
+
const tabular = serializedRows.join("\\\\\n");
|
|
6916
|
+
const optColumns = columns.length > 0 ? `[${columns}]` : "";
|
|
6917
|
+
if (open === "(" && close === ")")
|
|
6918
|
+
return joinLatex([
|
|
6919
|
+
"\\begin{pmatrix}",
|
|
6920
|
+
optColumns,
|
|
6921
|
+
tabular,
|
|
6922
|
+
"\\end{pmatrix}"
|
|
6923
|
+
]);
|
|
6924
|
+
if (open === "[" && close === "]")
|
|
6925
|
+
return joinLatex([
|
|
6926
|
+
"\\begin{bmatrix}",
|
|
6927
|
+
optColumns,
|
|
6928
|
+
tabular,
|
|
6929
|
+
"\\end{bmatrix}"
|
|
6930
|
+
]);
|
|
6931
|
+
if (open === "{" && close === "}")
|
|
6932
|
+
return joinLatex([
|
|
6933
|
+
"\\begin{Bmatrix}",
|
|
6934
|
+
optColumns,
|
|
6935
|
+
tabular,
|
|
6936
|
+
"\\end{Bmatrix}"
|
|
6937
|
+
]);
|
|
6938
|
+
if (open === "|" && close === "|")
|
|
6939
|
+
return joinLatex([
|
|
6940
|
+
"\\begin{vmatrix}",
|
|
6941
|
+
optColumns,
|
|
6942
|
+
tabular,
|
|
6943
|
+
"\\end{vmatrix}"
|
|
6944
|
+
]);
|
|
6945
|
+
if (open === "\u2016" && close === "\u2016")
|
|
6946
|
+
return joinLatex([
|
|
6947
|
+
"\\begin{Vmatrix}",
|
|
6948
|
+
optColumns,
|
|
6949
|
+
tabular,
|
|
6950
|
+
"\\end{Vmatrix}"
|
|
6951
|
+
]);
|
|
6952
|
+
if (open === "{" && close === ".")
|
|
6953
|
+
return joinLatex(["\\begin{dcases}", optColumns, tabular, "\\end{dcases}"]);
|
|
6954
|
+
if (open === "." && close === "}")
|
|
6955
|
+
return joinLatex(["\\begin{rcases}", optColumns, tabular, "\\end{rcases}"]);
|
|
6956
|
+
if (columns || open !== "." || close !== ".") {
|
|
6957
|
+
return joinLatex([
|
|
6958
|
+
"\\left",
|
|
6959
|
+
DELIMITERS_SHORTHAND[open] ?? open,
|
|
6960
|
+
"\\begin{array}",
|
|
6961
|
+
`{${columns}}`,
|
|
6962
|
+
tabular,
|
|
6963
|
+
"\\end{array}",
|
|
6964
|
+
"\\right",
|
|
6965
|
+
DELIMITERS_SHORTHAND[close] ?? close
|
|
6966
|
+
]);
|
|
6967
|
+
}
|
|
6968
|
+
return joinLatex(["\\begin{matrix}", tabular, "\\end{matrix}"]);
|
|
6969
|
+
}
|
|
6823
6970
|
|
|
6824
6971
|
// src/compute-engine/latex-syntax/dictionary/definitions-logic.ts
|
|
6825
6972
|
var DEFINITIONS_LOGIC = [
|
|
@@ -8729,7 +8876,7 @@ var ComputeEngine = (() => {
|
|
|
8729
8876
|
});
|
|
8730
8877
|
return false;
|
|
8731
8878
|
}
|
|
8732
|
-
if ("identifierTrigger" in entry) {
|
|
8879
|
+
if ("identifierTrigger" in entry && (!("kind" in entry) || entry.kind !== "environment")) {
|
|
8733
8880
|
if (typeof entry.identifierTrigger !== "string" || !isValidIdentifier(entry.identifierTrigger)) {
|
|
8734
8881
|
onError({
|
|
8735
8882
|
severity: "warning",
|
|
@@ -9698,12 +9845,14 @@ var ComputeEngine = (() => {
|
|
|
9698
9845
|
return result;
|
|
9699
9846
|
}
|
|
9700
9847
|
/** Parse a group as a a string, for example for `\operatorname` or `\begin` */
|
|
9701
|
-
parseStringGroup() {
|
|
9848
|
+
parseStringGroup(optional) {
|
|
9849
|
+
if (optional === void 0)
|
|
9850
|
+
optional = false;
|
|
9702
9851
|
const start = this.index;
|
|
9703
9852
|
while (this.match("<space>")) {
|
|
9704
9853
|
}
|
|
9705
|
-
if (this.match("<{>")) {
|
|
9706
|
-
this.addBoundary(["<}>"]);
|
|
9854
|
+
if (this.match(optional ? "[" : "<{>")) {
|
|
9855
|
+
this.addBoundary([optional ? "]" : "<}>"]);
|
|
9707
9856
|
const arg = this.parseStringGroupContent();
|
|
9708
9857
|
if (this.matchBoundary())
|
|
9709
9858
|
return arg;
|
|
@@ -11454,13 +11603,13 @@ var ComputeEngine = (() => {
|
|
|
11454
11603
|
};
|
|
11455
11604
|
|
|
11456
11605
|
// src/compute-engine/domain-utils.ts
|
|
11457
|
-
var import_complex3 = __toESM(require_complex());
|
|
11606
|
+
var import_complex3 = __toESM(require_complex(), 1);
|
|
11458
11607
|
|
|
11459
11608
|
// src/compute-engine/numerics/rationals.ts
|
|
11460
|
-
var import_complex2 = __toESM(require_complex());
|
|
11609
|
+
var import_complex2 = __toESM(require_complex(), 1);
|
|
11461
11610
|
|
|
11462
11611
|
// src/compute-engine/numerics/numeric.ts
|
|
11463
|
-
var import_complex = __toESM(require_complex());
|
|
11612
|
+
var import_complex = __toESM(require_complex(), 1);
|
|
11464
11613
|
|
|
11465
11614
|
// src/compute-engine/numerics/richardson.ts
|
|
11466
11615
|
function extrapolate(f, x0, options = {}) {
|
|
@@ -13492,7 +13641,7 @@ var ComputeEngine = (() => {
|
|
|
13492
13641
|
}
|
|
13493
13642
|
|
|
13494
13643
|
// src/compute-engine/boxed-expression/utils.ts
|
|
13495
|
-
var import_complex4 = __toESM(require_complex());
|
|
13644
|
+
var import_complex4 = __toESM(require_complex(), 1);
|
|
13496
13645
|
function isLatexString(s) {
|
|
13497
13646
|
if (typeof s === "string")
|
|
13498
13647
|
return s.startsWith("$") && s.endsWith("$");
|
|
@@ -13712,7 +13861,7 @@ var ComputeEngine = (() => {
|
|
|
13712
13861
|
}
|
|
13713
13862
|
|
|
13714
13863
|
// src/compute-engine/boxed-expression/order.ts
|
|
13715
|
-
var import_complex5 = __toESM(require_complex());
|
|
13864
|
+
var import_complex5 = __toESM(require_complex(), 1);
|
|
13716
13865
|
|
|
13717
13866
|
// src/compute-engine/symbolic/polynomials.ts
|
|
13718
13867
|
function totalDegree(expr) {
|
|
@@ -13760,7 +13909,7 @@ var ComputeEngine = (() => {
|
|
|
13760
13909
|
|
|
13761
13910
|
// src/compute-engine/boxed-expression/order.ts
|
|
13762
13911
|
var DEFAULT_COMPLEXITY = 1e5;
|
|
13763
|
-
function sortAdd(
|
|
13912
|
+
function sortAdd(ops2) {
|
|
13764
13913
|
return ops2.sort((a, b) => {
|
|
13765
13914
|
const aLex = lex(a);
|
|
13766
13915
|
const bLex = lex(b);
|
|
@@ -13880,6 +14029,15 @@ var ComputeEngine = (() => {
|
|
|
13880
14029
|
}
|
|
13881
14030
|
return (a.complexity ?? DEFAULT_COMPLEXITY) - (b.complexity ?? DEFAULT_COMPLEXITY);
|
|
13882
14031
|
}
|
|
14032
|
+
function canonicalOrder(expr, { recursive = false }) {
|
|
14033
|
+
if (expr.ops) {
|
|
14034
|
+
const ops2 = recursive ? expr.ops.map((x) => canonicalOrder(x, { recursive })) : expr.ops;
|
|
14035
|
+
if (expr.head === "Add")
|
|
14036
|
+
return expr.engine._fn("Add", sortAdd(ops2));
|
|
14037
|
+
return expr.engine._fn(expr.head, ops2.sort(order));
|
|
14038
|
+
}
|
|
14039
|
+
return expr;
|
|
14040
|
+
}
|
|
13883
14041
|
function getLeafCount(expr) {
|
|
13884
14042
|
if (expr.keys !== null)
|
|
13885
14043
|
return 1 + expr.keysCount;
|
|
@@ -13930,7 +14088,7 @@ var ComputeEngine = (() => {
|
|
|
13930
14088
|
}
|
|
13931
14089
|
|
|
13932
14090
|
// src/compute-engine/symbolic/sum.ts
|
|
13933
|
-
var import_complex6 = __toESM(require_complex());
|
|
14091
|
+
var import_complex6 = __toESM(require_complex(), 1);
|
|
13934
14092
|
|
|
13935
14093
|
// src/compute-engine/collection-utils.ts
|
|
13936
14094
|
function isCollection(col) {
|
|
@@ -14235,7 +14393,7 @@ var ComputeEngine = (() => {
|
|
|
14235
14393
|
return ce.Zero;
|
|
14236
14394
|
if (xs.length === 1 && !isIndexableCollection(xs[0]))
|
|
14237
14395
|
return xs[0];
|
|
14238
|
-
return ce._fn("Add", sortAdd(
|
|
14396
|
+
return ce._fn("Add", sortAdd(xs));
|
|
14239
14397
|
}
|
|
14240
14398
|
};
|
|
14241
14399
|
|
|
@@ -14445,10 +14603,10 @@ var ComputeEngine = (() => {
|
|
|
14445
14603
|
}
|
|
14446
14604
|
|
|
14447
14605
|
// src/compute-engine/boxed-expression/abstract-boxed-expression.ts
|
|
14448
|
-
var import_complex8 = __toESM(require_complex());
|
|
14606
|
+
var import_complex8 = __toESM(require_complex(), 1);
|
|
14449
14607
|
|
|
14450
14608
|
// src/compute-engine/symbolic/utils.ts
|
|
14451
|
-
var import_complex7 = __toESM(require_complex());
|
|
14609
|
+
var import_complex7 = __toESM(require_complex(), 1);
|
|
14452
14610
|
function makePositive(expr) {
|
|
14453
14611
|
if (expr.head === "Negate")
|
|
14454
14612
|
return [-1, expr.op1];
|
|
@@ -15625,6 +15783,7 @@ var ComputeEngine = (() => {
|
|
|
15625
15783
|
set value(_value) {
|
|
15626
15784
|
throw new Error(`Can't change the value of \\(${this.latex}\\)`);
|
|
15627
15785
|
}
|
|
15786
|
+
// @ts-ignore
|
|
15628
15787
|
get domain() {
|
|
15629
15788
|
return void 0;
|
|
15630
15789
|
}
|
|
@@ -15990,7 +16149,7 @@ var ComputeEngine = (() => {
|
|
|
15990
16149
|
return ce.number(ce.complex(re, im));
|
|
15991
16150
|
}
|
|
15992
16151
|
if (ops2.length > 1)
|
|
15993
|
-
ops2 = sortAdd(
|
|
16152
|
+
ops2 = sortAdd(ops2);
|
|
15994
16153
|
return ce._fn("Add", ops2);
|
|
15995
16154
|
}
|
|
15996
16155
|
function domainAdd(_ce, args) {
|
|
@@ -16094,12 +16253,16 @@ var ComputeEngine = (() => {
|
|
|
16094
16253
|
}
|
|
16095
16254
|
return result ?? void 0;
|
|
16096
16255
|
}
|
|
16097
|
-
const [index, lower, upper, isFinite2] = normalizeLimits(range);
|
|
16256
|
+
const [index, lower, upper, isFinite2] = normalizeLimits(range.evaluate());
|
|
16098
16257
|
if (!index)
|
|
16099
16258
|
return void 0;
|
|
16100
16259
|
const fn = expr;
|
|
16101
|
-
if (
|
|
16260
|
+
if (lower >= upper)
|
|
16102
16261
|
return void 0;
|
|
16262
|
+
if (mode === "simplify" && upper - lower >= MAX_SYMBOLIC_TERMS)
|
|
16263
|
+
return void 0;
|
|
16264
|
+
if (mode === "evaluate" && upper - lower >= MAX_SYMBOLIC_TERMS)
|
|
16265
|
+
mode = "N";
|
|
16103
16266
|
const savedContext = ce.swapScope(fn.scope);
|
|
16104
16267
|
ce.pushScope();
|
|
16105
16268
|
fn.bind();
|
|
@@ -16198,7 +16361,7 @@ var ComputeEngine = (() => {
|
|
|
16198
16361
|
}
|
|
16199
16362
|
|
|
16200
16363
|
// src/compute-engine/symbolic/negate.ts
|
|
16201
|
-
var import_complex9 = __toESM(require_complex());
|
|
16364
|
+
var import_complex9 = __toESM(require_complex(), 1);
|
|
16202
16365
|
function negateLiteral(expr, metadata) {
|
|
16203
16366
|
let n = expr.numericValue;
|
|
16204
16367
|
if (n === null)
|
|
@@ -16730,10 +16893,10 @@ var ComputeEngine = (() => {
|
|
|
16730
16893
|
}
|
|
16731
16894
|
|
|
16732
16895
|
// src/compute-engine/boxed-expression/box.ts
|
|
16733
|
-
var import_complex14 = __toESM(require_complex());
|
|
16896
|
+
var import_complex14 = __toESM(require_complex(), 1);
|
|
16734
16897
|
|
|
16735
16898
|
// src/compute-engine/boxed-expression/serialize.ts
|
|
16736
|
-
var import_complex11 = __toESM(require_complex());
|
|
16899
|
+
var import_complex11 = __toESM(require_complex(), 1);
|
|
16737
16900
|
|
|
16738
16901
|
// src/compute-engine/numerics/numeric-bignum.ts
|
|
16739
16902
|
function gcd3(a, b) {
|
|
@@ -16858,7 +17021,7 @@ var ComputeEngine = (() => {
|
|
|
16858
17021
|
}
|
|
16859
17022
|
|
|
16860
17023
|
// src/compute-engine/symbolic/product.ts
|
|
16861
|
-
var import_complex10 = __toESM(require_complex());
|
|
17024
|
+
var import_complex10 = __toESM(require_complex(), 1);
|
|
16862
17025
|
var Product = class {
|
|
16863
17026
|
constructor(ce, xs, options) {
|
|
16864
17027
|
this.options = options;
|
|
@@ -17806,7 +17969,7 @@ var ComputeEngine = (() => {
|
|
|
17806
17969
|
};
|
|
17807
17970
|
|
|
17808
17971
|
// src/compute-engine/boxed-expression/boxed-function.ts
|
|
17809
|
-
var import_complex12 = __toESM(require_complex());
|
|
17972
|
+
var import_complex12 = __toESM(require_complex(), 1);
|
|
17810
17973
|
|
|
17811
17974
|
// src/compute-engine/simplify-rules.ts
|
|
17812
17975
|
var SIMPLIFY_RULES = [];
|
|
@@ -17814,7 +17977,7 @@ var ComputeEngine = (() => {
|
|
|
17814
17977
|
// src/compute-engine/function-utils.ts
|
|
17815
17978
|
function canonicalFunctionExpression(expr) {
|
|
17816
17979
|
if (expr.head === "N" && typeof expr.op1.head === "string") {
|
|
17817
|
-
const newHead = {
|
|
17980
|
+
const newHead = { Integrate: "NIntegrate", Limit: "NLimit" }[expr.op1.head];
|
|
17818
17981
|
if (newHead)
|
|
17819
17982
|
expr = expr.engine._fn(newHead, expr.op1.ops);
|
|
17820
17983
|
}
|
|
@@ -18285,6 +18448,11 @@ var ComputeEngine = (() => {
|
|
|
18285
18448
|
evaluate(options) {
|
|
18286
18449
|
if (!this.isValid)
|
|
18287
18450
|
return this;
|
|
18451
|
+
if (options?.numericMode) {
|
|
18452
|
+
const h = this.head;
|
|
18453
|
+
if (h === "Integrate" || h === "Limit")
|
|
18454
|
+
return this.engine.box(["N", this], { canonical: true }).evaluate(options);
|
|
18455
|
+
}
|
|
18288
18456
|
if (!this.isCanonical) {
|
|
18289
18457
|
this.engine.pushScope();
|
|
18290
18458
|
const canonical2 = this.canonical;
|
|
@@ -18524,7 +18692,7 @@ var ComputeEngine = (() => {
|
|
|
18524
18692
|
}
|
|
18525
18693
|
|
|
18526
18694
|
// src/compute-engine/boxed-expression/boxed-number.ts
|
|
18527
|
-
var import_complex13 = __toESM(require_complex());
|
|
18695
|
+
var import_complex13 = __toESM(require_complex(), 1);
|
|
18528
18696
|
|
|
18529
18697
|
// src/compute-engine/numerics/primes.ts
|
|
18530
18698
|
var LARGE_PRIME = 1125899906842597;
|
|
@@ -19412,7 +19580,7 @@ var ComputeEngine = (() => {
|
|
|
19412
19580
|
}
|
|
19413
19581
|
|
|
19414
19582
|
// src/compute-engine/library/arithmetic.ts
|
|
19415
|
-
var import_complex16 = __toESM(require_complex());
|
|
19583
|
+
var import_complex16 = __toESM(require_complex(), 1);
|
|
19416
19584
|
|
|
19417
19585
|
// src/compute-engine/numerics/numeric-complex.ts
|
|
19418
19586
|
function gamma3(c) {
|
|
@@ -19423,7 +19591,7 @@ var ComputeEngine = (() => {
|
|
|
19423
19591
|
}
|
|
19424
19592
|
|
|
19425
19593
|
// src/compute-engine/library/arithmetic-power.ts
|
|
19426
|
-
var import_complex15 = __toESM(require_complex());
|
|
19594
|
+
var import_complex15 = __toESM(require_complex(), 1);
|
|
19427
19595
|
function canonicalPower(ce, base, exponent, metadata) {
|
|
19428
19596
|
if (exponent.symbol === "ComplexInfinity")
|
|
19429
19597
|
return ce.NaN;
|
|
@@ -21115,71 +21283,6 @@ var ComputeEngine = (() => {
|
|
|
21115
21283
|
evaluate: (ce, ops2) => evalSummation(ce, ops2[0], ops2[1], "evaluate"),
|
|
21116
21284
|
N: (ce, ops2) => evalSummation(ce, ops2[0], ops2[1], "N")
|
|
21117
21285
|
}
|
|
21118
|
-
},
|
|
21119
|
-
// Limits
|
|
21120
|
-
Limit: {
|
|
21121
|
-
description: "Limit of a function",
|
|
21122
|
-
complexity: 5e3,
|
|
21123
|
-
hold: "all",
|
|
21124
|
-
threadable: false,
|
|
21125
|
-
signature: {
|
|
21126
|
-
domain: [
|
|
21127
|
-
"FunctionOf",
|
|
21128
|
-
"Anything",
|
|
21129
|
-
"Numbers",
|
|
21130
|
-
["OptArg", "Numbers"],
|
|
21131
|
-
"Numbers"
|
|
21132
|
-
],
|
|
21133
|
-
N: (ce, ops2) => {
|
|
21134
|
-
const [f, x, dir] = ops2;
|
|
21135
|
-
const target = asFloat(x.N());
|
|
21136
|
-
if (target === null)
|
|
21137
|
-
return void 0;
|
|
21138
|
-
const fn = applicable(f);
|
|
21139
|
-
return ce.number(
|
|
21140
|
-
limit(
|
|
21141
|
-
(x2) => {
|
|
21142
|
-
const y = fn([ce.number(x2)])?.value;
|
|
21143
|
-
return typeof y === "number" ? y : Number.NaN;
|
|
21144
|
-
},
|
|
21145
|
-
target,
|
|
21146
|
-
dir ? asFloat(dir) ?? 1 : 1
|
|
21147
|
-
)
|
|
21148
|
-
);
|
|
21149
|
-
}
|
|
21150
|
-
}
|
|
21151
|
-
},
|
|
21152
|
-
NLimit: {
|
|
21153
|
-
description: "Numerical approximation of the limit of a function",
|
|
21154
|
-
complexity: 5e3,
|
|
21155
|
-
hold: "all",
|
|
21156
|
-
threadable: false,
|
|
21157
|
-
signature: {
|
|
21158
|
-
domain: [
|
|
21159
|
-
"FunctionOf",
|
|
21160
|
-
"Anything",
|
|
21161
|
-
"Numbers",
|
|
21162
|
-
["OptArg", "Numbers"],
|
|
21163
|
-
"Numbers"
|
|
21164
|
-
],
|
|
21165
|
-
evaluate: (ce, ops2) => {
|
|
21166
|
-
const [f, x, dir] = ops2;
|
|
21167
|
-
const target = asFloat(x.N());
|
|
21168
|
-
if (target === null)
|
|
21169
|
-
return void 0;
|
|
21170
|
-
const fn = applicable(f);
|
|
21171
|
-
return ce.number(
|
|
21172
|
-
limit(
|
|
21173
|
-
(x2) => {
|
|
21174
|
-
const y = fn([ce.number(x2)])?.value;
|
|
21175
|
-
return typeof y === "number" ? y : Number.NaN;
|
|
21176
|
-
},
|
|
21177
|
-
target,
|
|
21178
|
-
dir ? asFloat(dir) ?? 1 : 1
|
|
21179
|
-
)
|
|
21180
|
-
);
|
|
21181
|
-
}
|
|
21182
|
-
}
|
|
21183
21286
|
}
|
|
21184
21287
|
},
|
|
21185
21288
|
//
|
|
@@ -21850,6 +21953,73 @@ var ComputeEngine = (() => {
|
|
|
21850
21953
|
}
|
|
21851
21954
|
}
|
|
21852
21955
|
}
|
|
21956
|
+
},
|
|
21957
|
+
{
|
|
21958
|
+
// Limits
|
|
21959
|
+
Limit: {
|
|
21960
|
+
description: "Limit of a function",
|
|
21961
|
+
complexity: 5e3,
|
|
21962
|
+
hold: "all",
|
|
21963
|
+
threadable: false,
|
|
21964
|
+
signature: {
|
|
21965
|
+
domain: [
|
|
21966
|
+
"FunctionOf",
|
|
21967
|
+
"Anything",
|
|
21968
|
+
"Numbers",
|
|
21969
|
+
["OptArg", "Numbers"],
|
|
21970
|
+
"Numbers"
|
|
21971
|
+
],
|
|
21972
|
+
N: (ce, ops2) => {
|
|
21973
|
+
const [f, x, dir] = ops2;
|
|
21974
|
+
const target = asFloat(x.N());
|
|
21975
|
+
if (target === null)
|
|
21976
|
+
return void 0;
|
|
21977
|
+
const fn = applicable(f);
|
|
21978
|
+
return ce.number(
|
|
21979
|
+
limit(
|
|
21980
|
+
(x2) => {
|
|
21981
|
+
const y = fn([ce.number(x2)])?.value;
|
|
21982
|
+
return typeof y === "number" ? y : Number.NaN;
|
|
21983
|
+
},
|
|
21984
|
+
target,
|
|
21985
|
+
dir ? asFloat(dir) ?? 1 : 1
|
|
21986
|
+
)
|
|
21987
|
+
);
|
|
21988
|
+
}
|
|
21989
|
+
}
|
|
21990
|
+
},
|
|
21991
|
+
NLimit: {
|
|
21992
|
+
description: "Numerical approximation of the limit of a function",
|
|
21993
|
+
complexity: 5e3,
|
|
21994
|
+
hold: "all",
|
|
21995
|
+
threadable: false,
|
|
21996
|
+
signature: {
|
|
21997
|
+
domain: [
|
|
21998
|
+
"FunctionOf",
|
|
21999
|
+
"Anything",
|
|
22000
|
+
"Numbers",
|
|
22001
|
+
["OptArg", "Numbers"],
|
|
22002
|
+
"Numbers"
|
|
22003
|
+
],
|
|
22004
|
+
evaluate: (ce, ops2) => {
|
|
22005
|
+
const [f, x, dir] = ops2;
|
|
22006
|
+
const target = asFloat(x.N());
|
|
22007
|
+
if (target === null)
|
|
22008
|
+
return void 0;
|
|
22009
|
+
const fn = applicable(f);
|
|
22010
|
+
return ce.number(
|
|
22011
|
+
limit(
|
|
22012
|
+
(x2) => {
|
|
22013
|
+
const y = fn([ce.number(x2)])?.value;
|
|
22014
|
+
return typeof y === "number" ? y : Number.NaN;
|
|
22015
|
+
},
|
|
22016
|
+
target,
|
|
22017
|
+
dir ? asFloat(dir) ?? 1 : 1
|
|
22018
|
+
)
|
|
22019
|
+
);
|
|
22020
|
+
}
|
|
22021
|
+
}
|
|
22022
|
+
}
|
|
21853
22023
|
}
|
|
21854
22024
|
];
|
|
21855
22025
|
|
|
@@ -22606,6 +22776,15 @@ var ComputeEngine = (() => {
|
|
|
22606
22776
|
return result;
|
|
22607
22777
|
}
|
|
22608
22778
|
function canonicalList(ce, ops2) {
|
|
22779
|
+
const op12 = ops2[0];
|
|
22780
|
+
if (ops2.length === 1 && op12.head === "Matrix") {
|
|
22781
|
+
const [body, delimiters, columns] = op12.ops;
|
|
22782
|
+
if (!delimiters || delimiters.string === "..") {
|
|
22783
|
+
if (!columns)
|
|
22784
|
+
return ce._fn("Matrix", [body, delimiters]);
|
|
22785
|
+
return ce._fn("Matrix", [body, ce.string("[]"), columns]);
|
|
22786
|
+
}
|
|
22787
|
+
}
|
|
22609
22788
|
ops2 = ops2.map((op3) => {
|
|
22610
22789
|
if (op3.head === "Delimiter") {
|
|
22611
22790
|
if (op3.op1.head === "Sequence")
|
|
@@ -23449,12 +23628,44 @@ var ComputeEngine = (() => {
|
|
|
23449
23628
|
evaluate: (_ce, ops2) => ops2[0].simplify()
|
|
23450
23629
|
}
|
|
23451
23630
|
},
|
|
23631
|
+
// Can be used to sort arguments of an expression.
|
|
23632
|
+
// Sorting arguments of commutative functions is a weak form of
|
|
23633
|
+
// canonicalization that can be useful in some cases, for example
|
|
23634
|
+
// to accept "x+1" and "1+x" while rejecting "x+1" and "2x-x+1"
|
|
23635
|
+
CanonicalOrder: {
|
|
23636
|
+
complexity: 8200,
|
|
23637
|
+
hold: "all",
|
|
23638
|
+
signature: {
|
|
23639
|
+
domain: ["FunctionOf", "Anything", "Anything"],
|
|
23640
|
+
canonical: (_ce, ops2) => canonicalOrder(ops2[0], { recursive: true })
|
|
23641
|
+
}
|
|
23642
|
+
},
|
|
23452
23643
|
N: {
|
|
23453
23644
|
hold: "all",
|
|
23454
23645
|
signature: {
|
|
23455
23646
|
domain: ["FunctionOf", "Anything", "Anything"],
|
|
23456
23647
|
result: (_ce, ops2) => ops2[0].domain,
|
|
23457
|
-
canonical: (ce, ops2) =>
|
|
23648
|
+
canonical: (ce, ops2) => {
|
|
23649
|
+
if (ops2.length !== 1)
|
|
23650
|
+
return ce._fn("N", checkArity(ce, ops2, 1));
|
|
23651
|
+
const h = ops2[0].head;
|
|
23652
|
+
if (h === "N")
|
|
23653
|
+
return ops2[0].canonical;
|
|
23654
|
+
if (h === "Integrate") {
|
|
23655
|
+
const [index, lower, upper] = normalizeLimits(ops2[0].op2);
|
|
23656
|
+
if (!index || lower === void 0 || upper === void 0)
|
|
23657
|
+
return null;
|
|
23658
|
+
const fn = ops2[0].op1;
|
|
23659
|
+
return ce._fn("NIntegrate", [
|
|
23660
|
+
ce.box(["Function", fn, index]),
|
|
23661
|
+
ce.number(lower),
|
|
23662
|
+
ce.number(upper)
|
|
23663
|
+
]);
|
|
23664
|
+
}
|
|
23665
|
+
if (h === "Limit")
|
|
23666
|
+
return ce._fn("NLimit", ops2[0].ops);
|
|
23667
|
+
return ce._fn("N", ops2);
|
|
23668
|
+
},
|
|
23458
23669
|
evaluate: (_ce, ops2) => ops2[0].N()
|
|
23459
23670
|
}
|
|
23460
23671
|
},
|
|
@@ -23712,22 +23923,40 @@ var ComputeEngine = (() => {
|
|
|
23712
23923
|
evaluate: (_ce, ops2) => ops2[0].evaluate(),
|
|
23713
23924
|
N: (_ce, ops2) => ops2[0].N()
|
|
23714
23925
|
}
|
|
23926
|
+
},
|
|
23927
|
+
// Vector is a specialized collection to represent a column vector.
|
|
23928
|
+
// ["Vector", a, b, c] is a shorthand for ["List", ["List", a], ["List", b], ["List", c]]
|
|
23929
|
+
Vector: {
|
|
23930
|
+
complexity: 9e3,
|
|
23931
|
+
hold: "all",
|
|
23932
|
+
signature: {
|
|
23933
|
+
restParam: "Anything",
|
|
23934
|
+
result: "Lists",
|
|
23935
|
+
canonical: (ce, ops2) => {
|
|
23936
|
+
return ce._fn("Matrix", [
|
|
23937
|
+
ce._fn(
|
|
23938
|
+
"List",
|
|
23939
|
+
ce.canonical(ops2).map((op3) => ce._fn("List", [op3]))
|
|
23940
|
+
)
|
|
23941
|
+
]);
|
|
23942
|
+
}
|
|
23943
|
+
}
|
|
23715
23944
|
}
|
|
23716
23945
|
}
|
|
23717
23946
|
];
|
|
23718
|
-
function canonicalMatrix(ce, ops2) {
|
|
23947
|
+
function canonicalMatrix(ce, ops2, head2 = "Matrix") {
|
|
23719
23948
|
if (ops2.length === 0)
|
|
23720
|
-
return ce._fn(
|
|
23721
|
-
const body = ops2[0].canonical;
|
|
23949
|
+
return ce._fn(head2, []);
|
|
23950
|
+
const body = ops2[0].head === "Vector" ? ops2[0].canonical.ops[0] : ops2[0].canonical;
|
|
23722
23951
|
const delims = ops2[1]?.canonical;
|
|
23723
23952
|
const columns = ops2[2]?.canonical;
|
|
23724
23953
|
if (ops2.length > 3)
|
|
23725
|
-
return ce._fn(
|
|
23954
|
+
return ce._fn(head2, checkArity(ce, ops2, 3));
|
|
23726
23955
|
if (columns)
|
|
23727
|
-
return ce._fn(
|
|
23956
|
+
return ce._fn(head2, [body, delims, columns]);
|
|
23728
23957
|
if (delims)
|
|
23729
|
-
return ce._fn(
|
|
23730
|
-
return ce._fn(
|
|
23958
|
+
return ce._fn(head2, [body, delims]);
|
|
23959
|
+
return ce._fn(head2, [body]);
|
|
23731
23960
|
}
|
|
23732
23961
|
|
|
23733
23962
|
// src/compute-engine/library/logic.ts
|
|
@@ -23965,6 +24194,28 @@ var ComputeEngine = (() => {
|
|
|
23965
24194
|
}
|
|
23966
24195
|
}
|
|
23967
24196
|
},
|
|
24197
|
+
IsSame: {
|
|
24198
|
+
description: "Compare two expressions for structural equality",
|
|
24199
|
+
hold: "all",
|
|
24200
|
+
signature: {
|
|
24201
|
+
domain: "RelationalOperators",
|
|
24202
|
+
// Since we want to work on non-canonical expressions,
|
|
24203
|
+
// do nothing to canonicalize the arguments
|
|
24204
|
+
evaluate: (ce, ops2) => {
|
|
24205
|
+
if (ops2.length !== 2)
|
|
24206
|
+
return void 0;
|
|
24207
|
+
let [lhs, rhs] = ops2;
|
|
24208
|
+
if (lhs.head === "CanonicalOrder")
|
|
24209
|
+
lhs = lhs.canonical;
|
|
24210
|
+
if (rhs.head === "CanonicalOrder")
|
|
24211
|
+
rhs = rhs.canonical;
|
|
24212
|
+
const test = lhs.isSame(rhs);
|
|
24213
|
+
if (test === true)
|
|
24214
|
+
return ce.True;
|
|
24215
|
+
return ce.False;
|
|
24216
|
+
}
|
|
24217
|
+
}
|
|
24218
|
+
},
|
|
23968
24219
|
Equal: {
|
|
23969
24220
|
commutative: true,
|
|
23970
24221
|
complexity: 11e3,
|
|
@@ -25652,7 +25903,7 @@ var ComputeEngine = (() => {
|
|
|
25652
25903
|
}
|
|
25653
25904
|
|
|
25654
25905
|
// src/compute-engine/boxed-expression/boxed-symbol-definition.ts
|
|
25655
|
-
var import_complex17 = __toESM(require_complex());
|
|
25906
|
+
var import_complex17 = __toESM(require_complex(), 1);
|
|
25656
25907
|
var _BoxedSymbolDefinition = class {
|
|
25657
25908
|
// @todo
|
|
25658
25909
|
constructor(ce, name, def) {
|
|
@@ -26644,7 +26895,7 @@ ${JSON.stringify(entry)}`
|
|
|
26644
26895
|
}
|
|
26645
26896
|
|
|
26646
26897
|
// src/compute-engine/cost-function.ts
|
|
26647
|
-
var import_complex19 = __toESM(require_complex());
|
|
26898
|
+
var import_complex19 = __toESM(require_complex(), 1);
|
|
26648
26899
|
function numericCostFunction(n) {
|
|
26649
26900
|
if (Number.isInteger(n) && n !== 0) {
|
|
26650
26901
|
return Math.floor(Math.log2(Math.abs(n)) / Math.log2(10)) + (n > 0 ? 1 : 2);
|
|
@@ -27226,6 +27477,7 @@ ${JSON.stringify(entry)}`
|
|
|
27226
27477
|
});
|
|
27227
27478
|
}
|
|
27228
27479
|
}
|
|
27480
|
+
// @ts-ignore
|
|
27229
27481
|
get domain() {
|
|
27230
27482
|
const def = this._def;
|
|
27231
27483
|
if (def) {
|
|
@@ -27614,7 +27866,6 @@ ${JSON.stringify(entry)}`
|
|
|
27614
27866
|
symbols: /* @__PURE__ */ new Set(),
|
|
27615
27867
|
expressions: /* @__PURE__ */ new Set()
|
|
27616
27868
|
};
|
|
27617
|
-
this._defaultDomain = null;
|
|
27618
27869
|
this._numericMode = options?.numericMode ?? "auto";
|
|
27619
27870
|
this._precision = Math.max(
|
|
27620
27871
|
options?.numericPrecision ?? 100,
|
|
@@ -27858,6 +28109,56 @@ ${JSON.stringify(entry)}`
|
|
|
27858
28109
|
return 0;
|
|
27859
28110
|
return n;
|
|
27860
28111
|
}
|
|
28112
|
+
/** Create an arbitrary precision number.
|
|
28113
|
+
*
|
|
28114
|
+
* The return value is an object with methods to perform arithmetic
|
|
28115
|
+
* operations:
|
|
28116
|
+
* - `toNumber()`: convert to a JavaScript `number` with potential loss of precision
|
|
28117
|
+
* - `add()`
|
|
28118
|
+
* - `sub()`
|
|
28119
|
+
* - `neg()` (unary minus)
|
|
28120
|
+
* - `mul()`
|
|
28121
|
+
* - `div()`
|
|
28122
|
+
* - `pow()`
|
|
28123
|
+
* - `sqrt()` (square root)
|
|
28124
|
+
* - `cbrt()` (cube root)
|
|
28125
|
+
* - `exp()` (e^x)
|
|
28126
|
+
* - `log()`
|
|
28127
|
+
* - `ln()` (natural logarithm)
|
|
28128
|
+
* - `mod()`
|
|
28129
|
+
|
|
28130
|
+
* - `abs()`
|
|
28131
|
+
* - `ceil()`
|
|
28132
|
+
* - `floor()`
|
|
28133
|
+
* - `round()`
|
|
28134
|
+
|
|
28135
|
+
* - `equals()`
|
|
28136
|
+
* - `gt()`
|
|
28137
|
+
* - `gte()`
|
|
28138
|
+
* - `lt()`
|
|
28139
|
+
* - `lte()`
|
|
28140
|
+
*
|
|
28141
|
+
* - `cos()`
|
|
28142
|
+
* - `sin()`
|
|
28143
|
+
* - `tanh()`
|
|
28144
|
+
* - `acos()`
|
|
28145
|
+
* - `asin()`
|
|
28146
|
+
* - `atan()`
|
|
28147
|
+
* - `cosh()`
|
|
28148
|
+
* - `sinh()`
|
|
28149
|
+
* - `acosh()`
|
|
28150
|
+
* - `asinh()`
|
|
28151
|
+
* - `atanh()`
|
|
28152
|
+
*
|
|
28153
|
+
* - `isFinite()`
|
|
28154
|
+
* - `isInteger()`
|
|
28155
|
+
* - `isNaN()`
|
|
28156
|
+
* - `isNegative()`
|
|
28157
|
+
* - `isPositive()`
|
|
28158
|
+
* - `isZero()`
|
|
28159
|
+
* - `sign()` (1, 0 or -1)
|
|
28160
|
+
*
|
|
28161
|
+
*/
|
|
27861
28162
|
bignum(a) {
|
|
27862
28163
|
if (typeof a === "bigint")
|
|
27863
28164
|
return new this._bignum(a.toString());
|
|
@@ -27868,6 +28169,51 @@ ${JSON.stringify(entry)}`
|
|
|
27868
28169
|
}
|
|
27869
28170
|
return this._BIGNUM_NAN;
|
|
27870
28171
|
}
|
|
28172
|
+
/** Create a complex number.
|
|
28173
|
+
* The return value is an object with methods to perform arithmetic
|
|
28174
|
+
* operations:
|
|
28175
|
+
* - `re` (real part, as a JavaScript `number`)
|
|
28176
|
+
* - `im` (imaginary part, as a JavaScript `number`)
|
|
28177
|
+
* - `add()`
|
|
28178
|
+
* - `sub()`
|
|
28179
|
+
* - `neg()` (unary minus)
|
|
28180
|
+
* - `mul()`
|
|
28181
|
+
* - `div()`
|
|
28182
|
+
* - `pow()`
|
|
28183
|
+
* - `sqrt()` (square root)
|
|
28184
|
+
* - `exp()` (e^x)
|
|
28185
|
+
* - `log()`
|
|
28186
|
+
* - `ln()` (natural logarithm)
|
|
28187
|
+
* - `mod()`
|
|
28188
|
+
|
|
28189
|
+
* - `abs()`
|
|
28190
|
+
* - `ceil()`
|
|
28191
|
+
* - `floor()`
|
|
28192
|
+
* - `round()`
|
|
28193
|
+
|
|
28194
|
+
* - `arg()` the angle of the complex number
|
|
28195
|
+
* - `inverse()` the inverse of the complex number 1/z
|
|
28196
|
+
* - `conjugate()` the conjugate of the complex number
|
|
28197
|
+
|
|
28198
|
+
* - `equals()`
|
|
28199
|
+
*
|
|
28200
|
+
* - `cos()`
|
|
28201
|
+
* - `sin()`
|
|
28202
|
+
* - `tanh()`
|
|
28203
|
+
* - `acos()`
|
|
28204
|
+
* - `asin()`
|
|
28205
|
+
* - `atan()`
|
|
28206
|
+
* - `cosh()`
|
|
28207
|
+
* - `sinh()`
|
|
28208
|
+
* - `acosh()`
|
|
28209
|
+
* - `asinh()`
|
|
28210
|
+
* - `atanh()`
|
|
28211
|
+
*
|
|
28212
|
+
* - `isFinite()`
|
|
28213
|
+
* - `isNaN()`
|
|
28214
|
+
* - `isZero()`
|
|
28215
|
+
* - `sign()` (1, 0 or -1)
|
|
28216
|
+
*/
|
|
27871
28217
|
complex(a, b) {
|
|
27872
28218
|
if (a instanceof Decimal)
|
|
27873
28219
|
a = a.toNumber();
|
|
@@ -27971,7 +28317,14 @@ ${JSON.stringify(entry)}`
|
|
|
27971
28317
|
return void 0;
|
|
27972
28318
|
}
|
|
27973
28319
|
/**
|
|
27974
|
-
*
|
|
28320
|
+
* Associate a new definition to a symbol in the current context.
|
|
28321
|
+
*
|
|
28322
|
+
* If a definition existed previously, it is replaced.
|
|
28323
|
+
*
|
|
28324
|
+
*
|
|
28325
|
+
* For internal use. Use `ce.declare()` instead.
|
|
28326
|
+
*
|
|
28327
|
+
* @internal
|
|
27975
28328
|
*/
|
|
27976
28329
|
defineSymbol(name, def) {
|
|
27977
28330
|
if (!this.context)
|
|
@@ -27988,6 +28341,15 @@ ${JSON.stringify(entry)}`
|
|
|
27988
28341
|
this.context.ids.set(boxedDef.name, boxedDef);
|
|
27989
28342
|
return boxedDef;
|
|
27990
28343
|
}
|
|
28344
|
+
/**
|
|
28345
|
+
* Associate a new delookupSymbolfinition to a function in the current context.
|
|
28346
|
+
*
|
|
28347
|
+
* If a definition existed previously, it is replaced.
|
|
28348
|
+
*
|
|
28349
|
+
* For internal use. Use `ce.declare()` instead.
|
|
28350
|
+
*
|
|
28351
|
+
* @internal
|
|
28352
|
+
*/
|
|
27991
28353
|
defineFunction(name, def) {
|
|
27992
28354
|
if (!this.context)
|
|
27993
28355
|
throw Error("Function cannot be defined: no scope available");
|
|
@@ -28032,8 +28394,8 @@ ${JSON.stringify(entry)}`
|
|
|
28032
28394
|
};
|
|
28033
28395
|
return this;
|
|
28034
28396
|
}
|
|
28035
|
-
/** Remove the
|
|
28036
|
-
*/
|
|
28397
|
+
/** Remove the most recent scope from the scope stack, and set its
|
|
28398
|
+
* parent scope as current. */
|
|
28037
28399
|
popScope() {
|
|
28038
28400
|
if (!this.context)
|
|
28039
28401
|
throw Error("No scope available");
|
|
@@ -28041,12 +28403,17 @@ ${JSON.stringify(entry)}`
|
|
|
28041
28403
|
console.assert(this.context);
|
|
28042
28404
|
return this;
|
|
28043
28405
|
}
|
|
28406
|
+
/** Set the current scope, return the previous scope. */
|
|
28044
28407
|
swapScope(scope) {
|
|
28045
28408
|
const oldScope = this.context;
|
|
28046
28409
|
this.context = scope;
|
|
28047
28410
|
console.assert(this.context);
|
|
28048
28411
|
return oldScope;
|
|
28049
28412
|
}
|
|
28413
|
+
/**
|
|
28414
|
+
* Reset the value of any identifiers that have been assigned a value
|
|
28415
|
+
* in the current scope.
|
|
28416
|
+
* @internal */
|
|
28050
28417
|
resetContext() {
|
|
28051
28418
|
if (!this.context)
|
|
28052
28419
|
return;
|
|
@@ -28066,6 +28433,7 @@ ${JSON.stringify(entry)}`
|
|
|
28066
28433
|
}
|
|
28067
28434
|
}
|
|
28068
28435
|
}
|
|
28436
|
+
/** @internal */
|
|
28069
28437
|
_printScope(options, scope, depth = 0) {
|
|
28070
28438
|
options ?? (options = { details: false, maxDepth: 1 });
|
|
28071
28439
|
scope ?? (scope = this.context);
|
|
@@ -28376,6 +28744,9 @@ ${JSON.stringify(entry)}`
|
|
|
28376
28744
|
}
|
|
28377
28745
|
return this._cache[cacheName]?.value;
|
|
28378
28746
|
}
|
|
28747
|
+
/**
|
|
28748
|
+
* Return a boxed expression from the input.
|
|
28749
|
+
*/
|
|
28379
28750
|
box(expr, options) {
|
|
28380
28751
|
return box(this, expr, options);
|
|
28381
28752
|
}
|
|
@@ -28385,6 +28756,16 @@ ${JSON.stringify(entry)}`
|
|
|
28385
28756
|
const bxs = xs;
|
|
28386
28757
|
return bxs.every((x) => x.isCanonical) ? bxs : bxs.map((x) => x.canonical);
|
|
28387
28758
|
}
|
|
28759
|
+
/**
|
|
28760
|
+
* Return a function expression.
|
|
28761
|
+
*
|
|
28762
|
+
* Note that the result may not be a function, or may have a different
|
|
28763
|
+
* `head` than the one specified.
|
|
28764
|
+
*
|
|
28765
|
+
* For example:
|
|
28766
|
+
* `ce.fn("Rational", [ce.number(1), ce.number(2)]))` \( \to \) `ce.number([1,2])`
|
|
28767
|
+
*
|
|
28768
|
+
*/
|
|
28388
28769
|
fn(head2, ops2, options) {
|
|
28389
28770
|
return boxFunction(this, head2, ops2, options ?? { canonical: true });
|
|
28390
28771
|
}
|
|
@@ -28429,18 +28810,33 @@ ${JSON.stringify(entry)}`
|
|
|
28429
28810
|
const actual = actualDomain ? actualDomain : this.symbol("Undefined");
|
|
28430
28811
|
return this.error(["incompatible-domain", expected, actual], where);
|
|
28431
28812
|
}
|
|
28813
|
+
/**
|
|
28814
|
+
* Add a`["Hold"]` wrapper to `expr.
|
|
28815
|
+
*/
|
|
28432
28816
|
hold(expr) {
|
|
28433
28817
|
return this._fn("Hold", [this.box(expr, { canonical: false })]);
|
|
28434
28818
|
}
|
|
28819
|
+
/** Shortcut for `this.fn("Add"...)`.
|
|
28820
|
+
*
|
|
28821
|
+
* The result is canonical.
|
|
28822
|
+
*/
|
|
28435
28823
|
add(ops2, metadata) {
|
|
28436
28824
|
const result = canonicalAdd(this, flattenOps(flattenSequence(ops2), "Add"));
|
|
28437
28825
|
if (metadata?.latex !== void 0)
|
|
28438
28826
|
result.latex = metadata.latex;
|
|
28439
28827
|
return result;
|
|
28440
28828
|
}
|
|
28829
|
+
/** Shortcut for `this.fn("Negate", [expr])`
|
|
28830
|
+
*
|
|
28831
|
+
* The result is canonical.
|
|
28832
|
+
*/
|
|
28441
28833
|
neg(expr, metadata) {
|
|
28442
28834
|
return canonicalNegate(expr, metadata);
|
|
28443
28835
|
}
|
|
28836
|
+
/** Shortcut for `this.fn("Multiply"...)`
|
|
28837
|
+
*
|
|
28838
|
+
* The result is canonical.
|
|
28839
|
+
*/
|
|
28444
28840
|
mul(ops2, metadata) {
|
|
28445
28841
|
const result = canonicalMultiply(
|
|
28446
28842
|
this,
|
|
@@ -28450,15 +28846,27 @@ ${JSON.stringify(entry)}`
|
|
|
28450
28846
|
result.latex = metadata.latex;
|
|
28451
28847
|
return result;
|
|
28452
28848
|
}
|
|
28849
|
+
/** Shortcut for `this.fn("Divide", [num, denom])`
|
|
28850
|
+
*
|
|
28851
|
+
* The result is canonical.
|
|
28852
|
+
*/
|
|
28453
28853
|
div(num, denom, metadata) {
|
|
28454
28854
|
const result = canonicalDivide(this, num, denom);
|
|
28455
28855
|
if (metadata?.latex !== void 0)
|
|
28456
28856
|
result.latex = metadata.latex;
|
|
28457
28857
|
return result;
|
|
28458
28858
|
}
|
|
28859
|
+
/** Shortcut for `this.fn("Sqrt"...)`
|
|
28860
|
+
*
|
|
28861
|
+
* The result is canonical.
|
|
28862
|
+
*/
|
|
28459
28863
|
sqrt(base, metadata) {
|
|
28460
28864
|
return canonicalPower(this, base, this.Half, metadata);
|
|
28461
28865
|
}
|
|
28866
|
+
/** Shortcut for `this.fn("Power"...)`
|
|
28867
|
+
*
|
|
28868
|
+
* The result is canonical.
|
|
28869
|
+
*/
|
|
28462
28870
|
pow(base, exponent, metadata) {
|
|
28463
28871
|
if (base.symbol === "ExponentialE" && exponent instanceof import_complex20.Complex) {
|
|
28464
28872
|
const im = exponent.im;
|
|
@@ -28509,6 +28917,10 @@ ${JSON.stringify(entry)}`
|
|
|
28509
28917
|
exponent = this.number(exponent);
|
|
28510
28918
|
return canonicalPower(this, base, exponent, metadata);
|
|
28511
28919
|
}
|
|
28920
|
+
/** Shortcut for `this.fn("Divide", [1, expr])`
|
|
28921
|
+
*
|
|
28922
|
+
* The result is canonical.
|
|
28923
|
+
*/
|
|
28512
28924
|
inv(expr, metadata) {
|
|
28513
28925
|
if (expr.isOne)
|
|
28514
28926
|
return this.One;
|
|
@@ -28541,21 +28953,33 @@ ${JSON.stringify(entry)}`
|
|
|
28541
28953
|
return this._fn("Divide", [this.One, expr], metadata);
|
|
28542
28954
|
return this._fn("Power", [expr, e], metadata);
|
|
28543
28955
|
}
|
|
28956
|
+
/** Shortcut for `this.fn("Pair"...)`
|
|
28957
|
+
*
|
|
28958
|
+
* The result is canonical.
|
|
28959
|
+
*/
|
|
28544
28960
|
pair(first, second, metadata) {
|
|
28545
28961
|
return new BoxedFunction(this, "Tuple", [first, second], {
|
|
28546
28962
|
metadata,
|
|
28547
28963
|
canonical: true
|
|
28548
28964
|
});
|
|
28549
28965
|
}
|
|
28966
|
+
/** Shortcut for `this.fn("Tuple"...)`
|
|
28967
|
+
*
|
|
28968
|
+
* The result is canonical.
|
|
28969
|
+
*/
|
|
28550
28970
|
tuple(elements, metadata) {
|
|
28551
28971
|
return new BoxedFunction(this, "Tuple", canonical(elements), {
|
|
28552
28972
|
metadata,
|
|
28553
28973
|
canonical: true
|
|
28554
28974
|
});
|
|
28555
28975
|
}
|
|
28976
|
+
array(elements, metadata) {
|
|
28977
|
+
return this.Nothing;
|
|
28978
|
+
}
|
|
28556
28979
|
string(s, metadata) {
|
|
28557
28980
|
return new BoxedString(this, s, metadata);
|
|
28558
28981
|
}
|
|
28982
|
+
/** Return a boxed symbol */
|
|
28559
28983
|
symbol(name, options) {
|
|
28560
28984
|
options = options ? { ...options } : {};
|
|
28561
28985
|
if (!("canonical" in options))
|
|
@@ -28593,6 +29017,11 @@ ${JSON.stringify(entry)}`
|
|
|
28593
29017
|
return makeCanonicalSymbol(this, name);
|
|
28594
29018
|
return new BoxedSymbol(this, name, options);
|
|
28595
29019
|
}
|
|
29020
|
+
/** Return a canonical boxed domain.
|
|
29021
|
+
*
|
|
29022
|
+
* If the domain is invalid, may return an `["Error"]` expression
|
|
29023
|
+
*
|
|
29024
|
+
*/
|
|
28596
29025
|
domain(domain, metadata) {
|
|
28597
29026
|
if (domain instanceof _BoxedDomain)
|
|
28598
29027
|
return domain;
|
|
@@ -28626,7 +29055,7 @@ ${JSON.stringify(entry)}`
|
|
|
28626
29055
|
throw Error("Expected a domain constructor, got " + constructor);
|
|
28627
29056
|
return new _BoxedDomain(this, domain, metadata);
|
|
28628
29057
|
}
|
|
28629
|
-
|
|
29058
|
+
/**
|
|
28630
29059
|
* This function tries to avoid creating a boxed number if `num` corresponds
|
|
28631
29060
|
* to a common value for which we have a shared instance (-1, 0, NaN, etc...)
|
|
28632
29061
|
*/
|
|
@@ -28678,6 +29107,9 @@ ${JSON.stringify(entry)}`
|
|
|
28678
29107
|
const result = this.latexSyntax.parse(latexString(latex) ?? latex);
|
|
28679
29108
|
return this.box(result, options);
|
|
28680
29109
|
}
|
|
29110
|
+
/** Serialize a `BoxedExpression` or a `MathJSON` expression to
|
|
29111
|
+
* a LaTeX string
|
|
29112
|
+
*/
|
|
28681
29113
|
serialize(x, options) {
|
|
28682
29114
|
if (typeof x === "object" && "json" in x) {
|
|
28683
29115
|
const ce = "engine" in x ? x.engine : this;
|
|
@@ -28688,6 +29120,16 @@ ${JSON.stringify(entry)}`
|
|
|
28688
29120
|
}
|
|
28689
29121
|
return this.latexSyntax.serialize(x, options);
|
|
28690
29122
|
}
|
|
29123
|
+
/**
|
|
29124
|
+
* Options to control the serialization of MathJSON expression to LaTeX
|
|
29125
|
+
* when using `this.latex` or `this.engine.serialize()`.
|
|
29126
|
+
*
|
|
29127
|
+
*
|
|
29128
|
+
* {@inheritDoc NumberFormattingOptions}
|
|
29129
|
+
* {@inheritDoc ParseLatexOptions}
|
|
29130
|
+
* {@inheritDoc SerializeLatexOptions}
|
|
29131
|
+
*
|
|
29132
|
+
*/
|
|
28691
29133
|
get latexOptions() {
|
|
28692
29134
|
const latexSyntax = this.latexSyntax;
|
|
28693
29135
|
return new Proxy(
|
|
@@ -28708,6 +29150,7 @@ ${JSON.stringify(entry)}`
|
|
|
28708
29150
|
set latexOptions(opts) {
|
|
28709
29151
|
this.latexSyntax.updateOptions(opts);
|
|
28710
29152
|
}
|
|
29153
|
+
/** {@inheritDoc JsonSerializationOptions} */
|
|
28711
29154
|
get jsonSerializationOptions() {
|
|
28712
29155
|
if (this._useRawJsonSerializationOptions) {
|
|
28713
29156
|
return new Proxy(this._rawJsonSerializationOptions, {
|
|
@@ -28796,6 +29239,21 @@ ${JSON.stringify(entry)}`
|
|
|
28796
29239
|
verify(_query) {
|
|
28797
29240
|
return false;
|
|
28798
29241
|
}
|
|
29242
|
+
/**
|
|
29243
|
+
* Add an assumption.
|
|
29244
|
+
*
|
|
29245
|
+
* Note that the assumption is put into canonical form before being added.
|
|
29246
|
+
*
|
|
29247
|
+
* @param symbol - The symbol to make an assumption about
|
|
29248
|
+
*
|
|
29249
|
+
* Returns:
|
|
29250
|
+
* - `contradiction` if the new assumption is incompatible with previous
|
|
29251
|
+
* ones.
|
|
29252
|
+
* - `tautology` if the new assumption is redundant with previous ones.
|
|
29253
|
+
* - `ok` if the assumption was successfully added to the assumption set.
|
|
29254
|
+
*
|
|
29255
|
+
*
|
|
29256
|
+
*/
|
|
28799
29257
|
assume(predicate) {
|
|
28800
29258
|
try {
|
|
28801
29259
|
return assume(this.box(predicate, { canonical: false }));
|
|
@@ -28804,6 +29262,7 @@ ${JSON.stringify(entry)}`
|
|
|
28804
29262
|
return "internal-error";
|
|
28805
29263
|
}
|
|
28806
29264
|
}
|
|
29265
|
+
/** Remove all assumptions about one or more symbols */
|
|
28807
29266
|
forget(symbol2) {
|
|
28808
29267
|
if (!this.context)
|
|
28809
29268
|
throw Error("No scope available");
|
|
@@ -28851,10 +29310,10 @@ ${JSON.stringify(entry)}`
|
|
|
28851
29310
|
}
|
|
28852
29311
|
|
|
28853
29312
|
// src/compute-engine.ts
|
|
28854
|
-
var version = "0.
|
|
29313
|
+
var version = "0.21.0";
|
|
28855
29314
|
globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
|
|
28856
29315
|
ComputeEngine: ComputeEngine.prototype.constructor,
|
|
28857
|
-
version: "0.
|
|
29316
|
+
version: "0.21.0"
|
|
28858
29317
|
};
|
|
28859
29318
|
return __toCommonJS(compute_engine_exports);
|
|
28860
29319
|
})();
|