pimath 0.0.120 → 0.0.121

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.
Files changed (171) hide show
  1. package/.eslintrc.js +23 -23
  2. package/.idea/PI.iml +7 -1
  3. package/dev/pimath.js +7929 -0
  4. package/dev/pimath.js.map +1 -0
  5. package/dist/{pi.js → pimath.js} +7612 -7840
  6. package/dist/pimath.js.map +1 -0
  7. package/dist/pimath.min.js +2 -0
  8. package/dist/pimath.min.js.map +1 -0
  9. package/docs/assets/main.js +3 -3
  10. package/docs/assets/search.js +1 -1
  11. package/docs/assets/style.css +450 -363
  12. package/docs/classes/Logicalset.Logicalset.html +119 -110
  13. package/docs/classes/Polynom.Rational.html +230 -227
  14. package/docs/classes/Vector-1.Vector.html +319 -273
  15. package/docs/classes/Vector.Point.html +189 -190
  16. package/docs/classes/algebra_equation.Equation.html +489 -446
  17. package/docs/classes/algebra_linearSystem.LinearSystem.html +228 -217
  18. package/docs/classes/algebra_monom.Monom.html +564 -507
  19. package/docs/classes/algebra_polynom.Polynom.html +774 -753
  20. package/docs/classes/coefficients_fraction.Fraction.html +573 -565
  21. package/docs/classes/geometry_circle.Circle.html +299 -299
  22. package/docs/classes/geometry_line.Line.html +511 -451
  23. package/docs/classes/geometry_triangle.Triangle.html +273 -264
  24. package/docs/classes/numeric.Numeric.html +138 -132
  25. package/docs/classes/shutingyard.Shutingyard.html +144 -133
  26. package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +47 -46
  27. package/docs/enums/geometry_line.LinePropriety.html +58 -58
  28. package/docs/enums/shutingyard.ShutingyardMode.html +62 -58
  29. package/docs/enums/shutingyard.ShutingyardType.html +74 -70
  30. package/docs/index.html +31 -33
  31. package/docs/interfaces/algebra_equation.ISolution.html +61 -59
  32. package/docs/interfaces/algebra_polynom.IEuclidian.html +47 -46
  33. package/docs/interfaces/geometry_triangle.remarquableLines.html +74 -74
  34. package/docs/modules/Logicalset.html +33 -38
  35. package/docs/modules/Polynom.html +33 -38
  36. package/docs/modules/Vector-1.html +33 -38
  37. package/docs/modules/Vector.html +33 -38
  38. package/docs/modules/algebra_equation.html +35 -41
  39. package/docs/modules/algebra_linearSystem.html +31 -37
  40. package/docs/modules/algebra_monom.html +33 -39
  41. package/docs/modules/algebra_polynom.html +35 -41
  42. package/docs/modules/coefficients_fraction.html +33 -39
  43. package/docs/modules/geometry_circle.html +31 -37
  44. package/docs/modules/geometry_line.html +33 -39
  45. package/docs/modules/geometry_triangle.html +33 -39
  46. package/docs/modules/numeric.html +31 -37
  47. package/docs/modules/shutingyard.html +41 -47
  48. package/docs/types/algebra_monom.literalType.html +33 -37
  49. package/docs/types/algebra_polynom.PolynomParsingType.html +33 -37
  50. package/docs/types/coefficients_fraction.FractionParsingType.html +32 -36
  51. package/docs/types/shutingyard.Token.html +38 -42
  52. package/docs/types/shutingyard.tokenType.html +40 -44
  53. package/docs/variables/shutingyard.tokenConstant.html +37 -41
  54. package/esm/index.d.ts +38 -41
  55. package/esm/index.js +43 -46
  56. package/esm/index.js.map +1 -1
  57. package/esm/maths/algebra/equation.d.ts +119 -117
  58. package/esm/maths/algebra/equation.js +796 -785
  59. package/esm/maths/algebra/equation.js.map +1 -1
  60. package/esm/maths/algebra/linearSystem.d.ts +39 -38
  61. package/esm/maths/algebra/linearSystem.js +278 -262
  62. package/esm/maths/algebra/linearSystem.js.map +1 -1
  63. package/esm/maths/algebra/logicalset.d.ts +28 -28
  64. package/esm/maths/algebra/logicalset.js +157 -157
  65. package/esm/maths/algebra/monom.d.ts +206 -206
  66. package/esm/maths/algebra/monom.js +908 -908
  67. package/esm/maths/algebra/monom.js.map +1 -1
  68. package/esm/maths/algebra/polynom.d.ts +157 -157
  69. package/esm/maths/algebra/polynom.js +1277 -1277
  70. package/esm/maths/algebra/rational.d.ts +45 -45
  71. package/esm/maths/algebra/rational.js +183 -183
  72. package/esm/maths/algebra/study/rationalStudy.d.ts +28 -28
  73. package/esm/maths/algebra/study/rationalStudy.js +243 -243
  74. package/esm/maths/algebra/study.d.ts +142 -142
  75. package/esm/maths/algebra/study.js +377 -377
  76. package/esm/maths/algebra/study.js.map +1 -1
  77. package/esm/maths/coefficients/fraction.d.ts +90 -90
  78. package/esm/maths/coefficients/fraction.js +516 -516
  79. package/esm/maths/coefficients/fraction.js.map +1 -1
  80. package/esm/maths/coefficients/nthRoot.d.ts +23 -23
  81. package/esm/maths/coefficients/nthRoot.js +136 -136
  82. package/esm/maths/geometry/circle.d.ts +45 -45
  83. package/esm/maths/geometry/circle.js +323 -323
  84. package/esm/maths/geometry/line.d.ts +99 -99
  85. package/esm/maths/geometry/line.js +481 -481
  86. package/esm/maths/geometry/line.js.map +1 -1
  87. package/esm/maths/geometry/point.d.ts +34 -34
  88. package/esm/maths/geometry/point.js +166 -166
  89. package/esm/maths/geometry/point.js.map +1 -1
  90. package/esm/maths/geometry/triangle.d.ts +85 -85
  91. package/esm/maths/geometry/triangle.js +268 -268
  92. package/esm/maths/geometry/vector.d.ts +41 -41
  93. package/esm/maths/geometry/vector.js +197 -197
  94. package/esm/maths/geometry/vector.js.map +1 -1
  95. package/esm/maths/numeric.d.ts +28 -28
  96. package/esm/maths/numeric.js +180 -180
  97. package/esm/maths/numexp.d.ts +19 -0
  98. package/esm/maths/numexp.js +186 -0
  99. package/esm/maths/numexp.js.map +1 -0
  100. package/esm/maths/randomization/random.d.ts +23 -23
  101. package/esm/maths/randomization/random.js +78 -78
  102. package/esm/maths/randomization/random.js.map +1 -1
  103. package/esm/maths/randomization/randomCore.d.ts +7 -7
  104. package/esm/maths/randomization/randomCore.js +21 -21
  105. package/esm/maths/randomization/rndFraction.d.ts +12 -12
  106. package/esm/maths/randomization/rndFraction.js +43 -43
  107. package/esm/maths/randomization/rndGeometryLine.d.ts +12 -12
  108. package/esm/maths/randomization/rndGeometryLine.js +45 -45
  109. package/esm/maths/randomization/rndGeometryPoint.d.ts +12 -12
  110. package/esm/maths/randomization/rndGeometryPoint.js +60 -60
  111. package/esm/maths/randomization/rndHelpers.d.ts +23 -23
  112. package/esm/maths/randomization/rndHelpers.js +76 -76
  113. package/esm/maths/randomization/rndMonom.d.ts +12 -12
  114. package/esm/maths/randomization/rndMonom.js +52 -52
  115. package/esm/maths/randomization/rndPolynom.d.ts +13 -13
  116. package/esm/maths/randomization/rndPolynom.js +74 -74
  117. package/esm/maths/randomization/rndTypes.d.ts +34 -34
  118. package/esm/maths/randomization/rndTypes.js +2 -2
  119. package/esm/maths/shutingyard.d.ts +59 -59
  120. package/esm/maths/shutingyard.js +442 -442
  121. package/esm/maths/shutingyard.js.map +1 -1
  122. package/package.json +11 -11
  123. package/public/index.html +50 -81
  124. package/public/playground.html +7 -8
  125. package/src/index.ts +2 -5
  126. package/src/maths/algebra/equation.ts +16 -0
  127. package/src/maths/algebra/linearSystem.ts +20 -0
  128. package/src/maths/algebra/study.ts +1 -1
  129. package/src/maths/{expressions/numexp.ts → numexp.ts} +2 -2
  130. package/tests/algebra/equation.test.ts +19 -5
  131. package/tests/algebra/linear.test.ts +3 -11
  132. package/tests/algebra/polynom.test.ts +7 -8
  133. package/tests/algebra/rationnal.test.ts +1 -1
  134. package/tests/algebra/study.test.ts +2 -9
  135. package/tests/coefficients/fraction.test.ts +8 -8
  136. package/tests/custom.test.ts +33 -37
  137. package/tests/numeric.test.ts +1 -2
  138. package/tests/numexp.test.ts +1 -5
  139. package/tests/shutingyard.test.ts +3 -3
  140. package/webpack-production-min.config.js +1 -1
  141. package/webpack-production.config.js +1 -1
  142. package/webpack.config.js +1 -1
  143. package/dist/pi.js.map +0 -1
  144. package/dist/pi.min.js +0 -2
  145. package/dist/pi.min.js.map +0 -1
  146. package/docs/classes/expressions_numexp.NumExp.html +0 -236
  147. package/docs/classes/expressions_polynomexp.PolynomExpFactor.html +0 -317
  148. package/docs/classes/expressions_polynomexp.PolynomExpProduct.html +0 -285
  149. package/docs/modules/expressions_numexp.html +0 -71
  150. package/docs/modules/expressions_polynomexp.html +0 -73
  151. package/docs/modules.html +0 -76
  152. package/graph.svg +0 -1033
  153. package/src/maths/expressions/ExpressionTree.ts +0 -172
  154. package/src/maths/expressions/expression.ts +0 -286
  155. package/src/maths/expressions/expressionFactor.ts +0 -190
  156. package/src/maths/expressions/expressionMember.ts +0 -233
  157. package/src/maths/expressions/expressionOperators.ts +0 -49
  158. package/src/maths/expressions/expressionParser.ts +0 -295
  159. package/src/maths/expressions/factors/ExpFactor.ts +0 -39
  160. package/src/maths/expressions/factors/ExpFactorConstant.ts +0 -60
  161. package/src/maths/expressions/factors/ExpFactorExponential.ts +0 -26
  162. package/src/maths/expressions/factors/ExpFactorNumber.ts +0 -72
  163. package/src/maths/expressions/factors/ExpFactorPower.ts +0 -42
  164. package/src/maths/expressions/factors/ExpFactorTrigo.ts +0 -53
  165. package/src/maths/expressions/factors/ExpFactorVariable.ts +0 -45
  166. package/src/maths/expressions/internals.ts +0 -14
  167. package/src/maths/expressions/polynomexp.bkp.ts +0 -221
  168. package/src/maths/expressions/polynomexp.ts +0 -310
  169. package/tests/expressions/expressions.test.ts +0 -145
  170. package/tests/expressions/expressiontree.test.ts +0 -11
  171. package/tests/polynomexp.test.ts +0 -12
