pimath 0.0.132 → 0.0.134

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 (114) hide show
  1. package/dist/pimath.js +2444 -3566
  2. package/package.json +37 -20
  3. package/types/algebra/equation.d.ts +109 -0
  4. package/types/algebra/equation.d.ts.map +1 -0
  5. package/types/algebra/equationSolver.d.ts +16 -0
  6. package/types/algebra/equationSolver.d.ts.map +1 -0
  7. package/types/algebra/factor.d.ts +47 -0
  8. package/types/algebra/factor.d.ts.map +1 -0
  9. package/{dist/maths → types}/algebra/monom.d.ts +98 -131
  10. package/types/algebra/monom.d.ts.map +1 -0
  11. package/types/algebra/polyFactor.d.ts +41 -0
  12. package/types/algebra/polyFactor.d.ts.map +1 -0
  13. package/types/algebra/polynom.d.ts +126 -0
  14. package/types/algebra/polynom.d.ts.map +1 -0
  15. package/types/algebra/rational.d.ts +41 -0
  16. package/types/algebra/rational.d.ts.map +1 -0
  17. package/{dist/maths → types}/coefficients/fraction.d.ts +69 -66
  18. package/types/coefficients/fraction.d.ts.map +1 -0
  19. package/{dist/maths → types}/coefficients/nthRoot.d.ts +3 -3
  20. package/{dist/maths → types}/geometry/circle.d.ts +10 -15
  21. package/types/geometry/circle.d.ts.map +1 -0
  22. package/types/geometry/geomMath.d.ts +10 -0
  23. package/types/geometry/geomMath.d.ts.map +1 -0
  24. package/{dist/maths → types}/geometry/line.d.ts +25 -35
  25. package/types/geometry/line.d.ts.map +1 -0
  26. package/types/geometry/line3.d.ts +50 -0
  27. package/types/geometry/line3.d.ts.map +1 -0
  28. package/types/geometry/plane3.d.ts +29 -0
  29. package/types/geometry/plane3.d.ts.map +1 -0
  30. package/types/geometry/vector.d.ts +70 -0
  31. package/types/geometry/vector.d.ts.map +1 -0
  32. package/types/geometry/vector3d.d.ts +37 -0
  33. package/types/geometry/vector3d.d.ts.map +1 -0
  34. package/types/index.d.ts +57 -0
  35. package/types/index.d.ts.map +1 -0
  36. package/types/numeric.d.ts +39 -0
  37. package/types/pimath.interface.d.ts +57 -0
  38. package/types/pimath.interface.d.ts.map +1 -0
  39. package/types/randomization/algebra/rndEquation.d.ts +4 -0
  40. package/types/randomization/algebra/rndEquation.d.ts.map +1 -0
  41. package/types/randomization/algebra/rndMonom.d.ts +4 -0
  42. package/types/randomization/algebra/rndMonom.d.ts.map +1 -0
  43. package/types/randomization/algebra/rndPolynom.d.ts +5 -0
  44. package/types/randomization/algebra/rndPolynom.d.ts.map +1 -0
  45. package/types/randomization/coefficient/rndFraction.d.ts +4 -0
  46. package/types/randomization/coefficient/rndFraction.d.ts.map +1 -0
  47. package/types/randomization/geometry/rndCircle.d.ts +4 -0
  48. package/types/randomization/geometry/rndCircle.d.ts.map +1 -0
  49. package/types/randomization/geometry/rndLine.d.ts +4 -0
  50. package/types/randomization/geometry/rndLine.d.ts.map +1 -0
  51. package/types/randomization/geometry/rndLine3.d.ts +4 -0
  52. package/types/randomization/geometry/rndLine3.d.ts.map +1 -0
  53. package/types/randomization/geometry/rndPoint.d.ts +4 -0
  54. package/types/randomization/geometry/rndPoint.d.ts.map +1 -0
  55. package/types/randomization/random.d.ts +20 -0
  56. package/types/randomization/random.d.ts.map +1 -0
  57. package/types/randomization/rndHelpers.d.ts +21 -0
  58. package/types/randomization/rndTypes.d.ts +64 -0
  59. package/types/randomization/rndTypes.d.ts.map +1 -0
  60. package/dist/main.d.ts +0 -1
  61. package/dist/maths/algebra/equation.d.ts +0 -120
  62. package/dist/maths/algebra/linearSystem.d.ts +0 -40
  63. package/dist/maths/algebra/logicalset.d.ts +0 -28
  64. package/dist/maths/algebra/polynom.d.ts +0 -155
  65. package/dist/maths/algebra/rational.d.ts +0 -44
  66. package/dist/maths/algebra/study/rationalStudy.d.ts +0 -14
  67. package/dist/maths/algebra/study.d.ts +0 -140
  68. package/dist/maths/geometry/point.d.ts +0 -36
  69. package/dist/maths/geometry/triangle.d.ts +0 -92
  70. package/dist/maths/geometry/vector.d.ts +0 -38
  71. package/dist/maths/numeric.d.ts +0 -28
  72. package/dist/maths/numexp.d.ts +0 -19
  73. package/dist/maths/randomization/random.d.ts +0 -26
  74. package/dist/maths/randomization/randomCore.d.ts +0 -7
  75. package/dist/maths/randomization/rndFraction.d.ts +0 -13
  76. package/dist/maths/randomization/rndGeometryCircle.d.ts +0 -13
  77. package/dist/maths/randomization/rndGeometryLine.d.ts +0 -13
  78. package/dist/maths/randomization/rndGeometryPoint.d.ts +0 -13
  79. package/dist/maths/randomization/rndHelpers.d.ts +0 -23
  80. package/dist/maths/randomization/rndMonom.d.ts +0 -13
  81. package/dist/maths/randomization/rndPolynom.d.ts +0 -14
  82. package/dist/maths/randomization/rndTypes.d.ts +0 -40
  83. package/dist/maths/shutingyard.d.ts +0 -59
  84. package/dist/pimath.d.ts +0 -39
  85. package/lib/main.ts +0 -1
  86. package/lib/maths/algebra/equation.ts +0 -891
  87. package/lib/maths/algebra/linearSystem.ts +0 -369
  88. package/lib/maths/algebra/logicalset.ts +0 -183
  89. package/lib/maths/algebra/monom.ts +0 -1027
  90. package/lib/maths/algebra/polynom.ts +0 -1537
  91. package/lib/maths/algebra/rational.ts +0 -244
  92. package/lib/maths/algebra/study/rationalStudy.ts +0 -287
  93. package/lib/maths/algebra/study.ts +0 -506
  94. package/lib/maths/coefficients/fraction.ts +0 -593
  95. package/lib/maths/coefficients/nthRoot.ts +0 -148
  96. package/lib/maths/geometry/circle.ts +0 -379
  97. package/lib/maths/geometry/line.ts +0 -604
  98. package/lib/maths/geometry/point.ts +0 -215
  99. package/lib/maths/geometry/triangle.ts +0 -368
  100. package/lib/maths/geometry/vector.ts +0 -243
  101. package/lib/maths/numeric.ts +0 -162
  102. package/lib/maths/numexp.ts +0 -198
  103. package/lib/maths/randomization/random.ts +0 -80
  104. package/lib/maths/randomization/randomCore.ts +0 -19
  105. package/lib/maths/randomization/rndFraction.ts +0 -47
  106. package/lib/maths/randomization/rndGeometryCircle.ts +0 -50
  107. package/lib/maths/randomization/rndGeometryLine.ts +0 -53
  108. package/lib/maths/randomization/rndGeometryPoint.ts +0 -69
  109. package/lib/maths/randomization/rndHelpers.ts +0 -107
  110. package/lib/maths/randomization/rndMonom.ts +0 -57
  111. package/lib/maths/randomization/rndPolynom.ts +0 -90
  112. package/lib/maths/randomization/rndTypes.ts +0 -43
  113. package/lib/maths/shutingyard.ts +0 -496
  114. package/lib/pimath.ts +0 -40
