pimath 0.0.62 → 0.0.65
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 +520 -0
- 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/polynom.d.ts +0 -6
- package/esm/maths/algebra/rational.d.ts +6 -10
- package/esm/maths/algebra/rational.js +8 -8
- package/esm/maths/algebra/rational.js.map +1 -1
- package/esm/maths/algebra/study/rationalStudy.d.ts +2 -8
- package/esm/maths/algebra/study/rationalStudy.js +15 -20
- package/esm/maths/algebra/study/rationalStudy.js.map +1 -1
- package/esm/maths/algebra/study.d.ts +24 -27
- package/esm/maths/algebra/study.js +48 -23
- package/esm/maths/algebra/study.js.map +1 -1
- package/package.json +1 -1
- package/src/maths/algebra/rational.ts +4 -0
- package/src/maths/algebra/study/rationalStudy.ts +14 -14
- package/src/maths/algebra/study.ts +59 -8
- package/tests/algebra/study.test.ts +20 -1
package/dist/pi.js
CHANGED
|
@@ -3264,6 +3264,7 @@ exports.Rational = void 0;
|
|
|
3264
3264
|
const polynom_1 = __webpack_require__(38);
|
|
3265
3265
|
const fraction_1 = __webpack_require__(506);
|
|
3266
3266
|
const equation_1 = __webpack_require__(760);
|
|
3267
|
+
const rationalStudy_1 = __webpack_require__(572);
|
|
3267
3268
|
/**
|
|
3268
3269
|
* Rational class can handle rational polynoms
|
|
3269
3270
|
*/
|
|
@@ -3389,6 +3390,9 @@ class Rational {
|
|
|
3389
3390
|
let N = this._numerator.evaluate(values), D = this._denominator.evaluate(values);
|
|
3390
3391
|
return N.divide(D);
|
|
3391
3392
|
};
|
|
3393
|
+
this.study = () => {
|
|
3394
|
+
return new rationalStudy_1.RationalStudy(this);
|
|
3395
|
+
};
|
|
3392
3396
|
if (numerator instanceof polynom_1.Polynom) {
|
|
3393
3397
|
this._numerator = numerator.clone();
|
|
3394
3398
|
}
|
|
@@ -3427,6 +3431,522 @@ class Rational {
|
|
|
3427
3431
|
exports.Rational = Rational;
|
|
3428
3432
|
|
|
3429
3433
|
|
|
3434
|
+
/***/ }),
|
|
3435
|
+
|
|
3436
|
+
/***/ 996:
|
|
3437
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3438
|
+
|
|
3439
|
+
|
|
3440
|
+
/**
|
|
3441
|
+
* Rational polynom module contains everything necessary to handle rational polynoms.
|
|
3442
|
+
* @module Polynom
|
|
3443
|
+
*/
|
|
3444
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3445
|
+
exports.Study = exports.TABLE_OF_SIGNS = exports.FUNCTION_EXTREMA = exports.ASYMPTOTE = exports.ZEROTYPE = void 0;
|
|
3446
|
+
const fraction_1 = __webpack_require__(506);
|
|
3447
|
+
const numexp_1 = __webpack_require__(735);
|
|
3448
|
+
var ZEROTYPE;
|
|
3449
|
+
(function (ZEROTYPE) {
|
|
3450
|
+
ZEROTYPE["ZERO"] = "z";
|
|
3451
|
+
ZEROTYPE["DEFENCE"] = "d";
|
|
3452
|
+
ZEROTYPE["NOTHING"] = "t";
|
|
3453
|
+
})(ZEROTYPE = exports.ZEROTYPE || (exports.ZEROTYPE = {}));
|
|
3454
|
+
var ASYMPTOTE;
|
|
3455
|
+
(function (ASYMPTOTE) {
|
|
3456
|
+
ASYMPTOTE["VERTICAL"] = "av";
|
|
3457
|
+
ASYMPTOTE["HORIZONTAL"] = "ah";
|
|
3458
|
+
ASYMPTOTE["SLOPE"] = "ao";
|
|
3459
|
+
ASYMPTOTE["HOLE"] = "hole";
|
|
3460
|
+
})(ASYMPTOTE = exports.ASYMPTOTE || (exports.ASYMPTOTE = {}));
|
|
3461
|
+
var FUNCTION_EXTREMA;
|
|
3462
|
+
(function (FUNCTION_EXTREMA) {
|
|
3463
|
+
FUNCTION_EXTREMA["MIN"] = "min";
|
|
3464
|
+
FUNCTION_EXTREMA["MAX"] = "max";
|
|
3465
|
+
FUNCTION_EXTREMA["FLAT"] = "flat";
|
|
3466
|
+
FUNCTION_EXTREMA["NOTHING"] = "";
|
|
3467
|
+
})(FUNCTION_EXTREMA = exports.FUNCTION_EXTREMA || (exports.FUNCTION_EXTREMA = {}));
|
|
3468
|
+
var TABLE_OF_SIGNS;
|
|
3469
|
+
(function (TABLE_OF_SIGNS) {
|
|
3470
|
+
TABLE_OF_SIGNS[TABLE_OF_SIGNS["DEFAULT"] = 0] = "DEFAULT";
|
|
3471
|
+
TABLE_OF_SIGNS[TABLE_OF_SIGNS["GROWS"] = 1] = "GROWS";
|
|
3472
|
+
TABLE_OF_SIGNS[TABLE_OF_SIGNS["VARIATIONS"] = 2] = "VARIATIONS";
|
|
3473
|
+
})(TABLE_OF_SIGNS = exports.TABLE_OF_SIGNS || (exports.TABLE_OF_SIGNS = {}));
|
|
3474
|
+
/**
|
|
3475
|
+
* The study class is a "function study" class that will get:
|
|
3476
|
+
* fx : get the function
|
|
3477
|
+
* domain : string
|
|
3478
|
+
* zeroes : Object (tex, IZero)
|
|
3479
|
+
* signs : table of signs + tex output using tkz-tab
|
|
3480
|
+
* av : vertical asymptotic
|
|
3481
|
+
* ah : horizontal asymptotic
|
|
3482
|
+
* ao : obliques
|
|
3483
|
+
* deltaX : position relative
|
|
3484
|
+
* dx : derivative
|
|
3485
|
+
* grows : growing table + tex output using tkz-tab
|
|
3486
|
+
* ddx : dérivée seconde
|
|
3487
|
+
* variations : variation table + tex output using tkz-tab
|
|
3488
|
+
*/
|
|
3489
|
+
class Study {
|
|
3490
|
+
constructor(fx) {
|
|
3491
|
+
this.makeStudy = () => {
|
|
3492
|
+
this._zeroes = this.makeZeroes();
|
|
3493
|
+
this._signs = this.makeSigns();
|
|
3494
|
+
this._asymptotes = this.makeAsymptotes();
|
|
3495
|
+
this._derivative = this.makeDerivative();
|
|
3496
|
+
this._variations = this.makeVariation();
|
|
3497
|
+
this._signs.tex = this.texSigns;
|
|
3498
|
+
this._derivative.tex = this.texGrows;
|
|
3499
|
+
this._variations.tex = this.texVariations;
|
|
3500
|
+
};
|
|
3501
|
+
this.indexOfZero = (zeroes, zero) => {
|
|
3502
|
+
for (let i = 0; i < zeroes.length; i++) {
|
|
3503
|
+
if (zeroes[i].tex === zero.tex) {
|
|
3504
|
+
return i;
|
|
3505
|
+
}
|
|
3506
|
+
}
|
|
3507
|
+
return -1;
|
|
3508
|
+
};
|
|
3509
|
+
this.makeOneLineForSigns = (factor, zeroes, zeroSign) => {
|
|
3510
|
+
let oneLine = [], currentZero = factor.getZeroes().map(x => x.tex);
|
|
3511
|
+
// First +/- sign, before the first zero
|
|
3512
|
+
oneLine.push('');
|
|
3513
|
+
if (factor.degree().isZero()) {
|
|
3514
|
+
oneLine.push(factor.monoms[0].coefficient.sign() === 1 ? '+' : '-');
|
|
3515
|
+
}
|
|
3516
|
+
else {
|
|
3517
|
+
oneLine.push(factor.evaluate(zeroes[0].value - 1).sign() === 1 ? '+' : '-');
|
|
3518
|
+
}
|
|
3519
|
+
for (let i = 0; i < zeroes.length; i++) {
|
|
3520
|
+
// Add the zero if it's the current one
|
|
3521
|
+
oneLine.push(currentZero.includes(zeroes[i].tex) ? zeroSign : ZEROTYPE.NOTHING);
|
|
3522
|
+
// + / - sign after the current zero
|
|
3523
|
+
if (i < zeroes.length - 1) {
|
|
3524
|
+
oneLine.push(factor.evaluate((zeroes[i].value + zeroes[i + 1].value) / 2).sign() === 1 ? '+' : '-');
|
|
3525
|
+
}
|
|
3526
|
+
else if (i === zeroes.length - 1) {
|
|
3527
|
+
oneLine.push(factor.evaluate(zeroes[i].value + 1).sign() === 1 ? '+' : '-');
|
|
3528
|
+
}
|
|
3529
|
+
}
|
|
3530
|
+
oneLine.push('');
|
|
3531
|
+
return oneLine;
|
|
3532
|
+
};
|
|
3533
|
+
this.makeSignsResult = (signs) => {
|
|
3534
|
+
// Initialize the result line with the first line of the signs table
|
|
3535
|
+
let resultLine = signs[0].map((x, index) => {
|
|
3536
|
+
if (index === 0 || index === signs[0].length - 1) {
|
|
3537
|
+
return '';
|
|
3538
|
+
}
|
|
3539
|
+
if (index % 2 === 0) {
|
|
3540
|
+
return 't';
|
|
3541
|
+
}
|
|
3542
|
+
return '+';
|
|
3543
|
+
});
|
|
3544
|
+
// Go through each lines (except the first)
|
|
3545
|
+
for (let current of signs) {
|
|
3546
|
+
for (let i = 0; i < current.length; i++) {
|
|
3547
|
+
if (i % 2 === 0) {
|
|
3548
|
+
// t, z or d
|
|
3549
|
+
if (resultLine[i] === 'd') {
|
|
3550
|
+
continue;
|
|
3551
|
+
}
|
|
3552
|
+
if (current[i] !== 't') {
|
|
3553
|
+
resultLine[i] = current[i];
|
|
3554
|
+
}
|
|
3555
|
+
}
|
|
3556
|
+
else {
|
|
3557
|
+
// + or -
|
|
3558
|
+
if (current[i] === '-') {
|
|
3559
|
+
resultLine[i] = resultLine[i] === '+' ? '-' : '+';
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
}
|
|
3563
|
+
}
|
|
3564
|
+
return resultLine;
|
|
3565
|
+
};
|
|
3566
|
+
this.makeGrowsResult = (tos) => {
|
|
3567
|
+
// Use the last line (=> resultLine) to grab the necessary information
|
|
3568
|
+
let signsAsArray = Object.values(tos.signs), resultLine = signsAsArray[signsAsArray.length - 1], growsLine = [], extremes = {}, zeroes = tos.zeroes;
|
|
3569
|
+
// Get the extremes
|
|
3570
|
+
for (let i = 0; i < zeroes.length; i++) {
|
|
3571
|
+
// Get the corresponding item in the resultLine.
|
|
3572
|
+
let pos = 2 * i + 2;
|
|
3573
|
+
if (resultLine[pos] === 'z') {
|
|
3574
|
+
// It's a zero. Get the coordinates
|
|
3575
|
+
let x, y, zero = zeroes[i].exact, pt, xTex, yTex, pointType;
|
|
3576
|
+
// TODO: NumExp should parse something that isn't yet plotFunction
|
|
3577
|
+
let exp = new numexp_1.NumExp(this.fx.plotFunction);
|
|
3578
|
+
if (zero instanceof fraction_1.Fraction) {
|
|
3579
|
+
let value = zero, evalY = this.fx.evaluate(value);
|
|
3580
|
+
x = zero.value;
|
|
3581
|
+
y = evalY.value;
|
|
3582
|
+
xTex = zero.tex;
|
|
3583
|
+
yTex = evalY.tex;
|
|
3584
|
+
}
|
|
3585
|
+
else {
|
|
3586
|
+
x = zeroes[i].value;
|
|
3587
|
+
y = exp.evaluate({ x });
|
|
3588
|
+
xTex = x.toFixed(2);
|
|
3589
|
+
yTex = y.toFixed(2);
|
|
3590
|
+
}
|
|
3591
|
+
// Determine the type of the zero.
|
|
3592
|
+
if (resultLine[pos - 1] === resultLine[pos + 1]) {
|
|
3593
|
+
pointType = FUNCTION_EXTREMA.FLAT;
|
|
3594
|
+
}
|
|
3595
|
+
else if (resultLine[pos - 1] === '+') {
|
|
3596
|
+
pointType = FUNCTION_EXTREMA.MAX;
|
|
3597
|
+
}
|
|
3598
|
+
else {
|
|
3599
|
+
pointType = FUNCTION_EXTREMA.MIN;
|
|
3600
|
+
}
|
|
3601
|
+
// Add the point to the list
|
|
3602
|
+
extremes[zeroes[i].tex] = {
|
|
3603
|
+
type: pointType,
|
|
3604
|
+
tex: { x: xTex, y: yTex },
|
|
3605
|
+
value: { x, y }
|
|
3606
|
+
};
|
|
3607
|
+
}
|
|
3608
|
+
}
|
|
3609
|
+
// Create the grows line, based on tkz-tab
|
|
3610
|
+
// \tkzTabLine{ , + , z , - , d , - , z , + , }
|
|
3611
|
+
// \tkzTabVar{ -/ , +/$3$ , -D+/ , -/$1$ , +/ }
|
|
3612
|
+
growsLine.push(resultLine[1] === '+' ? '-/' : '+/');
|
|
3613
|
+
for (let i = 1; i < resultLine.length - 1; i++) {
|
|
3614
|
+
if (resultLine[i] === "z") {
|
|
3615
|
+
let extr = extremes[zeroes[(i - 2) / 2].tex];
|
|
3616
|
+
growsLine.push(`${resultLine[i - 1]}/\\(${extr.type}(${extr.tex.x};${extr.tex.y})\\)`);
|
|
3617
|
+
}
|
|
3618
|
+
else if (resultLine[i] === 'd') {
|
|
3619
|
+
growsLine.push(`${resultLine[i - 1]}D${resultLine[i + 1] === '+' ? '-' : '+'}/`);
|
|
3620
|
+
}
|
|
3621
|
+
}
|
|
3622
|
+
growsLine.push(`${resultLine[resultLine.length - 2]}/`);
|
|
3623
|
+
return { growsLine, extremes };
|
|
3624
|
+
};
|
|
3625
|
+
this.makeVariationsResult = (tos) => {
|
|
3626
|
+
// TODO: make variations result is not yet implemented.
|
|
3627
|
+
let extremes = {}, varsLine = [];
|
|
3628
|
+
return { varsLine, extremes };
|
|
3629
|
+
};
|
|
3630
|
+
this._makeTexFromTableOfSigns = (tos) => {
|
|
3631
|
+
let factors = tos.factors.map(x => `\\(${x.tex}\\)/1`), factorsFx = "\\(fx\\)/1.2", zeroes = tos.zeroes;
|
|
3632
|
+
// Add the last lines "label"
|
|
3633
|
+
if (tos.type === TABLE_OF_SIGNS.GROWS) {
|
|
3634
|
+
factorsFx = "\\(f'(x)\\)/1.2,\\(f(x)\\)/2";
|
|
3635
|
+
}
|
|
3636
|
+
else if (tos.type === TABLE_OF_SIGNS.VARIATIONS) {
|
|
3637
|
+
factorsFx = "\\(f''(x)\\)/1.2,\\(f(x)\\)/2";
|
|
3638
|
+
}
|
|
3639
|
+
// Create the tikzPicture header
|
|
3640
|
+
let tex = `\\begin{tikzpicture}
|
|
3641
|
+
\\tkzTabInit[lgt=3,espcl=2,deltacl=0]{/1.2,${factors.join(',')},/.1,${factorsFx} }{{\\scriptsize \\hspace{1cm} \\(-\\infty\\)},\\(${zeroes.map(x => x.tex).join('\\),\\(')}\\),{\\scriptsize \\hspace{-1cm} \\(+\\infty\\)}}`;
|
|
3642
|
+
let pos;
|
|
3643
|
+
for (pos = 0; pos < tos.factors.length; pos++) {
|
|
3644
|
+
tex += (`\n\\tkzTabLine{${tos.signs[pos].join(',')}}`);
|
|
3645
|
+
}
|
|
3646
|
+
// Add the result line
|
|
3647
|
+
tex += (`\n\\tkzTabLine{${tos.signs[pos].join(',')}}`);
|
|
3648
|
+
// Add the grows / vars line
|
|
3649
|
+
if (tos.type === TABLE_OF_SIGNS.GROWS) {
|
|
3650
|
+
tex += (`\n\\tkzTabVar{${tos.signs[pos + 1].join(',')}}`);
|
|
3651
|
+
}
|
|
3652
|
+
else if (tos.type === TABLE_OF_SIGNS.VARIATIONS) {
|
|
3653
|
+
// TODO: Check variations table for as tex
|
|
3654
|
+
tex += (`\n\\tkzTabVar{${tos.signs[pos + 1].join(',')}}`);
|
|
3655
|
+
}
|
|
3656
|
+
tex += `\n\\end{tikzpicture}`;
|
|
3657
|
+
return tex;
|
|
3658
|
+
};
|
|
3659
|
+
this.drawCode = () => {
|
|
3660
|
+
// Function as string
|
|
3661
|
+
let code = `f(x)=${this.fx.plotFunction}`;
|
|
3662
|
+
// Asymptotes
|
|
3663
|
+
let i = 1;
|
|
3664
|
+
this.asymptotes.forEach(asymptote => {
|
|
3665
|
+
if (asymptote.type === ASYMPTOTE.VERTICAL) {
|
|
3666
|
+
code += `\nav_${i}=line x=${asymptote.zero.value}->red,dash`;
|
|
3667
|
+
i++;
|
|
3668
|
+
}
|
|
3669
|
+
else if (asymptote.type === ASYMPTOTE.HORIZONTAL) {
|
|
3670
|
+
code += `\nah=line y=${asymptote.fx.monoms[0].coefficient.value}->orange,dash`;
|
|
3671
|
+
}
|
|
3672
|
+
else if (asymptote.type === ASYMPTOTE.SLOPE) {
|
|
3673
|
+
code += `\nao=line y=${asymptote.fx.plotFunction}->red,dash`;
|
|
3674
|
+
}
|
|
3675
|
+
i++;
|
|
3676
|
+
});
|
|
3677
|
+
// Extremes
|
|
3678
|
+
for (let zero in this.derivative.extremes) {
|
|
3679
|
+
let extreme = this.derivative.extremes[zero];
|
|
3680
|
+
code += `\nM_${i}(${extreme.value.x},${extreme.value.y})*`;
|
|
3681
|
+
i++;
|
|
3682
|
+
}
|
|
3683
|
+
// Zeroes
|
|
3684
|
+
this.zeroes.forEach(zero => {
|
|
3685
|
+
if (zero.type === ZEROTYPE.ZERO) {
|
|
3686
|
+
code += `\nZ_${i}(${zero.value},0)*`;
|
|
3687
|
+
i++;
|
|
3688
|
+
}
|
|
3689
|
+
});
|
|
3690
|
+
return code;
|
|
3691
|
+
};
|
|
3692
|
+
this.fx = fx;
|
|
3693
|
+
this.makeStudy();
|
|
3694
|
+
return this;
|
|
3695
|
+
}
|
|
3696
|
+
get zeroes() {
|
|
3697
|
+
return this._zeroes;
|
|
3698
|
+
}
|
|
3699
|
+
get domain() {
|
|
3700
|
+
return this.fx.domain();
|
|
3701
|
+
}
|
|
3702
|
+
get signs() {
|
|
3703
|
+
return this._signs;
|
|
3704
|
+
}
|
|
3705
|
+
get asymptotes() {
|
|
3706
|
+
return this._asymptotes;
|
|
3707
|
+
}
|
|
3708
|
+
get derivative() {
|
|
3709
|
+
return this._derivative;
|
|
3710
|
+
}
|
|
3711
|
+
get texSigns() {
|
|
3712
|
+
return this._makeTexFromTableOfSigns(this._signs);
|
|
3713
|
+
}
|
|
3714
|
+
get texGrows() {
|
|
3715
|
+
return this._makeTexFromTableOfSigns(this._derivative);
|
|
3716
|
+
}
|
|
3717
|
+
get texVariations() {
|
|
3718
|
+
return this._makeTexFromTableOfSigns(this._variations);
|
|
3719
|
+
}
|
|
3720
|
+
makeZeroes() {
|
|
3721
|
+
return [];
|
|
3722
|
+
}
|
|
3723
|
+
;
|
|
3724
|
+
makeSigns() {
|
|
3725
|
+
return {
|
|
3726
|
+
type: TABLE_OF_SIGNS.DEFAULT,
|
|
3727
|
+
fx: null,
|
|
3728
|
+
factors: [],
|
|
3729
|
+
zeroes: [],
|
|
3730
|
+
signs: [],
|
|
3731
|
+
extremes: {},
|
|
3732
|
+
tex: ''
|
|
3733
|
+
};
|
|
3734
|
+
}
|
|
3735
|
+
;
|
|
3736
|
+
makeAsymptotes() {
|
|
3737
|
+
return [];
|
|
3738
|
+
}
|
|
3739
|
+
makeDerivative() {
|
|
3740
|
+
return {
|
|
3741
|
+
type: TABLE_OF_SIGNS.GROWS,
|
|
3742
|
+
fx: null,
|
|
3743
|
+
factors: [],
|
|
3744
|
+
zeroes: [],
|
|
3745
|
+
signs: [],
|
|
3746
|
+
extremes: {},
|
|
3747
|
+
tex: ''
|
|
3748
|
+
};
|
|
3749
|
+
}
|
|
3750
|
+
makeVariation() {
|
|
3751
|
+
return {
|
|
3752
|
+
type: TABLE_OF_SIGNS.VARIATIONS,
|
|
3753
|
+
fx: null,
|
|
3754
|
+
factors: [],
|
|
3755
|
+
zeroes: [],
|
|
3756
|
+
signs: [],
|
|
3757
|
+
extremes: {},
|
|
3758
|
+
tex: ''
|
|
3759
|
+
};
|
|
3760
|
+
}
|
|
3761
|
+
}
|
|
3762
|
+
exports.Study = Study;
|
|
3763
|
+
|
|
3764
|
+
|
|
3765
|
+
/***/ }),
|
|
3766
|
+
|
|
3767
|
+
/***/ 572:
|
|
3768
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3769
|
+
|
|
3770
|
+
|
|
3771
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3772
|
+
exports.RationalStudy = void 0;
|
|
3773
|
+
/**
|
|
3774
|
+
* The study class is a "function study" class that will get:
|
|
3775
|
+
* fx : get the function
|
|
3776
|
+
* domain : string
|
|
3777
|
+
* zeroes : Object (tex, IZero)
|
|
3778
|
+
* signs : table of signs + tex output using tkz-tab
|
|
3779
|
+
* av : vertical asymptotic
|
|
3780
|
+
* ah : horizontal asymptotic
|
|
3781
|
+
* ao : obliques
|
|
3782
|
+
* deltaX : position relative
|
|
3783
|
+
* dx : derivative
|
|
3784
|
+
* grows : growing table + tex output using tkz-tab
|
|
3785
|
+
* ddx : dérivée seconde
|
|
3786
|
+
* variations : variation table + tex output using tkz-tab
|
|
3787
|
+
*/
|
|
3788
|
+
const study_1 = __webpack_require__(996);
|
|
3789
|
+
const rational_1 = __webpack_require__(107);
|
|
3790
|
+
const fraction_1 = __webpack_require__(506);
|
|
3791
|
+
const polynom_1 = __webpack_require__(38);
|
|
3792
|
+
class RationalStudy extends study_1.Study {
|
|
3793
|
+
constructor(fx) {
|
|
3794
|
+
super(fx);
|
|
3795
|
+
return this;
|
|
3796
|
+
}
|
|
3797
|
+
makeZeroes() {
|
|
3798
|
+
return this._getZeroes(this.fx);
|
|
3799
|
+
}
|
|
3800
|
+
;
|
|
3801
|
+
makeSigns() {
|
|
3802
|
+
let tos = this._getSigns(this.fx, this.zeroes);
|
|
3803
|
+
return tos;
|
|
3804
|
+
}
|
|
3805
|
+
;
|
|
3806
|
+
makeAsymptotes() {
|
|
3807
|
+
const reduced = this.fx.clone().reduce();
|
|
3808
|
+
// Vertical
|
|
3809
|
+
let asymptotes = [];
|
|
3810
|
+
this.zeroes.filter(x => x.type === study_1.ZEROTYPE.DEFENCE).forEach(zero => {
|
|
3811
|
+
// Check if it's a hole or an asymptote
|
|
3812
|
+
// TODO: Check for a hole ! Means calculate the limits !
|
|
3813
|
+
let Ztype = study_1.ASYMPTOTE.VERTICAL, tex = `x=${zero.tex}`;
|
|
3814
|
+
if (zero.exact instanceof fraction_1.Fraction) {
|
|
3815
|
+
if (reduced.denominator.evaluate(zero.exact).isNotZero()) {
|
|
3816
|
+
Ztype = study_1.ASYMPTOTE.HOLE;
|
|
3817
|
+
tex = `(${zero.tex};${reduced.evaluate(zero.exact).tex})`;
|
|
3818
|
+
}
|
|
3819
|
+
}
|
|
3820
|
+
else {
|
|
3821
|
+
if (reduced.denominator.evaluate(zero.value).isNotZero()) {
|
|
3822
|
+
Ztype = study_1.ASYMPTOTE.HOLE;
|
|
3823
|
+
tex = `(${zero.tex};${reduced.evaluate(zero.value).tex})`;
|
|
3824
|
+
}
|
|
3825
|
+
}
|
|
3826
|
+
asymptotes.push({
|
|
3827
|
+
fx: null,
|
|
3828
|
+
type: Ztype,
|
|
3829
|
+
tex: tex,
|
|
3830
|
+
zero: zero,
|
|
3831
|
+
limits: `\\lim_{x\\to${zero.tex} }\\ f(x) = \\pm\\infty`,
|
|
3832
|
+
deltaX: null
|
|
3833
|
+
});
|
|
3834
|
+
});
|
|
3835
|
+
// Sloped asymptote
|
|
3836
|
+
let NDegree = this.fx.numerator.degree(), DDegree = this.fx.denominator.degree();
|
|
3837
|
+
if (NDegree.isEqual(DDegree)) {
|
|
3838
|
+
let H = this.fx.numerator.monomByDegree().coefficient.clone().divide(this.fx.denominator.monomByDegree().coefficient), Htex = H.tex;
|
|
3839
|
+
let { reminder } = reduced.euclidian();
|
|
3840
|
+
asymptotes.push({
|
|
3841
|
+
fx: new polynom_1.Polynom(H),
|
|
3842
|
+
type: study_1.ASYMPTOTE.HORIZONTAL,
|
|
3843
|
+
tex: `y=${Htex}`,
|
|
3844
|
+
zero: null,
|
|
3845
|
+
limits: `\\lim_{x\\to\\infty}\\ f(x) = ${Htex}`,
|
|
3846
|
+
deltaX: new rational_1.Rational(reminder, reduced.denominator)
|
|
3847
|
+
});
|
|
3848
|
+
}
|
|
3849
|
+
else if (DDegree.greater(NDegree)) {
|
|
3850
|
+
asymptotes.push({
|
|
3851
|
+
fx: new polynom_1.Polynom('0'),
|
|
3852
|
+
type: study_1.ASYMPTOTE.HORIZONTAL,
|
|
3853
|
+
tex: `y=0`,
|
|
3854
|
+
zero: null,
|
|
3855
|
+
limits: `\\lim_{x\\to\\infty}\\ f(x) = ${0}`,
|
|
3856
|
+
deltaX: null
|
|
3857
|
+
});
|
|
3858
|
+
}
|
|
3859
|
+
else if (NDegree.value - 1 === DDegree.value) {
|
|
3860
|
+
// Calculate the slope
|
|
3861
|
+
let { quotient, reminder } = reduced.euclidian();
|
|
3862
|
+
asymptotes.push({
|
|
3863
|
+
fx: quotient.clone(),
|
|
3864
|
+
type: study_1.ASYMPTOTE.SLOPE,
|
|
3865
|
+
tex: `y=${quotient.tex}`,
|
|
3866
|
+
zero: null,
|
|
3867
|
+
limits: ``,
|
|
3868
|
+
deltaX: new rational_1.Rational(reminder, reduced.denominator)
|
|
3869
|
+
});
|
|
3870
|
+
}
|
|
3871
|
+
return asymptotes;
|
|
3872
|
+
}
|
|
3873
|
+
;
|
|
3874
|
+
makeDerivative() {
|
|
3875
|
+
let dx = this.fx.clone().derivative(), tos = this._getSigns(dx, this._getZeroes(dx), study_1.TABLE_OF_SIGNS.GROWS);
|
|
3876
|
+
let result = this.makeGrowsResult(tos);
|
|
3877
|
+
tos.signs.push(result.growsLine);
|
|
3878
|
+
tos.extremes = result.extremes;
|
|
3879
|
+
return tos;
|
|
3880
|
+
}
|
|
3881
|
+
;
|
|
3882
|
+
makeVariation() {
|
|
3883
|
+
// Get the zeroes, make signs.
|
|
3884
|
+
let dx = this.derivative.fx.clone().derivative(), tos = this._getSigns(dx, this._getZeroes(dx), study_1.TABLE_OF_SIGNS.VARIATIONS);
|
|
3885
|
+
let result = this.makeVariationsResult(tos);
|
|
3886
|
+
tos.signs.push(result.varsLine);
|
|
3887
|
+
tos.extremes = result.extremes;
|
|
3888
|
+
return tos;
|
|
3889
|
+
}
|
|
3890
|
+
;
|
|
3891
|
+
_getZeroes(fx) {
|
|
3892
|
+
// All zeroes.
|
|
3893
|
+
let zeroes = [];
|
|
3894
|
+
fx.numerator.getZeroes().filter(x => !isNaN(x.value)).forEach(z => {
|
|
3895
|
+
// add the item
|
|
3896
|
+
zeroes.push({
|
|
3897
|
+
tex: z.tex,
|
|
3898
|
+
value: z.value,
|
|
3899
|
+
exact: z.exact,
|
|
3900
|
+
extrema: study_1.FUNCTION_EXTREMA.NOTHING,
|
|
3901
|
+
type: study_1.ZEROTYPE.ZERO
|
|
3902
|
+
});
|
|
3903
|
+
});
|
|
3904
|
+
fx.denominator.getZeroes().filter(x => !isNaN(x.value)).forEach(z => {
|
|
3905
|
+
let idx = this.indexOfZero(zeroes, z);
|
|
3906
|
+
if (idx !== -1) {
|
|
3907
|
+
zeroes[idx].type = study_1.ZEROTYPE.DEFENCE;
|
|
3908
|
+
}
|
|
3909
|
+
else {
|
|
3910
|
+
// Add the item
|
|
3911
|
+
zeroes.push({
|
|
3912
|
+
tex: z.tex,
|
|
3913
|
+
value: z.value,
|
|
3914
|
+
exact: z.exact,
|
|
3915
|
+
extrema: study_1.FUNCTION_EXTREMA.NOTHING,
|
|
3916
|
+
type: study_1.ZEROTYPE.DEFENCE
|
|
3917
|
+
});
|
|
3918
|
+
}
|
|
3919
|
+
});
|
|
3920
|
+
// sort all zeroes
|
|
3921
|
+
zeroes.sort((a, b) => a.value - b.value);
|
|
3922
|
+
return zeroes;
|
|
3923
|
+
}
|
|
3924
|
+
_getSigns(fx, zeroes, typeOfTable) {
|
|
3925
|
+
// Factorize the rational
|
|
3926
|
+
let signs = [], factors = [];
|
|
3927
|
+
fx.numerator.factors.forEach(factor => {
|
|
3928
|
+
signs.push(this.makeOneLineForSigns(factor, zeroes, study_1.ZEROTYPE.ZERO));
|
|
3929
|
+
factors.push(factor.clone());
|
|
3930
|
+
});
|
|
3931
|
+
fx.denominator.factors.forEach(factor => {
|
|
3932
|
+
signs.push(this.makeOneLineForSigns(factor, zeroes, study_1.ZEROTYPE.DEFENCE));
|
|
3933
|
+
factors.push(factor.clone());
|
|
3934
|
+
});
|
|
3935
|
+
signs.push(this.makeSignsResult(signs));
|
|
3936
|
+
return {
|
|
3937
|
+
type: typeOfTable,
|
|
3938
|
+
fx,
|
|
3939
|
+
factors,
|
|
3940
|
+
zeroes,
|
|
3941
|
+
signs,
|
|
3942
|
+
extremes: {},
|
|
3943
|
+
tex: ''
|
|
3944
|
+
};
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3947
|
+
exports.RationalStudy = RationalStudy;
|
|
3948
|
+
|
|
3949
|
+
|
|
3430
3950
|
/***/ }),
|
|
3431
3951
|
|
|
3432
3952
|
/***/ 506:
|