@@ -1,244 +1,244 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RationalStudy = void 0;
4
- /**
5
- * The study class is a "function study" class that will get:
6
- * fx : get the function
7
- * domain : string
8
- * zeroes : Object (tex, IZero)
9
- * signs : table of signs + tex output using tkz-tab
10
- * av : vertical asymptotic
11
- * ah : horizontal asymptotic
12
- * ao : obliques
13
- * deltaX : position relative
14
- * dx : derivative
15
- * grows : growing table + tex output using tkz-tab
16
- * ddx : dérivée seconde
17
- * variations : variation table + tex output using tkz-tab
18
- */
19
- const study_1 = require("../study");
20
- const rational_1 = require("../rational");
21
- const fraction_1 = require("../../coefficients/fraction");
22
- const polynom_1 = require("../polynom");
23
- class RationalStudy extends study_1.Study {
24
- constructor(fx, config) {
25
- super(fx, config);
26
- return this;
27
- }
28
- makeZeroes() {
29
- return this._getZeroes(this.fx);
30
- }
31
- ;
32
- makeSigns() {
33
- return this._getSigns(this.fx, this.zeroes);
34
- }
35
- ;
36
- makeAsymptotes() {
37
- const reduced = this.fx.clone().reduce();
38
- // Vertical
39
- let asymptotes = [];
40
- this.zeroes.filter(x => x.type === study_1.ZEROTYPE.DEFENCE).forEach(zero => {
41
- // Check if it's a hole or an asymptote
42
- let Ztype = study_1.ASYMPTOTE.VERTICAL, tex = `x=${zero.tex}`, display = `x=${zero.display}`;
43
- // Check if it's a hole: the reduced polynom should not be null
44
- if (zero.exact instanceof fraction_1.Fraction) {
45
- if (reduced.denominator.evaluate(zero.exact).isNotZero()) {
46
- Ztype = study_1.ASYMPTOTE.HOLE;
47
- tex = `(${zero.tex};${reduced.evaluate(zero.exact).tex})`;
48
- display = `(${zero.display};${reduced.evaluate(zero.exact).display})`;
49
- }
50
- }
51
- else {
52
- if (reduced.denominator.evaluate(zero.value).isNotZero()) {
53
- Ztype = study_1.ASYMPTOTE.HOLE;
54
- tex = `(${zero.tex};${reduced.evaluate(zero.value).tex})`;
55
- display = `(${zero.display};${reduced.evaluate(zero.value).display})`;
56
- }
57
- }
58
- // Get the position before and after the asymptote.
59
- const delta = 0.000001;
60
- let before = this.fx.evaluateAsNumeric(zero.value - delta), after = this.fx.evaluateAsNumeric(zero.value + delta), position = [], pm = "";
61
- if (after < -10000) {
62
- position.push(study_1.ASYMPTOTE_POSITION.RB);
63
- pm += "m";
64
- }
65
- else if (after > 10000) {
66
- position.push(study_1.ASYMPTOTE_POSITION.RT);
67
- pm += "p";
68
- }
69
- if (before < -10000) {
70
- position.push(study_1.ASYMPTOTE_POSITION.LB);
71
- pm += "m";
72
- }
73
- else if (before > 10000) {
74
- position.push(study_1.ASYMPTOTE_POSITION.LT);
75
- pm += "p";
76
- }
77
- // Left and right are to infinity
78
- // TODO: handle the case were one side of the asymptote isn't infinity (not possible in rational study?!)
79
- if (pm === "pp") {
80
- pm = "+";
81
- }
82
- else if (pm === "mm") {
83
- pm = "-";
84
- }
85
- else {
86
- pm = `\\${pm}`;
87
- }
88
- asymptotes.push({
89
- fx: null,
90
- type: Ztype,
91
- tex,
92
- display,
93
- zero: zero,
94
- limits: `\\lim_{x\\to${zero.tex} }\\ f(x) = ${pm}\\infty`,
95
- deltaX: null,
96
- tableOfSign: null,
97
- position
98
- });
99
- });
100
- // Sloped asymptote
101
- let NDegree = this.fx.numerator.degree(), DDegree = this.fx.denominator.degree();
102
- if (NDegree.isEqual(DDegree)) {
103
- let H = this.fx.numerator.monomByDegree().coefficient.clone().divide(this.fx.denominator.monomByDegree().coefficient), Htex = H.tex;
104
- let { reminder } = reduced.euclidian(), deltaX = new rational_1.Rational(reminder, reduced.denominator);
105
- // Determine the position above or below on the left / right of the asymptote.
106
- asymptotes.push({
107
- fx: new polynom_1.Polynom(H),
108
- type: study_1.ASYMPTOTE.HORIZONTAL,
109
- tex: `y=${Htex}`,
110
- display: `y=${H.display}`,
111
- zero: null,
112
- limits: `\\lim_{x\\to\\infty}\\ f(x) = ${Htex}`,
113
- deltaX,
114
- tableOfSign: this._getSigns(deltaX),
115
- position: this._getHorizontalAsymptoteRelativePositon(deltaX)
116
- });
117
- }
118
- else if (DDegree.greater(NDegree)) {
119
- asymptotes.push({
120
- fx: new polynom_1.Polynom('0'),
121
- type: study_1.ASYMPTOTE.HORIZONTAL,
122
- tex: `y=0`,
123
- display: `y=0`,
124
- zero: null,
125
- limits: `\\lim_{x\\to\\infty}\\ f(x) = ${0}`,
126
- deltaX: null,
127
- tableOfSign: null,
128
- position: this._getHorizontalAsymptoteRelativePositon(this.fx)
129
- });
130
- }
131
- else if (NDegree.value - 1 === DDegree.value) {
132
- // Calculate the slope
133
- let { quotient, reminder } = reduced.euclidian(), deltaX = new rational_1.Rational(reminder, reduced.denominator);
134
- asymptotes.push({
135
- fx: quotient.clone(),
136
- type: study_1.ASYMPTOTE.SLOPE,
137
- tex: `y=${quotient.tex}`,
138
- display: `y=${quotient.display}`,
139
- zero: null,
140
- limits: ``,
141
- deltaX: new rational_1.Rational(reminder, reduced.denominator),
142
- tableOfSign: this._getSigns(deltaX),
143
- position: this._getHorizontalAsymptoteRelativePositon(deltaX)
144
- });
145
- }
146
- return asymptotes;
147
- }
148
- ;
149
- _getHorizontalAsymptoteRelativePositon(deltaX, delta = 1000000) {
150
- let position = [], before = deltaX.evaluateAsNumeric(-delta), after = deltaX.evaluateAsNumeric(delta);
151
- if (before >= 0) {
152
- position.push(study_1.ASYMPTOTE_POSITION.LT);
153
- }
154
- else {
155
- position.push(study_1.ASYMPTOTE_POSITION.LB);
156
- }
157
- if (after >= 0) {
158
- position.push(study_1.ASYMPTOTE_POSITION.RT);
159
- }
160
- else {
161
- position.push(study_1.ASYMPTOTE_POSITION.RB);
162
- }
163
- return position;
164
- }
165
- makeDerivative() {
166
- let dx = this.fx.clone().derivative(), tos = this._getSigns(dx, this._getZeroes(dx), study_1.TABLE_OF_SIGNS.GROWS);
167
- let result = this.makeGrowsResult(tos);
168
- tos.signs.push(result.growsLine);
169
- tos.extremes = result.extremes;
170
- return tos;
171
- }
172
- ;
173
- makeVariation() {
174
- // Get the zeroes, make signs.
175
- let dx = this.derivative.fx.clone().derivative(), tos = this._getSigns(dx, this._getZeroes(dx), study_1.TABLE_OF_SIGNS.VARIATIONS);
176
- let result = this.makeVariationsResult(tos);
177
- tos.signs.push(result.varsLine);
178
- tos.extremes = result.extremes;
179
- return tos;
180
- }
181
- ;
182
- _getZeroes(fx) {
183
- // All zeroes.
184
- let zeroes = [];
185
- fx.numerator.getZeroes().filter(x => !isNaN(x.value)).forEach(z => {
186
- // add the item
187
- zeroes.push({
188
- tex: z.tex,
189
- display: z.display,
190
- value: z.value,
191
- exact: z.exact,
192
- extrema: study_1.FUNCTION_EXTREMA.NOTHING,
193
- type: study_1.ZEROTYPE.ZERO
194
- });
195
- });
196
- fx.denominator.getZeroes().filter(x => !isNaN(x.value)).forEach(z => {
197
- let idx = this.indexOfZero(zeroes, z);
198
- if (idx !== -1) {
199
- zeroes[idx].type = study_1.ZEROTYPE.DEFENCE;
200
- }
201
- else {
202
- // Add the item
203
- zeroes.push({
204
- tex: z.tex,
205
- display: z.display,
206
- value: z.value,
207
- exact: z.exact,
208
- extrema: study_1.FUNCTION_EXTREMA.NOTHING,
209
- type: study_1.ZEROTYPE.DEFENCE
210
- });
211
- }
212
- });
213
- // sort all zeroes
214
- zeroes.sort((a, b) => a.value - b.value);
215
- return zeroes;
216
- }
217
- _getSigns(fx, zeroes, typeOfTable) {
218
- // Factorize the rational
219
- let signs = [], factors = [];
220
- if (zeroes === undefined) {
221
- zeroes = this._getZeroes(fx);
222
- }
223
- fx.numerator.factors.forEach(factor => {
224
- signs.push(this.makeOneLineForSigns(factor, zeroes, study_1.ZEROTYPE.ZERO));
225
- factors.push(factor.clone());
226
- });
227
- fx.denominator.factors.forEach(factor => {
228
- signs.push(this.makeOneLineForSigns(factor, zeroes, study_1.ZEROTYPE.DEFENCE));
229
- factors.push(factor.clone());
230
- });
231
- signs.push(this.makeSignsResult(signs));
232
- return {
233
- type: typeOfTable,
234
- fx,
235
- factors,
236
- zeroes,
237
- signs,
238
- extremes: {},
239
- tex: ''
240
- };
241
- }
242
- }
243
- exports.RationalStudy = RationalStudy;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RationalStudy = void 0;
4
+ /**
5
+ * The study class is a "function study" class that will get:
6
+ * fx : get the function
7
+ * domain : string
8
+ * zeroes : Object (tex, IZero)
9
+ * signs : table of signs + tex output using tkz-tab
10
+ * av : vertical asymptotic
11
+ * ah : horizontal asymptotic
12
+ * ao : obliques
13
+ * deltaX : position relative
14
+ * dx : derivative
15
+ * grows : growing table + tex output using tkz-tab
16
+ * ddx : dérivée seconde
17
+ * variations : variation table + tex output using tkz-tab
18
+ */
19
+ const study_1 = require("../study");
20
+ const rational_1 = require("../rational");
21
+ const fraction_1 = require("../../coefficients/fraction");
22
+ const polynom_1 = require("../polynom");
23
+ class RationalStudy extends study_1.Study {
24
+ constructor(fx, config) {
25
+ super(fx, config);
26
+ return this;
27
+ }
28
+ makeZeroes() {
29
+ return this._getZeroes(this.fx);
30
+ }
31
+ ;
32
+ makeSigns() {
33
+ return this._getSigns(this.fx, this.zeroes);
34
+ }
35
+ ;
36
+ makeAsymptotes() {
37
+ const reduced = this.fx.clone().reduce();
38
+ // Vertical
39
+ let asymptotes = [];
40
+ this.zeroes.filter(x => x.type === study_1.ZEROTYPE.DEFENCE).forEach(zero => {
41
+ // Check if it's a hole or an asymptote
42
+ let Ztype = study_1.ASYMPTOTE.VERTICAL, tex = `x=${zero.tex}`, display = `x=${zero.display}`;
43
+ // Check if it's a hole: the reduced polynom should not be null
44
+ if (zero.exact instanceof fraction_1.Fraction) {
45
+ if (reduced.denominator.evaluate(zero.exact).isNotZero()) {
46
+ Ztype = study_1.ASYMPTOTE.HOLE;
47
+ tex = `(${zero.tex};${reduced.evaluate(zero.exact).tex})`;
48
+ display = `(${zero.display};${reduced.evaluate(zero.exact).display})`;
49
+ }
50
+ }
51
+ else {
52
+ if (reduced.denominator.evaluate(zero.value).isNotZero()) {
53
+ Ztype = study_1.ASYMPTOTE.HOLE;
54
+ tex = `(${zero.tex};${reduced.evaluate(zero.value).tex})`;
55
+ display = `(${zero.display};${reduced.evaluate(zero.value).display})`;
56
+ }
57
+ }
58
+ // Get the position before and after the asymptote.
59
+ const delta = 0.000001;
60
+ let before = this.fx.evaluateAsNumeric(zero.value - delta), after = this.fx.evaluateAsNumeric(zero.value + delta), position = [], pm = "";
61
+ if (after < -10000) {
62
+ position.push(study_1.ASYMPTOTE_POSITION.RB);
63
+ pm += "m";
64
+ }
65
+ else if (after > 10000) {
66
+ position.push(study_1.ASYMPTOTE_POSITION.RT);
67
+ pm += "p";
68
+ }
69
+ if (before < -10000) {
70
+ position.push(study_1.ASYMPTOTE_POSITION.LB);
71
+ pm += "m";
72
+ }
73
+ else if (before > 10000) {
74
+ position.push(study_1.ASYMPTOTE_POSITION.LT);
75
+ pm += "p";
76
+ }
77
+ // Left and right are to infinity
78
+ // TODO: handle the case were one side of the asymptote isn't infinity (not possible in rational study?!)
79
+ if (pm === "pp") {
80
+ pm = "+";
81
+ }
82
+ else if (pm === "mm") {
83
+ pm = "-";
84
+ }
85
+ else {
86
+ pm = `\\${pm}`;
87
+ }
88
+ asymptotes.push({
89
+ fx: null,
90
+ type: Ztype,
91
+ tex,
92
+ display,
93
+ zero: zero,
94
+ limits: `\\lim_{x\\to${zero.tex} }\\ f(x) = ${pm}\\infty`,
95
+ deltaX: null,
96
+ tableOfSign: null,
97
+ position
98
+ });
99
+ });
100
+ // Sloped asymptote
101
+ let NDegree = this.fx.numerator.degree(), DDegree = this.fx.denominator.degree();
102
+ if (NDegree.isEqual(DDegree)) {
103
+ let H = this.fx.numerator.monomByDegree().coefficient.clone().divide(this.fx.denominator.monomByDegree().coefficient), Htex = H.tex;
104
+ let { reminder } = reduced.euclidian(), deltaX = new rational_1.Rational(reminder, reduced.denominator);
105
+ // Determine the position above or below on the left / right of the asymptote.
106
+ asymptotes.push({
107
+ fx: new polynom_1.Polynom(H),
108
+ type: study_1.ASYMPTOTE.HORIZONTAL,
109
+ tex: `y=${Htex}`,
110
+ display: `y=${H.display}`,
111
+ zero: null,
112
+ limits: `\\lim_{x\\to\\infty}\\ f(x) = ${Htex}`,
113
+ deltaX,
114
+ tableOfSign: this._getSigns(deltaX),
115
+ position: this._getHorizontalAsymptoteRelativePositon(deltaX)
116
+ });
117
+ }
118
+ else if (DDegree.greater(NDegree)) {
119
+ asymptotes.push({
120
+ fx: new polynom_1.Polynom('0'),
121
+ type: study_1.ASYMPTOTE.HORIZONTAL,
122
+ tex: `y=0`,
123
+ display: `y=0`,
124
+ zero: null,
125
+ limits: `\\lim_{x\\to\\infty}\\ f(x) = ${0}`,
126
+ deltaX: null,
127
+ tableOfSign: null,
128
+ position: this._getHorizontalAsymptoteRelativePositon(this.fx)
129
+ });
130
+ }
131
+ else if (NDegree.value - 1 === DDegree.value) {
132
+ // Calculate the slope
133
+ let { quotient, reminder } = reduced.euclidian(), deltaX = new rational_1.Rational(reminder, reduced.denominator);
134
+ asymptotes.push({
135
+ fx: quotient.clone(),
136
+ type: study_1.ASYMPTOTE.SLOPE,
137
+ tex: `y=${quotient.tex}`,
138
+ display: `y=${quotient.display}`,
139
+ zero: null,
140
+ limits: ``,
141
+ deltaX: new rational_1.Rational(reminder, reduced.denominator),
142
+ tableOfSign: this._getSigns(deltaX),
143
+ position: this._getHorizontalAsymptoteRelativePositon(deltaX)
144
+ });
145
+ }
146
+ return asymptotes;
147
+ }
148
+ ;
149
+ _getHorizontalAsymptoteRelativePositon(deltaX, delta = 1000000) {
150
+ let position = [], before = deltaX.evaluateAsNumeric(-delta), after = deltaX.evaluateAsNumeric(delta);
151
+ if (before >= 0) {
152
+ position.push(study_1.ASYMPTOTE_POSITION.LT);
153
+ }
154
+ else {
155
+ position.push(study_1.ASYMPTOTE_POSITION.LB);
156
+ }
157
+ if (after >= 0) {
158
+ position.push(study_1.ASYMPTOTE_POSITION.RT);
159
+ }
160
+ else {
161
+ position.push(study_1.ASYMPTOTE_POSITION.RB);
162
+ }
163
+ return position;
164
+ }
165
+ makeDerivative() {
166
+ let dx = this.fx.clone().derivative(), tos = this._getSigns(dx, this._getZeroes(dx), study_1.TABLE_OF_SIGNS.GROWS);
167
+ let result = this.makeGrowsResult(tos);
168
+ tos.signs.push(result.growsLine);
169
+ tos.extremes = result.extremes;
170
+ return tos;
171
+ }
172
+ ;
173
+ makeVariation() {
174
+ // Get the zeroes, make signs.
175
+ let dx = this.derivative.fx.clone().derivative(), tos = this._getSigns(dx, this._getZeroes(dx), study_1.TABLE_OF_SIGNS.VARIATIONS);
176
+ let result = this.makeVariationsResult(tos);
177
+ tos.signs.push(result.varsLine);
178
+ tos.extremes = result.extremes;
179
+ return tos;
180
+ }
181
+ ;
182
+ _getZeroes(fx) {
183
+ // All zeroes.
184
+ let zeroes = [];
185
+ fx.numerator.getZeroes().filter(x => !isNaN(x.value)).forEach(z => {
186
+ // add the item
187
+ zeroes.push({
188
+ tex: z.tex,
189
+ display: z.display,
190
+ value: z.value,
191
+ exact: z.exact,
192
+ extrema: study_1.FUNCTION_EXTREMA.NOTHING,
193
+ type: study_1.ZEROTYPE.ZERO
194
+ });
195
+ });
196
+ fx.denominator.getZeroes().filter(x => !isNaN(x.value)).forEach(z => {
197
+ let idx = this.indexOfZero(zeroes, z);
198
+ if (idx !== -1) {
199
+ zeroes[idx].type = study_1.ZEROTYPE.DEFENCE;
200
+ }
201
+ else {
202
+ // Add the item
203
+ zeroes.push({
204
+ tex: z.tex,
205
+ display: z.display,
206
+ value: z.value,
207
+ exact: z.exact,
208
+ extrema: study_1.FUNCTION_EXTREMA.NOTHING,
209
+ type: study_1.ZEROTYPE.DEFENCE
210
+ });
211
+ }
212
+ });
213
+ // sort all zeroes
214
+ zeroes.sort((a, b) => a.value - b.value);
215
+ return zeroes;
216
+ }
217
+ _getSigns(fx, zeroes, typeOfTable) {
218
+ // Factorize the rational
219
+ let signs = [], factors = [];
220
+ if (zeroes === undefined) {
221
+ zeroes = this._getZeroes(fx);
222
+ }
223
+ fx.numerator.factors.forEach(factor => {
224
+ signs.push(this.makeOneLineForSigns(factor, zeroes, study_1.ZEROTYPE.ZERO));
225
+ factors.push(factor.clone());
226
+ });
227
+ fx.denominator.factors.forEach(factor => {
228
+ signs.push(this.makeOneLineForSigns(factor, zeroes, study_1.ZEROTYPE.DEFENCE));
229
+ factors.push(factor.clone());
230
+ });
231
+ signs.push(this.makeSignsResult(signs));
232
+ return {
233
+ type: typeOfTable,
234
+ fx,
235
+ factors,
236
+ zeroes,
237
+ signs,
238
+ extremes: {},
239
+ tex: ''
240
+ };
241
+ }
242
+ }
243
+ exports.RationalStudy = RationalStudy;
244
244
  //# sourceMappingURL=rationalStudy.js.map