pimath 0.1.20 → 0.1.22
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/polyFactor.d.ts +5 -1
- package/dist/index.d.ts +5 -0
- package/dist/pimath.interface.d.ts +1 -1
- package/dist/pimath.js +245 -236
- package/dist/pimath.js.map +1 -1
- package/package.json +1 -1
package/dist/pimath.js
CHANGED
|
@@ -4,7 +4,7 @@ var yi = (o) => {
|
|
|
4
4
|
};
|
|
5
5
|
var Ri = (o, e, t) => e in o ? Si(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
6
6
|
var a = (o, e, t) => Ri(o, typeof e != "symbol" ? e + "" : e, t), Jt = (o, e, t) => e.has(o) || yi("Cannot " + t);
|
|
7
|
-
var s = (o, e, t) => (Jt(o, e, "read from private field"), t ? t.call(o) : e.get(o)), p = (o, e, t) => e.has(o) ? yi("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), h = (o, e, t, i) => (Jt(o, e, "write to private field"), i ? i.call(o, t) : e.set(o, t), t),
|
|
7
|
+
var s = (o, e, t) => (Jt(o, e, "read from private field"), t ? t.call(o) : e.get(o)), p = (o, e, t) => e.has(o) ? yi("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), h = (o, e, t, i) => (Jt(o, e, "write to private field"), i ? i.call(o, t) : e.set(o, t), t), q = (o, e, t) => (Jt(o, e, "access private method"), t);
|
|
8
8
|
function zi(o) {
|
|
9
9
|
const e = vi(o), t = [];
|
|
10
10
|
let i, n;
|
|
@@ -391,37 +391,37 @@ class vt {
|
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
393
|
Z = new WeakMap(), ee = new WeakMap(), ie = new WeakMap(), Xe = new WeakMap();
|
|
394
|
-
var
|
|
394
|
+
var fe, je, I, ot, ye, bi, ti, xi, Ei, Ni;
|
|
395
395
|
const mi = class mi {
|
|
396
396
|
constructor(e, t, i = "x") {
|
|
397
|
-
p(this,
|
|
398
|
-
p(this,
|
|
397
|
+
p(this, I);
|
|
398
|
+
p(this, fe);
|
|
399
399
|
p(this, je);
|
|
400
400
|
if (h(this, je, i), Object.hasOwn(e, "moveLeft")) {
|
|
401
401
|
const n = e;
|
|
402
|
-
h(this,
|
|
402
|
+
h(this, fe, n.left.clone().subtract(n.right));
|
|
403
403
|
} else
|
|
404
|
-
h(this,
|
|
404
|
+
h(this, fe, e.clone().subtract(t ?? 0));
|
|
405
405
|
}
|
|
406
406
|
solve() {
|
|
407
|
-
if (s(this,
|
|
408
|
-
return
|
|
409
|
-
if (s(this,
|
|
410
|
-
return
|
|
411
|
-
const e =
|
|
407
|
+
if (s(this, fe).degree().isOne())
|
|
408
|
+
return q(this, I, xi).call(this);
|
|
409
|
+
if (s(this, fe).degree().value === 2)
|
|
410
|
+
return q(this, I, Ei).call(this);
|
|
411
|
+
const e = q(this, I, bi).call(this);
|
|
412
412
|
if (e.length > 0)
|
|
413
413
|
return e;
|
|
414
|
-
if (s(this,
|
|
415
|
-
return
|
|
414
|
+
if (s(this, fe).degree().value === 3)
|
|
415
|
+
return q(this, I, ti).call(this);
|
|
416
416
|
throw new Error("The equation degree is too high.");
|
|
417
417
|
}
|
|
418
418
|
solveAsCardan() {
|
|
419
|
-
if (s(this,
|
|
419
|
+
if (s(this, fe).degree().value !== 3)
|
|
420
420
|
throw new Error("The equation is not cubic.");
|
|
421
|
-
return
|
|
421
|
+
return q(this, I, ti).call(this);
|
|
422
422
|
}
|
|
423
423
|
};
|
|
424
|
-
|
|
424
|
+
fe = new WeakMap(), je = new WeakMap(), I = new WeakSet(), ot = function(e, t) {
|
|
425
425
|
return {
|
|
426
426
|
variable: s(this, je),
|
|
427
427
|
exact: !1,
|
|
@@ -431,7 +431,7 @@ ce = new WeakMap(), je = new WeakMap(), P = new WeakSet(), ot = function(e, t) {
|
|
|
431
431
|
};
|
|
432
432
|
}, ye = function(e) {
|
|
433
433
|
if (e instanceof u && e.isApproximative())
|
|
434
|
-
return
|
|
434
|
+
return q(this, I, ot).call(this, e.value);
|
|
435
435
|
const t = new u(e);
|
|
436
436
|
return {
|
|
437
437
|
variable: s(this, je),
|
|
@@ -441,23 +441,23 @@ ce = new WeakMap(), je = new WeakMap(), P = new WeakSet(), ot = function(e, t) {
|
|
|
441
441
|
display: t.display
|
|
442
442
|
};
|
|
443
443
|
}, bi = function() {
|
|
444
|
-
let e = s(this,
|
|
444
|
+
let e = s(this, fe).clone(), t = [];
|
|
445
445
|
const i = e.lcmDenominator();
|
|
446
446
|
i !== 1 && e.multiply(i);
|
|
447
447
|
const n = e.monomByDegree().coefficient;
|
|
448
448
|
let r = e.monomByDegree(0).coefficient;
|
|
449
449
|
for (; r.isZero(); )
|
|
450
|
-
t.length === 0 && t.push(
|
|
450
|
+
t.length === 0 && t.push(q(this, I, ye).call(this, 0)), e = e.divide("x"), r = e.monomByDegree(0).coefficient;
|
|
451
451
|
const l = G.dividers(n.value), c = G.dividers(r.value);
|
|
452
452
|
for (const f of l)
|
|
453
453
|
for (const g of c) {
|
|
454
|
-
const
|
|
455
|
-
e.evaluate(
|
|
454
|
+
const N = new u(g, f);
|
|
455
|
+
e.evaluate(N).isZero() && !t.find((V) => V.value === N.value) && t.push(q(this, I, ye).call(this, N)), N.opposite(), e.evaluate(N).isZero() && !t.find((V) => V.value === N.value) && t.push(q(this, I, ye).call(this, N));
|
|
456
456
|
}
|
|
457
457
|
for (const f of t) {
|
|
458
458
|
if (f.exact !== !1 && f.exact.isZero())
|
|
459
459
|
continue;
|
|
460
|
-
const g = s(this,
|
|
460
|
+
const g = s(this, fe).clone().parse("x", f.exact.denominator, -f.exact.numerator);
|
|
461
461
|
for (; e.isDividableBy(g); )
|
|
462
462
|
e = e.divide(g);
|
|
463
463
|
}
|
|
@@ -468,61 +468,61 @@ ce = new WeakMap(), je = new WeakMap(), P = new WeakSet(), ot = function(e, t) {
|
|
|
468
468
|
const d = new mi(e, e.clone().parse("0"), s(this, je));
|
|
469
469
|
return t = t.concat(d.solve()), t.sort((f, g) => f.value - g.value);
|
|
470
470
|
}, ti = function() {
|
|
471
|
-
const e = s(this,
|
|
472
|
-
if (
|
|
473
|
-
const he = g.clone().opposite().add(
|
|
474
|
-
return [
|
|
471
|
+
const e = s(this, fe), 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), d = r.clone().divide(t), f = c.clone().subtract(l.clone().pow(2).divide(3)), g = d.clone().subtract(l.clone().multiply(c).divide(3)).add(l.clone().pow(3).multiply(2).divide(27)), N = g.clone().opposite(), V = f.clone().opposite().pow(3).divide(27), pe = N.clone().pow(2).subtract(V.clone().multiply(4)).opposite();
|
|
472
|
+
if (pe.isNegative()) {
|
|
473
|
+
const he = g.clone().opposite().add(pe.clone().opposite().sqrt()).divide(2).root(3), ae = g.clone().opposite().subtract(pe.clone().opposite().sqrt()).divide(2).root(3), ge = he.clone().add(ae).subtract(l.clone().divide(3));
|
|
474
|
+
return [q(this, I, ye).call(this, ge)];
|
|
475
475
|
}
|
|
476
|
-
if (
|
|
476
|
+
if (pe.isZero()) {
|
|
477
477
|
const he = g.clone().opposite().divide(2).root(3), ae = he.clone().opposite().subtract(l.clone().divide(3)), ge = he.clone().multiply(2).subtract(l.clone().divide(3));
|
|
478
|
-
return ae.isEqual(ge) ? [
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
].sort((
|
|
478
|
+
return ae.isEqual(ge) ? [q(this, I, ye).call(this, ae)] : [
|
|
479
|
+
q(this, I, ye).call(this, ge),
|
|
480
|
+
q(this, I, ye).call(this, ae)
|
|
481
|
+
].sort((me, ce) => me.value - ce.value);
|
|
482
482
|
}
|
|
483
|
-
if (
|
|
484
|
-
const he = [], ae = f.value, ge = g.value,
|
|
485
|
-
for (let
|
|
486
|
-
he.push(2 * Math.sqrt(-ae / 3) * Math.cos(Math.acos(3 * ge / (2 * ae) * Math.sqrt(-3 / ae)) / 3 + 2 * Math.PI *
|
|
487
|
-
return he.map((
|
|
483
|
+
if (pe.isPositive()) {
|
|
484
|
+
const he = [], ae = f.value, ge = g.value, me = l.value;
|
|
485
|
+
for (let ce = 0; ce < 3; ce++)
|
|
486
|
+
he.push(2 * Math.sqrt(-ae / 3) * Math.cos(Math.acos(3 * ge / (2 * ae) * Math.sqrt(-3 / ae)) / 3 + 2 * Math.PI * ce / 3) - me / 3);
|
|
487
|
+
return he.map((ce) => q(this, I, ot).call(this, ce)).sort((ce, nt) => ce.value - nt.value);
|
|
488
488
|
}
|
|
489
489
|
return [];
|
|
490
490
|
}, xi = function() {
|
|
491
|
-
const e = s(this,
|
|
491
|
+
const e = s(this, fe).monomByDegree(0).coefficient.clone().opposite().divide(s(this, fe).monomByDegree(1).coefficient);
|
|
492
492
|
return [
|
|
493
|
-
|
|
493
|
+
q(this, I, ye).call(this, e)
|
|
494
494
|
];
|
|
495
495
|
}, Ei = function() {
|
|
496
|
-
const e = s(this,
|
|
496
|
+
const e = s(this, fe), t = e.monomByDegree(2).coefficient, i = e.monomByDegree(1).coefficient, n = e.monomByDegree(0).coefficient, r = i.clone().pow(2).subtract(t.clone().multiply(n).multiply(4));
|
|
497
497
|
if (r.isNegative())
|
|
498
498
|
return [];
|
|
499
499
|
if (r.isSquare()) {
|
|
500
500
|
const l = r.sqrt(), c = i.clone().opposite().add(l).divide(t.clone().multiply(2)), d = i.clone().opposite().subtract(l).divide(t.clone().multiply(2));
|
|
501
|
-
return l.isZero() ? [
|
|
502
|
-
|
|
503
|
-
|
|
501
|
+
return l.isZero() ? [q(this, I, ye).call(this, c)] : [
|
|
502
|
+
q(this, I, ye).call(this, c),
|
|
503
|
+
q(this, I, ye).call(this, d)
|
|
504
504
|
].sort((f, g) => f.value - g.value);
|
|
505
505
|
}
|
|
506
|
-
return
|
|
506
|
+
return q(this, I, Ni).call(this, t, i, r);
|
|
507
507
|
}, Ni = function(e, t, i) {
|
|
508
|
-
const n = G.dividers(i.value).filter((
|
|
509
|
-
function V(
|
|
510
|
-
return `\\frac{ ${
|
|
508
|
+
const n = G.dividers(i.value).filter((me) => Math.sqrt(me) % 1 === 0).map((me) => Math.sqrt(me)).pop() ?? 1, r = G.gcd(2 * e.value, t.value, n) * (e.isNegative() ? -1 : 1), l = t.clone().divide(r).opposite(), c = e.clone().divide(r).multiply(2), d = i.clone().divide(n ** 2), f = Math.abs(n / r), g = n === 1 ? "-" : `-${f} `, N = n === 1 ? "+" : `+${f} `;
|
|
509
|
+
function V(me, ce, nt, Kt) {
|
|
510
|
+
return `\\frac{ ${ce} ${nt}\\sqrt{ ${Kt} } }{ ${me} }`;
|
|
511
511
|
}
|
|
512
|
-
function
|
|
513
|
-
return `(${
|
|
512
|
+
function pe(me, ce, nt, Kt) {
|
|
513
|
+
return `(${ce}${nt}sqrt(${Kt}))/${me}`;
|
|
514
514
|
}
|
|
515
515
|
const he = i.value ** 0.5, ae = (-t.value - he) / (2 * e.value), ge = (-t.value + he) / (2 * e.value);
|
|
516
516
|
return [
|
|
517
|
-
|
|
517
|
+
q(this, I, ot).call(this, ae, {
|
|
518
518
|
tex: V(c.tex, l.tex, g.toString(), d.tex),
|
|
519
|
-
display:
|
|
519
|
+
display: pe(c.display, l.display, g.toString(), d.display)
|
|
520
520
|
}),
|
|
521
|
-
|
|
522
|
-
tex: V(c.tex, l.tex,
|
|
523
|
-
display:
|
|
521
|
+
q(this, I, ot).call(this, ge, {
|
|
522
|
+
tex: V(c.tex, l.tex, N.toString(), d.tex),
|
|
523
|
+
display: pe(c.display, l.display, N.toString(), d.display)
|
|
524
524
|
})
|
|
525
|
-
].sort((
|
|
525
|
+
].sort((me, ce) => me.value - ce.value);
|
|
526
526
|
};
|
|
527
527
|
let Nt = mi;
|
|
528
528
|
var Gi = Object.defineProperty, Ti = (o) => {
|
|
@@ -536,22 +536,22 @@ var m = /* @__PURE__ */ ((o) => (o.VARIABLE = "variable", o.COEFFICIENT = "coeff
|
|
|
536
536
|
function Hi(o, e) {
|
|
537
537
|
if (o.length <= 1)
|
|
538
538
|
return o;
|
|
539
|
-
const t = Object.keys(e).filter((
|
|
540
|
-
t.sort((
|
|
539
|
+
const t = Object.keys(e).filter((N) => e[N].type === m.FUNCTION).map((N) => N);
|
|
540
|
+
t.sort((N, V) => V.length - N.length);
|
|
541
541
|
const i = new RegExp(`^(${t.join("|")})\\(`), n = Object.keys(di);
|
|
542
|
-
n.sort((
|
|
542
|
+
n.sort((N, V) => V.length - N.length);
|
|
543
543
|
const r = new RegExp(`^(${n.join("|")})`), l = /^(\d+(\.\d+)?)/;
|
|
544
544
|
let c = "", d, f, g;
|
|
545
545
|
for (; o.length > 0; ) {
|
|
546
546
|
if (d = f, g = void 0, t.length > 0 && i.exec(o)) {
|
|
547
|
-
const
|
|
548
|
-
|
|
547
|
+
const N = t.find((V) => o.startsWith(V));
|
|
548
|
+
N && (g = N + "(", o = o.slice(N.length + 1), f = m.FUNCTION);
|
|
549
549
|
} else if (n.length > 0 && r.exec(o)) {
|
|
550
|
-
const
|
|
551
|
-
|
|
550
|
+
const N = n.find((V) => o.startsWith(V));
|
|
551
|
+
N && (g = N, o = o.slice(N.length), f = m.CONSTANT);
|
|
552
552
|
} else if (l.exec(o)) {
|
|
553
|
-
const
|
|
554
|
-
|
|
553
|
+
const N = l.exec(o);
|
|
554
|
+
N && (g = N[0], o = o.slice(N[0].length), f = m.COEFFICIENT);
|
|
555
555
|
} else
|
|
556
556
|
switch (g = o[0], o = o.slice(1), g) {
|
|
557
557
|
case "(":
|
|
@@ -703,17 +703,17 @@ class Qt {
|
|
|
703
703
|
break;
|
|
704
704
|
case m.OPERATION:
|
|
705
705
|
if (n.length > 0) {
|
|
706
|
-
let
|
|
707
|
-
for (g = +d;
|
|
708
|
-
(_(this, te)[r].associative === "left" && _(this, te)[r].precedence <= _(this, te)[
|
|
709
|
-
_(this, te)[r].associative === "right" && _(this, te)[r].precedence < _(this, te)[
|
|
706
|
+
let N = n[n.length - 1];
|
|
707
|
+
for (g = +d; N.token in _(this, te) && //either o1 is left-associative and its precedence is less than or equal to that of o2,
|
|
708
|
+
(_(this, te)[r].associative === "left" && _(this, te)[r].precedence <= _(this, te)[N.token].precedence || //or o1 is right associative, and has precedence less than that of o2,
|
|
709
|
+
_(this, te)[r].associative === "right" && _(this, te)[r].precedence < _(this, te)[N.token].precedence); ) {
|
|
710
710
|
if (g--, g === 0) {
|
|
711
711
|
console.log("SECURITY LEVEL 2 OPERATION EXIT");
|
|
712
712
|
break;
|
|
713
713
|
}
|
|
714
714
|
if (i.push(n.pop() ?? { token: "", tokenType: m.OPERATION }), n.length === 0)
|
|
715
715
|
break;
|
|
716
|
-
|
|
716
|
+
N = n[n.length - 1];
|
|
717
717
|
}
|
|
718
718
|
}
|
|
719
719
|
n.push({ token: r, tokenType: c });
|
|
@@ -852,7 +852,7 @@ class _i {
|
|
|
852
852
|
}
|
|
853
853
|
}
|
|
854
854
|
var T, v, Ye, xt, Le, qt, kt;
|
|
855
|
-
const
|
|
855
|
+
const P = class P {
|
|
856
856
|
constructor(e) {
|
|
857
857
|
p(this, Ye);
|
|
858
858
|
p(this, T);
|
|
@@ -861,7 +861,7 @@ const I = class I {
|
|
|
861
861
|
* Clone the current Monom.
|
|
862
862
|
*/
|
|
863
863
|
a(this, "clone", () => {
|
|
864
|
-
const e = new
|
|
864
|
+
const e = new P();
|
|
865
865
|
e.coefficient = s(this, T).clone();
|
|
866
866
|
for (const t in s(this, v))
|
|
867
867
|
e.setLetter(t, s(this, v)[t].clone());
|
|
@@ -873,8 +873,8 @@ const I = class I {
|
|
|
873
873
|
*/
|
|
874
874
|
a(this, "add", (...e) => {
|
|
875
875
|
for (const t of e) {
|
|
876
|
-
const i = t instanceof
|
|
877
|
-
this.isSameAs(i) ? (this.isZero() &&
|
|
876
|
+
const i = t instanceof P ? t : new P(t);
|
|
877
|
+
this.isSameAs(i) ? (this.isZero() && q(this, Ye, xt).call(this, i), s(this, T).add(i.coefficient)) : console.log("Add monom: " + this.display + " is not similar with ", i.display);
|
|
878
878
|
}
|
|
879
879
|
return this;
|
|
880
880
|
});
|
|
@@ -893,7 +893,7 @@ const I = class I {
|
|
|
893
893
|
const t = s(this, v)[e].clone(), i = this.clone();
|
|
894
894
|
return s(i, v)[e].subtract(1), s(i, T).multiply(new u(t.clone())), i;
|
|
895
895
|
} else
|
|
896
|
-
return new
|
|
896
|
+
return new P().zero();
|
|
897
897
|
});
|
|
898
898
|
/**
|
|
899
899
|
* Divide the current monoms by multiple monoms
|
|
@@ -901,7 +901,7 @@ const I = class I {
|
|
|
901
901
|
*/
|
|
902
902
|
a(this, "divide", (...e) => {
|
|
903
903
|
for (const t of e) {
|
|
904
|
-
const i = t instanceof
|
|
904
|
+
const i = t instanceof P ? t : new P(t);
|
|
905
905
|
s(this, T).divide(i.coefficient);
|
|
906
906
|
for (const n in i.literal)
|
|
907
907
|
s(this, v)[n] = this.hasVariable(n) ? s(this, v)[n].subtract(i.literal[n]) : i.literal[n].clone().opposite(), s(this, v)[n].isZero() && this.removeVariable(n);
|
|
@@ -1008,7 +1008,7 @@ const I = class I {
|
|
|
1008
1008
|
*/
|
|
1009
1009
|
a(this, "multiply", (...e) => {
|
|
1010
1010
|
for (const t of e) {
|
|
1011
|
-
const i = t instanceof
|
|
1011
|
+
const i = t instanceof P ? t : new P(t);
|
|
1012
1012
|
s(this, T).multiply(i.coefficient);
|
|
1013
1013
|
for (const n in i.literal)
|
|
1014
1014
|
this.hasVariable(n) ? s(this, v)[n].add(i.literal[n]) : s(this, v)[n] = i.literal[n].clone();
|
|
@@ -1075,8 +1075,8 @@ const I = class I {
|
|
|
1075
1075
|
*/
|
|
1076
1076
|
a(this, "subtract", (...e) => {
|
|
1077
1077
|
for (const t of e) {
|
|
1078
|
-
const i = t instanceof
|
|
1079
|
-
this.isSameAs(i) ? (this.isZero() &&
|
|
1078
|
+
const i = t instanceof P ? t : new P(t);
|
|
1079
|
+
this.isSameAs(i) ? (this.isZero() && q(this, Ye, xt).call(this, i), s(this, T).add(i.clone().coefficient.opposite())) : console.log("Subtract: Is not similar: ", i.display);
|
|
1080
1080
|
}
|
|
1081
1081
|
return this;
|
|
1082
1082
|
});
|
|
@@ -1122,23 +1122,23 @@ const I = class I {
|
|
|
1122
1122
|
var d;
|
|
1123
1123
|
let i, n, r, l, c;
|
|
1124
1124
|
if (t.tokenType === m.COEFFICIENT)
|
|
1125
|
-
e.push(new
|
|
1125
|
+
e.push(new P(new u(t.token)));
|
|
1126
1126
|
else if (t.tokenType === m.VARIABLE) {
|
|
1127
|
-
const f = new
|
|
1127
|
+
const f = new P().one();
|
|
1128
1128
|
f.setLetter(t.token, 1), e.push(f.clone());
|
|
1129
1129
|
} else if (t.tokenType === m.OPERATION)
|
|
1130
1130
|
switch (t.token) {
|
|
1131
1131
|
case "-":
|
|
1132
|
-
n = e.pop() ?? new
|
|
1132
|
+
n = e.pop() ?? new P().zero(), i = e.pop() ?? new P().zero(), e.push(i.subtract(n));
|
|
1133
1133
|
break;
|
|
1134
1134
|
case "*":
|
|
1135
|
-
n = e.pop() ?? new
|
|
1135
|
+
n = e.pop() ?? new P().one(), i = e.pop() ?? new P().one(), e.push(i.multiply(n));
|
|
1136
1136
|
break;
|
|
1137
1137
|
case "/":
|
|
1138
|
-
n = e.pop() ?? new
|
|
1138
|
+
n = e.pop() ?? new P().one(), i = e.pop() ?? new P().one(), e.push(i.divide(n));
|
|
1139
1139
|
break;
|
|
1140
1140
|
case "^": {
|
|
1141
|
-
c = ((d = e.pop()) == null ? void 0 : d.coefficient) ?? new u().one(), r = e.pop() ?? new
|
|
1141
|
+
c = ((d = e.pop()) == null ? void 0 : d.coefficient) ?? new u().one(), r = e.pop() ?? new P().one(), l = r.variables[0], l && r.setLetter(l, c), e.push(r);
|
|
1142
1142
|
break;
|
|
1143
1143
|
}
|
|
1144
1144
|
}
|
|
@@ -1151,7 +1151,7 @@ const I = class I {
|
|
|
1151
1151
|
* @param inputStr
|
|
1152
1152
|
*/
|
|
1153
1153
|
parse(e) {
|
|
1154
|
-
return h(this, T, new u()), h(this, v, {}), typeof e == "string" ? s(this, qt).call(this, e) : typeof e == "number" ? h(this, T, new u(e)) : e instanceof u ? h(this, T, e.clone()) : e instanceof
|
|
1154
|
+
return h(this, T, new u()), h(this, v, {}), typeof e == "string" ? s(this, qt).call(this, e) : typeof e == "number" ? h(this, T, new u(e)) : e instanceof u ? h(this, T, e.clone()) : e instanceof P && (h(this, T, s(e, T).clone()), q(this, Ye, xt).call(this, e)), this;
|
|
1155
1155
|
}
|
|
1156
1156
|
/**
|
|
1157
1157
|
* Get the coefficient \\(k\\) of the Monom \\(k\\cdot x^{n}\\)
|
|
@@ -1193,20 +1193,20 @@ const I = class I {
|
|
|
1193
1193
|
if (t.length > 0 && e.length > 0)
|
|
1194
1194
|
for (const n of e)
|
|
1195
1195
|
for (const r of t) {
|
|
1196
|
-
const l = new
|
|
1196
|
+
const l = new P();
|
|
1197
1197
|
l.coefficient = new u(n), l.literal = r, i.push(l);
|
|
1198
1198
|
}
|
|
1199
1199
|
else if (e.length === 0)
|
|
1200
1200
|
for (const n of t) {
|
|
1201
|
-
const r = new
|
|
1201
|
+
const r = new P();
|
|
1202
1202
|
r.coefficient = new u().one(), r.literal = n, i.push(r);
|
|
1203
1203
|
}
|
|
1204
1204
|
else
|
|
1205
1205
|
for (const n of e) {
|
|
1206
|
-
const r = new
|
|
1206
|
+
const r = new P();
|
|
1207
1207
|
r.coefficient = new u(n), i.push(r);
|
|
1208
1208
|
}
|
|
1209
|
-
return i.length === 0 ? [new
|
|
1209
|
+
return i.length === 0 ? [new P().one()] : i;
|
|
1210
1210
|
}
|
|
1211
1211
|
integrate(e, t, i) {
|
|
1212
1212
|
const n = this.primitive(i);
|
|
@@ -1301,11 +1301,11 @@ const I = class I {
|
|
|
1301
1301
|
T = new WeakMap(), v = new WeakMap(), Ye = new WeakSet(), xt = function(e) {
|
|
1302
1302
|
for (const t in e.literal)
|
|
1303
1303
|
s(this, v)[t] = e.literal[t].clone();
|
|
1304
|
-
}, Le = new WeakMap(), qt = new WeakMap(), kt = new WeakMap(), a(
|
|
1304
|
+
}, Le = new WeakMap(), qt = new WeakMap(), kt = new WeakMap(), a(P, "gcd", (...e) => {
|
|
1305
1305
|
for (const r of e)
|
|
1306
1306
|
if (r.containsRationalPower())
|
|
1307
|
-
return new
|
|
1308
|
-
const t = new
|
|
1307
|
+
return new P().zero();
|
|
1308
|
+
const t = new P(), i = G.gcd(...e.map((r) => r.coefficient.numerator)), n = G.lcm(...e.map((r) => r.coefficient.denominator));
|
|
1309
1309
|
t.coefficient = new u(i, n).reduce();
|
|
1310
1310
|
for (const r of e) {
|
|
1311
1311
|
for (const l in t.literal)
|
|
@@ -1318,20 +1318,20 @@ T = new WeakMap(), v = new WeakMap(), Ye = new WeakSet(), xt = function(e) {
|
|
|
1318
1318
|
* Multiply two monoms and return a NEW monom.
|
|
1319
1319
|
* @param monoms
|
|
1320
1320
|
*/
|
|
1321
|
-
a(
|
|
1322
|
-
const t = new
|
|
1321
|
+
a(P, "xMultiply", (...e) => {
|
|
1322
|
+
const t = new P().one();
|
|
1323
1323
|
for (const i of e)
|
|
1324
1324
|
t.multiply(i);
|
|
1325
1325
|
return t;
|
|
1326
1326
|
});
|
|
1327
|
-
let M =
|
|
1327
|
+
let M = P;
|
|
1328
1328
|
function wi(o, e = !0) {
|
|
1329
1329
|
return e ? `\\left( ${o} \\right)` : `(${o})`;
|
|
1330
1330
|
}
|
|
1331
1331
|
function Re(o, e, t, i, n) {
|
|
1332
1332
|
return o.map((r, l) => i !== void 0 && l < i || n !== void 0 && l > n ? r : r === e ? t : r);
|
|
1333
1333
|
}
|
|
1334
|
-
var Ue, y, Qe, ut, Ke, ft, Mt, Ct, $t, Je,
|
|
1334
|
+
var Ue, y, Qe, ut, Ke, ft, Mt, Ct, $t, Je, Pt, dt, It, Bt, St, Rt, Oi, zt, Lt;
|
|
1335
1335
|
const C = class C {
|
|
1336
1336
|
constructor(e, ...t) {
|
|
1337
1337
|
p(this, Rt);
|
|
@@ -1346,7 +1346,7 @@ const C = class C {
|
|
|
1346
1346
|
*/
|
|
1347
1347
|
a(this, "parse", (e, ...t) => {
|
|
1348
1348
|
if (h(this, y, []), h(this, Ue, []), typeof e == "string")
|
|
1349
|
-
return
|
|
1349
|
+
return q(this, Rt, Oi).call(this, e, ...t);
|
|
1350
1350
|
if ((typeof e == "number" || e instanceof u || e instanceof M) && t.length === 0)
|
|
1351
1351
|
s(this, y).push(new M(e));
|
|
1352
1352
|
else if (e instanceof M && t.length > 0)
|
|
@@ -1462,7 +1462,7 @@ const C = class C {
|
|
|
1462
1462
|
t.push(i.clone()), i.one();
|
|
1463
1463
|
break;
|
|
1464
1464
|
} else {
|
|
1465
|
-
let c = s(this,
|
|
1465
|
+
let c = s(this, Pt).call(this, i, l, e ?? "x");
|
|
1466
1466
|
for (l = i.degree(e).value; c.length > 0; ) {
|
|
1467
1467
|
const d = c[0];
|
|
1468
1468
|
if (!i.isDividableBy(d))
|
|
@@ -1470,8 +1470,8 @@ const C = class C {
|
|
|
1470
1470
|
else {
|
|
1471
1471
|
const f = i.euclidean(d);
|
|
1472
1472
|
t.push(d), i = f.quotient.clone(), c = c.filter((g) => {
|
|
1473
|
-
const
|
|
1474
|
-
return V.isDivisible(he) ?
|
|
1473
|
+
const N = i.monoms[0], V = i.monoms[i.monoms.length - 1], pe = g.monoms[0], he = g.monoms[g.monoms.length - 1];
|
|
1474
|
+
return V.isDivisible(he) ? N.isDivisible(pe) : !1;
|
|
1475
1475
|
});
|
|
1476
1476
|
}
|
|
1477
1477
|
}
|
|
@@ -1574,7 +1574,7 @@ const C = class C {
|
|
|
1574
1574
|
r.degree(t).isEqual(e) && i.push(r.clone());
|
|
1575
1575
|
return i;
|
|
1576
1576
|
});
|
|
1577
|
-
a(this, "multiply", (e) => e instanceof C ? s(this, St).call(this, e) : e instanceof u ? s(this, dt).call(this, e) : e instanceof M ? s(this, Bt).call(this, e) : Number.isSafeInteger(e) && typeof e == "number" ? s(this,
|
|
1577
|
+
a(this, "multiply", (e) => e instanceof C ? s(this, St).call(this, e) : e instanceof u ? s(this, dt).call(this, e) : e instanceof M ? s(this, Bt).call(this, e) : Number.isSafeInteger(e) && typeof e == "number" ? s(this, It).call(this, e) : this);
|
|
1578
1578
|
a(this, "one", () => (h(this, y, []), s(this, y).push(new M().one()), this));
|
|
1579
1579
|
// ------------------------------------------
|
|
1580
1580
|
a(this, "opposite", () => (h(this, y, s(this, y).map((e) => e.opposite())), this));
|
|
@@ -1677,7 +1677,7 @@ const C = class C {
|
|
|
1677
1677
|
}), t;
|
|
1678
1678
|
});
|
|
1679
1679
|
p(this, $t, (e) => {
|
|
1680
|
-
var
|
|
1680
|
+
var N;
|
|
1681
1681
|
let t, i, n, r, l, c, d, f, g;
|
|
1682
1682
|
if (this.numberOfVars === 1)
|
|
1683
1683
|
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() ? (d = r.clone().opposite().divide(n.clone().multiply(2)), t = new C(e).subtract(d.display).multiply(d.denominator), i = new C(e).subtract(d.display).multiply(d.denominator), g = n.divide(d.denominator).divide(d.denominator), g.isOne() ? [t, i] : [new C(g.display), t, i]) : c.isPositive() && c.isSquare() ? (d = r.clone().opposite().add(c.clone().sqrt()).divide(n.clone().multiply(2)), f = r.clone().opposite().subtract(c.clone().sqrt()).divide(n.clone().multiply(2)), g = n.divide(d.denominator).divide(f.denominator), g.isOne() ? [
|
|
@@ -1689,10 +1689,10 @@ const C = class C {
|
|
|
1689
1689
|
new C(e).subtract(f.display).multiply(f.denominator)
|
|
1690
1690
|
]) : [this.clone()];
|
|
1691
1691
|
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))) {
|
|
1692
|
-
const V = new C("x", n.coefficient, r.coefficient, l.coefficient),
|
|
1692
|
+
const V = new C("x", n.coefficient, r.coefficient, l.coefficient), pe = s(N = V, $t).call(N, "x"), he = [];
|
|
1693
1693
|
let ae;
|
|
1694
|
-
if (
|
|
1695
|
-
for (const ge of
|
|
1694
|
+
if (pe.length >= 2) {
|
|
1695
|
+
for (const ge of pe)
|
|
1696
1696
|
ge.degree().isZero() ? he.push(ge.clone()) : (ae = ge.clone(), ae.monoms[0].literal = n.literalSqrt, ae.monoms[1].literal = l.literalSqrt, he.push(ae.clone()));
|
|
1697
1697
|
return he;
|
|
1698
1698
|
}
|
|
@@ -1709,7 +1709,7 @@ const C = class C {
|
|
|
1709
1709
|
}
|
|
1710
1710
|
return i === !0 && this.length > 1 && (e === "tex" ? r = `\\left( ${r} \\right)` : r = `(${r})`), r === "" && (r = "0"), r;
|
|
1711
1711
|
});
|
|
1712
|
-
p(this,
|
|
1712
|
+
p(this, Pt, (e, t, i) => {
|
|
1713
1713
|
const n = e.monoms[0].dividers, r = e.monoms[e.monoms.length - 1].dividers, l = [];
|
|
1714
1714
|
return n.forEach((c) => {
|
|
1715
1715
|
c.degree(i).isLeq(t) && r.forEach((d) => {
|
|
@@ -1722,7 +1722,7 @@ const C = class C {
|
|
|
1722
1722
|
t.coefficient.multiply(e);
|
|
1723
1723
|
return this.reduce();
|
|
1724
1724
|
});
|
|
1725
|
-
p(this,
|
|
1725
|
+
p(this, It, (e) => s(this, dt).call(this, new u(e)));
|
|
1726
1726
|
p(this, Bt, (e) => {
|
|
1727
1727
|
for (const t of s(this, y))
|
|
1728
1728
|
t.multiply(e);
|
|
@@ -1865,8 +1865,8 @@ const C = class C {
|
|
|
1865
1865
|
0,
|
|
1866
1866
|
l
|
|
1867
1867
|
)), r = g * 2 + 1, l = f === i.length - 1 ? n.length : t.findIndex((V) => V.value === i[f + 1].value) * 2 + 1;
|
|
1868
|
-
const
|
|
1869
|
-
c = this.evaluate(
|
|
1868
|
+
const N = f === i.length - 1 ? d.value + 1 : (d.value + i[f + 1].value) / 2;
|
|
1869
|
+
c = this.evaluate(N, !0) < 0 ? "-" : "+", n[r] = "z", n = Re(n, "", c, r, l), r = +l, l = n.length;
|
|
1870
1870
|
});
|
|
1871
1871
|
}
|
|
1872
1872
|
return { roots: t, signs: n };
|
|
@@ -1884,7 +1884,7 @@ const C = class C {
|
|
|
1884
1884
|
return this.getZeroes();
|
|
1885
1885
|
}
|
|
1886
1886
|
};
|
|
1887
|
-
Ue = new WeakMap(), y = new WeakMap(), Qe = new WeakMap(), ut = new WeakMap(), Ke = new WeakMap(), ft = new WeakMap(), Mt = new WeakMap(), Ct = new WeakMap(), $t = new WeakMap(), Je = new WeakMap(),
|
|
1887
|
+
Ue = new WeakMap(), y = new WeakMap(), Qe = new WeakMap(), ut = new WeakMap(), Ke = new WeakMap(), ft = new WeakMap(), Mt = new WeakMap(), Ct = new WeakMap(), $t = new WeakMap(), Je = new WeakMap(), Pt = new WeakMap(), dt = new WeakMap(), It = new WeakMap(), Bt = new WeakMap(), St = new WeakMap(), Rt = new WeakSet(), Oi = function(e, ...t) {
|
|
1888
1888
|
if (t.length === 0) {
|
|
1889
1889
|
if (e = "" + e, e !== "" && !isNaN(Number(e))) {
|
|
1890
1890
|
this.empty();
|
|
@@ -1913,7 +1913,7 @@ Ue = new WeakMap(), y = new WeakMap(), Qe = new WeakMap(), ut = new WeakMap(), K
|
|
|
1913
1913
|
} else
|
|
1914
1914
|
return this.zero();
|
|
1915
1915
|
}, zt = new WeakMap(), Lt = new WeakMap();
|
|
1916
|
-
let
|
|
1916
|
+
let O = C;
|
|
1917
1917
|
var A, k, se, Dt, _e, Vt;
|
|
1918
1918
|
const Ee = class Ee {
|
|
1919
1919
|
constructor(e, t, i) {
|
|
@@ -1929,7 +1929,7 @@ const Ee = class Ee {
|
|
|
1929
1929
|
if (t === !1)
|
|
1930
1930
|
throw new Error("The equation is not valid (no sign found)");
|
|
1931
1931
|
const i = e.split(t);
|
|
1932
|
-
return this.create(new
|
|
1932
|
+
return this.create(new O(i[0]), new O(i[1]), s(this, _e).call(this, t));
|
|
1933
1933
|
});
|
|
1934
1934
|
a(this, "create", (e, t, i) => (h(this, A, e), h(this, k, t), h(this, se, s(this, _e).call(this, i ?? "=")), this));
|
|
1935
1935
|
a(this, "clone", () => new Ee(s(this, A).clone(), s(this, k).clone(), s(this, se)));
|
|
@@ -2048,11 +2048,11 @@ const Ee = class Ee {
|
|
|
2048
2048
|
// Equations solving algorithms
|
|
2049
2049
|
p(this, _e, (e) => e === void 0 ? "=" : e.includes("geq") || e.includes(">=") || e.includes("=>") ? ">=" : e.includes(">") ? ">" : e.includes("leq") || e.includes("<=") || e.includes("=<") ? "<=" : e.includes("<") ? "<" : "=");
|
|
2050
2050
|
p(this, Vt, () => s(this, se) === "=" ? this : s(this, se).includes("<") ? (s(this, se).replace("<", ">"), this) : s(this, se).includes(">") ? (s(this, se).replace(">", "<"), this) : this);
|
|
2051
|
-
if (h(this, A, new
|
|
2051
|
+
if (h(this, A, new O().zero()), h(this, k, new O().zero()), h(this, se, "="), e !== void 0 && t === void 0) {
|
|
2052
2052
|
if (e instanceof Ee)
|
|
2053
2053
|
return e.clone();
|
|
2054
2054
|
typeof e == "string" && this.parse(e);
|
|
2055
|
-
} else e !== void 0 && t !== void 0 && (this.left = new
|
|
2055
|
+
} else e !== void 0 && t !== void 0 && (this.left = new O(e), this.right = new O(t));
|
|
2056
2056
|
return i !== void 0 && (this.sign = i), this;
|
|
2057
2057
|
}
|
|
2058
2058
|
/**
|
|
@@ -2068,7 +2068,7 @@ const Ee = class Ee {
|
|
|
2068
2068
|
return s(this, A).add(e.left), s(this, k).add(e.right), this;
|
|
2069
2069
|
if (typeof e == "string" && !Ee.isEquationString(e))
|
|
2070
2070
|
return this.add(new Ee(e));
|
|
2071
|
-
const t = new
|
|
2071
|
+
const t = new O(e);
|
|
2072
2072
|
return s(this, A).add(t), s(this, k).add(t), this;
|
|
2073
2073
|
}
|
|
2074
2074
|
/**
|
|
@@ -2099,7 +2099,7 @@ const Ee = class Ee {
|
|
|
2099
2099
|
return s(this, A).subtract(e.left), s(this, k).subtract(e.right), this;
|
|
2100
2100
|
if (typeof e == "string" && !Ee.isEquationString(e))
|
|
2101
2101
|
return this.subtract(new Ee(e));
|
|
2102
|
-
const t = new
|
|
2102
|
+
const t = new O(e);
|
|
2103
2103
|
return s(this, A).subtract(t), s(this, k).subtract(t), this;
|
|
2104
2104
|
}
|
|
2105
2105
|
static isEquationString(e) {
|
|
@@ -2158,9 +2158,9 @@ const ve = class ve {
|
|
|
2158
2158
|
h(this, Te, e.polynom.clone()), h(this, Ae, e.power.clone());
|
|
2159
2159
|
else if (typeof e == "string" && t === void 0) {
|
|
2160
2160
|
const [i, n = "1"] = e.split("^");
|
|
2161
|
-
h(this, Te, new
|
|
2161
|
+
h(this, Te, new O(i)), h(this, Ae, new u(n.replace("(", "").replace(")", "")));
|
|
2162
2162
|
} else
|
|
2163
|
-
h(this, Te, new
|
|
2163
|
+
h(this, Te, new O(e)), h(this, Ae, new u(t ?? 1));
|
|
2164
2164
|
return h(this, Ne, 1), this;
|
|
2165
2165
|
}
|
|
2166
2166
|
parse() {
|
|
@@ -2203,7 +2203,7 @@ const ve = class ve {
|
|
|
2203
2203
|
divide(e) {
|
|
2204
2204
|
if (e instanceof ve && this.isSameAs(e))
|
|
2205
2205
|
return this.power.subtract(e.power), this;
|
|
2206
|
-
const t = new
|
|
2206
|
+
const t = new O(e);
|
|
2207
2207
|
if (this.isSameAs(t))
|
|
2208
2208
|
return this.power.subtract(1), this;
|
|
2209
2209
|
throw new Error("The two factors must be the same");
|
|
@@ -2225,7 +2225,7 @@ const ve = class ve {
|
|
|
2225
2225
|
}
|
|
2226
2226
|
isSameAs(e) {
|
|
2227
2227
|
let t;
|
|
2228
|
-
return e instanceof ve ? t = e.polynom : e instanceof
|
|
2228
|
+
return e instanceof ve ? t = e.polynom : e instanceof O ? t = e : t = new O(e), this.polynom.isEqual(t);
|
|
2229
2229
|
}
|
|
2230
2230
|
isZero() {
|
|
2231
2231
|
return this.polynom.isZero();
|
|
@@ -2233,7 +2233,7 @@ const ve = class ve {
|
|
|
2233
2233
|
multiply(e) {
|
|
2234
2234
|
if (e instanceof ve && this.isSameAs(e))
|
|
2235
2235
|
return this.power.add(e.power), this;
|
|
2236
|
-
const t = new
|
|
2236
|
+
const t = new O(e);
|
|
2237
2237
|
if (this.isSameAs(t))
|
|
2238
2238
|
return this.power.add(1), this;
|
|
2239
2239
|
throw new Error("The two factors must be the same");
|
|
@@ -2292,7 +2292,7 @@ const ve = class ve {
|
|
|
2292
2292
|
}
|
|
2293
2293
|
};
|
|
2294
2294
|
Ne = new WeakMap(), Te = new WeakMap(), Ae = new WeakMap(), et = new WeakMap();
|
|
2295
|
-
let
|
|
2295
|
+
let le = ve;
|
|
2296
2296
|
var at = /* @__PURE__ */ ((o) => (o[o.ROOT = 0] = "ROOT", o[o.POWER = 1] = "POWER", o))(at || {}), D, $e, Zt, Ft;
|
|
2297
2297
|
const He = class He {
|
|
2298
2298
|
constructor(...e) {
|
|
@@ -2371,7 +2371,7 @@ const He = class He {
|
|
|
2371
2371
|
const n = t.split("").splice(0, i - 1);
|
|
2372
2372
|
return new He(
|
|
2373
2373
|
...e.map((r) => {
|
|
2374
|
-
const l = new
|
|
2374
|
+
const l = new O(n.join(""), ...r);
|
|
2375
2375
|
return new H(l, 0);
|
|
2376
2376
|
})
|
|
2377
2377
|
);
|
|
@@ -2552,13 +2552,13 @@ class es {
|
|
|
2552
2552
|
return s(this, Oe).filter((e) => e.tokenType === "variable").map((e) => e.token);
|
|
2553
2553
|
}
|
|
2554
2554
|
vennAB() {
|
|
2555
|
-
return
|
|
2555
|
+
return q(this, pt, si).call(this, {
|
|
2556
2556
|
A: ["A", "AB"],
|
|
2557
2557
|
B: ["B", "AB"]
|
|
2558
2558
|
}, ["A", "B", "AB", "E"]);
|
|
2559
2559
|
}
|
|
2560
2560
|
vennABC() {
|
|
2561
|
-
return
|
|
2561
|
+
return q(this, pt, si).call(this, {
|
|
2562
2562
|
A: ["A", "AB", "AC", "ABC"],
|
|
2563
2563
|
B: ["B", "AB", "BC", "ABC"],
|
|
2564
2564
|
C: ["C", "AC", "BC", "ABC"]
|
|
@@ -2609,34 +2609,34 @@ Oe = new WeakMap(), pt = new WeakSet(), si = function(e, t) {
|
|
|
2609
2609
|
}
|
|
2610
2610
|
return [...i[0]].sort();
|
|
2611
2611
|
};
|
|
2612
|
-
var tt,
|
|
2613
|
-
const
|
|
2612
|
+
var tt, E, mt, ri, gt, oi;
|
|
2613
|
+
const ue = class ue {
|
|
2614
2614
|
constructor(...e) {
|
|
2615
2615
|
p(this, gt);
|
|
2616
2616
|
p(this, tt, at.POWER);
|
|
2617
|
-
p(this,
|
|
2617
|
+
p(this, E, []);
|
|
2618
2618
|
return this.parse(...e), this;
|
|
2619
2619
|
}
|
|
2620
2620
|
parse(...e) {
|
|
2621
|
-
return e.length === 0 ? this : (h(this,
|
|
2621
|
+
return e.length === 0 ? this : (h(this, E, []), e.forEach((t) => {
|
|
2622
2622
|
if (typeof t == "string") {
|
|
2623
2623
|
const i = t.split(")(").join(")*(").split("*");
|
|
2624
|
-
s(this,
|
|
2625
|
-
} else t instanceof
|
|
2624
|
+
s(this, E).push(...i.map((n) => new le(n)));
|
|
2625
|
+
} else t instanceof ue ? s(this, E).push(...t.factors.map((i) => i.clone())) : s(this, E).push(new le(t));
|
|
2626
2626
|
}), this);
|
|
2627
2627
|
}
|
|
2628
2628
|
clone() {
|
|
2629
|
-
return new
|
|
2629
|
+
return new ue(...s(this, E).map((e) => e.clone()));
|
|
2630
2630
|
}
|
|
2631
2631
|
get tex() {
|
|
2632
|
-
const { num: e, den: t } =
|
|
2632
|
+
const { num: e, den: t } = q(this, gt, oi).call(this);
|
|
2633
2633
|
if (t.length === 0)
|
|
2634
2634
|
return e.length === 1 ? e[0].asSingle.tex : e.map((r) => r.tex).join("");
|
|
2635
2635
|
const i = e.length === 1 ? e[0].asSingle.tex : e.map((r) => r.tex).join(""), n = t.length === 1 ? t[0].asSingle.tex : t.map((r) => r.tex).join("");
|
|
2636
2636
|
return `\\frac{ ${i} }{ ${n} }`;
|
|
2637
2637
|
}
|
|
2638
2638
|
get display() {
|
|
2639
|
-
const { num: e, den: t } =
|
|
2639
|
+
const { num: e, den: t } = q(this, gt, oi).call(this);
|
|
2640
2640
|
if (t.length === 0)
|
|
2641
2641
|
return e.length === 1 ? e[0].asSingle.display : e.map((r) => r.display).join("");
|
|
2642
2642
|
const i = e.length === 1 ? e[0].asSingle.display : e.map((r) => r.display).join(""), n = t.length === 1 ? t[0].asSingle.display : t.map((r) => r.display).join("");
|
|
@@ -2645,25 +2645,25 @@ const me = class me {
|
|
|
2645
2645
|
static gcd(...e) {
|
|
2646
2646
|
var i;
|
|
2647
2647
|
if (e.length === 0)
|
|
2648
|
-
return new
|
|
2648
|
+
return new ue().one();
|
|
2649
2649
|
if (e.length === 1)
|
|
2650
2650
|
return e[0];
|
|
2651
2651
|
if (e.length === 2)
|
|
2652
|
-
return
|
|
2652
|
+
return q(i = ue, mt, ri).call(i, e[0], e[1]);
|
|
2653
2653
|
let t = e[0];
|
|
2654
2654
|
return e.shift(), e.forEach((n) => {
|
|
2655
2655
|
var r;
|
|
2656
|
-
return t =
|
|
2656
|
+
return t = q(r = ue, mt, ri).call(r, t, n);
|
|
2657
2657
|
}), t;
|
|
2658
2658
|
}
|
|
2659
2659
|
add(...e) {
|
|
2660
2660
|
let t = [this, ...e];
|
|
2661
|
-
const i =
|
|
2661
|
+
const i = ue.gcd(...t);
|
|
2662
2662
|
t = t.map((r) => r.divide(i).reduce());
|
|
2663
|
-
const n = new
|
|
2664
|
-
return t.forEach((r) => n.add(r.develop())), h(this,
|
|
2663
|
+
const n = new O("0");
|
|
2664
|
+
return t.forEach((r) => n.add(r.develop())), h(this, E, [
|
|
2665
2665
|
...i.factors,
|
|
2666
|
-
new
|
|
2666
|
+
new le(n)
|
|
2667
2667
|
]), this;
|
|
2668
2668
|
}
|
|
2669
2669
|
get asPower() {
|
|
@@ -2673,47 +2673,47 @@ const me = class me {
|
|
|
2673
2673
|
return h(this, tt, at.ROOT), this;
|
|
2674
2674
|
}
|
|
2675
2675
|
degree(e) {
|
|
2676
|
-
return s(this,
|
|
2676
|
+
return s(this, E).reduce((t, i) => t.add(i.degree(e)), new u("0"));
|
|
2677
2677
|
}
|
|
2678
2678
|
get denominator() {
|
|
2679
|
-
return s(this,
|
|
2679
|
+
return s(this, E).filter((e) => e.power.isNegative());
|
|
2680
2680
|
}
|
|
2681
2681
|
derivative() {
|
|
2682
|
-
const e = [], t = s(this,
|
|
2682
|
+
const e = [], t = s(this, E).length;
|
|
2683
2683
|
for (let n = 0; n < t; n++) {
|
|
2684
|
-
const r = s(this,
|
|
2685
|
-
e.push(new
|
|
2684
|
+
const r = s(this, E).slice(), l = r.splice(n, 1)[0];
|
|
2685
|
+
e.push(new ue(...r).multiply(new ue(...l.derivative())));
|
|
2686
2686
|
}
|
|
2687
2687
|
e.forEach((n) => n.reduce());
|
|
2688
2688
|
const i = e.shift();
|
|
2689
|
-
return i !== void 0 && h(this,
|
|
2689
|
+
return i !== void 0 && h(this, E, i.factors), this.add(...e);
|
|
2690
2690
|
}
|
|
2691
2691
|
develop() {
|
|
2692
|
-
const e = new
|
|
2693
|
-
return s(this,
|
|
2692
|
+
const e = new O("1");
|
|
2693
|
+
return s(this, E).forEach((t) => {
|
|
2694
2694
|
e.multiply(t.develop());
|
|
2695
2695
|
}), e;
|
|
2696
2696
|
}
|
|
2697
2697
|
divide(e) {
|
|
2698
|
-
return h(this,
|
|
2698
|
+
return h(this, E, s(this, E).concat(e.clone().factors.map((t) => t.inverse()))), this;
|
|
2699
2699
|
}
|
|
2700
2700
|
evaluate(e, t) {
|
|
2701
|
-
return t ? s(this,
|
|
2701
|
+
return t ? s(this, E).reduce((i, n) => i * n.evaluate(e, t), 1) : s(this, E).reduce((i, n) => i.multiply(n.evaluate(e)), new u("1"));
|
|
2702
2702
|
}
|
|
2703
2703
|
get factors() {
|
|
2704
|
-
return s(this,
|
|
2704
|
+
return s(this, E);
|
|
2705
2705
|
}
|
|
2706
2706
|
set factors(e) {
|
|
2707
|
-
h(this,
|
|
2707
|
+
h(this, E, e);
|
|
2708
2708
|
}
|
|
2709
|
-
fromPolynom(e, t) {
|
|
2710
|
-
return h(this,
|
|
2709
|
+
fromPolynom(e, t, i) {
|
|
2710
|
+
return h(this, E, new O(e).factorize(i).map((n) => new le(n))), t && new O(t).factorize(i).forEach((n) => s(this, E).push(new le(n, -1))), this;
|
|
2711
2711
|
}
|
|
2712
2712
|
getFactors() {
|
|
2713
|
-
return s(this,
|
|
2713
|
+
return s(this, E);
|
|
2714
2714
|
}
|
|
2715
2715
|
getZeroes() {
|
|
2716
|
-
const e = [].concat(...s(this,
|
|
2716
|
+
const e = [].concat(...s(this, E).map((t) => t.polynom.getZeroes()));
|
|
2717
2717
|
return e.sort((t, i) => t.value - i.value), e.filter(
|
|
2718
2718
|
(t, i, n) => i === n.findIndex(
|
|
2719
2719
|
(r) => r.value === t.value
|
|
@@ -2721,63 +2721,69 @@ const me = class me {
|
|
|
2721
2721
|
);
|
|
2722
2722
|
}
|
|
2723
2723
|
hasVariable(e) {
|
|
2724
|
-
return s(this,
|
|
2724
|
+
return s(this, E).some((t) => t.hasVariable(e));
|
|
2725
2725
|
}
|
|
2726
2726
|
inverse() {
|
|
2727
|
-
return h(this,
|
|
2727
|
+
return h(this, E, s(this, E).map((e) => e.inverse())), this;
|
|
2728
2728
|
}
|
|
2729
2729
|
isEqual(e) {
|
|
2730
|
-
const t =
|
|
2730
|
+
const t = ue.gcd(this, e), i = this.clone().divide(t).reduce(), n = e.clone().divide(t).reduce();
|
|
2731
2731
|
return i.isOne() && n.isOne();
|
|
2732
2732
|
}
|
|
2733
2733
|
isOne() {
|
|
2734
|
-
return s(this,
|
|
2734
|
+
return s(this, E).every((e) => e.isOne());
|
|
2735
2735
|
}
|
|
2736
2736
|
isZero() {
|
|
2737
|
-
return s(this,
|
|
2737
|
+
return s(this, E).every((e) => e.isZero());
|
|
2738
2738
|
}
|
|
2739
2739
|
multiply(...e) {
|
|
2740
2740
|
return e.forEach((t) => {
|
|
2741
|
-
h(this,
|
|
2741
|
+
h(this, E, s(this, E).concat(t.clone().factors));
|
|
2742
2742
|
}), this;
|
|
2743
2743
|
}
|
|
2744
2744
|
get numerator() {
|
|
2745
|
-
return s(this,
|
|
2745
|
+
return s(this, E).filter((e) => e.power.isPositive());
|
|
2746
2746
|
}
|
|
2747
2747
|
one() {
|
|
2748
|
-
return h(this,
|
|
2748
|
+
return h(this, E, [new le("1", "1")]), this;
|
|
2749
2749
|
}
|
|
2750
2750
|
opposite() {
|
|
2751
|
-
const e = s(this,
|
|
2752
|
-
return e >= 0 ? s(this,
|
|
2751
|
+
const e = s(this, E).findIndex((t) => t.display === "(-1)");
|
|
2752
|
+
return e >= 0 ? s(this, E).splice(e, 1) : s(this, E).push(new le("-1", "1")), this;
|
|
2753
2753
|
}
|
|
2754
2754
|
pow(e) {
|
|
2755
|
-
return h(this,
|
|
2755
|
+
return h(this, E, s(this, E).map((t) => t.pow(e))), this;
|
|
2756
2756
|
}
|
|
2757
2757
|
primitive() {
|
|
2758
2758
|
throw new Error("Method not implemented.");
|
|
2759
2759
|
}
|
|
2760
2760
|
reduce() {
|
|
2761
2761
|
const e = ei(this);
|
|
2762
|
-
return h(this,
|
|
2762
|
+
return h(this, E, Object.values(e).map((t) => {
|
|
2763
2763
|
const i = t[0].polynom, n = t.reduce((r, l) => r.add(l.power), new u("0"));
|
|
2764
|
-
return new
|
|
2764
|
+
return new le(i, n.reduce());
|
|
2765
2765
|
}).filter((t) => !t.power.isZero())), this;
|
|
2766
2766
|
}
|
|
2767
2767
|
root(e) {
|
|
2768
|
-
return h(this,
|
|
2768
|
+
return h(this, E, s(this, E).map((t) => t.root(e))), this;
|
|
2769
2769
|
}
|
|
2770
2770
|
sort() {
|
|
2771
|
-
return h(this,
|
|
2771
|
+
return h(this, E, s(this, E).sort((e, t) => e.degree().isLeq(t.degree()) ? -1 : 1)), this;
|
|
2772
|
+
}
|
|
2773
|
+
splitFactors() {
|
|
2774
|
+
return {
|
|
2775
|
+
numerator: new ue(...s(this, E).filter((e) => e.power.isPositive())),
|
|
2776
|
+
denominator: new ue(...s(this, E).filter((e) => e.power.isStrictlyNegative()))
|
|
2777
|
+
};
|
|
2772
2778
|
}
|
|
2773
2779
|
sqrt() {
|
|
2774
|
-
return h(this,
|
|
2780
|
+
return h(this, E, s(this, E).map((e) => e.sqrt())), this;
|
|
2775
2781
|
}
|
|
2776
2782
|
subtract(...e) {
|
|
2777
2783
|
return this.add(...e.map((t) => t.opposite()));
|
|
2778
2784
|
}
|
|
2779
2785
|
tableOfSigns() {
|
|
2780
|
-
const e = this.getZeroes(), t = this.factors.map((n) => ({ factor: new
|
|
2786
|
+
const e = this.getZeroes(), t = this.factors.map((n) => ({ factor: new le(n), ...n.tableOfSigns(e) }));
|
|
2781
2787
|
return { signs: t.map((n) => n.signs).reduce((n, r) => (n.length === 0 ? n = r : r.forEach((l, c) => {
|
|
2782
2788
|
switch (l) {
|
|
2783
2789
|
case "d":
|
|
@@ -2796,23 +2802,23 @@ const me = class me {
|
|
|
2796
2802
|
}), n), []), roots: e, factors: t };
|
|
2797
2803
|
}
|
|
2798
2804
|
get variables() {
|
|
2799
|
-
return s(this,
|
|
2805
|
+
return s(this, E).reduce((e, t) => e.concat(t.variables), []);
|
|
2800
2806
|
}
|
|
2801
2807
|
zero() {
|
|
2802
|
-
return h(this,
|
|
2808
|
+
return h(this, E, [new le("0", "1")]), this;
|
|
2803
2809
|
}
|
|
2804
2810
|
};
|
|
2805
|
-
tt = new WeakMap(),
|
|
2811
|
+
tt = new WeakMap(), E = new WeakMap(), mt = new WeakSet(), ri = function(e, t) {
|
|
2806
2812
|
const i = ei(e), n = ei(t), l = Object.keys(i).filter((c) => Object.hasOwn(n, c)).map((c) => {
|
|
2807
|
-
const d = i[c].reduce((g,
|
|
2808
|
-
return new
|
|
2813
|
+
const d = i[c].reduce((g, N) => g.add(N.power), new u("0")), f = n[c].reduce((g, N) => g.add(N.power), new u("0"));
|
|
2814
|
+
return new le(c, u.min(d, f));
|
|
2809
2815
|
});
|
|
2810
|
-
return new
|
|
2816
|
+
return new ue(...l);
|
|
2811
2817
|
}, gt = new WeakSet(), oi = function() {
|
|
2812
2818
|
let e, t = [];
|
|
2813
|
-
return s(this, tt) === at.ROOT ? (e = this.numerator, t = this.denominator.map((i) => i.clone().inverse())) : e = s(this,
|
|
2814
|
-
}, p(
|
|
2815
|
-
let ni =
|
|
2819
|
+
return s(this, tt) === at.ROOT ? (e = this.numerator, t = this.denominator.map((i) => i.clone().inverse())) : e = s(this, E), e.length === 0 && (e = [new le("1")]), { num: e, den: t };
|
|
2820
|
+
}, p(ue, mt);
|
|
2821
|
+
let ni = ue;
|
|
2816
2822
|
function ei(o) {
|
|
2817
2823
|
const e = new u().one(), t = o.factors.reduce((i, n) => {
|
|
2818
2824
|
if (n.polynom.degree().isZero())
|
|
@@ -2820,7 +2826,7 @@ function ei(o) {
|
|
|
2820
2826
|
const r = n.polynom.display;
|
|
2821
2827
|
return Object.hasOwn(i, r) ? i[r].push(n) : i[r] = [n], i;
|
|
2822
2828
|
}, {});
|
|
2823
|
-
return e.isOne() || (t[e.display] = [new
|
|
2829
|
+
return e.isOne() || (t[e.display] = [new le(e.display, 1)]), t;
|
|
2824
2830
|
}
|
|
2825
2831
|
function ts(o, e) {
|
|
2826
2832
|
return o.dimension === e.dimension && o.array.every(
|
|
@@ -3041,22 +3047,22 @@ var we = /* @__PURE__ */ ((o) => (o.None = "none", o.Parallel = "parallel", o.Pe
|
|
|
3041
3047
|
function qi(o = 0.5) {
|
|
3042
3048
|
return Math.random() < o;
|
|
3043
3049
|
}
|
|
3044
|
-
function
|
|
3050
|
+
function de(o, e, t) {
|
|
3045
3051
|
if (e === void 0)
|
|
3046
|
-
return o >= 0 ?
|
|
3052
|
+
return o >= 0 ? de(0, o) : de(o, 0);
|
|
3047
3053
|
if (o === e)
|
|
3048
3054
|
return o;
|
|
3049
3055
|
if (t === void 0)
|
|
3050
3056
|
return Math.floor(Math.random() * (e - o + 1) + o);
|
|
3051
3057
|
if (Math.abs(e - o) <= t.length)
|
|
3052
3058
|
throw new Error("The number of excluded values is too high.");
|
|
3053
|
-
let i =
|
|
3059
|
+
let i = de(o, e);
|
|
3054
3060
|
for (; t.includes(i); )
|
|
3055
|
-
i =
|
|
3061
|
+
i = de(o, e);
|
|
3056
3062
|
return i;
|
|
3057
3063
|
}
|
|
3058
3064
|
function Y(o, e) {
|
|
3059
|
-
return e === !1 ? qi() ?
|
|
3065
|
+
return e === !1 ? qi() ? de(1, o) : -de(1, o) : de(-o, o);
|
|
3060
3066
|
}
|
|
3061
3067
|
function rs(o) {
|
|
3062
3068
|
let e = G.primes();
|
|
@@ -3066,7 +3072,7 @@ function os(o, e) {
|
|
|
3066
3072
|
return e === void 0 && (e = 1), o.length <= 0 ? Object.values(o) : ki(o).slice(0, e);
|
|
3067
3073
|
}
|
|
3068
3074
|
function pi(o) {
|
|
3069
|
-
return o.length === 0 ? null : o[
|
|
3075
|
+
return o.length === 0 ? null : o[de(0, o.length - 1)];
|
|
3070
3076
|
}
|
|
3071
3077
|
function ki(o) {
|
|
3072
3078
|
const e = Object.values(o);
|
|
@@ -3102,7 +3108,7 @@ class B extends x {
|
|
|
3102
3108
|
return e.array = this.copy(), e.asPoint = !0, e;
|
|
3103
3109
|
}
|
|
3104
3110
|
}
|
|
3105
|
-
var
|
|
3111
|
+
var Pe, S, z, U, ne, Q, Ie, be;
|
|
3106
3112
|
const Ze = class Ze {
|
|
3107
3113
|
/**
|
|
3108
3114
|
* Value can be a mix of:
|
|
@@ -3110,14 +3116,14 @@ const Ze = class Ze {
|
|
|
3110
3116
|
* @param values
|
|
3111
3117
|
*/
|
|
3112
3118
|
constructor(...e) {
|
|
3113
|
-
p(this,
|
|
3119
|
+
p(this, Pe);
|
|
3114
3120
|
// ax + by + c = 0
|
|
3115
3121
|
p(this, S);
|
|
3116
3122
|
p(this, z);
|
|
3117
3123
|
p(this, U);
|
|
3118
3124
|
p(this, ne);
|
|
3119
3125
|
p(this, Q);
|
|
3120
|
-
p(this,
|
|
3126
|
+
p(this, Ie);
|
|
3121
3127
|
p(this, be, "canonical");
|
|
3122
3128
|
a(this, "randomPoint", (e) => {
|
|
3123
3129
|
const t = s(this, Q).clone().multiplyByScalar(Y(e === void 0 || e <= 1 ? 3 : e, !1)).add(s(this, ne));
|
|
@@ -3189,19 +3195,19 @@ const Ze = class Ze {
|
|
|
3189
3195
|
e.left.monomByDegree(0).coefficient
|
|
3190
3196
|
);
|
|
3191
3197
|
});
|
|
3192
|
-
a(this, "fromCoefficient", (e, t, i) => (h(this, S, new u(e)), h(this, z, new u(t)), h(this, U, new u(i)), h(this, Q, new x(s(this, z).clone(), s(this, S).clone().opposite())), h(this, ne, new x(new u().zero(), s(this, U).clone())), h(this,
|
|
3198
|
+
a(this, "fromCoefficient", (e, t, i) => (h(this, S, new u(e)), h(this, z, new u(t)), h(this, U, new u(i)), h(this, Q, new x(s(this, z).clone(), s(this, S).clone().opposite())), h(this, ne, new x(new u().zero(), s(this, U).clone())), h(this, Ie, s(this, Q).clone().normal()), this));
|
|
3193
3199
|
a(this, "fromPointAndDirection", (e, t) => (this.fromCoefficient(
|
|
3194
3200
|
t.y,
|
|
3195
3201
|
t.x.clone().opposite(),
|
|
3196
3202
|
e.x.clone().multiply(t.y).subtract(e.y.clone().multiply(t.x)).opposite()
|
|
3197
|
-
), h(this, ne, e.clone()), h(this, Q, t.clone()), h(this,
|
|
3203
|
+
), h(this, ne, e.clone()), h(this, Q, t.clone()), h(this, Ie, s(this, Q).clone().normal()), this));
|
|
3198
3204
|
a(this, "fromPointAndNormal", (e, t) => this.fromCoefficient(
|
|
3199
3205
|
t.x,
|
|
3200
3206
|
t.y,
|
|
3201
3207
|
e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)).opposite()
|
|
3202
3208
|
));
|
|
3203
3209
|
a(this, "fromPointAndLine", (e, t, i) => (i === void 0 && (i = we.Parallel), i === we.Parallel ? this.fromPointAndNormal(e, t.normal) : i === we.Perpendicular ? this.fromPointAndNormal(e, t.director) : this));
|
|
3204
|
-
a(this, "clone", () => (h(this, S, s(this, S).clone()), h(this, z, s(this, z).clone()), h(this, U, s(this, U).clone()), h(this, Q, s(this, Q).clone()), h(this, ne, s(this, ne).clone()), h(this,
|
|
3210
|
+
a(this, "clone", () => (h(this, S, s(this, S).clone()), h(this, z, s(this, z).clone()), h(this, U, s(this, U).clone()), h(this, Q, s(this, Q).clone()), h(this, ne, s(this, ne).clone()), h(this, Ie, s(this, Ie).clone()), this));
|
|
3205
3211
|
// ------------------------------------------
|
|
3206
3212
|
// Mathematical operations
|
|
3207
3213
|
// ------------------------------------------
|
|
@@ -3239,7 +3245,7 @@ const Ze = class Ze {
|
|
|
3239
3245
|
const t = this.getEquation().isolate("x"), i = new u(e);
|
|
3240
3246
|
return t instanceof H ? t.right.evaluate({ y: i }) : new u().invalid();
|
|
3241
3247
|
});
|
|
3242
|
-
return h(this, S, new u().zero()), h(this, z, new u().zero()), h(this, U, new u().zero()), h(this, ne, new x()), h(this, Q, new x()), h(this,
|
|
3248
|
+
return h(this, S, new u().zero()), h(this, z, new u().zero()), h(this, U, new u().zero()), h(this, ne, new x()), h(this, Q, new x()), h(this, Ie, new x()), h(this, Pe, !0), e.length > 0 && this.parse(...e), this;
|
|
3243
3249
|
}
|
|
3244
3250
|
get a() {
|
|
3245
3251
|
return s(this, S);
|
|
@@ -3274,12 +3280,12 @@ const Ze = class Ze {
|
|
|
3274
3280
|
h(this, Q, e);
|
|
3275
3281
|
}
|
|
3276
3282
|
get n() {
|
|
3277
|
-
return s(this,
|
|
3283
|
+
return s(this, Ie);
|
|
3278
3284
|
}
|
|
3279
3285
|
// ------------------------------------------
|
|
3280
3286
|
getEquation() {
|
|
3281
|
-
const e = new H(new
|
|
3282
|
-
return s(this,
|
|
3287
|
+
const e = new H(new O().parse("xy", s(this, S), s(this, z), s(this, U)), new O("0"));
|
|
3288
|
+
return s(this, Pe) ? e.simplify() : e;
|
|
3283
3289
|
}
|
|
3284
3290
|
// get system(): { x: Equation, y: Equation } {
|
|
3285
3291
|
// const e1 = new Equation(
|
|
@@ -3315,13 +3321,13 @@ const Ze = class Ze {
|
|
|
3315
3321
|
case "equation":
|
|
3316
3322
|
return this.getEquation().reorder().tex;
|
|
3317
3323
|
case "mxh":
|
|
3318
|
-
return this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new
|
|
3324
|
+
return this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new O().parse("x", this.slope, this.height).tex;
|
|
3319
3325
|
case "parametric":
|
|
3320
3326
|
case "system": {
|
|
3321
3327
|
const t = s(this, Q).clone();
|
|
3322
|
-
return s(this,
|
|
3323
|
-
x &= ${new
|
|
3324
|
-
y &= ${new
|
|
3328
|
+
return s(this, Pe) && t.simplify(), e === "parametric" ? `${x.asTex("x", "y")} = ${x.asTex(s(this, ne).x.tex, s(this, ne).y.tex)} + k\\cdot ${x.asTex(t.x.tex, t.y.tex)}` : `\\left\\{\\begin{aligned}
|
|
3329
|
+
x &= ${new O(s(this, ne).x).add(new M(s(this, Q).x).multiply(new M("k"))).reorder("k", !0).tex}\\\\
|
|
3330
|
+
y &= ${new O(s(this, ne).y).add(new M(s(this, Q).y).multiply(new M("k"))).reorder("k", !0).tex}
|
|
3325
3331
|
\\end{aligned}\\right.`;
|
|
3326
3332
|
}
|
|
3327
3333
|
default: {
|
|
@@ -3331,10 +3337,10 @@ const Ze = class Ze {
|
|
|
3331
3337
|
}
|
|
3332
3338
|
}
|
|
3333
3339
|
get reduceBeforeDisplay() {
|
|
3334
|
-
return s(this,
|
|
3340
|
+
return s(this, Pe);
|
|
3335
3341
|
}
|
|
3336
3342
|
set reduceBeforeDisplay(e) {
|
|
3337
|
-
h(this,
|
|
3343
|
+
h(this, Pe, e);
|
|
3338
3344
|
}
|
|
3339
3345
|
get display() {
|
|
3340
3346
|
const e = s(this, be);
|
|
@@ -3342,10 +3348,10 @@ const Ze = class Ze {
|
|
|
3342
3348
|
case "equation":
|
|
3343
3349
|
return this.getEquation().reorder().display;
|
|
3344
3350
|
case "mxh":
|
|
3345
|
-
return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new
|
|
3351
|
+
return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new O().parse("x", this.slope, this.height).display;
|
|
3346
3352
|
case "parametric": {
|
|
3347
3353
|
const t = s(this, Q).clone();
|
|
3348
|
-
return s(this,
|
|
3354
|
+
return s(this, Pe) && t.simplify(), `((x,y))=((${s(this, ne).x.display},${s(this, ne).y.display}))+k((${t.x.display},${t.y.display}))`;
|
|
3349
3355
|
}
|
|
3350
3356
|
default: {
|
|
3351
3357
|
const t = this.getEquation();
|
|
@@ -3402,10 +3408,10 @@ const Ze = class Ze {
|
|
|
3402
3408
|
return s(this, S).isZero() || (s(this, S).isOne() ? t = "x" : s(this, S).clone().opposite().isOne() ? t = "-x" : t = s(this, S).value.toFixed(e) + "x"), s(this, z).isZero() || (s(this, z).isPositive() && (t += "+"), t += s(this, z).value.toFixed(e) + "y"), s(this, U).isZero() || (s(this, U).isPositive() && (t += "+"), t += s(this, U).value.toFixed(e)), t + "=0";
|
|
3403
3409
|
}
|
|
3404
3410
|
};
|
|
3405
|
-
|
|
3411
|
+
Pe = new WeakMap(), S = new WeakMap(), z = new WeakMap(), U = new WeakMap(), ne = new WeakMap(), Q = new WeakMap(), Ie = new WeakMap(), be = new WeakMap(), // A line is defined as the canonical form
|
|
3406
3412
|
a(Ze, "PERPENDICULAR", we.Perpendicular), a(Ze, "PARALLEL", we.Parallel);
|
|
3407
3413
|
let R = Ze;
|
|
3408
|
-
var re, j, qe, jt, Ut, Gt, oe, Mi, Et, Ci, $i,
|
|
3414
|
+
var re, j, qe, jt, Ut, Gt, oe, Mi, Et, Ci, $i, Pi, ai;
|
|
3409
3415
|
const Wt = class Wt {
|
|
3410
3416
|
constructor(...e) {
|
|
3411
3417
|
p(this, oe);
|
|
@@ -3452,7 +3458,7 @@ const Wt = class Wt {
|
|
|
3452
3458
|
return [new R(e, t, we.Perpendicular)];
|
|
3453
3459
|
});
|
|
3454
3460
|
p(this, Ut, (e) => {
|
|
3455
|
-
const t = this.center.x.clone().subtract(e.x), i = this.center.y.clone().subtract(e.y), n = new
|
|
3461
|
+
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");
|
|
3456
3462
|
return n.multiply(t).subtract(i).pow(2), r.multiply(this.squareRadius), new H(n, r).solve().map((d) => {
|
|
3457
3463
|
let f;
|
|
3458
3464
|
const g = new H("y", "x");
|
|
@@ -3506,10 +3512,10 @@ const Wt = class Wt {
|
|
|
3506
3512
|
);
|
|
3507
3513
|
}
|
|
3508
3514
|
setRadius(e, t) {
|
|
3509
|
-
return t ? h(this, j, new u(e)) : h(this, j, new u(e).pow(2)),
|
|
3515
|
+
return t ? h(this, j, new u(e)) : h(this, j, new u(e).pow(2)), q(this, oe, Et).call(this), this;
|
|
3510
3516
|
}
|
|
3511
3517
|
parse(...e) {
|
|
3512
|
-
return
|
|
3518
|
+
return q(this, oe, Mi).call(this), typeof e[0] == "string" ? q(this, oe, ai).call(this, new H(e[0])) : e[0] instanceof H ? q(this, oe, ai).call(this, e[0]) : e[0] instanceof Wt ? q(this, oe, Ci).call(this, e[0]) : e[0] instanceof B && e.length > 1 && (e[1] instanceof B ? e[2] instanceof B || q(this, oe, Pi).call(this, e[0], e[1]) : (e[1] instanceof u || typeof e[1] == "number") && q(this, oe, $i).call(this, e[0], e[1], typeof e[2] == "boolean" ? e[2] : !1)), q(this, oe, Et).call(this), this;
|
|
3513
3519
|
}
|
|
3514
3520
|
// private _parseThroughtThreePoints(A: Point, B: Point, C: Point): this {
|
|
3515
3521
|
// const T = new Triangle(A, B, C), mAB = T.remarquables.mediators.AB.clone(),
|
|
@@ -3522,14 +3528,14 @@ re = new WeakMap(), j = new WeakMap(), qe = new WeakMap(), jt = new WeakMap(), U
|
|
|
3522
3528
|
return h(this, re, void 0), h(this, j, void 0), h(this, qe, void 0), this;
|
|
3523
3529
|
}, Et = function() {
|
|
3524
3530
|
h(this, qe, new H(
|
|
3525
|
-
new
|
|
3526
|
-
new
|
|
3531
|
+
new O(`(x-(${this.center.x.display}))^2+(y-(${this.center.y.display}))^2`),
|
|
3532
|
+
new O(this.squareRadius.display)
|
|
3527
3533
|
).moveLeft());
|
|
3528
3534
|
}, Ci = function(e) {
|
|
3529
|
-
return h(this, re, e.center.clone()), h(this, j, e.squareRadius.clone()),
|
|
3535
|
+
return h(this, re, e.center.clone()), h(this, j, e.squareRadius.clone()), q(this, oe, Et).call(this), this;
|
|
3530
3536
|
}, $i = function(e, t, i) {
|
|
3531
3537
|
return h(this, re, e.clone()), i ? h(this, j, new u(t)) : h(this, j, new u(t).pow(2)), this;
|
|
3532
|
-
},
|
|
3538
|
+
}, Pi = function(e, t) {
|
|
3533
3539
|
return h(this, re, e.clone()), h(this, j, new x(s(this, re), t).normSquare), this;
|
|
3534
3540
|
}, ai = function(e) {
|
|
3535
3541
|
if (e.moveLeft(), e.degree("x").value === 2 && e.degree("y").value === 2) {
|
|
@@ -3614,11 +3620,11 @@ const lt = class lt {
|
|
|
3614
3620
|
return {
|
|
3615
3621
|
parametric: `${x.asTex("x", "y", "z")} = ${x.asTex(s(this, L).x.tex, s(this, L).y.tex, s(this, L).z.tex)} + k\\cdot ${x.asTex(s(this, W).x.tex, s(this, W).y.tex, s(this, W).z.tex)}`,
|
|
3616
3622
|
system: `\\left\\{\\begin{aligned}
|
|
3617
|
-
x &= ${new
|
|
3618
|
-
y &= ${new
|
|
3619
|
-
z &= ${new
|
|
3623
|
+
x &= ${new O(s(this, L).x).add(new M(s(this, W).x).multiply(new M("k"))).reorder("k", !0).tex}\\\\
|
|
3624
|
+
y &= ${new O(s(this, L).y).add(new M(s(this, W).y).multiply(new M("k"))).reorder("k", !0).tex}\\\\
|
|
3625
|
+
z &= ${new O(s(this, L).z).add(new M(s(this, W).z).multiply(new M("k"))).reorder("k", !0).tex}
|
|
3620
3626
|
\\end{aligned}\\right.`,
|
|
3621
|
-
cartesian: `\\frac{ ${new
|
|
3627
|
+
cartesian: `\\frac{ ${new O("x", 1, s(this, L).x.clone().opposite()).tex} }{ ${this.direction.x.tex} } = \\frac{ ${new O("y", 1, s(this, L).y.clone().opposite()).tex} }{ ${this.direction.y.tex} } = \\frac{ ${new O("z", 1, s(this, L).z.clone().opposite()).tex} }{ ${this.direction.z.tex} }`
|
|
3622
3628
|
};
|
|
3623
3629
|
}
|
|
3624
3630
|
get display() {
|
|
@@ -3708,8 +3714,8 @@ const gi = class gi {
|
|
|
3708
3714
|
}
|
|
3709
3715
|
get tex() {
|
|
3710
3716
|
return new H(
|
|
3711
|
-
new
|
|
3712
|
-
new
|
|
3717
|
+
new O("xyz", this.a, this.b, this.c, this.d),
|
|
3718
|
+
new O(0)
|
|
3713
3719
|
).reduce().tex;
|
|
3714
3720
|
}
|
|
3715
3721
|
parse(e) {
|
|
@@ -3984,16 +3990,16 @@ function Ot(o) {
|
|
|
3984
3990
|
},
|
|
3985
3991
|
o
|
|
3986
3992
|
), t = new u();
|
|
3987
|
-
if (e.negative ? t.numerator = Y(e.max, e.zero) : t.numerator =
|
|
3993
|
+
if (e.negative ? t.numerator = Y(e.max, e.zero) : t.numerator = de(e.zero ? 0 : 1, e.max), e.natural)
|
|
3988
3994
|
t.denominator = 1;
|
|
3989
3995
|
else {
|
|
3990
3996
|
let i = 0;
|
|
3991
3997
|
for (; t.isRelative() && i < 10; )
|
|
3992
|
-
t.denominator =
|
|
3998
|
+
t.denominator = de(1, e.max), i++;
|
|
3993
3999
|
}
|
|
3994
4000
|
return e.reduced ? t.reduce() : t;
|
|
3995
4001
|
}
|
|
3996
|
-
function
|
|
4002
|
+
function Ii(o) {
|
|
3997
4003
|
const e = Object.assign(
|
|
3998
4004
|
{
|
|
3999
4005
|
letters: "x",
|
|
@@ -4033,10 +4039,10 @@ function Bi(o) {
|
|
|
4033
4039
|
const e = Object.assign(
|
|
4034
4040
|
as,
|
|
4035
4041
|
o
|
|
4036
|
-
), t = new
|
|
4042
|
+
), t = new O().empty();
|
|
4037
4043
|
let i;
|
|
4038
4044
|
for (let n = e.degree; n >= 0; n--)
|
|
4039
|
-
i =
|
|
4045
|
+
i = Ii({
|
|
4040
4046
|
letters: e.letters,
|
|
4041
4047
|
degree: n,
|
|
4042
4048
|
fraction: e.fraction,
|
|
@@ -4044,7 +4050,7 @@ function Bi(o) {
|
|
|
4044
4050
|
}), e.unit && e.degree === n && i.coefficient.one(), t.add(i);
|
|
4045
4051
|
if (e.positive && t.monomByDegree().coefficient.isNegative() && t.monomByDegree().coefficient.opposite(), e.numberOfMonoms && e.numberOfMonoms > 0 && e.numberOfMonoms < t.length)
|
|
4046
4052
|
for (; t.length > e.numberOfMonoms; ) {
|
|
4047
|
-
const n =
|
|
4053
|
+
const n = de(1, t.length - 1);
|
|
4048
4054
|
t.monoms.splice(n, 1);
|
|
4049
4055
|
}
|
|
4050
4056
|
return t.reduce();
|
|
@@ -4069,7 +4075,7 @@ function ls(o) {
|
|
|
4069
4075
|
}
|
|
4070
4076
|
},
|
|
4071
4077
|
o
|
|
4072
|
-
), t = new
|
|
4078
|
+
), t = new O().one();
|
|
4073
4079
|
for (let i = 0; i < e.degree; i++) {
|
|
4074
4080
|
const n = Bi({
|
|
4075
4081
|
degree: 1,
|
|
@@ -4106,7 +4112,7 @@ function cs(o) {
|
|
|
4106
4112
|
o
|
|
4107
4113
|
), t = ui(e.center);
|
|
4108
4114
|
let i, n;
|
|
4109
|
-
return e.pointsOnCircle === 8 ? (i =
|
|
4115
|
+
return e.pointsOnCircle === 8 ? (i = de(1, 3), n = i ** 2 + (i + 1) ** 2) : n = de(1, 20), new Tt(t, n, !0);
|
|
4110
4116
|
}
|
|
4111
4117
|
function us(o) {
|
|
4112
4118
|
const e = Object.assign(
|
|
@@ -4146,9 +4152,9 @@ function fs(o) {
|
|
|
4146
4152
|
const ds = {
|
|
4147
4153
|
equation: (o) => ls(o),
|
|
4148
4154
|
polynom: (o) => Bi(o),
|
|
4149
|
-
monom: (o) =>
|
|
4155
|
+
monom: (o) => Ii(o),
|
|
4150
4156
|
fraction: (o) => Ot(o),
|
|
4151
|
-
number: (o, e, t) =>
|
|
4157
|
+
number: (o, e, t) => de(o, e, t),
|
|
4152
4158
|
numberSym: (o, e) => Y(o, e),
|
|
4153
4159
|
prime: (o) => rs(o),
|
|
4154
4160
|
bool: (o) => qi(o),
|
|
@@ -4168,11 +4174,11 @@ const ds = {
|
|
|
4168
4174
|
Fraction: u,
|
|
4169
4175
|
Root: vt,
|
|
4170
4176
|
Monom: M,
|
|
4171
|
-
Polynom:
|
|
4177
|
+
Polynom: O,
|
|
4172
4178
|
Equation: H,
|
|
4173
4179
|
Matrix: hs,
|
|
4174
4180
|
LinearSystem: ii,
|
|
4175
|
-
Factor:
|
|
4181
|
+
Factor: le,
|
|
4176
4182
|
PolyFactor: ni,
|
|
4177
4183
|
LogicalSet: es,
|
|
4178
4184
|
Random: ds,
|
|
@@ -4192,7 +4198,7 @@ export {
|
|
|
4192
4198
|
H as Equation,
|
|
4193
4199
|
Nt as EquationSolver,
|
|
4194
4200
|
at as FACTOR_DISPLAY,
|
|
4195
|
-
|
|
4201
|
+
le as Factor,
|
|
4196
4202
|
u as Fraction,
|
|
4197
4203
|
R as Line,
|
|
4198
4204
|
At as Line3,
|
|
@@ -4201,10 +4207,13 @@ export {
|
|
|
4201
4207
|
hs as Matrix,
|
|
4202
4208
|
M as Monom,
|
|
4203
4209
|
vt as NthRoot,
|
|
4210
|
+
_i as NumExp,
|
|
4211
|
+
G as Numeric,
|
|
4204
4212
|
li as Plane3,
|
|
4205
4213
|
B as Point,
|
|
4206
4214
|
ni as PolyFactor,
|
|
4207
|
-
|
|
4215
|
+
O as Polynom,
|
|
4216
|
+
ds as Random,
|
|
4208
4217
|
ci as Triangle,
|
|
4209
4218
|
x as Vector,
|
|
4210
4219
|
is as areVectorsColinears,
|