@doenet/doenetml-iframe 0.7.7 → 0.7.8-dev.20260226230802.7acd737
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/index.js +165 -59
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -16153,6 +16153,8 @@ function normalize_function_names$1(e3) {
|
|
|
16153
16153
|
var r = t[0], n = t.slice(1);
|
|
16154
16154
|
if ("apply" === r) {
|
|
16155
16155
|
if ("sqrt" === n[0]) return ["^", normalize_function_names$1(n[1]), 0.5];
|
|
16156
|
+
if ("cbrt" === n[0]) return ["^", normalize_function_names$1(n[1]), ["/", 1, 3]];
|
|
16157
|
+
if ("nthroot" === n[0]) return 2 !== n.length || "tuple" !== n[1][0] || 3 !== n[1].length ? ["^", normalize_function_names$1(n[1]), 0.5] : ["^", normalize_function_names$1(n[1][1]), ["/", 1, normalize_function_names$1(n[1][2])]];
|
|
16156
16158
|
var i = normalize_function_names_sub$1(n[0]);
|
|
16157
16159
|
i = ["apply", i];
|
|
16158
16160
|
var a = n.slice(1).map((function(e4) {
|
|
@@ -16235,20 +16237,30 @@ function normalize_angle_linesegment_arg_order$1(e3) {
|
|
|
16235
16237
|
}
|
|
16236
16238
|
function normalize_negative_numbers$1(e3) {
|
|
16237
16239
|
var t = get_tree$1(e3);
|
|
16240
|
+
function r(e4) {
|
|
16241
|
+
if ("number" == typeof e4 && e4 >= 0) return [-e4, true];
|
|
16242
|
+
if (!Array.isArray(e4)) return [e4, false];
|
|
16243
|
+
if ("*" === e4[0] && "number" == typeof e4[1] && e4[1] >= 0) return [["*", -e4[1], ...e4.slice(2).map(normalize_negative_numbers$1)], true];
|
|
16244
|
+
if ("/" === e4[0] && 3 === e4.length) {
|
|
16245
|
+
let [t2, n3] = r(e4[1]);
|
|
16246
|
+
if (n3) return [["/", t2, normalize_negative_numbers$1(e4[2])], true];
|
|
16247
|
+
}
|
|
16248
|
+
return [e4, false];
|
|
16249
|
+
}
|
|
16238
16250
|
if (!Array.isArray(t)) return t;
|
|
16239
|
-
let
|
|
16240
|
-
if ("-" ===
|
|
16241
|
-
if ("number" == typeof
|
|
16242
|
-
if (Array.isArray(
|
|
16243
|
-
|
|
16244
|
-
if (
|
|
16251
|
+
let n = t[0], i = t.slice(1);
|
|
16252
|
+
if ("-" === n && 1 === i.length) {
|
|
16253
|
+
if ("number" == typeof i[0] && i[0] >= 0) return -i[0];
|
|
16254
|
+
if (Array.isArray(i[0]) && "*" === i[0][0]) {
|
|
16255
|
+
let [e4, t2] = r(i[0][1]);
|
|
16256
|
+
if (t2) return ["*", e4, ...i[0].slice(2).map(normalize_negative_numbers$1)];
|
|
16245
16257
|
}
|
|
16246
|
-
if (Array.isArray(
|
|
16247
|
-
|
|
16248
|
-
if (
|
|
16258
|
+
if (Array.isArray(i[0]) && "/" === i[0][0] && 3 === i[0].length) {
|
|
16259
|
+
let [e4, t2] = r(i[0][1]);
|
|
16260
|
+
if (t2) return ["/", e4, normalize_negative_numbers$1(i[0][2])];
|
|
16249
16261
|
}
|
|
16250
16262
|
}
|
|
16251
|
-
return [
|
|
16263
|
+
return [n, ...i.map(normalize_negative_numbers$1)];
|
|
16252
16264
|
}
|
|
16253
16265
|
function tuples_to_vectors$1(e3) {
|
|
16254
16266
|
var t = get_tree$1(e3);
|
|
@@ -16874,8 +16886,11 @@ function sort_key$1(e3, t = {}) {
|
|
|
16874
16886
|
if ("boolean" == typeof e3) return [1, "boolean", e3];
|
|
16875
16887
|
if (!Array.isArray(e3)) return [-1, "unknown", e3];
|
|
16876
16888
|
var r = e3[0], n = e3.slice(1);
|
|
16889
|
+
if ("^" === r && 2 === n.length) return [...sort_key$1(n[0], t), "power", ...sort_key$1(n[1], t)];
|
|
16877
16890
|
if ("apply" === r) {
|
|
16878
|
-
var i = [2, "function", n[0]]
|
|
16891
|
+
var i = [2, "function", n[0]];
|
|
16892
|
+
"sqrt" !== n[0] && "cbrt" !== n[0] && "nthroot" !== n[0] || (i = [5, "root", "sqrt" === n[0] ? 2 : "cbrt" === n[0] ? 3 : n[1][2] ?? 2]);
|
|
16893
|
+
var a = n[1], o = 1, s = [];
|
|
16879
16894
|
return Array.isArray(a) ? (o = (a = a.slice(1)).length, s = a.map(((e4) => sort_key$1(e4, t)))) : s = [sort_key$1(a, t)], i.push([o, s]), i;
|
|
16880
16895
|
}
|
|
16881
16896
|
if ("unit" === r) {
|
|
@@ -18031,9 +18046,10 @@ const substitute$1$1 = function(e3, t) {
|
|
|
18031
18046
|
let t2 = match$2$1(e5, r2, a);
|
|
18032
18047
|
if (t2) {
|
|
18033
18048
|
let e6 = substitute$1$1(n3, t2);
|
|
18034
|
-
a.
|
|
18035
|
-
|
|
18036
|
-
|
|
18049
|
+
const i2 = a.assumptions ? substitute$1$1(a.assumptions, t2) : void 0;
|
|
18050
|
+
a.evaluate_numbers && (e6 = evaluate_numbers$1(e6, { max_digits: a.max_digits, evaluate_functions: a.evaluate_functions, assumptions: i2 }));
|
|
18051
|
+
let o = [], s = [];
|
|
18052
|
+
return t2._skipped && (o = t2._skipped), t2._skipped_before && (s = t2._skipped_before), (s.length > 0 || o.length > 0) && (Array.isArray(e6) && (e6 = e6[0] === r2[0] ? e6.slice(1) : [e6]), e6 = [r2[0]].concat(s, e6, o)), a.evaluate_numbers && (e6 = evaluate_numbers$1(e6, { max_digits: a.max_digits, evaluate_functions: a.evaluate_functions, assumptions: i2 })), e6;
|
|
18037
18053
|
}
|
|
18038
18054
|
return e5;
|
|
18039
18055
|
}));
|
|
@@ -18076,7 +18092,7 @@ const operators$2$1 = { "+": function(e3) {
|
|
|
18076
18092
|
}, binom: function(e3) {
|
|
18077
18093
|
const t = new math$2.SymbolNode("combinations");
|
|
18078
18094
|
return new math$2.FunctionNode(t, e3);
|
|
18079
|
-
} },
|
|
18095
|
+
} }, functionConversions$1 = { nCr: "combinations", nPr: "permutations", binom: "combinations" };
|
|
18080
18096
|
let astToMathjs$1$1 = class astToMathjs$12 {
|
|
18081
18097
|
constructor({ mathjs: e3 = null } = {}) {
|
|
18082
18098
|
e3 && (math$2 = e3);
|
|
@@ -18090,7 +18106,7 @@ let astToMathjs$1$1 = class astToMathjs$12 {
|
|
|
18090
18106
|
if ("apply" === t) {
|
|
18091
18107
|
if ("string" != typeof r[0]) throw Error("Non string functions not implemented for conversion to mathjs");
|
|
18092
18108
|
if ("factorial" === r[0]) return new math$2.OperatorNode("!", "factorial", [this.convert(r[1])]);
|
|
18093
|
-
let e4 =
|
|
18109
|
+
let e4 = functionConversions$1[r[0]];
|
|
18094
18110
|
e4 || (e4 = r[0]);
|
|
18095
18111
|
const t2 = new math$2.SymbolNode(e4), n = r[1];
|
|
18096
18112
|
let i;
|
|
@@ -19048,7 +19064,7 @@ function is_nonzero_ast$1(e3, t, r) {
|
|
|
19048
19064
|
}
|
|
19049
19065
|
return (!is_positive_ast$1(a[1], n3, true, r) || false !== e4) && void 0;
|
|
19050
19066
|
}
|
|
19051
|
-
if ("apply" === i) return !!(functions$3.C.nonzero && functions$3.C.nonzero.includes(a[0]) && is_complex_ast$1(a[1], n3, r)) || (!!(functions$3.R.nonzero && functions$3.R.nonzero.includes(a[0]) && is_real_ast$1(a[1], n3, r)) || (!!(functions$3.nonzeroC.nonzero && functions$3.nonzeroC.nonzero.includes(a[0]) && is_nonzero_ast$1(a[1], n3, r)
|
|
19067
|
+
if ("apply" === i) return !!(functions$3.C.nonzero && functions$3.C.nonzero.includes(a[0]) && is_complex_ast$1(a[1], n3, r)) || (!!(functions$3.R.nonzero && functions$3.R.nonzero.includes(a[0]) && is_real_ast$1(a[1], n3, r)) || (!!(functions$3.nonzeroC.nonzero && functions$3.nonzeroC.nonzero.includes(a[0]) && is_nonzero_ast$1(a[1], n3, r)) || (!!(functions$3.nonneg.nonzero && functions$3.nonneg.nonzero.includes(a[0]) && is_positive_ast$1(a[1], n3, false, r)) || (!!(functions$3.pos.nonzero && functions$3.pos.nonzero.includes(a[0]) && is_positive_ast$1(a[1], n3, true, r)) || void 0))));
|
|
19052
19068
|
if ("prime" === i) return;
|
|
19053
19069
|
return false;
|
|
19054
19070
|
}
|
|
@@ -19217,7 +19233,7 @@ function flatten$6(e3) {
|
|
|
19217
19233
|
}
|
|
19218
19234
|
return [t].concat(r);
|
|
19219
19235
|
}
|
|
19220
|
-
const sci_notat_exp_regex$1$1 = "(E[+\\-]?[0-9]+\\s*($|(?=\\,|\\||\\)|\\}|\\])))?", number_rules_sci$1$1 = [["[0-9]+(\\.[0-9]*)?" + sci_notat_exp_regex$1$1, "NUMBER"], ["\\.[0-9]+" + sci_notat_exp_regex$1$1, "NUMBER"]], number_rules_non_sci$1$1 = [["[0-9]+(\\.[0-9]*)?", "NUMBER"], ["\\.[0-9]+", "NUMBER"]], base_text_rules$1 = [["\\*\\*", "^"], ["\\*", "*"], ["\\xB7", "*"], ["·", "*"], ["•", "*"], ["⋅", "*"], ["×", "*"], ["/", "/"], ["-", "-"], ["֊", "-"], ["־", "-"], ["᠆", "-"], ["‐", "-"], ["‑", "-"], ["‒", "-"], ["–", "-"], ["—", "-"], ["―", "-"], ["⁻", "-"], ["₋", "-"], ["−", "-"], ["⸺", "-"], ["⸻", "-"], ["﹘", "-"], ["﹣", "-"], ["-", "-"], ["\\+", "+"], ["\\^", "^"], ["‸", "^"], ["ʌ", "^"], ["′", "'"], ["\\|", "|"], ["\\(", "("], ["\\)", ")"], ["\\[", "["], ["\\]", "]"], ["\\{", "{"], ["\\}", "}"], ["⟨", "LANGLE"], ["⟩", "RANGLE"], ["〈", "LANGLE"], ["〉", "RANGLE"], [",", ","], [":", ":"], ["α", "VARMULTICHAR", "alpha"], ["β", "VARMULTICHAR", "beta"], ["ϐ", "VARMULTICHAR", "beta"], ["Γ", "VARMULTICHAR", "Gamma"], ["γ", "VARMULTICHAR", "gamma"], ["Δ", "VARMULTICHAR", "Delta"], ["δ", "VARMULTICHAR", "delta"], ["ε", "VARMULTICHAR", "epsilon"], ["ϵ", "VARMULTICHAR", "epsilon"], ["ζ", "VARMULTICHAR", "zeta"], ["η", "VARMULTICHAR", "eta"], ["Θ", "VARMULTICHAR", "Theta"], ["ϴ", "VARMULTICHAR", "Theta"], ["θ", "VARMULTICHAR", "theta"], ["ᶿ", "VARMULTICHAR", "theta"], ["ϑ", "VARMULTICHAR", "theta"], ["ι", "VARMULTICHAR", "iota"], ["κ", "VARMULTICHAR", "kappa"], ["Λ", "VARMULTICHAR", "Lambda"], ["λ", "VARMULTICHAR", "lambda"], ["μ", "VARMULTICHAR", "mu"], ["µ", "VARMULTICHAR", "mu"], ["ν", "VARMULTICHAR", "nu"], ["Ξ", "VARMULTICHAR", "Xi"], ["ξ", "VARMULTICHAR", "xi"], ["Π", "VARMULTICHAR", "Pi"], ["π", "VARMULTICHAR", "pi"], ["ϖ", "VARMULTICHAR", "pi"], ["ρ", "VARMULTICHAR", "rho"], ["ϱ", "VARMULTICHAR", "rho"], ["Σ", "VARMULTICHAR", "Sigma"], ["σ", "VARMULTICHAR", "sigma"], ["ς", "VARMULTICHAR", "sigma"], ["τ", "VARMULTICHAR", "tau"], ["Υ", "VARMULTICHAR", "Upsilon"], ["υ", "VARMULTICHAR", "upsilon"], ["Φ", "VARMULTICHAR", "Phi"], ["φ", "VARMULTICHAR", "phi"], ["ϕ", "VARMULTICHAR", "phi"], ["Ψ", "VARMULTICHAR", "Psi"], ["ψ", "VARMULTICHAR", "psi"], ["Ω", "VARMULTICHAR", "Omega"], ["ω", "VARMULTICHAR", "omega"], ["∅", "VARMULTICHAR", "emptyset"], ["oo(?![a-zA-Z0-9])", "INFINITY"], ["OO(?![a-zA-Z0-9])", "INFINITY"], ["infty(?![a-zA-Z0-9])", "INFINITY"], ["infinity(?![a-zA-Z0-9])", "INFINITY"], ["Infinity(?![a-zA-Z0-9])", "INFINITY"], ["∞", "INFINITY"], ["ℯ", "VAR", "e"], ["♠", "VARMULTICHAR", "spade"], ["♡", "VARMULTICHAR", "heart"], ["♢", "VARMULTICHAR", "diamond"], ["♣", "VARMULTICHAR", "club"], ["★", "VARMULTICHAR", "bigstar"], ["◯", "VARMULTICHAR", "bigcirc"], ["◊", "VARMULTICHAR", "lozenge"], ["△", "VARMULTICHAR", "bigtriangleup"], ["▽", "VARMULTICHAR", "bigtriangledown"], ["⧫", "VARMULTICHAR", "blacklozenge"], ["■", "VARMULTICHAR", "blacksquare"], ["▲", "VARMULTICHAR", "blacktriangle"], ["▼", "VARMULTICHAR", "blacktriangledown"], ["◀", "VARMULTICHAR", "blacktriangleleft"], ["▶", "VARMULTICHAR", "blacktriangleright"], ["□", "VARMULTICHAR", "Box"], ["∘", "VARMULTICHAR", "circ"], ["⋆", "VARMULTICHAR", "star"], ["and(?![a-zA-Z0-9])", "AND"], ["\\&\\&?", "AND"], ["∧", "AND"], ["or(?![a-zA-Z0-9])", "OR"], ["∨", "OR"], ["not(?![a-zA-Z0-9])", "NOT"], ["¬", "NOT"], ["=", "="], ["᐀", "="], ["゠", "="], ["!=", "NE"], ["≠", "NE"], ["<=", "LE"], ["≤", "LE"], [">=", "GE"], ["≥", "GE"], ["<", "<"], [">", ">"], ["forall(?![a-zA-Z0-9])", "FORALL"], ["∀", "FORALL"], ["exists(?![a-zA-Z0-9])", "EXISTS"], ["∃", "EXISTS"], ["elementof(?![a-zA-Z0-9])", "IN"], ["∈", "IN"], ["notelementof(?![a-zA-Z0-9])", "NOTIN"], ["∉", "NOTIN"], ["containselement(?![a-zA-Z0-9])", "NI"], ["∋", "NI"], ["notcontainselement(?![a-zA-Z0-9])", "NOTNI"], ["∌", "NOTNI"], ["subset(?![a-zA-Z0-9])", "SUBSET"], ["⊂", "SUBSET"], ["subseteq(?![a-zA-Z0-9])", "SUBSETEQ"], ["⊆", "SUBSETEQ"], ["notsubset(?![a-zA-Z0-9])", "NOTSUBSET"], ["⊄", "NOTSUBSET"], ["notsubseteq(?![a-zA-Z0-9])", "NOTSUBSETEQ"], ["⊈", "NOTSUBSETEQ"], ["superset(?![a-zA-Z0-9])", "SUPERSET"], ["⊃", "SUPERSET"], ["superseteq(?![a-zA-Z0-9])", "SUPERSETEQ"], ["⊇", "SUPERSETEQ"], ["notsuperset(?![a-zA-Z0-9])", "NOTSUPERSET"], ["⊅", "NOTSUPERSET"], ["notsuperseteq(?![a-zA-Z0-9])", "NOTSUPERSETEQ"], ["⊉", "NOTSUPERSETEQ"], ["union(?![a-zA-Z0-9])", "UNION"], ["∪", "UNION"], ["intersect(?![a-zA-Z0-9])", "INTERSECT"], ["∩", "INTERSECT"], ["rightarrow(?![a-zA-Z0-9])", "RIGHTARROW"], ["→", "RIGHTARROW"], ["⟶", "RIGHTARROW"], ["leftarrow(?![a-zA-Z0-9])", "LEFTARROW"], ["←", "LEFTARROW"], ["⟵", "LEFTARROW"], ["leftrightarrow(?![a-zA-Z0-9])", "LEFTRIGHTARROW"], ["↔", "LEFTRIGHTARROW"], ["⟷", "LEFTRIGHTARROW"], ["implies(?![a-zA-Z0-9])", "IMPLIES"], ["⇒", "IMPLIES"], ["⟹", "IMPLIES"], ["impliedby(?![a-zA-Z0-9])", "IMPLIEDBY"], ["⇐", "IMPLIEDBY"], ["⟸", "IMPLIEDBY"], ["iff(?![a-zA-Z0-9])", "IFF"], ["⇔", "IFF"], ["⟺", "IFF"], ["perp(?![a-zA-Z0-9])", "PERP"], ["⟂", "PERP"], ["parallel(?![a-zA-Z0-9])", "PARALLEL"], ["∥", "PARALLEL"], ["angle(?![a-zA-Z0-9])", "ANGLE"], ["∠", "ANGLE"], ["int(?![a-zA-Z0-9])", "INT"], ["∫", "INT"], ["!", "!"], ["'", "'"], ["_", "_"], ["\\.\\.\\.", "LDOTS"], ["[a-zA-Z∂][a-zA-Z∂0-9]*", "VAR"], ["[_$%]", "VAR"]], allowSimplifiedFunctionApplicationDefault$1$1 = true, splitSymbolsDefault$1 = true, unsplitSymbolsDefault$1 = ["alpha", "beta", "gamma", "Gamma", "delta", "Delta", "epsilon", "zeta", "eta", "theta", "Theta", "iota", "kappa", "lambda", "Lambda", "mu", "nu", "xi", "Xi", "pi", "Pi", "rho", "sigma", "Sigma", "tau", "Tau", "upsilon", "Upsilon", "phi", "Phi", "chi", "psi", "Psi", "omega", "Omega", "angle", "deg", "emptyset"], appliedFunctionSymbolsDefault$1$1 = ["abs", "exp", "log", "ln", "log10", "sign", "sqrt", "erf", "cos", "cosh", "acos", "acosh", "arccos", "arccosh", "cot", "coth", "acot", "acoth", "arccot", "arccoth", "csc", "csch", "acsc", "acsch", "arccsc", "arccsch", "sec", "sech", "asec", "asech", "arcsec", "arcsech", "sin", "sinh", "asin", "asinh", "arcsin", "arcsinh", "tan", "tanh", "atan", "atan2", "atanh", "arctan", "arctanh", "arg", "conj", "re", "im", "det", "trace", "nPr", "nCr", "floor", "ceil", "round"], functionSymbolsDefault$1$1 = ["f", "g"], operatorSymbolsDefault$1$1 = ["binom", "vec", "linesegment"], unitsDefault$1$1 = get_all_units$1(), parseLeibnizNotationDefault$1$1 = true;
|
|
19236
|
+
const sci_notat_exp_regex$1$1 = "(E[+\\-]?[0-9]+\\s*($|(?=\\,|\\||\\)|\\}|\\])))?", number_rules_sci$1$1 = [["[0-9]+(\\.[0-9]*)?" + sci_notat_exp_regex$1$1, "NUMBER"], ["\\.[0-9]+" + sci_notat_exp_regex$1$1, "NUMBER"]], number_rules_non_sci$1$1 = [["[0-9]+(\\.[0-9]*)?", "NUMBER"], ["\\.[0-9]+", "NUMBER"]], base_text_rules$1 = [["\\*\\*", "^"], ["\\*", "*"], ["\\xB7", "*"], ["·", "*"], ["•", "*"], ["⋅", "*"], ["×", "*"], ["/", "/"], ["-", "-"], ["֊", "-"], ["־", "-"], ["᠆", "-"], ["‐", "-"], ["‑", "-"], ["‒", "-"], ["–", "-"], ["—", "-"], ["―", "-"], ["⁻", "-"], ["₋", "-"], ["−", "-"], ["⸺", "-"], ["⸻", "-"], ["﹘", "-"], ["﹣", "-"], ["-", "-"], ["\\+", "+"], ["\\^", "^"], ["‸", "^"], ["ʌ", "^"], ["′", "'"], ["\\|", "|"], ["\\(", "("], ["\\)", ")"], ["\\[", "["], ["\\]", "]"], ["\\{", "{"], ["\\}", "}"], ["⟨", "LANGLE"], ["⟩", "RANGLE"], ["〈", "LANGLE"], ["〉", "RANGLE"], [",", ","], [":", ":"], ["α", "VARMULTICHAR", "alpha"], ["β", "VARMULTICHAR", "beta"], ["ϐ", "VARMULTICHAR", "beta"], ["Γ", "VARMULTICHAR", "Gamma"], ["γ", "VARMULTICHAR", "gamma"], ["Δ", "VARMULTICHAR", "Delta"], ["δ", "VARMULTICHAR", "delta"], ["ε", "VARMULTICHAR", "epsilon"], ["ϵ", "VARMULTICHAR", "epsilon"], ["ζ", "VARMULTICHAR", "zeta"], ["η", "VARMULTICHAR", "eta"], ["Θ", "VARMULTICHAR", "Theta"], ["ϴ", "VARMULTICHAR", "Theta"], ["θ", "VARMULTICHAR", "theta"], ["ᶿ", "VARMULTICHAR", "theta"], ["ϑ", "VARMULTICHAR", "theta"], ["ι", "VARMULTICHAR", "iota"], ["κ", "VARMULTICHAR", "kappa"], ["Λ", "VARMULTICHAR", "Lambda"], ["λ", "VARMULTICHAR", "lambda"], ["μ", "VARMULTICHAR", "mu"], ["µ", "VARMULTICHAR", "mu"], ["ν", "VARMULTICHAR", "nu"], ["Ξ", "VARMULTICHAR", "Xi"], ["ξ", "VARMULTICHAR", "xi"], ["Π", "VARMULTICHAR", "Pi"], ["π", "VARMULTICHAR", "pi"], ["ϖ", "VARMULTICHAR", "pi"], ["ρ", "VARMULTICHAR", "rho"], ["ϱ", "VARMULTICHAR", "rho"], ["Σ", "VARMULTICHAR", "Sigma"], ["σ", "VARMULTICHAR", "sigma"], ["ς", "VARMULTICHAR", "sigma"], ["τ", "VARMULTICHAR", "tau"], ["Υ", "VARMULTICHAR", "Upsilon"], ["υ", "VARMULTICHAR", "upsilon"], ["Φ", "VARMULTICHAR", "Phi"], ["φ", "VARMULTICHAR", "phi"], ["ϕ", "VARMULTICHAR", "phi"], ["Ψ", "VARMULTICHAR", "Psi"], ["ψ", "VARMULTICHAR", "psi"], ["Ω", "VARMULTICHAR", "Omega"], ["ω", "VARMULTICHAR", "omega"], ["∅", "VARMULTICHAR", "emptyset"], ["oo(?![a-zA-Z0-9])", "INFINITY"], ["OO(?![a-zA-Z0-9])", "INFINITY"], ["infty(?![a-zA-Z0-9])", "INFINITY"], ["infinity(?![a-zA-Z0-9])", "INFINITY"], ["Infinity(?![a-zA-Z0-9])", "INFINITY"], ["∞", "INFINITY"], ["ℯ", "VAR", "e"], ["♠", "VARMULTICHAR", "spade"], ["♡", "VARMULTICHAR", "heart"], ["♢", "VARMULTICHAR", "diamond"], ["♣", "VARMULTICHAR", "club"], ["★", "VARMULTICHAR", "bigstar"], ["◯", "VARMULTICHAR", "bigcirc"], ["◊", "VARMULTICHAR", "lozenge"], ["△", "VARMULTICHAR", "bigtriangleup"], ["▽", "VARMULTICHAR", "bigtriangledown"], ["⧫", "VARMULTICHAR", "blacklozenge"], ["■", "VARMULTICHAR", "blacksquare"], ["▲", "VARMULTICHAR", "blacktriangle"], ["▼", "VARMULTICHAR", "blacktriangledown"], ["◀", "VARMULTICHAR", "blacktriangleleft"], ["▶", "VARMULTICHAR", "blacktriangleright"], ["□", "VARMULTICHAR", "Box"], ["∘", "VARMULTICHAR", "circ"], ["⋆", "VARMULTICHAR", "star"], ["and(?![a-zA-Z0-9])", "AND"], ["\\&\\&?", "AND"], ["∧", "AND"], ["or(?![a-zA-Z0-9])", "OR"], ["∨", "OR"], ["not(?![a-zA-Z0-9])", "NOT"], ["¬", "NOT"], ["=", "="], ["᐀", "="], ["゠", "="], ["!=", "NE"], ["≠", "NE"], ["<=", "LE"], ["≤", "LE"], [">=", "GE"], ["≥", "GE"], ["<", "<"], [">", ">"], ["forall(?![a-zA-Z0-9])", "FORALL"], ["∀", "FORALL"], ["exists(?![a-zA-Z0-9])", "EXISTS"], ["∃", "EXISTS"], ["elementof(?![a-zA-Z0-9])", "IN"], ["∈", "IN"], ["notelementof(?![a-zA-Z0-9])", "NOTIN"], ["∉", "NOTIN"], ["containselement(?![a-zA-Z0-9])", "NI"], ["∋", "NI"], ["notcontainselement(?![a-zA-Z0-9])", "NOTNI"], ["∌", "NOTNI"], ["subset(?![a-zA-Z0-9])", "SUBSET"], ["⊂", "SUBSET"], ["subseteq(?![a-zA-Z0-9])", "SUBSETEQ"], ["⊆", "SUBSETEQ"], ["notsubset(?![a-zA-Z0-9])", "NOTSUBSET"], ["⊄", "NOTSUBSET"], ["notsubseteq(?![a-zA-Z0-9])", "NOTSUBSETEQ"], ["⊈", "NOTSUBSETEQ"], ["superset(?![a-zA-Z0-9])", "SUPERSET"], ["⊃", "SUPERSET"], ["superseteq(?![a-zA-Z0-9])", "SUPERSETEQ"], ["⊇", "SUPERSETEQ"], ["notsuperset(?![a-zA-Z0-9])", "NOTSUPERSET"], ["⊅", "NOTSUPERSET"], ["notsuperseteq(?![a-zA-Z0-9])", "NOTSUPERSETEQ"], ["⊉", "NOTSUPERSETEQ"], ["union(?![a-zA-Z0-9])", "UNION"], ["∪", "UNION"], ["intersect(?![a-zA-Z0-9])", "INTERSECT"], ["∩", "INTERSECT"], ["rightarrow(?![a-zA-Z0-9])", "RIGHTARROW"], ["→", "RIGHTARROW"], ["⟶", "RIGHTARROW"], ["leftarrow(?![a-zA-Z0-9])", "LEFTARROW"], ["←", "LEFTARROW"], ["⟵", "LEFTARROW"], ["leftrightarrow(?![a-zA-Z0-9])", "LEFTRIGHTARROW"], ["↔", "LEFTRIGHTARROW"], ["⟷", "LEFTRIGHTARROW"], ["implies(?![a-zA-Z0-9])", "IMPLIES"], ["⇒", "IMPLIES"], ["⟹", "IMPLIES"], ["impliedby(?![a-zA-Z0-9])", "IMPLIEDBY"], ["⇐", "IMPLIEDBY"], ["⟸", "IMPLIEDBY"], ["iff(?![a-zA-Z0-9])", "IFF"], ["⇔", "IFF"], ["⟺", "IFF"], ["perp(?![a-zA-Z0-9])", "PERP"], ["⟂", "PERP"], ["parallel(?![a-zA-Z0-9])", "PARALLEL"], ["∥", "PARALLEL"], ["angle(?![a-zA-Z0-9])", "ANGLE"], ["∠", "ANGLE"], ["int(?![a-zA-Z0-9])", "INT"], ["∫", "INT"], ["!", "!"], ["'", "'"], ["_", "_"], ["\\.\\.\\.", "LDOTS"], ["[a-zA-Z∂][a-zA-Z∂0-9]*", "VAR"], ["[_$%]", "VAR"]], allowSimplifiedFunctionApplicationDefault$1$1 = true, splitSymbolsDefault$1 = true, unsplitSymbolsDefault$1 = ["alpha", "beta", "gamma", "Gamma", "delta", "Delta", "epsilon", "zeta", "eta", "theta", "Theta", "iota", "kappa", "lambda", "Lambda", "mu", "nu", "xi", "Xi", "pi", "Pi", "rho", "sigma", "Sigma", "tau", "Tau", "upsilon", "Upsilon", "phi", "Phi", "chi", "psi", "Psi", "omega", "Omega", "angle", "deg", "emptyset"], appliedFunctionSymbolsDefault$1$1 = ["abs", "exp", "log", "ln", "log10", "sign", "sqrt", "cbrt", "nthroot", "mod", "erf", "cos", "cosh", "acos", "acosh", "arccos", "arccosh", "cot", "coth", "acot", "acoth", "arccot", "arccoth", "csc", "csch", "acsc", "acsch", "arccsc", "arccsch", "sec", "sech", "asec", "asech", "arcsec", "arcsech", "sin", "sinh", "asin", "asinh", "arcsin", "arcsinh", "tan", "tanh", "atan", "atan2", "atanh", "arctan", "arctanh", "arg", "conj", "re", "im", "det", "trace", "nPr", "nCr", "floor", "ceil", "round"], functionSymbolsDefault$1$1 = ["f", "g"], operatorSymbolsDefault$1$1 = ["binom", "vec", "linesegment"], unitsDefault$1$1 = get_all_units$1(), parseLeibnizNotationDefault$1$1 = true;
|
|
19221
19237
|
let textToAst$4$1 = class textToAst$42 {
|
|
19222
19238
|
constructor({ allowSimplifiedFunctionApplication: e3 = allowSimplifiedFunctionApplicationDefault$1$1, splitSymbols: t = splitSymbolsDefault$1, unsplitSymbols: r = unsplitSymbolsDefault$1, appliedFunctionSymbols: n = appliedFunctionSymbolsDefault$1$1, functionSymbols: i = functionSymbolsDefault$1$1, operatorSymbols: a = operatorSymbolsDefault$1$1, units: o = unitsDefault$1$1, parseLeibnizNotation: s = parseLeibnizNotationDefault$1$1, parseScientificNotation: u = true } = {}) {
|
|
19223
19239
|
this.allowSimplifiedFunctionApplication = e3, this.splitSymbols = t, this.unsplitSymbols = r, this.appliedFunctionSymbols = n, this.functionSymbols = i, this.operatorSymbols = a, this.units = o, this.parseLeibnizNotation = s;
|
|
@@ -19845,7 +19861,7 @@ function collapse_unary_minus$1(e3) {
|
|
|
19845
19861
|
}
|
|
19846
19862
|
function simplify$2(e3, t, r) {
|
|
19847
19863
|
var n = get_tree$1(e3);
|
|
19848
|
-
return contains_blank$1(n) ? n : (void 0 === t && void 0 !== e3.context && void 0 !== e3.context.get_assumptions && (t = e3.context.get_assumptions([e3.variables()])), n = evaluate_numbers$1(n, { assumptions: t, max_digits: r, evaluate_functions: true }), Array.isArray(n) ? n = collect_like_terms_factors$1(n =
|
|
19864
|
+
return contains_blank$1(n) ? n : (void 0 === t && void 0 !== e3.context && void 0 !== e3.context.get_assumptions && (t = e3.context.get_assumptions([e3.variables()])), n = evaluate_numbers$1(n, { assumptions: t, max_digits: r, evaluate_functions: true }), Array.isArray(n) ? n = collect_like_terms_factors$1(n = simplify_integers_in_roots$1(n = perform_vector_matrix_additions_scalar_multiplications$1(n = simplify_logical$1(n, t))), t, r) : n);
|
|
19849
19865
|
}
|
|
19850
19866
|
function simplify_logical$1(e3, t) {
|
|
19851
19867
|
var r = get_tree$1(e3);
|
|
@@ -19854,15 +19870,45 @@ function simplify_logical$1(e3, t) {
|
|
|
19854
19870
|
var n = [];
|
|
19855
19871
|
return n.push([["not", ["not", "a"]], "a"]), n.push([["not", ["and", "a", "b"]], ["or", ["not", "a"], ["not", "b"]]]), n.push([["not", ["or", "a", "b"]], ["and", ["not", "a"], ["not", "b"]]]), n.push([["not", ["=", "a", "b"]], ["ne", "a", "b"]]), n.push([["not", ["ne", "a", "b"]], ["=", "a", "b"]]), n.push([["not", ["<", "a", "b"]], ["le", "b", "a"]]), n.push([["not", ["le", "a", "b"]], ["not", ["le", "a", "b"]]]), n.push([["not", ["in", "a", "b"]], ["notin", "a", "b"]]), n.push([["not", ["subset", "a", "b"]], ["notsubset", "a", "b"]]), r = flatten$5$1(r = applyAllTransformations$1(r, n, 20));
|
|
19856
19872
|
}
|
|
19857
|
-
function
|
|
19873
|
+
function apply_root$1(e3, t) {
|
|
19874
|
+
return 2 === t ? ["apply", "sqrt", e3] : 3 === t ? ["apply", "cbrt", e3] : ["apply", "nthroot", ["tuple", e3, t]];
|
|
19875
|
+
}
|
|
19876
|
+
function simplify_integers_in_roots$1(e3) {
|
|
19858
19877
|
if (!Array.isArray(e3)) return e3;
|
|
19859
19878
|
var t = e3[0], r = e3.slice(1);
|
|
19860
|
-
if ("
|
|
19861
|
-
let
|
|
19862
|
-
|
|
19863
|
-
|
|
19879
|
+
if ("*" === t) {
|
|
19880
|
+
let e4 = 1;
|
|
19881
|
+
const t2 = [];
|
|
19882
|
+
for (const n3 of r) if ("number" == typeof n3) e4 *= n3;
|
|
19883
|
+
else {
|
|
19884
|
+
const r2 = simplify_integers_in_roots$1(n3);
|
|
19885
|
+
Array.isArray(r2) && "*" === r2[0] ? "number" == typeof r2[1] ? (e4 *= r2[1], t2.push(...r2.slice(2))) : t2.push(...r2.slice(1)) : t2.push(r2);
|
|
19886
|
+
}
|
|
19887
|
+
return 1 !== e4 && t2.unshift(e4), ["*", ...t2];
|
|
19888
|
+
}
|
|
19889
|
+
if ("apply" === t && ["sqrt", "cbrt", "nthroot"].includes(r[0])) {
|
|
19890
|
+
const e4 = r[0];
|
|
19891
|
+
let t2 = 2, i = r[1];
|
|
19892
|
+
if ("cbrt" === e4) t2 = 3;
|
|
19893
|
+
else if ("nthroot" === e4) if (Array.isArray(r[1]) && "tuple" === r[1][0]) {
|
|
19894
|
+
if (!(Number.isInteger(r[1][2]) && r[1][2] > 0)) return ["apply", "nthroot", ...r.slice(1).map(simplify_integers_in_roots$1)];
|
|
19895
|
+
t2 = r[1][2], i = r[1][1];
|
|
19896
|
+
} else t2 = 2;
|
|
19897
|
+
if (i = simplify_integers_in_roots$1(i), Number.isInteger(i)) {
|
|
19898
|
+
let { n_outside: e5, n_inside: r2 } = n(i, t2);
|
|
19899
|
+
if (1 !== e5) return ["*", e5, apply_root$1(r2, t2)];
|
|
19900
|
+
} else if (Array.isArray(i) && "*" === i[0] && "number" == typeof i[1]) {
|
|
19901
|
+
let { n_outside: e5, n_inside: r2 } = n(i[1], t2);
|
|
19902
|
+
if (1 !== e5) return ["*", e5, apply_root$1(["*", r2, ...i.slice(2)], t2)];
|
|
19903
|
+
}
|
|
19904
|
+
return apply_root$1(i, t2);
|
|
19905
|
+
}
|
|
19906
|
+
return [t, ...r.map(simplify_integers_in_roots$1)];
|
|
19907
|
+
function n(e4, t2 = 2) {
|
|
19908
|
+
let r2 = e4, n3 = 1, i = 2, a = math$1$1.pow(i, t2);
|
|
19909
|
+
for (; a <= Math.abs(r2); ) r2 % a == 0 ? (r2 /= a, n3 *= i) : (i++, a = math$1$1.pow(i, t2));
|
|
19910
|
+
return { n_outside: n3, n_inside: r2 };
|
|
19864
19911
|
}
|
|
19865
|
-
return [t, ...r.map(simplify_integer_square_roots$1)];
|
|
19866
19912
|
}
|
|
19867
19913
|
function perform_vector_matrix_additions_scalar_multiplications$1(e3, t = true) {
|
|
19868
19914
|
var r = get_tree$1(e3);
|
|
@@ -20152,7 +20198,7 @@ function collect_like_terms_factors$1(e3, t, r) {
|
|
|
20152
20198
|
for (let e4 in all_units$2) {
|
|
20153
20199
|
all_units$2[e4].prefix ? (s.push([["+", ["unit", e4, "x"], ["unit", e4, "y"]], ["unit", e4, ["+", "x", "y"]], { variables: { x: true, y: true }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["unit", e4, "x"], ["-", ["unit", e4, "y"]]], ["unit", e4, ["+", "x", ["-", "y"]]], { variables: { x: true, y: true }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }])) : (s.push([["+", ["unit", "x", e4], ["unit", "y", e4]], ["unit", ["+", "x", "y"], e4], { variables: { x: true, y: true }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["unit", "x", e4], ["-", ["unit", "y", e4]]], ["unit", ["+", "x", ["-", "y"]], e4], { variables: { x: true, y: true }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]));
|
|
20154
20200
|
}
|
|
20155
|
-
return s.push([["*", ["^", "x", "n"], ["^", "x", "m"]], ["^", "x", ["+", "n", "m"]], { variables: { x: (e4) => is_nonzero_ast$1(e4, t), n, m: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["*", ["^", "x", "n"], ["^", "x", "m"]], ["^", "x", ["+", "n", "m"]], { variables: { x: true, n: (e4) => n(e4) && is_positive_ast$1(e4, t), m: (e4) => n(e4) && is_positive_ast$1(e4, t) }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["^", ["-", "x"], "n"], ["^", "x", "n"], { variables: { x: true, n: (e4) => Number.isInteger(e4) && Number.isInteger(e4 / 2) }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, max_group: 1 }]), s.push([["^", ["-", "x"], "n"], ["-", ["^", "x", "n"]], { variables: { x: true, n: (e4) => Number.isInteger(e4) && !Number.isInteger(e4 / 2) }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, max_group: 1 }]), s.push([["*", ["^", "x", "n"], ["^", "x", "m"]], ["^", "x", ["+", "n", "m"]], { variables: { x: true, n: (e4) => n(e4) && is_negative_ast$1(e4, t), m: (e4) => n(e4) && is_negative_ast$1(e4, t) }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["*", ["apply", "exp", "n"], ["apply", "exp", "m"]], ["apply", "exp", ["+", "n", "m"]], { variables: { n, m: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", "n", "x"], ["*", "m", "x"]], ["*", ["+", "n", "m"], "x"], { variables: { x: true, n, m: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", "n1", "x"], ["*", ["/", "n2", "m2"], "x"]], ["*", ["+", "n1", ["/", "n2", "m2"]], "x"], { variables: { x: true, n1: n, n2: n, m2: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m2", "n1", "n2"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", "n1", "x"], ["*", ["-", ["/", "n2", "m2"]], "x"]], ["*", ["+", "n1", ["-", ["/", "n2", "m2"]]], "x"], { variables: { x: true, n1: n, n2: n, m2: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m2", "n1", "n2"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", ["/", "n1", "m1"], "x"], ["*", ["/", "n2", "m2"], "x"]], ["*", ["+", ["/", "n1", "m1"], ["/", "n2", "m2"]], "x"], { variables: { x: true, n1: n, m1: n, n2: n, m2: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m1", "m2", "n1", "n2"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", ["/", "n1", "m1"], "x"], ["*", ["-", ["/", "n2", "m2"]], "x"]], ["*", ["+", ["/", "n1", "m1"], ["-", ["/", "n2", "m2"]]], "x"], { variables: { x: true, n1: n, m1: n, n2: n, m2: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m1", "m2", "n1", "n2"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", "n", "x"], ["-", ["*", "m", "x"]]], ["*", ["+", "n", ["-", "m"]], "x"], { variables: { x: true, n, m: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["^", ["*", "x", "y"], "a"], ["*", ["^", "x", "a"], ["^", "y", "a"]], { allow_permutations: true }]), s.push([["^", ["^", "x", "n"], "m"], ["^", "x", ["*", "n", "m"]], { variables: { x: true, n, m: n }, evaluate_numbers: true, max_digits: r, allow_permutations: true }]), s.push([["-", ["+", "a", "b"]], ["+", ["-", "a"], ["-", "b"]]]), s.push([["*", "x", "y"], ["*", "x", "y"], { variables: { x: a, y: a }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), o = applyAllTransformations$1(o, s, 40), (s = []).push([["*", "x", ["^", "y", ["-", "a"]]], ["/", "x", ["^", "y", "a"]], { allow_extended_match: true, allow_permutations: true, evaluate_numbers: true, max_digits: r, max_group: 1 }]), s.push([["*", "x", ["apply", "exp", ["-", "a"]]], ["/", "x", ["apply", "exp", "a"]], { allow_extended_match: true, allow_permutations: true, evaluate_numbers: true, max_digits: r, max_group: 1, variables: { x: true, a: true } }]), s.push([["*", "x", ["^", "y", "n"]], ["/", "x", ["^", "y", ["-", "n"]]], { variables: { x: true, y: true, n: i }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["*", "x", ["apply", "exp", "n"]], ["/", "x", ["apply", "exp", ["-", "n"]]], { variables: { x: true, n: i }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), o = applyAllTransformations$1(o, s, 40), (s = []).push([["^", "y", "n"], ["/", 1, ["^", "y", ["-", "n"]]], { variables: { y: true, n: i }, evaluate_numbers: true, max_digits: r }]), s.push([["apply", "exp", "n"], ["/", 1, ["apply", "exp", ["-", "n"]]], { variables: { n: i }, evaluate_numbers: true, max_digits: r }]), o = applyAllTransformations$1(o, s, 40), (s = []).push([["/", ["/", "x", "y"], "z"], ["/", "x", ["*", "y", "z"]], { allow_extended_match: true, allow_permutations: true }]), s.push([["/", "x", ["/", "y", "z"]], ["/", ["*", "x", "z"], "y"], { allow_extended_match: true, allow_permutations: true }]), o = applyAllTransformations$1(o, s, 40), (s = []).push([["*", "x", ["/", "y", "z"]], ["/", ["*", "x", "y"], "z"], { allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["/", ["/", "x", "y"], "z"], ["/", "x", ["*", "y", "z"]], { allow_extended_match: true, allow_permutations: true }]), s.push([["/", "x", ["/", "y", "z"]], ["/", ["*", "x", "z"], "y"], { allow_extended_match: true, allow_permutations: true }]), o = evaluate_numbers$1(o = applyAllTransformations$1(o, s, 40), { assumptions: t, max_digits: r });
|
|
20201
|
+
return s.push([["*", ["^", "x", "n"], ["^", "x", "m"]], ["^", "x", ["+", "n", "m"]], { variables: { x: (e4) => is_nonzero_ast$1(e4, t), n, m: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["*", ["^", "x", "n"], ["^", "x", "m"]], ["^", "x", ["+", "n", "m"]], { variables: { x: true, n: (e4) => n(e4) && is_positive_ast$1(e4, t), m: (e4) => n(e4) && is_positive_ast$1(e4, t) }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["^", ["-", "x"], "n"], ["^", "x", "n"], { variables: { x: true, n: (e4) => Number.isInteger(e4) && Number.isInteger(e4 / 2) }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, max_group: 1 }]), s.push([["^", ["-", "x"], "n"], ["-", ["^", "x", "n"]], { variables: { x: true, n: (e4) => Number.isInteger(e4) && !Number.isInteger(e4 / 2) }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, max_group: 1 }]), s.push([["*", ["^", "x", "n"], ["^", "x", "m"]], ["^", "x", ["+", "n", "m"]], { variables: { x: true, n: (e4) => n(e4) && is_negative_ast$1(e4, t), m: (e4) => n(e4) && is_negative_ast$1(e4, t) }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["*", ["apply", "exp", "n"], ["apply", "exp", "m"]], ["apply", "exp", ["+", "n", "m"]], { variables: { n, m: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", "n", "x"], ["*", "m", "x"]], ["*", ["+", "n", "m"], "x"], { variables: { x: true, n, m: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", "n1", "x"], ["*", ["/", "n2", "m2"], "x"]], ["*", ["+", "n1", ["/", "n2", "m2"]], "x"], { variables: { x: true, n1: n, n2: n, m2: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m2", "n1", "n2"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", "n1", "x"], ["*", ["-", ["/", "n2", "m2"]], "x"]], ["*", ["+", "n1", ["-", ["/", "n2", "m2"]]], "x"], { variables: { x: true, n1: n, n2: n, m2: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m2", "n1", "n2"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", ["/", "n1", "m1"], "x"], ["*", ["/", "n2", "m2"], "x"]], ["*", ["+", ["/", "n1", "m1"], ["/", "n2", "m2"]], "x"], { variables: { x: true, n1: n, m1: n, n2: n, m2: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m1", "m2", "n1", "n2"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", ["/", "n1", "m1"], "x"], ["*", ["-", ["/", "n2", "m2"]], "x"]], ["*", ["+", ["/", "n1", "m1"], ["-", ["/", "n2", "m2"]]], "x"], { variables: { x: true, n1: n, m1: n, n2: n, m2: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m1", "m2", "n1", "n2"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", "n", "x"], ["-", ["*", "m", "x"]]], ["*", ["+", "n", ["-", "m"]], "x"], { variables: { x: true, n, m: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["^", ["*", "x", "y"], "a"], ["*", ["^", "x", "a"], ["^", "y", "a"]], { allow_permutations: true }]), s.push([["^", ["^", "x", "n"], "m"], ["^", "x", ["*", "n", "m"]], { variables: { x: true, n, m: n }, evaluate_numbers: true, max_digits: r, allow_permutations: true }]), s.push([["-", ["+", "a", "b"]], ["+", ["-", "a"], ["-", "b"]]]), s.push([["apply", "sqrt", ["*", "a", ["^", "x", "n"]]], ["*", ["apply", "sqrt", ["*", "a", ["^", "x", ["apply", "mod", ["tuple", "n", 2]]]]], ["^", "x", ["/", ["+", "n", ["-", ["apply", "mod", ["tuple", "n", 2]]]], 2]]], { variables: { a: true, x: (e4) => is_positive_ast$1(e4, t, false), n: (e4) => Number.isInteger(e4) && e4 > 1 }, evaluate_numbers: true, evaluate_functions: true, max_digits: r, allow_implicit_identities: ["a"], allow_permutations: true, assumptions: ["ne", "x", 0] }]), s.push([["apply", "sqrt", ["*", "a", ["^", "x", "n"]]], ["*", ["apply", "sqrt", ["*", "a", ["^", "x", ["apply", "mod", ["tuple", "n", 2]]]]], ["^", ["apply", "abs", "x"], ["/", ["+", "n", ["-", ["apply", "mod", ["tuple", "n", 2]]]], 2]]], { variables: { a: true, x: (e4) => !is_positive_ast$1(e4, t, false) && is_real_ast$1(e4, t), n: (e4) => Number.isInteger(e4) && e4 > 1 }, evaluate_numbers: true, evaluate_functions: true, max_digits: r, allow_implicit_identities: ["a"], allow_permutations: true, assumptions: ["ne", "x", 0] }]), s.push([["apply", "cbrt", ["*", "a", ["^", "x", "n"]]], ["*", ["apply", "cbrt", ["*", "a", ["^", "x", ["apply", "mod", ["tuple", "n", 3]]]]], ["^", "x", ["/", ["+", "n", ["-", ["apply", "mod", ["tuple", "n", 3]]]], 3]]], { variables: { a: true, x: (e4) => is_real_ast$1(e4, t), n: (e4) => Number.isInteger(e4) && e4 > 2 }, evaluate_numbers: true, evaluate_functions: true, max_digits: r, allow_implicit_identities: ["a"], allow_permutations: true, assumptions: ["ne", "x", 0] }]), s.push([["apply", "nthroot", ["tuple", ["*", "a", ["^", "x", "n"]], "m"]], ["*", ["apply", "nthroot", ["tuple", ["*", "a", ["^", "x", ["apply", "mod", ["tuple", "n", "m"]]]], "m"]], ["^", "x", ["/", ["+", "n", ["-", ["apply", "mod", ["tuple", "n", "m"]]]], "m"]]], { variables: { a: true, x: (e4) => is_positive_ast$1(e4, t, false), n: (e4) => Number.isInteger(e4) && e4 > 2, m: (e4) => Number.isInteger(e4) && e4 > 1 }, evaluate_numbers: true, evaluate_functions: true, max_digits: r, allow_implicit_identities: ["a"], allow_permutations: true, assumptions: ["ne", "x", 0] }]), s.push([["apply", "nthroot", ["tuple", ["*", "a", ["^", "x", "n"]], "m"]], ["*", ["apply", "nthroot", ["tuple", ["*", "a", ["^", "x", ["apply", "mod", ["tuple", "n", "m"]]]], "m"]], ["^", "x", ["/", ["+", "n", ["-", ["apply", "mod", ["tuple", "n", "m"]]]], "m"]]], { variables: { a: true, x: (e4) => is_real_ast$1(e4, t), n: (e4) => Number.isInteger(e4) && e4 > 2, m: (e4) => Number.isInteger(e4) && !Number.isInteger(e4 / 2) && e4 > 1 }, evaluate_numbers: true, evaluate_functions: true, max_digits: r, allow_implicit_identities: ["a"], allow_permutations: true, assumptions: ["ne", "x", 0] }]), s.push([["apply", "nthroot", ["tuple", ["*", "a", ["^", "x", "n"]], "m"]], ["*", ["apply", "nthroot", ["tuple", ["*", "a", ["^", "x", ["apply", "mod", ["tuple", "n", "m"]]]], "m"]], ["^", ["apply", "abs", "x"], ["/", ["+", "n", ["-", ["apply", "mod", ["tuple", "n", "m"]]]], "m"]]], { variables: { a: true, x: (e4) => !is_positive_ast$1(e4, t, false) && is_real_ast$1(e4, t), n: (e4) => Number.isInteger(e4) && e4 > 2, m: (e4) => Number.isInteger(e4) && Number.isInteger(e4 / 2) && e4 > 1 }, evaluate_numbers: true, evaluate_functions: true, max_digits: r, allow_implicit_identities: ["a"], allow_permutations: true, assumptions: ["ne", "x", 0] }]), s.push([["apply", "cbrt", ["*", "a", "x"]], ["-", ["apply", "cbrt", ["-", ["*", "a", "x"]]]], { variables: { a: (e4) => is_negative_ast$1(e4, t), x: true }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["x"] }]), s.push([["apply", "cbrt", ["-", "x"]], ["-", ["apply", "cbrt", "x"]], { variables: { x: true }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["x"] }]), s.push([["apply", "nthroot", ["tuple", ["*", "a", "x"], "n"]], ["-", ["apply", "nthroot", ["tuple", ["-", ["*", "a", "x"]], "n"]]], { variables: { a: (e4) => is_negative_ast$1(e4, t), x: true, n: (e4) => Number.isInteger(e4) && !Number.isInteger(e4 / 2) && e4 > 1 }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["x"] }]), s.push([["apply", "nthroot", ["tuple", ["-", "x"], "n"]], ["-", ["apply", "nthroot", ["tuple", "x", "n"]]], { variables: { x: true, n: (e4) => Number.isInteger(e4) && !Number.isInteger(e4 / 2) && e4 > 1 }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["x"] }]), s.push([["^", ["apply", "abs", "x"], "n"], ["^", "x", "n"], { variables: { x: true, n: (e4) => Number.isInteger(e4) && Number.isInteger(e4 / 2) }, evaluate_numbers: true, max_digits: r }]), s.push([["*", "x", "y"], ["*", "x", "y"], { variables: { x: a, y: a }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), o = applyAllTransformations$1(o, s, 40), (s = []).push([["*", "x", ["^", "y", ["-", "a"]]], ["/", "x", ["^", "y", "a"]], { allow_extended_match: true, allow_permutations: true, evaluate_numbers: true, max_digits: r, max_group: 1 }]), s.push([["*", "x", ["apply", "exp", ["-", "a"]]], ["/", "x", ["apply", "exp", "a"]], { allow_extended_match: true, allow_permutations: true, evaluate_numbers: true, max_digits: r, max_group: 1, variables: { x: true, a: true } }]), s.push([["*", "x", ["^", "y", "n"]], ["/", "x", ["^", "y", ["-", "n"]]], { variables: { x: true, y: true, n: i }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["*", "x", ["apply", "exp", "n"]], ["/", "x", ["apply", "exp", ["-", "n"]]], { variables: { x: true, n: i }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), o = applyAllTransformations$1(o, s, 40), (s = []).push([["^", "y", "n"], ["/", 1, ["^", "y", ["-", "n"]]], { variables: { y: true, n: i }, evaluate_numbers: true, max_digits: r }]), s.push([["apply", "exp", "n"], ["/", 1, ["apply", "exp", ["-", "n"]]], { variables: { n: i }, evaluate_numbers: true, max_digits: r }]), o = applyAllTransformations$1(o, s, 40), (s = []).push([["/", ["/", "x", "y"], "z"], ["/", "x", ["*", "y", "z"]], { allow_extended_match: true, allow_permutations: true }]), s.push([["/", "x", ["/", "y", "z"]], ["/", ["*", "x", "z"], "y"], { allow_extended_match: true, allow_permutations: true }]), o = applyAllTransformations$1(o, s, 40), (s = []).push([["*", "x", ["/", "y", "z"]], ["/", ["*", "x", "y"], "z"], { allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["/", ["/", "x", "y"], "z"], ["/", "x", ["*", "y", "z"]], { allow_extended_match: true, allow_permutations: true }]), s.push([["/", "x", ["/", "y", "z"]], ["/", ["*", "x", "z"], "y"], { allow_extended_match: true, allow_permutations: true }]), o = evaluate_numbers$1(o = applyAllTransformations$1(o, s, 40), { assumptions: t, max_digits: r, evaluate_functions: true });
|
|
20156
20202
|
}
|
|
20157
20203
|
function simplify_ratios$1(e3, t) {
|
|
20158
20204
|
function r(e4) {
|
|
@@ -20806,7 +20852,7 @@ let astToLatex$1$1 = class astToLatex$12 {
|
|
|
20806
20852
|
}
|
|
20807
20853
|
simple_factor_or_function_or_parens(e3) {
|
|
20808
20854
|
var t = this.factor(e3);
|
|
20809
|
-
return !!(t.length <= 1 || "string" == typeof e3 && e3.match(/^\w+$/) || Array.isArray(e3) && "apply" === e3[0] && "sqrt"
|
|
20855
|
+
return !!(t.length <= 1 || "string" == typeof e3 && e3.match(/^\w+$/) || Array.isArray(e3) && "apply" === e3[0] && !["sqrt", "cbrt", "nthroot"].includes(e3[1]) || t.match(/^\\left\(.*\\right\)$/) || t.match(/^\\left\\langle.*\\right\\rangle$/)) || "number" == typeof e3 && (e3 >= 0 && !e3.toString().includes("e"));
|
|
20810
20856
|
}
|
|
20811
20857
|
stringConvert(e3) {
|
|
20812
20858
|
return e3.length > 1 ? (this.convertLatexSymbols[e3] && (e3 = this.convertLatexSymbols[e3]), this.allowedLatexSymbols.includes(e3) ? "\\" + e3 : "\\operatorname{" + e3 + "}") : this.allowedLatexSymbols.includes(e3) ? "\\" + e3 : "_" !== e3 || this.showBlanks ? e3 : "";
|
|
@@ -20897,6 +20943,8 @@ let astToLatex$1$1 = class astToLatex$12 {
|
|
|
20897
20943
|
return this.simple_factor_or_function_or_parens(r[1]) || "_" === r[1][0] && "string" == typeof r[1][1] ? e5 + "!" : "\\left(" + e5 + "\\right)!";
|
|
20898
20944
|
}
|
|
20899
20945
|
if ("sqrt" === r[0]) return "\\sqrt{" + this.statement(r[1]) + "}";
|
|
20946
|
+
if ("cbrt" === r[0]) return "\\sqrt[3]{" + this.statement(r[1]) + "}";
|
|
20947
|
+
if ("nthroot" === r[0]) return Array.isArray(r[1]) && "tuple" === r[1][0] && 3 === r[1].length ? "\\sqrt[" + this.statement(r[1][2]) + "]{" + this.statement(r[1][1]) + "}" : "\\sqrt{" + this.statement(r[1]) + "}";
|
|
20900
20948
|
let e4, t2 = r[0];
|
|
20901
20949
|
if ("^" === t2[0] && (t2 = t2[1]), "_" === t2[0] && (t2 = t2[1]), "int" === t2) {
|
|
20902
20950
|
let e5, t3 = this.factor(r[0]), n3 = r[1];
|
|
@@ -20937,7 +20985,7 @@ let astToLatex$1$1 = class astToLatex$12 {
|
|
|
20937
20985
|
}
|
|
20938
20986
|
};
|
|
20939
20987
|
const textToAst$2$1 = new textToAst$4$1(), astToLatex$2 = new astToLatex$1$1();
|
|
20940
|
-
var derivatives$1 = { sin: textToAst$2$1.convert("cos x"), cos: textToAst$2$1.convert("-(sin x)"), tan: textToAst$2$1.convert("(sec x)^2"), cot: textToAst$2$1.convert("-((csc x)^2)"), sec: textToAst$2$1.convert("(sec x)*(tan x)"), csc: textToAst$2$1.convert("-(csc x)*(cot x)"), sqrt: textToAst$2$1.convert("1/(2*sqrt(x))"), log: textToAst$2$1.convert("1/x"), ln: textToAst$2$1.convert("1/x"), exp: textToAst$2$1.convert("exp(x)"), arcsin: textToAst$2$1.convert("1/sqrt(1 - x^2)"), arccos: textToAst$2$1.convert("-1/sqrt(1 - x^2)"), arctan: textToAst$2$1.convert("1/(1 + x^2)"), arccsc: textToAst$2$1.convert("-1/(sqrt(-1/x^2 + 1)*x^2)"), arcsec: textToAst$2$1.convert("1/(sqrt(-1/x^2 + 1)*x^2)"), arccot: textToAst$2$1.convert("-1/(1 + x^2)"), abs: textToAst$2$1.convert("abs(x)/x") };
|
|
20988
|
+
var derivatives$1 = { sin: textToAst$2$1.convert("cos x"), cos: textToAst$2$1.convert("-(sin x)"), tan: textToAst$2$1.convert("(sec x)^2"), cot: textToAst$2$1.convert("-((csc x)^2)"), sec: textToAst$2$1.convert("(sec x)*(tan x)"), csc: textToAst$2$1.convert("-(csc x)*(cot x)"), sqrt: textToAst$2$1.convert("1/(2*sqrt(x))"), cbrt: textToAst$2$1.convert("1/(3*x^(2/3))"), log: textToAst$2$1.convert("1/x"), ln: textToAst$2$1.convert("1/x"), exp: textToAst$2$1.convert("exp(x)"), arcsin: textToAst$2$1.convert("1/sqrt(1 - x^2)"), arccos: textToAst$2$1.convert("-1/sqrt(1 - x^2)"), arctan: textToAst$2$1.convert("1/(1 + x^2)"), arccsc: textToAst$2$1.convert("-1/(sqrt(-1/x^2 + 1)*x^2)"), arcsec: textToAst$2$1.convert("1/(sqrt(-1/x^2 + 1)*x^2)"), arccot: textToAst$2$1.convert("-1/(1 + x^2)"), asin: textToAst$2$1.convert("1/sqrt(1 - x^2)"), acos: textToAst$2$1.convert("-1/sqrt(1 - x^2)"), atan: textToAst$2$1.convert("1/(1 + x^2)"), acsc: textToAst$2$1.convert("-1/(sqrt(-1/x^2 + 1)*x^2)"), asec: textToAst$2$1.convert("1/(sqrt(-1/x^2 + 1)*x^2)"), acot: textToAst$2$1.convert("-1/(1 + x^2)"), abs: textToAst$2$1.convert("abs(x)/x") };
|
|
20941
20989
|
function derivative$1(e3, t, r = []) {
|
|
20942
20990
|
var n = get_tree$1(e3), i = "\\frac{d}{d" + t + "} ";
|
|
20943
20991
|
if ("number" == typeof n) return r.push("The derivative of a constant is zero, that is, \\(" + i + astToLatex$2.convert(n) + " = 0\\)."), 0;
|
|
@@ -20945,6 +20993,11 @@ function derivative$1(e3, t, r = []) {
|
|
|
20945
20993
|
if ("string" == typeof n) return t === n ? (r.push("We know the derivative of the identity function is one, that is, \\(" + i + astToLatex$2.convert(n) + " = 1\\)."), 1) : (r.push("As far as \\(" + astToLatex$2.convert(t) + "\\) is concerned, \\(" + astToLatex$2.convert(n) + "\\) is constant, so " + i + astToLatex$2.convert(n) + " = 0\\)."), 0);
|
|
20946
20994
|
if (!Array.isArray(n)) return null;
|
|
20947
20995
|
var a = n[0], o = n.slice(1);
|
|
20996
|
+
if ("apply" === a && "nthroot" === o[0]) if (3 !== o[1].length || "tuple" !== o[1][0]) o[0] = "sqrt";
|
|
20997
|
+
else {
|
|
20998
|
+
let e4 = o[1][2];
|
|
20999
|
+
a = "^", o = [o[1][1], ["/", 1, e4]];
|
|
21000
|
+
}
|
|
20948
21001
|
if ("+" === a || "-" === a || "~" === a) {
|
|
20949
21002
|
r.push("Using the sum rule, \\(" + i + astToLatex$2.convert(n) + " = " + o.map((function(e5, t2) {
|
|
20950
21003
|
return i + astToLatex$2.convert(e5);
|
|
@@ -22622,7 +22675,7 @@ let latexToAst$1$1 = class latexToAst$12 {
|
|
|
22622
22675
|
this.advance();
|
|
22623
22676
|
let r2 = this.statement({ parse_absolute_value: t });
|
|
22624
22677
|
if ("}" !== this.token.token_type) throw new ParseError$1("Expecting }", this.lexer.location);
|
|
22625
|
-
this.advance(), i = 2 === e4 ? ["apply", "sqrt", r2] : ["
|
|
22678
|
+
this.advance(), i = 2 === e4 ? ["apply", "sqrt", r2] : 3 === e4 ? ["apply", "cbrt", r2] : ["apply", "nthroot", ["tuple", r2, e4]];
|
|
22626
22679
|
} else if ("VAR" === this.token.token_type || "LATEXCOMMAND" === this.token.token_type || "VARMULTICHAR" === this.token.token_type) {
|
|
22627
22680
|
if (i = this.token.token_text, "LATEXCOMMAND" === this.token.token_type) {
|
|
22628
22681
|
if (i = i.slice(1), !(this.appliedFunctionSymbols.includes(i) || this.functionSymbols.includes(i) || this.allowedLatexSymbols.includes(i) || i in this.operatorSymbols)) throw new ParseError$1("Unrecognized latex command " + this.token.original_text, this.lexer.location);
|
|
@@ -63026,6 +63079,8 @@ function normalize_function_names(e3) {
|
|
|
63026
63079
|
var r = t[0], n = t.slice(1);
|
|
63027
63080
|
if ("apply" === r) {
|
|
63028
63081
|
if ("sqrt" === n[0]) return ["^", normalize_function_names(n[1]), 0.5];
|
|
63082
|
+
if ("cbrt" === n[0]) return ["^", normalize_function_names(n[1]), ["/", 1, 3]];
|
|
63083
|
+
if ("nthroot" === n[0]) return 2 !== n.length || "tuple" !== n[1][0] || 3 !== n[1].length ? ["^", normalize_function_names(n[1]), 0.5] : ["^", normalize_function_names(n[1][1]), ["/", 1, normalize_function_names(n[1][2])]];
|
|
63029
63084
|
var i = normalize_function_names_sub(n[0]);
|
|
63030
63085
|
i = ["apply", i];
|
|
63031
63086
|
var a = n.slice(1).map((function(e4) {
|
|
@@ -63108,20 +63163,30 @@ function normalize_angle_linesegment_arg_order(e3) {
|
|
|
63108
63163
|
}
|
|
63109
63164
|
function normalize_negative_numbers(e3) {
|
|
63110
63165
|
var t = get_tree(e3);
|
|
63166
|
+
function r(e4) {
|
|
63167
|
+
if ("number" == typeof e4 && e4 >= 0) return [-e4, true];
|
|
63168
|
+
if (!Array.isArray(e4)) return [e4, false];
|
|
63169
|
+
if ("*" === e4[0] && "number" == typeof e4[1] && e4[1] >= 0) return [["*", -e4[1], ...e4.slice(2).map(normalize_negative_numbers)], true];
|
|
63170
|
+
if ("/" === e4[0] && 3 === e4.length) {
|
|
63171
|
+
let [t2, n3] = r(e4[1]);
|
|
63172
|
+
if (n3) return [["/", t2, normalize_negative_numbers(e4[2])], true];
|
|
63173
|
+
}
|
|
63174
|
+
return [e4, false];
|
|
63175
|
+
}
|
|
63111
63176
|
if (!Array.isArray(t)) return t;
|
|
63112
|
-
let
|
|
63113
|
-
if ("-" ===
|
|
63114
|
-
if ("number" == typeof
|
|
63115
|
-
if (Array.isArray(
|
|
63116
|
-
|
|
63117
|
-
if (
|
|
63177
|
+
let n = t[0], i = t.slice(1);
|
|
63178
|
+
if ("-" === n && 1 === i.length) {
|
|
63179
|
+
if ("number" == typeof i[0] && i[0] >= 0) return -i[0];
|
|
63180
|
+
if (Array.isArray(i[0]) && "*" === i[0][0]) {
|
|
63181
|
+
let [e4, t2] = r(i[0][1]);
|
|
63182
|
+
if (t2) return ["*", e4, ...i[0].slice(2).map(normalize_negative_numbers)];
|
|
63118
63183
|
}
|
|
63119
|
-
if (Array.isArray(
|
|
63120
|
-
|
|
63121
|
-
if (
|
|
63184
|
+
if (Array.isArray(i[0]) && "/" === i[0][0] && 3 === i[0].length) {
|
|
63185
|
+
let [e4, t2] = r(i[0][1]);
|
|
63186
|
+
if (t2) return ["/", e4, normalize_negative_numbers(i[0][2])];
|
|
63122
63187
|
}
|
|
63123
63188
|
}
|
|
63124
|
-
return [
|
|
63189
|
+
return [n, ...i.map(normalize_negative_numbers)];
|
|
63125
63190
|
}
|
|
63126
63191
|
function tuples_to_vectors(e3) {
|
|
63127
63192
|
var t = get_tree(e3);
|
|
@@ -63747,8 +63812,11 @@ function sort_key(e3, t = {}) {
|
|
|
63747
63812
|
if ("boolean" == typeof e3) return [1, "boolean", e3];
|
|
63748
63813
|
if (!Array.isArray(e3)) return [-1, "unknown", e3];
|
|
63749
63814
|
var r = e3[0], n = e3.slice(1);
|
|
63815
|
+
if ("^" === r && 2 === n.length) return [...sort_key(n[0], t), "power", ...sort_key(n[1], t)];
|
|
63750
63816
|
if ("apply" === r) {
|
|
63751
|
-
var i = [2, "function", n[0]]
|
|
63817
|
+
var i = [2, "function", n[0]];
|
|
63818
|
+
"sqrt" !== n[0] && "cbrt" !== n[0] && "nthroot" !== n[0] || (i = [5, "root", "sqrt" === n[0] ? 2 : "cbrt" === n[0] ? 3 : n[1][2] ?? 2]);
|
|
63819
|
+
var a = n[1], o = 1, s = [];
|
|
63752
63820
|
return Array.isArray(a) ? (o = (a = a.slice(1)).length, s = a.map(((e4) => sort_key(e4, t)))) : s = [sort_key(a, t)], i.push([o, s]), i;
|
|
63753
63821
|
}
|
|
63754
63822
|
if ("unit" === r) {
|
|
@@ -64904,9 +64972,10 @@ const substitute$1 = function(e3, t) {
|
|
|
64904
64972
|
let t2 = match$2(e5, r2, a);
|
|
64905
64973
|
if (t2) {
|
|
64906
64974
|
let e6 = substitute$1(n3, t2);
|
|
64907
|
-
a.
|
|
64908
|
-
|
|
64909
|
-
|
|
64975
|
+
const i2 = a.assumptions ? substitute$1(a.assumptions, t2) : void 0;
|
|
64976
|
+
a.evaluate_numbers && (e6 = evaluate_numbers(e6, { max_digits: a.max_digits, evaluate_functions: a.evaluate_functions, assumptions: i2 }));
|
|
64977
|
+
let o = [], s = [];
|
|
64978
|
+
return t2._skipped && (o = t2._skipped), t2._skipped_before && (s = t2._skipped_before), (s.length > 0 || o.length > 0) && (Array.isArray(e6) && (e6 = e6[0] === r2[0] ? e6.slice(1) : [e6]), e6 = [r2[0]].concat(s, e6, o)), a.evaluate_numbers && (e6 = evaluate_numbers(e6, { max_digits: a.max_digits, evaluate_functions: a.evaluate_functions, assumptions: i2 })), e6;
|
|
64910
64979
|
}
|
|
64911
64980
|
return e5;
|
|
64912
64981
|
}));
|
|
@@ -64949,7 +65018,7 @@ const operators$2 = { "+": function(e3) {
|
|
|
64949
65018
|
}, binom: function(e3) {
|
|
64950
65019
|
const t = new math.SymbolNode("combinations");
|
|
64951
65020
|
return new math.FunctionNode(t, e3);
|
|
64952
|
-
} },
|
|
65021
|
+
} }, functionConversions = { nCr: "combinations", nPr: "permutations", binom: "combinations" };
|
|
64953
65022
|
let astToMathjs$1 = class {
|
|
64954
65023
|
constructor({ mathjs: e3 = null } = {}) {
|
|
64955
65024
|
e3 && (math = e3);
|
|
@@ -64963,7 +65032,7 @@ let astToMathjs$1 = class {
|
|
|
64963
65032
|
if ("apply" === t) {
|
|
64964
65033
|
if ("string" != typeof r[0]) throw Error("Non string functions not implemented for conversion to mathjs");
|
|
64965
65034
|
if ("factorial" === r[0]) return new math.OperatorNode("!", "factorial", [this.convert(r[1])]);
|
|
64966
|
-
let e4 =
|
|
65035
|
+
let e4 = functionConversions[r[0]];
|
|
64967
65036
|
e4 || (e4 = r[0]);
|
|
64968
65037
|
const t2 = new math.SymbolNode(e4), n = r[1];
|
|
64969
65038
|
let i;
|
|
@@ -65921,7 +65990,7 @@ function is_nonzero_ast(e3, t, r) {
|
|
|
65921
65990
|
}
|
|
65922
65991
|
return (!is_positive_ast(a[1], n3, true, r) || false !== e4) && void 0;
|
|
65923
65992
|
}
|
|
65924
|
-
if ("apply" === i) return !!(functions.C.nonzero && functions.C.nonzero.includes(a[0]) && is_complex_ast(a[1], n3, r)) || (!!(functions.R.nonzero && functions.R.nonzero.includes(a[0]) && is_real_ast(a[1], n3, r)) || (!!(functions.nonzeroC.nonzero && functions.nonzeroC.nonzero.includes(a[0]) && is_nonzero_ast(a[1], n3, r)
|
|
65993
|
+
if ("apply" === i) return !!(functions.C.nonzero && functions.C.nonzero.includes(a[0]) && is_complex_ast(a[1], n3, r)) || (!!(functions.R.nonzero && functions.R.nonzero.includes(a[0]) && is_real_ast(a[1], n3, r)) || (!!(functions.nonzeroC.nonzero && functions.nonzeroC.nonzero.includes(a[0]) && is_nonzero_ast(a[1], n3, r)) || (!!(functions.nonneg.nonzero && functions.nonneg.nonzero.includes(a[0]) && is_positive_ast(a[1], n3, false, r)) || (!!(functions.pos.nonzero && functions.pos.nonzero.includes(a[0]) && is_positive_ast(a[1], n3, true, r)) || void 0))));
|
|
65925
65994
|
if ("prime" === i) return;
|
|
65926
65995
|
return false;
|
|
65927
65996
|
}
|
|
@@ -66090,7 +66159,7 @@ function flatten(e3) {
|
|
|
66090
66159
|
}
|
|
66091
66160
|
return [t].concat(r);
|
|
66092
66161
|
}
|
|
66093
|
-
const sci_notat_exp_regex$1 = "(E[+\\-]?[0-9]+\\s*($|(?=\\,|\\||\\)|\\}|\\])))?", number_rules_sci$1 = [["[0-9]+(\\.[0-9]*)?" + sci_notat_exp_regex$1, "NUMBER"], ["\\.[0-9]+" + sci_notat_exp_regex$1, "NUMBER"]], number_rules_non_sci$1 = [["[0-9]+(\\.[0-9]*)?", "NUMBER"], ["\\.[0-9]+", "NUMBER"]], base_text_rules = [["\\*\\*", "^"], ["\\*", "*"], ["\\xB7", "*"], ["·", "*"], ["•", "*"], ["⋅", "*"], ["×", "*"], ["/", "/"], ["-", "-"], ["֊", "-"], ["־", "-"], ["᠆", "-"], ["‐", "-"], ["‑", "-"], ["‒", "-"], ["–", "-"], ["—", "-"], ["―", "-"], ["⁻", "-"], ["₋", "-"], ["−", "-"], ["⸺", "-"], ["⸻", "-"], ["﹘", "-"], ["﹣", "-"], ["-", "-"], ["\\+", "+"], ["\\^", "^"], ["‸", "^"], ["ʌ", "^"], ["′", "'"], ["\\|", "|"], ["\\(", "("], ["\\)", ")"], ["\\[", "["], ["\\]", "]"], ["\\{", "{"], ["\\}", "}"], ["⟨", "LANGLE"], ["⟩", "RANGLE"], ["〈", "LANGLE"], ["〉", "RANGLE"], [",", ","], [":", ":"], ["α", "VARMULTICHAR", "alpha"], ["β", "VARMULTICHAR", "beta"], ["ϐ", "VARMULTICHAR", "beta"], ["Γ", "VARMULTICHAR", "Gamma"], ["γ", "VARMULTICHAR", "gamma"], ["Δ", "VARMULTICHAR", "Delta"], ["δ", "VARMULTICHAR", "delta"], ["ε", "VARMULTICHAR", "epsilon"], ["ϵ", "VARMULTICHAR", "epsilon"], ["ζ", "VARMULTICHAR", "zeta"], ["η", "VARMULTICHAR", "eta"], ["Θ", "VARMULTICHAR", "Theta"], ["ϴ", "VARMULTICHAR", "Theta"], ["θ", "VARMULTICHAR", "theta"], ["ᶿ", "VARMULTICHAR", "theta"], ["ϑ", "VARMULTICHAR", "theta"], ["ι", "VARMULTICHAR", "iota"], ["κ", "VARMULTICHAR", "kappa"], ["Λ", "VARMULTICHAR", "Lambda"], ["λ", "VARMULTICHAR", "lambda"], ["μ", "VARMULTICHAR", "mu"], ["µ", "VARMULTICHAR", "mu"], ["ν", "VARMULTICHAR", "nu"], ["Ξ", "VARMULTICHAR", "Xi"], ["ξ", "VARMULTICHAR", "xi"], ["Π", "VARMULTICHAR", "Pi"], ["π", "VARMULTICHAR", "pi"], ["ϖ", "VARMULTICHAR", "pi"], ["ρ", "VARMULTICHAR", "rho"], ["ϱ", "VARMULTICHAR", "rho"], ["Σ", "VARMULTICHAR", "Sigma"], ["σ", "VARMULTICHAR", "sigma"], ["ς", "VARMULTICHAR", "sigma"], ["τ", "VARMULTICHAR", "tau"], ["Υ", "VARMULTICHAR", "Upsilon"], ["υ", "VARMULTICHAR", "upsilon"], ["Φ", "VARMULTICHAR", "Phi"], ["φ", "VARMULTICHAR", "phi"], ["ϕ", "VARMULTICHAR", "phi"], ["Ψ", "VARMULTICHAR", "Psi"], ["ψ", "VARMULTICHAR", "psi"], ["Ω", "VARMULTICHAR", "Omega"], ["ω", "VARMULTICHAR", "omega"], ["∅", "VARMULTICHAR", "emptyset"], ["oo(?![a-zA-Z0-9])", "INFINITY"], ["OO(?![a-zA-Z0-9])", "INFINITY"], ["infty(?![a-zA-Z0-9])", "INFINITY"], ["infinity(?![a-zA-Z0-9])", "INFINITY"], ["Infinity(?![a-zA-Z0-9])", "INFINITY"], ["∞", "INFINITY"], ["ℯ", "VAR", "e"], ["♠", "VARMULTICHAR", "spade"], ["♡", "VARMULTICHAR", "heart"], ["♢", "VARMULTICHAR", "diamond"], ["♣", "VARMULTICHAR", "club"], ["★", "VARMULTICHAR", "bigstar"], ["◯", "VARMULTICHAR", "bigcirc"], ["◊", "VARMULTICHAR", "lozenge"], ["△", "VARMULTICHAR", "bigtriangleup"], ["▽", "VARMULTICHAR", "bigtriangledown"], ["⧫", "VARMULTICHAR", "blacklozenge"], ["■", "VARMULTICHAR", "blacksquare"], ["▲", "VARMULTICHAR", "blacktriangle"], ["▼", "VARMULTICHAR", "blacktriangledown"], ["◀", "VARMULTICHAR", "blacktriangleleft"], ["▶", "VARMULTICHAR", "blacktriangleright"], ["□", "VARMULTICHAR", "Box"], ["∘", "VARMULTICHAR", "circ"], ["⋆", "VARMULTICHAR", "star"], ["and(?![a-zA-Z0-9])", "AND"], ["\\&\\&?", "AND"], ["∧", "AND"], ["or(?![a-zA-Z0-9])", "OR"], ["∨", "OR"], ["not(?![a-zA-Z0-9])", "NOT"], ["¬", "NOT"], ["=", "="], ["᐀", "="], ["゠", "="], ["!=", "NE"], ["≠", "NE"], ["<=", "LE"], ["≤", "LE"], [">=", "GE"], ["≥", "GE"], ["<", "<"], [">", ">"], ["forall(?![a-zA-Z0-9])", "FORALL"], ["∀", "FORALL"], ["exists(?![a-zA-Z0-9])", "EXISTS"], ["∃", "EXISTS"], ["elementof(?![a-zA-Z0-9])", "IN"], ["∈", "IN"], ["notelementof(?![a-zA-Z0-9])", "NOTIN"], ["∉", "NOTIN"], ["containselement(?![a-zA-Z0-9])", "NI"], ["∋", "NI"], ["notcontainselement(?![a-zA-Z0-9])", "NOTNI"], ["∌", "NOTNI"], ["subset(?![a-zA-Z0-9])", "SUBSET"], ["⊂", "SUBSET"], ["subseteq(?![a-zA-Z0-9])", "SUBSETEQ"], ["⊆", "SUBSETEQ"], ["notsubset(?![a-zA-Z0-9])", "NOTSUBSET"], ["⊄", "NOTSUBSET"], ["notsubseteq(?![a-zA-Z0-9])", "NOTSUBSETEQ"], ["⊈", "NOTSUBSETEQ"], ["superset(?![a-zA-Z0-9])", "SUPERSET"], ["⊃", "SUPERSET"], ["superseteq(?![a-zA-Z0-9])", "SUPERSETEQ"], ["⊇", "SUPERSETEQ"], ["notsuperset(?![a-zA-Z0-9])", "NOTSUPERSET"], ["⊅", "NOTSUPERSET"], ["notsuperseteq(?![a-zA-Z0-9])", "NOTSUPERSETEQ"], ["⊉", "NOTSUPERSETEQ"], ["union(?![a-zA-Z0-9])", "UNION"], ["∪", "UNION"], ["intersect(?![a-zA-Z0-9])", "INTERSECT"], ["∩", "INTERSECT"], ["rightarrow(?![a-zA-Z0-9])", "RIGHTARROW"], ["→", "RIGHTARROW"], ["⟶", "RIGHTARROW"], ["leftarrow(?![a-zA-Z0-9])", "LEFTARROW"], ["←", "LEFTARROW"], ["⟵", "LEFTARROW"], ["leftrightarrow(?![a-zA-Z0-9])", "LEFTRIGHTARROW"], ["↔", "LEFTRIGHTARROW"], ["⟷", "LEFTRIGHTARROW"], ["implies(?![a-zA-Z0-9])", "IMPLIES"], ["⇒", "IMPLIES"], ["⟹", "IMPLIES"], ["impliedby(?![a-zA-Z0-9])", "IMPLIEDBY"], ["⇐", "IMPLIEDBY"], ["⟸", "IMPLIEDBY"], ["iff(?![a-zA-Z0-9])", "IFF"], ["⇔", "IFF"], ["⟺", "IFF"], ["perp(?![a-zA-Z0-9])", "PERP"], ["⟂", "PERP"], ["parallel(?![a-zA-Z0-9])", "PARALLEL"], ["∥", "PARALLEL"], ["angle(?![a-zA-Z0-9])", "ANGLE"], ["∠", "ANGLE"], ["int(?![a-zA-Z0-9])", "INT"], ["∫", "INT"], ["!", "!"], ["'", "'"], ["_", "_"], ["\\.\\.\\.", "LDOTS"], ["[a-zA-Z∂][a-zA-Z∂0-9]*", "VAR"], ["[_$%]", "VAR"]], allowSimplifiedFunctionApplicationDefault$1 = true, splitSymbolsDefault = true, unsplitSymbolsDefault = ["alpha", "beta", "gamma", "Gamma", "delta", "Delta", "epsilon", "zeta", "eta", "theta", "Theta", "iota", "kappa", "lambda", "Lambda", "mu", "nu", "xi", "Xi", "pi", "Pi", "rho", "sigma", "Sigma", "tau", "Tau", "upsilon", "Upsilon", "phi", "Phi", "chi", "psi", "Psi", "omega", "Omega", "angle", "deg", "emptyset"], appliedFunctionSymbolsDefault$1 = ["abs", "exp", "log", "ln", "log10", "sign", "sqrt", "erf", "cos", "cosh", "acos", "acosh", "arccos", "arccosh", "cot", "coth", "acot", "acoth", "arccot", "arccoth", "csc", "csch", "acsc", "acsch", "arccsc", "arccsch", "sec", "sech", "asec", "asech", "arcsec", "arcsech", "sin", "sinh", "asin", "asinh", "arcsin", "arcsinh", "tan", "tanh", "atan", "atan2", "atanh", "arctan", "arctanh", "arg", "conj", "re", "im", "det", "trace", "nPr", "nCr", "floor", "ceil", "round"], functionSymbolsDefault$1 = ["f", "g"], operatorSymbolsDefault$1 = ["binom", "vec", "linesegment"], unitsDefault$1 = get_all_units(), parseLeibnizNotationDefault$1 = true;
|
|
66162
|
+
const sci_notat_exp_regex$1 = "(E[+\\-]?[0-9]+\\s*($|(?=\\,|\\||\\)|\\}|\\])))?", number_rules_sci$1 = [["[0-9]+(\\.[0-9]*)?" + sci_notat_exp_regex$1, "NUMBER"], ["\\.[0-9]+" + sci_notat_exp_regex$1, "NUMBER"]], number_rules_non_sci$1 = [["[0-9]+(\\.[0-9]*)?", "NUMBER"], ["\\.[0-9]+", "NUMBER"]], base_text_rules = [["\\*\\*", "^"], ["\\*", "*"], ["\\xB7", "*"], ["·", "*"], ["•", "*"], ["⋅", "*"], ["×", "*"], ["/", "/"], ["-", "-"], ["֊", "-"], ["־", "-"], ["᠆", "-"], ["‐", "-"], ["‑", "-"], ["‒", "-"], ["–", "-"], ["—", "-"], ["―", "-"], ["⁻", "-"], ["₋", "-"], ["−", "-"], ["⸺", "-"], ["⸻", "-"], ["﹘", "-"], ["﹣", "-"], ["-", "-"], ["\\+", "+"], ["\\^", "^"], ["‸", "^"], ["ʌ", "^"], ["′", "'"], ["\\|", "|"], ["\\(", "("], ["\\)", ")"], ["\\[", "["], ["\\]", "]"], ["\\{", "{"], ["\\}", "}"], ["⟨", "LANGLE"], ["⟩", "RANGLE"], ["〈", "LANGLE"], ["〉", "RANGLE"], [",", ","], [":", ":"], ["α", "VARMULTICHAR", "alpha"], ["β", "VARMULTICHAR", "beta"], ["ϐ", "VARMULTICHAR", "beta"], ["Γ", "VARMULTICHAR", "Gamma"], ["γ", "VARMULTICHAR", "gamma"], ["Δ", "VARMULTICHAR", "Delta"], ["δ", "VARMULTICHAR", "delta"], ["ε", "VARMULTICHAR", "epsilon"], ["ϵ", "VARMULTICHAR", "epsilon"], ["ζ", "VARMULTICHAR", "zeta"], ["η", "VARMULTICHAR", "eta"], ["Θ", "VARMULTICHAR", "Theta"], ["ϴ", "VARMULTICHAR", "Theta"], ["θ", "VARMULTICHAR", "theta"], ["ᶿ", "VARMULTICHAR", "theta"], ["ϑ", "VARMULTICHAR", "theta"], ["ι", "VARMULTICHAR", "iota"], ["κ", "VARMULTICHAR", "kappa"], ["Λ", "VARMULTICHAR", "Lambda"], ["λ", "VARMULTICHAR", "lambda"], ["μ", "VARMULTICHAR", "mu"], ["µ", "VARMULTICHAR", "mu"], ["ν", "VARMULTICHAR", "nu"], ["Ξ", "VARMULTICHAR", "Xi"], ["ξ", "VARMULTICHAR", "xi"], ["Π", "VARMULTICHAR", "Pi"], ["π", "VARMULTICHAR", "pi"], ["ϖ", "VARMULTICHAR", "pi"], ["ρ", "VARMULTICHAR", "rho"], ["ϱ", "VARMULTICHAR", "rho"], ["Σ", "VARMULTICHAR", "Sigma"], ["σ", "VARMULTICHAR", "sigma"], ["ς", "VARMULTICHAR", "sigma"], ["τ", "VARMULTICHAR", "tau"], ["Υ", "VARMULTICHAR", "Upsilon"], ["υ", "VARMULTICHAR", "upsilon"], ["Φ", "VARMULTICHAR", "Phi"], ["φ", "VARMULTICHAR", "phi"], ["ϕ", "VARMULTICHAR", "phi"], ["Ψ", "VARMULTICHAR", "Psi"], ["ψ", "VARMULTICHAR", "psi"], ["Ω", "VARMULTICHAR", "Omega"], ["ω", "VARMULTICHAR", "omega"], ["∅", "VARMULTICHAR", "emptyset"], ["oo(?![a-zA-Z0-9])", "INFINITY"], ["OO(?![a-zA-Z0-9])", "INFINITY"], ["infty(?![a-zA-Z0-9])", "INFINITY"], ["infinity(?![a-zA-Z0-9])", "INFINITY"], ["Infinity(?![a-zA-Z0-9])", "INFINITY"], ["∞", "INFINITY"], ["ℯ", "VAR", "e"], ["♠", "VARMULTICHAR", "spade"], ["♡", "VARMULTICHAR", "heart"], ["♢", "VARMULTICHAR", "diamond"], ["♣", "VARMULTICHAR", "club"], ["★", "VARMULTICHAR", "bigstar"], ["◯", "VARMULTICHAR", "bigcirc"], ["◊", "VARMULTICHAR", "lozenge"], ["△", "VARMULTICHAR", "bigtriangleup"], ["▽", "VARMULTICHAR", "bigtriangledown"], ["⧫", "VARMULTICHAR", "blacklozenge"], ["■", "VARMULTICHAR", "blacksquare"], ["▲", "VARMULTICHAR", "blacktriangle"], ["▼", "VARMULTICHAR", "blacktriangledown"], ["◀", "VARMULTICHAR", "blacktriangleleft"], ["▶", "VARMULTICHAR", "blacktriangleright"], ["□", "VARMULTICHAR", "Box"], ["∘", "VARMULTICHAR", "circ"], ["⋆", "VARMULTICHAR", "star"], ["and(?![a-zA-Z0-9])", "AND"], ["\\&\\&?", "AND"], ["∧", "AND"], ["or(?![a-zA-Z0-9])", "OR"], ["∨", "OR"], ["not(?![a-zA-Z0-9])", "NOT"], ["¬", "NOT"], ["=", "="], ["᐀", "="], ["゠", "="], ["!=", "NE"], ["≠", "NE"], ["<=", "LE"], ["≤", "LE"], [">=", "GE"], ["≥", "GE"], ["<", "<"], [">", ">"], ["forall(?![a-zA-Z0-9])", "FORALL"], ["∀", "FORALL"], ["exists(?![a-zA-Z0-9])", "EXISTS"], ["∃", "EXISTS"], ["elementof(?![a-zA-Z0-9])", "IN"], ["∈", "IN"], ["notelementof(?![a-zA-Z0-9])", "NOTIN"], ["∉", "NOTIN"], ["containselement(?![a-zA-Z0-9])", "NI"], ["∋", "NI"], ["notcontainselement(?![a-zA-Z0-9])", "NOTNI"], ["∌", "NOTNI"], ["subset(?![a-zA-Z0-9])", "SUBSET"], ["⊂", "SUBSET"], ["subseteq(?![a-zA-Z0-9])", "SUBSETEQ"], ["⊆", "SUBSETEQ"], ["notsubset(?![a-zA-Z0-9])", "NOTSUBSET"], ["⊄", "NOTSUBSET"], ["notsubseteq(?![a-zA-Z0-9])", "NOTSUBSETEQ"], ["⊈", "NOTSUBSETEQ"], ["superset(?![a-zA-Z0-9])", "SUPERSET"], ["⊃", "SUPERSET"], ["superseteq(?![a-zA-Z0-9])", "SUPERSETEQ"], ["⊇", "SUPERSETEQ"], ["notsuperset(?![a-zA-Z0-9])", "NOTSUPERSET"], ["⊅", "NOTSUPERSET"], ["notsuperseteq(?![a-zA-Z0-9])", "NOTSUPERSETEQ"], ["⊉", "NOTSUPERSETEQ"], ["union(?![a-zA-Z0-9])", "UNION"], ["∪", "UNION"], ["intersect(?![a-zA-Z0-9])", "INTERSECT"], ["∩", "INTERSECT"], ["rightarrow(?![a-zA-Z0-9])", "RIGHTARROW"], ["→", "RIGHTARROW"], ["⟶", "RIGHTARROW"], ["leftarrow(?![a-zA-Z0-9])", "LEFTARROW"], ["←", "LEFTARROW"], ["⟵", "LEFTARROW"], ["leftrightarrow(?![a-zA-Z0-9])", "LEFTRIGHTARROW"], ["↔", "LEFTRIGHTARROW"], ["⟷", "LEFTRIGHTARROW"], ["implies(?![a-zA-Z0-9])", "IMPLIES"], ["⇒", "IMPLIES"], ["⟹", "IMPLIES"], ["impliedby(?![a-zA-Z0-9])", "IMPLIEDBY"], ["⇐", "IMPLIEDBY"], ["⟸", "IMPLIEDBY"], ["iff(?![a-zA-Z0-9])", "IFF"], ["⇔", "IFF"], ["⟺", "IFF"], ["perp(?![a-zA-Z0-9])", "PERP"], ["⟂", "PERP"], ["parallel(?![a-zA-Z0-9])", "PARALLEL"], ["∥", "PARALLEL"], ["angle(?![a-zA-Z0-9])", "ANGLE"], ["∠", "ANGLE"], ["int(?![a-zA-Z0-9])", "INT"], ["∫", "INT"], ["!", "!"], ["'", "'"], ["_", "_"], ["\\.\\.\\.", "LDOTS"], ["[a-zA-Z∂][a-zA-Z∂0-9]*", "VAR"], ["[_$%]", "VAR"]], allowSimplifiedFunctionApplicationDefault$1 = true, splitSymbolsDefault = true, unsplitSymbolsDefault = ["alpha", "beta", "gamma", "Gamma", "delta", "Delta", "epsilon", "zeta", "eta", "theta", "Theta", "iota", "kappa", "lambda", "Lambda", "mu", "nu", "xi", "Xi", "pi", "Pi", "rho", "sigma", "Sigma", "tau", "Tau", "upsilon", "Upsilon", "phi", "Phi", "chi", "psi", "Psi", "omega", "Omega", "angle", "deg", "emptyset"], appliedFunctionSymbolsDefault$1 = ["abs", "exp", "log", "ln", "log10", "sign", "sqrt", "cbrt", "nthroot", "mod", "erf", "cos", "cosh", "acos", "acosh", "arccos", "arccosh", "cot", "coth", "acot", "acoth", "arccot", "arccoth", "csc", "csch", "acsc", "acsch", "arccsc", "arccsch", "sec", "sech", "asec", "asech", "arcsec", "arcsech", "sin", "sinh", "asin", "asinh", "arcsin", "arcsinh", "tan", "tanh", "atan", "atan2", "atanh", "arctan", "arctanh", "arg", "conj", "re", "im", "det", "trace", "nPr", "nCr", "floor", "ceil", "round"], functionSymbolsDefault$1 = ["f", "g"], operatorSymbolsDefault$1 = ["binom", "vec", "linesegment"], unitsDefault$1 = get_all_units(), parseLeibnizNotationDefault$1 = true;
|
|
66094
66163
|
let textToAst$4 = class {
|
|
66095
66164
|
constructor({ allowSimplifiedFunctionApplication: e3 = allowSimplifiedFunctionApplicationDefault$1, splitSymbols: t = splitSymbolsDefault, unsplitSymbols: r = unsplitSymbolsDefault, appliedFunctionSymbols: n = appliedFunctionSymbolsDefault$1, functionSymbols: i = functionSymbolsDefault$1, operatorSymbols: a = operatorSymbolsDefault$1, units: o = unitsDefault$1, parseLeibnizNotation: s = parseLeibnizNotationDefault$1, parseScientificNotation: u = true } = {}) {
|
|
66096
66165
|
this.allowSimplifiedFunctionApplication = e3, this.splitSymbols = t, this.unsplitSymbols = r, this.appliedFunctionSymbols = n, this.functionSymbols = i, this.operatorSymbols = a, this.units = o, this.parseLeibnizNotation = s;
|
|
@@ -66718,7 +66787,7 @@ function collapse_unary_minus(e3) {
|
|
|
66718
66787
|
}
|
|
66719
66788
|
function simplify(e3, t, r) {
|
|
66720
66789
|
var n = get_tree(e3);
|
|
66721
|
-
return contains_blank(n) ? n : (void 0 === t && void 0 !== e3.context && void 0 !== e3.context.get_assumptions && (t = e3.context.get_assumptions([e3.variables()])), n = evaluate_numbers(n, { assumptions: t, max_digits: r, evaluate_functions: true }), Array.isArray(n) ? n = collect_like_terms_factors(n =
|
|
66790
|
+
return contains_blank(n) ? n : (void 0 === t && void 0 !== e3.context && void 0 !== e3.context.get_assumptions && (t = e3.context.get_assumptions([e3.variables()])), n = evaluate_numbers(n, { assumptions: t, max_digits: r, evaluate_functions: true }), Array.isArray(n) ? n = collect_like_terms_factors(n = simplify_integers_in_roots(n = perform_vector_matrix_additions_scalar_multiplications(n = simplify_logical(n, t))), t, r) : n);
|
|
66722
66791
|
}
|
|
66723
66792
|
function simplify_logical(e3, t) {
|
|
66724
66793
|
var r = get_tree(e3);
|
|
@@ -66727,15 +66796,45 @@ function simplify_logical(e3, t) {
|
|
|
66727
66796
|
var n = [];
|
|
66728
66797
|
return n.push([["not", ["not", "a"]], "a"]), n.push([["not", ["and", "a", "b"]], ["or", ["not", "a"], ["not", "b"]]]), n.push([["not", ["or", "a", "b"]], ["and", ["not", "a"], ["not", "b"]]]), n.push([["not", ["=", "a", "b"]], ["ne", "a", "b"]]), n.push([["not", ["ne", "a", "b"]], ["=", "a", "b"]]), n.push([["not", ["<", "a", "b"]], ["le", "b", "a"]]), n.push([["not", ["le", "a", "b"]], ["not", ["le", "a", "b"]]]), n.push([["not", ["in", "a", "b"]], ["notin", "a", "b"]]), n.push([["not", ["subset", "a", "b"]], ["notsubset", "a", "b"]]), r = flatten$5(r = applyAllTransformations(r, n, 20));
|
|
66729
66798
|
}
|
|
66730
|
-
function
|
|
66799
|
+
function apply_root(e3, t) {
|
|
66800
|
+
return 2 === t ? ["apply", "sqrt", e3] : 3 === t ? ["apply", "cbrt", e3] : ["apply", "nthroot", ["tuple", e3, t]];
|
|
66801
|
+
}
|
|
66802
|
+
function simplify_integers_in_roots(e3) {
|
|
66731
66803
|
if (!Array.isArray(e3)) return e3;
|
|
66732
66804
|
var t = e3[0], r = e3.slice(1);
|
|
66733
|
-
if ("
|
|
66734
|
-
let
|
|
66735
|
-
|
|
66736
|
-
|
|
66805
|
+
if ("*" === t) {
|
|
66806
|
+
let e4 = 1;
|
|
66807
|
+
const t2 = [];
|
|
66808
|
+
for (const n3 of r) if ("number" == typeof n3) e4 *= n3;
|
|
66809
|
+
else {
|
|
66810
|
+
const r2 = simplify_integers_in_roots(n3);
|
|
66811
|
+
Array.isArray(r2) && "*" === r2[0] ? "number" == typeof r2[1] ? (e4 *= r2[1], t2.push(...r2.slice(2))) : t2.push(...r2.slice(1)) : t2.push(r2);
|
|
66812
|
+
}
|
|
66813
|
+
return 1 !== e4 && t2.unshift(e4), ["*", ...t2];
|
|
66814
|
+
}
|
|
66815
|
+
if ("apply" === t && ["sqrt", "cbrt", "nthroot"].includes(r[0])) {
|
|
66816
|
+
const e4 = r[0];
|
|
66817
|
+
let t2 = 2, i = r[1];
|
|
66818
|
+
if ("cbrt" === e4) t2 = 3;
|
|
66819
|
+
else if ("nthroot" === e4) if (Array.isArray(r[1]) && "tuple" === r[1][0]) {
|
|
66820
|
+
if (!(Number.isInteger(r[1][2]) && r[1][2] > 0)) return ["apply", "nthroot", ...r.slice(1).map(simplify_integers_in_roots)];
|
|
66821
|
+
t2 = r[1][2], i = r[1][1];
|
|
66822
|
+
} else t2 = 2;
|
|
66823
|
+
if (i = simplify_integers_in_roots(i), Number.isInteger(i)) {
|
|
66824
|
+
let { n_outside: e5, n_inside: r2 } = n(i, t2);
|
|
66825
|
+
if (1 !== e5) return ["*", e5, apply_root(r2, t2)];
|
|
66826
|
+
} else if (Array.isArray(i) && "*" === i[0] && "number" == typeof i[1]) {
|
|
66827
|
+
let { n_outside: e5, n_inside: r2 } = n(i[1], t2);
|
|
66828
|
+
if (1 !== e5) return ["*", e5, apply_root(["*", r2, ...i.slice(2)], t2)];
|
|
66829
|
+
}
|
|
66830
|
+
return apply_root(i, t2);
|
|
66831
|
+
}
|
|
66832
|
+
return [t, ...r.map(simplify_integers_in_roots)];
|
|
66833
|
+
function n(e4, t2 = 2) {
|
|
66834
|
+
let r2 = e4, n3 = 1, i = 2, a = math$1.pow(i, t2);
|
|
66835
|
+
for (; a <= Math.abs(r2); ) r2 % a == 0 ? (r2 /= a, n3 *= i) : (i++, a = math$1.pow(i, t2));
|
|
66836
|
+
return { n_outside: n3, n_inside: r2 };
|
|
66737
66837
|
}
|
|
66738
|
-
return [t, ...r.map(simplify_integer_square_roots)];
|
|
66739
66838
|
}
|
|
66740
66839
|
function perform_vector_matrix_additions_scalar_multiplications(e3, t = true) {
|
|
66741
66840
|
var r = get_tree(e3);
|
|
@@ -67025,7 +67124,7 @@ function collect_like_terms_factors(e3, t, r) {
|
|
|
67025
67124
|
for (let e4 in all_units) {
|
|
67026
67125
|
all_units[e4].prefix ? (s.push([["+", ["unit", e4, "x"], ["unit", e4, "y"]], ["unit", e4, ["+", "x", "y"]], { variables: { x: true, y: true }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["unit", e4, "x"], ["-", ["unit", e4, "y"]]], ["unit", e4, ["+", "x", ["-", "y"]]], { variables: { x: true, y: true }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }])) : (s.push([["+", ["unit", "x", e4], ["unit", "y", e4]], ["unit", ["+", "x", "y"], e4], { variables: { x: true, y: true }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["unit", "x", e4], ["-", ["unit", "y", e4]]], ["unit", ["+", "x", ["-", "y"]], e4], { variables: { x: true, y: true }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]));
|
|
67027
67126
|
}
|
|
67028
|
-
return s.push([["*", ["^", "x", "n"], ["^", "x", "m"]], ["^", "x", ["+", "n", "m"]], { variables: { x: (e4) => is_nonzero_ast(e4, t), n, m: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["*", ["^", "x", "n"], ["^", "x", "m"]], ["^", "x", ["+", "n", "m"]], { variables: { x: true, n: (e4) => n(e4) && is_positive_ast(e4, t), m: (e4) => n(e4) && is_positive_ast(e4, t) }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["^", ["-", "x"], "n"], ["^", "x", "n"], { variables: { x: true, n: (e4) => Number.isInteger(e4) && Number.isInteger(e4 / 2) }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, max_group: 1 }]), s.push([["^", ["-", "x"], "n"], ["-", ["^", "x", "n"]], { variables: { x: true, n: (e4) => Number.isInteger(e4) && !Number.isInteger(e4 / 2) }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, max_group: 1 }]), s.push([["*", ["^", "x", "n"], ["^", "x", "m"]], ["^", "x", ["+", "n", "m"]], { variables: { x: true, n: (e4) => n(e4) && is_negative_ast(e4, t), m: (e4) => n(e4) && is_negative_ast(e4, t) }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["*", ["apply", "exp", "n"], ["apply", "exp", "m"]], ["apply", "exp", ["+", "n", "m"]], { variables: { n, m: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", "n", "x"], ["*", "m", "x"]], ["*", ["+", "n", "m"], "x"], { variables: { x: true, n, m: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", "n1", "x"], ["*", ["/", "n2", "m2"], "x"]], ["*", ["+", "n1", ["/", "n2", "m2"]], "x"], { variables: { x: true, n1: n, n2: n, m2: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m2", "n1", "n2"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", "n1", "x"], ["*", ["-", ["/", "n2", "m2"]], "x"]], ["*", ["+", "n1", ["-", ["/", "n2", "m2"]]], "x"], { variables: { x: true, n1: n, n2: n, m2: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m2", "n1", "n2"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", ["/", "n1", "m1"], "x"], ["*", ["/", "n2", "m2"], "x"]], ["*", ["+", ["/", "n1", "m1"], ["/", "n2", "m2"]], "x"], { variables: { x: true, n1: n, m1: n, n2: n, m2: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m1", "m2", "n1", "n2"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", ["/", "n1", "m1"], "x"], ["*", ["-", ["/", "n2", "m2"]], "x"]], ["*", ["+", ["/", "n1", "m1"], ["-", ["/", "n2", "m2"]]], "x"], { variables: { x: true, n1: n, m1: n, n2: n, m2: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m1", "m2", "n1", "n2"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", "n", "x"], ["-", ["*", "m", "x"]]], ["*", ["+", "n", ["-", "m"]], "x"], { variables: { x: true, n, m: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["^", ["*", "x", "y"], "a"], ["*", ["^", "x", "a"], ["^", "y", "a"]], { allow_permutations: true }]), s.push([["^", ["^", "x", "n"], "m"], ["^", "x", ["*", "n", "m"]], { variables: { x: true, n, m: n }, evaluate_numbers: true, max_digits: r, allow_permutations: true }]), s.push([["-", ["+", "a", "b"]], ["+", ["-", "a"], ["-", "b"]]]), s.push([["*", "x", "y"], ["*", "x", "y"], { variables: { x: a, y: a }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), o = applyAllTransformations(o, s, 40), (s = []).push([["*", "x", ["^", "y", ["-", "a"]]], ["/", "x", ["^", "y", "a"]], { allow_extended_match: true, allow_permutations: true, evaluate_numbers: true, max_digits: r, max_group: 1 }]), s.push([["*", "x", ["apply", "exp", ["-", "a"]]], ["/", "x", ["apply", "exp", "a"]], { allow_extended_match: true, allow_permutations: true, evaluate_numbers: true, max_digits: r, max_group: 1, variables: { x: true, a: true } }]), s.push([["*", "x", ["^", "y", "n"]], ["/", "x", ["^", "y", ["-", "n"]]], { variables: { x: true, y: true, n: i }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["*", "x", ["apply", "exp", "n"]], ["/", "x", ["apply", "exp", ["-", "n"]]], { variables: { x: true, n: i }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), o = applyAllTransformations(o, s, 40), (s = []).push([["^", "y", "n"], ["/", 1, ["^", "y", ["-", "n"]]], { variables: { y: true, n: i }, evaluate_numbers: true, max_digits: r }]), s.push([["apply", "exp", "n"], ["/", 1, ["apply", "exp", ["-", "n"]]], { variables: { n: i }, evaluate_numbers: true, max_digits: r }]), o = applyAllTransformations(o, s, 40), (s = []).push([["/", ["/", "x", "y"], "z"], ["/", "x", ["*", "y", "z"]], { allow_extended_match: true, allow_permutations: true }]), s.push([["/", "x", ["/", "y", "z"]], ["/", ["*", "x", "z"], "y"], { allow_extended_match: true, allow_permutations: true }]), o = applyAllTransformations(o, s, 40), (s = []).push([["*", "x", ["/", "y", "z"]], ["/", ["*", "x", "y"], "z"], { allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["/", ["/", "x", "y"], "z"], ["/", "x", ["*", "y", "z"]], { allow_extended_match: true, allow_permutations: true }]), s.push([["/", "x", ["/", "y", "z"]], ["/", ["*", "x", "z"], "y"], { allow_extended_match: true, allow_permutations: true }]), o = evaluate_numbers(o = applyAllTransformations(o, s, 40), { assumptions: t, max_digits: r });
|
|
67127
|
+
return s.push([["*", ["^", "x", "n"], ["^", "x", "m"]], ["^", "x", ["+", "n", "m"]], { variables: { x: (e4) => is_nonzero_ast(e4, t), n, m: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["*", ["^", "x", "n"], ["^", "x", "m"]], ["^", "x", ["+", "n", "m"]], { variables: { x: true, n: (e4) => n(e4) && is_positive_ast(e4, t), m: (e4) => n(e4) && is_positive_ast(e4, t) }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["^", ["-", "x"], "n"], ["^", "x", "n"], { variables: { x: true, n: (e4) => Number.isInteger(e4) && Number.isInteger(e4 / 2) }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, max_group: 1 }]), s.push([["^", ["-", "x"], "n"], ["-", ["^", "x", "n"]], { variables: { x: true, n: (e4) => Number.isInteger(e4) && !Number.isInteger(e4 / 2) }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, max_group: 1 }]), s.push([["*", ["^", "x", "n"], ["^", "x", "m"]], ["^", "x", ["+", "n", "m"]], { variables: { x: true, n: (e4) => n(e4) && is_negative_ast(e4, t), m: (e4) => n(e4) && is_negative_ast(e4, t) }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["*", ["apply", "exp", "n"], ["apply", "exp", "m"]], ["apply", "exp", ["+", "n", "m"]], { variables: { n, m: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", "n", "x"], ["*", "m", "x"]], ["*", ["+", "n", "m"], "x"], { variables: { x: true, n, m: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", "n1", "x"], ["*", ["/", "n2", "m2"], "x"]], ["*", ["+", "n1", ["/", "n2", "m2"]], "x"], { variables: { x: true, n1: n, n2: n, m2: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m2", "n1", "n2"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", "n1", "x"], ["*", ["-", ["/", "n2", "m2"]], "x"]], ["*", ["+", "n1", ["-", ["/", "n2", "m2"]]], "x"], { variables: { x: true, n1: n, n2: n, m2: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m2", "n1", "n2"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", ["/", "n1", "m1"], "x"], ["*", ["/", "n2", "m2"], "x"]], ["*", ["+", ["/", "n1", "m1"], ["/", "n2", "m2"]], "x"], { variables: { x: true, n1: n, m1: n, n2: n, m2: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m1", "m2", "n1", "n2"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", ["/", "n1", "m1"], "x"], ["*", ["-", ["/", "n2", "m2"]], "x"]], ["*", ["+", ["/", "n1", "m1"], ["-", ["/", "n2", "m2"]]], "x"], { variables: { x: true, n1: n, m1: n, n2: n, m2: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m1", "m2", "n1", "n2"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["+", ["*", "n", "x"], ["-", ["*", "m", "x"]]], ["*", ["+", "n", ["-", "m"]], "x"], { variables: { x: true, n, m: n }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["m", "n"], allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["^", ["*", "x", "y"], "a"], ["*", ["^", "x", "a"], ["^", "y", "a"]], { allow_permutations: true }]), s.push([["^", ["^", "x", "n"], "m"], ["^", "x", ["*", "n", "m"]], { variables: { x: true, n, m: n }, evaluate_numbers: true, max_digits: r, allow_permutations: true }]), s.push([["-", ["+", "a", "b"]], ["+", ["-", "a"], ["-", "b"]]]), s.push([["apply", "sqrt", ["*", "a", ["^", "x", "n"]]], ["*", ["apply", "sqrt", ["*", "a", ["^", "x", ["apply", "mod", ["tuple", "n", 2]]]]], ["^", "x", ["/", ["+", "n", ["-", ["apply", "mod", ["tuple", "n", 2]]]], 2]]], { variables: { a: true, x: (e4) => is_positive_ast(e4, t, false), n: (e4) => Number.isInteger(e4) && e4 > 1 }, evaluate_numbers: true, evaluate_functions: true, max_digits: r, allow_implicit_identities: ["a"], allow_permutations: true, assumptions: ["ne", "x", 0] }]), s.push([["apply", "sqrt", ["*", "a", ["^", "x", "n"]]], ["*", ["apply", "sqrt", ["*", "a", ["^", "x", ["apply", "mod", ["tuple", "n", 2]]]]], ["^", ["apply", "abs", "x"], ["/", ["+", "n", ["-", ["apply", "mod", ["tuple", "n", 2]]]], 2]]], { variables: { a: true, x: (e4) => !is_positive_ast(e4, t, false) && is_real_ast(e4, t), n: (e4) => Number.isInteger(e4) && e4 > 1 }, evaluate_numbers: true, evaluate_functions: true, max_digits: r, allow_implicit_identities: ["a"], allow_permutations: true, assumptions: ["ne", "x", 0] }]), s.push([["apply", "cbrt", ["*", "a", ["^", "x", "n"]]], ["*", ["apply", "cbrt", ["*", "a", ["^", "x", ["apply", "mod", ["tuple", "n", 3]]]]], ["^", "x", ["/", ["+", "n", ["-", ["apply", "mod", ["tuple", "n", 3]]]], 3]]], { variables: { a: true, x: (e4) => is_real_ast(e4, t), n: (e4) => Number.isInteger(e4) && e4 > 2 }, evaluate_numbers: true, evaluate_functions: true, max_digits: r, allow_implicit_identities: ["a"], allow_permutations: true, assumptions: ["ne", "x", 0] }]), s.push([["apply", "nthroot", ["tuple", ["*", "a", ["^", "x", "n"]], "m"]], ["*", ["apply", "nthroot", ["tuple", ["*", "a", ["^", "x", ["apply", "mod", ["tuple", "n", "m"]]]], "m"]], ["^", "x", ["/", ["+", "n", ["-", ["apply", "mod", ["tuple", "n", "m"]]]], "m"]]], { variables: { a: true, x: (e4) => is_positive_ast(e4, t, false), n: (e4) => Number.isInteger(e4) && e4 > 2, m: (e4) => Number.isInteger(e4) && e4 > 1 }, evaluate_numbers: true, evaluate_functions: true, max_digits: r, allow_implicit_identities: ["a"], allow_permutations: true, assumptions: ["ne", "x", 0] }]), s.push([["apply", "nthroot", ["tuple", ["*", "a", ["^", "x", "n"]], "m"]], ["*", ["apply", "nthroot", ["tuple", ["*", "a", ["^", "x", ["apply", "mod", ["tuple", "n", "m"]]]], "m"]], ["^", "x", ["/", ["+", "n", ["-", ["apply", "mod", ["tuple", "n", "m"]]]], "m"]]], { variables: { a: true, x: (e4) => is_real_ast(e4, t), n: (e4) => Number.isInteger(e4) && e4 > 2, m: (e4) => Number.isInteger(e4) && !Number.isInteger(e4 / 2) && e4 > 1 }, evaluate_numbers: true, evaluate_functions: true, max_digits: r, allow_implicit_identities: ["a"], allow_permutations: true, assumptions: ["ne", "x", 0] }]), s.push([["apply", "nthroot", ["tuple", ["*", "a", ["^", "x", "n"]], "m"]], ["*", ["apply", "nthroot", ["tuple", ["*", "a", ["^", "x", ["apply", "mod", ["tuple", "n", "m"]]]], "m"]], ["^", ["apply", "abs", "x"], ["/", ["+", "n", ["-", ["apply", "mod", ["tuple", "n", "m"]]]], "m"]]], { variables: { a: true, x: (e4) => !is_positive_ast(e4, t, false) && is_real_ast(e4, t), n: (e4) => Number.isInteger(e4) && e4 > 2, m: (e4) => Number.isInteger(e4) && Number.isInteger(e4 / 2) && e4 > 1 }, evaluate_numbers: true, evaluate_functions: true, max_digits: r, allow_implicit_identities: ["a"], allow_permutations: true, assumptions: ["ne", "x", 0] }]), s.push([["apply", "cbrt", ["*", "a", "x"]], ["-", ["apply", "cbrt", ["-", ["*", "a", "x"]]]], { variables: { a: (e4) => is_negative_ast(e4, t), x: true }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["x"] }]), s.push([["apply", "cbrt", ["-", "x"]], ["-", ["apply", "cbrt", "x"]], { variables: { x: true }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["x"] }]), s.push([["apply", "nthroot", ["tuple", ["*", "a", "x"], "n"]], ["-", ["apply", "nthroot", ["tuple", ["-", ["*", "a", "x"]], "n"]]], { variables: { a: (e4) => is_negative_ast(e4, t), x: true, n: (e4) => Number.isInteger(e4) && !Number.isInteger(e4 / 2) && e4 > 1 }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["x"] }]), s.push([["apply", "nthroot", ["tuple", ["-", "x"], "n"]], ["-", ["apply", "nthroot", ["tuple", "x", "n"]]], { variables: { x: true, n: (e4) => Number.isInteger(e4) && !Number.isInteger(e4 / 2) && e4 > 1 }, evaluate_numbers: true, max_digits: r, allow_implicit_identities: ["x"] }]), s.push([["^", ["apply", "abs", "x"], "n"], ["^", "x", "n"], { variables: { x: true, n: (e4) => Number.isInteger(e4) && Number.isInteger(e4 / 2) }, evaluate_numbers: true, max_digits: r }]), s.push([["*", "x", "y"], ["*", "x", "y"], { variables: { x: a, y: a }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), o = applyAllTransformations(o, s, 40), (s = []).push([["*", "x", ["^", "y", ["-", "a"]]], ["/", "x", ["^", "y", "a"]], { allow_extended_match: true, allow_permutations: true, evaluate_numbers: true, max_digits: r, max_group: 1 }]), s.push([["*", "x", ["apply", "exp", ["-", "a"]]], ["/", "x", ["apply", "exp", "a"]], { allow_extended_match: true, allow_permutations: true, evaluate_numbers: true, max_digits: r, max_group: 1, variables: { x: true, a: true } }]), s.push([["*", "x", ["^", "y", "n"]], ["/", "x", ["^", "y", ["-", "n"]]], { variables: { x: true, y: true, n: i }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["*", "x", ["apply", "exp", "n"]], ["/", "x", ["apply", "exp", ["-", "n"]]], { variables: { x: true, n: i }, evaluate_numbers: true, max_digits: r, allow_extended_match: true, allow_permutations: true, max_group: 1 }]), o = applyAllTransformations(o, s, 40), (s = []).push([["^", "y", "n"], ["/", 1, ["^", "y", ["-", "n"]]], { variables: { y: true, n: i }, evaluate_numbers: true, max_digits: r }]), s.push([["apply", "exp", "n"], ["/", 1, ["apply", "exp", ["-", "n"]]], { variables: { n: i }, evaluate_numbers: true, max_digits: r }]), o = applyAllTransformations(o, s, 40), (s = []).push([["/", ["/", "x", "y"], "z"], ["/", "x", ["*", "y", "z"]], { allow_extended_match: true, allow_permutations: true }]), s.push([["/", "x", ["/", "y", "z"]], ["/", ["*", "x", "z"], "y"], { allow_extended_match: true, allow_permutations: true }]), o = applyAllTransformations(o, s, 40), (s = []).push([["*", "x", ["/", "y", "z"]], ["/", ["*", "x", "y"], "z"], { allow_extended_match: true, allow_permutations: true, max_group: 1 }]), s.push([["/", ["/", "x", "y"], "z"], ["/", "x", ["*", "y", "z"]], { allow_extended_match: true, allow_permutations: true }]), s.push([["/", "x", ["/", "y", "z"]], ["/", ["*", "x", "z"], "y"], { allow_extended_match: true, allow_permutations: true }]), o = evaluate_numbers(o = applyAllTransformations(o, s, 40), { assumptions: t, max_digits: r, evaluate_functions: true });
|
|
67029
67128
|
}
|
|
67030
67129
|
function simplify_ratios(e3, t) {
|
|
67031
67130
|
function r(e4) {
|
|
@@ -67679,7 +67778,7 @@ let astToLatex$1 = class {
|
|
|
67679
67778
|
}
|
|
67680
67779
|
simple_factor_or_function_or_parens(e3) {
|
|
67681
67780
|
var t = this.factor(e3);
|
|
67682
|
-
return !!(t.length <= 1 || "string" == typeof e3 && e3.match(/^\w+$/) || Array.isArray(e3) && "apply" === e3[0] && "sqrt"
|
|
67781
|
+
return !!(t.length <= 1 || "string" == typeof e3 && e3.match(/^\w+$/) || Array.isArray(e3) && "apply" === e3[0] && !["sqrt", "cbrt", "nthroot"].includes(e3[1]) || t.match(/^\\left\(.*\\right\)$/) || t.match(/^\\left\\langle.*\\right\\rangle$/)) || "number" == typeof e3 && (e3 >= 0 && !e3.toString().includes("e"));
|
|
67683
67782
|
}
|
|
67684
67783
|
stringConvert(e3) {
|
|
67685
67784
|
return e3.length > 1 ? (this.convertLatexSymbols[e3] && (e3 = this.convertLatexSymbols[e3]), this.allowedLatexSymbols.includes(e3) ? "\\" + e3 : "\\operatorname{" + e3 + "}") : this.allowedLatexSymbols.includes(e3) ? "\\" + e3 : "_" !== e3 || this.showBlanks ? e3 : "";
|
|
@@ -67770,6 +67869,8 @@ let astToLatex$1 = class {
|
|
|
67770
67869
|
return this.simple_factor_or_function_or_parens(r[1]) || "_" === r[1][0] && "string" == typeof r[1][1] ? e5 + "!" : "\\left(" + e5 + "\\right)!";
|
|
67771
67870
|
}
|
|
67772
67871
|
if ("sqrt" === r[0]) return "\\sqrt{" + this.statement(r[1]) + "}";
|
|
67872
|
+
if ("cbrt" === r[0]) return "\\sqrt[3]{" + this.statement(r[1]) + "}";
|
|
67873
|
+
if ("nthroot" === r[0]) return Array.isArray(r[1]) && "tuple" === r[1][0] && 3 === r[1].length ? "\\sqrt[" + this.statement(r[1][2]) + "]{" + this.statement(r[1][1]) + "}" : "\\sqrt{" + this.statement(r[1]) + "}";
|
|
67773
67874
|
let e4, t2 = r[0];
|
|
67774
67875
|
if ("^" === t2[0] && (t2 = t2[1]), "_" === t2[0] && (t2 = t2[1]), "int" === t2) {
|
|
67775
67876
|
let e5, t3 = this.factor(r[0]), n3 = r[1];
|
|
@@ -67810,7 +67911,7 @@ let astToLatex$1 = class {
|
|
|
67810
67911
|
}
|
|
67811
67912
|
};
|
|
67812
67913
|
const textToAst$2 = new textToAst$4(), astToLatex = new astToLatex$1();
|
|
67813
|
-
var derivatives = { sin: textToAst$2.convert("cos x"), cos: textToAst$2.convert("-(sin x)"), tan: textToAst$2.convert("(sec x)^2"), cot: textToAst$2.convert("-((csc x)^2)"), sec: textToAst$2.convert("(sec x)*(tan x)"), csc: textToAst$2.convert("-(csc x)*(cot x)"), sqrt: textToAst$2.convert("1/(2*sqrt(x))"), log: textToAst$2.convert("1/x"), ln: textToAst$2.convert("1/x"), exp: textToAst$2.convert("exp(x)"), arcsin: textToAst$2.convert("1/sqrt(1 - x^2)"), arccos: textToAst$2.convert("-1/sqrt(1 - x^2)"), arctan: textToAst$2.convert("1/(1 + x^2)"), arccsc: textToAst$2.convert("-1/(sqrt(-1/x^2 + 1)*x^2)"), arcsec: textToAst$2.convert("1/(sqrt(-1/x^2 + 1)*x^2)"), arccot: textToAst$2.convert("-1/(1 + x^2)"), abs: textToAst$2.convert("abs(x)/x") };
|
|
67914
|
+
var derivatives = { sin: textToAst$2.convert("cos x"), cos: textToAst$2.convert("-(sin x)"), tan: textToAst$2.convert("(sec x)^2"), cot: textToAst$2.convert("-((csc x)^2)"), sec: textToAst$2.convert("(sec x)*(tan x)"), csc: textToAst$2.convert("-(csc x)*(cot x)"), sqrt: textToAst$2.convert("1/(2*sqrt(x))"), cbrt: textToAst$2.convert("1/(3*x^(2/3))"), log: textToAst$2.convert("1/x"), ln: textToAst$2.convert("1/x"), exp: textToAst$2.convert("exp(x)"), arcsin: textToAst$2.convert("1/sqrt(1 - x^2)"), arccos: textToAst$2.convert("-1/sqrt(1 - x^2)"), arctan: textToAst$2.convert("1/(1 + x^2)"), arccsc: textToAst$2.convert("-1/(sqrt(-1/x^2 + 1)*x^2)"), arcsec: textToAst$2.convert("1/(sqrt(-1/x^2 + 1)*x^2)"), arccot: textToAst$2.convert("-1/(1 + x^2)"), asin: textToAst$2.convert("1/sqrt(1 - x^2)"), acos: textToAst$2.convert("-1/sqrt(1 - x^2)"), atan: textToAst$2.convert("1/(1 + x^2)"), acsc: textToAst$2.convert("-1/(sqrt(-1/x^2 + 1)*x^2)"), asec: textToAst$2.convert("1/(sqrt(-1/x^2 + 1)*x^2)"), acot: textToAst$2.convert("-1/(1 + x^2)"), abs: textToAst$2.convert("abs(x)/x") };
|
|
67814
67915
|
function derivative(e3, t, r = []) {
|
|
67815
67916
|
var n = get_tree(e3), i = "\\frac{d}{d" + t + "} ";
|
|
67816
67917
|
if ("number" == typeof n) return r.push("The derivative of a constant is zero, that is, \\(" + i + astToLatex.convert(n) + " = 0\\)."), 0;
|
|
@@ -67818,6 +67919,11 @@ function derivative(e3, t, r = []) {
|
|
|
67818
67919
|
if ("string" == typeof n) return t === n ? (r.push("We know the derivative of the identity function is one, that is, \\(" + i + astToLatex.convert(n) + " = 1\\)."), 1) : (r.push("As far as \\(" + astToLatex.convert(t) + "\\) is concerned, \\(" + astToLatex.convert(n) + "\\) is constant, so " + i + astToLatex.convert(n) + " = 0\\)."), 0);
|
|
67819
67920
|
if (!Array.isArray(n)) return null;
|
|
67820
67921
|
var a = n[0], o = n.slice(1);
|
|
67922
|
+
if ("apply" === a && "nthroot" === o[0]) if (3 !== o[1].length || "tuple" !== o[1][0]) o[0] = "sqrt";
|
|
67923
|
+
else {
|
|
67924
|
+
let e4 = o[1][2];
|
|
67925
|
+
a = "^", o = [o[1][1], ["/", 1, e4]];
|
|
67926
|
+
}
|
|
67821
67927
|
if ("+" === a || "-" === a || "~" === a) {
|
|
67822
67928
|
r.push("Using the sum rule, \\(" + i + astToLatex.convert(n) + " = " + o.map((function(e5, t2) {
|
|
67823
67929
|
return i + astToLatex.convert(e5);
|
|
@@ -69495,7 +69601,7 @@ let latexToAst$1 = class {
|
|
|
69495
69601
|
this.advance();
|
|
69496
69602
|
let r2 = this.statement({ parse_absolute_value: t });
|
|
69497
69603
|
if ("}" !== this.token.token_type) throw new ParseError("Expecting }", this.lexer.location);
|
|
69498
|
-
this.advance(), i = 2 === e4 ? ["apply", "sqrt", r2] : ["
|
|
69604
|
+
this.advance(), i = 2 === e4 ? ["apply", "sqrt", r2] : 3 === e4 ? ["apply", "cbrt", r2] : ["apply", "nthroot", ["tuple", r2, e4]];
|
|
69499
69605
|
} else if ("VAR" === this.token.token_type || "LATEXCOMMAND" === this.token.token_type || "VARMULTICHAR" === this.token.token_type) {
|
|
69500
69606
|
if (i = this.token.token_text, "LATEXCOMMAND" === this.token.token_type) {
|
|
69501
69607
|
if (i = i.slice(1), !(this.appliedFunctionSymbols.includes(i) || this.functionSymbols.includes(i) || this.allowedLatexSymbols.includes(i) || i in this.operatorSymbols)) throw new ParseError("Unrecognized latex command " + this.token.original_text, this.lexer.location);
|
|
@@ -70773,7 +70879,7 @@ function ExternalVirtualKeyboard() {
|
|
|
70773
70879
|
}
|
|
70774
70880
|
);
|
|
70775
70881
|
}
|
|
70776
|
-
const version = "0.7.
|
|
70882
|
+
const version = "0.7.8-dev.20260226230802.7acd737";
|
|
70777
70883
|
const latestDoenetmlVersion = version;
|
|
70778
70884
|
function DoenetViewer({
|
|
70779
70885
|
doenetML,
|