pimath 0.0.127 → 0.0.129

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 (212) hide show
  1. package/dist/main.d.ts +39 -0
  2. package/{esm → dist}/maths/algebra/equation.d.ts +11 -10
  3. package/{esm → dist}/maths/algebra/linearSystem.d.ts +5 -4
  4. package/{esm → dist}/maths/algebra/monom.d.ts +5 -4
  5. package/{esm → dist}/maths/algebra/polynom.d.ts +11 -13
  6. package/{esm → dist}/maths/algebra/rational.d.ts +7 -9
  7. package/dist/maths/algebra/study/rationalStudy.d.ts +14 -0
  8. package/{esm → dist}/maths/algebra/study.d.ts +4 -7
  9. package/{esm → dist}/maths/geometry/circle.d.ts +9 -8
  10. package/{esm → dist}/maths/geometry/line.d.ts +17 -14
  11. package/{esm → dist}/maths/geometry/point.d.ts +11 -9
  12. package/{esm → dist}/maths/geometry/triangle.d.ts +4 -3
  13. package/{esm → dist}/maths/geometry/vector.d.ts +7 -10
  14. package/{esm → dist}/maths/randomization/random.d.ts +10 -7
  15. package/{esm → dist}/maths/randomization/rndFraction.d.ts +4 -3
  16. package/dist/maths/randomization/rndGeometryCircle.d.ts +13 -0
  17. package/{esm → dist}/maths/randomization/rndGeometryLine.d.ts +4 -3
  18. package/{esm → dist}/maths/randomization/rndGeometryPoint.d.ts +4 -3
  19. package/{esm → dist}/maths/randomization/rndMonom.d.ts +5 -4
  20. package/{esm → dist}/maths/randomization/rndPolynom.d.ts +5 -4
  21. package/{esm → dist}/maths/randomization/rndTypes.d.ts +7 -1
  22. package/dist/pimath.js +4239 -7819
  23. package/package.json +13 -7
  24. package/.eslintrc.js +0 -24
  25. package/.idea/$CACHE_FILE$ +0 -6
  26. package/.idea/PI.iml +0 -14
  27. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  28. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  29. package/.idea/misc.xml +0 -6
  30. package/.idea/modules.xml +0 -8
  31. package/.idea/php.xml +0 -19
  32. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]/shelved.patch +0 -192
  33. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]1/shelved.patch +0 -0
  34. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30__Default_Changelist_.xml +0 -4
  35. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43_[Default_Changelist]/shelved.patch +0 -2404
  36. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43__Default_Changelist_.xml +0 -4
  37. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01_[Default_Changelist]/shelved.patch +0 -1362
  38. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01__Default_Changelist_.xml +0 -4
  39. package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]/shelved.patch +0 -90
  40. package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_.xml +0 -4
  41. package/.idea/vcs.xml +0 -6
  42. package/dev/pimath.js +0 -7945
  43. package/dev/pimath.js.map +0 -1
  44. package/dist/pimath.js.map +0 -1
  45. package/dist/pimath.min.js +0 -2
  46. package/dist/pimath.min.js.map +0 -1
  47. package/docs/.nojekyll +0 -1
  48. package/docs/assets/highlight.css +0 -78
  49. package/docs/assets/main.js +0 -59
  50. package/docs/assets/navigation.js +0 -1
  51. package/docs/assets/search.js +0 -1
  52. package/docs/assets/style.css +0 -1383
  53. package/docs/classes/Logicalset.Logicalset.html +0 -217
  54. package/docs/classes/Polynom.Rational.html +0 -397
  55. package/docs/classes/Vector-1.Vector.html +0 -490
  56. package/docs/classes/Vector.Point.html +0 -337
  57. package/docs/classes/algebra_equation.Equation.html +0 -790
  58. package/docs/classes/algebra_linearSystem.LinearSystem.html +0 -404
  59. package/docs/classes/algebra_monom.Monom.html +0 -962
  60. package/docs/classes/algebra_polynom.Polynom.html +0 -1275
  61. package/docs/classes/coefficients_fraction.Fraction.html +0 -934
  62. package/docs/classes/geometry_circle.Circle.html +0 -472
  63. package/docs/classes/geometry_line.Line.html +0 -774
  64. package/docs/classes/geometry_triangle.Triangle.html +0 -429
  65. package/docs/classes/numeric.Numeric.html +0 -265
  66. package/docs/classes/shutingyard.Shutingyard.html +0 -250
  67. package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +0 -83
  68. package/docs/enums/geometry_line.LinePropriety.html +0 -97
  69. package/docs/enums/shutingyard.ShutingyardMode.html +0 -97
  70. package/docs/enums/shutingyard.ShutingyardType.html +0 -111
  71. package/docs/index.html +0 -63
  72. package/docs/interfaces/algebra_equation.ISolution.html +0 -105
  73. package/docs/interfaces/algebra_polynom.IEuclidian.html +0 -87
  74. package/docs/interfaces/geometry_triangle.remarquableLines.html +0 -163
  75. package/docs/modules/Logicalset.html +0 -65
  76. package/docs/modules/Polynom.html +0 -65
  77. package/docs/modules/Vector-1.html +0 -65
  78. package/docs/modules/Vector.html +0 -65
  79. package/docs/modules/algebra_equation.html +0 -69
  80. package/docs/modules/algebra_linearSystem.html +0 -61
  81. package/docs/modules/algebra_monom.html +0 -65
  82. package/docs/modules/algebra_polynom.html +0 -69
  83. package/docs/modules/coefficients_fraction.html +0 -65
  84. package/docs/modules/geometry_circle.html +0 -61
  85. package/docs/modules/geometry_line.html +0 -65
  86. package/docs/modules/geometry_triangle.html +0 -65
  87. package/docs/modules/numeric.html +0 -61
  88. package/docs/modules/shutingyard.html +0 -75
  89. package/docs/types/algebra_monom.literalType.html +0 -61
  90. package/docs/types/algebra_polynom.PolynomParsingType.html +0 -56
  91. package/docs/types/coefficients_fraction.FractionParsingType.html +0 -56
  92. package/docs/types/shutingyard.Token.html +0 -63
  93. package/docs/types/shutingyard.tokenType.html +0 -68
  94. package/docs/variables/shutingyard.tokenConstant.html +0 -61
  95. package/esm/index.d.ts +0 -38
  96. package/esm/index.js +0 -44
  97. package/esm/index.js.map +0 -1
  98. package/esm/maths/algebra/equation.js +0 -797
  99. package/esm/maths/algebra/equation.js.map +0 -1
  100. package/esm/maths/algebra/linearSystem.js +0 -279
  101. package/esm/maths/algebra/linearSystem.js.map +0 -1
  102. package/esm/maths/algebra/logicalset.js +0 -158
  103. package/esm/maths/algebra/logicalset.js.map +0 -1
  104. package/esm/maths/algebra/monom.js +0 -909
  105. package/esm/maths/algebra/monom.js.map +0 -1
  106. package/esm/maths/algebra/polynom.js +0 -1305
  107. package/esm/maths/algebra/polynom.js.map +0 -1
  108. package/esm/maths/algebra/rational.js +0 -195
  109. package/esm/maths/algebra/rational.js.map +0 -1
  110. package/esm/maths/algebra/study/rationalStudy.d.ts +0 -28
  111. package/esm/maths/algebra/study/rationalStudy.js +0 -244
  112. package/esm/maths/algebra/study/rationalStudy.js.map +0 -1
  113. package/esm/maths/algebra/study.js +0 -380
  114. package/esm/maths/algebra/study.js.map +0 -1
  115. package/esm/maths/coefficients/fraction.js +0 -517
  116. package/esm/maths/coefficients/fraction.js.map +0 -1
  117. package/esm/maths/coefficients/nthRoot.js +0 -137
  118. package/esm/maths/coefficients/nthRoot.js.map +0 -1
  119. package/esm/maths/geometry/circle.js +0 -324
  120. package/esm/maths/geometry/circle.js.map +0 -1
  121. package/esm/maths/geometry/line.js +0 -485
  122. package/esm/maths/geometry/line.js.map +0 -1
  123. package/esm/maths/geometry/point.js +0 -167
  124. package/esm/maths/geometry/point.js.map +0 -1
  125. package/esm/maths/geometry/triangle.js +0 -276
  126. package/esm/maths/geometry/triangle.js.map +0 -1
  127. package/esm/maths/geometry/vector.js +0 -198
  128. package/esm/maths/geometry/vector.js.map +0 -1
  129. package/esm/maths/numeric.js +0 -136
  130. package/esm/maths/numeric.js.map +0 -1
  131. package/esm/maths/numexp.js +0 -186
  132. package/esm/maths/numexp.js.map +0 -1
  133. package/esm/maths/randomization/random.js +0 -79
  134. package/esm/maths/randomization/random.js.map +0 -1
  135. package/esm/maths/randomization/randomCore.js +0 -22
  136. package/esm/maths/randomization/randomCore.js.map +0 -1
  137. package/esm/maths/randomization/rndFraction.js +0 -44
  138. package/esm/maths/randomization/rndFraction.js.map +0 -1
  139. package/esm/maths/randomization/rndGeometryLine.js +0 -46
  140. package/esm/maths/randomization/rndGeometryLine.js.map +0 -1
  141. package/esm/maths/randomization/rndGeometryPoint.js +0 -61
  142. package/esm/maths/randomization/rndGeometryPoint.js.map +0 -1
  143. package/esm/maths/randomization/rndHelpers.js +0 -98
  144. package/esm/maths/randomization/rndHelpers.js.map +0 -1
  145. package/esm/maths/randomization/rndMonom.js +0 -53
  146. package/esm/maths/randomization/rndMonom.js.map +0 -1
  147. package/esm/maths/randomization/rndPolynom.js +0 -75
  148. package/esm/maths/randomization/rndPolynom.js.map +0 -1
  149. package/esm/maths/randomization/rndTypes.js +0 -3
  150. package/esm/maths/randomization/rndTypes.js.map +0 -1
  151. package/esm/maths/shutingyard.js +0 -443
  152. package/esm/maths/shutingyard.js.map +0 -1
  153. package/public/demo.css +0 -3
  154. package/public/index.html +0 -283
  155. package/public/matrices.html +0 -100
  156. package/public/playground.html +0 -168
  157. package/src/index.ts +0 -42
  158. package/src/maths/algebra/equation.ts +0 -897
  159. package/src/maths/algebra/linearSystem.ts +0 -370
  160. package/src/maths/algebra/logicalset.ts +0 -183
  161. package/src/maths/algebra/monom.ts +0 -1028
  162. package/src/maths/algebra/polynom.ts +0 -1537
  163. package/src/maths/algebra/rational.ts +0 -240
  164. package/src/maths/algebra/study/rationalStudy.ts +0 -287
  165. package/src/maths/algebra/study.ts +0 -506
  166. package/src/maths/coefficients/fraction.ts +0 -593
  167. package/src/maths/coefficients/nthRoot.ts +0 -148
  168. package/src/maths/geometry/circle.ts +0 -382
  169. package/src/maths/geometry/line.ts +0 -604
  170. package/src/maths/geometry/point.ts +0 -215
  171. package/src/maths/geometry/triangle.ts +0 -368
  172. package/src/maths/geometry/vector.ts +0 -242
  173. package/src/maths/numeric.ts +0 -162
  174. package/src/maths/numexp.ts +0 -184
  175. package/src/maths/randomization/random.ts +0 -80
  176. package/src/maths/randomization/randomCore.ts +0 -19
  177. package/src/maths/randomization/rndFraction.ts +0 -47
  178. package/src/maths/randomization/rndGeometryCircle.ts +0 -50
  179. package/src/maths/randomization/rndGeometryLine.ts +0 -53
  180. package/src/maths/randomization/rndGeometryPoint.ts +0 -69
  181. package/src/maths/randomization/rndHelpers.ts +0 -107
  182. package/src/maths/randomization/rndMonom.ts +0 -57
  183. package/src/maths/randomization/rndPolynom.ts +0 -90
  184. package/src/maths/randomization/rndTypes.ts +0 -43
  185. package/src/maths/shutingyard.ts +0 -496
  186. package/tests/algebra/equation.test.ts +0 -64
  187. package/tests/algebra/linear.test.ts +0 -58
  188. package/tests/algebra/monom.test.ts +0 -78
  189. package/tests/algebra/polynom.test.ts +0 -343
  190. package/tests/algebra/rationnal.test.ts +0 -64
  191. package/tests/algebra/study.test.ts +0 -48
  192. package/tests/coefficients/fraction.test.ts +0 -131
  193. package/tests/custom.test.ts +0 -33
  194. package/tests/geometry/circle.test.ts +0 -404
  195. package/tests/geometry/line.test.ts +0 -36
  196. package/tests/numeric.test.ts +0 -43
  197. package/tests/numexp.test.ts +0 -89
  198. package/tests/shutingyard.test.ts +0 -58
  199. package/tsconfig.json +0 -41
  200. package/tsconfig.testing.json +0 -28
  201. package/typedoc.katex.js +0 -11
  202. package/webpack-production-min.config.js +0 -26
  203. package/webpack-production.config.js +0 -26
  204. package/webpack.config.js +0 -26
  205. package/{esm → dist}/maths/algebra/logicalset.d.ts +6 -6
  206. package/{esm → dist}/maths/coefficients/fraction.d.ts +0 -0
  207. package/{esm → dist}/maths/coefficients/nthRoot.d.ts +0 -0
  208. package/{esm → dist}/maths/numeric.d.ts +0 -0
  209. package/{esm → dist}/maths/numexp.d.ts +3 -3
  210. /package/{esm → dist}/maths/randomization/randomCore.d.ts +0 -0
  211. /package/{esm → dist}/maths/randomization/rndHelpers.d.ts +0 -0
  212. /package/{esm → dist}/maths/shutingyard.d.ts +0 -0
