pimath 0.0.93 → 0.0.95
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 +70 -8
- 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 +6 -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 +15 -3
- package/esm/maths/algebra/study/rationalStudy.js.map +1 -1
- package/esm/maths/algebra/study.d.ts +1 -0
- package/esm/maths/algebra/study.js.map +1 -1
- package/esm/maths/coefficients/nthRoot.d.ts +1 -0
- package/esm/maths/coefficients/nthRoot.js +23 -8
- 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 +11 -2
- package/src/maths/algebra/study.ts +1 -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
|
}];
|
|
@@ -3936,18 +3967,20 @@ class RationalStudy extends study_1.Study {
|
|
|
3936
3967
|
let asymptotes = [];
|
|
3937
3968
|
this.zeroes.filter(x => x.type === study_1.ZEROTYPE.DEFENCE).forEach(zero => {
|
|
3938
3969
|
// Check if it's a hole or an asymptote
|
|
3939
|
-
let Ztype = study_1.ASYMPTOTE.VERTICAL, tex = `x=${zero.tex}`;
|
|
3970
|
+
let Ztype = study_1.ASYMPTOTE.VERTICAL, tex = `x=${zero.tex}`, display = `x=${zero.display}`;
|
|
3940
3971
|
// Check if it's a hole: the reduced polynom should not be null
|
|
3941
3972
|
if (zero.exact instanceof fraction_1.Fraction) {
|
|
3942
3973
|
if (reduced.denominator.evaluate(zero.exact).isNotZero()) {
|
|
3943
3974
|
Ztype = study_1.ASYMPTOTE.HOLE;
|
|
3944
3975
|
tex = `(${zero.tex};${reduced.evaluate(zero.exact).tex})`;
|
|
3976
|
+
display = `(${zero.display};${reduced.evaluate(zero.exact).display})`;
|
|
3945
3977
|
}
|
|
3946
3978
|
}
|
|
3947
3979
|
else {
|
|
3948
3980
|
if (reduced.denominator.evaluate(zero.value).isNotZero()) {
|
|
3949
3981
|
Ztype = study_1.ASYMPTOTE.HOLE;
|
|
3950
3982
|
tex = `(${zero.tex};${reduced.evaluate(zero.value).tex})`;
|
|
3983
|
+
display = `(${zero.display};${reduced.evaluate(zero.value).display})`;
|
|
3951
3984
|
}
|
|
3952
3985
|
}
|
|
3953
3986
|
// Get the position before and after the asymptote.
|
|
@@ -3983,7 +4016,8 @@ class RationalStudy extends study_1.Study {
|
|
|
3983
4016
|
asymptotes.push({
|
|
3984
4017
|
fx: null,
|
|
3985
4018
|
type: Ztype,
|
|
3986
|
-
tex
|
|
4019
|
+
tex,
|
|
4020
|
+
display,
|
|
3987
4021
|
zero: zero,
|
|
3988
4022
|
limits: `\\lim_{x\\to${zero.tex} }\\ f(x) = ${pm}\\infty`,
|
|
3989
4023
|
deltaX: null,
|
|
@@ -4001,6 +4035,7 @@ class RationalStudy extends study_1.Study {
|
|
|
4001
4035
|
fx: new polynom_1.Polynom(H),
|
|
4002
4036
|
type: study_1.ASYMPTOTE.HORIZONTAL,
|
|
4003
4037
|
tex: `y=${Htex}`,
|
|
4038
|
+
display: H.display,
|
|
4004
4039
|
zero: null,
|
|
4005
4040
|
limits: `\\lim_{x\\to\\infty}\\ f(x) = ${Htex}`,
|
|
4006
4041
|
deltaX,
|
|
@@ -4013,6 +4048,7 @@ class RationalStudy extends study_1.Study {
|
|
|
4013
4048
|
fx: new polynom_1.Polynom('0'),
|
|
4014
4049
|
type: study_1.ASYMPTOTE.HORIZONTAL,
|
|
4015
4050
|
tex: `y=0`,
|
|
4051
|
+
display: `y=0`,
|
|
4016
4052
|
zero: null,
|
|
4017
4053
|
limits: `\\lim_{x\\to\\infty}\\ f(x) = ${0}`,
|
|
4018
4054
|
deltaX: null,
|
|
@@ -4027,6 +4063,7 @@ class RationalStudy extends study_1.Study {
|
|
|
4027
4063
|
fx: quotient.clone(),
|
|
4028
4064
|
type: study_1.ASYMPTOTE.SLOPE,
|
|
4029
4065
|
tex: `y=${quotient.tex}`,
|
|
4066
|
+
display: `y=${quotient.display}`,
|
|
4030
4067
|
zero: null,
|
|
4031
4068
|
limits: ``,
|
|
4032
4069
|
deltaX: new rational_1.Rational(reminder, reduced.denominator),
|
|
@@ -4077,6 +4114,7 @@ class RationalStudy extends study_1.Study {
|
|
|
4077
4114
|
// add the item
|
|
4078
4115
|
zeroes.push({
|
|
4079
4116
|
tex: z.tex,
|
|
4117
|
+
display: z.display,
|
|
4080
4118
|
value: z.value,
|
|
4081
4119
|
exact: z.exact,
|
|
4082
4120
|
extrema: study_1.FUNCTION_EXTREMA.NOTHING,
|
|
@@ -4092,6 +4130,7 @@ class RationalStudy extends study_1.Study {
|
|
|
4092
4130
|
// Add the item
|
|
4093
4131
|
zeroes.push({
|
|
4094
4132
|
tex: z.tex,
|
|
4133
|
+
display: z.display,
|
|
4095
4134
|
value: z.value,
|
|
4096
4135
|
exact: z.exact,
|
|
4097
4136
|
extrema: study_1.FUNCTION_EXTREMA.NOTHING,
|
|
@@ -4768,6 +4807,29 @@ class NthRoot {
|
|
|
4768
4807
|
}
|
|
4769
4808
|
}
|
|
4770
4809
|
}
|
|
4810
|
+
get display() {
|
|
4811
|
+
let C;
|
|
4812
|
+
if (this._coefficient === 1) {
|
|
4813
|
+
C = '';
|
|
4814
|
+
}
|
|
4815
|
+
else if (this._coefficient === -1) {
|
|
4816
|
+
C = '-';
|
|
4817
|
+
}
|
|
4818
|
+
else {
|
|
4819
|
+
C = this._coefficient.toString();
|
|
4820
|
+
}
|
|
4821
|
+
if (this._radical === 1) {
|
|
4822
|
+
return `${this._coefficient}`;
|
|
4823
|
+
}
|
|
4824
|
+
else {
|
|
4825
|
+
if (this._nth === 2) {
|
|
4826
|
+
return `${C}sqrt{${this._radical}}`;
|
|
4827
|
+
}
|
|
4828
|
+
else {
|
|
4829
|
+
return `${C}root(${this._nth}){${this._radical}}`;
|
|
4830
|
+
}
|
|
4831
|
+
}
|
|
4832
|
+
}
|
|
4771
4833
|
get value() {
|
|
4772
4834
|
return this._coefficient * Math.pow(this._radical, 1 / this._nth);
|
|
4773
4835
|
}
|