pimath 0.0.120 → 0.0.122
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/.idea/PI.iml +7 -1
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]/shelved.patch +90 -0
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]1/shelved.patch +107 -0
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_.xml +4 -0
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_1.xml +4 -0
- package/LICENSE.md +1 -1
- package/dev/pimath.js +7929 -0
- package/dev/pimath.js.map +1 -0
- package/dist/{pi.js → pimath.js} +7613 -7840
- package/dist/pimath.js.map +1 -0
- package/dist/pimath.min.js +2 -0
- package/dist/pimath.min.js.map +1 -0
- package/docs/assets/main.js +58 -58
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +1367 -1280
- package/docs/classes/Logicalset.Logicalset.html +221 -212
- package/docs/classes/Polynom.Rational.html +391 -388
- package/docs/classes/Vector-1.Vector.html +494 -448
- package/docs/classes/Vector.Point.html +341 -342
- package/docs/classes/algebra_equation.Equation.html +796 -753
- package/docs/classes/algebra_linearSystem.LinearSystem.html +408 -397
- package/docs/classes/algebra_monom.Monom.html +967 -910
- package/docs/classes/algebra_polynom.Polynom.html +1281 -1260
- package/docs/classes/coefficients_fraction.Fraction.html +939 -931
- package/docs/classes/geometry_circle.Circle.html +476 -476
- package/docs/classes/geometry_line.Line.html +779 -719
- package/docs/classes/geometry_triangle.Triangle.html +429 -420
- package/docs/classes/numeric.Numeric.html +269 -263
- package/docs/classes/shutingyard.Shutingyard.html +259 -248
- package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +89 -88
- package/docs/enums/geometry_line.LinePropriety.html +102 -102
- package/docs/enums/shutingyard.ShutingyardMode.html +106 -102
- package/docs/enums/shutingyard.ShutingyardType.html +120 -116
- package/docs/index.html +63 -65
- package/docs/interfaces/algebra_equation.ISolution.html +111 -109
- package/docs/interfaces/algebra_polynom.IEuclidian.html +93 -92
- package/docs/interfaces/geometry_triangle.remarquableLines.html +150 -150
- package/docs/modules/Logicalset.html +69 -74
- package/docs/modules/Polynom.html +69 -74
- package/docs/modules/Vector-1.html +69 -74
- package/docs/modules/Vector.html +69 -74
- package/docs/modules/algebra_equation.html +75 -81
- package/docs/modules/algebra_linearSystem.html +65 -71
- package/docs/modules/algebra_monom.html +70 -76
- package/docs/modules/algebra_polynom.html +75 -81
- package/docs/modules/coefficients_fraction.html +70 -76
- package/docs/modules/geometry_circle.html +65 -71
- package/docs/modules/geometry_line.html +70 -76
- package/docs/modules/geometry_triangle.html +70 -76
- package/docs/modules/numeric.html +65 -71
- package/docs/modules/shutingyard.html +84 -90
- package/docs/types/algebra_monom.literalType.html +66 -70
- package/docs/types/algebra_polynom.PolynomParsingType.html +62 -66
- package/docs/types/coefficients_fraction.FractionParsingType.html +61 -65
- package/docs/types/shutingyard.Token.html +72 -76
- package/docs/types/shutingyard.tokenType.html +77 -81
- package/docs/variables/shutingyard.tokenConstant.html +70 -74
- package/esm/index.d.ts +38 -41
- package/esm/index.js +43 -46
- package/esm/index.js.map +1 -1
- package/esm/maths/algebra/equation.d.ts +119 -117
- package/esm/maths/algebra/equation.js +796 -785
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/algebra/linearSystem.d.ts +39 -38
- package/esm/maths/algebra/linearSystem.js +278 -262
- package/esm/maths/algebra/linearSystem.js.map +1 -1
- package/esm/maths/algebra/logicalset.d.ts +28 -28
- package/esm/maths/algebra/logicalset.js +157 -157
- package/esm/maths/algebra/monom.d.ts +206 -206
- package/esm/maths/algebra/monom.js +908 -908
- package/esm/maths/algebra/monom.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +157 -157
- package/esm/maths/algebra/polynom.js +1277 -1277
- package/esm/maths/algebra/rational.d.ts +45 -45
- package/esm/maths/algebra/rational.js +183 -183
- package/esm/maths/algebra/study/rationalStudy.d.ts +28 -28
- package/esm/maths/algebra/study/rationalStudy.js +243 -243
- package/esm/maths/algebra/study.d.ts +143 -142
- package/esm/maths/algebra/study.js +378 -377
- package/esm/maths/algebra/study.js.map +1 -1
- package/esm/maths/coefficients/fraction.d.ts +90 -90
- package/esm/maths/coefficients/fraction.js +516 -516
- package/esm/maths/coefficients/fraction.js.map +1 -1
- package/esm/maths/coefficients/nthRoot.d.ts +23 -23
- package/esm/maths/coefficients/nthRoot.js +136 -136
- package/esm/maths/geometry/circle.d.ts +45 -45
- package/esm/maths/geometry/circle.js +323 -323
- package/esm/maths/geometry/line.d.ts +99 -99
- package/esm/maths/geometry/line.js +481 -481
- package/esm/maths/geometry/line.js.map +1 -1
- package/esm/maths/geometry/point.d.ts +34 -34
- package/esm/maths/geometry/point.js +166 -166
- package/esm/maths/geometry/point.js.map +1 -1
- package/esm/maths/geometry/triangle.d.ts +85 -85
- package/esm/maths/geometry/triangle.js +268 -268
- package/esm/maths/geometry/vector.d.ts +41 -41
- package/esm/maths/geometry/vector.js +197 -197
- package/esm/maths/geometry/vector.js.map +1 -1
- package/esm/maths/numeric.d.ts +28 -28
- package/esm/maths/numeric.js +180 -180
- package/esm/maths/numexp.d.ts +19 -0
- package/esm/maths/numexp.js +186 -0
- package/esm/maths/numexp.js.map +1 -0
- package/esm/maths/randomization/random.d.ts +23 -23
- package/esm/maths/randomization/random.js +78 -78
- package/esm/maths/randomization/random.js.map +1 -1
- package/esm/maths/randomization/randomCore.d.ts +7 -7
- package/esm/maths/randomization/randomCore.js +21 -21
- package/esm/maths/randomization/rndFraction.d.ts +12 -12
- package/esm/maths/randomization/rndFraction.js +43 -43
- package/esm/maths/randomization/rndGeometryLine.d.ts +12 -12
- package/esm/maths/randomization/rndGeometryLine.js +45 -45
- package/esm/maths/randomization/rndGeometryPoint.d.ts +12 -12
- package/esm/maths/randomization/rndGeometryPoint.js +60 -60
- package/esm/maths/randomization/rndHelpers.d.ts +23 -23
- package/esm/maths/randomization/rndHelpers.js +76 -76
- package/esm/maths/randomization/rndMonom.d.ts +12 -12
- package/esm/maths/randomization/rndMonom.js +52 -52
- package/esm/maths/randomization/rndPolynom.d.ts +13 -13
- package/esm/maths/randomization/rndPolynom.js +74 -74
- package/esm/maths/randomization/rndTypes.d.ts +34 -34
- package/esm/maths/randomization/rndTypes.js +2 -2
- package/esm/maths/shutingyard.d.ts +59 -59
- package/esm/maths/shutingyard.js +442 -442
- package/esm/maths/shutingyard.js.map +1 -1
- package/package.json +11 -11
- package/public/index.html +50 -81
- package/public/playground.html +7 -8
- package/src/index.ts +1 -4
- package/src/maths/algebra/equation.ts +16 -0
- package/src/maths/algebra/linearSystem.ts +20 -0
- package/src/maths/algebra/study.ts +12 -10
- package/src/maths/{expressions/numexp.ts → numexp.ts} +2 -2
- package/tests/algebra/equation.test.ts +19 -5
- package/tests/algebra/linear.test.ts +3 -11
- package/tests/algebra/polynom.test.ts +7 -8
- package/tests/algebra/rationnal.test.ts +1 -1
- package/tests/algebra/study.test.ts +2 -9
- package/tests/coefficients/fraction.test.ts +8 -8
- package/tests/custom.test.ts +33 -37
- package/tests/numeric.test.ts +1 -2
- package/tests/numexp.test.ts +13 -5
- package/tests/shutingyard.test.ts +3 -3
- package/webpack-production-min.config.js +1 -1
- package/webpack-production.config.js +1 -1
- package/webpack.config.js +1 -1
- package/dist/pi.js.map +0 -1
- package/dist/pi.min.js +0 -2
- package/dist/pi.min.js.map +0 -1
- package/docs/classes/expressions_numexp.NumExp.html +0 -236
- package/docs/classes/expressions_polynomexp.PolynomExpFactor.html +0 -317
- package/docs/classes/expressions_polynomexp.PolynomExpProduct.html +0 -285
- package/docs/modules/expressions_numexp.html +0 -71
- package/docs/modules/expressions_polynomexp.html +0 -73
- package/docs/modules.html +0 -76
- package/graph.svg +0 -1033
- package/src/maths/expressions/ExpressionTree.ts +0 -172
- package/src/maths/expressions/expression.ts +0 -286
- package/src/maths/expressions/expressionFactor.ts +0 -190
- package/src/maths/expressions/expressionMember.ts +0 -233
- package/src/maths/expressions/expressionOperators.ts +0 -49
- package/src/maths/expressions/expressionParser.ts +0 -295
- package/src/maths/expressions/factors/ExpFactor.ts +0 -39
- package/src/maths/expressions/factors/ExpFactorConstant.ts +0 -60
- package/src/maths/expressions/factors/ExpFactorExponential.ts +0 -26
- package/src/maths/expressions/factors/ExpFactorNumber.ts +0 -72
- package/src/maths/expressions/factors/ExpFactorPower.ts +0 -42
- package/src/maths/expressions/factors/ExpFactorTrigo.ts +0 -53
- package/src/maths/expressions/factors/ExpFactorVariable.ts +0 -45
- package/src/maths/expressions/internals.ts +0 -14
- package/src/maths/expressions/polynomexp.bkp.ts +0 -221
- package/src/maths/expressions/polynomexp.ts +0 -310
- package/tests/expressions/expressions.test.ts +0 -145
- package/tests/expressions/expressiontree.test.ts +0 -11
- package/tests/polynomexp.test.ts +0 -12
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rational polynom module contains everything necessary to handle rational polynoms.
|
|
3
|
-
* @module Polynom
|
|
4
|
-
*/
|
|
5
|
-
import { IEuclidian, Polynom } from "./polynom";
|
|
6
|
-
import { Fraction } from "../coefficients/fraction";
|
|
7
|
-
import { literalType } from "./monom";
|
|
8
|
-
import { RationalStudy } from "./study/rationalStudy";
|
|
9
|
-
import { StudyConfig } from "./study";
|
|
10
|
-
/**
|
|
11
|
-
* Rational class can handle rational polynoms
|
|
12
|
-
*/
|
|
13
|
-
export declare class Rational {
|
|
14
|
-
private _denominator;
|
|
15
|
-
private _numerator;
|
|
16
|
-
private _rawString;
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
* @param numerator
|
|
20
|
-
* @param denominator
|
|
21
|
-
*/
|
|
22
|
-
constructor(numerator?: Polynom | string, denominator?: Polynom | string);
|
|
23
|
-
get numerator(): Polynom;
|
|
24
|
-
get denominator(): Polynom;
|
|
25
|
-
get tex(): string;
|
|
26
|
-
get texFactors(): string;
|
|
27
|
-
get plotFunction(): string;
|
|
28
|
-
clone: () => Rational;
|
|
29
|
-
domain: () => string;
|
|
30
|
-
amplify: (P: Polynom) => Rational;
|
|
31
|
-
derivative: (letter?: string) => Rational;
|
|
32
|
-
factorize: (letter?: string) => Rational;
|
|
33
|
-
simplify: (P: Polynom) => Rational;
|
|
34
|
-
reduce: () => Rational;
|
|
35
|
-
opposed: () => Rational;
|
|
36
|
-
add: (R: Rational) => Rational;
|
|
37
|
-
subtract: (R: Rational) => Rational;
|
|
38
|
-
euclidian: () => IEuclidian;
|
|
39
|
-
limits: (value: Fraction | number, offset?: string, letter?: string) => Fraction;
|
|
40
|
-
evaluate: (values: literalType | Fraction | number) => Fraction;
|
|
41
|
-
evaluateAsNumeric: (values: number | {
|
|
42
|
-
[Key: string]: number;
|
|
43
|
-
}) => number;
|
|
44
|
-
study: (config?: StudyConfig | string) => RationalStudy;
|
|
45
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Rational polynom module contains everything necessary to handle rational polynoms.
|
|
3
|
+
* @module Polynom
|
|
4
|
+
*/
|
|
5
|
+
import { IEuclidian, Polynom } from "./polynom";
|
|
6
|
+
import { Fraction } from "../coefficients/fraction";
|
|
7
|
+
import { literalType } from "./monom";
|
|
8
|
+
import { RationalStudy } from "./study/rationalStudy";
|
|
9
|
+
import { StudyConfig } from "./study";
|
|
10
|
+
/**
|
|
11
|
+
* Rational class can handle rational polynoms
|
|
12
|
+
*/
|
|
13
|
+
export declare class Rational {
|
|
14
|
+
private _denominator;
|
|
15
|
+
private _numerator;
|
|
16
|
+
private _rawString;
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param numerator
|
|
20
|
+
* @param denominator
|
|
21
|
+
*/
|
|
22
|
+
constructor(numerator?: Polynom | string, denominator?: Polynom | string);
|
|
23
|
+
get numerator(): Polynom;
|
|
24
|
+
get denominator(): Polynom;
|
|
25
|
+
get tex(): string;
|
|
26
|
+
get texFactors(): string;
|
|
27
|
+
get plotFunction(): string;
|
|
28
|
+
clone: () => Rational;
|
|
29
|
+
domain: () => string;
|
|
30
|
+
amplify: (P: Polynom) => Rational;
|
|
31
|
+
derivative: (letter?: string) => Rational;
|
|
32
|
+
factorize: (letter?: string) => Rational;
|
|
33
|
+
simplify: (P: Polynom) => Rational;
|
|
34
|
+
reduce: () => Rational;
|
|
35
|
+
opposed: () => Rational;
|
|
36
|
+
add: (R: Rational) => Rational;
|
|
37
|
+
subtract: (R: Rational) => Rational;
|
|
38
|
+
euclidian: () => IEuclidian;
|
|
39
|
+
limits: (value: Fraction | number, offset?: string, letter?: string) => Fraction;
|
|
40
|
+
evaluate: (values: literalType | Fraction | number) => Fraction;
|
|
41
|
+
evaluateAsNumeric: (values: number | {
|
|
42
|
+
[Key: string]: number;
|
|
43
|
+
}) => number;
|
|
44
|
+
study: (config?: StudyConfig | string) => RationalStudy;
|
|
45
|
+
}
|
|
@@ -1,184 +1,184 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Rational polynom module contains everything necessary to handle rational polynoms.
|
|
4
|
-
* @module Polynom
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.Rational = void 0;
|
|
8
|
-
const polynom_1 = require("./polynom");
|
|
9
|
-
const fraction_1 = require("../coefficients/fraction");
|
|
10
|
-
const equation_1 = require("./equation");
|
|
11
|
-
const rationalStudy_1 = require("./study/rationalStudy");
|
|
12
|
-
/**
|
|
13
|
-
* Rational class can handle rational polynoms
|
|
14
|
-
*/
|
|
15
|
-
class Rational {
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @param numerator
|
|
19
|
-
* @param denominator
|
|
20
|
-
*/
|
|
21
|
-
constructor(numerator, denominator) {
|
|
22
|
-
this.clone = () => {
|
|
23
|
-
return new Rational(this._numerator.clone(), this._denominator.clone());
|
|
24
|
-
};
|
|
25
|
-
this.domain = () => {
|
|
26
|
-
let zeroes = this._denominator.getZeroes();
|
|
27
|
-
if (zeroes.length === 0 || zeroes[0].tex === equation_1.PARTICULAR_SOLUTION.real) {
|
|
28
|
-
return equation_1.PARTICULAR_SOLUTION.varnothing;
|
|
29
|
-
}
|
|
30
|
-
else if (zeroes[0].tex === equation_1.PARTICULAR_SOLUTION.varnothing) {
|
|
31
|
-
return equation_1.PARTICULAR_SOLUTION.real;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
return '\\mathbb{R}\\setminus\\left\\{' +
|
|
35
|
-
zeroes.map(x => x.tex).join(';') + '\\right\\}';
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
this.amplify = (P) => {
|
|
39
|
-
this._numerator.multiply(P);
|
|
40
|
-
this._denominator.multiply(P);
|
|
41
|
-
return this;
|
|
42
|
-
};
|
|
43
|
-
this.derivative = (letter) => {
|
|
44
|
-
let N = this._numerator.clone(), D = this._denominator.clone(), dN = N.clone().derivative(letter), dD = D.clone().derivative(letter);
|
|
45
|
-
this._numerator = dN.clone().multiply(D).subtract(N.clone().multiply(dD));
|
|
46
|
-
this._denominator = D.clone().pow(2);
|
|
47
|
-
return this;
|
|
48
|
-
};
|
|
49
|
-
this.factorize = (letter) => {
|
|
50
|
-
this._numerator.factorize(letter);
|
|
51
|
-
this._denominator.factorize(letter);
|
|
52
|
-
return this;
|
|
53
|
-
};
|
|
54
|
-
this.simplify = (P) => {
|
|
55
|
-
let NumeratorEuclidien = this._numerator.euclidian(P);
|
|
56
|
-
if (!NumeratorEuclidien.reminder.isZero()) {
|
|
57
|
-
return this;
|
|
58
|
-
}
|
|
59
|
-
let DenominatorEuclidien = this._denominator.euclidian(P);
|
|
60
|
-
if (!DenominatorEuclidien.reminder.isZero()) {
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
this._numerator = NumeratorEuclidien.quotient;
|
|
64
|
-
this._denominator = DenominatorEuclidien.quotient;
|
|
65
|
-
return this;
|
|
66
|
-
};
|
|
67
|
-
this.reduce = () => {
|
|
68
|
-
this._numerator.factorize();
|
|
69
|
-
for (let f of this._numerator.factors) {
|
|
70
|
-
this.simplify(f);
|
|
71
|
-
}
|
|
72
|
-
return this;
|
|
73
|
-
};
|
|
74
|
-
this.opposed = () => {
|
|
75
|
-
this._numerator.opposed();
|
|
76
|
-
return this;
|
|
77
|
-
};
|
|
78
|
-
this.add = (R) => {
|
|
79
|
-
// 1. Make sure both rational are at the same denominator
|
|
80
|
-
// 2. Add the numerators.
|
|
81
|
-
// 3. Simplify
|
|
82
|
-
// Store the adding denominator
|
|
83
|
-
let denominator = this._denominator.clone();
|
|
84
|
-
// Amplif the main rational polynom by the adding denominator
|
|
85
|
-
this.amplify(R._denominator);
|
|
86
|
-
// Add to the numerator the adding value...
|
|
87
|
-
this._numerator.add(R._numerator.clone().multiply(denominator));
|
|
88
|
-
return this;
|
|
89
|
-
};
|
|
90
|
-
this.subtract = (R) => {
|
|
91
|
-
return this.add(R.clone().opposed());
|
|
92
|
-
};
|
|
93
|
-
this.euclidian = () => {
|
|
94
|
-
return this._numerator.euclidian(this._denominator);
|
|
95
|
-
};
|
|
96
|
-
// TODO : where and how is used limits ?
|
|
97
|
-
this.limits = (value, offset, letter) => {
|
|
98
|
-
if (value === Infinity || value === -Infinity) {
|
|
99
|
-
let { quotient, reminder } = this._numerator.clone().euclidian(this._denominator);
|
|
100
|
-
// quotient is positive => it will be infinite.
|
|
101
|
-
if (quotient.degree(letter).isStrictlyPositive()) {
|
|
102
|
-
return value === Infinity ? quotient.limitToInfinity(letter) : quotient.limitToNegativeInfinity(letter);
|
|
103
|
-
// return quotient.monomByDegree(undefined, letter).coefficient.sign()===1?(new Fraction()).infinite():(new Fraction()).infinite().opposed()
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
return quotient.monomByDegree(undefined, letter).coefficient;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
let evalValues = {}, evalValuesOffset = {}, theLimit, theSign, FR = this.clone().reduce();
|
|
111
|
-
evalValues[letter === undefined ? 'x' : letter] = new fraction_1.Fraction(value);
|
|
112
|
-
if (offset !== 'above' && offset !== 'below') {
|
|
113
|
-
theLimit = FR._numerator.evaluate(evalValues)
|
|
114
|
-
.divide(FR._denominator.evaluate(evalValues));
|
|
115
|
-
return theLimit.isInfinity() ? theLimit.abs() : theLimit;
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
if (offset === 'above') {
|
|
119
|
-
evalValuesOffset[letter === undefined ? 'x' : letter] = (new fraction_1.Fraction(value)).add(0.000001);
|
|
120
|
-
}
|
|
121
|
-
else if (offset === 'below') {
|
|
122
|
-
evalValuesOffset[letter === undefined ? 'x' : letter] = (new fraction_1.Fraction(value)).subtract(0.000001);
|
|
123
|
-
}
|
|
124
|
-
theLimit = FR._numerator.evaluate(evalValues)
|
|
125
|
-
.divide(FR._denominator.evaluate(evalValues));
|
|
126
|
-
theSign = FR._numerator.evaluate(evalValuesOffset)
|
|
127
|
-
.divide(FR._denominator.evaluate(evalValuesOffset)).sign();
|
|
128
|
-
if (theLimit.isInfinity()) {
|
|
129
|
-
return theSign === 1 ? theLimit.abs() : theLimit.abs().opposed();
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
return theLimit;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
this.evaluate = (values) => {
|
|
138
|
-
const r = new fraction_1.Fraction().zero();
|
|
139
|
-
let N = this._numerator.evaluate(values), D = this._denominator.evaluate(values);
|
|
140
|
-
return N.divide(D);
|
|
141
|
-
};
|
|
142
|
-
this.evaluateAsNumeric = (values) => {
|
|
143
|
-
return this._numerator.evaluateAsNumeric(values) / this._denominator.evaluateAsNumeric(values);
|
|
144
|
-
};
|
|
145
|
-
this.study = (config) => {
|
|
146
|
-
return new rationalStudy_1.RationalStudy(this, config);
|
|
147
|
-
};
|
|
148
|
-
if (numerator instanceof polynom_1.Polynom) {
|
|
149
|
-
this._numerator = numerator.clone();
|
|
150
|
-
}
|
|
151
|
-
else if (typeof numerator === 'string') {
|
|
152
|
-
this._numerator = new polynom_1.Polynom(numerator);
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
this._numerator = new polynom_1.Polynom();
|
|
156
|
-
}
|
|
157
|
-
if (denominator instanceof polynom_1.Polynom) {
|
|
158
|
-
this._denominator = denominator.clone();
|
|
159
|
-
}
|
|
160
|
-
else if (typeof denominator === 'string') {
|
|
161
|
-
this._denominator = new polynom_1.Polynom(denominator);
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
this._denominator = new polynom_1.Polynom();
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
get numerator() {
|
|
168
|
-
return this._numerator;
|
|
169
|
-
}
|
|
170
|
-
get denominator() {
|
|
171
|
-
return this._denominator;
|
|
172
|
-
}
|
|
173
|
-
get tex() {
|
|
174
|
-
return `\\frac{ ${this._numerator.tex} }{ ${this._denominator.tex} }`;
|
|
175
|
-
}
|
|
176
|
-
get texFactors() {
|
|
177
|
-
return `\\frac{ ${this._numerator.texFactors} }{ ${this._denominator.texFactors} }`;
|
|
178
|
-
}
|
|
179
|
-
get plotFunction() {
|
|
180
|
-
return `(${this._numerator.plotFunction})/(${this._denominator.plotFunction})`;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
exports.Rational = Rational;
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Rational polynom module contains everything necessary to handle rational polynoms.
|
|
4
|
+
* @module Polynom
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.Rational = void 0;
|
|
8
|
+
const polynom_1 = require("./polynom");
|
|
9
|
+
const fraction_1 = require("../coefficients/fraction");
|
|
10
|
+
const equation_1 = require("./equation");
|
|
11
|
+
const rationalStudy_1 = require("./study/rationalStudy");
|
|
12
|
+
/**
|
|
13
|
+
* Rational class can handle rational polynoms
|
|
14
|
+
*/
|
|
15
|
+
class Rational {
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param numerator
|
|
19
|
+
* @param denominator
|
|
20
|
+
*/
|
|
21
|
+
constructor(numerator, denominator) {
|
|
22
|
+
this.clone = () => {
|
|
23
|
+
return new Rational(this._numerator.clone(), this._denominator.clone());
|
|
24
|
+
};
|
|
25
|
+
this.domain = () => {
|
|
26
|
+
let zeroes = this._denominator.getZeroes();
|
|
27
|
+
if (zeroes.length === 0 || zeroes[0].tex === equation_1.PARTICULAR_SOLUTION.real) {
|
|
28
|
+
return equation_1.PARTICULAR_SOLUTION.varnothing;
|
|
29
|
+
}
|
|
30
|
+
else if (zeroes[0].tex === equation_1.PARTICULAR_SOLUTION.varnothing) {
|
|
31
|
+
return equation_1.PARTICULAR_SOLUTION.real;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return '\\mathbb{R}\\setminus\\left\\{' +
|
|
35
|
+
zeroes.map(x => x.tex).join(';') + '\\right\\}';
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
this.amplify = (P) => {
|
|
39
|
+
this._numerator.multiply(P);
|
|
40
|
+
this._denominator.multiply(P);
|
|
41
|
+
return this;
|
|
42
|
+
};
|
|
43
|
+
this.derivative = (letter) => {
|
|
44
|
+
let N = this._numerator.clone(), D = this._denominator.clone(), dN = N.clone().derivative(letter), dD = D.clone().derivative(letter);
|
|
45
|
+
this._numerator = dN.clone().multiply(D).subtract(N.clone().multiply(dD));
|
|
46
|
+
this._denominator = D.clone().pow(2);
|
|
47
|
+
return this;
|
|
48
|
+
};
|
|
49
|
+
this.factorize = (letter) => {
|
|
50
|
+
this._numerator.factorize(letter);
|
|
51
|
+
this._denominator.factorize(letter);
|
|
52
|
+
return this;
|
|
53
|
+
};
|
|
54
|
+
this.simplify = (P) => {
|
|
55
|
+
let NumeratorEuclidien = this._numerator.euclidian(P);
|
|
56
|
+
if (!NumeratorEuclidien.reminder.isZero()) {
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
let DenominatorEuclidien = this._denominator.euclidian(P);
|
|
60
|
+
if (!DenominatorEuclidien.reminder.isZero()) {
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
this._numerator = NumeratorEuclidien.quotient;
|
|
64
|
+
this._denominator = DenominatorEuclidien.quotient;
|
|
65
|
+
return this;
|
|
66
|
+
};
|
|
67
|
+
this.reduce = () => {
|
|
68
|
+
this._numerator.factorize();
|
|
69
|
+
for (let f of this._numerator.factors) {
|
|
70
|
+
this.simplify(f);
|
|
71
|
+
}
|
|
72
|
+
return this;
|
|
73
|
+
};
|
|
74
|
+
this.opposed = () => {
|
|
75
|
+
this._numerator.opposed();
|
|
76
|
+
return this;
|
|
77
|
+
};
|
|
78
|
+
this.add = (R) => {
|
|
79
|
+
// 1. Make sure both rational are at the same denominator
|
|
80
|
+
// 2. Add the numerators.
|
|
81
|
+
// 3. Simplify
|
|
82
|
+
// Store the adding denominator
|
|
83
|
+
let denominator = this._denominator.clone();
|
|
84
|
+
// Amplif the main rational polynom by the adding denominator
|
|
85
|
+
this.amplify(R._denominator);
|
|
86
|
+
// Add to the numerator the adding value...
|
|
87
|
+
this._numerator.add(R._numerator.clone().multiply(denominator));
|
|
88
|
+
return this;
|
|
89
|
+
};
|
|
90
|
+
this.subtract = (R) => {
|
|
91
|
+
return this.add(R.clone().opposed());
|
|
92
|
+
};
|
|
93
|
+
this.euclidian = () => {
|
|
94
|
+
return this._numerator.euclidian(this._denominator);
|
|
95
|
+
};
|
|
96
|
+
// TODO : where and how is used limits ?
|
|
97
|
+
this.limits = (value, offset, letter) => {
|
|
98
|
+
if (value === Infinity || value === -Infinity) {
|
|
99
|
+
let { quotient, reminder } = this._numerator.clone().euclidian(this._denominator);
|
|
100
|
+
// quotient is positive => it will be infinite.
|
|
101
|
+
if (quotient.degree(letter).isStrictlyPositive()) {
|
|
102
|
+
return value === Infinity ? quotient.limitToInfinity(letter) : quotient.limitToNegativeInfinity(letter);
|
|
103
|
+
// return quotient.monomByDegree(undefined, letter).coefficient.sign()===1?(new Fraction()).infinite():(new Fraction()).infinite().opposed()
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
return quotient.monomByDegree(undefined, letter).coefficient;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
let evalValues = {}, evalValuesOffset = {}, theLimit, theSign, FR = this.clone().reduce();
|
|
111
|
+
evalValues[letter === undefined ? 'x' : letter] = new fraction_1.Fraction(value);
|
|
112
|
+
if (offset !== 'above' && offset !== 'below') {
|
|
113
|
+
theLimit = FR._numerator.evaluate(evalValues)
|
|
114
|
+
.divide(FR._denominator.evaluate(evalValues));
|
|
115
|
+
return theLimit.isInfinity() ? theLimit.abs() : theLimit;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
if (offset === 'above') {
|
|
119
|
+
evalValuesOffset[letter === undefined ? 'x' : letter] = (new fraction_1.Fraction(value)).add(0.000001);
|
|
120
|
+
}
|
|
121
|
+
else if (offset === 'below') {
|
|
122
|
+
evalValuesOffset[letter === undefined ? 'x' : letter] = (new fraction_1.Fraction(value)).subtract(0.000001);
|
|
123
|
+
}
|
|
124
|
+
theLimit = FR._numerator.evaluate(evalValues)
|
|
125
|
+
.divide(FR._denominator.evaluate(evalValues));
|
|
126
|
+
theSign = FR._numerator.evaluate(evalValuesOffset)
|
|
127
|
+
.divide(FR._denominator.evaluate(evalValuesOffset)).sign();
|
|
128
|
+
if (theLimit.isInfinity()) {
|
|
129
|
+
return theSign === 1 ? theLimit.abs() : theLimit.abs().opposed();
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
return theLimit;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
this.evaluate = (values) => {
|
|
138
|
+
const r = new fraction_1.Fraction().zero();
|
|
139
|
+
let N = this._numerator.evaluate(values), D = this._denominator.evaluate(values);
|
|
140
|
+
return N.divide(D);
|
|
141
|
+
};
|
|
142
|
+
this.evaluateAsNumeric = (values) => {
|
|
143
|
+
return this._numerator.evaluateAsNumeric(values) / this._denominator.evaluateAsNumeric(values);
|
|
144
|
+
};
|
|
145
|
+
this.study = (config) => {
|
|
146
|
+
return new rationalStudy_1.RationalStudy(this, config);
|
|
147
|
+
};
|
|
148
|
+
if (numerator instanceof polynom_1.Polynom) {
|
|
149
|
+
this._numerator = numerator.clone();
|
|
150
|
+
}
|
|
151
|
+
else if (typeof numerator === 'string') {
|
|
152
|
+
this._numerator = new polynom_1.Polynom(numerator);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
this._numerator = new polynom_1.Polynom();
|
|
156
|
+
}
|
|
157
|
+
if (denominator instanceof polynom_1.Polynom) {
|
|
158
|
+
this._denominator = denominator.clone();
|
|
159
|
+
}
|
|
160
|
+
else if (typeof denominator === 'string') {
|
|
161
|
+
this._denominator = new polynom_1.Polynom(denominator);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
this._denominator = new polynom_1.Polynom();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
get numerator() {
|
|
168
|
+
return this._numerator;
|
|
169
|
+
}
|
|
170
|
+
get denominator() {
|
|
171
|
+
return this._denominator;
|
|
172
|
+
}
|
|
173
|
+
get tex() {
|
|
174
|
+
return `\\frac{ ${this._numerator.tex} }{ ${this._denominator.tex} }`;
|
|
175
|
+
}
|
|
176
|
+
get texFactors() {
|
|
177
|
+
return `\\frac{ ${this._numerator.texFactors} }{ ${this._denominator.texFactors} }`;
|
|
178
|
+
}
|
|
179
|
+
get plotFunction() {
|
|
180
|
+
return `(${this._numerator.plotFunction})/(${this._denominator.plotFunction})`;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.Rational = Rational;
|
|
184
184
|
//# sourceMappingURL=rational.js.map
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The study class is a "function study" class that will get:
|
|
3
|
-
* fx : get the function
|
|
4
|
-
* domain : string
|
|
5
|
-
* zeroes : Object (tex, IZero)
|
|
6
|
-
* signs : table of signs + tex output using tkz-tab
|
|
7
|
-
* av : vertical asymptotic
|
|
8
|
-
* ah : horizontal asymptotic
|
|
9
|
-
* ao : obliques
|
|
10
|
-
* deltaX : position relative
|
|
11
|
-
* dx : derivative
|
|
12
|
-
* grows : growing table + tex output using tkz-tab
|
|
13
|
-
* ddx : dérivée seconde
|
|
14
|
-
* variations : variation table + tex output using tkz-tab
|
|
15
|
-
*/
|
|
16
|
-
import { ASYMPTOTE_POSITION, IAsymptote, ITableOfSigns, IZero, Study, StudyableFunction, StudyConfig } from "../study";
|
|
17
|
-
import { Rational } from "../rational";
|
|
18
|
-
export declare class RationalStudy extends Study {
|
|
19
|
-
constructor(fx: StudyableFunction, config?: StudyConfig | string);
|
|
20
|
-
makeZeroes(): IZero[];
|
|
21
|
-
makeSigns(): ITableOfSigns;
|
|
22
|
-
makeAsymptotes(): IAsymptote[];
|
|
23
|
-
_getHorizontalAsymptoteRelativePositon(deltaX: Rational, delta?: number): ASYMPTOTE_POSITION[];
|
|
24
|
-
makeDerivative(): ITableOfSigns;
|
|
25
|
-
makeVariation(): ITableOfSigns;
|
|
26
|
-
private _getZeroes;
|
|
27
|
-
private _getSigns;
|
|
28
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* The study class is a "function study" class that will get:
|
|
3
|
+
* fx : get the function
|
|
4
|
+
* domain : string
|
|
5
|
+
* zeroes : Object (tex, IZero)
|
|
6
|
+
* signs : table of signs + tex output using tkz-tab
|
|
7
|
+
* av : vertical asymptotic
|
|
8
|
+
* ah : horizontal asymptotic
|
|
9
|
+
* ao : obliques
|
|
10
|
+
* deltaX : position relative
|
|
11
|
+
* dx : derivative
|
|
12
|
+
* grows : growing table + tex output using tkz-tab
|
|
13
|
+
* ddx : dérivée seconde
|
|
14
|
+
* variations : variation table + tex output using tkz-tab
|
|
15
|
+
*/
|
|
16
|
+
import { ASYMPTOTE_POSITION, IAsymptote, ITableOfSigns, IZero, Study, StudyableFunction, StudyConfig } from "../study";
|
|
17
|
+
import { Rational } from "../rational";
|
|
18
|
+
export declare class RationalStudy extends Study {
|
|
19
|
+
constructor(fx: StudyableFunction, config?: StudyConfig | string);
|
|
20
|
+
makeZeroes(): IZero[];
|
|
21
|
+
makeSigns(): ITableOfSigns;
|
|
22
|
+
makeAsymptotes(): IAsymptote[];
|
|
23
|
+
_getHorizontalAsymptoteRelativePositon(deltaX: Rational, delta?: number): ASYMPTOTE_POSITION[];
|
|
24
|
+
makeDerivative(): ITableOfSigns;
|
|
25
|
+
makeVariation(): ITableOfSigns;
|
|
26
|
+
private _getZeroes;
|
|
27
|
+
private _getSigns;
|
|
28
|
+
}
|