pimath 0.1.22 → 0.1.23
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 +2 -6
- package/dist/pimath.js +76 -82
- package/dist/pimath.js.map +1 -1
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@ export declare class PolyFactor implements IPiMathObject<PolyFactor>, IExpressio
|
|
|
14
14
|
get asPower(): this;
|
|
15
15
|
get asRoot(): this;
|
|
16
16
|
degree(letter?: string): Fraction;
|
|
17
|
-
get denominator():
|
|
17
|
+
get denominator(): PolyFactor;
|
|
18
18
|
derivative(): this;
|
|
19
19
|
develop(): Polynom;
|
|
20
20
|
divide(value: PolyFactor): this;
|
|
@@ -30,7 +30,7 @@ export declare class PolyFactor implements IPiMathObject<PolyFactor>, IExpressio
|
|
|
30
30
|
isOne(): boolean;
|
|
31
31
|
isZero(): boolean;
|
|
32
32
|
multiply(...values: PolyFactor[]): this;
|
|
33
|
-
get numerator():
|
|
33
|
+
get numerator(): PolyFactor;
|
|
34
34
|
one(): this;
|
|
35
35
|
opposite(): this;
|
|
36
36
|
pow(value: number | Fraction): this;
|
|
@@ -38,10 +38,6 @@ export declare class PolyFactor implements IPiMathObject<PolyFactor>, IExpressio
|
|
|
38
38
|
reduce(): this;
|
|
39
39
|
root(value: number): this;
|
|
40
40
|
sort(): this;
|
|
41
|
-
splitFactors(): {
|
|
42
|
-
numerator: PolyFactor;
|
|
43
|
-
denominator: PolyFactor;
|
|
44
|
-
};
|
|
45
41
|
sqrt(): this;
|
|
46
42
|
subtract(...values: PolyFactor[]): this;
|
|
47
43
|
tableOfSigns(): POLYFACTOR_TABLE_OF_SIGNS;
|
package/dist/pimath.js
CHANGED
|
@@ -391,10 +391,10 @@ class vt {
|
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
393
|
Z = new WeakMap(), ee = new WeakMap(), ie = new WeakMap(), Xe = new WeakMap();
|
|
394
|
-
var fe, je,
|
|
394
|
+
var fe, je, P, ot, ye, bi, ti, xi, Ei, Ni;
|
|
395
395
|
const mi = class mi {
|
|
396
396
|
constructor(e, t, i = "x") {
|
|
397
|
-
p(this,
|
|
397
|
+
p(this, P);
|
|
398
398
|
p(this, fe);
|
|
399
399
|
p(this, je);
|
|
400
400
|
if (h(this, je, i), Object.hasOwn(e, "moveLeft")) {
|
|
@@ -405,23 +405,23 @@ const mi = class mi {
|
|
|
405
405
|
}
|
|
406
406
|
solve() {
|
|
407
407
|
if (s(this, fe).degree().isOne())
|
|
408
|
-
return q(this,
|
|
408
|
+
return q(this, P, xi).call(this);
|
|
409
409
|
if (s(this, fe).degree().value === 2)
|
|
410
|
-
return q(this,
|
|
411
|
-
const e = q(this,
|
|
410
|
+
return q(this, P, Ei).call(this);
|
|
411
|
+
const e = q(this, P, bi).call(this);
|
|
412
412
|
if (e.length > 0)
|
|
413
413
|
return e;
|
|
414
414
|
if (s(this, fe).degree().value === 3)
|
|
415
|
-
return q(this,
|
|
415
|
+
return q(this, P, ti).call(this);
|
|
416
416
|
throw new Error("The equation degree is too high.");
|
|
417
417
|
}
|
|
418
418
|
solveAsCardan() {
|
|
419
419
|
if (s(this, fe).degree().value !== 3)
|
|
420
420
|
throw new Error("The equation is not cubic.");
|
|
421
|
-
return q(this,
|
|
421
|
+
return q(this, P, ti).call(this);
|
|
422
422
|
}
|
|
423
423
|
};
|
|
424
|
-
fe = new WeakMap(), je = new WeakMap(),
|
|
424
|
+
fe = new WeakMap(), je = new WeakMap(), P = new WeakSet(), ot = function(e, t) {
|
|
425
425
|
return {
|
|
426
426
|
variable: s(this, je),
|
|
427
427
|
exact: !1,
|
|
@@ -431,7 +431,7 @@ fe = new WeakMap(), je = new WeakMap(), I = new WeakSet(), ot = function(e, t) {
|
|
|
431
431
|
};
|
|
432
432
|
}, ye = function(e) {
|
|
433
433
|
if (e instanceof u && e.isApproximative())
|
|
434
|
-
return q(this,
|
|
434
|
+
return q(this, P, ot).call(this, e.value);
|
|
435
435
|
const t = new u(e);
|
|
436
436
|
return {
|
|
437
437
|
variable: s(this, je),
|
|
@@ -447,12 +447,12 @@ fe = new WeakMap(), je = new WeakMap(), I = new WeakSet(), ot = function(e, t) {
|
|
|
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(q(this,
|
|
450
|
+
t.length === 0 && t.push(q(this, P, 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
454
|
const N = new u(g, f);
|
|
455
|
-
e.evaluate(N).isZero() && !t.find((V) => V.value === N.value) && t.push(q(this,
|
|
455
|
+
e.evaluate(N).isZero() && !t.find((V) => V.value === N.value) && t.push(q(this, P, ye).call(this, N)), N.opposite(), e.evaluate(N).isZero() && !t.find((V) => V.value === N.value) && t.push(q(this, P, ye).call(this, N));
|
|
456
456
|
}
|
|
457
457
|
for (const f of t) {
|
|
458
458
|
if (f.exact !== !1 && f.exact.isZero())
|
|
@@ -471,26 +471,26 @@ fe = new WeakMap(), je = new WeakMap(), I = new WeakSet(), ot = function(e, t) {
|
|
|
471
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
472
|
if (pe.isNegative()) {
|
|
473
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,
|
|
474
|
+
return [q(this, P, ye).call(this, ge)];
|
|
475
475
|
}
|
|
476
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) ? [q(this,
|
|
479
|
-
q(this,
|
|
480
|
-
q(this,
|
|
478
|
+
return ae.isEqual(ge) ? [q(this, P, ye).call(this, ae)] : [
|
|
479
|
+
q(this, P, ye).call(this, ge),
|
|
480
|
+
q(this, P, ye).call(this, ae)
|
|
481
481
|
].sort((me, ce) => me.value - ce.value);
|
|
482
482
|
}
|
|
483
483
|
if (pe.isPositive()) {
|
|
484
484
|
const he = [], ae = f.value, ge = g.value, me = l.value;
|
|
485
485
|
for (let ce = 0; ce < 3; ce++)
|
|
486
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,
|
|
487
|
+
return he.map((ce) => q(this, P, ot).call(this, ce)).sort((ce, nt) => ce.value - nt.value);
|
|
488
488
|
}
|
|
489
489
|
return [];
|
|
490
490
|
}, xi = function() {
|
|
491
491
|
const e = s(this, fe).monomByDegree(0).coefficient.clone().opposite().divide(s(this, fe).monomByDegree(1).coefficient);
|
|
492
492
|
return [
|
|
493
|
-
q(this,
|
|
493
|
+
q(this, P, ye).call(this, e)
|
|
494
494
|
];
|
|
495
495
|
}, Ei = function() {
|
|
496
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));
|
|
@@ -498,12 +498,12 @@ fe = new WeakMap(), je = new WeakMap(), I = new WeakSet(), ot = function(e, t) {
|
|
|
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() ? [q(this,
|
|
502
|
-
q(this,
|
|
503
|
-
q(this,
|
|
501
|
+
return l.isZero() ? [q(this, P, ye).call(this, c)] : [
|
|
502
|
+
q(this, P, ye).call(this, c),
|
|
503
|
+
q(this, P, ye).call(this, d)
|
|
504
504
|
].sort((f, g) => f.value - g.value);
|
|
505
505
|
}
|
|
506
|
-
return q(this,
|
|
506
|
+
return q(this, P, Ni).call(this, t, i, r);
|
|
507
507
|
}, Ni = function(e, t, i) {
|
|
508
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
509
|
function V(me, ce, nt, Kt) {
|
|
@@ -514,11 +514,11 @@ fe = new WeakMap(), je = new WeakMap(), I = new WeakSet(), ot = function(e, t) {
|
|
|
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
|
-
q(this,
|
|
517
|
+
q(this, P, ot).call(this, ae, {
|
|
518
518
|
tex: V(c.tex, l.tex, g.toString(), d.tex),
|
|
519
519
|
display: pe(c.display, l.display, g.toString(), d.display)
|
|
520
520
|
}),
|
|
521
|
-
q(this,
|
|
521
|
+
q(this, P, ot).call(this, ge, {
|
|
522
522
|
tex: V(c.tex, l.tex, N.toString(), d.tex),
|
|
523
523
|
display: pe(c.display, l.display, N.toString(), d.display)
|
|
524
524
|
})
|
|
@@ -852,7 +852,7 @@ class _i {
|
|
|
852
852
|
}
|
|
853
853
|
}
|
|
854
854
|
var T, v, Ye, xt, Le, qt, kt;
|
|
855
|
-
const
|
|
855
|
+
const I = class I {
|
|
856
856
|
constructor(e) {
|
|
857
857
|
p(this, Ye);
|
|
858
858
|
p(this, T);
|
|
@@ -861,7 +861,7 @@ const P = class P {
|
|
|
861
861
|
* Clone the current Monom.
|
|
862
862
|
*/
|
|
863
863
|
a(this, "clone", () => {
|
|
864
|
-
const e = new
|
|
864
|
+
const e = new I();
|
|
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,7 +873,7 @@ const P = class P {
|
|
|
873
873
|
*/
|
|
874
874
|
a(this, "add", (...e) => {
|
|
875
875
|
for (const t of e) {
|
|
876
|
-
const i = t instanceof
|
|
876
|
+
const i = t instanceof I ? t : new I(t);
|
|
877
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;
|
|
@@ -893,7 +893,7 @@ const P = class P {
|
|
|
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 I().zero();
|
|
897
897
|
});
|
|
898
898
|
/**
|
|
899
899
|
* Divide the current monoms by multiple monoms
|
|
@@ -901,7 +901,7 @@ const P = class P {
|
|
|
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 I ? t : new I(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 P = class P {
|
|
|
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 I ? t : new I(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,7 +1075,7 @@ const P = class P {
|
|
|
1075
1075
|
*/
|
|
1076
1076
|
a(this, "subtract", (...e) => {
|
|
1077
1077
|
for (const t of e) {
|
|
1078
|
-
const i = t instanceof
|
|
1078
|
+
const i = t instanceof I ? t : new I(t);
|
|
1079
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;
|
|
@@ -1122,23 +1122,23 @@ const P = class P {
|
|
|
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 I(new u(t.token)));
|
|
1126
1126
|
else if (t.tokenType === m.VARIABLE) {
|
|
1127
|
-
const f = new
|
|
1127
|
+
const f = new I().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 I().zero(), i = e.pop() ?? new I().zero(), e.push(i.subtract(n));
|
|
1133
1133
|
break;
|
|
1134
1134
|
case "*":
|
|
1135
|
-
n = e.pop() ?? new
|
|
1135
|
+
n = e.pop() ?? new I().one(), i = e.pop() ?? new I().one(), e.push(i.multiply(n));
|
|
1136
1136
|
break;
|
|
1137
1137
|
case "/":
|
|
1138
|
-
n = e.pop() ?? new
|
|
1138
|
+
n = e.pop() ?? new I().one(), i = e.pop() ?? new I().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 I().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 P = class P {
|
|
|
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 I && (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 P = class P {
|
|
|
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 I();
|
|
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 I();
|
|
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 I();
|
|
1207
1207
|
r.coefficient = new u(n), i.push(r);
|
|
1208
1208
|
}
|
|
1209
|
-
return i.length === 0 ? [new
|
|
1209
|
+
return i.length === 0 ? [new I().one()] : i;
|
|
1210
1210
|
}
|
|
1211
1211
|
integrate(e, t, i) {
|
|
1212
1212
|
const n = this.primitive(i);
|
|
@@ -1301,11 +1301,11 @@ const P = class P {
|
|
|
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(I, "gcd", (...e) => {
|
|
1305
1305
|
for (const r of e)
|
|
1306
1306
|
if (r.containsRationalPower())
|
|
1307
|
-
return new
|
|
1308
|
-
const t = new
|
|
1307
|
+
return new I().zero();
|
|
1308
|
+
const t = new I(), 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(I, "xMultiply", (...e) => {
|
|
1322
|
+
const t = new I().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 = I;
|
|
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, It, dt, Pt, Bt, St, Rt, Oi, zt, Lt;
|
|
1335
1335
|
const C = class C {
|
|
1336
1336
|
constructor(e, ...t) {
|
|
1337
1337
|
p(this, Rt);
|
|
@@ -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, It).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))
|
|
@@ -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, Pt).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));
|
|
@@ -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, It, (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, Pt, (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);
|
|
@@ -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(), It = new WeakMap(), dt = new WeakMap(), Pt = 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();
|
|
@@ -2676,7 +2676,7 @@ const ue = class ue {
|
|
|
2676
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, E).filter((e) => e.power.isNegative());
|
|
2679
|
+
return new ue(...s(this, E).filter((e) => e.power.isNegative()));
|
|
2680
2680
|
}
|
|
2681
2681
|
derivative() {
|
|
2682
2682
|
const e = [], t = s(this, E).length;
|
|
@@ -2742,7 +2742,7 @@ const ue = class ue {
|
|
|
2742
2742
|
}), this;
|
|
2743
2743
|
}
|
|
2744
2744
|
get numerator() {
|
|
2745
|
-
return s(this, E).filter((e) => e.power.isPositive());
|
|
2745
|
+
return new ue(...s(this, E).filter((e) => e.power.isPositive()));
|
|
2746
2746
|
}
|
|
2747
2747
|
one() {
|
|
2748
2748
|
return h(this, E, [new le("1", "1")]), this;
|
|
@@ -2770,12 +2770,6 @@ const ue = class ue {
|
|
|
2770
2770
|
sort() {
|
|
2771
2771
|
return h(this, E, s(this, E).sort((e, t) => e.degree().isLeq(t.degree()) ? -1 : 1)), this;
|
|
2772
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
|
-
};
|
|
2778
|
-
}
|
|
2779
2773
|
sqrt() {
|
|
2780
2774
|
return h(this, E, s(this, E).map((e) => e.sqrt())), this;
|
|
2781
2775
|
}
|
|
@@ -2816,7 +2810,7 @@ tt = new WeakMap(), E = new WeakMap(), mt = new WeakSet(), ri = function(e, t) {
|
|
|
2816
2810
|
return new ue(...l);
|
|
2817
2811
|
}, gt = new WeakSet(), oi = function() {
|
|
2818
2812
|
let e, t = [];
|
|
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 };
|
|
2813
|
+
return s(this, tt) === at.ROOT ? (e = this.numerator.factors, t = this.denominator.factors.map((i) => i.clone().inverse())) : e = s(this, E), e.length === 0 && (e = [new le("1")]), { num: e, den: t };
|
|
2820
2814
|
}, p(ue, mt);
|
|
2821
2815
|
let ni = ue;
|
|
2822
2816
|
function ei(o) {
|
|
@@ -3108,7 +3102,7 @@ class B extends x {
|
|
|
3108
3102
|
return e.array = this.copy(), e.asPoint = !0, e;
|
|
3109
3103
|
}
|
|
3110
3104
|
}
|
|
3111
|
-
var
|
|
3105
|
+
var Ie, S, z, U, ne, Q, Pe, be;
|
|
3112
3106
|
const Ze = class Ze {
|
|
3113
3107
|
/**
|
|
3114
3108
|
* Value can be a mix of:
|
|
@@ -3116,14 +3110,14 @@ const Ze = class Ze {
|
|
|
3116
3110
|
* @param values
|
|
3117
3111
|
*/
|
|
3118
3112
|
constructor(...e) {
|
|
3119
|
-
p(this,
|
|
3113
|
+
p(this, Ie);
|
|
3120
3114
|
// ax + by + c = 0
|
|
3121
3115
|
p(this, S);
|
|
3122
3116
|
p(this, z);
|
|
3123
3117
|
p(this, U);
|
|
3124
3118
|
p(this, ne);
|
|
3125
3119
|
p(this, Q);
|
|
3126
|
-
p(this,
|
|
3120
|
+
p(this, Pe);
|
|
3127
3121
|
p(this, be, "canonical");
|
|
3128
3122
|
a(this, "randomPoint", (e) => {
|
|
3129
3123
|
const t = s(this, Q).clone().multiplyByScalar(Y(e === void 0 || e <= 1 ? 3 : e, !1)).add(s(this, ne));
|
|
@@ -3195,19 +3189,19 @@ const Ze = class Ze {
|
|
|
3195
3189
|
e.left.monomByDegree(0).coefficient
|
|
3196
3190
|
);
|
|
3197
3191
|
});
|
|
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,
|
|
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, Pe, s(this, Q).clone().normal()), this));
|
|
3199
3193
|
a(this, "fromPointAndDirection", (e, t) => (this.fromCoefficient(
|
|
3200
3194
|
t.y,
|
|
3201
3195
|
t.x.clone().opposite(),
|
|
3202
3196
|
e.x.clone().multiply(t.y).subtract(e.y.clone().multiply(t.x)).opposite()
|
|
3203
|
-
), h(this, ne, e.clone()), h(this, Q, t.clone()), h(this,
|
|
3197
|
+
), h(this, ne, e.clone()), h(this, Q, t.clone()), h(this, Pe, s(this, Q).clone().normal()), this));
|
|
3204
3198
|
a(this, "fromPointAndNormal", (e, t) => this.fromCoefficient(
|
|
3205
3199
|
t.x,
|
|
3206
3200
|
t.y,
|
|
3207
3201
|
e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)).opposite()
|
|
3208
3202
|
));
|
|
3209
3203
|
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));
|
|
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,
|
|
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, Pe, s(this, Pe).clone()), this));
|
|
3211
3205
|
// ------------------------------------------
|
|
3212
3206
|
// Mathematical operations
|
|
3213
3207
|
// ------------------------------------------
|
|
@@ -3245,7 +3239,7 @@ const Ze = class Ze {
|
|
|
3245
3239
|
const t = this.getEquation().isolate("x"), i = new u(e);
|
|
3246
3240
|
return t instanceof H ? t.right.evaluate({ y: i }) : new u().invalid();
|
|
3247
3241
|
});
|
|
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,
|
|
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, Pe, new x()), h(this, Ie, !0), e.length > 0 && this.parse(...e), this;
|
|
3249
3243
|
}
|
|
3250
3244
|
get a() {
|
|
3251
3245
|
return s(this, S);
|
|
@@ -3280,12 +3274,12 @@ const Ze = class Ze {
|
|
|
3280
3274
|
h(this, Q, e);
|
|
3281
3275
|
}
|
|
3282
3276
|
get n() {
|
|
3283
|
-
return s(this,
|
|
3277
|
+
return s(this, Pe);
|
|
3284
3278
|
}
|
|
3285
3279
|
// ------------------------------------------
|
|
3286
3280
|
getEquation() {
|
|
3287
3281
|
const e = new H(new O().parse("xy", s(this, S), s(this, z), s(this, U)), new O("0"));
|
|
3288
|
-
return s(this,
|
|
3282
|
+
return s(this, Ie) ? e.simplify() : e;
|
|
3289
3283
|
}
|
|
3290
3284
|
// get system(): { x: Equation, y: Equation } {
|
|
3291
3285
|
// const e1 = new Equation(
|
|
@@ -3325,7 +3319,7 @@ const Ze = class Ze {
|
|
|
3325
3319
|
case "parametric":
|
|
3326
3320
|
case "system": {
|
|
3327
3321
|
const t = s(this, Q).clone();
|
|
3328
|
-
return s(this,
|
|
3322
|
+
return s(this, Ie) && 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
3323
|
x &= ${new O(s(this, ne).x).add(new M(s(this, Q).x).multiply(new M("k"))).reorder("k", !0).tex}\\\\
|
|
3330
3324
|
y &= ${new O(s(this, ne).y).add(new M(s(this, Q).y).multiply(new M("k"))).reorder("k", !0).tex}
|
|
3331
3325
|
\\end{aligned}\\right.`;
|
|
@@ -3337,10 +3331,10 @@ const Ze = class Ze {
|
|
|
3337
3331
|
}
|
|
3338
3332
|
}
|
|
3339
3333
|
get reduceBeforeDisplay() {
|
|
3340
|
-
return s(this,
|
|
3334
|
+
return s(this, Ie);
|
|
3341
3335
|
}
|
|
3342
3336
|
set reduceBeforeDisplay(e) {
|
|
3343
|
-
h(this,
|
|
3337
|
+
h(this, Ie, e);
|
|
3344
3338
|
}
|
|
3345
3339
|
get display() {
|
|
3346
3340
|
const e = s(this, be);
|
|
@@ -3351,7 +3345,7 @@ const Ze = class Ze {
|
|
|
3351
3345
|
return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new O().parse("x", this.slope, this.height).display;
|
|
3352
3346
|
case "parametric": {
|
|
3353
3347
|
const t = s(this, Q).clone();
|
|
3354
|
-
return s(this,
|
|
3348
|
+
return s(this, Ie) && t.simplify(), `((x,y))=((${s(this, ne).x.display},${s(this, ne).y.display}))+k((${t.x.display},${t.y.display}))`;
|
|
3355
3349
|
}
|
|
3356
3350
|
default: {
|
|
3357
3351
|
const t = this.getEquation();
|
|
@@ -3408,10 +3402,10 @@ const Ze = class Ze {
|
|
|
3408
3402
|
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";
|
|
3409
3403
|
}
|
|
3410
3404
|
};
|
|
3411
|
-
|
|
3405
|
+
Ie = new WeakMap(), S = new WeakMap(), z = new WeakMap(), U = new WeakMap(), ne = new WeakMap(), Q = new WeakMap(), Pe = new WeakMap(), be = new WeakMap(), // A line is defined as the canonical form
|
|
3412
3406
|
a(Ze, "PERPENDICULAR", we.Perpendicular), a(Ze, "PARALLEL", we.Parallel);
|
|
3413
3407
|
let R = Ze;
|
|
3414
|
-
var re, j, qe, jt, Ut, Gt, oe, Mi, Et, Ci, $i,
|
|
3408
|
+
var re, j, qe, jt, Ut, Gt, oe, Mi, Et, Ci, $i, Ii, ai;
|
|
3415
3409
|
const Wt = class Wt {
|
|
3416
3410
|
constructor(...e) {
|
|
3417
3411
|
p(this, oe);
|
|
@@ -3515,7 +3509,7 @@ const Wt = class Wt {
|
|
|
3515
3509
|
return t ? h(this, j, new u(e)) : h(this, j, new u(e).pow(2)), q(this, oe, Et).call(this), this;
|
|
3516
3510
|
}
|
|
3517
3511
|
parse(...e) {
|
|
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,
|
|
3512
|
+
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, Ii).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;
|
|
3519
3513
|
}
|
|
3520
3514
|
// private _parseThroughtThreePoints(A: Point, B: Point, C: Point): this {
|
|
3521
3515
|
// const T = new Triangle(A, B, C), mAB = T.remarquables.mediators.AB.clone(),
|
|
@@ -3535,7 +3529,7 @@ re = new WeakMap(), j = new WeakMap(), qe = new WeakMap(), jt = new WeakMap(), U
|
|
|
3535
3529
|
return h(this, re, e.center.clone()), h(this, j, e.squareRadius.clone()), q(this, oe, Et).call(this), this;
|
|
3536
3530
|
}, $i = function(e, t, i) {
|
|
3537
3531
|
return h(this, re, e.clone()), i ? h(this, j, new u(t)) : h(this, j, new u(t).pow(2)), this;
|
|
3538
|
-
},
|
|
3532
|
+
}, Ii = function(e, t) {
|
|
3539
3533
|
return h(this, re, e.clone()), h(this, j, new x(s(this, re), t).normSquare), this;
|
|
3540
3534
|
}, ai = function(e) {
|
|
3541
3535
|
if (e.moveLeft(), e.degree("x").value === 2 && e.degree("y").value === 2) {
|
|
@@ -3999,7 +3993,7 @@ function Ot(o) {
|
|
|
3999
3993
|
}
|
|
4000
3994
|
return e.reduced ? t.reduce() : t;
|
|
4001
3995
|
}
|
|
4002
|
-
function
|
|
3996
|
+
function Pi(o) {
|
|
4003
3997
|
const e = Object.assign(
|
|
4004
3998
|
{
|
|
4005
3999
|
letters: "x",
|
|
@@ -4042,7 +4036,7 @@ function Bi(o) {
|
|
|
4042
4036
|
), t = new O().empty();
|
|
4043
4037
|
let i;
|
|
4044
4038
|
for (let n = e.degree; n >= 0; n--)
|
|
4045
|
-
i =
|
|
4039
|
+
i = Pi({
|
|
4046
4040
|
letters: e.letters,
|
|
4047
4041
|
degree: n,
|
|
4048
4042
|
fraction: e.fraction,
|
|
@@ -4152,7 +4146,7 @@ function fs(o) {
|
|
|
4152
4146
|
const ds = {
|
|
4153
4147
|
equation: (o) => ls(o),
|
|
4154
4148
|
polynom: (o) => Bi(o),
|
|
4155
|
-
monom: (o) =>
|
|
4149
|
+
monom: (o) => Pi(o),
|
|
4156
4150
|
fraction: (o) => Ot(o),
|
|
4157
4151
|
number: (o, e, t) => de(o, e, t),
|
|
4158
4152
|
numberSym: (o, e) => Y(o, e),
|