@cortex-js/compute-engine 0.26.2 → 0.26.3
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/README.md +5 -3
- package/dist/compute-engine.esm.js +57 -26
- package/dist/compute-engine.js +57 -26
- package/dist/compute-engine.min.esm.js +23 -23
- package/dist/compute-engine.min.js +22 -22
- 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/buffer.d.ts +1 -1
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/one-of.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/common/styled-text.d.ts +1 -1
- package/dist/types/common/suggest.d.ts +1 -1
- package/dist/types/common/syntax-highlighter.d.ts +1 -1
- package/dist/types/common/terminal.d.ts +1 -1
- package/dist/types/common/type/parse.d.ts +1 -1
- package/dist/types/common/type/primitive.d.ts +1 -1
- package/dist/types/common/type/serialize.d.ts +1 -1
- package/dist/types/common/type/subtype.d.ts +1 -1
- package/dist/types/common/type/types.d.ts +1 -1
- package/dist/types/common/type/utils.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/apply.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-divide.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-multiply.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/box.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/boxed-tensor.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/product.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/public.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/tensor-fields.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/terms.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/trigonometry.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 +1 -1
- package/dist/types/compute-engine/cost-function.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 +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-relational-operators.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/parse-identifier.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/public.d.ts +1 -1
- 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.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/invisible-operator.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/numeric-value/big-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/public.d.ts +1 -1
- package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/bignum.d.ts +1 -1
- package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
- package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
- package/dist/types/compute-engine/numerics/monte-carlo.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 +1 -1
- 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/numerics/special-functions.d.ts +1 -1
- package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
- package/dist/types/compute-engine/public.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
- package/dist/types/compute-engine.d.ts +2 -2
- package/dist/types/math-json/identifiers.d.ts +1 -1
- package/dist/types/math-json/types.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 +1 -1
package/README.md
CHANGED
|
@@ -27,13 +27,15 @@ import { ComputeEngine } from "@cortex-js/compute-engine";
|
|
|
27
27
|
|
|
28
28
|
const ce = new ComputeEngine();
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
ce.parse("2^{11}-1 \\in \\Z").evaluate().print()
|
|
31
31
|
// ➔ "True"
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
##
|
|
34
|
+
## FAQ
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
**Q** How do I build the project?
|
|
37
|
+
|
|
38
|
+
[Build](BUILD.md) instructions
|
|
37
39
|
|
|
38
40
|
## Related Projects
|
|
39
41
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Compute Engine 0.26.
|
|
1
|
+
/** Compute Engine 0.26.3 */
|
|
2
2
|
|
|
3
3
|
// src/compute-engine/boxed-expression/public.ts
|
|
4
4
|
function isRuleStep(x) {
|
|
@@ -9596,7 +9596,10 @@ function canonicalMultiply(ce, ops) {
|
|
|
9596
9596
|
if (next.operator === "Sqrt" && next.op1.isNumberLiteral && isSubtype(next.op1.type, "finite_integer")) {
|
|
9597
9597
|
let radical = next.op1.numericValue;
|
|
9598
9598
|
if (typeof radical !== "number") radical = radical.re;
|
|
9599
|
-
if (radical >= SMALL_INTEGER)
|
|
9599
|
+
if (radical >= SMALL_INTEGER) {
|
|
9600
|
+
ys.push(x);
|
|
9601
|
+
continue;
|
|
9602
|
+
}
|
|
9600
9603
|
if (isSubtype(x.type, "finite_rational")) {
|
|
9601
9604
|
const rational = x.numericValue;
|
|
9602
9605
|
const [num, den] = typeof rational === "number" ? [rational, 1] : [rational.numerator.re, rational.denominator.re];
|
|
@@ -9689,6 +9692,7 @@ function mulN(...xs) {
|
|
|
9689
9692
|
function canonicalDivide(op1, op2) {
|
|
9690
9693
|
const ce = op1.engine;
|
|
9691
9694
|
if (!op1.isValid || !op2.isValid) return ce._fn("Divide", [op1, op2]);
|
|
9695
|
+
if (op1.isNaN || op2.isNaN) return ce.NaN;
|
|
9692
9696
|
if (op2.is(0)) return op1.is(0) ? ce.NaN : ce.ComplexInfinity;
|
|
9693
9697
|
if (op1.is(0)) return ce.Zero;
|
|
9694
9698
|
if (op2.is(0) === false) {
|
|
@@ -9888,9 +9892,11 @@ var Product = class _Product {
|
|
|
9888
9892
|
return;
|
|
9889
9893
|
}
|
|
9890
9894
|
if (term.isInfinity) {
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
|
|
9895
|
+
if (isOne(exp2)) {
|
|
9896
|
+
this.coefficient = this.engine._numericValue(
|
|
9897
|
+
term.isNegative ? -Infinity : Infinity
|
|
9898
|
+
);
|
|
9899
|
+
} else this.terms.push({ term, exponent: exp2 });
|
|
9894
9900
|
return;
|
|
9895
9901
|
}
|
|
9896
9902
|
if (isOne(exp2)) {
|
|
@@ -10045,8 +10051,15 @@ var Product = class _Product {
|
|
|
10045
10051
|
const ce = this.engine;
|
|
10046
10052
|
const coef = this.coefficient;
|
|
10047
10053
|
if (coef.isZero) return [ce.Zero, ce.One];
|
|
10048
|
-
if (coef.isPositiveInfinity || coef.isNegativeInfinity)
|
|
10054
|
+
if (coef.isPositiveInfinity || coef.isNegativeInfinity) {
|
|
10055
|
+
if (this.terms.length === 0) {
|
|
10056
|
+
return [
|
|
10057
|
+
coef.isPositiveInfinity ? ce.PositiveInfinity : ce.NegativeInfinity,
|
|
10058
|
+
ce.One
|
|
10059
|
+
];
|
|
10060
|
+
}
|
|
10049
10061
|
return [ce.NaN, ce.NaN];
|
|
10062
|
+
}
|
|
10050
10063
|
const isNegativeOne2 = coef.isNegativeOne;
|
|
10051
10064
|
if (isNegativeOne2) this.coefficient = ce._numericValue(1);
|
|
10052
10065
|
const xs = this.groupedByDegrees({ mode: "rational" });
|
|
@@ -10613,13 +10626,23 @@ function evalTrig(name, op) {
|
|
|
10613
10626
|
(x) => x.sinh(),
|
|
10614
10627
|
(x) => x.sinh()
|
|
10615
10628
|
);
|
|
10616
|
-
case "Tan":
|
|
10617
|
-
|
|
10629
|
+
case "Tan": {
|
|
10630
|
+
const result = applyAngle(
|
|
10618
10631
|
op,
|
|
10619
|
-
|
|
10620
|
-
|
|
10632
|
+
(x) => {
|
|
10633
|
+
const y = Math.tan(x);
|
|
10634
|
+
if (y > 1e6 || y < -1e6) return ce.ComplexInfinity;
|
|
10635
|
+
return y;
|
|
10636
|
+
},
|
|
10637
|
+
(x) => {
|
|
10638
|
+
const y = x.tan();
|
|
10639
|
+
if (y.greaterThan(1e6) || y.lessThan(-1e6)) return ce.ComplexInfinity;
|
|
10640
|
+
return y;
|
|
10641
|
+
},
|
|
10621
10642
|
(x) => x.tan()
|
|
10622
10643
|
);
|
|
10644
|
+
return result;
|
|
10645
|
+
}
|
|
10623
10646
|
case "Tanh":
|
|
10624
10647
|
return applyAngle(
|
|
10625
10648
|
op,
|
|
@@ -10853,9 +10876,11 @@ function canonicalRoot(a, b) {
|
|
|
10853
10876
|
if (exp2 === 1) return a;
|
|
10854
10877
|
if (exp2 === 2) {
|
|
10855
10878
|
if (a.isNumberLiteral && isSubtype(a.type, "rational")) {
|
|
10856
|
-
|
|
10857
|
-
|
|
10858
|
-
|
|
10879
|
+
if (a.re < SMALL_INTEGER) {
|
|
10880
|
+
const v = a.sqrt();
|
|
10881
|
+
if (typeof v.numericValue === "number") return v;
|
|
10882
|
+
if (v.numericValue.isExact) return v;
|
|
10883
|
+
}
|
|
10859
10884
|
}
|
|
10860
10885
|
return ce._fn("Sqrt", [a]);
|
|
10861
10886
|
}
|
|
@@ -11623,10 +11648,9 @@ function makeLambda(expr) {
|
|
|
11623
11648
|
ce.resetContext();
|
|
11624
11649
|
let i = 0;
|
|
11625
11650
|
for (const param of params) ce.assign(param, args[i++]);
|
|
11626
|
-
const result = fn.
|
|
11651
|
+
const result = fn.evaluate();
|
|
11627
11652
|
ce.swapScope(context);
|
|
11628
|
-
|
|
11629
|
-
return result;
|
|
11653
|
+
return result.isValid ? result : void 0;
|
|
11630
11654
|
};
|
|
11631
11655
|
}
|
|
11632
11656
|
function apply3(fn, args) {
|
|
@@ -13423,7 +13447,7 @@ var ARITHMETIC_LIBRARY = [
|
|
|
13423
13447
|
const [base, exp2] = args;
|
|
13424
13448
|
return canonicalRoot(base, exp2);
|
|
13425
13449
|
},
|
|
13426
|
-
evaluate: ([x, n], { numericApproximation }) =>
|
|
13450
|
+
evaluate: ([x, n], { numericApproximation }) => root(x, n, { numericApproximation })
|
|
13427
13451
|
},
|
|
13428
13452
|
Round: {
|
|
13429
13453
|
complexity: 1250,
|
|
@@ -21743,8 +21767,15 @@ var DERIVATIVES_TABLE = {
|
|
|
21743
21767
|
Log: ["Power", ["Multiply", "_", ["Ln", "10"]], -1],
|
|
21744
21768
|
Sqrt: ["Multiply", ["Power", "_", ["Negate", "Half"]], "Half"],
|
|
21745
21769
|
Abs: [
|
|
21746
|
-
"
|
|
21747
|
-
["
|
|
21770
|
+
"Which",
|
|
21771
|
+
["Equal", "_", 0],
|
|
21772
|
+
NaN,
|
|
21773
|
+
["Less", "_", 0],
|
|
21774
|
+
-1,
|
|
21775
|
+
["Greater", "_", 0],
|
|
21776
|
+
1,
|
|
21777
|
+
"True",
|
|
21778
|
+
["D", ["Abs", "_"], "_"]
|
|
21748
21779
|
],
|
|
21749
21780
|
// https://proofwiki.org/wiki/Derivative_of_Error_Function
|
|
21750
21781
|
Erf: [
|
|
@@ -24601,9 +24632,9 @@ var TRIGONOMETRY_LIBRARY = [
|
|
|
24601
24632
|
}
|
|
24602
24633
|
return ce.number(fArg).div(180).mul(ce.Pi);
|
|
24603
24634
|
},
|
|
24604
|
-
evaluate: (ops,
|
|
24605
|
-
if (
|
|
24606
|
-
return ops[0].mul(
|
|
24635
|
+
evaluate: (ops, options) => {
|
|
24636
|
+
if (options.engine.angularUnit === "deg") return ops[0];
|
|
24637
|
+
return ops[0].mul(options.engine.Pi.div(180)).evaluate(options);
|
|
24607
24638
|
}
|
|
24608
24639
|
},
|
|
24609
24640
|
// Hypot: sqrt(x*x + y*y)
|
|
@@ -25417,7 +25448,7 @@ var BoxedNumber = class extends _BoxedExpression {
|
|
|
25417
25448
|
if (typeof this._value === "number") {
|
|
25418
25449
|
if (this._value === 0 || this._value === 1) return this;
|
|
25419
25450
|
if (this._value === -1) return this.engine.I;
|
|
25420
|
-
if (this._value > 0 && Number.isInteger(this._value))
|
|
25451
|
+
if (this._value > 0 && Number.isInteger(this._value) && this._value < SMALL_INTEGER)
|
|
25421
25452
|
return this.engine.number(
|
|
25422
25453
|
this.engine._numericValue({ radical: this._value })
|
|
25423
25454
|
);
|
|
@@ -32963,7 +32994,7 @@ var ComputeEngine = class _ComputeEngine {
|
|
|
32963
32994
|
}
|
|
32964
32995
|
if ("radical" in value || "rational" in value) {
|
|
32965
32996
|
if (value.radical !== void 0 && (!Number.isInteger(value.radical) || value.radical >= SMALL_INTEGER)) {
|
|
32966
|
-
|
|
32997
|
+
throw Error("Unexpected value for radical part:" + value.radical);
|
|
32967
32998
|
}
|
|
32968
32999
|
if (value.rational) {
|
|
32969
33000
|
if (isMachineRational(value.rational)) {
|
|
@@ -34363,10 +34394,10 @@ function mark(line, mark2) {
|
|
|
34363
34394
|
}
|
|
34364
34395
|
|
|
34365
34396
|
// src/compute-engine.ts
|
|
34366
|
-
var version = "0.26.
|
|
34397
|
+
var version = "0.26.3";
|
|
34367
34398
|
globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
|
|
34368
34399
|
ComputeEngine: ComputeEngine.prototype.constructor,
|
|
34369
|
-
version: "0.26.
|
|
34400
|
+
version: "0.26.3"
|
|
34370
34401
|
};
|
|
34371
34402
|
export {
|
|
34372
34403
|
ComputeEngine,
|
package/dist/compute-engine.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Compute Engine 0.26.
|
|
1
|
+
/** Compute Engine 0.26.3 */
|
|
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 __defProp = Object.defineProperty;
|
|
@@ -9627,7 +9627,10 @@ Invalid type
|
|
|
9627
9627
|
if (next.operator === "Sqrt" && next.op1.isNumberLiteral && isSubtype(next.op1.type, "finite_integer")) {
|
|
9628
9628
|
let radical = next.op1.numericValue;
|
|
9629
9629
|
if (typeof radical !== "number") radical = radical.re;
|
|
9630
|
-
if (radical >= SMALL_INTEGER)
|
|
9630
|
+
if (radical >= SMALL_INTEGER) {
|
|
9631
|
+
ys.push(x);
|
|
9632
|
+
continue;
|
|
9633
|
+
}
|
|
9631
9634
|
if (isSubtype(x.type, "finite_rational")) {
|
|
9632
9635
|
const rational = x.numericValue;
|
|
9633
9636
|
const [num, den] = typeof rational === "number" ? [rational, 1] : [rational.numerator.re, rational.denominator.re];
|
|
@@ -9720,6 +9723,7 @@ Invalid type
|
|
|
9720
9723
|
function canonicalDivide(op1, op2) {
|
|
9721
9724
|
const ce = op1.engine;
|
|
9722
9725
|
if (!op1.isValid || !op2.isValid) return ce._fn("Divide", [op1, op2]);
|
|
9726
|
+
if (op1.isNaN || op2.isNaN) return ce.NaN;
|
|
9723
9727
|
if (op2.is(0)) return op1.is(0) ? ce.NaN : ce.ComplexInfinity;
|
|
9724
9728
|
if (op1.is(0)) return ce.Zero;
|
|
9725
9729
|
if (op2.is(0) === false) {
|
|
@@ -9919,9 +9923,11 @@ Invalid type
|
|
|
9919
9923
|
return;
|
|
9920
9924
|
}
|
|
9921
9925
|
if (term.isInfinity) {
|
|
9922
|
-
|
|
9923
|
-
|
|
9924
|
-
|
|
9926
|
+
if (isOne(exp2)) {
|
|
9927
|
+
this.coefficient = this.engine._numericValue(
|
|
9928
|
+
term.isNegative ? -Infinity : Infinity
|
|
9929
|
+
);
|
|
9930
|
+
} else this.terms.push({ term, exponent: exp2 });
|
|
9925
9931
|
return;
|
|
9926
9932
|
}
|
|
9927
9933
|
if (isOne(exp2)) {
|
|
@@ -10076,8 +10082,15 @@ Invalid type
|
|
|
10076
10082
|
const ce = this.engine;
|
|
10077
10083
|
const coef = this.coefficient;
|
|
10078
10084
|
if (coef.isZero) return [ce.Zero, ce.One];
|
|
10079
|
-
if (coef.isPositiveInfinity || coef.isNegativeInfinity)
|
|
10085
|
+
if (coef.isPositiveInfinity || coef.isNegativeInfinity) {
|
|
10086
|
+
if (this.terms.length === 0) {
|
|
10087
|
+
return [
|
|
10088
|
+
coef.isPositiveInfinity ? ce.PositiveInfinity : ce.NegativeInfinity,
|
|
10089
|
+
ce.One
|
|
10090
|
+
];
|
|
10091
|
+
}
|
|
10080
10092
|
return [ce.NaN, ce.NaN];
|
|
10093
|
+
}
|
|
10081
10094
|
const isNegativeOne2 = coef.isNegativeOne;
|
|
10082
10095
|
if (isNegativeOne2) this.coefficient = ce._numericValue(1);
|
|
10083
10096
|
const xs = this.groupedByDegrees({ mode: "rational" });
|
|
@@ -10644,13 +10657,23 @@ Invalid type
|
|
|
10644
10657
|
(x) => x.sinh(),
|
|
10645
10658
|
(x) => x.sinh()
|
|
10646
10659
|
);
|
|
10647
|
-
case "Tan":
|
|
10648
|
-
|
|
10660
|
+
case "Tan": {
|
|
10661
|
+
const result = applyAngle(
|
|
10649
10662
|
op,
|
|
10650
|
-
|
|
10651
|
-
|
|
10663
|
+
(x) => {
|
|
10664
|
+
const y = Math.tan(x);
|
|
10665
|
+
if (y > 1e6 || y < -1e6) return ce.ComplexInfinity;
|
|
10666
|
+
return y;
|
|
10667
|
+
},
|
|
10668
|
+
(x) => {
|
|
10669
|
+
const y = x.tan();
|
|
10670
|
+
if (y.greaterThan(1e6) || y.lessThan(-1e6)) return ce.ComplexInfinity;
|
|
10671
|
+
return y;
|
|
10672
|
+
},
|
|
10652
10673
|
(x) => x.tan()
|
|
10653
10674
|
);
|
|
10675
|
+
return result;
|
|
10676
|
+
}
|
|
10654
10677
|
case "Tanh":
|
|
10655
10678
|
return applyAngle(
|
|
10656
10679
|
op,
|
|
@@ -10884,9 +10907,11 @@ Invalid type
|
|
|
10884
10907
|
if (exp2 === 1) return a;
|
|
10885
10908
|
if (exp2 === 2) {
|
|
10886
10909
|
if (a.isNumberLiteral && isSubtype(a.type, "rational")) {
|
|
10887
|
-
|
|
10888
|
-
|
|
10889
|
-
|
|
10910
|
+
if (a.re < SMALL_INTEGER) {
|
|
10911
|
+
const v = a.sqrt();
|
|
10912
|
+
if (typeof v.numericValue === "number") return v;
|
|
10913
|
+
if (v.numericValue.isExact) return v;
|
|
10914
|
+
}
|
|
10890
10915
|
}
|
|
10891
10916
|
return ce._fn("Sqrt", [a]);
|
|
10892
10917
|
}
|
|
@@ -11654,10 +11679,9 @@ Invalid type
|
|
|
11654
11679
|
ce.resetContext();
|
|
11655
11680
|
let i = 0;
|
|
11656
11681
|
for (const param of params) ce.assign(param, args[i++]);
|
|
11657
|
-
const result = fn.
|
|
11682
|
+
const result = fn.evaluate();
|
|
11658
11683
|
ce.swapScope(context);
|
|
11659
|
-
|
|
11660
|
-
return result;
|
|
11684
|
+
return result.isValid ? result : void 0;
|
|
11661
11685
|
};
|
|
11662
11686
|
}
|
|
11663
11687
|
function apply3(fn, args) {
|
|
@@ -13454,7 +13478,7 @@ Invalid type
|
|
|
13454
13478
|
const [base, exp2] = args;
|
|
13455
13479
|
return canonicalRoot(base, exp2);
|
|
13456
13480
|
},
|
|
13457
|
-
evaluate: ([x, n], { numericApproximation }) =>
|
|
13481
|
+
evaluate: ([x, n], { numericApproximation }) => root(x, n, { numericApproximation })
|
|
13458
13482
|
},
|
|
13459
13483
|
Round: {
|
|
13460
13484
|
complexity: 1250,
|
|
@@ -21774,8 +21798,15 @@ ${e.message}`);
|
|
|
21774
21798
|
Log: ["Power", ["Multiply", "_", ["Ln", "10"]], -1],
|
|
21775
21799
|
Sqrt: ["Multiply", ["Power", "_", ["Negate", "Half"]], "Half"],
|
|
21776
21800
|
Abs: [
|
|
21777
|
-
"
|
|
21778
|
-
["
|
|
21801
|
+
"Which",
|
|
21802
|
+
["Equal", "_", 0],
|
|
21803
|
+
NaN,
|
|
21804
|
+
["Less", "_", 0],
|
|
21805
|
+
-1,
|
|
21806
|
+
["Greater", "_", 0],
|
|
21807
|
+
1,
|
|
21808
|
+
"True",
|
|
21809
|
+
["D", ["Abs", "_"], "_"]
|
|
21779
21810
|
],
|
|
21780
21811
|
// https://proofwiki.org/wiki/Derivative_of_Error_Function
|
|
21781
21812
|
Erf: [
|
|
@@ -24632,9 +24663,9 @@ ${e.message}`);
|
|
|
24632
24663
|
}
|
|
24633
24664
|
return ce.number(fArg).div(180).mul(ce.Pi);
|
|
24634
24665
|
},
|
|
24635
|
-
evaluate: (ops,
|
|
24636
|
-
if (
|
|
24637
|
-
return ops[0].mul(
|
|
24666
|
+
evaluate: (ops, options) => {
|
|
24667
|
+
if (options.engine.angularUnit === "deg") return ops[0];
|
|
24668
|
+
return ops[0].mul(options.engine.Pi.div(180)).evaluate(options);
|
|
24638
24669
|
}
|
|
24639
24670
|
},
|
|
24640
24671
|
// Hypot: sqrt(x*x + y*y)
|
|
@@ -25448,7 +25479,7 @@ Error in definition of "${name}"`,
|
|
|
25448
25479
|
if (typeof this._value === "number") {
|
|
25449
25480
|
if (this._value === 0 || this._value === 1) return this;
|
|
25450
25481
|
if (this._value === -1) return this.engine.I;
|
|
25451
|
-
if (this._value > 0 && Number.isInteger(this._value))
|
|
25482
|
+
if (this._value > 0 && Number.isInteger(this._value) && this._value < SMALL_INTEGER)
|
|
25452
25483
|
return this.engine.number(
|
|
25453
25484
|
this.engine._numericValue({ radical: this._value })
|
|
25454
25485
|
);
|
|
@@ -32994,7 +33025,7 @@ Error in definition of "${name}"`,
|
|
|
32994
33025
|
}
|
|
32995
33026
|
if ("radical" in value || "rational" in value) {
|
|
32996
33027
|
if (value.radical !== void 0 && (!Number.isInteger(value.radical) || value.radical >= SMALL_INTEGER)) {
|
|
32997
|
-
|
|
33028
|
+
throw Error("Unexpected value for radical part:" + value.radical);
|
|
32998
33029
|
}
|
|
32999
33030
|
if (value.rational) {
|
|
33000
33031
|
if (isMachineRational(value.rational)) {
|
|
@@ -34394,10 +34425,10 @@ ${lineNo.toString().padStart(maxDigits, " ")}`;
|
|
|
34394
34425
|
}
|
|
34395
34426
|
|
|
34396
34427
|
// src/compute-engine.ts
|
|
34397
|
-
var version = "0.26.
|
|
34428
|
+
var version = "0.26.3";
|
|
34398
34429
|
globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
|
|
34399
34430
|
ComputeEngine: ComputeEngine.prototype.constructor,
|
|
34400
|
-
version: "0.26.
|
|
34431
|
+
version: "0.26.3"
|
|
34401
34432
|
};
|
|
34402
34433
|
return __toCommonJS(compute_engine_exports);
|
|
34403
34434
|
})();
|