@@ -1,240 +0,0 @@
1
- /**
2
- * Rational polynom module contains everything necessary to handle rational polynoms.
3
- * @module Polynom
4
- */
5
-
6
- import {IEuclidian, Polynom} from "./polynom";
7
- import {Fraction} from "../coefficients/fraction";
8
- import {literalType} from "./monom";
9
- import {PARTICULAR_SOLUTION} from "./equation";
10
- import {RationalStudy} from "./study/rationalStudy";
11
- import {StudyConfig} from "./study";
12
-
13
- /**
14
- * Rational class can handle rational polynoms
15
- */
16
- export class Rational {
17
- private _denominator: Polynom;
18
- private _numerator: Polynom;
19
- private _rawString: string;
20
-
21
- /**
22
- *
23
- * @param numerator
24
- * @param denominator
25
- */
26
- constructor(numerator?: Polynom | string, denominator?: Polynom | string) {
27
- if (numerator instanceof Polynom) {
28
- this._numerator = numerator.clone()
29
- } else if (typeof numerator === 'string') {
30
- this._numerator = new Polynom(numerator)
31
- } else {
32
- this._numerator = new Polynom()
33
- }
34
-
35
- if (denominator instanceof Polynom) {
36
- this._denominator = denominator.clone()
37
- } else if (typeof denominator === 'string') {
38
- this._denominator = new Polynom(denominator)
39
- } else {
40
- this._denominator = new Polynom()
41
- }
42
-
43
- }
44
-
45
- get numerator(): Polynom {
46
- return this._numerator
47
- }
48
-
49
- get denominator(): Polynom {
50
- return this._denominator
51
- }
52
-
53
- get tex(): string {
54
- return `\\frac{ ${this._numerator.tex} }{ ${this._denominator.tex} }`;
55
- }
56
-
57
- get display(): string {
58
- return `(${this._numerator.display})/(${this._denominator.display})`;
59
- }
60
-
61
- get texFactors(): string {
62
- return `\\frac{ ${this._numerator.texFactors} }{ ${this._denominator.texFactors} }`
63
- }
64
-
65
- get plotFunction(): string {
66
- return `(${this._numerator.plotFunction})/(${this._denominator.plotFunction})`
67
- }
68
-
69
- clone = (): Rational => {
70
- return new Rational(
71
- this._numerator.clone(),
72
- this._denominator.clone()
73
- )
74
- }
75
-
76
- domain = (): string => {
77
- let zeroes = this._denominator.getZeroes();
78
-
79
- if (zeroes.length === 0 || zeroes[0].tex === PARTICULAR_SOLUTION.real) {
80
- return PARTICULAR_SOLUTION.varnothing
81
- } else if (zeroes[0].tex === PARTICULAR_SOLUTION.varnothing) {
82
- return PARTICULAR_SOLUTION.real
83
- } else {
84
- return '\\mathbb{R}\\setminus\\left\\{' +
85
- zeroes.map(x => x.tex).join(';') + '\\right\\}'
86
- }
87
- }
88
-
89
- amplify = (P: Polynom): Rational => {
90
- this._numerator.multiply(P);
91
- this._denominator.multiply(P);
92
-
93
- return this;
94
- }
95
-
96
- derivative = (letter?: string): Rational => {
97
- let N = this._numerator.clone(),
98
- D = this._denominator.clone(),
99
- dN = N.clone().derivative(letter),
100
- dD = D.clone().derivative(letter)
101
-
102
- this._numerator = dN.clone().multiply(D).subtract(N.clone().multiply(dD))
103
- this._denominator = D.clone().pow(2)
104
-
105
- return this
106
- }
107
-
108
- factorize = (letter?: string): Rational => {
109
- this._numerator.factorize(letter)
110
- this._denominator.factorize(letter)
111
- return this
112
- }
113
-
114
- simplify = (P: Polynom): Rational => {
115
- let NumeratorEuclidien = this._numerator.euclidian(P);
116
- if (!NumeratorEuclidien.reminder.isZero()) {
117
- return this;
118
- }
119
-
120
- let DenominatorEuclidien = this._denominator.euclidian(P);
121
- if (!DenominatorEuclidien.reminder.isZero()) {
122
- return this;
123
- }
124
-
125
- this._numerator = NumeratorEuclidien.quotient;
126
- this._denominator = DenominatorEuclidien.quotient;
127
- return this;
128
- }
129
-
130
- reduce = (): Rational => {
131
- this._numerator.factorize();
132
- for (let f of this._numerator.factors) {
133
-
134
- if(f.degree().isZero()){
135
- // Do the simplify only if the factor can divide the denominator
136
- if(this._denominator.commonMonom().coefficient.clone().divide(f.monomByDegree().coefficient).isNatural()){
137
- this.simplify(f);
138
- }
139
- }else {
140
- this.simplify(f);
141
- }
142
- }
143
-
144
- return this;
145
- }
146
-
147
- opposed = (): Rational => {
148
- this._numerator.opposed();
149
- return this;
150
- }
151
-
152
- add = (R: Rational): Rational => {
153
- // 1. Make sure both rational are at the same denominator
154
- // 2. Add the numerators.
155
- // 3. Simplify
156
-
157
- // Store the adding denominator
158
- let denominator = this._denominator.clone()
159
-
160
- // Amplif the main rational polynom by the adding denominator
161
- this.amplify(R._denominator)
162
-
163
- // Add to the numerator the adding value...
164
- this._numerator.add(R._numerator.clone().multiply(denominator));
165
-
166
- return this;
167
- }
168
-
169
- subtract = (R: Rational): Rational => {
170
- return this.add(R.clone().opposed())
171
- }
172
-
173
- euclidian = (): IEuclidian => {
174
- return this._numerator.euclidian(this._denominator)
175
- }
176
-
177
- // TODO : where and how is used limits ?
178
- limits = (value: Fraction | number, offset?: string, letter?: string): Fraction => {
179
- if (value === Infinity || value === -Infinity) {
180
- let {quotient, reminder} = this._numerator.clone().euclidian(this._denominator)
181
-
182
- // quotient is positive => it will be infinite.
183
- if (quotient.degree(letter).isStrictlyPositive()) {
184
- return value === Infinity ? quotient.limitToInfinity(letter) : quotient.limitToNegativeInfinity(letter)
185
- // return quotient.monomByDegree(undefined, letter).coefficient.sign()===1?(new Fraction()).infinite():(new Fraction()).infinite().opposed()
186
- } else {
187
- return quotient.monomByDegree(undefined, letter).coefficient
188
- }
189
- } else {
190
- let evalValues: literalType = {},
191
- evalValuesOffset: literalType = {},
192
- theLimit: Fraction | number,
193
- theSign: number,
194
- FR = this.clone().reduce()
195
-
196
- evalValues[letter === undefined ? 'x' : letter] = new Fraction(value)
197
-
198
- if (offset !== 'above' && offset !== 'below') {
199
- theLimit = FR._numerator.evaluate(evalValues)
200
- .divide(FR._denominator.evaluate(evalValues))
201
-
202
- return theLimit.isInfinity() ? theLimit.abs() : theLimit
203
- } else {
204
- if (offset === 'above') {
205
- evalValuesOffset[letter === undefined ? 'x' : letter] = (new Fraction(value)).add(0.000001)
206
- } else if (offset === 'below') {
207
- evalValuesOffset[letter === undefined ? 'x' : letter] = (new Fraction(value)).subtract(0.000001)
208
- }
209
-
210
- theLimit = FR._numerator.evaluate(evalValues)
211
- .divide(FR._denominator.evaluate(evalValues))
212
- theSign = FR._numerator.evaluate(evalValuesOffset)
213
- .divide(FR._denominator.evaluate(evalValuesOffset)).sign()
214
-
215
- if (theLimit.isInfinity()) {
216
- return theSign === 1 ? theLimit.abs() : theLimit.abs().opposed()
217
- } else {
218
- return theLimit
219
- }
220
- }
221
- }
222
- }
223
-
224
- evaluate = (values: literalType | Fraction | number): Fraction => {
225
- const r = new Fraction().zero();
226
-
227
- let N = this._numerator.evaluate(values),
228
- D = this._denominator.evaluate(values)
229
-
230
- return N.divide(D)
231
- };
232
-
233
- evaluateAsNumeric = (values: { [Key: string]: number } | number): number => {
234
- return this._numerator.evaluateAsNumeric(values) / this._denominator.evaluateAsNumeric(values)
235
- }
236
-
237
- study = (config?:StudyConfig|string): RationalStudy => {
238
- return new RationalStudy(this, config)
239
- }
240
- }
@@ -1,287 +0,0 @@
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 {
17
- ASYMPTOTE,
18
- ASYMPTOTE_POSITION,
19
- FUNCTION_EXTREMA,
20
- IAsymptote,
21
- ITableOfSigns,
22
- IZero,
23
- Study,
24
- StudyableFunction, StudyConfig,
25
- TABLE_OF_SIGNS,
26
- ZEROTYPE
27
- } from "../study";
28
- import {Rational} from "../rational";
29
- import {Fraction} from "../../coefficients/fraction";
30
- import {Polynom} from "../polynom";
31
-
32
- export class RationalStudy extends Study {
33
- constructor(fx: StudyableFunction, config?: StudyConfig|string) {
34
- super(fx, config)
35
-
36
- return this
37
- }
38
-
39
- makeZeroes(): IZero[] {
40
- return this._getZeroes(this.fx)
41
- };
42
-
43
- makeSigns(): ITableOfSigns {
44
- return this._getSigns(this.fx, this.zeroes)
45
- };
46
-
47
- makeAsymptotes(): IAsymptote[] {
48
- const reduced: Rational = this.fx.clone().reduce()
49
-
50
- // Vertical
51
- let asymptotes: IAsymptote[] = []
52
- this.zeroes.filter(x => x.type === ZEROTYPE.DEFENCE).forEach(zero => {
53
- // Check if it's a hole or an asymptote
54
- let Ztype = ASYMPTOTE.VERTICAL,
55
- tex = `x=${zero.tex}`,
56
- display = `x=${zero.display}`
57
-
58
- // Check if it's a hole: the reduced polynom should not be null
59
- if (zero.exact instanceof Fraction) {
60
- if (reduced.denominator.evaluate(zero.exact).isNotZero()) {
61
- Ztype = ASYMPTOTE.HOLE
62
- tex = `(${zero.tex};${reduced.evaluate(zero.exact).tex})`
63
- display = `(${zero.display};${reduced.evaluate(zero.exact).display})`
64
- }
65
- } else {
66
- if (reduced.denominator.evaluate(zero.value).isNotZero()) {
67
- Ztype = ASYMPTOTE.HOLE
68
- tex = `(${zero.tex};${reduced.evaluate(zero.value).tex})`
69
- display = `(${zero.display};${reduced.evaluate(zero.value).display})`
70
- }
71
- }
72
-
73
- // Get the position before and after the asymptote.
74
- const delta = 0.000001
75
- let before = this.fx.evaluateAsNumeric(zero.value - delta),
76
- after = this.fx.evaluateAsNumeric(zero.value + delta),
77
- position: ASYMPTOTE_POSITION[] = [],
78
- pm = ""
79
-
80
- if (after < -10000) {
81
- position.push(ASYMPTOTE_POSITION.RB)
82
- pm += "m"
83
- } else if (after > 10000) {
84
- position.push(ASYMPTOTE_POSITION.RT)
85
- pm += "p"
86
- }
87
-
88
- if (before < -10000) {
89
- position.push(ASYMPTOTE_POSITION.LB)
90
- pm += "m"
91
- } else if (before > 10000) {
92
- position.push(ASYMPTOTE_POSITION.LT)
93
- pm += "p"
94
- }
95
-
96
- // Left and right are to infinity
97
- // TODO: handle the case were one side of the asymptote isn't infinity (not possible in rational study?!)
98
- if (pm === "pp") {
99
- pm = "+"
100
- } else if (pm === "mm") {
101
- pm = "-"
102
- } else {
103
- pm = `\\${pm}`
104
- }
105
-
106
- asymptotes.push({
107
- fx: null,
108
- type: Ztype,
109
- tex,
110
- display,
111
- zero: zero,
112
- limits: `\\lim_{x\\to${zero.tex} }\\ f(x) = ${pm}\\infty`,
113
- deltaX: null,
114
- tableOfSign: null,
115
- position
116
- })
117
- })
118
-
119
- // Sloped asymptote
120
- let NDegree = this.fx.numerator.degree(),
121
- DDegree = this.fx.denominator.degree()
122
- if (NDegree.isEqual(DDegree)) {
123
- let H = this.fx.numerator.monomByDegree().coefficient.clone().divide(this.fx.denominator.monomByDegree().coefficient),
124
- Htex = H.tex
125
-
126
- let {reminder} = reduced.euclidian(),
127
- deltaX = new Rational(reminder, reduced.denominator)
128
-
129
- // Determine the position above or below on the left / right of the asymptote.
130
- asymptotes.push({
131
- fx: new Polynom(H),
132
- type: ASYMPTOTE.HORIZONTAL,
133
- tex: `y=${Htex}`,
134
- display: `y=${H.display}`,
135
- zero: null,
136
- limits: `\\lim_{x\\to\\infty}\\ f(x) = ${Htex}`,
137
- deltaX,
138
- tableOfSign: this._getSigns(deltaX),
139
- position: this._getHorizontalAsymptoteRelativePositon(deltaX)
140
- })
141
- } else if (DDegree.greater(NDegree)) {
142
- asymptotes.push({
143
- fx: new Polynom('0'),
144
- type: ASYMPTOTE.HORIZONTAL,
145
- tex: `y=0`,
146
- display: `y=0`,
147
- zero: null,
148
- limits: `\\lim_{x\\to\\infty}\\ f(x) = ${0}`,
149
- deltaX: null,
150
- tableOfSign: null,
151
- position: this._getHorizontalAsymptoteRelativePositon(this.fx)
152
- })
153
- } else if (NDegree.value - 1 === DDegree.value) {
154
- // Calculate the slope
155
- let {quotient, reminder} = reduced.euclidian(),
156
- deltaX = new Rational(reminder, reduced.denominator)
157
-
158
- asymptotes.push({
159
- fx: quotient.clone(),
160
- type: ASYMPTOTE.SLOPE,
161
- tex: `y=${quotient.tex}`,
162
- display: `y=${quotient.display}`,
163
- zero: null,
164
- limits: ``,
165
- deltaX: new Rational(reminder, reduced.denominator),
166
- tableOfSign: this._getSigns(deltaX),
167
- position: this._getHorizontalAsymptoteRelativePositon(deltaX)
168
- })
169
- }
170
-
171
- return asymptotes
172
- };
173
-
174
- _getHorizontalAsymptoteRelativePositon(deltaX: Rational, delta: number = 1000000): ASYMPTOTE_POSITION[] {
175
-
176
- let position: ASYMPTOTE_POSITION[] = [],
177
- before = deltaX.evaluateAsNumeric(-delta),
178
- after = deltaX.evaluateAsNumeric(delta)
179
-
180
- if (before >= 0) {
181
- position.push(ASYMPTOTE_POSITION.LT)
182
- } else {
183
- position.push(ASYMPTOTE_POSITION.LB)
184
- }
185
-
186
- if (after >= 0) {
187
- position.push(ASYMPTOTE_POSITION.RT)
188
- } else {
189
- position.push(ASYMPTOTE_POSITION.RB)
190
- }
191
-
192
- return position
193
- }
194
-
195
- makeDerivative(): ITableOfSigns {
196
- let dx = this.fx.clone().derivative(),
197
- tos = this._getSigns(dx, this._getZeroes(dx), TABLE_OF_SIGNS.GROWS)
198
-
199
- let result = this.makeGrowsResult(tos)
200
- tos.signs.push(result.growsLine)
201
- tos.extremes = result.extremes
202
- return tos
203
- };
204
-
205
- makeVariation(): ITableOfSigns {
206
- // Get the zeroes, make signs.
207
- let dx = this.derivative.fx.clone().derivative(),
208
- tos = this._getSigns(dx, this._getZeroes(dx), TABLE_OF_SIGNS.VARIATIONS)
209
-
210
- let result = this.makeVariationsResult(tos)
211
- tos.signs.push(result.varsLine)
212
- tos.extremes = result.extremes
213
- return tos
214
- };
215
-
216
- private _getZeroes(fx: StudyableFunction) {
217
- // All zeroes.
218
- let zeroes: IZero[] = []
219
-
220
- fx.numerator.getZeroes().filter(x => !isNaN(x.value)).forEach(z => {
221
- // add the item
222
- zeroes.push({
223
- tex: z.tex,
224
- display: z.display,
225
- value: z.value,
226
- exact: z.exact,
227
- extrema: FUNCTION_EXTREMA.NOTHING,
228
- type: ZEROTYPE.ZERO
229
- })
230
- })
231
-
232
- fx.denominator.getZeroes().filter(x => !isNaN(x.value)).forEach(z => {
233
- let idx = this.indexOfZero(zeroes, z)
234
-
235
- if (idx !== -1) {
236
- zeroes[idx].type = ZEROTYPE.DEFENCE
237
- } else {
238
- // Add the item
239
- zeroes.push({
240
- tex: z.tex,
241
- display: z.display,
242
- value: z.value,
243
- exact: z.exact,
244
- extrema: FUNCTION_EXTREMA.NOTHING,
245
- type: ZEROTYPE.DEFENCE
246
- })
247
- }
248
- })
249
-
250
- // sort all zeroes
251
- zeroes.sort((a, b) => a.value - b.value)
252
-
253
- return zeroes
254
- }
255
-
256
- private _getSigns(fx: Rational, zeroes?: IZero[], typeOfTable?: TABLE_OF_SIGNS): ITableOfSigns {
257
- // Factorize the rational
258
- let signs: (string[])[] = [],
259
- factors: Polynom[] = []
260
-
261
- if (zeroes === undefined) {
262
- zeroes = this._getZeroes(fx)
263
- }
264
-
265
- fx.numerator.factors.forEach(factor => {
266
- signs.push(this.makeOneLineForSigns(factor, zeroes, ZEROTYPE.ZERO))
267
- factors.push(factor.clone())
268
- })
269
-
270
- fx.denominator.factors.forEach(factor => {
271
- signs.push(this.makeOneLineForSigns(factor, zeroes, ZEROTYPE.DEFENCE))
272
- factors.push(factor.clone())
273
- })
274
-
275
- signs.push(this.makeSignsResult(signs))
276
-
277
- return {
278
- type: typeOfTable,
279
- fx,
280
- factors,
281
- zeroes,
282
- signs,
283
- extremes: {},
284
- tex: ''
285
- }
286
- }
287
- }