pimath 0.1.26 → 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/algebra/linearSystem.d.ts +2 -2
- package/dist/pimath.js +268 -261
- package/dist/pimath.js.map +1 -1
- package/package.json +1 -1
package/dist/pimath.js
CHANGED
|
@@ -79,7 +79,7 @@ const U = {
|
|
|
79
79
|
round: Hi
|
|
80
80
|
};
|
|
81
81
|
var ut, x, v, Re;
|
|
82
|
-
const
|
|
82
|
+
const $ = class $ {
|
|
83
83
|
constructor(e, t) {
|
|
84
84
|
m(this, ut, !1);
|
|
85
85
|
m(this, x, 1);
|
|
@@ -114,22 +114,22 @@ const P = class P {
|
|
|
114
114
|
}
|
|
115
115
|
break;
|
|
116
116
|
case "object":
|
|
117
|
-
e instanceof
|
|
117
|
+
e instanceof $ && (h(this, v, +e.numerator), h(this, x, +e.denominator));
|
|
118
118
|
break;
|
|
119
119
|
}
|
|
120
120
|
return this;
|
|
121
121
|
});
|
|
122
122
|
a(this, "clone", () => {
|
|
123
|
-
const e = new
|
|
123
|
+
const e = new $();
|
|
124
124
|
return e.numerator = +s(this, v), e.denominator = +s(this, x), e;
|
|
125
125
|
});
|
|
126
126
|
a(this, "abs", () => (h(this, v, Math.abs(s(this, v))), h(this, x, Math.abs(s(this, x))), this));
|
|
127
127
|
a(this, "add", (e) => {
|
|
128
|
-
if (e instanceof
|
|
128
|
+
if (e instanceof $) {
|
|
129
129
|
const t = s(this, v), i = s(this, x);
|
|
130
130
|
h(this, v, t * e.denominator + e.numerator * i), h(this, x, i * e.denominator);
|
|
131
131
|
} else
|
|
132
|
-
return this.add(new
|
|
132
|
+
return this.add(new $(e));
|
|
133
133
|
return this.reduce();
|
|
134
134
|
});
|
|
135
135
|
a(this, "amplify", (e) => (Number.isSafeInteger(e) && (h(this, v, s(this, v) * e), h(this, x, s(this, x) * e)), this));
|
|
@@ -146,7 +146,7 @@ const P = class P {
|
|
|
146
146
|
a(this, "compare", (e, t) => {
|
|
147
147
|
t === void 0 && (t = "=");
|
|
148
148
|
let i;
|
|
149
|
-
switch (e instanceof
|
|
149
|
+
switch (e instanceof $ ? i = e.clone() : i = new $(e), t) {
|
|
150
150
|
case ">":
|
|
151
151
|
return this.value > i.value;
|
|
152
152
|
case ">=":
|
|
@@ -168,9 +168,9 @@ const P = class P {
|
|
|
168
168
|
}
|
|
169
169
|
});
|
|
170
170
|
a(this, "divide", (e) => {
|
|
171
|
-
const t = new
|
|
171
|
+
const t = new $(e);
|
|
172
172
|
if (t.numerator === 0)
|
|
173
|
-
return new
|
|
173
|
+
return new $().infinite();
|
|
174
174
|
const i = +s(this, v), n = +s(this, x);
|
|
175
175
|
return h(this, v, i * t.denominator), h(this, x, n * t.numerator), this.reduce();
|
|
176
176
|
});
|
|
@@ -188,7 +188,7 @@ const P = class P {
|
|
|
188
188
|
a(this, "isGeq", (e) => this.compare(e, ">="));
|
|
189
189
|
a(this, "isGreater", (e) => this.compare(e, ">"));
|
|
190
190
|
a(this, "isInfinity", () => Math.abs(s(this, v)) === 1 / 0);
|
|
191
|
-
a(this, "isInverted", (e) => this.isEqual(new
|
|
191
|
+
a(this, "isInverted", (e) => this.isEqual(new $().one().divide(e.clone())));
|
|
192
192
|
a(this, "isLeq", (e) => this.compare(e, "<="));
|
|
193
193
|
/* Compare shortcuts */
|
|
194
194
|
a(this, "isLesser", (e) => this.compare(e, "<"));
|
|
@@ -212,13 +212,13 @@ const P = class P {
|
|
|
212
212
|
// Mathematical operations specific to fractions
|
|
213
213
|
a(this, "isZero", () => s(this, v) === 0);
|
|
214
214
|
a(this, "multiply", (e) => {
|
|
215
|
-
const t = new
|
|
215
|
+
const t = new $(e);
|
|
216
216
|
return h(this, v, s(this, v) * t.numerator), h(this, x, s(this, x) * t.denominator), this.reduce();
|
|
217
217
|
});
|
|
218
218
|
a(this, "one", () => (h(this, v, 1), h(this, x, 1), this));
|
|
219
219
|
a(this, "opposite", () => (h(this, v, -s(this, v)), this));
|
|
220
220
|
a(this, "pow", (e) => {
|
|
221
|
-
if (e instanceof
|
|
221
|
+
if (e instanceof $)
|
|
222
222
|
return this.pow(e.value);
|
|
223
223
|
this.reduce(), e < 0 && this.inverse();
|
|
224
224
|
const t = Math.floor(Math.pow(s(this, v), Math.abs(e))), i = Math.floor(Math.pow(s(this, x), Math.abs(e)));
|
|
@@ -245,7 +245,7 @@ const P = class P {
|
|
|
245
245
|
// Getter and setter
|
|
246
246
|
a(this, "sign", () => s(this, v) * s(this, x) >= 0 ? 1 : -1);
|
|
247
247
|
a(this, "sqrt", () => this.root(2));
|
|
248
|
-
a(this, "subtract", (e) => e instanceof
|
|
248
|
+
a(this, "subtract", (e) => e instanceof $ ? this.add(e.clone().opposite()) : this.add(-e));
|
|
249
249
|
a(this, "zero", () => (h(this, v, 0), h(this, x, 1), this));
|
|
250
250
|
return e !== void 0 && this.parse(e, t), this;
|
|
251
251
|
}
|
|
@@ -286,44 +286,44 @@ const P = class P {
|
|
|
286
286
|
return e === 0 ? 0 : e;
|
|
287
287
|
}
|
|
288
288
|
};
|
|
289
|
-
ut = new WeakMap(), x = new WeakMap(), v = new WeakMap(), Re = new WeakMap(), a(
|
|
290
|
-
const t = new
|
|
289
|
+
ut = new WeakMap(), x = new WeakMap(), v = new WeakMap(), Re = new WeakMap(), a($, "average", (...e) => {
|
|
290
|
+
const t = new $().zero();
|
|
291
291
|
for (const i of e)
|
|
292
292
|
t.add(i);
|
|
293
293
|
return t.divide(e.length), t;
|
|
294
|
-
}), a(
|
|
295
|
-
let t = new
|
|
294
|
+
}), a($, "max", (...e) => {
|
|
295
|
+
let t = new $(e[0]);
|
|
296
296
|
for (const i of e) {
|
|
297
|
-
const n = new
|
|
297
|
+
const n = new $(i);
|
|
298
298
|
n.isGreater(t) && (t = n.clone());
|
|
299
299
|
}
|
|
300
300
|
return t;
|
|
301
|
-
}), a(
|
|
302
|
-
let t = new
|
|
301
|
+
}), a($, "min", (...e) => {
|
|
302
|
+
let t = new $(e[0]);
|
|
303
303
|
for (const i of e) {
|
|
304
|
-
const n = new
|
|
304
|
+
const n = new $(i);
|
|
305
305
|
n.isLesser(t) && (t = n.clone());
|
|
306
306
|
}
|
|
307
307
|
return t;
|
|
308
|
-
}), a(
|
|
309
|
-
const n = e.map((r) => r instanceof
|
|
308
|
+
}), a($, "sort", (e, t) => {
|
|
309
|
+
const n = e.map((r) => r instanceof $ ? r : new $(r)).sort((r, l) => r.value - l.value);
|
|
310
310
|
return t && n.reverse(), n;
|
|
311
311
|
}), // ------------------------------------------
|
|
312
312
|
// Compare functions
|
|
313
|
-
a(
|
|
313
|
+
a($, "unique", (e) => {
|
|
314
314
|
const t = {}, i = [];
|
|
315
315
|
return e.forEach((n) => {
|
|
316
|
-
n instanceof
|
|
316
|
+
n instanceof $ || (n = new $(n)), t[n.clone().reduce().tex] || (i.push(n.clone()), t[n.tex] = !0);
|
|
317
317
|
}), i;
|
|
318
|
-
}), a(
|
|
319
|
-
const t = new
|
|
318
|
+
}), a($, "xMultiply", (...e) => {
|
|
319
|
+
const t = new $();
|
|
320
320
|
for (const i of e) {
|
|
321
|
-
const n = new
|
|
321
|
+
const n = new $(i);
|
|
322
322
|
t.numerator = t.numerator * n.numerator, t.denominator = t.denominator * n.denominator;
|
|
323
323
|
}
|
|
324
324
|
return t;
|
|
325
325
|
});
|
|
326
|
-
let
|
|
326
|
+
let f = $;
|
|
327
327
|
var Z, ie, re, Ye;
|
|
328
328
|
class vt {
|
|
329
329
|
constructor(...e) {
|
|
@@ -428,9 +428,9 @@ K = new WeakMap(), Fe = new WeakMap(), C = new WeakSet(), Ge = function(e, t) {
|
|
|
428
428
|
display: (t == null ? void 0 : t.display) ?? ""
|
|
429
429
|
};
|
|
430
430
|
}, ge = function(e) {
|
|
431
|
-
if (e instanceof
|
|
431
|
+
if (e instanceof f && e.isApproximative())
|
|
432
432
|
return A(this, C, Ge).call(this, e.value);
|
|
433
|
-
const t = new
|
|
433
|
+
const t = new f(e);
|
|
434
434
|
return {
|
|
435
435
|
variable: s(this, Fe),
|
|
436
436
|
exact: t,
|
|
@@ -441,21 +441,21 @@ K = new WeakMap(), Fe = new WeakMap(), C = new WeakSet(), Ge = function(e, t) {
|
|
|
441
441
|
}, vi = function() {
|
|
442
442
|
const e = [];
|
|
443
443
|
s(this, K).degree().value;
|
|
444
|
-
const t = s(this, K).getCoefficients().map((p) => p.value), [i, ...n] = s(this, K).getCoefficients(), r = 1 + Math.max(...n.map((p) => p.value / i.value)), c = 2 * r / 100,
|
|
444
|
+
const t = s(this, K).getCoefficients().map((p) => p.value), [i, ...n] = s(this, K).getCoefficients(), r = 1 + Math.max(...n.map((p) => p.value / i.value)), c = 2 * r / 100, u = [];
|
|
445
445
|
for (let p = -r; p <= r; p += c) {
|
|
446
446
|
const w = U.numberCorrection(p);
|
|
447
|
-
|
|
447
|
+
u.push(
|
|
448
448
|
{
|
|
449
449
|
x: w,
|
|
450
450
|
fx: s(this, K).evaluate(w, !0)
|
|
451
451
|
}
|
|
452
452
|
);
|
|
453
453
|
}
|
|
454
|
-
|
|
454
|
+
u.sort((p, w) => p.x - w.x);
|
|
455
455
|
const d = [];
|
|
456
|
-
return
|
|
457
|
-
w > 0 && (p.fx === 0 ? d.push([p.x, p.x]) :
|
|
458
|
-
|
|
456
|
+
return u.forEach((p, w) => {
|
|
457
|
+
w > 0 && (p.fx === 0 ? d.push([p.x, p.x]) : u[w - 1].fx * p.fx < 0 && d.push([
|
|
458
|
+
u[w - 1].x,
|
|
459
459
|
p.x
|
|
460
460
|
]));
|
|
461
461
|
}), d.forEach((p) => {
|
|
@@ -474,10 +474,10 @@ K = new WeakMap(), Fe = new WeakMap(), C = new WeakSet(), Ge = function(e, t) {
|
|
|
474
474
|
let c;
|
|
475
475
|
for (; (i - t) / 2 > n; ) {
|
|
476
476
|
c = (t + i) / 2;
|
|
477
|
-
const
|
|
478
|
-
if (
|
|
477
|
+
const u = s(this, K).evaluate(c, !0);
|
|
478
|
+
if (u === 0)
|
|
479
479
|
return c;
|
|
480
|
-
r *
|
|
480
|
+
r * u < 0 ? (i = c, l = u) : (t = c, r = u);
|
|
481
481
|
}
|
|
482
482
|
return (t + i) / 2;
|
|
483
483
|
}, xi = function() {
|
|
@@ -491,7 +491,7 @@ K = new WeakMap(), Fe = new WeakMap(), C = new WeakSet(), Ge = function(e, t) {
|
|
|
491
491
|
const l = U.dividers(n.value), c = U.dividers(r.value);
|
|
492
492
|
for (const d of l)
|
|
493
493
|
for (const p of c) {
|
|
494
|
-
const w = new
|
|
494
|
+
const w = new f(p, d);
|
|
495
495
|
e.evaluate(w).isZero() && !t.find((V) => V.value === w.value) && t.push(A(this, C, ge).call(this, w)), w.opposite(), e.evaluate(w).isZero() && !t.find((V) => V.value === w.value) && t.push(A(this, C, ge).call(this, w));
|
|
496
496
|
}
|
|
497
497
|
for (const d of t) {
|
|
@@ -505,10 +505,10 @@ K = new WeakMap(), Fe = new WeakMap(), C = new WeakSet(), Ge = function(e, t) {
|
|
|
505
505
|
return t.sort((d, p) => d.value - p.value);
|
|
506
506
|
if (e.degree().value > 3)
|
|
507
507
|
return [];
|
|
508
|
-
const
|
|
509
|
-
return t = t.concat(
|
|
508
|
+
const u = new pi(e, e.clone().parse("0"), s(this, Fe));
|
|
509
|
+
return t = t.concat(u.solve()), t.sort((d, p) => d.value - p.value);
|
|
510
510
|
}, Ei = function() {
|
|
511
|
-
const e = s(this, K), t = e.monomByDegree(3).coefficient, i = e.monomByDegree(2).coefficient, n = e.monomByDegree(1).coefficient, r = e.monomByDegree(0).coefficient, l = i.clone().divide(t), c = n.clone().divide(t),
|
|
511
|
+
const e = s(this, K), t = e.monomByDegree(3).coefficient, i = e.monomByDegree(2).coefficient, n = e.monomByDegree(1).coefficient, r = e.monomByDegree(0).coefficient, l = i.clone().divide(t), c = n.clone().divide(t), u = r.clone().divide(t), d = c.clone().subtract(l.clone().pow(2).divide(3)), p = u.clone().subtract(l.clone().multiply(c).divide(3)).add(l.clone().pow(3).multiply(2).divide(27)), w = p.clone().opposite(), V = d.clone().opposite().pow(3).divide(27), ce = w.clone().pow(2).subtract(V.clone().multiply(4)).opposite();
|
|
512
512
|
if (ce.isNegative()) {
|
|
513
513
|
const ue = p.clone().opposite().add(ce.clone().opposite().sqrt()).divide(2).root(3), fe = p.clone().opposite().subtract(ce.clone().opposite().sqrt()).divide(2).root(3), ye = ue.clone().add(fe).subtract(l.clone().divide(3));
|
|
514
514
|
return [A(this, C, ge).call(this, ye)];
|
|
@@ -537,15 +537,15 @@ K = new WeakMap(), Fe = new WeakMap(), C = new WeakSet(), Ge = function(e, t) {
|
|
|
537
537
|
if (r.isNegative())
|
|
538
538
|
return [];
|
|
539
539
|
if (r.isSquare()) {
|
|
540
|
-
const l = r.sqrt(), c = i.clone().opposite().add(l).divide(t.clone().multiply(2)),
|
|
540
|
+
const l = r.sqrt(), c = i.clone().opposite().add(l).divide(t.clone().multiply(2)), u = i.clone().opposite().subtract(l).divide(t.clone().multiply(2));
|
|
541
541
|
return l.isZero() ? [A(this, C, ge).call(this, c)] : [
|
|
542
542
|
A(this, C, ge).call(this, c),
|
|
543
|
-
A(this, C, ge).call(this,
|
|
543
|
+
A(this, C, ge).call(this, u)
|
|
544
544
|
].sort((d, p) => d.value - p.value);
|
|
545
545
|
}
|
|
546
546
|
return A(this, C, Ti).call(this, t, i, r);
|
|
547
547
|
}, Ti = function(e, t, i) {
|
|
548
|
-
const n = U.dividers(i.value).filter((me) => Math.sqrt(me) % 1 === 0).map((me) => Math.sqrt(me)).pop() ?? 1, r = U.gcd(2 * e.value, t.value, n) * (e.isNegative() ? -1 : 1), l = t.clone().divide(r).opposite(), c = e.clone().divide(r).multiply(2),
|
|
548
|
+
const n = U.dividers(i.value).filter((me) => Math.sqrt(me) % 1 === 0).map((me) => Math.sqrt(me)).pop() ?? 1, r = U.gcd(2 * e.value, t.value, n) * (e.isNegative() ? -1 : 1), l = t.clone().divide(r).opposite(), c = e.clone().divide(r).multiply(2), u = i.clone().divide(n ** 2), d = Math.abs(n / r), p = n === 1 ? "-" : `-${d} `, w = n === 1 ? "+" : `+${d} `;
|
|
549
549
|
function V(me, de, rt, Jt) {
|
|
550
550
|
return `\\frac{ ${de} ${rt}\\sqrt{ ${Jt} } }{ ${me} }`;
|
|
551
551
|
}
|
|
@@ -555,12 +555,12 @@ K = new WeakMap(), Fe = new WeakMap(), C = new WeakSet(), Ge = function(e, t) {
|
|
|
555
555
|
const ue = i.value ** 0.5, fe = (-t.value - ue) / (2 * e.value), ye = (-t.value + ue) / (2 * e.value);
|
|
556
556
|
return [
|
|
557
557
|
A(this, C, Ge).call(this, fe, {
|
|
558
|
-
tex: V(c.tex, l.tex, p.toString(),
|
|
559
|
-
display: ce(c.display, l.display, p.toString(),
|
|
558
|
+
tex: V(c.tex, l.tex, p.toString(), u.tex),
|
|
559
|
+
display: ce(c.display, l.display, p.toString(), u.display)
|
|
560
560
|
}),
|
|
561
561
|
A(this, C, Ge).call(this, ye, {
|
|
562
|
-
tex: V(c.tex, l.tex, w.toString(),
|
|
563
|
-
display: ce(c.display, l.display, w.toString(),
|
|
562
|
+
tex: V(c.tex, l.tex, w.toString(), u.tex),
|
|
563
|
+
display: ce(c.display, l.display, w.toString(), u.display)
|
|
564
564
|
})
|
|
565
565
|
].sort((me, de) => me.value - de.value);
|
|
566
566
|
};
|
|
@@ -581,9 +581,9 @@ function Qi(o, e) {
|
|
|
581
581
|
const i = new RegExp(`^(${t.join("|")})\\(`), n = Object.keys(fi);
|
|
582
582
|
n.sort((w, V) => V.length - w.length);
|
|
583
583
|
const r = new RegExp(`^(${n.join("|")})`), l = /^(\d+(\.\d+)?)/;
|
|
584
|
-
let c = "",
|
|
584
|
+
let c = "", u, d, p;
|
|
585
585
|
for (; o.length > 0; ) {
|
|
586
|
-
if (
|
|
586
|
+
if (u = d, p = void 0, t.length > 0 && i.exec(o)) {
|
|
587
587
|
const w = t.find((V) => o.startsWith(V));
|
|
588
588
|
w && (p = w + "(", o = o.slice(w.length + 1), d = g.FUNCTION);
|
|
589
589
|
} else if (n.length > 0 && r.exec(o)) {
|
|
@@ -615,7 +615,7 @@ function Qi(o, e) {
|
|
|
615
615
|
}
|
|
616
616
|
if (p === void 0 || d === void 0)
|
|
617
617
|
throw new Error("The token is undefined");
|
|
618
|
-
c += Ki(
|
|
618
|
+
c += Ki(u, d), c += p;
|
|
619
619
|
}
|
|
620
620
|
return c;
|
|
621
621
|
}
|
|
@@ -724,7 +724,7 @@ class Kt {
|
|
|
724
724
|
const i = [], n = [];
|
|
725
725
|
let r = "", l = 0, c;
|
|
726
726
|
(t ?? te(this, Ve)) && (e = Qi(e, te(this, ne)));
|
|
727
|
-
const
|
|
727
|
+
const u = 50;
|
|
728
728
|
let d = 50, p;
|
|
729
729
|
for (; l < e.length; ) {
|
|
730
730
|
if (d--, d === 0) {
|
|
@@ -744,7 +744,7 @@ class Kt {
|
|
|
744
744
|
case g.OPERATION:
|
|
745
745
|
if (n.length > 0) {
|
|
746
746
|
let w = n[n.length - 1];
|
|
747
|
-
for (p = +
|
|
747
|
+
for (p = +u; w.token in te(this, ne) && //either o1 is left-associative and its precedence is less than or equal to that of o2,
|
|
748
748
|
(te(this, ne)[r].associative === "left" && te(this, ne)[r].precedence <= te(this, ne)[w.token].precedence || //or o1 is right associative, and has precedence less than that of o2,
|
|
749
749
|
te(this, ne)[r].associative === "right" && te(this, ne)[r].precedence < te(this, ne)[w.token].precedence); ) {
|
|
750
750
|
if (p--, p === 0) {
|
|
@@ -759,7 +759,7 @@ class Kt {
|
|
|
759
759
|
n.push({ token: r, tokenType: c });
|
|
760
760
|
break;
|
|
761
761
|
case g.FUNCTION_ARGUMENT:
|
|
762
|
-
for (p = +
|
|
762
|
+
for (p = +u; n[n.length - 1].token !== "(" && n.length > 0; ) {
|
|
763
763
|
if (p--, p === 0) {
|
|
764
764
|
console.log("SECURITY LEVEL 2 FUNCTION ARGUMENT EXIT");
|
|
765
765
|
break;
|
|
@@ -771,7 +771,7 @@ class Kt {
|
|
|
771
771
|
n.push({ token: r, tokenType: c }), e[l] === "-" && i.push({ token: "0", tokenType: g.COEFFICIENT });
|
|
772
772
|
break;
|
|
773
773
|
case g.RIGHT_PARENTHESIS:
|
|
774
|
-
for (p = +
|
|
774
|
+
for (p = +u; n[n.length - 1].token !== "(" && n.length > 1; ) {
|
|
775
775
|
if (p--, p === 0) {
|
|
776
776
|
console.log("SECURITY LEVEL 2 CLOSING PARENTHESIS EXIT");
|
|
777
777
|
break;
|
|
@@ -923,7 +923,7 @@ const I = class I {
|
|
|
923
923
|
* Get the degree of a monom. If no setLetter is given, the result will be the global degree.
|
|
924
924
|
* @param letter (string) Letter to get to degree (power)
|
|
925
925
|
*/
|
|
926
|
-
a(this, "degree", (e) => this.variables.length === 0 ? new
|
|
926
|
+
a(this, "degree", (e) => this.variables.length === 0 ? new f().zero() : e === void 0 ? Object.values(s(this, b)).reduce((t, i) => t.clone().add(i)) : this.hasVariable(e) ? s(this, b)[e].clone() : new f().zero());
|
|
927
927
|
/**
|
|
928
928
|
* Derivative the monom
|
|
929
929
|
* @param letter
|
|
@@ -931,7 +931,7 @@ const I = class I {
|
|
|
931
931
|
a(this, "derivative", (e) => {
|
|
932
932
|
if (e === void 0 && (e = "x"), this.hasVariable(e)) {
|
|
933
933
|
const t = s(this, b)[e].clone(), i = this.clone();
|
|
934
|
-
return s(i, b)[e].subtract(1), s(i, T).multiply(new
|
|
934
|
+
return s(i, b)[e].subtract(1), s(i, T).multiply(new f(t.clone())), i;
|
|
935
935
|
} else
|
|
936
936
|
return new I().zero();
|
|
937
937
|
});
|
|
@@ -955,31 +955,31 @@ const I = class I {
|
|
|
955
955
|
*/
|
|
956
956
|
a(this, "evaluate", (e, t) => {
|
|
957
957
|
if (t === !0) {
|
|
958
|
-
if (e instanceof
|
|
958
|
+
if (e instanceof f)
|
|
959
959
|
return s(this, ze).call(this, e.value);
|
|
960
960
|
if (e instanceof vt)
|
|
961
|
-
return new
|
|
961
|
+
return new f().invalid();
|
|
962
962
|
if (typeof e == "number")
|
|
963
963
|
return s(this, ze).call(this, e);
|
|
964
964
|
if (typeof e == "object") {
|
|
965
965
|
const n = {};
|
|
966
966
|
for (const r in e)
|
|
967
|
-
n[r] = new
|
|
967
|
+
n[r] = new f(e[r]).value;
|
|
968
968
|
return s(this, ze).call(this, n);
|
|
969
969
|
}
|
|
970
970
|
}
|
|
971
971
|
const i = this.coefficient.clone();
|
|
972
|
-
if (typeof e == "number" || e instanceof
|
|
972
|
+
if (typeof e == "number" || e instanceof f) {
|
|
973
973
|
const n = {};
|
|
974
|
-
return n[this.variables[0]] = new
|
|
974
|
+
return n[this.variables[0]] = new f(e), this.evaluate(n);
|
|
975
975
|
}
|
|
976
976
|
if (e instanceof vt)
|
|
977
|
-
return new
|
|
977
|
+
return new f().invalid();
|
|
978
978
|
if (typeof e == "object") {
|
|
979
979
|
if (this.variables.length === 0)
|
|
980
980
|
return this.coefficient;
|
|
981
981
|
for (const n in s(this, b)) {
|
|
982
|
-
const r = new
|
|
982
|
+
const r = new f(e[n]);
|
|
983
983
|
i.multiply(r.pow(s(this, b)[n]));
|
|
984
984
|
}
|
|
985
985
|
}
|
|
@@ -1058,7 +1058,7 @@ const I = class I {
|
|
|
1058
1058
|
/**
|
|
1059
1059
|
* Create a one value monom
|
|
1060
1060
|
*/
|
|
1061
|
-
a(this, "one", () => (h(this, T, new
|
|
1061
|
+
a(this, "one", () => (h(this, T, new f().one()), h(this, b, {}), this));
|
|
1062
1062
|
/**
|
|
1063
1063
|
* Get the opposite
|
|
1064
1064
|
* Returns a monom.
|
|
@@ -1078,7 +1078,7 @@ const I = class I {
|
|
|
1078
1078
|
e === void 0 && (e = "x");
|
|
1079
1079
|
const t = this.clone();
|
|
1080
1080
|
let i;
|
|
1081
|
-
return t.hasVariable(e) ? (i = t.degree(e).clone().add(1), t.coefficient = t.coefficient.clone().divide(i), t.setLetter(e, i)) : (t.coefficient.isZero() && (t.coefficient = new
|
|
1081
|
+
return t.hasVariable(e) ? (i = t.degree(e).clone().add(1), t.coefficient = t.coefficient.clone().divide(i), t.setLetter(e, i)) : (t.coefficient.isZero() && (t.coefficient = new f().one()), t.setLetter(e, 1)), t;
|
|
1082
1082
|
});
|
|
1083
1083
|
a(this, "reduce", () => {
|
|
1084
1084
|
this.coefficient.reduce();
|
|
@@ -1097,7 +1097,7 @@ const I = class I {
|
|
|
1097
1097
|
* @param letter (string) Letter to change
|
|
1098
1098
|
* @param pow (number) Power of the setLetter (must be positive integer.
|
|
1099
1099
|
*/
|
|
1100
|
-
a(this, "setLetter", (e, t) => t instanceof
|
|
1100
|
+
a(this, "setLetter", (e, t) => t instanceof f ? (this.hasVariable(e) && t.isZero() && this.removeVariable(e), s(this, b)[e] = t.clone(), this) : this.setLetter(e, new f(t)));
|
|
1101
1101
|
/**
|
|
1102
1102
|
* Return the square root of a monom
|
|
1103
1103
|
*/
|
|
@@ -1123,16 +1123,16 @@ const I = class I {
|
|
|
1123
1123
|
/**
|
|
1124
1124
|
* Create a zero value monom
|
|
1125
1125
|
*/
|
|
1126
|
-
a(this, "zero", () => (h(this, T, new
|
|
1126
|
+
a(this, "zero", () => (h(this, T, new f().zero()), h(this, b, {}), this));
|
|
1127
1127
|
m(this, ze, (e) => {
|
|
1128
1128
|
let t = this.coefficient.value;
|
|
1129
1129
|
if (typeof e == "number") {
|
|
1130
1130
|
const i = {}, n = this.variables[0];
|
|
1131
1131
|
return i[n] = e, s(this, ze).call(this, i);
|
|
1132
1132
|
}
|
|
1133
|
-
if (e instanceof
|
|
1133
|
+
if (e instanceof f) {
|
|
1134
1134
|
const i = {};
|
|
1135
|
-
return i[this.variables[0]] = new
|
|
1135
|
+
return i[this.variables[0]] = new f(e).value, s(this, ze).call(this, i);
|
|
1136
1136
|
}
|
|
1137
1137
|
if (e instanceof vt)
|
|
1138
1138
|
return NaN;
|
|
@@ -1141,7 +1141,7 @@ const I = class I {
|
|
|
1141
1141
|
return this.coefficient.value;
|
|
1142
1142
|
for (const i in s(this, b)) {
|
|
1143
1143
|
const n = e[i];
|
|
1144
|
-
n instanceof
|
|
1144
|
+
n instanceof f ? t *= n.value ** s(this, b)[i].value : t *= n ** s(this, b)[i].value;
|
|
1145
1145
|
}
|
|
1146
1146
|
}
|
|
1147
1147
|
return t;
|
|
@@ -1152,17 +1152,17 @@ const I = class I {
|
|
|
1152
1152
|
return this.zero(), this;
|
|
1153
1153
|
if (i.length === 1) {
|
|
1154
1154
|
const r = i[0];
|
|
1155
|
-
return this.one(), r.tokenType === g.COEFFICIENT ? this.coefficient = new
|
|
1155
|
+
return this.one(), r.tokenType === g.COEFFICIENT ? this.coefficient = new f(r.token) : r.tokenType === g.VARIABLE && this.setLetter(r.token, 1), this;
|
|
1156
1156
|
} else
|
|
1157
1157
|
for (const r of i)
|
|
1158
1158
|
s(this, Mt).call(this, n, r);
|
|
1159
1159
|
return this.one(), this.multiply(n[0]), this;
|
|
1160
1160
|
});
|
|
1161
1161
|
m(this, Mt, (e, t) => {
|
|
1162
|
-
var
|
|
1162
|
+
var u;
|
|
1163
1163
|
let i, n, r, l, c;
|
|
1164
1164
|
if (t.tokenType === g.COEFFICIENT)
|
|
1165
|
-
e.push(new I(new
|
|
1165
|
+
e.push(new I(new f(t.token)));
|
|
1166
1166
|
else if (t.tokenType === g.VARIABLE) {
|
|
1167
1167
|
const d = new I().one();
|
|
1168
1168
|
d.setLetter(t.token, 1), e.push(d.clone());
|
|
@@ -1178,12 +1178,12 @@ const I = class I {
|
|
|
1178
1178
|
n = e.pop() ?? new I().one(), i = e.pop() ?? new I().one(), e.push(i.divide(n));
|
|
1179
1179
|
break;
|
|
1180
1180
|
case "^": {
|
|
1181
|
-
c = ((
|
|
1181
|
+
c = ((u = e.pop()) == null ? void 0 : u.coefficient) ?? new f().one(), r = e.pop() ?? new I().one(), l = r.variables[0], l && r.setLetter(l, c), e.push(r);
|
|
1182
1182
|
break;
|
|
1183
1183
|
}
|
|
1184
1184
|
}
|
|
1185
1185
|
});
|
|
1186
|
-
return h(this, T, new
|
|
1186
|
+
return h(this, T, new f().zero()), h(this, b, {}), e !== void 0 && this.parse(e), this;
|
|
1187
1187
|
}
|
|
1188
1188
|
// -----------------------------------------
|
|
1189
1189
|
/**
|
|
@@ -1191,7 +1191,7 @@ const I = class I {
|
|
|
1191
1191
|
* @param inputStr
|
|
1192
1192
|
*/
|
|
1193
1193
|
parse(e) {
|
|
1194
|
-
return h(this, T, new
|
|
1194
|
+
return h(this, T, new f()), h(this, b, {}), typeof e == "string" ? s(this, kt).call(this, e) : typeof e == "number" ? h(this, T, new f(e)) : e instanceof f ? h(this, T, e.clone()) : e instanceof I && (h(this, T, s(e, T).clone()), A(this, Qe, xt).call(this, e)), this;
|
|
1195
1195
|
}
|
|
1196
1196
|
/**
|
|
1197
1197
|
* Get the coefficient \\(k\\) of the Monom \\(k\\cdot x^{n}\\)
|
|
@@ -1205,7 +1205,7 @@ const I = class I {
|
|
|
1205
1205
|
* @param {Fraction | number | string} F
|
|
1206
1206
|
*/
|
|
1207
1207
|
set coefficient(e) {
|
|
1208
|
-
h(this, T, new
|
|
1208
|
+
h(this, T, new f(e));
|
|
1209
1209
|
}
|
|
1210
1210
|
// Display getter
|
|
1211
1211
|
/**
|
|
@@ -1234,17 +1234,17 @@ const I = class I {
|
|
|
1234
1234
|
for (const n of e)
|
|
1235
1235
|
for (const r of t) {
|
|
1236
1236
|
const l = new I();
|
|
1237
|
-
l.coefficient = new
|
|
1237
|
+
l.coefficient = new f(n), l.literal = r, i.push(l);
|
|
1238
1238
|
}
|
|
1239
1239
|
else if (e.length === 0)
|
|
1240
1240
|
for (const n of t) {
|
|
1241
1241
|
const r = new I();
|
|
1242
|
-
r.coefficient = new
|
|
1242
|
+
r.coefficient = new f().one(), r.literal = n, i.push(r);
|
|
1243
1243
|
}
|
|
1244
1244
|
else
|
|
1245
1245
|
for (const n of e) {
|
|
1246
1246
|
const r = new I();
|
|
1247
|
-
r.coefficient = new
|
|
1247
|
+
r.coefficient = new f(n), i.push(r);
|
|
1248
1248
|
}
|
|
1249
1249
|
return i.length === 0 ? [new I().one()] : i;
|
|
1250
1250
|
}
|
|
@@ -1285,9 +1285,9 @@ const I = class I {
|
|
|
1285
1285
|
*/
|
|
1286
1286
|
set literalStr(e) {
|
|
1287
1287
|
for (const t of [...e.matchAll(/([a-z])\^([+-]?[0-9]+)/g)])
|
|
1288
|
-
t[1] in s(this, b) || (s(this, b)[t[1]] = new
|
|
1288
|
+
t[1] in s(this, b) || (s(this, b)[t[1]] = new f().zero()), s(this, b)[t[1]].add(+t[2]);
|
|
1289
1289
|
for (const t of [...e.matchAll(/([a-z](?!\^))/g)])
|
|
1290
|
-
t[1] in s(this, b) || (s(this, b)[t[1]] = new
|
|
1290
|
+
t[1] in s(this, b) || (s(this, b)[t[1]] = new f().zero()), s(this, b)[t[1]].add(1);
|
|
1291
1291
|
}
|
|
1292
1292
|
get plotFunction() {
|
|
1293
1293
|
let e = "";
|
|
@@ -1326,13 +1326,13 @@ const I = class I {
|
|
|
1326
1326
|
for (let n = 0; n <= this.literal[t].value; n++)
|
|
1327
1327
|
if (e.length === 0) {
|
|
1328
1328
|
const r = {};
|
|
1329
|
-
r[t] = new
|
|
1329
|
+
r[t] = new f(n), i.push(r);
|
|
1330
1330
|
} else
|
|
1331
1331
|
for (const r of e) {
|
|
1332
1332
|
const l = {};
|
|
1333
1333
|
for (const c in r)
|
|
1334
1334
|
l[c] = r[c];
|
|
1335
|
-
l[t] = new
|
|
1335
|
+
l[t] = new f(n), i.push(l);
|
|
1336
1336
|
}
|
|
1337
1337
|
return i;
|
|
1338
1338
|
}
|
|
@@ -1345,12 +1345,12 @@ T = new WeakMap(), b = new WeakMap(), Qe = new WeakSet(), xt = function(e) {
|
|
|
1345
1345
|
if (r.containsRationalPower())
|
|
1346
1346
|
return new I().zero();
|
|
1347
1347
|
const t = new I(), i = U.gcd(...e.map((r) => r.coefficient.numerator)), n = U.lcm(...e.map((r) => r.coefficient.denominator));
|
|
1348
|
-
t.coefficient = new
|
|
1348
|
+
t.coefficient = new f(i, n).reduce();
|
|
1349
1349
|
for (const r of e) {
|
|
1350
1350
|
for (const l in t.literal)
|
|
1351
1351
|
l in r.literal || t.literal[l].zero();
|
|
1352
1352
|
for (const l in r.literal)
|
|
1353
|
-
!t.hasVariable(l) && r.literal[l].isStrictlyPositive() ? t.literal[l] = r.literal[l].clone() : t.literal[l] = new
|
|
1353
|
+
!t.hasVariable(l) && r.literal[l].isStrictlyPositive() ? t.literal[l] = r.literal[l].clone() : t.literal[l] = new f(Math.min(r.literal[l].value, t.literal[l].value));
|
|
1354
1354
|
}
|
|
1355
1355
|
return t;
|
|
1356
1356
|
}), /**
|
|
@@ -1370,8 +1370,8 @@ function yi(o, e = !0) {
|
|
|
1370
1370
|
function Et(o, e, t, i, n) {
|
|
1371
1371
|
return o.map((r, l) => r === e ? t : r);
|
|
1372
1372
|
}
|
|
1373
|
-
var je, y, Ke, ft, Je, dt, Ct, $t,
|
|
1374
|
-
const
|
|
1373
|
+
var je, y, Ke, ft, Je, dt, Ct, Pt, $t, _e, It, pt, St, Bt, Rt, zt, ki, Lt, Vt;
|
|
1374
|
+
const P = class P {
|
|
1375
1375
|
constructor(e, ...t) {
|
|
1376
1376
|
m(this, zt);
|
|
1377
1377
|
m(this, je);
|
|
@@ -1386,13 +1386,13 @@ const $ = class $ {
|
|
|
1386
1386
|
a(this, "parse", (e, ...t) => {
|
|
1387
1387
|
if (h(this, y, []), h(this, je, []), typeof e == "string")
|
|
1388
1388
|
return A(this, zt, ki).call(this, e, ...t);
|
|
1389
|
-
if ((typeof e == "number" || e instanceof
|
|
1389
|
+
if ((typeof e == "number" || e instanceof f || e instanceof M) && t.length === 0)
|
|
1390
1390
|
s(this, y).push(new M(e));
|
|
1391
1391
|
else if (e instanceof M && t.length > 0)
|
|
1392
1392
|
s(this, y).push(new M(e)), t.forEach((i) => {
|
|
1393
1393
|
s(this, y).push(new M(i));
|
|
1394
1394
|
});
|
|
1395
|
-
else if (e instanceof
|
|
1395
|
+
else if (e instanceof P)
|
|
1396
1396
|
for (const i of e.monoms)
|
|
1397
1397
|
s(this, y).push(i.clone());
|
|
1398
1398
|
return this;
|
|
@@ -1401,47 +1401,47 @@ const $ = class $ {
|
|
|
1401
1401
|
* Clone the polynom
|
|
1402
1402
|
*/
|
|
1403
1403
|
a(this, "clone", () => {
|
|
1404
|
-
const e = new
|
|
1404
|
+
const e = new P(), t = [];
|
|
1405
1405
|
for (const i of s(this, y))
|
|
1406
1406
|
t.push(i.clone());
|
|
1407
1407
|
return e.monoms = t, e;
|
|
1408
1408
|
});
|
|
1409
1409
|
a(this, "add", (...e) => {
|
|
1410
1410
|
for (const t of e)
|
|
1411
|
-
t instanceof
|
|
1411
|
+
t instanceof P ? h(this, y, s(this, y).concat(t.monoms)) : t instanceof M ? s(this, y).push(t.clone()) : typeof t == "number" && Number.isSafeInteger(t) ? s(this, y).push(new M(t.toString())) : s(this, y).push(new M(t));
|
|
1412
1412
|
return this.reduce();
|
|
1413
1413
|
});
|
|
1414
1414
|
a(this, "commonMonom", () => {
|
|
1415
1415
|
const e = new M().one(), t = this.gcdNumerator(), i = this.gcdDenominator(), n = this.degree();
|
|
1416
|
-
e.coefficient = new
|
|
1416
|
+
e.coefficient = new f(t, i);
|
|
1417
1417
|
for (const r of this.variables) {
|
|
1418
1418
|
e.setLetter(r, n);
|
|
1419
1419
|
for (const l of s(this, y))
|
|
1420
|
-
if (e.setLetter(r,
|
|
1420
|
+
if (e.setLetter(r, f.min(l.degree(r), e.degree(r))), e.degree(r).isZero())
|
|
1421
1421
|
break;
|
|
1422
1422
|
}
|
|
1423
1423
|
return e;
|
|
1424
1424
|
});
|
|
1425
1425
|
a(this, "degree", (e) => {
|
|
1426
|
-
let t = new
|
|
1426
|
+
let t = new f().zero();
|
|
1427
1427
|
for (const i of s(this, y))
|
|
1428
|
-
t =
|
|
1428
|
+
t = f.max(i.degree(e).value, t);
|
|
1429
1429
|
return t;
|
|
1430
1430
|
});
|
|
1431
1431
|
a(this, "derivative", (e) => {
|
|
1432
|
-
const t = new
|
|
1432
|
+
const t = new P();
|
|
1433
1433
|
for (const i of s(this, y))
|
|
1434
1434
|
t.add(i.derivative(e));
|
|
1435
1435
|
return t.reduce();
|
|
1436
1436
|
});
|
|
1437
1437
|
a(this, "divide", (e) => {
|
|
1438
|
-
if (e instanceof
|
|
1438
|
+
if (e instanceof f)
|
|
1439
1439
|
return s(this, dt).call(this, e);
|
|
1440
1440
|
if (typeof e == "number" && Number.isSafeInteger(e))
|
|
1441
1441
|
return s(this, Ct).call(this, e);
|
|
1442
1442
|
if (e instanceof M)
|
|
1443
|
-
return this.divide(new
|
|
1444
|
-
if (e instanceof
|
|
1443
|
+
return this.divide(new P(e));
|
|
1444
|
+
if (e instanceof P) {
|
|
1445
1445
|
if (e.monoms.length === 1 && e.variables.length === 0)
|
|
1446
1446
|
return s(this, dt).call(this, e.monoms[0].coefficient);
|
|
1447
1447
|
{
|
|
@@ -1450,7 +1450,7 @@ const $ = class $ {
|
|
|
1450
1450
|
return h(this, y, t.monoms), this;
|
|
1451
1451
|
}
|
|
1452
1452
|
} else if (typeof e == "string")
|
|
1453
|
-
return this.divide(new
|
|
1453
|
+
return this.divide(new P(e));
|
|
1454
1454
|
throw new Error(`Cannot divide by ${e}`);
|
|
1455
1455
|
});
|
|
1456
1456
|
a(this, "empty", () => (h(this, y, []), this));
|
|
@@ -1460,22 +1460,22 @@ const $ = class $ {
|
|
|
1460
1460
|
* returns {quotient: Polynom, reminder: Polynom}
|
|
1461
1461
|
*/
|
|
1462
1462
|
a(this, "euclidean", (e) => {
|
|
1463
|
-
const t = e.variables[0], i = new
|
|
1463
|
+
const t = e.variables[0], i = new P().zero(), n = this.clone().reorder(t);
|
|
1464
1464
|
if (e.variables.length === 0)
|
|
1465
1465
|
return {
|
|
1466
1466
|
quotient: this.clone().divide(e).reduce(),
|
|
1467
|
-
reminder: new
|
|
1467
|
+
reminder: new P().zero()
|
|
1468
1468
|
};
|
|
1469
1469
|
const r = e.monomByDegree(void 0, t), l = e.degree(t);
|
|
1470
|
-
let c,
|
|
1471
|
-
for (; n.degree(t).isGeq(l) &&
|
|
1470
|
+
let c, u = this.degree(t).value * 2;
|
|
1471
|
+
for (; n.degree(t).isGeq(l) && u > 0 && (u--, c = n.monomByDegree(void 0, t).clone().divide(r), !(!c.isZero() && (i.add(c), n.subtract(e.clone().multiply(c)).reduce(), c.degree(t).isZero()))); )
|
|
1472
1472
|
;
|
|
1473
1473
|
return i.reduce(), n.reduce(), { quotient: i, reminder: n };
|
|
1474
1474
|
});
|
|
1475
1475
|
a(this, "evaluate", (e, t) => {
|
|
1476
1476
|
if (t)
|
|
1477
|
-
return s(this,
|
|
1478
|
-
const i = new
|
|
1477
|
+
return s(this, Pt).call(this, e);
|
|
1478
|
+
const i = new f().zero();
|
|
1479
1479
|
return s(this, y).forEach((n) => {
|
|
1480
1480
|
i.add(n.evaluate(e, t));
|
|
1481
1481
|
}), i;
|
|
@@ -1489,7 +1489,7 @@ const $ = class $ {
|
|
|
1489
1489
|
let t = [], i = this.clone().reorder();
|
|
1490
1490
|
const n = i.commonMonom();
|
|
1491
1491
|
if (i.monomByDegree().coefficient.isStrictlyNegative() && n.coefficient.isStrictlyPositive() && !n.isOne() && n.opposite(), !n.isOne()) {
|
|
1492
|
-
const c = new
|
|
1492
|
+
const c = new P(n);
|
|
1493
1493
|
t = [c.clone()], i = i.euclidean(c).quotient;
|
|
1494
1494
|
}
|
|
1495
1495
|
let r = i.degree().clone().multiply(2).value, l = 1;
|
|
@@ -1503,12 +1503,12 @@ const $ = class $ {
|
|
|
1503
1503
|
} else {
|
|
1504
1504
|
let c = s(this, It).call(this, i, l, e ?? "x");
|
|
1505
1505
|
for (l = i.degree(e).value; c.length > 0; ) {
|
|
1506
|
-
const
|
|
1507
|
-
if (!i.isDividableBy(
|
|
1506
|
+
const u = c[0];
|
|
1507
|
+
if (!i.isDividableBy(u))
|
|
1508
1508
|
c.shift();
|
|
1509
1509
|
else {
|
|
1510
|
-
const d = i.euclidean(
|
|
1511
|
-
t.push(
|
|
1510
|
+
const d = i.euclidean(u);
|
|
1511
|
+
t.push(u), i = d.quotient.clone(), c = c.filter((p) => {
|
|
1512
1512
|
const w = i.monoms[0], V = i.monoms[i.monoms.length - 1], ce = p.monoms[0], ue = p.monoms[p.monoms.length - 1];
|
|
1513
1513
|
return V.isDivisible(ue) ? w.isDivisible(ce) : !1;
|
|
1514
1514
|
});
|
|
@@ -1535,7 +1535,7 @@ const $ = class $ {
|
|
|
1535
1535
|
a(this, "getZeroes", () => this.degree().isZero() ? [] : (this.roots = new At(this.clone()).solve(), this.roots));
|
|
1536
1536
|
a(this, "integrate", (e, t, i = "x") => {
|
|
1537
1537
|
const n = this.primitive(i), r = {}, l = {};
|
|
1538
|
-
return r[i] = new
|
|
1538
|
+
return r[i] = new f(e), l[i] = new f(t), n.evaluate(l).subtract(n.evaluate(r));
|
|
1539
1539
|
});
|
|
1540
1540
|
a(this, "isDeveloped", (e) => {
|
|
1541
1541
|
let t;
|
|
@@ -1543,7 +1543,7 @@ const $ = class $ {
|
|
|
1543
1543
|
if (i.includes("(") || i.includes(")"))
|
|
1544
1544
|
return !1;
|
|
1545
1545
|
try {
|
|
1546
|
-
t = new
|
|
1546
|
+
t = new P(e);
|
|
1547
1547
|
} catch {
|
|
1548
1548
|
return !1;
|
|
1549
1549
|
}
|
|
@@ -1552,7 +1552,7 @@ const $ = class $ {
|
|
|
1552
1552
|
a(this, "isDividableBy", (e) => {
|
|
1553
1553
|
if (e.degree().isOne()) {
|
|
1554
1554
|
const t = e.getZeroes()[0];
|
|
1555
|
-
return t.exact instanceof
|
|
1555
|
+
return t.exact instanceof f ? this.evaluate(t.exact).isZero() : !1;
|
|
1556
1556
|
} else {
|
|
1557
1557
|
const { reminder: t } = this.euclidean(e);
|
|
1558
1558
|
return t.isZero();
|
|
@@ -1563,7 +1563,7 @@ const $ = class $ {
|
|
|
1563
1563
|
a(this, "isReduced", (e) => {
|
|
1564
1564
|
if (!this.isDeveloped(e))
|
|
1565
1565
|
return !1;
|
|
1566
|
-
const t = new
|
|
1566
|
+
const t = new P(e);
|
|
1567
1567
|
if (t.monoms.length > this.monoms.length)
|
|
1568
1568
|
return !1;
|
|
1569
1569
|
for (const i of t.monoms)
|
|
@@ -1582,11 +1582,11 @@ const $ = class $ {
|
|
|
1582
1582
|
});
|
|
1583
1583
|
a(this, "limitToInfinity", (e) => {
|
|
1584
1584
|
const t = this.monomByDegree(void 0, e), i = t.coefficient.sign(), n = t.degree(e);
|
|
1585
|
-
return n.isStrictlyPositive() ? i === 1 ? new
|
|
1585
|
+
return n.isStrictlyPositive() ? i === 1 ? new f().infinite() : new f().infinite().opposite() : n.isZero() ? t.coefficient : new f().zero();
|
|
1586
1586
|
});
|
|
1587
1587
|
a(this, "limitToNegativeInfinity", (e) => {
|
|
1588
1588
|
const t = this.monomByDegree(void 0, e), i = t.coefficient.sign(), n = t.degree(e);
|
|
1589
|
-
return n.isStrictlyPositive() ? i === -1 ? new
|
|
1589
|
+
return n.isStrictlyPositive() ? i === -1 ? new f().infinite() : new f().infinite().opposite() : n.isZero() ? t.coefficient : new f().zero();
|
|
1590
1590
|
});
|
|
1591
1591
|
a(this, "monomByDegree", (e, t) => {
|
|
1592
1592
|
if (e === void 0)
|
|
@@ -1613,7 +1613,7 @@ const $ = class $ {
|
|
|
1613
1613
|
r.degree(t).isEqual(e) && i.push(r.clone());
|
|
1614
1614
|
return i;
|
|
1615
1615
|
});
|
|
1616
|
-
a(this, "multiply", (e) => e instanceof
|
|
1616
|
+
a(this, "multiply", (e) => e instanceof P ? s(this, Rt).call(this, e) : e instanceof f ? s(this, pt).call(this, e) : e instanceof M ? s(this, Bt).call(this, e) : Number.isSafeInteger(e) && typeof e == "number" ? s(this, St).call(this, e) : this);
|
|
1617
1617
|
a(this, "one", () => (h(this, y, []), s(this, y).push(new M().one()), this));
|
|
1618
1618
|
// ------------------------------------------
|
|
1619
1619
|
a(this, "opposite", () => (h(this, y, s(this, y).map((e) => e.opposite())), this));
|
|
@@ -1623,14 +1623,14 @@ const $ = class $ {
|
|
|
1623
1623
|
if (e < 0)
|
|
1624
1624
|
return this.zero();
|
|
1625
1625
|
if (e === 0)
|
|
1626
|
-
return new
|
|
1626
|
+
return new P();
|
|
1627
1627
|
const t = this.clone();
|
|
1628
1628
|
for (let i = 1; i < e; i++)
|
|
1629
1629
|
this.multiply(t);
|
|
1630
1630
|
return this.reduce();
|
|
1631
1631
|
});
|
|
1632
1632
|
a(this, "primitive", (e) => {
|
|
1633
|
-
const t = new
|
|
1633
|
+
const t = new P();
|
|
1634
1634
|
for (const i of s(this, y))
|
|
1635
1635
|
t.add(i.primitive(e));
|
|
1636
1636
|
return t;
|
|
@@ -1645,7 +1645,7 @@ const $ = class $ {
|
|
|
1645
1645
|
h(this, y, s(this, y).filter((t) => !t.coefficient.isZero()));
|
|
1646
1646
|
for (const t of s(this, y))
|
|
1647
1647
|
t.coefficient.reduce();
|
|
1648
|
-
return this.length === 0 ? new
|
|
1648
|
+
return this.length === 0 ? new P().zero() : this.reorder();
|
|
1649
1649
|
});
|
|
1650
1650
|
// ------------------------------------------
|
|
1651
1651
|
a(this, "reorder", (e = "x", t) => {
|
|
@@ -1656,8 +1656,8 @@ const $ = class $ {
|
|
|
1656
1656
|
if (l !== c)
|
|
1657
1657
|
return t ? l - c : c - l;
|
|
1658
1658
|
if (i.length > 0)
|
|
1659
|
-
for (const
|
|
1660
|
-
const d = n.degree(
|
|
1659
|
+
for (const u of i) {
|
|
1660
|
+
const d = n.degree(u).value, p = r.degree(u).value;
|
|
1661
1661
|
if (d !== p)
|
|
1662
1662
|
return t ? d - p : p - d;
|
|
1663
1663
|
}
|
|
@@ -1671,14 +1671,14 @@ const $ = class $ {
|
|
|
1671
1671
|
*/
|
|
1672
1672
|
a(this, "replaceBy", (e, t) => {
|
|
1673
1673
|
let i;
|
|
1674
|
-
const n = new
|
|
1674
|
+
const n = new P().zero();
|
|
1675
1675
|
for (const r of this.monoms)
|
|
1676
1676
|
!r.hasVariable(e) || r.literal[e].isZero() ? n.add(r.clone()) : (i = r.literal[e].clone(), r.removeVariable(e), n.add(t.clone().pow(Math.abs(i.numerator)).multiply(r)));
|
|
1677
1677
|
return h(this, y, n.reduce().monoms), this;
|
|
1678
1678
|
});
|
|
1679
1679
|
a(this, "subtract", (...e) => {
|
|
1680
1680
|
for (const t of e)
|
|
1681
|
-
t instanceof
|
|
1681
|
+
t instanceof P ? this.add(t.clone().opposite()) : t instanceof M ? s(this, y).push(t.clone().opposite()) : s(this, y).push(new M(t).opposite());
|
|
1682
1682
|
return this.reduce();
|
|
1683
1683
|
});
|
|
1684
1684
|
/**
|
|
@@ -1704,31 +1704,31 @@ const $ = class $ {
|
|
|
1704
1704
|
return this;
|
|
1705
1705
|
});
|
|
1706
1706
|
m(this, Ct, (e) => {
|
|
1707
|
-
const t = new
|
|
1707
|
+
const t = new f(e);
|
|
1708
1708
|
for (const i of s(this, y))
|
|
1709
1709
|
i.coefficient.divide(t);
|
|
1710
1710
|
return this;
|
|
1711
1711
|
});
|
|
1712
|
-
m(this,
|
|
1712
|
+
m(this, Pt, (e) => {
|
|
1713
1713
|
let t = 0;
|
|
1714
1714
|
return s(this, y).forEach((i) => {
|
|
1715
1715
|
t += i.evaluate(e, !0);
|
|
1716
1716
|
}), t;
|
|
1717
1717
|
});
|
|
1718
|
-
m(this,
|
|
1718
|
+
m(this, $t, (e) => {
|
|
1719
1719
|
var w;
|
|
1720
|
-
let t, i, n, r, l, c,
|
|
1720
|
+
let t, i, n, r, l, c, u, d, p;
|
|
1721
1721
|
if (this.numberOfVars === 1)
|
|
1722
|
-
return n = this.monomByDegree(2, e).coefficient, r = this.monomByDegree(1, e).coefficient, l = this.monomByDegree(0, e).coefficient, c = r.clone().pow(2).subtract(n.clone().multiply(l).multiply(4)), c.isZero() ? (
|
|
1723
|
-
new
|
|
1724
|
-
new
|
|
1722
|
+
return n = this.monomByDegree(2, e).coefficient, r = this.monomByDegree(1, e).coefficient, l = this.monomByDegree(0, e).coefficient, c = r.clone().pow(2).subtract(n.clone().multiply(l).multiply(4)), c.isZero() ? (u = r.clone().opposite().divide(n.clone().multiply(2)), t = new P(e).subtract(u.display).multiply(u.denominator), i = new P(e).subtract(u.display).multiply(u.denominator), p = n.divide(u.denominator).divide(u.denominator), p.isOne() ? [t, i] : [new P(p.display), t, i]) : c.isPositive() && c.isSquare() ? (u = r.clone().opposite().add(c.clone().sqrt()).divide(n.clone().multiply(2)), d = r.clone().opposite().subtract(c.clone().sqrt()).divide(n.clone().multiply(2)), p = n.divide(u.denominator).divide(d.denominator), p.isOne() ? [
|
|
1723
|
+
new P(e).subtract(u.display).multiply(u.denominator),
|
|
1724
|
+
new P(e).subtract(d.display).multiply(d.denominator)
|
|
1725
1725
|
] : [
|
|
1726
|
-
new
|
|
1727
|
-
new
|
|
1728
|
-
new
|
|
1726
|
+
new P(p.display),
|
|
1727
|
+
new P(e).subtract(u.display).multiply(u.denominator),
|
|
1728
|
+
new P(e).subtract(d.display).multiply(d.denominator)
|
|
1729
1729
|
]) : [this.clone()];
|
|
1730
1730
|
if (n = this.monomByDegree(2, e), r = this.monomByDegree(1, e), l = this.monomByDegree(0, e), n.isLiteralSquare() && l.isLiteralSquare() && r.clone().pow(2).isSameAs(n.clone().multiply(l))) {
|
|
1731
|
-
const V = new
|
|
1731
|
+
const V = new P("x", n.coefficient, r.coefficient, l.coefficient), ce = s(w = V, $t).call(w, "x"), ue = [];
|
|
1732
1732
|
let fe;
|
|
1733
1733
|
if (ce.length >= 2) {
|
|
1734
1734
|
for (const ye of ce)
|
|
@@ -1751,8 +1751,8 @@ const $ = class $ {
|
|
|
1751
1751
|
m(this, It, (e, t, i) => {
|
|
1752
1752
|
const n = e.monoms[0].dividers, r = e.monoms[e.monoms.length - 1].dividers, l = [];
|
|
1753
1753
|
return n.forEach((c) => {
|
|
1754
|
-
c.degree(i).isLeq(t) && r.forEach((
|
|
1755
|
-
c.degree(i).isNotEqual(
|
|
1754
|
+
c.degree(i).isLeq(t) && r.forEach((u) => {
|
|
1755
|
+
c.degree(i).isNotEqual(u.degree(i)) && (l.push(new P(c, u)), l.push(new P(c, u.clone().opposite())));
|
|
1756
1756
|
});
|
|
1757
1757
|
}), l;
|
|
1758
1758
|
});
|
|
@@ -1761,7 +1761,7 @@ const $ = class $ {
|
|
|
1761
1761
|
t.coefficient.multiply(e);
|
|
1762
1762
|
return this.reduce();
|
|
1763
1763
|
});
|
|
1764
|
-
m(this, St, (e) => s(this, pt).call(this, new
|
|
1764
|
+
m(this, St, (e) => s(this, pt).call(this, new f(e)));
|
|
1765
1765
|
m(this, Bt, (e) => {
|
|
1766
1766
|
for (const t of s(this, y))
|
|
1767
1767
|
t.multiply(e);
|
|
@@ -1789,10 +1789,10 @@ const $ = class $ {
|
|
|
1789
1789
|
m(this, Vt, (e, t) => {
|
|
1790
1790
|
switch (t.tokenType) {
|
|
1791
1791
|
case g.COEFFICIENT:
|
|
1792
|
-
e.push(new
|
|
1792
|
+
e.push(new P(t.token));
|
|
1793
1793
|
break;
|
|
1794
1794
|
case g.VARIABLE:
|
|
1795
|
-
e.push(new
|
|
1795
|
+
e.push(new P().add(new M(t.token)));
|
|
1796
1796
|
break;
|
|
1797
1797
|
case g.CONSTANT:
|
|
1798
1798
|
console.log("Actually, not supported - will be added later !");
|
|
@@ -1849,11 +1849,11 @@ const $ = class $ {
|
|
|
1849
1849
|
const t = "x";
|
|
1850
1850
|
return e.reverse().forEach((i, n) => {
|
|
1851
1851
|
const r = new M();
|
|
1852
|
-
r.coefficient = new
|
|
1852
|
+
r.coefficient = new f(i), r.setLetter(t, n), s(this, y).push(r);
|
|
1853
1853
|
}), this;
|
|
1854
1854
|
}
|
|
1855
1855
|
getCoefficients() {
|
|
1856
|
-
const e = this.clone().reorder(), t = this.degree().value + 1, i = new Array(t).fill(new
|
|
1856
|
+
const e = this.clone().reorder(), t = this.degree().value + 1, i = new Array(t).fill(new f(0));
|
|
1857
1857
|
return e.monoms.forEach((n) => {
|
|
1858
1858
|
const r = t - n.degree().value - 1;
|
|
1859
1859
|
i[r] = n.coefficient.clone();
|
|
@@ -1930,7 +1930,7 @@ const $ = class $ {
|
|
|
1930
1930
|
return this.getZeroes();
|
|
1931
1931
|
}
|
|
1932
1932
|
};
|
|
1933
|
-
je = new WeakMap(), y = new WeakMap(), Ke = new WeakMap(), ft = new WeakMap(), Je = new WeakMap(), dt = new WeakMap(), Ct = new WeakMap(),
|
|
1933
|
+
je = new WeakMap(), y = new WeakMap(), Ke = new WeakMap(), ft = new WeakMap(), Je = new WeakMap(), dt = new WeakMap(), Ct = new WeakMap(), Pt = new WeakMap(), $t = new WeakMap(), _e = new WeakMap(), It = new WeakMap(), pt = new WeakMap(), St = new WeakMap(), Bt = new WeakMap(), Rt = new WeakMap(), zt = new WeakSet(), ki = function(e, ...t) {
|
|
1934
1934
|
if (t.length === 0) {
|
|
1935
1935
|
if (e = "" + e, e !== "" && !isNaN(Number(e))) {
|
|
1936
1936
|
this.empty();
|
|
@@ -1940,7 +1940,7 @@ je = new WeakMap(), y = new WeakMap(), Ke = new WeakMap(), ft = new WeakMap(), J
|
|
|
1940
1940
|
return s(this, Lt).call(this, e);
|
|
1941
1941
|
} else if (/^[a-z]+/.test(e)) {
|
|
1942
1942
|
this.empty();
|
|
1943
|
-
const i = t.map((n) => new
|
|
1943
|
+
const i = t.map((n) => new f(n));
|
|
1944
1944
|
if (e.length > 1) {
|
|
1945
1945
|
const n = e.split("");
|
|
1946
1946
|
if (n.length < t.length - 2)
|
|
@@ -1961,7 +1961,7 @@ je = new WeakMap(), y = new WeakMap(), Ke = new WeakMap(), ft = new WeakMap(), J
|
|
|
1961
1961
|
} else
|
|
1962
1962
|
return this.zero();
|
|
1963
1963
|
}, Lt = new WeakMap(), Vt = new WeakMap();
|
|
1964
|
-
let O =
|
|
1964
|
+
let O = P;
|
|
1965
1965
|
var q, k, oe, Dt, et, Zt;
|
|
1966
1966
|
const Ne = class Ne {
|
|
1967
1967
|
constructor(e, t, i) {
|
|
@@ -1985,7 +1985,7 @@ const Ne = class Ne {
|
|
|
1985
1985
|
* Get the degree of the equation
|
|
1986
1986
|
* @param letter
|
|
1987
1987
|
*/
|
|
1988
|
-
a(this, "degree", (e) =>
|
|
1988
|
+
a(this, "degree", (e) => f.max(s(this, q).degree(e), s(this, k).degree(e)));
|
|
1989
1989
|
/**
|
|
1990
1990
|
* divide an equation by a given value (transformed as a fraction)
|
|
1991
1991
|
*
|
|
@@ -2001,7 +2001,7 @@ const Ne = class Ne {
|
|
|
2001
2001
|
* @returns {Equation}
|
|
2002
2002
|
*/
|
|
2003
2003
|
a(this, "divide", (e) => {
|
|
2004
|
-
const t = new
|
|
2004
|
+
const t = new f(e);
|
|
2005
2005
|
return t.isZero() ? this : this.multiply(t.inverse());
|
|
2006
2006
|
});
|
|
2007
2007
|
/**
|
|
@@ -2054,7 +2054,7 @@ const Ne = class Ne {
|
|
|
2054
2054
|
* @param value
|
|
2055
2055
|
*/
|
|
2056
2056
|
a(this, "multiply", (e) => {
|
|
2057
|
-
const t = new
|
|
2057
|
+
const t = new f(e);
|
|
2058
2058
|
return s(this, q).multiply(t), s(this, k).multiply(t), s(this, oe) !== "=" && t.sign() === -1 && s(this, Zt).call(this), this;
|
|
2059
2059
|
});
|
|
2060
2060
|
a(this, "opposite", () => (h(this, q, s(this, q).opposite()), h(this, k, s(this, k).opposite()), this));
|
|
@@ -2202,7 +2202,7 @@ const ve = class ve {
|
|
|
2202
2202
|
m(this, Ae);
|
|
2203
2203
|
m(this, be);
|
|
2204
2204
|
m(this, tt, !1);
|
|
2205
|
-
return e instanceof ve ? (h(this, Ae, e.polynom.clone()), h(this, be, e.power.clone()), t !== void 0 && s(this, be).multiply(new
|
|
2205
|
+
return e instanceof ve ? (h(this, Ae, e.polynom.clone()), h(this, be, e.power.clone()), t !== void 0 && s(this, be).multiply(new f(t))) : e !== void 0 ? (h(this, Ae, new O(e)), h(this, be, new f(t ?? 1))) : (h(this, Ae, new O()), h(this, be, new f(1))), h(this, Te, 1), this;
|
|
2206
2206
|
}
|
|
2207
2207
|
parse() {
|
|
2208
2208
|
throw new Error("Method not implemented.");
|
|
@@ -2211,7 +2211,7 @@ const ve = class ve {
|
|
|
2211
2211
|
return new ve(this);
|
|
2212
2212
|
}
|
|
2213
2213
|
fromPolynom(e) {
|
|
2214
|
-
return h(this, Ae, new O(e)), h(this, be, new
|
|
2214
|
+
return h(this, Ae, new O(e)), h(this, be, new f(1)), this;
|
|
2215
2215
|
}
|
|
2216
2216
|
get tex() {
|
|
2217
2217
|
const e = this.power.numerator, t = this.power.denominator;
|
|
@@ -2301,7 +2301,7 @@ const ve = class ve {
|
|
|
2301
2301
|
return s(this, be);
|
|
2302
2302
|
}
|
|
2303
2303
|
set power(e) {
|
|
2304
|
-
h(this, be, new
|
|
2304
|
+
h(this, be, new f(e));
|
|
2305
2305
|
}
|
|
2306
2306
|
primitive() {
|
|
2307
2307
|
throw new Error("Method not implemented.");
|
|
@@ -2337,28 +2337,28 @@ const ve = class ve {
|
|
|
2337
2337
|
};
|
|
2338
2338
|
Te = new WeakMap(), Ae = new WeakMap(), be = new WeakMap(), tt = new WeakMap();
|
|
2339
2339
|
let se = ve;
|
|
2340
|
-
var lt = /* @__PURE__ */ ((o) => (o[o.ROOT = 0] = "ROOT", o[o.POWER = 1] = "POWER", o))(lt || {}), D,
|
|
2340
|
+
var lt = /* @__PURE__ */ ((o) => (o[o.ROOT = 0] = "ROOT", o[o.POWER = 1] = "POWER", o))(lt || {}), D, Pe, Ft, jt;
|
|
2341
2341
|
const Xe = class Xe {
|
|
2342
2342
|
constructor(...e) {
|
|
2343
2343
|
m(this, D);
|
|
2344
2344
|
// Determine the letters in the linear system, usually ['x', 'y']
|
|
2345
|
-
m(this,
|
|
2345
|
+
m(this, Pe);
|
|
2346
2346
|
a(this, "parse", (...e) => (h(this, D, e.map((t) => new H(t))), s(this, Ft).call(this), this));
|
|
2347
2347
|
a(this, "clone", () => new Xe().parse(...s(this, D).map((e) => e.clone())));
|
|
2348
2348
|
a(this, "buildTex", (e, t) => {
|
|
2349
2349
|
let i, n, r = [];
|
|
2350
2350
|
const l = [];
|
|
2351
|
-
for (const
|
|
2352
|
-
r = r.concat(
|
|
2351
|
+
for (const u of e)
|
|
2352
|
+
r = r.concat(u.letters());
|
|
2353
2353
|
r = [...new Set(r)], r.sort();
|
|
2354
|
-
for (let
|
|
2355
|
-
const d = e[
|
|
2354
|
+
for (let u = 0; u < e.length; u++) {
|
|
2355
|
+
const d = e[u];
|
|
2356
2356
|
i = [];
|
|
2357
2357
|
for (const p of r)
|
|
2358
2358
|
n = d.left.monomByLetter(p), i.length === 0 ? i.push(n.isZero() ? "" : n.tex) : i.push(n.isZero() ? "" : (n.coefficient.sign() === 1 ? "+" : "") + n.tex);
|
|
2359
|
-
if (i.push("="), i.push(d.right.tex), (t == null ? void 0 : t[
|
|
2359
|
+
if (i.push("="), i.push(d.right.tex), (t == null ? void 0 : t[u]) !== void 0) {
|
|
2360
2360
|
i[i.length - 1] = i[i.length - 1] + " \\phantom{\\quad}";
|
|
2361
|
-
for (const p of t[
|
|
2361
|
+
for (const p of t[u])
|
|
2362
2362
|
i.push(`\\ \\cdot\\ ${p.startsWith("-") ? "\\left(" + p + "\\right)" : p}`);
|
|
2363
2363
|
}
|
|
2364
2364
|
l.push(i.join("&"));
|
|
@@ -2367,7 +2367,7 @@ const Xe = class Xe {
|
|
|
2367
2367
|
return t !== void 0 && t.length > 0 && (c = t[0].length), `\\left\\{\\begin{array}{${"r".repeat(r.length)}cl ${"|l".repeat(c)}}${l.join("\\\\ ")}\\end{array}\\right.`;
|
|
2368
2368
|
});
|
|
2369
2369
|
a(this, "mergeEquations", (e, t, i, n) => {
|
|
2370
|
-
const r = e.clone().multiply(new
|
|
2370
|
+
const r = e.clone().multiply(new f(i)), l = t.clone().multiply(new f(n));
|
|
2371
2371
|
return r.left.add(l.left), r.right.add(l.right), r;
|
|
2372
2372
|
});
|
|
2373
2373
|
// ------------------------------------------
|
|
@@ -2379,21 +2379,28 @@ const Xe = class Xe {
|
|
|
2379
2379
|
a(this, "solveMatrix", () => {
|
|
2380
2380
|
const [e, t] = this.matrix, i = e.map((n, r) => [...n, t[r]]);
|
|
2381
2381
|
for (let n = 0; n < e.length; n++) {
|
|
2382
|
-
|
|
2382
|
+
let r = i[n][n].clone();
|
|
2383
|
+
if (r.isZero()) {
|
|
2384
|
+
const l = i.find((c, u) => u > n && !c[n].isZero());
|
|
2385
|
+
if (l)
|
|
2386
|
+
i[n].forEach((c, u) => c.add(l[u])), r = i[n][n].clone();
|
|
2387
|
+
else
|
|
2388
|
+
throw new Error("Unsolvable...");
|
|
2389
|
+
}
|
|
2383
2390
|
i[n] = i[n].map((l) => l.divide(r));
|
|
2384
2391
|
for (let l = 0; l < e.length; l++) {
|
|
2385
2392
|
if (l === n)
|
|
2386
2393
|
continue;
|
|
2387
2394
|
const c = i[l][n].clone().opposite();
|
|
2388
|
-
for (let
|
|
2389
|
-
i[l][
|
|
2390
|
-
if (i[l].slice(0, i[l].length - 1).every((
|
|
2391
|
-
return i[l][i[l].length - 1].isZero() ? [new
|
|
2395
|
+
for (let u = 0; u < i[l].length; u++)
|
|
2396
|
+
i[l][u].add(i[n][u].clone().multiply(c));
|
|
2397
|
+
if (i[l].slice(0, i[l].length - 1).every((u) => u.isZero()))
|
|
2398
|
+
return i[l][i[l].length - 1].isZero() ? [new f().infinite()] : [];
|
|
2392
2399
|
}
|
|
2393
2400
|
}
|
|
2394
2401
|
return i.map((n) => n[n.length - 1]);
|
|
2395
2402
|
});
|
|
2396
|
-
m(this, Ft, () => (h(this,
|
|
2403
|
+
m(this, Ft, () => (h(this, Pe, s(this, D).reduce((e, t) => [.../* @__PURE__ */ new Set([...e, ...t.variables])], [])), s(this, Pe).sort(), this));
|
|
2397
2404
|
m(this, jt, () => {
|
|
2398
2405
|
const e = [], t = [];
|
|
2399
2406
|
for (const i of s(this, D)) {
|
|
@@ -2406,7 +2413,7 @@ const Xe = class Xe {
|
|
|
2406
2413
|
}
|
|
2407
2414
|
return [e, t];
|
|
2408
2415
|
});
|
|
2409
|
-
return h(this, D, []), h(this,
|
|
2416
|
+
return h(this, D, []), h(this, Pe, []), e.length > 0 && this.parse(...e), this;
|
|
2410
2417
|
}
|
|
2411
2418
|
static fromMatrix(e, t = "xyz") {
|
|
2412
2419
|
const i = e[0].length;
|
|
@@ -2436,7 +2443,7 @@ const Xe = class Xe {
|
|
|
2436
2443
|
return this;
|
|
2437
2444
|
}
|
|
2438
2445
|
degree(e) {
|
|
2439
|
-
return
|
|
2446
|
+
return f.max(...s(this, D).map((t) => t.degree(e)));
|
|
2440
2447
|
}
|
|
2441
2448
|
get display() {
|
|
2442
2449
|
return this.tex + "as display";
|
|
@@ -2452,7 +2459,7 @@ const Xe = class Xe {
|
|
|
2452
2459
|
throw new Error("Method not implemented.");
|
|
2453
2460
|
}
|
|
2454
2461
|
hasVariable(e) {
|
|
2455
|
-
return s(this,
|
|
2462
|
+
return s(this, Pe).includes(e);
|
|
2456
2463
|
}
|
|
2457
2464
|
isEqual(e) {
|
|
2458
2465
|
return this.equations.every((t, i) => t.isEqual(e.equations[i]));
|
|
@@ -2501,14 +2508,14 @@ const Xe = class Xe {
|
|
|
2501
2508
|
return this.buildTex(e.equations);
|
|
2502
2509
|
}
|
|
2503
2510
|
get variables() {
|
|
2504
|
-
return s(this,
|
|
2511
|
+
return s(this, Pe);
|
|
2505
2512
|
}
|
|
2506
2513
|
set variables(e) {
|
|
2507
2514
|
const t = typeof e == "string" ? e.split("") : [...e];
|
|
2508
|
-
t.sort(), h(this,
|
|
2515
|
+
t.sort(), h(this, Pe, t);
|
|
2509
2516
|
}
|
|
2510
2517
|
};
|
|
2511
|
-
D = new WeakMap(),
|
|
2518
|
+
D = new WeakMap(), Pe = new WeakMap(), Ft = new WeakMap(), jt = new WeakMap();
|
|
2512
2519
|
let ti = Xe;
|
|
2513
2520
|
var Oe, mt, ii;
|
|
2514
2521
|
class ss {
|
|
@@ -2629,7 +2636,7 @@ Oe = new WeakMap(), mt = new WeakSet(), ii = function(e, t) {
|
|
|
2629
2636
|
case "&":
|
|
2630
2637
|
if (i.length >= 2) {
|
|
2631
2638
|
const l = i.pop(), c = i.pop();
|
|
2632
|
-
c && l && i.push(new Set([...c].filter((
|
|
2639
|
+
c && l && i.push(new Set([...c].filter((u) => l.has(u))));
|
|
2633
2640
|
}
|
|
2634
2641
|
break;
|
|
2635
2642
|
case "|":
|
|
@@ -2641,7 +2648,7 @@ Oe = new WeakMap(), mt = new WeakSet(), ii = function(e, t) {
|
|
|
2641
2648
|
case "-":
|
|
2642
2649
|
if (i.length >= 2) {
|
|
2643
2650
|
const l = i.pop(), c = i.pop();
|
|
2644
|
-
c && l && i.push(new Set([...c].filter((
|
|
2651
|
+
c && l && i.push(new Set([...c].filter((u) => !l.has(u))));
|
|
2645
2652
|
}
|
|
2646
2653
|
break;
|
|
2647
2654
|
case "!":
|
|
@@ -2715,8 +2722,8 @@ const X = class X {
|
|
|
2715
2722
|
let n;
|
|
2716
2723
|
if (i.some((c) => c.factors.length > 0)) {
|
|
2717
2724
|
const c = X.lcm(...i);
|
|
2718
|
-
t.forEach((
|
|
2719
|
-
|
|
2725
|
+
t.forEach((u, d) => {
|
|
2726
|
+
u.multiply(c.clone().divide(i[d]));
|
|
2720
2727
|
}), n = c;
|
|
2721
2728
|
}
|
|
2722
2729
|
const r = X.gcd(...t), l = new O(0).add(
|
|
@@ -2734,7 +2741,7 @@ const X = class X {
|
|
|
2734
2741
|
return h(this, it, lt.ROOT), this;
|
|
2735
2742
|
}
|
|
2736
2743
|
degree(e) {
|
|
2737
|
-
return s(this, N).reduce((t, i) => t.add(i.degree(e)), new
|
|
2744
|
+
return s(this, N).reduce((t, i) => t.add(i.degree(e)), new f("0"));
|
|
2738
2745
|
}
|
|
2739
2746
|
get denominator() {
|
|
2740
2747
|
return new X(
|
|
@@ -2765,15 +2772,15 @@ const X = class X {
|
|
|
2765
2772
|
return h(this, N, s(this, N).concat(e.clone().factors.map((t) => t.inverse()))), this;
|
|
2766
2773
|
}
|
|
2767
2774
|
evaluate(e, t) {
|
|
2768
|
-
return t ? s(this, N).reduce((i, n) => i * n.evaluate(e, t), 1) : s(this, N).reduce((i, n) => i.multiply(n.evaluate(e)), new
|
|
2775
|
+
return t ? s(this, N).reduce((i, n) => i * n.evaluate(e, t), 1) : s(this, N).reduce((i, n) => i.multiply(n.evaluate(e)), new f("1"));
|
|
2769
2776
|
}
|
|
2770
2777
|
factorize(e) {
|
|
2771
2778
|
const t = [];
|
|
2772
2779
|
s(this, N).forEach((l) => {
|
|
2773
2780
|
const c = l.polynom.factorize(e);
|
|
2774
2781
|
if (c.length > 1) {
|
|
2775
|
-
const
|
|
2776
|
-
t.push(...c.map((d) => new se(d,
|
|
2782
|
+
const u = l.power.clone();
|
|
2783
|
+
t.push(...c.map((d) => new se(d, u)));
|
|
2777
2784
|
} else
|
|
2778
2785
|
t.push(l.clone());
|
|
2779
2786
|
});
|
|
@@ -2845,7 +2852,7 @@ const X = class X {
|
|
|
2845
2852
|
reduce() {
|
|
2846
2853
|
const e = ht(this);
|
|
2847
2854
|
return h(this, N, Object.values(e).map((t) => {
|
|
2848
|
-
const i = t[0].polynom, n = t.reduce((r, l) => r.add(l.power), new
|
|
2855
|
+
const i = t[0].polynom, n = t.reduce((r, l) => r.add(l.power), new f("0"));
|
|
2849
2856
|
return new se(i, n.reduce());
|
|
2850
2857
|
}).filter((t) => !t.power.isZero())), this;
|
|
2851
2858
|
}
|
|
@@ -2866,8 +2873,8 @@ const X = class X {
|
|
|
2866
2873
|
const l = t.polynom.monoms.length, c = i.polynom.monoms.length;
|
|
2867
2874
|
if (l !== c)
|
|
2868
2875
|
return l - c;
|
|
2869
|
-
const
|
|
2870
|
-
return
|
|
2876
|
+
const u = t.polynom.degree(e).value, d = i.polynom.degree(e).value;
|
|
2877
|
+
return u !== d ? u - d : n !== r ? n - r : t.degree().isLeq(i.degree()) ? -1 : 1;
|
|
2871
2878
|
}), this;
|
|
2872
2879
|
}
|
|
2873
2880
|
sqrt() {
|
|
@@ -2880,29 +2887,29 @@ const X = class X {
|
|
|
2880
2887
|
const e = this.getZeroes(), t = e.map((r) => r.value), i = this.factors.map((r) => ({ factor: new se(r), ...r.tableOfSigns() }));
|
|
2881
2888
|
return i.forEach((r) => {
|
|
2882
2889
|
const l = new Array(2 * e.length + 1).fill("");
|
|
2883
|
-
let c = r.signs.shift(),
|
|
2890
|
+
let c = r.signs.shift(), u = r.roots.shift();
|
|
2884
2891
|
const d = l.map((p, w) => {
|
|
2885
2892
|
if (w % 2 === 0)
|
|
2886
2893
|
return c;
|
|
2887
|
-
if (
|
|
2894
|
+
if (u === void 0 || u.value !== t[(w - 1) / 2])
|
|
2888
2895
|
return "t";
|
|
2889
2896
|
const V = r.signs.shift();
|
|
2890
|
-
return c = r.signs.shift(),
|
|
2897
|
+
return c = r.signs.shift(), u = r.roots.shift(), V;
|
|
2891
2898
|
});
|
|
2892
2899
|
r.roots = e, r.signs = d;
|
|
2893
|
-
}), { signs: i.map((r) => r.signs).reduce((r, l) => r.length === 0 ? l : (l.forEach((c,
|
|
2900
|
+
}), { signs: i.map((r) => r.signs).reduce((r, l) => r.length === 0 ? l : (l.forEach((c, u) => {
|
|
2894
2901
|
switch (c) {
|
|
2895
2902
|
case "d":
|
|
2896
|
-
r[
|
|
2903
|
+
r[u] = "d";
|
|
2897
2904
|
break;
|
|
2898
2905
|
case "z":
|
|
2899
|
-
r[
|
|
2906
|
+
r[u] = r[u] === "d" ? "d" : "z";
|
|
2900
2907
|
break;
|
|
2901
2908
|
case "h":
|
|
2902
|
-
r[
|
|
2909
|
+
r[u] = "h";
|
|
2903
2910
|
break;
|
|
2904
2911
|
case "-":
|
|
2905
|
-
r[
|
|
2912
|
+
r[u] = r[u] === "h" ? "h" : r[u] === "-" ? "+" : "-";
|
|
2906
2913
|
break;
|
|
2907
2914
|
}
|
|
2908
2915
|
}), r), []), roots: e, factors: i };
|
|
@@ -2916,14 +2923,14 @@ const X = class X {
|
|
|
2916
2923
|
};
|
|
2917
2924
|
it = new WeakMap(), N = new WeakMap(), We = new WeakSet(), ni = function(e, t) {
|
|
2918
2925
|
const i = ht(e), n = ht(t), l = Object.keys(i).filter((c) => Object.hasOwn(n, c)).map((c) => {
|
|
2919
|
-
const
|
|
2920
|
-
return new se(c,
|
|
2926
|
+
const u = i[c].reduce((p, w) => p.add(w.power), new f("0")), d = n[c].reduce((p, w) => p.add(w.power), new f("0"));
|
|
2927
|
+
return new se(c, f.min(u, d));
|
|
2921
2928
|
});
|
|
2922
2929
|
return new X(...l);
|
|
2923
2930
|
}, Mi = function(e, t) {
|
|
2924
2931
|
const i = ht(e), n = ht(t), l = [.../* @__PURE__ */ new Set([...Object.keys(i), ...Object.keys(n)])].map((c) => {
|
|
2925
|
-
const
|
|
2926
|
-
return new se(c,
|
|
2932
|
+
const u = Object.hasOwn(i, c) ? i[c].reduce((p, w) => p.add(w.power), new f("0")) : new f(0), d = Object.hasOwn(n, c) ? n[c].reduce((p, w) => p.add(w.power), new f("0")) : new f(0);
|
|
2933
|
+
return new se(c, f.max(u, d));
|
|
2927
2934
|
});
|
|
2928
2935
|
return new X(...l);
|
|
2929
2936
|
}, gt = new WeakSet(), ri = function() {
|
|
@@ -2932,11 +2939,11 @@ it = new WeakMap(), N = new WeakMap(), We = new WeakSet(), ni = function(e, t) {
|
|
|
2932
2939
|
}, m(X, We);
|
|
2933
2940
|
let si = X;
|
|
2934
2941
|
function ht(o) {
|
|
2935
|
-
const e = new
|
|
2942
|
+
const e = new f().one(), t = new f().one(), i = o.factors.reduce((l, c) => {
|
|
2936
2943
|
if (c.polynom.degree().isZero())
|
|
2937
2944
|
return c.power.isPositive() ? e.multiply(c.polynom.monoms[0].coefficient) : t.multiply(c.polynom.monoms[0].coefficient), l;
|
|
2938
|
-
const
|
|
2939
|
-
return Object.hasOwn(l,
|
|
2945
|
+
const u = c.polynom.display;
|
|
2946
|
+
return Object.hasOwn(l, u) ? l[u].push(c) : l[u] = [c], l;
|
|
2940
2947
|
}, {}), { numerator: n, denominator: r } = e.divide(t).reduce();
|
|
2941
2948
|
return n !== 1 && (i[n.toString()] = [new se(n, 1)]), r !== 1 && (i[r.toString()] = [new se(r, -1)]), i;
|
|
2942
2949
|
}
|
|
@@ -2954,9 +2961,9 @@ function rs(o, e) {
|
|
|
2954
2961
|
);
|
|
2955
2962
|
}
|
|
2956
2963
|
function os(o, e) {
|
|
2957
|
-
return o.dimension !== e.dimension ? new
|
|
2964
|
+
return o.dimension !== e.dimension ? new f().invalid() : o.array.reduce(
|
|
2958
2965
|
(t, i, n) => t.add(i.clone().multiply(e.array[n])),
|
|
2959
|
-
new
|
|
2966
|
+
new f(0)
|
|
2960
2967
|
);
|
|
2961
2968
|
}
|
|
2962
2969
|
function hs(...o) {
|
|
@@ -2997,10 +3004,10 @@ const Be = class Be {
|
|
|
2997
3004
|
a(this, "isColinearTo", (e) => rs(this, e));
|
|
2998
3005
|
a(this, "isNormalTo", (e) => this.dot(e).isZero());
|
|
2999
3006
|
a(this, "multiplyByScalar", (e) => {
|
|
3000
|
-
const t = new
|
|
3007
|
+
const t = new f(e);
|
|
3001
3008
|
return this.array.forEach((i) => i.multiply(t)), this;
|
|
3002
3009
|
});
|
|
3003
|
-
a(this, "divideByScalar", (e) => this.multiplyByScalar(new
|
|
3010
|
+
a(this, "divideByScalar", (e) => this.multiplyByScalar(new f(e).inverse()));
|
|
3004
3011
|
a(this, "simplify", () => this.multiplyByScalar(
|
|
3005
3012
|
U.lcm(...this.array.map((e) => e.denominator))
|
|
3006
3013
|
).divideByScalar(
|
|
@@ -3015,7 +3022,7 @@ const Be = class Be {
|
|
|
3015
3022
|
a(this, "fromString", (e) => {
|
|
3016
3023
|
e.startsWith("(") && (e = e.substring(1)), e.endsWith(")") && (e = e.substring(0, e.length - 1));
|
|
3017
3024
|
const t = e.split(/[,;\s]/g).filter((i) => i.trim() !== "");
|
|
3018
|
-
return t.length < 2 ? this : (h(this, F, t.map((i) => new
|
|
3025
|
+
return t.length < 2 ? this : (h(this, F, t.map((i) => new f(i))), this);
|
|
3019
3026
|
});
|
|
3020
3027
|
e.length > 0 && this.parse(...e);
|
|
3021
3028
|
}
|
|
@@ -3032,13 +3039,13 @@ const Be = class Be {
|
|
|
3032
3039
|
return s(this, F)[0];
|
|
3033
3040
|
}
|
|
3034
3041
|
set x(e) {
|
|
3035
|
-
s(this, F)[0] = new
|
|
3042
|
+
s(this, F)[0] = new f(e);
|
|
3036
3043
|
}
|
|
3037
3044
|
get y() {
|
|
3038
3045
|
return s(this, F)[1];
|
|
3039
3046
|
}
|
|
3040
3047
|
set y(e) {
|
|
3041
|
-
s(this, F)[1] = new
|
|
3048
|
+
s(this, F)[1] = new f(e);
|
|
3042
3049
|
}
|
|
3043
3050
|
get z() {
|
|
3044
3051
|
if (this.dimension < 3)
|
|
@@ -3048,7 +3055,7 @@ const Be = class Be {
|
|
|
3048
3055
|
set z(e) {
|
|
3049
3056
|
if (this.dimension < 3)
|
|
3050
3057
|
throw new Error("Vector is not 3D");
|
|
3051
|
-
s(this, F)[2] = new
|
|
3058
|
+
s(this, F)[2] = new f(e);
|
|
3052
3059
|
}
|
|
3053
3060
|
get asPoint() {
|
|
3054
3061
|
return s(this, Le);
|
|
@@ -3057,7 +3064,7 @@ const Be = class Be {
|
|
|
3057
3064
|
h(this, Le, e);
|
|
3058
3065
|
}
|
|
3059
3066
|
get normSquare() {
|
|
3060
|
-
return this.array.reduce((e, t) => e.add(t.clone().pow(2)), new
|
|
3067
|
+
return this.array.reduce((e, t) => e.add(t.clone().pow(2)), new f(0));
|
|
3061
3068
|
}
|
|
3062
3069
|
get norm() {
|
|
3063
3070
|
return Math.sqrt(this.normSquare.value);
|
|
@@ -3075,7 +3082,7 @@ const Be = class Be {
|
|
|
3075
3082
|
h(this, F, s(this, F).slice(0, e));
|
|
3076
3083
|
else if (e > this.dimension)
|
|
3077
3084
|
for (let t = this.dimension; t < e; t++)
|
|
3078
|
-
s(this, F).push(new
|
|
3085
|
+
s(this, F).push(new f(0));
|
|
3079
3086
|
return this;
|
|
3080
3087
|
}
|
|
3081
3088
|
get dimension() {
|
|
@@ -3114,7 +3121,7 @@ const Be = class Be {
|
|
|
3114
3121
|
return h(this, F, i.array.map((n, r) => n.clone().subtract(t.array[r]))), this;
|
|
3115
3122
|
}
|
|
3116
3123
|
}
|
|
3117
|
-
return h(this, F, e.map((t) => new
|
|
3124
|
+
return h(this, F, e.map((t) => new f(t))), this;
|
|
3118
3125
|
}
|
|
3119
3126
|
clone() {
|
|
3120
3127
|
const e = new Be();
|
|
@@ -3185,12 +3192,12 @@ function as(o) {
|
|
|
3185
3192
|
return o !== void 0 && (e = e.filter((t) => t < o)), di(e);
|
|
3186
3193
|
}
|
|
3187
3194
|
function ls(o, e) {
|
|
3188
|
-
return e === void 0 && (e = 1), o.length <= 0 ? Object.values(o) :
|
|
3195
|
+
return e === void 0 && (e = 1), o.length <= 0 ? Object.values(o) : Pi(o).slice(0, e);
|
|
3189
3196
|
}
|
|
3190
3197
|
function di(o) {
|
|
3191
3198
|
return o.length === 0 ? null : o[pe(0, o.length - 1)];
|
|
3192
3199
|
}
|
|
3193
|
-
function
|
|
3200
|
+
function Pi(o) {
|
|
3194
3201
|
const e = Object.values(o);
|
|
3195
3202
|
for (let t = e.length - 1; t > 0; t--) {
|
|
3196
3203
|
const i = Math.floor(Math.random() * (t + 1)), n = e[t];
|
|
@@ -3212,7 +3219,7 @@ class S extends E {
|
|
|
3212
3219
|
if (e.length > 1) {
|
|
3213
3220
|
if (e.some((i) => i instanceof E))
|
|
3214
3221
|
throw new Error("Creating a point with multiple argument requires an input fraction");
|
|
3215
|
-
const t = e.map((i) => new
|
|
3222
|
+
const t = e.map((i) => new f(i));
|
|
3216
3223
|
if (t.some((i) => i.isNaN()))
|
|
3217
3224
|
throw new Error("The value is not a valid point sting (a,b): " + e.join(","));
|
|
3218
3225
|
this.array = t;
|
|
@@ -3224,7 +3231,7 @@ class S extends E {
|
|
|
3224
3231
|
return e.array = this.copy(), e.asPoint = !0, e;
|
|
3225
3232
|
}
|
|
3226
3233
|
}
|
|
3227
|
-
var
|
|
3234
|
+
var $e, B, z, W, he, J, Ie, xe;
|
|
3228
3235
|
const De = class De {
|
|
3229
3236
|
/**
|
|
3230
3237
|
* Value can be a mix of:
|
|
@@ -3232,7 +3239,7 @@ const De = class De {
|
|
|
3232
3239
|
* @param values
|
|
3233
3240
|
*/
|
|
3234
3241
|
constructor(...e) {
|
|
3235
|
-
m(this,
|
|
3242
|
+
m(this, $e);
|
|
3236
3243
|
// ax + by + c = 0
|
|
3237
3244
|
m(this, B);
|
|
3238
3245
|
m(this, z);
|
|
@@ -3311,7 +3318,7 @@ const De = class De {
|
|
|
3311
3318
|
e.left.monomByDegree(0).coefficient
|
|
3312
3319
|
);
|
|
3313
3320
|
});
|
|
3314
|
-
a(this, "fromCoefficient", (e, t, i) => (h(this, B, new
|
|
3321
|
+
a(this, "fromCoefficient", (e, t, i) => (h(this, B, new f(e)), h(this, z, new f(t)), h(this, W, new f(i)), h(this, J, new E(s(this, z).clone(), s(this, B).clone().opposite())), h(this, he, new E(new f().zero(), s(this, W).clone())), h(this, Ie, s(this, J).clone().normal()), this));
|
|
3315
3322
|
a(this, "fromPointAndDirection", (e, t) => (this.fromCoefficient(
|
|
3316
3323
|
t.y,
|
|
3317
3324
|
t.x.clone().opposite(),
|
|
@@ -3346,7 +3353,7 @@ const De = class De {
|
|
|
3346
3353
|
a(this, "intersection", (e) => {
|
|
3347
3354
|
const t = new S();
|
|
3348
3355
|
let i = !1, n = !1;
|
|
3349
|
-
return s(this, z).isZero() || e.b.isZero(), this.isParallelTo(e) ? (t.x = new
|
|
3356
|
+
return s(this, z).isZero() || e.b.isZero(), this.isParallelTo(e) ? (t.x = new f().invalid(), t.y = new f().invalid(), i = !0) : this.isSameAs(e) ? (t.x = new f().invalid(), t.y = new f().invalid(), n = !0) : (t.x = s(this, z).clone().multiply(e.c).subtract(s(this, W).clone().multiply(e.b)).divide(s(this, B).clone().multiply(e.b).subtract(s(this, z).clone().multiply(e.a))), t.y = s(this, B).clone().multiply(e.c).subtract(s(this, W).clone().multiply(e.a)).divide(s(this, z).clone().multiply(e.a).subtract(s(this, B).clone().multiply(e.b)))), {
|
|
3350
3357
|
point: t,
|
|
3351
3358
|
hasIntersection: !(i || n),
|
|
3352
3359
|
isParallel: i,
|
|
@@ -3354,14 +3361,14 @@ const De = class De {
|
|
|
3354
3361
|
};
|
|
3355
3362
|
});
|
|
3356
3363
|
a(this, "getValueAtX", (e) => {
|
|
3357
|
-
const t = this.getEquation().isolate("y"), i = new
|
|
3358
|
-
return t instanceof H ? t.right.evaluate({ x: i }) : new
|
|
3364
|
+
const t = this.getEquation().isolate("y"), i = new f(e);
|
|
3365
|
+
return t instanceof H ? t.right.evaluate({ x: i }) : new f().invalid();
|
|
3359
3366
|
});
|
|
3360
3367
|
a(this, "getValueAtY", (e) => {
|
|
3361
|
-
const t = this.getEquation().isolate("x"), i = new
|
|
3362
|
-
return t instanceof H ? t.right.evaluate({ y: i }) : new
|
|
3368
|
+
const t = this.getEquation().isolate("x"), i = new f(e);
|
|
3369
|
+
return t instanceof H ? t.right.evaluate({ y: i }) : new f().invalid();
|
|
3363
3370
|
});
|
|
3364
|
-
return h(this, B, new
|
|
3371
|
+
return h(this, B, new f().zero()), h(this, z, new f().zero()), h(this, W, new f().zero()), h(this, he, new E()), h(this, J, new E()), h(this, Ie, new E()), h(this, $e, !0), e.length > 0 && this.parse(...e), this;
|
|
3365
3372
|
}
|
|
3366
3373
|
get a() {
|
|
3367
3374
|
return s(this, B);
|
|
@@ -3401,7 +3408,7 @@ const De = class De {
|
|
|
3401
3408
|
// ------------------------------------------
|
|
3402
3409
|
getEquation() {
|
|
3403
3410
|
const e = new H(new O().parse("xy", s(this, B), s(this, z), s(this, W)), new O("0"));
|
|
3404
|
-
return s(this,
|
|
3411
|
+
return s(this, $e) ? e.simplify() : e;
|
|
3405
3412
|
}
|
|
3406
3413
|
// get system(): { x: Equation, y: Equation } {
|
|
3407
3414
|
// const e1 = new Equation(
|
|
@@ -3441,7 +3448,7 @@ const De = class De {
|
|
|
3441
3448
|
case "parametric":
|
|
3442
3449
|
case "system": {
|
|
3443
3450
|
const t = s(this, J).clone();
|
|
3444
|
-
return s(this,
|
|
3451
|
+
return s(this, $e) && t.simplify(), e === "parametric" ? `${E.asTex("x", "y")} = ${E.asTex(s(this, he).x.tex, s(this, he).y.tex)} + k\\cdot ${E.asTex(t.x.tex, t.y.tex)}` : `\\left\\{\\begin{aligned}
|
|
3445
3452
|
x &= ${new O(s(this, he).x).add(new M(s(this, J).x).multiply(new M("k"))).reorder("k", !0).tex}\\\\
|
|
3446
3453
|
y &= ${new O(s(this, he).y).add(new M(s(this, J).y).multiply(new M("k"))).reorder("k", !0).tex}
|
|
3447
3454
|
\\end{aligned}\\right.`;
|
|
@@ -3453,10 +3460,10 @@ const De = class De {
|
|
|
3453
3460
|
}
|
|
3454
3461
|
}
|
|
3455
3462
|
get reduceBeforeDisplay() {
|
|
3456
|
-
return s(this,
|
|
3463
|
+
return s(this, $e);
|
|
3457
3464
|
}
|
|
3458
3465
|
set reduceBeforeDisplay(e) {
|
|
3459
|
-
h(this,
|
|
3466
|
+
h(this, $e, e);
|
|
3460
3467
|
}
|
|
3461
3468
|
get display() {
|
|
3462
3469
|
const e = s(this, xe);
|
|
@@ -3467,7 +3474,7 @@ const De = class De {
|
|
|
3467
3474
|
return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new O().parse("x", this.slope, this.height).display;
|
|
3468
3475
|
case "parametric": {
|
|
3469
3476
|
const t = s(this, J).clone();
|
|
3470
|
-
return s(this,
|
|
3477
|
+
return s(this, $e) && t.simplify(), `((x,y))=((${s(this, he).x.display},${s(this, he).y.display}))+k((${t.x.display},${t.y.display}))`;
|
|
3471
3478
|
}
|
|
3472
3479
|
default: {
|
|
3473
3480
|
const t = this.getEquation();
|
|
@@ -3496,7 +3503,7 @@ const De = class De {
|
|
|
3496
3503
|
return {
|
|
3497
3504
|
value: NaN,
|
|
3498
3505
|
tex: "Not a line",
|
|
3499
|
-
fraction: new
|
|
3506
|
+
fraction: new f().infinite()
|
|
3500
3507
|
};
|
|
3501
3508
|
const n = t.value / Math.sqrt(i.value), r = t.clone().divide(i.clone().sqrt());
|
|
3502
3509
|
return i.isSquare() ? {
|
|
@@ -3524,10 +3531,10 @@ const De = class De {
|
|
|
3524
3531
|
return s(this, B).isZero() || (s(this, B).isOne() ? t = "x" : s(this, B).clone().opposite().isOne() ? t = "-x" : t = s(this, B).value.toFixed(e) + "x"), s(this, z).isZero() || (s(this, z).isPositive() && (t += "+"), t += s(this, z).value.toFixed(e) + "y"), s(this, W).isZero() || (s(this, W).isPositive() && (t += "+"), t += s(this, W).value.toFixed(e)), t + "=0";
|
|
3525
3532
|
}
|
|
3526
3533
|
};
|
|
3527
|
-
|
|
3534
|
+
$e = new WeakMap(), B = new WeakMap(), z = new WeakMap(), W = new WeakMap(), he = new WeakMap(), J = new WeakMap(), Ie = new WeakMap(), xe = new WeakMap(), // A line is defined as the canonical form
|
|
3528
3535
|
a(De, "PERPENDICULAR", we.Perpendicular), a(De, "PARALLEL", we.Parallel);
|
|
3529
3536
|
let R = De;
|
|
3530
|
-
var ae, j, qe, Ut, Wt, Gt, le,
|
|
3537
|
+
var ae, j, qe, Ut, Wt, Gt, le, $i, Nt, Ii, Si, Bi, hi;
|
|
3531
3538
|
const Ht = class Ht {
|
|
3532
3539
|
constructor(...e) {
|
|
3533
3540
|
m(this, le);
|
|
@@ -3552,7 +3559,7 @@ const Ht = class Ht {
|
|
|
3552
3559
|
const i = s(this, qe).clone(), n = e.getEquation().clone().isolate("x"), r = e.getEquation().clone().isolate("y");
|
|
3553
3560
|
return n instanceof H && r instanceof H && (i.replaceBy("y", r.right).simplify(), i.solve()), t;
|
|
3554
3561
|
});
|
|
3555
|
-
a(this, "tangents", (e) => e instanceof
|
|
3562
|
+
a(this, "tangents", (e) => e instanceof f ? s(this, Gt).call(this, e) : this.isPointOnCircle(e) ? s(this, Ut).call(this, e) : s(this, ae) !== void 0 && s(this, ae).distanceTo(e).value > this.radius.value ? s(this, Wt).call(this, e) : (console.log("No tangents as the point is inside !"), []));
|
|
3556
3563
|
a(this, "isPointOnCircle", (e) => {
|
|
3557
3564
|
var t;
|
|
3558
3565
|
return ((t = s(this, qe)) == null ? void 0 : t.test({ x: e.x, y: e.y })) ?? !1;
|
|
@@ -3575,15 +3582,15 @@ const Ht = class Ht {
|
|
|
3575
3582
|
});
|
|
3576
3583
|
m(this, Wt, (e) => {
|
|
3577
3584
|
const t = this.center.x.clone().subtract(e.x), i = this.center.y.clone().subtract(e.y), n = new O("x"), r = new O("x^2+1");
|
|
3578
|
-
return n.multiply(t).subtract(i).pow(2), r.multiply(this.squareRadius), new H(n, r).solve().map((
|
|
3585
|
+
return n.multiply(t).subtract(i).pow(2), r.multiply(this.squareRadius), new H(n, r).solve().map((u) => {
|
|
3579
3586
|
let d;
|
|
3580
3587
|
const p = new H("y", "x");
|
|
3581
|
-
return
|
|
3588
|
+
return u.exact instanceof f ? (d = e.x.clone().opposite().multiply(u.exact).add(e.y), p.right.multiply(u.exact).add(d)) : (d = e.x.clone().opposite().multiply(u.value).add(e.y), p.right.multiply(u.value).add(d)), new R(p);
|
|
3582
3589
|
});
|
|
3583
3590
|
});
|
|
3584
3591
|
m(this, Gt, (e) => {
|
|
3585
|
-
const t = e.numerator, i = -e.denominator, n = this.center.x.clone(), r = this.center.y.clone(), l = this.squareRadius.clone().multiply(e.numerator ** 2 + e.denominator ** 2), c = n.clone().multiply(t).opposite().subtract(r.clone().multiply(i)).add(l.clone().sqrt()),
|
|
3586
|
-
return [new R(t, i, c), new R(t, i,
|
|
3592
|
+
const t = e.numerator, i = -e.denominator, n = this.center.x.clone(), r = this.center.y.clone(), l = this.squareRadius.clone().multiply(e.numerator ** 2 + e.denominator ** 2), c = n.clone().multiply(t).opposite().subtract(r.clone().multiply(i)).add(l.clone().sqrt()), u = n.clone().multiply(t).opposite().subtract(r.clone().multiply(i)).subtract(l.clone().sqrt());
|
|
3593
|
+
return [new R(t, i, c), new R(t, i, u)];
|
|
3587
3594
|
});
|
|
3588
3595
|
e.length > 0 && this.parse(...e);
|
|
3589
3596
|
}
|
|
@@ -3591,7 +3598,7 @@ const Ht = class Ht {
|
|
|
3591
3598
|
return s(this, ae) ?? new S();
|
|
3592
3599
|
}
|
|
3593
3600
|
get squareRadius() {
|
|
3594
|
-
return s(this, j) ?? new
|
|
3601
|
+
return s(this, j) ?? new f(0);
|
|
3595
3602
|
}
|
|
3596
3603
|
get cartesian() {
|
|
3597
3604
|
if (s(this, qe) === void 0)
|
|
@@ -3628,10 +3635,10 @@ const Ht = class Ht {
|
|
|
3628
3635
|
);
|
|
3629
3636
|
}
|
|
3630
3637
|
setRadius(e, t) {
|
|
3631
|
-
return t ? h(this, j, new
|
|
3638
|
+
return t ? h(this, j, new f(e)) : h(this, j, new f(e).pow(2)), A(this, le, Nt).call(this), this;
|
|
3632
3639
|
}
|
|
3633
3640
|
parse(...e) {
|
|
3634
|
-
return A(this, le,
|
|
3641
|
+
return A(this, le, $i).call(this), typeof e[0] == "string" ? A(this, le, hi).call(this, new H(e[0])) : e[0] instanceof H ? A(this, le, hi).call(this, e[0]) : e[0] instanceof Ht ? A(this, le, Ii).call(this, e[0]) : e[0] instanceof S && e.length > 1 && (e[1] instanceof S ? e[2] instanceof S || A(this, le, Bi).call(this, e[0], e[1]) : (e[1] instanceof f || typeof e[1] == "number") && A(this, le, Si).call(this, e[0], e[1], typeof e[2] == "boolean" ? e[2] : !1)), A(this, le, Nt).call(this), this;
|
|
3635
3642
|
}
|
|
3636
3643
|
// private _parseThroughtThreePoints(A: Point, B: Point, C: Point): this {
|
|
3637
3644
|
// const T = new Triangle(A, B, C), mAB = T.remarquables.mediators.AB.clone(),
|
|
@@ -3640,7 +3647,7 @@ const Ht = class Ht {
|
|
|
3640
3647
|
// return this
|
|
3641
3648
|
// }
|
|
3642
3649
|
};
|
|
3643
|
-
ae = new WeakMap(), j = new WeakMap(), qe = new WeakMap(), Ut = new WeakMap(), Wt = new WeakMap(), Gt = new WeakMap(), le = new WeakSet(),
|
|
3650
|
+
ae = new WeakMap(), j = new WeakMap(), qe = new WeakMap(), Ut = new WeakMap(), Wt = new WeakMap(), Gt = new WeakMap(), le = new WeakSet(), $i = function() {
|
|
3644
3651
|
return h(this, ae, void 0), h(this, j, void 0), h(this, qe, void 0), this;
|
|
3645
3652
|
}, Nt = function() {
|
|
3646
3653
|
h(this, qe, new H(
|
|
@@ -3650,7 +3657,7 @@ ae = new WeakMap(), j = new WeakMap(), qe = new WeakMap(), Ut = new WeakMap(), W
|
|
|
3650
3657
|
}, Ii = function(e) {
|
|
3651
3658
|
return h(this, ae, e.center.clone()), h(this, j, e.squareRadius.clone()), A(this, le, Nt).call(this), this;
|
|
3652
3659
|
}, Si = function(e, t, i) {
|
|
3653
|
-
return h(this, ae, e.clone()), i ? h(this, j, new
|
|
3660
|
+
return h(this, ae, e.clone()), i ? h(this, j, new f(t)) : h(this, j, new f(t).pow(2)), this;
|
|
3654
3661
|
}, Bi = function(e, t) {
|
|
3655
3662
|
return h(this, ae, e.clone()), h(this, j, new E(s(this, ae), t).normSquare), this;
|
|
3656
3663
|
}, hi = function(e) {
|
|
@@ -3708,7 +3715,7 @@ const ct = class ct {
|
|
|
3708
3715
|
// return new Fraction().invalid()
|
|
3709
3716
|
// }
|
|
3710
3717
|
a(this, "randomPoint", (e = 5) => {
|
|
3711
|
-
const t = s(this, L).clone(), i = new
|
|
3718
|
+
const t = s(this, L).clone(), i = new f(Q(e, !1));
|
|
3712
3719
|
return new S(
|
|
3713
3720
|
t.x.clone().add(s(this, G).x.clone().multiply(i)),
|
|
3714
3721
|
t.y.clone().add(s(this, G).y.clone().multiply(i)),
|
|
@@ -3847,18 +3854,18 @@ const mi = class mi {
|
|
|
3847
3854
|
return;
|
|
3848
3855
|
}
|
|
3849
3856
|
if (e.equation) {
|
|
3850
|
-
const r = e.equation.moveLeft().reduce().left, l = r.monomByLetter("x").coefficient, c = r.monomByLetter("y").coefficient,
|
|
3851
|
-
this.normal = new E(l, c,
|
|
3857
|
+
const r = e.equation.moveLeft().reduce().left, l = r.monomByLetter("x").coefficient, c = r.monomByLetter("y").coefficient, u = r.monomByLetter("z").coefficient, d = r.monomByDegree(0).coefficient;
|
|
3858
|
+
this.normal = new E(l, c, u), l.isNotZero() ? this.point = new S(d.clone().divide(l).opposite(), 0, 0) : c.isNotZero() ? this.point = new S(0, d.clone().divide(c).opposite(), 0) : this.point = new S(0, 0, d.clone().divide(u).opposite());
|
|
3852
3859
|
return;
|
|
3853
3860
|
}
|
|
3854
3861
|
if (((i = e.points) == null ? void 0 : i.length) === 3 && e.points.every((r) => r instanceof E)) {
|
|
3855
|
-
const r = e.points[0], l = e.points[1], c = e.points[2],
|
|
3856
|
-
this.normal =
|
|
3862
|
+
const r = e.points[0], l = e.points[1], c = e.points[2], u = new E(r, l), d = new E(r, c);
|
|
3863
|
+
this.normal = u.cross(d), this.point = r;
|
|
3857
3864
|
return;
|
|
3858
3865
|
}
|
|
3859
3866
|
if (((n = e.coefficients) == null ? void 0 : n.length) === 4) {
|
|
3860
|
-
const [r, l, c,
|
|
3861
|
-
this.normal = new E(r, l, c), this.point = new S(0, 0, -
|
|
3867
|
+
const [r, l, c, u] = e.coefficients;
|
|
3868
|
+
this.normal = new E(r, l, c), this.point = new S(0, 0, -u);
|
|
3862
3869
|
return;
|
|
3863
3870
|
}
|
|
3864
3871
|
}
|
|
@@ -3918,7 +3925,7 @@ const Qt = class Qt {
|
|
|
3918
3925
|
*/
|
|
3919
3926
|
a(this, "parse", (...e) => {
|
|
3920
3927
|
if (e.length === 6) {
|
|
3921
|
-
const t = e.map((i) => new
|
|
3928
|
+
const t = e.map((i) => new f(i));
|
|
3922
3929
|
if (t.some((i) => i.isNaN()))
|
|
3923
3930
|
throw new Error("One of the values is not a valid number");
|
|
3924
3931
|
return this.parse(
|
|
@@ -4022,7 +4029,7 @@ const Qt = class Qt {
|
|
|
4022
4029
|
B: r.internal,
|
|
4023
4030
|
C: r.internal,
|
|
4024
4031
|
intersection: null
|
|
4025
|
-
},
|
|
4032
|
+
}, u = {
|
|
4026
4033
|
A: n.external,
|
|
4027
4034
|
B: r.external,
|
|
4028
4035
|
C: l.external,
|
|
@@ -4032,7 +4039,7 @@ const Qt = class Qt {
|
|
|
4032
4039
|
mediators: t,
|
|
4033
4040
|
heights: i,
|
|
4034
4041
|
bisectors: c,
|
|
4035
|
-
externalBisectors:
|
|
4042
|
+
externalBisectors: u
|
|
4036
4043
|
};
|
|
4037
4044
|
return d.medians.intersection = d.medians.A.intersection(d.medians.B).point, d.mediators.intersection = d.mediators.AB.intersection(d.mediators.BC).point, d.heights.intersection = d.heights.A.intersection(d.heights.B).point, d.bisectors.intersection = d.bisectors.A.intersection(d.bisectors.B).point, d;
|
|
4038
4045
|
});
|
|
@@ -4041,7 +4048,7 @@ const Qt = class Qt {
|
|
|
4041
4048
|
let i, n;
|
|
4042
4049
|
if (e === "A" ? (i = t.AB, n = t.AC) : e === "B" ? (i = t.AB, n = t.BC) : e === "C" && (i = t.BC, n = t.AC), i === void 0 || n === void 0)
|
|
4043
4050
|
throw new Error(`The point ${e} does not exist`);
|
|
4044
|
-
const r = i.n.simplify().norm, l = n.n.simplify().norm, c = i.getEquation().multiply(l),
|
|
4051
|
+
const r = i.n.simplify().norm, l = n.n.simplify().norm, c = i.getEquation().multiply(l), u = n.getEquation().multiply(r), d = new R(c.clone().subtract(u).simplify()), p = new R(u.clone().subtract(c).simplify());
|
|
4045
4052
|
return e === "A" ? d.hitSegment(this.B, this.C) ? { internal: d, external: p } : { internal: p, external: d } : e === "B" ? d.hitSegment(this.A, this.C) ? { internal: d, external: p } : { internal: p, external: d } : e === "C" ? d.hitSegment(this.B, this.A) ? { internal: d, external: p } : { internal: p, external: d } : { internal: d, external: p };
|
|
4046
4053
|
});
|
|
4047
4054
|
return e.length > 0 && this.parse(...e), this;
|
|
@@ -4104,7 +4111,7 @@ function qt(o) {
|
|
|
4104
4111
|
natural: !1
|
|
4105
4112
|
},
|
|
4106
4113
|
o
|
|
4107
|
-
), t = new
|
|
4114
|
+
), t = new f();
|
|
4108
4115
|
if (e.negative ? t.numerator = Q(e.max, e.zero) : t.numerator = pe(e.zero ? 0 : 1, e.max), e.natural)
|
|
4109
4116
|
t.denominator = 1;
|
|
4110
4117
|
else {
|
|
@@ -4212,7 +4219,7 @@ function ci(o) {
|
|
|
4212
4219
|
quadrant: null
|
|
4213
4220
|
},
|
|
4214
4221
|
o
|
|
4215
|
-
), t = e.axis === "x", i = e.axis === "y", n = e.fraction ? qt({ max: e.max, zero: t }) : new
|
|
4222
|
+
), t = e.axis === "x", i = e.axis === "y", n = e.fraction ? qt({ max: e.max, zero: t }) : new f(Q(e.max, t)), r = e.fraction ? qt({ max: e.max, zero: i }) : new f(Q(e.max, i));
|
|
4216
4223
|
return Number(e.quadrant) === 1 && (n.abs(), r.abs()), Number(e.quadrant) === 2 && (n.isPositive() && n.opposite(), r.isNegative() && r.opposite()), Number(e.quadrant) === 3 && (n.isPositive() && n.opposite(), r.isPositive() && r.opposite()), Number(e.quadrant) === 4 && (n.isNegative() && n.opposite(), r.isPositive() && r.opposite()), new S(n, r);
|
|
4217
4224
|
}
|
|
4218
4225
|
function ds(o) {
|
|
@@ -4244,7 +4251,7 @@ function ps(o) {
|
|
|
4244
4251
|
);
|
|
4245
4252
|
for (; t.isNull; )
|
|
4246
4253
|
t.x = Q(10), t.y = Q(10);
|
|
4247
|
-
return e.slope === 1 ? t.x.sign() !== t.y.sign() && t.y.opposite() : e.slope === -1 && t.x.sign() !== t.y.sign() && t.y.opposite(), new R(new E(e.A.x, e.A.y), t);
|
|
4254
|
+
return e.slope === 1 ? t.x.sign() !== t.y.sign() && t.y.opposite() : e.slope === -1 && t.x.sign() !== t.y.sign() && t.y.opposite(), new R().fromPointAndDirection(new E(e.A.x, e.A.y), t);
|
|
4248
4255
|
}
|
|
4249
4256
|
function ms(o) {
|
|
4250
4257
|
const e = Object.assign(
|
|
@@ -4275,7 +4282,7 @@ const gs = {
|
|
|
4275
4282
|
bool: (o) => Ci(o),
|
|
4276
4283
|
array: (o, e) => ls(o, e),
|
|
4277
4284
|
item: (o) => di(o),
|
|
4278
|
-
shuffle: (o) =>
|
|
4285
|
+
shuffle: (o) => Pi(o),
|
|
4279
4286
|
line: (o) => ps(o),
|
|
4280
4287
|
line3: (o) => ms(o),
|
|
4281
4288
|
vector: (o) => ci(o),
|
|
@@ -4286,7 +4293,7 @@ const gs = {
|
|
|
4286
4293
|
circle: (o) => ds(o)
|
|
4287
4294
|
}, ws = {
|
|
4288
4295
|
Numeric: U,
|
|
4289
|
-
Fraction:
|
|
4296
|
+
Fraction: f,
|
|
4290
4297
|
Root: vt,
|
|
4291
4298
|
Monom: M,
|
|
4292
4299
|
Polynom: O,
|
|
@@ -4314,7 +4321,7 @@ export {
|
|
|
4314
4321
|
At as EquationSolver,
|
|
4315
4322
|
lt as FACTOR_DISPLAY,
|
|
4316
4323
|
se as Factor,
|
|
4317
|
-
|
|
4324
|
+
f as Fraction,
|
|
4318
4325
|
R as Line,
|
|
4319
4326
|
Ot as Line3,
|
|
4320
4327
|
ti as LinearSystem,
|