pimath 0.0.93 → 0.0.94
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/pi.js +62 -6
- package/dist/pi.js.map +1 -1
- package/dist/pi.min.js +1 -1
- package/dist/pi.min.js.map +1 -1
- package/esm/maths/algebra/equation.d.ts +5 -3
- package/esm/maths/algebra/equation.js +92 -59
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/algebra/study/rationalStudy.js +29 -24
- package/esm/maths/algebra/study/rationalStudy.js.map +1 -1
- package/esm/maths/coefficients/nthRoot.d.ts +3 -0
- package/esm/maths/coefficients/nthRoot.js +23 -4
- package/esm/maths/coefficients/nthRoot.js.map +1 -1
- package/package.json +1 -1
- package/src/maths/algebra/equation.ts +46 -12
- package/src/maths/algebra/study/rationalStudy.ts +2 -0
- package/src/maths/coefficients/nthRoot.ts +22 -0
package/dist/pi.js
CHANGED
|
@@ -389,13 +389,14 @@ class Equation {
|
|
|
389
389
|
};
|
|
390
390
|
this._solveDegree1 = (letter) => {
|
|
391
391
|
const m1 = this._polynom.monomByDegree(1, letter).coefficient, m0 = this._polynom.monomByDegree(0, letter).coefficient, v = m0.clone().opposed().divide(m1);
|
|
392
|
-
let s;
|
|
392
|
+
let s, d;
|
|
393
393
|
if (this.isStrictEqual()) {
|
|
394
394
|
if (m1.value === 0) {
|
|
395
395
|
// In this case, the coefficient of the x variable is zero.
|
|
396
396
|
if (m0.value === 0) {
|
|
397
397
|
this._solutions = [{
|
|
398
398
|
tex: this._real,
|
|
399
|
+
display: "RR",
|
|
399
400
|
value: NaN,
|
|
400
401
|
exact: false
|
|
401
402
|
}];
|
|
@@ -403,6 +404,7 @@ class Equation {
|
|
|
403
404
|
else {
|
|
404
405
|
this._solutions = [{
|
|
405
406
|
tex: this._varnothing,
|
|
407
|
+
display: "O/",
|
|
406
408
|
value: NaN,
|
|
407
409
|
exact: false
|
|
408
410
|
}];
|
|
@@ -411,6 +413,7 @@ class Equation {
|
|
|
411
413
|
else {
|
|
412
414
|
this._solutions = [{
|
|
413
415
|
tex: v.tex,
|
|
416
|
+
display: v.display,
|
|
414
417
|
value: v.value,
|
|
415
418
|
exact: v
|
|
416
419
|
}];
|
|
@@ -421,13 +424,16 @@ class Equation {
|
|
|
421
424
|
// In this case, the coefficient of the x variable is zero.
|
|
422
425
|
if (m0.value === 0 && this.isAlsoEqual()) {
|
|
423
426
|
s = '\\mathbb{R}';
|
|
427
|
+
d = "RR";
|
|
424
428
|
}
|
|
425
429
|
else {
|
|
426
430
|
if (m0.value > 0) {
|
|
427
431
|
s = this.isGreater() ? this._real : this._varnothing;
|
|
432
|
+
s = this.isGreater() ? "RR" : "O/";
|
|
428
433
|
}
|
|
429
434
|
else {
|
|
430
435
|
s = !this.isGreater() ? this._real : this._varnothing;
|
|
436
|
+
s = !this.isGreater() ? "RR" : "O/";
|
|
431
437
|
}
|
|
432
438
|
}
|
|
433
439
|
}
|
|
@@ -435,13 +441,16 @@ class Equation {
|
|
|
435
441
|
// Must handle the case if the m1 monom is negative.
|
|
436
442
|
if ((this.isGreater() && m1.sign() === 1) || (!this.isGreater() && m1.sign() === -1)) {
|
|
437
443
|
s = `\\left${this.isAlsoEqual() ? '[' : ']'}${v.tex};+\\infty\\right[`;
|
|
444
|
+
d = `${this.isAlsoEqual() ? '[' : ']'}${v.tex};+oo[`;
|
|
438
445
|
}
|
|
439
446
|
else {
|
|
440
447
|
s = `\\left]-\\infty;${v.tex} \\right${this.isAlsoEqual() ? ']' : '['}`;
|
|
448
|
+
d = `]-oo;${v.tex}${this.isAlsoEqual() ? ']' : '['}`;
|
|
441
449
|
}
|
|
442
450
|
}
|
|
443
451
|
this._solutions = [{
|
|
444
452
|
tex: s,
|
|
453
|
+
display: d,
|
|
445
454
|
value: NaN,
|
|
446
455
|
exact: false
|
|
447
456
|
}];
|
|
@@ -456,14 +465,17 @@ class Equation {
|
|
|
456
465
|
realX2 = (-b + Math.sqrt(delta)) / (2 * a);
|
|
457
466
|
if (delta > 1.0e5) {
|
|
458
467
|
// The delta is too big to be parsed !
|
|
468
|
+
let v1 = ((-b - Math.sqrt(delta)) / (2 * a)).toFixed(5), v2 = ((-b + Math.sqrt(delta)) / (2 * a)).toFixed(5);
|
|
459
469
|
this._solutions = [
|
|
460
470
|
{
|
|
461
|
-
tex:
|
|
471
|
+
tex: v1,
|
|
472
|
+
display: v1,
|
|
462
473
|
value: realX1,
|
|
463
474
|
exact: false
|
|
464
475
|
},
|
|
465
476
|
{
|
|
466
|
-
tex:
|
|
477
|
+
tex: v2,
|
|
478
|
+
display: v2,
|
|
467
479
|
value: realX2,
|
|
468
480
|
exact: false
|
|
469
481
|
}
|
|
@@ -481,19 +493,27 @@ class Equation {
|
|
|
481
493
|
am = -am;
|
|
482
494
|
bm = -bm;
|
|
483
495
|
}
|
|
484
|
-
let tex1 = "", tex2 = "";
|
|
496
|
+
let tex1 = "", tex2 = "", display1 = "", display2 = "";
|
|
485
497
|
tex1 = `${bm !== 0 ? ((-bm) + ' - ') : ''}${nthDelta.tex}`;
|
|
486
498
|
tex2 = `${bm !== 0 ? ((-bm) + ' + ') : ''}${nthDelta.tex}`;
|
|
499
|
+
display1 = `${bm !== 0 ? ((-bm) + ' - ') : ''}${nthDelta.display}`;
|
|
500
|
+
display2 = `${bm !== 0 ? ((-bm) + ' + ') : ''}${nthDelta.display}`;
|
|
487
501
|
if (am !== 1) {
|
|
488
502
|
tex1 = `\\frac{ ${tex1} }{ ${2 * am} }`;
|
|
489
503
|
tex2 = `\\frac{ ${tex2} }{ ${2 * am} }`;
|
|
490
504
|
}
|
|
491
505
|
this._solutions = [
|
|
492
506
|
{
|
|
493
|
-
tex: tex1,
|
|
507
|
+
tex: tex1,
|
|
508
|
+
display: tex1,
|
|
509
|
+
value: realX1,
|
|
510
|
+
exact: false
|
|
494
511
|
},
|
|
495
512
|
{
|
|
496
|
-
tex: tex2,
|
|
513
|
+
tex: tex2,
|
|
514
|
+
display: tex2,
|
|
515
|
+
value: realX2,
|
|
516
|
+
exact: false
|
|
497
517
|
},
|
|
498
518
|
];
|
|
499
519
|
// if (b !== 0) {
|
|
@@ -561,11 +581,13 @@ class Equation {
|
|
|
561
581
|
this._solutions = [
|
|
562
582
|
{
|
|
563
583
|
tex: S1.frac,
|
|
584
|
+
display: S1.display,
|
|
564
585
|
value: realX1,
|
|
565
586
|
exact: S1
|
|
566
587
|
},
|
|
567
588
|
{
|
|
568
589
|
tex: S2.frac,
|
|
590
|
+
display: S2.display,
|
|
569
591
|
value: realX2,
|
|
570
592
|
exact: S2
|
|
571
593
|
}
|
|
@@ -577,6 +599,7 @@ class Equation {
|
|
|
577
599
|
const sol = new fraction_1.Fraction(-b, 2 * a).reduce();
|
|
578
600
|
this._solutions = [{
|
|
579
601
|
tex: sol.frac,
|
|
602
|
+
display: sol.display,
|
|
580
603
|
value: sol.value,
|
|
581
604
|
exact: sol
|
|
582
605
|
}];
|
|
@@ -584,6 +607,7 @@ class Equation {
|
|
|
584
607
|
else {
|
|
585
608
|
this._solutions = [{
|
|
586
609
|
tex: this._varnothing,
|
|
610
|
+
display: "O/",
|
|
587
611
|
value: NaN,
|
|
588
612
|
exact: false
|
|
589
613
|
}];
|
|
@@ -596,6 +620,7 @@ class Equation {
|
|
|
596
620
|
if ((this.isGreater() && aF.sign() === 1) || (!this.isGreater() && aF.sign() === -1)) {
|
|
597
621
|
this._solutions = [{
|
|
598
622
|
tex: `\\left]-\\infty ; ${sX1}\\right${this.isAlsoEqual() ? ']' : '['} \\cup \\left${this.isAlsoEqual() ? '[' : ']'}${sX2};+\\infty\\right[`,
|
|
623
|
+
display: `]-oo;${sX1}${this.isAlsoEqual() ? ']' : '['}uu${this.isAlsoEqual() ? '[' : ']'}${sX2};+oo[`,
|
|
599
624
|
value: NaN,
|
|
600
625
|
exact: false
|
|
601
626
|
}
|
|
@@ -604,6 +629,7 @@ class Equation {
|
|
|
604
629
|
else {
|
|
605
630
|
this._solutions = [{
|
|
606
631
|
tex: `\\left${this.isAlsoEqual() ? '[' : ']'}${sX1} ; ${sX2}\\right${this.isAlsoEqual() ? ']' : '['}`,
|
|
632
|
+
display: `${this.isAlsoEqual() ? '[' : ']'}${sX1};${sX2}${this.isAlsoEqual() ? ']' : '['}`,
|
|
607
633
|
value: NaN,
|
|
608
634
|
exact: false
|
|
609
635
|
}];
|
|
@@ -614,6 +640,7 @@ class Equation {
|
|
|
614
640
|
if ((this.isGreater() && aF.sign() === 1) || (!this.isGreater() && aF.sign() === -1)) {
|
|
615
641
|
this._solutions = [{
|
|
616
642
|
tex: `\\left]-\\infty ; ${this._solutions[0].tex}\\right[ \\cup \\left]${this._solutions[0].tex};+\\infty\\right[`,
|
|
643
|
+
display: `]-oo;${this._solutions[0].tex}[uu]${this._solutions[0].tex};+oo[`,
|
|
617
644
|
value: NaN,
|
|
618
645
|
exact: false
|
|
619
646
|
}
|
|
@@ -622,6 +649,7 @@ class Equation {
|
|
|
622
649
|
else {
|
|
623
650
|
this._solutions = [{
|
|
624
651
|
tex: this._varnothing,
|
|
652
|
+
display: "O/",
|
|
625
653
|
value: NaN,
|
|
626
654
|
exact: false
|
|
627
655
|
}];
|
|
@@ -631,6 +659,7 @@ class Equation {
|
|
|
631
659
|
if ((this.isGreater() && aF.sign() === 1) || (!this.isGreater() && aF.sign() === -1)) {
|
|
632
660
|
this._solutions = [{
|
|
633
661
|
tex: this._real,
|
|
662
|
+
display: "RR",
|
|
634
663
|
value: NaN,
|
|
635
664
|
exact: false
|
|
636
665
|
}];
|
|
@@ -644,6 +673,7 @@ class Equation {
|
|
|
644
673
|
if (this.isGreater()) {
|
|
645
674
|
this._solutions = [{
|
|
646
675
|
tex: aF.sign() === 1 ? this._real : this._varnothing,
|
|
676
|
+
display: aF.sign() === 1 ? "RR" : "O/",
|
|
647
677
|
value: NaN,
|
|
648
678
|
exact: false
|
|
649
679
|
}];
|
|
@@ -651,6 +681,7 @@ class Equation {
|
|
|
651
681
|
else {
|
|
652
682
|
this._solutions = [{
|
|
653
683
|
tex: aF.sign() === -1 ? this._real : this._varnothing,
|
|
684
|
+
display: aF.sign() === -1 ? "RR" : "O/",
|
|
654
685
|
value: NaN,
|
|
655
686
|
exact: false
|
|
656
687
|
}];
|
|
@@ -4077,6 +4108,7 @@ class RationalStudy extends study_1.Study {
|
|
|
4077
4108
|
// add the item
|
|
4078
4109
|
zeroes.push({
|
|
4079
4110
|
tex: z.tex,
|
|
4111
|
+
display: z.display,
|
|
4080
4112
|
value: z.value,
|
|
4081
4113
|
exact: z.exact,
|
|
4082
4114
|
extrema: study_1.FUNCTION_EXTREMA.NOTHING,
|
|
@@ -4092,6 +4124,7 @@ class RationalStudy extends study_1.Study {
|
|
|
4092
4124
|
// Add the item
|
|
4093
4125
|
zeroes.push({
|
|
4094
4126
|
tex: z.tex,
|
|
4127
|
+
display: z.display,
|
|
4095
4128
|
value: z.value,
|
|
4096
4129
|
exact: z.exact,
|
|
4097
4130
|
extrema: study_1.FUNCTION_EXTREMA.NOTHING,
|
|
@@ -4768,6 +4801,29 @@ class NthRoot {
|
|
|
4768
4801
|
}
|
|
4769
4802
|
}
|
|
4770
4803
|
}
|
|
4804
|
+
get display() {
|
|
4805
|
+
let C;
|
|
4806
|
+
if (this._coefficient === 1) {
|
|
4807
|
+
C = '';
|
|
4808
|
+
}
|
|
4809
|
+
else if (this._coefficient === -1) {
|
|
4810
|
+
C = '-';
|
|
4811
|
+
}
|
|
4812
|
+
else {
|
|
4813
|
+
C = this._coefficient.toString();
|
|
4814
|
+
}
|
|
4815
|
+
if (this._radical === 1) {
|
|
4816
|
+
return `${this._coefficient}`;
|
|
4817
|
+
}
|
|
4818
|
+
else {
|
|
4819
|
+
if (this._nth === 2) {
|
|
4820
|
+
return `${C}sqrt{${this._radical}}`;
|
|
4821
|
+
}
|
|
4822
|
+
else {
|
|
4823
|
+
return `${C}root(${this._nth}){${this._radical}}`;
|
|
4824
|
+
}
|
|
4825
|
+
}
|
|
4826
|
+
}
|
|
4771
4827
|
get value() {
|
|
4772
4828
|
return this._coefficient * Math.pow(this._radical, 1 / this._nth);
|
|
4773
4829
|
}
|