@@ -1,244 +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 displayFactors(): string {
66
- return `(${this._numerator.displayFactors})/(${this._denominator.displayFactors})`;
67
- }
68
-
69
- get plotFunction(): string {
70
- return `(${this._numerator.plotFunction})/(${this._denominator.plotFunction})`
71
- }
72
-
73
- clone = (): Rational => {
74
- return new Rational(
75
- this._numerator.clone(),
76
- this._denominator.clone()
77
- )
78
- }
79
-
80
- domain = (): string => {
81
- let zeroes = this._denominator.getZeroes();
82
-
83
- if (zeroes.length === 0 || zeroes[0].tex === PARTICULAR_SOLUTION.real) {
84
- return PARTICULAR_SOLUTION.varnothing
85
- } else if (zeroes[0].tex === PARTICULAR_SOLUTION.varnothing) {
86
- return PARTICULAR_SOLUTION.real
87
- } else {
88
- return '\\mathbb{R}\\setminus\\left\\{' +
89
- zeroes.map(x => x.tex).join(';') + '\\right\\}'
90
- }
91
- }
92
-
93
- amplify = (P: Polynom): Rational => {
94
- this._numerator.multiply(P);
95
- this._denominator.multiply(P);
96
-
97
- return this;
98
- }
99
-
100
- derivative = (letter?: string): Rational => {
101
- let N = this._numerator.clone(),
102
- D = this._denominator.clone(),
103
- dN = N.clone().derivative(letter),
104
- dD = D.clone().derivative(letter)
105
-
106
- this._numerator = dN.clone().multiply(D).subtract(N.clone().multiply(dD))
107
- this._denominator = D.clone().pow(2)
108
-
109
- return this
110
- }
111
-
112
- factorize = (letter?: string): Rational => {
113
- this._numerator.factorize(letter)
114
- this._denominator.factorize(letter)
115
- return this
116
- }
117
-
118
- simplify = (P: Polynom): Rational => {
119
- let NumeratorEuclidien = this._numerator.euclidian(P);
120
- if (!NumeratorEuclidien.reminder.isZero()) {
121
- return this;
122
- }
123
-
124
- let DenominatorEuclidien = this._denominator.euclidian(P);
125
- if (!DenominatorEuclidien.reminder.isZero()) {
126
- return this;
127
- }
128
-
129
- this._numerator = NumeratorEuclidien.quotient;
130
- this._denominator = DenominatorEuclidien.quotient;
131
- return this;
132
- }
133
-
134
- reduce = (): Rational => {
135
- this._numerator.factorize();
136
- for (let f of this._numerator.factors) {
137
-
138
- if (f.degree().isZero()) {
139
- // Do the simplify only if the factor can divide the denominator
140
- if (this._denominator.commonMonom().coefficient.clone().divide(f.monomByDegree().coefficient).isNatural()) {
141
- this.simplify(f);
142
- }
143
- } else {
144
- this.simplify(f);
145
- }
146
- }
147
-
148
- return this;
149
- }
150
-
151
- opposed = (): Rational => {
152
- this._numerator.opposed();
153
- return this;
154
- }
155
-
156
- add = (R: Rational): Rational => {
157
- // 1. Make sure both rational are at the same denominator
158
- // 2. Add the numerators.
159
- // 3. Simplify
160
-
161
- // Store the adding denominator
162
- let denominator = this._denominator.clone()
163
-
164
- // Amplif the main rational polynom by the adding denominator
165
- this.amplify(R._denominator)
166
-
167
- // Add to the numerator the adding value...
168
- this._numerator.add(R._numerator.clone().multiply(denominator));
169
-
170
- return this;
171
- }
172
-
173
- subtract = (R: Rational): Rational => {
174
- return this.add(R.clone().opposed())
175
- }
176
-
177
- euclidian = (): IEuclidian => {
178
- return this._numerator.euclidian(this._denominator)
179
- }
180
-
181
- // TODO : where and how is used limits ?
182
- limits = (value: Fraction | number, offset?: string, letter?: string): Fraction => {
183
- if (value === Infinity || value === -Infinity) {
184
- let {quotient, reminder} = this._numerator.clone().euclidian(this._denominator)
185
-
186
- // quotient is positive => it will be infinite.
187
- if (quotient.degree(letter).isStrictlyPositive()) {
188
- return value === Infinity ? quotient.limitToInfinity(letter) : quotient.limitToNegativeInfinity(letter)
189
- // return quotient.monomByDegree(undefined, letter).coefficient.sign()===1?(new Fraction()).infinite():(new Fraction()).infinite().opposed()
190
- } else {
191
- return quotient.monomByDegree(undefined, letter).coefficient
192
- }
193
- } else {
194
- let evalValues: literalType = {},
195
- evalValuesOffset: literalType = {},
196
- theLimit: Fraction | number,
197
- theSign: number,
198
- FR = this.clone().reduce()
199
-
200
- evalValues[letter === undefined ? 'x' : letter] = new Fraction(value)
201
-
202
- if (offset !== 'above' && offset !== 'below') {
203
- theLimit = FR._numerator.evaluate(evalValues)
204
- .divide(FR._denominator.evaluate(evalValues))
205
-
206
- return theLimit.isInfinity() ? theLimit.abs() : theLimit
207
- } else {
208
- if (offset === 'above') {
209
- evalValuesOffset[letter === undefined ? 'x' : letter] = (new Fraction(value)).add(0.000001)
210
- } else if (offset === 'below') {
211
- evalValuesOffset[letter === undefined ? 'x' : letter] = (new Fraction(value)).subtract(0.000001)
212
- }
213
-
214
- theLimit = FR._numerator.evaluate(evalValues)
215
- .divide(FR._denominator.evaluate(evalValues))
216
- theSign = FR._numerator.evaluate(evalValuesOffset)
217
- .divide(FR._denominator.evaluate(evalValuesOffset)).sign()
218
-
219
- if (theLimit.isInfinity()) {
220
- return theSign === 1 ? theLimit.abs() : theLimit.abs().opposed()
221
- } else {
222
- return theLimit
223
- }
224
- }
225
- }
226
- }
227
-
228
- evaluate = (values: literalType | Fraction | number): Fraction => {
229
- const r = new Fraction().zero();
230
-
231
- let N = this._numerator.evaluate(values),
232
- D = this._denominator.evaluate(values)
233
-
234
- return N.divide(D)
235
- };
236
-
237
- evaluateAsNumeric = (values: { [Key: string]: number } | number): number => {
238
- return this._numerator.evaluateAsNumeric(values) / this._denominator.evaluateAsNumeric(values)
239
- }
240
-
241
- study = (config?: StudyConfig | string): RationalStudy => {
242
- return new RationalStudy(this, config)
243
- }
244
- }
@@ -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
- }