pimath 0.0.61 → 0.0.64
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/.eslintrc.js +23 -23
- package/.idea/misc.xml +5 -0
- package/.idea/php.xml +1 -1
- package/.idea/shelf/Uncommitted_changes_before_Update_at_17_04_2022_12_40_[Changes]/shelved.patch +21 -0
- package/.idea/shelf/Uncommitted_changes_before_Update_at_17_04_2022_12_40__Changes_.xml +4 -0
- package/dist/pi.js +491 -98
- package/dist/pi.js.map +1 -1
- package/dist/pi.min.js +1 -1
- package/dist/pi.min.js.map +1 -1
- package/docs/assets/highlight.css +78 -78
- package/docs/assets/main.js +52 -52
- package/docs/assets/style.css +1413 -1413
- package/docs/classes/Logicalset.Logicalset-1.html +4 -4
- package/docs/classes/Polynom.Rational.html +3 -3
- package/docs/classes/algebra_equation.Equation.html +25 -25
- package/docs/classes/algebra_monom.Monom.html +113 -113
- package/docs/classes/algebra_polynom.Polynom.html +29 -29
- package/docs/classes/coefficients_fraction.Fraction.html +18 -18
- package/docs/classes/coefficients_nthroot.NthRoot.html +2 -2
- package/docs/classes/geometry_circle.Circle.html +2 -2
- package/docs/classes/geometry_line.Line.html +2 -2
- package/docs/classes/geometry_triangle.Triangle.html +16 -16
- package/docs/classes/numeric.Numeric.html +13 -13
- package/docs/classes/shutingyard.Shutingyard.html +17 -17
- package/docs/index.html +10 -10
- package/docs/interfaces/algebra_equation.ISolution.html +2 -2
- package/docs/modules/Logicalset.html +2 -2
- package/docs/modules/Polynom.html +2 -2
- package/docs/modules/Vector.html +2 -2
- package/esm/maths/algebra/linearSystem.js +0 -1
- package/esm/maths/algebra/linearSystem.js.map +1 -1
- package/esm/maths/algebra/monom.js +3 -0
- package/esm/maths/algebra/monom.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +19 -19
- package/esm/maths/algebra/polynom.js +7 -6
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/algebra/rational.d.ts +11 -15
- package/esm/maths/algebra/rational.js +15 -105
- package/esm/maths/algebra/rational.js.map +1 -1
- package/esm/maths/algebra/study/rationalStudy.d.ts +27 -0
- package/esm/maths/algebra/study/rationalStudy.js +174 -0
- package/esm/maths/algebra/study/rationalStudy.js.map +1 -0
- package/esm/maths/algebra/study.d.ts +128 -0
- package/esm/maths/algebra/study.js +284 -0
- package/esm/maths/algebra/study.js.map +1 -0
- package/package.json +1 -1
- package/src/maths/algebra/linearSystem.ts +0 -1
- package/src/maths/algebra/monom.ts +3 -0
- package/src/maths/algebra/polynom.ts +33 -36
- package/src/maths/algebra/rational.ts +24 -132
- package/src/maths/algebra/study/rationalStudy.ts +205 -0
- package/src/maths/algebra/study.ts +393 -0
- package/tests/algebra/rationnal.test.ts +0 -43
- package/tests/algebra/study.test.ts +18 -0
package/dist/pi.js
CHANGED
|
@@ -932,7 +932,6 @@ class LinearSystem {
|
|
|
932
932
|
this.log = () => {
|
|
933
933
|
let str = '';
|
|
934
934
|
for (let E of this._equations) {
|
|
935
|
-
console.log(E.tex);
|
|
936
935
|
str += `${E.tex}\\n}`;
|
|
937
936
|
}
|
|
938
937
|
return str;
|
|
@@ -1673,6 +1672,9 @@ class Monom {
|
|
|
1673
1672
|
return this.evaluate(tmpValues);
|
|
1674
1673
|
}
|
|
1675
1674
|
if (typeof values === 'object') {
|
|
1675
|
+
if (this.variables.length === 0) {
|
|
1676
|
+
return this.coefficient;
|
|
1677
|
+
}
|
|
1676
1678
|
for (let L in this._literal) {
|
|
1677
1679
|
if (values[L] === undefined) {
|
|
1678
1680
|
return new fraction_1.Fraction().zero();
|
|
@@ -2720,10 +2722,10 @@ class Polynom {
|
|
|
2720
2722
|
allDividers.shift();
|
|
2721
2723
|
}
|
|
2722
2724
|
else {
|
|
2723
|
-
// Add the factor
|
|
2724
|
-
factors.push(div);
|
|
2725
2725
|
// It's dividable - so make the division
|
|
2726
2726
|
let result = P.euclidian(div);
|
|
2727
|
+
// Add the factor
|
|
2728
|
+
factors.push(div);
|
|
2727
2729
|
// As it's dividable, get the quotient.
|
|
2728
2730
|
P = result.quotient.clone();
|
|
2729
2731
|
// filter all dividers that are no more suitable.
|
|
@@ -2748,11 +2750,11 @@ class Polynom {
|
|
|
2748
2750
|
factors.push(P.clone());
|
|
2749
2751
|
}
|
|
2750
2752
|
// Save the factors
|
|
2751
|
-
this.
|
|
2753
|
+
this._factors = factors;
|
|
2752
2754
|
// The factors list is no more dirty
|
|
2753
2755
|
this.dirty_factors = false;
|
|
2754
2756
|
}
|
|
2755
|
-
return this.
|
|
2757
|
+
return this._factors;
|
|
2756
2758
|
};
|
|
2757
2759
|
this.isDividableBy = (div) => {
|
|
2758
2760
|
// Quick evaluation.
|
|
@@ -3125,7 +3127,7 @@ class Polynom {
|
|
|
3125
3127
|
return this.getZeroes();
|
|
3126
3128
|
}
|
|
3127
3129
|
get factors() {
|
|
3128
|
-
return this.
|
|
3130
|
+
return this.factorize();
|
|
3129
3131
|
}
|
|
3130
3132
|
set factors(value) {
|
|
3131
3133
|
this.mark_as_dirty();
|
|
@@ -3262,6 +3264,7 @@ exports.Rational = void 0;
|
|
|
3262
3264
|
const polynom_1 = __webpack_require__(38);
|
|
3263
3265
|
const fraction_1 = __webpack_require__(506);
|
|
3264
3266
|
const equation_1 = __webpack_require__(760);
|
|
3267
|
+
const rationalStudy_1 = __webpack_require__(572);
|
|
3265
3268
|
/**
|
|
3266
3269
|
* Rational class can handle rational polynoms
|
|
3267
3270
|
*/
|
|
@@ -3273,9 +3276,7 @@ class Rational {
|
|
|
3273
3276
|
*/
|
|
3274
3277
|
constructor(numerator, denominator) {
|
|
3275
3278
|
this.clone = () => {
|
|
3276
|
-
this._numerator
|
|
3277
|
-
this._denominator = this._denominator.clone();
|
|
3278
|
-
return this;
|
|
3279
|
+
return new Rational(this._numerator.clone(), this._denominator.clone());
|
|
3279
3280
|
};
|
|
3280
3281
|
this.domain = () => {
|
|
3281
3282
|
let zeroes = this._denominator.getZeroes();
|
|
@@ -3340,6 +3341,10 @@ class Rational {
|
|
|
3340
3341
|
this.subtract = (R) => {
|
|
3341
3342
|
return this.add(R.clone().opposed());
|
|
3342
3343
|
};
|
|
3344
|
+
this.euclidian = () => {
|
|
3345
|
+
return this._numerator.euclidian(this._denominator);
|
|
3346
|
+
};
|
|
3347
|
+
// TODO : where and how is used limits ?
|
|
3343
3348
|
this.limits = (value, offset, letter) => {
|
|
3344
3349
|
if (value === Infinity || value === -Infinity) {
|
|
3345
3350
|
let { quotient, reminder } = this._numerator.clone().euclidian(this._denominator);
|
|
@@ -3380,26 +3385,154 @@ class Rational {
|
|
|
3380
3385
|
}
|
|
3381
3386
|
}
|
|
3382
3387
|
};
|
|
3383
|
-
this.
|
|
3384
|
-
|
|
3385
|
-
this._numerator.
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3388
|
+
this.evaluate = (values) => {
|
|
3389
|
+
const r = new fraction_1.Fraction().zero();
|
|
3390
|
+
let N = this._numerator.evaluate(values), D = this._denominator.evaluate(values);
|
|
3391
|
+
return N.divide(D);
|
|
3392
|
+
};
|
|
3393
|
+
this.study = () => {
|
|
3394
|
+
return new rationalStudy_1.RationalStudy(this);
|
|
3395
|
+
};
|
|
3396
|
+
if (numerator instanceof polynom_1.Polynom) {
|
|
3397
|
+
this._numerator = numerator.clone();
|
|
3398
|
+
}
|
|
3399
|
+
else if (typeof numerator === 'string') {
|
|
3400
|
+
this._numerator = new polynom_1.Polynom(numerator);
|
|
3401
|
+
}
|
|
3402
|
+
else {
|
|
3403
|
+
this._numerator = new polynom_1.Polynom();
|
|
3404
|
+
}
|
|
3405
|
+
if (denominator instanceof polynom_1.Polynom) {
|
|
3406
|
+
this._denominator = denominator.clone();
|
|
3407
|
+
}
|
|
3408
|
+
else if (typeof denominator === 'string') {
|
|
3409
|
+
this._denominator = new polynom_1.Polynom(denominator);
|
|
3410
|
+
}
|
|
3411
|
+
else {
|
|
3412
|
+
this._denominator = new polynom_1.Polynom();
|
|
3413
|
+
}
|
|
3414
|
+
}
|
|
3415
|
+
get numerator() {
|
|
3416
|
+
return this._numerator;
|
|
3417
|
+
}
|
|
3418
|
+
get denominator() {
|
|
3419
|
+
return this._denominator;
|
|
3420
|
+
}
|
|
3421
|
+
get tex() {
|
|
3422
|
+
return `\\frac{ ${this._numerator.tex} }{ ${this._denominator.tex} }`;
|
|
3423
|
+
}
|
|
3424
|
+
get texFactors() {
|
|
3425
|
+
return `\\frac{ ${this._numerator.texFactors} }{ ${this._denominator.texFactors} }`;
|
|
3426
|
+
}
|
|
3427
|
+
get plotFunction() {
|
|
3428
|
+
return `(${this._numerator.plotFunction})/(${this._denominator.plotFunction})`;
|
|
3429
|
+
}
|
|
3430
|
+
}
|
|
3431
|
+
exports.Rational = Rational;
|
|
3432
|
+
|
|
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
|
+
var ZEROTYPE;
|
|
3448
|
+
(function (ZEROTYPE) {
|
|
3449
|
+
ZEROTYPE["ZERO"] = "z";
|
|
3450
|
+
ZEROTYPE["DEFENCE"] = "d";
|
|
3451
|
+
ZEROTYPE["NOTHING"] = "t";
|
|
3452
|
+
})(ZEROTYPE = exports.ZEROTYPE || (exports.ZEROTYPE = {}));
|
|
3453
|
+
var ASYMPTOTE;
|
|
3454
|
+
(function (ASYMPTOTE) {
|
|
3455
|
+
ASYMPTOTE["VERTICAL"] = "av";
|
|
3456
|
+
ASYMPTOTE["HORIZONTAL"] = "ah";
|
|
3457
|
+
ASYMPTOTE["SLOPE"] = "ao";
|
|
3458
|
+
ASYMPTOTE["HOLE"] = "hole";
|
|
3459
|
+
})(ASYMPTOTE = exports.ASYMPTOTE || (exports.ASYMPTOTE = {}));
|
|
3460
|
+
var FUNCTION_EXTREMA;
|
|
3461
|
+
(function (FUNCTION_EXTREMA) {
|
|
3462
|
+
FUNCTION_EXTREMA["MIN"] = "min";
|
|
3463
|
+
FUNCTION_EXTREMA["MAX"] = "max";
|
|
3464
|
+
FUNCTION_EXTREMA["FLAT"] = "flat";
|
|
3465
|
+
FUNCTION_EXTREMA["NOTHING"] = "";
|
|
3466
|
+
})(FUNCTION_EXTREMA = exports.FUNCTION_EXTREMA || (exports.FUNCTION_EXTREMA = {}));
|
|
3467
|
+
var TABLE_OF_SIGNS;
|
|
3468
|
+
(function (TABLE_OF_SIGNS) {
|
|
3469
|
+
TABLE_OF_SIGNS[TABLE_OF_SIGNS["DEFAULT"] = 0] = "DEFAULT";
|
|
3470
|
+
TABLE_OF_SIGNS[TABLE_OF_SIGNS["GROWS"] = 1] = "GROWS";
|
|
3471
|
+
TABLE_OF_SIGNS[TABLE_OF_SIGNS["VARIATIONS"] = 2] = "VARIATIONS";
|
|
3472
|
+
})(TABLE_OF_SIGNS = exports.TABLE_OF_SIGNS || (exports.TABLE_OF_SIGNS = {}));
|
|
3473
|
+
/**
|
|
3474
|
+
* The study class is a "function study" class that will get:
|
|
3475
|
+
* fx : get the function
|
|
3476
|
+
* domain : string
|
|
3477
|
+
* zeroes : Object (tex, IZero)
|
|
3478
|
+
* signs : table of signs + tex output using tkz-tab
|
|
3479
|
+
* av : vertical asymptotic
|
|
3480
|
+
* ah : horizontal asymptotic
|
|
3481
|
+
* ao : obliques
|
|
3482
|
+
* deltaX : position relative
|
|
3483
|
+
* dx : derivative
|
|
3484
|
+
* grows : growing table + tex output using tkz-tab
|
|
3485
|
+
* ddx : dérivée seconde
|
|
3486
|
+
* variations : variation table + tex output using tkz-tab
|
|
3487
|
+
*/
|
|
3488
|
+
class Study {
|
|
3489
|
+
constructor(fx) {
|
|
3490
|
+
this.makeStudy = () => {
|
|
3491
|
+
this._zeroes = this.makeZeroes();
|
|
3492
|
+
this._signs = this.makeSigns();
|
|
3493
|
+
this._asymptotes = this.makeAsymptotes();
|
|
3494
|
+
this._derivative = this.makeDerivative();
|
|
3495
|
+
this._variations = this.makeVariation();
|
|
3496
|
+
this._signs.tex = this.texSigns;
|
|
3497
|
+
this._derivative.tex = this.texGrows;
|
|
3498
|
+
this._variations.tex = this.texVariations;
|
|
3499
|
+
};
|
|
3500
|
+
this.indexOfZero = (zeroes, zero) => {
|
|
3501
|
+
for (let i = 0; i < zeroes.length; i++) {
|
|
3502
|
+
if (zeroes[i].tex === zero.tex) {
|
|
3503
|
+
return i;
|
|
3401
3504
|
}
|
|
3402
|
-
|
|
3505
|
+
}
|
|
3506
|
+
return -1;
|
|
3507
|
+
};
|
|
3508
|
+
this.makeOneLineForSigns = (factor, zeroes, zeroSign) => {
|
|
3509
|
+
let oneLine = [], currentZero = factor.getZeroes().map(x => x.tex);
|
|
3510
|
+
// First +/- sign, before the first zero
|
|
3511
|
+
oneLine.push('');
|
|
3512
|
+
if (factor.degree().isZero()) {
|
|
3513
|
+
oneLine.push(factor.monoms[0].coefficient.sign() === 1 ? '+' : '-');
|
|
3514
|
+
}
|
|
3515
|
+
else {
|
|
3516
|
+
oneLine.push(factor.evaluate(zeroes[0].value - 1).sign() === 1 ? '+' : '-');
|
|
3517
|
+
}
|
|
3518
|
+
for (let i = 0; i < zeroes.length; i++) {
|
|
3519
|
+
// Add the zero if it's the current one
|
|
3520
|
+
oneLine.push(currentZero.includes(zeroes[i].tex) ? zeroSign : ZEROTYPE.NOTHING);
|
|
3521
|
+
// + / - sign after the current zero
|
|
3522
|
+
if (i < zeroes.length - 1) {
|
|
3523
|
+
oneLine.push(factor.evaluate((zeroes[i].value + zeroes[i + 1].value) / 2).sign() === 1 ? '+' : '-');
|
|
3524
|
+
}
|
|
3525
|
+
else if (i === zeroes.length - 1) {
|
|
3526
|
+
oneLine.push(factor.evaluate(zeroes[i].value + 1).sign() === 1 ? '+' : '-');
|
|
3527
|
+
}
|
|
3528
|
+
}
|
|
3529
|
+
oneLine.push('');
|
|
3530
|
+
return oneLine;
|
|
3531
|
+
};
|
|
3532
|
+
this.makeSignsResult = (signs) => {
|
|
3533
|
+
// Initialize the result line with the first line of the signs table
|
|
3534
|
+
let resultLine = signs[0].map((x, index) => {
|
|
3535
|
+
if (index === 0 || index === signs[0].length - 1) {
|
|
3403
3536
|
return '';
|
|
3404
3537
|
}
|
|
3405
3538
|
if (index % 2 === 0) {
|
|
@@ -3407,7 +3540,8 @@ class Rational {
|
|
|
3407
3540
|
}
|
|
3408
3541
|
return '+';
|
|
3409
3542
|
});
|
|
3410
|
-
|
|
3543
|
+
// Go through each lines (except the first)
|
|
3544
|
+
for (let current of signs) {
|
|
3411
3545
|
for (let i = 0; i < current.length; i++) {
|
|
3412
3546
|
if (i % 2 === 0) {
|
|
3413
3547
|
// t, z or d
|
|
@@ -3426,93 +3560,352 @@ class Rational {
|
|
|
3426
3560
|
}
|
|
3427
3561
|
}
|
|
3428
3562
|
}
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3563
|
+
return resultLine;
|
|
3564
|
+
};
|
|
3565
|
+
this.makeGrowsResult = (tos) => {
|
|
3566
|
+
// Use the last line (=> resultLine) to grab the necessary information
|
|
3567
|
+
let signsAsArray = Object.values(tos.signs), resultLine = signsAsArray[signsAsArray.length - 1], growsLine = [], extremes = {}, zeroes = tos.zeroes;
|
|
3568
|
+
// Get the extremes
|
|
3569
|
+
for (let i = 0; i < zeroes.length; i++) {
|
|
3570
|
+
// Get the corresponding item in the resultLine.
|
|
3571
|
+
let pos = 2 * i + 2;
|
|
3572
|
+
if (resultLine[pos] === 'z') {
|
|
3573
|
+
// It's a zero. Get the coordinates
|
|
3574
|
+
let x, y, zero = zeroes[i].exact, pt, xTex, yTex, pointType;
|
|
3575
|
+
if (zero instanceof fraction_1.Fraction) {
|
|
3576
|
+
let value = zero, evalY = this.fx.evaluate(value);
|
|
3577
|
+
x = zero.value;
|
|
3578
|
+
y = evalY.value;
|
|
3579
|
+
xTex = zero.tex;
|
|
3580
|
+
yTex = evalY.tex;
|
|
3581
|
+
}
|
|
3582
|
+
else {
|
|
3583
|
+
x = zeroes[i].value;
|
|
3584
|
+
y = this.fx.evaluate(zeroes[i].value).value;
|
|
3585
|
+
xTex = x.toFixed(2);
|
|
3586
|
+
yTex = y.toFixed(2);
|
|
3587
|
+
}
|
|
3588
|
+
// Determine the type of the zero.
|
|
3589
|
+
if (resultLine[pos - 1] === resultLine[pos + 1]) {
|
|
3590
|
+
pointType = FUNCTION_EXTREMA.FLAT;
|
|
3591
|
+
}
|
|
3592
|
+
else if (resultLine[pos - 1] === '+') {
|
|
3593
|
+
pointType = FUNCTION_EXTREMA.MAX;
|
|
3594
|
+
}
|
|
3595
|
+
else {
|
|
3596
|
+
pointType = FUNCTION_EXTREMA.MIN;
|
|
3597
|
+
}
|
|
3598
|
+
// Add the point to the list
|
|
3599
|
+
extremes[zeroes[i].tex] = {
|
|
3600
|
+
type: pointType,
|
|
3601
|
+
tex: { x: xTex, y: yTex },
|
|
3602
|
+
value: { x, y }
|
|
3603
|
+
};
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3606
|
+
// Create the grows line, based on tkz-tab
|
|
3607
|
+
// \tkzTabLine{ , + , z , - , d , - , z , + , }
|
|
3608
|
+
// \tkzTabVar{ -/ , +/$3$ , -D+/ , -/$1$ , +/ }
|
|
3609
|
+
growsLine.push(resultLine[1] === '+' ? '-/' : '+/');
|
|
3610
|
+
for (let i = 1; i < resultLine.length - 1; i++) {
|
|
3611
|
+
if (resultLine[i] === "z") {
|
|
3612
|
+
let extr = extremes[zeroes[(i - 2) / 2].tex];
|
|
3613
|
+
growsLine.push(`${resultLine[i - 1]}/\\(${extr.type}(${extr.tex.x};${extr.tex.y})\\)`);
|
|
3614
|
+
}
|
|
3615
|
+
else if (resultLine[i] === 'd') {
|
|
3616
|
+
growsLine.push(`${resultLine[i - 1]}D${resultLine[i + 1] === '+' ? '-' : '+'}/`);
|
|
3617
|
+
}
|
|
3618
|
+
}
|
|
3619
|
+
growsLine.push(`${resultLine[resultLine.length - 2]}/`);
|
|
3620
|
+
return { growsLine, extremes };
|
|
3621
|
+
};
|
|
3622
|
+
this.makeVariationsResult = (tos) => {
|
|
3623
|
+
// TODO: make variations result is not yet implemented.
|
|
3624
|
+
let extremes = {}, varsLine = [];
|
|
3625
|
+
return { varsLine, extremes };
|
|
3440
3626
|
};
|
|
3441
3627
|
this._makeTexFromTableOfSigns = (tos) => {
|
|
3628
|
+
let factors = tos.factors.map(x => `\\(${x.tex}\\)/1`), factorsFx = "\\(fx\\)/1.2", zeroes = tos.zeroes;
|
|
3629
|
+
// Add the last lines "label"
|
|
3630
|
+
if (tos.type === TABLE_OF_SIGNS.GROWS) {
|
|
3631
|
+
factorsFx = "\\(f'(x)\\)/1.2,\\(f(x)\\)/2";
|
|
3632
|
+
}
|
|
3633
|
+
else if (tos.type === TABLE_OF_SIGNS.VARIATIONS) {
|
|
3634
|
+
factorsFx = "\\(f''(x)\\)/1.2,\\(f(x)\\)/2";
|
|
3635
|
+
}
|
|
3636
|
+
// Create the tikzPicture header
|
|
3442
3637
|
let tex = `\\begin{tikzpicture}
|
|
3443
|
-
\\tkzTabInit[lgt=3,espcl=2,deltacl=0]{/1.2
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3638
|
+
\\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\\)}}`;
|
|
3639
|
+
let pos;
|
|
3640
|
+
for (pos = 0; pos < tos.factors.length; pos++) {
|
|
3641
|
+
tex += (`\n\\tkzTabLine{${tos.signs[pos].join(',')}}`);
|
|
3642
|
+
}
|
|
3643
|
+
// Add the result line
|
|
3644
|
+
tex += (`\n\\tkzTabLine{${tos.signs[pos].join(',')}}`);
|
|
3645
|
+
// Add the grows / vars line
|
|
3646
|
+
if (tos.type === TABLE_OF_SIGNS.GROWS) {
|
|
3647
|
+
tex += (`\n\\tkzTabVar{${tos.signs[pos + 1].join(',')}}`);
|
|
3648
|
+
}
|
|
3649
|
+
else if (tos.type === TABLE_OF_SIGNS.VARIATIONS) {
|
|
3650
|
+
// TODO: Check variations table for as tex
|
|
3651
|
+
tex += (`\n\\tkzTabVar{${tos.signs[pos + 1].join(',')}}`);
|
|
3652
|
+
}
|
|
3447
3653
|
tex += `\n\\end{tikzpicture}`;
|
|
3448
|
-
tos.tex = tex;
|
|
3449
3654
|
return tex;
|
|
3450
3655
|
};
|
|
3451
|
-
this.
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3656
|
+
this.fx = fx;
|
|
3657
|
+
this.makeStudy();
|
|
3658
|
+
return this;
|
|
3659
|
+
}
|
|
3660
|
+
get zeroes() {
|
|
3661
|
+
return this._zeroes;
|
|
3662
|
+
}
|
|
3663
|
+
get domain() {
|
|
3664
|
+
return this.fx.domain();
|
|
3665
|
+
}
|
|
3666
|
+
get signs() {
|
|
3667
|
+
return this._signs;
|
|
3668
|
+
}
|
|
3669
|
+
get asymptotes() {
|
|
3670
|
+
return this._asymptotes;
|
|
3671
|
+
}
|
|
3672
|
+
get derivative() {
|
|
3673
|
+
return this._derivative;
|
|
3674
|
+
}
|
|
3675
|
+
get texSigns() {
|
|
3676
|
+
return this._makeTexFromTableOfSigns(this._signs);
|
|
3677
|
+
}
|
|
3678
|
+
get texGrows() {
|
|
3679
|
+
return this._makeTexFromTableOfSigns(this._derivative);
|
|
3680
|
+
}
|
|
3681
|
+
get texVariations() {
|
|
3682
|
+
return this._makeTexFromTableOfSigns(this._variations);
|
|
3683
|
+
}
|
|
3684
|
+
makeZeroes() {
|
|
3685
|
+
return [];
|
|
3686
|
+
}
|
|
3687
|
+
;
|
|
3688
|
+
makeSigns() {
|
|
3689
|
+
return {
|
|
3690
|
+
type: TABLE_OF_SIGNS.DEFAULT,
|
|
3691
|
+
fx: null,
|
|
3692
|
+
factors: [],
|
|
3693
|
+
zeroes: [],
|
|
3694
|
+
signs: [],
|
|
3695
|
+
extremes: {},
|
|
3696
|
+
tex: ''
|
|
3697
|
+
};
|
|
3698
|
+
}
|
|
3699
|
+
;
|
|
3700
|
+
makeAsymptotes() {
|
|
3701
|
+
return [];
|
|
3702
|
+
}
|
|
3703
|
+
makeDerivative() {
|
|
3704
|
+
return {
|
|
3705
|
+
type: TABLE_OF_SIGNS.GROWS,
|
|
3706
|
+
fx: null,
|
|
3707
|
+
factors: [],
|
|
3708
|
+
zeroes: [],
|
|
3709
|
+
signs: [],
|
|
3710
|
+
extremes: {},
|
|
3711
|
+
tex: ''
|
|
3712
|
+
};
|
|
3713
|
+
}
|
|
3714
|
+
makeVariation() {
|
|
3715
|
+
return {
|
|
3716
|
+
type: TABLE_OF_SIGNS.VARIATIONS,
|
|
3717
|
+
fx: null,
|
|
3718
|
+
factors: [],
|
|
3719
|
+
zeroes: [],
|
|
3720
|
+
signs: [],
|
|
3721
|
+
extremes: {},
|
|
3722
|
+
tex: ''
|
|
3723
|
+
};
|
|
3724
|
+
}
|
|
3725
|
+
}
|
|
3726
|
+
exports.Study = Study;
|
|
3727
|
+
|
|
3728
|
+
|
|
3729
|
+
/***/ }),
|
|
3730
|
+
|
|
3731
|
+
/***/ 572:
|
|
3732
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3733
|
+
|
|
3734
|
+
|
|
3735
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3736
|
+
exports.RationalStudy = void 0;
|
|
3737
|
+
/**
|
|
3738
|
+
* The study class is a "function study" class that will get:
|
|
3739
|
+
* fx : get the function
|
|
3740
|
+
* domain : string
|
|
3741
|
+
* zeroes : Object (tex, IZero)
|
|
3742
|
+
* signs : table of signs + tex output using tkz-tab
|
|
3743
|
+
* av : vertical asymptotic
|
|
3744
|
+
* ah : horizontal asymptotic
|
|
3745
|
+
* ao : obliques
|
|
3746
|
+
* deltaX : position relative
|
|
3747
|
+
* dx : derivative
|
|
3748
|
+
* grows : growing table + tex output using tkz-tab
|
|
3749
|
+
* ddx : dérivée seconde
|
|
3750
|
+
* variations : variation table + tex output using tkz-tab
|
|
3751
|
+
*/
|
|
3752
|
+
const study_1 = __webpack_require__(996);
|
|
3753
|
+
const rational_1 = __webpack_require__(107);
|
|
3754
|
+
const fraction_1 = __webpack_require__(506);
|
|
3755
|
+
class RationalStudy extends study_1.Study {
|
|
3756
|
+
constructor(fx) {
|
|
3757
|
+
super(fx);
|
|
3758
|
+
return this;
|
|
3759
|
+
}
|
|
3760
|
+
makeZeroes() {
|
|
3761
|
+
console.log('GETTING ZEROES');
|
|
3762
|
+
return this._getZeroes(this.fx);
|
|
3763
|
+
}
|
|
3764
|
+
;
|
|
3765
|
+
makeSigns() {
|
|
3766
|
+
let tos = this._getSigns(this.fx, this.zeroes);
|
|
3767
|
+
return tos;
|
|
3768
|
+
}
|
|
3769
|
+
;
|
|
3770
|
+
makeAsymptotes() {
|
|
3771
|
+
const reduced = this.fx.clone().reduce();
|
|
3772
|
+
// Vertical
|
|
3773
|
+
let asymptotes = [];
|
|
3774
|
+
this.zeroes.filter(x => x.type === study_1.ZEROTYPE.DEFENCE).forEach(zero => {
|
|
3775
|
+
// Check if it's a hole or an asymptote
|
|
3776
|
+
// TODO: Check for a hole ! Means calculate the limits !
|
|
3777
|
+
let Ztype = study_1.ASYMPTOTE.VERTICAL, tex = `x=${zero.tex}`;
|
|
3778
|
+
if (zero.exact instanceof fraction_1.Fraction) {
|
|
3779
|
+
if (reduced.denominator.evaluate(zero.exact).isNotZero()) {
|
|
3780
|
+
Ztype = study_1.ASYMPTOTE.HOLE;
|
|
3781
|
+
tex = `(${zero.tex};${reduced.evaluate(zero.exact).tex})`;
|
|
3782
|
+
}
|
|
3457
3783
|
}
|
|
3458
3784
|
else {
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
// Add the zero if it's the current one
|
|
3463
|
-
oneLine.push(currentZero.includes(zeroes[i].tex) ? zeroSign : 't');
|
|
3464
|
-
// + / - sign after the current zero
|
|
3465
|
-
if (i < zeroes.length - 1) {
|
|
3466
|
-
oneLine.push(factor.evaluate((zeroes[i].value + zeroes[i + 1].value) / 2).sign() === 1 ? '+' : '-');
|
|
3467
|
-
}
|
|
3468
|
-
else if (i === zeroes.length - 1) {
|
|
3469
|
-
oneLine.push(factor.evaluate(zeroes[i].value + 1).sign() === 1 ? '+' : '-');
|
|
3785
|
+
if (reduced.denominator.evaluate(zero.value).isNotZero()) {
|
|
3786
|
+
Ztype = study_1.ASYMPTOTE.HOLE;
|
|
3787
|
+
tex = `(${zero.tex};${reduced.evaluate(zero.value).tex})`;
|
|
3470
3788
|
}
|
|
3471
3789
|
}
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
};
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3790
|
+
asymptotes.push({
|
|
3791
|
+
type: Ztype,
|
|
3792
|
+
tex: tex,
|
|
3793
|
+
zero: zero,
|
|
3794
|
+
limits: `\\lim_{x\\to${zero.tex} }\\ f(x) = \\pm\\infty`,
|
|
3795
|
+
deltaX: null
|
|
3796
|
+
});
|
|
3797
|
+
});
|
|
3798
|
+
// Sloped asymptote
|
|
3799
|
+
let NDegree = this.fx.numerator.degree(), DDegree = this.fx.denominator.degree();
|
|
3800
|
+
if (NDegree.isEqual(DDegree)) {
|
|
3801
|
+
let H = this.fx.numerator.monomByDegree().coefficient.clone().divide(this.fx.denominator.monomByDegree().coefficient).tex;
|
|
3802
|
+
let { reminder } = reduced.euclidian();
|
|
3803
|
+
asymptotes.push({
|
|
3804
|
+
type: study_1.ASYMPTOTE.HORIZONTAL,
|
|
3805
|
+
tex: `y=${H}`,
|
|
3806
|
+
zero: null,
|
|
3807
|
+
limits: `\\lim_{x\\to\\infty}\\ f(x) = ${H}`,
|
|
3808
|
+
deltaX: new rational_1.Rational(reminder, reduced.denominator)
|
|
3809
|
+
});
|
|
3491
3810
|
}
|
|
3492
|
-
else if (
|
|
3493
|
-
|
|
3811
|
+
else if (DDegree.greater(NDegree)) {
|
|
3812
|
+
asymptotes.push({
|
|
3813
|
+
type: study_1.ASYMPTOTE.HORIZONTAL,
|
|
3814
|
+
tex: `y=0`,
|
|
3815
|
+
zero: null,
|
|
3816
|
+
limits: `\\lim_{x\\to\\infty}\\ f(x) = ${0}`,
|
|
3817
|
+
deltaX: null
|
|
3818
|
+
});
|
|
3494
3819
|
}
|
|
3495
|
-
else {
|
|
3496
|
-
|
|
3820
|
+
else if (NDegree.value - 1 === DDegree.value) {
|
|
3821
|
+
// Calculate the slope
|
|
3822
|
+
let { quotient, reminder } = reduced.euclidian();
|
|
3823
|
+
asymptotes.push({
|
|
3824
|
+
type: study_1.ASYMPTOTE.SLOPE,
|
|
3825
|
+
tex: `y=${quotient.tex}`,
|
|
3826
|
+
zero: null,
|
|
3827
|
+
limits: ``,
|
|
3828
|
+
deltaX: new rational_1.Rational(reminder, reduced.denominator)
|
|
3829
|
+
});
|
|
3497
3830
|
}
|
|
3831
|
+
return asymptotes;
|
|
3498
3832
|
}
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
return
|
|
3833
|
+
;
|
|
3834
|
+
makeDerivative() {
|
|
3835
|
+
let dx = this.fx.clone().derivative(), tos = this._getSigns(dx, this._getZeroes(dx), study_1.TABLE_OF_SIGNS.GROWS);
|
|
3836
|
+
console.log(tos.factors.length, tos.signs.length);
|
|
3837
|
+
let result = this.makeGrowsResult(tos);
|
|
3838
|
+
tos.signs.push(result.growsLine);
|
|
3839
|
+
tos.extremes = result.extremes;
|
|
3840
|
+
return tos;
|
|
3507
3841
|
}
|
|
3508
|
-
|
|
3509
|
-
|
|
3842
|
+
;
|
|
3843
|
+
makeVariation() {
|
|
3844
|
+
// Get the zeroes, make signs.
|
|
3845
|
+
let dx = this.derivative.fx.clone().derivative(), tos = this._getSigns(dx, this._getZeroes(dx), study_1.TABLE_OF_SIGNS.VARIATIONS);
|
|
3846
|
+
let result = this.makeVariationsResult(tos);
|
|
3847
|
+
tos.signs.push(result.varsLine);
|
|
3848
|
+
tos.extremes = result.extremes;
|
|
3849
|
+
return tos;
|
|
3510
3850
|
}
|
|
3511
|
-
|
|
3512
|
-
|
|
3851
|
+
;
|
|
3852
|
+
_getZeroes(fx) {
|
|
3853
|
+
// All zeroes.
|
|
3854
|
+
let zeroes = [];
|
|
3855
|
+
fx.numerator.getZeroes().filter(x => !isNaN(x.value)).forEach(z => {
|
|
3856
|
+
// add the item
|
|
3857
|
+
zeroes.push({
|
|
3858
|
+
tex: z.tex,
|
|
3859
|
+
value: z.value,
|
|
3860
|
+
exact: z.exact,
|
|
3861
|
+
extrema: study_1.FUNCTION_EXTREMA.NOTHING,
|
|
3862
|
+
type: study_1.ZEROTYPE.ZERO
|
|
3863
|
+
});
|
|
3864
|
+
});
|
|
3865
|
+
fx.denominator.getZeroes().filter(x => !isNaN(x.value)).forEach(z => {
|
|
3866
|
+
let idx = this.indexOfZero(zeroes, z);
|
|
3867
|
+
if (idx !== -1) {
|
|
3868
|
+
zeroes[idx].type = study_1.ZEROTYPE.DEFENCE;
|
|
3869
|
+
}
|
|
3870
|
+
else {
|
|
3871
|
+
// Add the item
|
|
3872
|
+
zeroes.push({
|
|
3873
|
+
tex: z.tex,
|
|
3874
|
+
value: z.value,
|
|
3875
|
+
exact: z.exact,
|
|
3876
|
+
extrema: study_1.FUNCTION_EXTREMA.NOTHING,
|
|
3877
|
+
type: study_1.ZEROTYPE.DEFENCE
|
|
3878
|
+
});
|
|
3879
|
+
}
|
|
3880
|
+
});
|
|
3881
|
+
// sort all zeroes
|
|
3882
|
+
zeroes.sort((a, b) => a.value - b.value);
|
|
3883
|
+
return zeroes;
|
|
3884
|
+
}
|
|
3885
|
+
_getSigns(fx, zeroes, typeOfTable) {
|
|
3886
|
+
// Factorize the rational
|
|
3887
|
+
let signs = [], factors = [];
|
|
3888
|
+
fx.numerator.factors.forEach(factor => {
|
|
3889
|
+
signs.push(this.makeOneLineForSigns(factor, zeroes, study_1.ZEROTYPE.ZERO));
|
|
3890
|
+
factors.push(factor.clone());
|
|
3891
|
+
});
|
|
3892
|
+
fx.denominator.factors.forEach(factor => {
|
|
3893
|
+
signs.push(this.makeOneLineForSigns(factor, zeroes, study_1.ZEROTYPE.DEFENCE));
|
|
3894
|
+
factors.push(factor.clone());
|
|
3895
|
+
});
|
|
3896
|
+
signs.push(this.makeSignsResult(signs));
|
|
3897
|
+
return {
|
|
3898
|
+
type: typeOfTable,
|
|
3899
|
+
fx,
|
|
3900
|
+
factors,
|
|
3901
|
+
zeroes,
|
|
3902
|
+
signs,
|
|
3903
|
+
extremes: {},
|
|
3904
|
+
tex: ''
|
|
3905
|
+
};
|
|
3513
3906
|
}
|
|
3514
3907
|
}
|
|
3515
|
-
exports.
|
|
3908
|
+
exports.RationalStudy = RationalStudy;
|
|
3516
3909
|
|
|
3517
3910
|
|
|
3518
3911
|
/***/ }),
|