pimath 0.0.21 → 0.0.25
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/dev/demo.css +3 -0
- package/dev/index.html +216 -53
- package/dev/pi.js +374 -132
- package/dev/pi.js.map +1 -1
- package/dist/pi.js +1 -1
- package/dist/pi.js.map +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/algebra.Equation.html +11 -13
- package/docs/classes/algebra.LinearSystem.html +1 -1
- package/docs/classes/algebra.Logicalset.html +3 -3
- package/docs/classes/algebra.Monom.html +42 -42
- package/docs/classes/algebra.Polynom.html +12 -25
- package/docs/classes/algebra.Rational.html +3 -3
- package/docs/classes/coefficients.Fraction.html +10 -6
- package/docs/classes/coefficients.Nthroot.html +3 -1
- package/docs/classes/geometry.Circle.html +3 -1
- package/docs/classes/geometry.Line.html +3 -1
- package/docs/classes/geometry.Point.html +1 -1
- package/docs/classes/geometry.Triangle.html +6 -6
- package/docs/classes/geometry.Vector.html +1 -1
- package/docs/classes/numeric.Numeric.html +5 -5
- package/docs/classes/shutingyard.Shutingyard.html +5 -5
- package/docs/index.html +1 -1
- package/docs/interfaces/geometry.remarquableLines.html +1 -1
- package/docs/modules/algebra.html +1 -1
- package/docs/modules/coefficients.html +1 -1
- package/docs/modules/geometry.html +1 -1
- package/docs/modules/numeric.html +1 -1
- package/docs/modules/random.Random.html +1 -1
- package/docs/modules/random.html +1 -1
- package/docs/modules/shutingyard.html +1 -1
- package/docs/modules.html +1 -1
- package/esm/maths/algebra/equation.d.ts +11 -5
- package/esm/maths/algebra/equation.js +159 -52
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/algebra/linearSystem.d.ts +3 -4
- package/esm/maths/algebra/linearSystem.js +2 -5
- package/esm/maths/algebra/linearSystem.js.map +1 -1
- package/esm/maths/algebra/logicalset.d.ts +2 -2
- package/esm/maths/algebra/logicalset.js.map +1 -1
- package/esm/maths/algebra/monom.d.ts +3 -2
- package/esm/maths/algebra/monom.js +22 -1
- package/esm/maths/algebra/monom.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +6 -6
- package/esm/maths/algebra/polynom.js +3 -3
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/coefficients/fraction.d.ts +2 -2
- package/esm/maths/coefficients/fraction.js +1 -1
- package/esm/maths/coefficients/fraction.js.map +1 -1
- package/esm/maths/coefficients/nthroot.d.ts +1 -1
- package/esm/maths/coefficients/nthroot.js +4 -1
- package/esm/maths/coefficients/nthroot.js.map +1 -1
- package/esm/maths/geometry/circle.d.ts +12 -3
- package/esm/maths/geometry/circle.js +125 -39
- package/esm/maths/geometry/circle.js.map +1 -1
- package/esm/maths/geometry/line.d.ts +4 -4
- package/esm/maths/geometry/line.js +17 -7
- package/esm/maths/geometry/line.js.map +1 -1
- package/esm/maths/geometry/point.d.ts +3 -4
- package/esm/maths/geometry/point.js +18 -15
- package/esm/maths/geometry/point.js.map +1 -1
- package/esm/maths/geometry/triangle.d.ts +0 -1
- package/esm/maths/geometry/triangle.js +3 -4
- package/esm/maths/geometry/triangle.js.map +1 -1
- package/esm/maths/geometry/vector.js +2 -1
- package/esm/maths/geometry/vector.js.map +1 -1
- package/esm/maths/random/index.js +18 -6
- package/esm/maths/random/index.js.map +1 -1
- package/esm/maths/random/rndFraction.js +4 -3
- package/esm/maths/random/rndFraction.js.map +1 -1
- package/esm/maths/random/rndMonom.d.ts +1 -1
- package/esm/maths/random/rndMonom.js +12 -7
- package/esm/maths/random/rndMonom.js.map +1 -1
- package/esm/maths/random/rndPolynom.js +8 -2
- package/esm/maths/random/rndPolynom.js.map +1 -1
- package/esm/maths/random/rndTypes.d.ts +3 -1
- package/package.json +3 -5
- package/src/maths/algebra/equation.ts +183 -73
- package/src/maths/algebra/linearSystem.ts +262 -265
- package/src/maths/algebra/logicalset.ts +1 -1
- package/src/maths/algebra/monom.ts +24 -18
- package/src/maths/algebra/polynom.ts +9 -9
- package/src/maths/coefficients/fraction.ts +11 -7
- package/src/maths/coefficients/nthroot.ts +8 -1
- package/src/maths/geometry/circle.ts +160 -45
- package/src/maths/geometry/line.ts +30 -11
- package/src/maths/geometry/point.ts +25 -18
- package/src/maths/geometry/triangle.ts +3 -5
- package/src/maths/geometry/vector.ts +4 -3
- package/src/maths/random/index.ts +24 -6
- package/src/maths/random/rndFraction.ts +4 -3
- package/src/maths/random/rndMonom.ts +39 -35
- package/src/maths/random/rndPolynom.ts +13 -3
- package/src/maths/random/rndTypes.ts +4 -2
- package/tests/algebra/monom.test.ts +18 -4
- package/tests/algebra/polynom.test.ts +10 -4
- package/tests/geometry/circle.test.ts +28 -0
- package/tsconfig.json +4 -1
- package/typedoc.katex.js +11 -0
- package/docs/classes/algebra.Algebra.Equation.html +0 -26
- package/docs/classes/algebra.Algebra.LinearSystem.html +0 -1
- package/docs/classes/algebra.Algebra.LogicalSet.html +0 -3
- package/docs/classes/algebra.Algebra.Monom.html +0 -111
- package/docs/classes/algebra.Algebra.Polynom.html +0 -36
- package/docs/classes/algebra.Algebra.Rational.html +0 -2
- package/docs/classes/geometry.Geometry.Circle.html +0 -1
- package/docs/classes/geometry.Geometry.Line.html +0 -1
- package/docs/classes/geometry.Geometry.Point.html +0 -1
- package/docs/classes/geometry.Geometry.Triangle.html +0 -9
- package/docs/classes/geometry.Geometry.Vector.html +0 -1
- package/docs/modules/algebra.Algebra.html +0 -1
- package/docs/modules/geometry.Geometry.html +0 -1
- package/src/maths/algebra/monom_bck.backup +0 -746
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import {Polynom} from "./polynom";
|
|
2
2
|
import {Monom} from "./monom";
|
|
3
3
|
import {Numeric} from "../numeric";
|
|
4
|
-
import {Fraction} from "../coefficients";
|
|
5
|
-
import {Nthroot} from "../coefficients";
|
|
4
|
+
import {Fraction, Nthroot} from "../coefficients";
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Equation is a class to manage equations...
|
|
9
8
|
*/
|
|
9
|
+
interface ISolution {
|
|
10
|
+
tex: string,
|
|
11
|
+
value: number,
|
|
12
|
+
exact: unknown
|
|
13
|
+
}
|
|
14
|
+
|
|
10
15
|
export class Equation {
|
|
11
16
|
private _left: Polynom; // Left part of the equation
|
|
12
17
|
private _right: Polynom; // Right part of the equation
|
|
13
18
|
private _sign: string; // Signe of the equation, by default =
|
|
14
19
|
|
|
15
20
|
private _polynom: Polynom; // Used to solve the equation // TODO: remove the private value ?
|
|
16
|
-
private _solutions:
|
|
21
|
+
private _solutions: ISolution[]
|
|
17
22
|
|
|
18
|
-
// Undetermined
|
|
23
|
+
// Undetermined texSolutions.
|
|
19
24
|
private _varnothing: string = '\\varnothing';
|
|
20
25
|
private _real: string = '\\mathbb{R}';
|
|
21
26
|
|
|
@@ -24,21 +29,30 @@ export class Equation {
|
|
|
24
29
|
* Markdown *support* is cool
|
|
25
30
|
* @param equations
|
|
26
31
|
*/
|
|
27
|
-
constructor(...equations:
|
|
32
|
+
constructor(...equations: unknown[]) {
|
|
28
33
|
// Default equation
|
|
29
34
|
this._left = new Polynom().zero();
|
|
30
35
|
this._right = new Polynom().zero();
|
|
31
36
|
this._sign = '=';
|
|
32
37
|
|
|
33
38
|
if (equations.length === 1) {
|
|
34
|
-
if
|
|
39
|
+
if(equations[0] instanceof Equation) {
|
|
35
40
|
return equations[0].clone();
|
|
36
|
-
} else {
|
|
41
|
+
} else if(typeof equations[0] === 'string') {
|
|
37
42
|
this.parse(equations[0]);
|
|
38
43
|
}
|
|
39
44
|
} else if (equations.length === 2) {
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
if(equations[0] instanceof Polynom){
|
|
46
|
+
this.left = equations[0].clone()
|
|
47
|
+
}else if(typeof equations[0] === 'string'){
|
|
48
|
+
this.left = new Polynom(equations[0])
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if(equations[1] instanceof Polynom){
|
|
52
|
+
this.right = equations[1].clone()
|
|
53
|
+
}else if(typeof equations[1] === 'string'){
|
|
54
|
+
this.right = new Polynom(equations[1])
|
|
55
|
+
}
|
|
42
56
|
} else {
|
|
43
57
|
// Return default empty equation
|
|
44
58
|
return this;
|
|
@@ -54,37 +68,35 @@ export class Equation {
|
|
|
54
68
|
// ------------------------------------------
|
|
55
69
|
// Getter and setter
|
|
56
70
|
// ------------------------------------------
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return this._solutions;
|
|
71
|
+
get solutions(): ISolution[] {
|
|
72
|
+
return this._solutions
|
|
60
73
|
}
|
|
61
|
-
|
|
62
74
|
get solution(): string {
|
|
63
75
|
if (this._solutions.length === 1
|
|
64
76
|
&&
|
|
65
77
|
(
|
|
66
|
-
this._solutions[0] === this._real
|
|
67
|
-
|| this._solutions[0] === this._varnothing
|
|
68
|
-
|| this._solutions[0].includes('\\left')
|
|
78
|
+
this._solutions[0].tex === this._real
|
|
79
|
+
|| this._solutions[0].tex === this._varnothing
|
|
80
|
+
|| this._solutions[0].tex.includes('\\left')
|
|
69
81
|
)
|
|
70
82
|
) {
|
|
71
83
|
return `S = ${this._solutions[0]}`;
|
|
72
84
|
}
|
|
73
|
-
return `S = \\left{ ${this._solutions.join(';')} \\right}`;
|
|
85
|
+
return `S = \\left{ ${this._solutions.map(x => x.tex).join(';')} \\right}`;
|
|
74
86
|
}
|
|
75
87
|
|
|
76
88
|
get isReal(): boolean {
|
|
77
89
|
if (this._solutions === undefined) {
|
|
78
90
|
this.solve();
|
|
79
91
|
}
|
|
80
|
-
return this._solutions[0] === this._real;
|
|
92
|
+
return this._solutions[0].tex === this._real;
|
|
81
93
|
}
|
|
82
94
|
|
|
83
95
|
get isVarnothing(): boolean {
|
|
84
96
|
if (this._solutions === undefined) {
|
|
85
97
|
this.solve();
|
|
86
98
|
}
|
|
87
|
-
return this._solutions[0] === this._varnothing;
|
|
99
|
+
return this._solutions[0].tex === this._varnothing;
|
|
88
100
|
}
|
|
89
101
|
|
|
90
102
|
get signAsTex(): string {
|
|
@@ -304,8 +316,8 @@ export class Equation {
|
|
|
304
316
|
* Multiply by the lcm denominator and divide by the gcm numerators.
|
|
305
317
|
*/
|
|
306
318
|
simplify = (): Equation => {
|
|
307
|
-
this.multiply(Numeric.lcm(...this._left.getDenominators()
|
|
308
|
-
this.divide(Numeric.gcd(...this._left.getNumerators()
|
|
319
|
+
this.multiply(Numeric.lcm(...this._left.getDenominators(), ...this._right.getDenominators()));
|
|
320
|
+
this.divide(Numeric.gcd(...this._left.getNumerators(), ...this._right.getNumerators()));
|
|
309
321
|
return this;
|
|
310
322
|
}
|
|
311
323
|
|
|
@@ -361,7 +373,7 @@ export class Equation {
|
|
|
361
373
|
* Multiple an equation by a fraction value.
|
|
362
374
|
* @param value
|
|
363
375
|
*/
|
|
364
|
-
multiply = (value:
|
|
376
|
+
multiply = (value: unknown): Equation => {
|
|
365
377
|
|
|
366
378
|
// Make sure we have a fraction.
|
|
367
379
|
let F: Fraction = new Fraction(value);
|
|
@@ -392,13 +404,13 @@ export class Equation {
|
|
|
392
404
|
* @param value
|
|
393
405
|
* @returns {Equation}
|
|
394
406
|
*/
|
|
395
|
-
divide = (value:
|
|
407
|
+
divide = (value: unknown): Equation => {
|
|
396
408
|
// Make sure we have a fraction.
|
|
397
409
|
let F: Fraction = new Fraction(value);
|
|
398
410
|
|
|
399
|
-
if(F.isZero()){
|
|
411
|
+
if (F.isZero()) {
|
|
400
412
|
return this;
|
|
401
|
-
}else {
|
|
413
|
+
} else {
|
|
402
414
|
return this.multiply(F.invert());
|
|
403
415
|
}
|
|
404
416
|
}
|
|
@@ -430,27 +442,25 @@ export class Equation {
|
|
|
430
442
|
// -----------------------------------------------
|
|
431
443
|
// Equations solving algorithms
|
|
432
444
|
// -----------------------------------------------
|
|
433
|
-
solve = (
|
|
445
|
+
solve = (): Equation => {
|
|
434
446
|
// Initialise the variables:
|
|
435
447
|
this._solutions = [];
|
|
436
448
|
|
|
437
|
-
// TODO: this._polynom could be removed.
|
|
438
449
|
// TODO: consolidate solving equations (inequations vs equations)
|
|
439
450
|
// TODO: work with not natural degrees ?
|
|
440
451
|
this._polynom = this._left.clone().subtract(this._right);
|
|
441
452
|
|
|
442
|
-
switch (this._polynom.degree(
|
|
453
|
+
switch (this._polynom.degree().value) {
|
|
443
454
|
case 0:
|
|
444
455
|
case 1:
|
|
445
|
-
this._solveDegree1(
|
|
456
|
+
this._solveDegree1();
|
|
446
457
|
break;
|
|
447
458
|
case 2:
|
|
448
|
-
this._solveDegree2(
|
|
459
|
+
this._solveDegree2();
|
|
449
460
|
break;
|
|
450
461
|
default:
|
|
451
|
-
this._solveDegree3plus(
|
|
462
|
+
this._solveDegree3plus();
|
|
452
463
|
}
|
|
453
|
-
|
|
454
464
|
return this;
|
|
455
465
|
};
|
|
456
466
|
|
|
@@ -476,22 +486,34 @@ export class Equation {
|
|
|
476
486
|
}
|
|
477
487
|
};
|
|
478
488
|
|
|
479
|
-
private _solveDegree1 = (letter?: string):
|
|
489
|
+
private _solveDegree1 = (letter?: string): ISolution[] => {
|
|
480
490
|
const m1 = this._polynom.monomByDegree(1, letter).coefficient,
|
|
481
491
|
m0 = this._polynom.monomByDegree(0, letter).coefficient,
|
|
482
|
-
v = m0.clone().opposed().divide(m1)
|
|
492
|
+
v = m0.clone().opposed().divide(m1);
|
|
483
493
|
let s: string;
|
|
484
494
|
|
|
485
495
|
if (this.isStrictEqual()) {
|
|
486
496
|
if (m1.value === 0) {
|
|
487
497
|
// In this case, the coefficient of the x variable is zero.
|
|
488
498
|
if (m0.value === 0) {
|
|
489
|
-
this._solutions = [
|
|
499
|
+
this._solutions = [{
|
|
500
|
+
tex: this._real,
|
|
501
|
+
value: NaN,
|
|
502
|
+
exact: false
|
|
503
|
+
}];
|
|
490
504
|
} else {
|
|
491
|
-
this._solutions = [
|
|
505
|
+
this._solutions = [{
|
|
506
|
+
tex: this._varnothing,
|
|
507
|
+
value: NaN,
|
|
508
|
+
exact: false
|
|
509
|
+
}];
|
|
492
510
|
}
|
|
493
511
|
} else {
|
|
494
|
-
this._solutions = [
|
|
512
|
+
this._solutions = [{
|
|
513
|
+
tex: v.display,
|
|
514
|
+
value: v.value,
|
|
515
|
+
exact: v
|
|
516
|
+
}]
|
|
495
517
|
}
|
|
496
518
|
} else {
|
|
497
519
|
if (m1.value === 0) {
|
|
@@ -513,13 +535,17 @@ export class Equation {
|
|
|
513
535
|
s = `\\left\\]-\\infty;${v} \\right\\${this.isAlsoEqual() ? '\\]' : '\\['}`;
|
|
514
536
|
}
|
|
515
537
|
}
|
|
516
|
-
this._solutions = [
|
|
538
|
+
this._solutions = [{
|
|
539
|
+
tex: s,
|
|
540
|
+
value: NaN,
|
|
541
|
+
exact: false
|
|
542
|
+
}];
|
|
517
543
|
}
|
|
518
544
|
|
|
519
545
|
return this._solutions;
|
|
520
546
|
};
|
|
521
547
|
|
|
522
|
-
private _solveDegree2 = (letter?: string):
|
|
548
|
+
private _solveDegree2 = (letter?: string): ISolution[] => {
|
|
523
549
|
let aF = this._polynom.monomByDegree(2, letter).coefficient,
|
|
524
550
|
bF = this._polynom.monomByDegree(1, letter).coefficient,
|
|
525
551
|
cF = this._polynom.monomByDegree(0, letter).coefficient,
|
|
@@ -537,14 +563,22 @@ export class Equation {
|
|
|
537
563
|
realX1 = (-b - Math.sqrt(delta)) / (2 * a);
|
|
538
564
|
realX2 = (-b + Math.sqrt(delta)) / (2 * a);
|
|
539
565
|
|
|
540
|
-
if(delta>1.0e5){
|
|
566
|
+
if (delta > 1.0e5) {
|
|
541
567
|
// The delta is too big to be parsed !
|
|
542
568
|
this._solutions = [
|
|
543
|
-
|
|
544
|
-
|
|
569
|
+
{
|
|
570
|
+
tex: ((-b - Math.sqrt(delta)) / (2 * a)).toFixed(5),
|
|
571
|
+
value: realX1,
|
|
572
|
+
exact: false
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
tex: ((-b + Math.sqrt(delta)) / (2 * a)).toFixed(5),
|
|
576
|
+
value: realX2,
|
|
577
|
+
exact: false
|
|
578
|
+
}
|
|
545
579
|
]
|
|
546
|
-
}else {
|
|
547
|
-
nthDelta = new Nthroot(
|
|
580
|
+
} else {
|
|
581
|
+
nthDelta = new Nthroot(delta).reduce();
|
|
548
582
|
if (nthDelta.hasRadical()) {
|
|
549
583
|
// -b +- coeff\sqrt{radical}
|
|
550
584
|
// -------------------------
|
|
@@ -557,89 +591,165 @@ export class Equation {
|
|
|
557
591
|
if (b !== 0) {
|
|
558
592
|
if (2 * a / gcd === 1) {
|
|
559
593
|
this._solutions = [
|
|
560
|
-
|
|
561
|
-
|
|
594
|
+
{
|
|
595
|
+
tex: `${-b / gcd} - ${nthDelta.tex}`,
|
|
596
|
+
value: realX1,
|
|
597
|
+
exact: false // TODO: implement exact value with nthroot
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
tex: `${-b / gcd} + ${nthDelta.tex}`,
|
|
601
|
+
value: realX2,
|
|
602
|
+
exact: false
|
|
603
|
+
},
|
|
604
|
+
|
|
562
605
|
]
|
|
563
606
|
} else {
|
|
564
607
|
this._solutions = [
|
|
565
|
-
|
|
566
|
-
|
|
608
|
+
{
|
|
609
|
+
tex: `\\dfrac{${-b / gcd} - ${nthDelta.tex} }{ ${2 * a / gcd} }`,
|
|
610
|
+
value: realX1,
|
|
611
|
+
exact: false
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
tex: `\\dfrac{${-b / gcd} + ${nthDelta.tex} }{ ${2 * a / gcd} }`,
|
|
615
|
+
value: realX2,
|
|
616
|
+
exact: false
|
|
617
|
+
},
|
|
567
618
|
]
|
|
568
619
|
}
|
|
569
620
|
} else {
|
|
570
621
|
if (2 * a / gcd === 1) {
|
|
571
622
|
this._solutions = [
|
|
572
|
-
|
|
573
|
-
|
|
623
|
+
{
|
|
624
|
+
tex: `- ${nthDelta.tex}`,
|
|
625
|
+
value: realX1,
|
|
626
|
+
exact: false
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
tex: `${nthDelta.tex}`,
|
|
630
|
+
value: realX2,
|
|
631
|
+
exact: false
|
|
632
|
+
},
|
|
574
633
|
]
|
|
575
634
|
} else {
|
|
576
635
|
this._solutions = [
|
|
577
|
-
|
|
578
|
-
|
|
636
|
+
{
|
|
637
|
+
tex: `\\dfrac{- ${nthDelta.tex} }{ ${2 * a / gcd} }`,
|
|
638
|
+
value: realX1,
|
|
639
|
+
exact: false
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
tex: `\\dfrac{${nthDelta.tex} }{ ${2 * a / gcd} }`,
|
|
643
|
+
value: realX2,
|
|
644
|
+
exact: false
|
|
645
|
+
},
|
|
579
646
|
]
|
|
580
647
|
}
|
|
581
648
|
}
|
|
582
649
|
} else {
|
|
583
650
|
// -b +- d / 2a
|
|
651
|
+
const S1 = new Fraction(-b - nthDelta.coefficient, 2 * a).reduce(),
|
|
652
|
+
S2 = new Fraction(-b + nthDelta.coefficient, 2 * a).reduce()
|
|
584
653
|
this._solutions = [
|
|
585
|
-
|
|
586
|
-
|
|
654
|
+
{
|
|
655
|
+
tex: S1.dfrac,
|
|
656
|
+
value: realX1,
|
|
657
|
+
exact: S1
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
tex: S2.dfrac,
|
|
661
|
+
value: realX2,
|
|
662
|
+
exact: S2
|
|
663
|
+
}
|
|
587
664
|
]
|
|
588
665
|
}
|
|
589
666
|
}
|
|
590
667
|
|
|
591
668
|
} else if (delta === 0) {
|
|
592
|
-
|
|
669
|
+
const sol = new Fraction(-b, 2 * a).reduce()
|
|
670
|
+
this._solutions = [{
|
|
671
|
+
tex: sol.dfrac,
|
|
672
|
+
value: sol.value,
|
|
673
|
+
exact: sol
|
|
674
|
+
}];
|
|
593
675
|
} else {
|
|
594
|
-
this._solutions = [
|
|
676
|
+
this._solutions = [{
|
|
677
|
+
tex: this._varnothing,
|
|
678
|
+
value: NaN,
|
|
679
|
+
exact: false
|
|
680
|
+
}];
|
|
595
681
|
}
|
|
596
682
|
|
|
597
683
|
|
|
598
684
|
// Handle now the inequations.
|
|
599
685
|
if (!this.isStrictEqual()) {
|
|
600
686
|
if (this._solutions.length === 2) {
|
|
601
|
-
sX1 = (realX1 < realX2) ? this._solutions[0] : this._solutions[1];
|
|
602
|
-
sX2 = (realX1 < realX2) ? this._solutions[1] : this._solutions[0];
|
|
687
|
+
sX1 = (realX1 < realX2) ? this._solutions[0].tex : this._solutions[1].tex;
|
|
688
|
+
sX2 = (realX1 < realX2) ? this._solutions[1].tex : this._solutions[0].tex;
|
|
603
689
|
|
|
604
690
|
if ((this.isGreater() && aF.sign() === 1) || (!this.isGreater() && aF.sign() === -1)) {
|
|
605
|
-
this._solutions = [
|
|
606
|
-
`\\left]-\\infty ; ${sX1}\\right${this.isAlsoEqual() ? ']' : '['} \\cup \\left${this.isAlsoEqual() ? '[' : ']'}${sX2};+\\infty\\right[
|
|
691
|
+
this._solutions = [{
|
|
692
|
+
tex: `\\left]-\\infty ; ${sX1}\\right${this.isAlsoEqual() ? ']' : '['} \\cup \\left${this.isAlsoEqual() ? '[' : ']'}${sX2};+\\infty\\right[`,
|
|
693
|
+
value: NaN,
|
|
694
|
+
exact: false
|
|
695
|
+
}
|
|
607
696
|
];
|
|
608
697
|
} else {
|
|
609
|
-
this._solutions = [
|
|
610
|
-
`\\left${this.isAlsoEqual() ? '[' : ']'}${sX1} ; ${sX2}\\right${this.isAlsoEqual() ? ']' : '['}
|
|
611
|
-
|
|
698
|
+
this._solutions = [{
|
|
699
|
+
tex: `\\left${this.isAlsoEqual() ? '[' : ']'}${sX1} ; ${sX2}\\right${this.isAlsoEqual() ? ']' : '['}`,
|
|
700
|
+
value: NaN,
|
|
701
|
+
exact: false
|
|
702
|
+
}]
|
|
612
703
|
}
|
|
613
|
-
} else if (this._solutions.length === 1 && this._solutions[0] !== this._varnothing) {
|
|
704
|
+
} else if (this._solutions.length === 1 && this._solutions[0].tex !== this._varnothing) {
|
|
614
705
|
if (!this.isAlsoEqual()) {
|
|
615
706
|
if ((this.isGreater() && aF.sign() === 1) || (!this.isGreater() && aF.sign() === -1)) {
|
|
616
|
-
this._solutions = [
|
|
617
|
-
`\\left]-\\infty ; ${this._solutions[0]}\\right[ \\cup \\left]${this._solutions[0]};+\\infty\\right[
|
|
707
|
+
this._solutions = [{
|
|
708
|
+
tex: `\\left]-\\infty ; ${this._solutions[0].tex}\\right[ \\cup \\left]${this._solutions[0].tex};+\\infty\\right[`,
|
|
709
|
+
value: NaN,
|
|
710
|
+
exact: false
|
|
711
|
+
}
|
|
618
712
|
];
|
|
619
713
|
} else {
|
|
620
|
-
this._solutions = [
|
|
714
|
+
this._solutions = [{
|
|
715
|
+
tex: this._varnothing,
|
|
716
|
+
value: NaN,
|
|
717
|
+
exact: false
|
|
718
|
+
}];
|
|
621
719
|
}
|
|
622
720
|
} else {
|
|
623
721
|
if ((this.isGreater() && aF.sign() === 1) || (!this.isGreater() && aF.sign() === -1)) {
|
|
624
|
-
this._solutions = [
|
|
722
|
+
this._solutions = [{
|
|
723
|
+
tex: this._real,
|
|
724
|
+
value: NaN,
|
|
725
|
+
exact: false
|
|
726
|
+
}];
|
|
625
727
|
} else {
|
|
626
|
-
// this.
|
|
728
|
+
// this._texSolutions = [ this._texSolutions[0] ];
|
|
627
729
|
}
|
|
628
730
|
}
|
|
629
731
|
} else {
|
|
630
732
|
if (this.isGreater()) {
|
|
631
|
-
this._solutions = [
|
|
733
|
+
this._solutions = [{
|
|
734
|
+
tex: aF.sign() === 1 ? this._real : this._varnothing,
|
|
735
|
+
value: NaN,
|
|
736
|
+
exact: false
|
|
737
|
+
}];
|
|
632
738
|
} else {
|
|
633
|
-
this._solutions = [
|
|
739
|
+
this._solutions = [{
|
|
740
|
+
tex: aF.sign() === -1 ? this._real : this._varnothing,
|
|
741
|
+
value: NaN,
|
|
742
|
+
exact: false
|
|
743
|
+
}];
|
|
634
744
|
}
|
|
635
745
|
}
|
|
636
746
|
}
|
|
637
747
|
return this._solutions;
|
|
638
748
|
};
|
|
639
749
|
|
|
640
|
-
private _solveDegree3plus = (
|
|
750
|
+
private _solveDegree3plus = (): ISolution[] => {
|
|
641
751
|
// TODO: try to resolve equations with a degree superior than 2.
|
|
642
|
-
this._solutions = [
|
|
752
|
+
this._solutions = [{tex: 'solve x - not yet handled', value: NaN, exact: false}]; // ESLint remove system :(
|
|
643
753
|
return this._solutions;
|
|
644
754
|
};
|
|
645
755
|
|