pimath 0.0.128 → 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.
- package/dist/main.d.ts +39 -0
- package/dist/maths/algebra/equation.d.ts +120 -0
- package/dist/maths/algebra/linearSystem.d.ts +40 -0
- package/dist/maths/algebra/logicalset.d.ts +28 -0
- package/dist/maths/algebra/monom.d.ts +207 -0
- package/dist/maths/algebra/polynom.d.ts +155 -0
- package/dist/maths/algebra/rational.d.ts +44 -0
- package/dist/maths/algebra/study/rationalStudy.d.ts +14 -0
- package/dist/maths/algebra/study.d.ts +140 -0
- package/dist/maths/coefficients/fraction.d.ts +90 -0
- package/dist/maths/coefficients/nthRoot.d.ts +23 -0
- package/dist/maths/geometry/circle.d.ts +46 -0
- package/dist/maths/geometry/line.d.ts +102 -0
- package/dist/maths/geometry/point.d.ts +36 -0
- package/dist/maths/geometry/triangle.d.ts +92 -0
- package/dist/maths/geometry/vector.d.ts +38 -0
- package/dist/maths/numeric.d.ts +28 -0
- package/dist/maths/numexp.d.ts +19 -0
- package/dist/maths/randomization/random.d.ts +26 -0
- package/dist/maths/randomization/randomCore.d.ts +7 -0
- package/dist/maths/randomization/rndFraction.d.ts +13 -0
- package/dist/maths/randomization/rndGeometryCircle.d.ts +13 -0
- package/dist/maths/randomization/rndGeometryLine.d.ts +13 -0
- package/dist/maths/randomization/rndGeometryPoint.d.ts +13 -0
- package/dist/maths/randomization/rndHelpers.d.ts +23 -0
- package/dist/maths/randomization/rndMonom.d.ts +13 -0
- package/dist/maths/randomization/rndPolynom.d.ts +14 -0
- package/dist/maths/randomization/rndTypes.d.ts +40 -0
- package/dist/maths/shutingyard.d.ts +59 -0
- package/dist/pimath.js +85 -85
- package/package.json +10 -12
- package/.eslintrc.js +0 -24
- package/.idea/$CACHE_FILE$ +0 -6
- package/.idea/PI.iml +0 -14
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/php.xml +0 -19
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]/shelved.patch +0 -192
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]1/shelved.patch +0 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30__Default_Changelist_.xml +0 -4
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43_[Default_Changelist]/shelved.patch +0 -2404
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43__Default_Changelist_.xml +0 -4
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01_[Default_Changelist]/shelved.patch +0 -1362
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01__Default_Changelist_.xml +0 -4
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]/shelved.patch +0 -90
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_.xml +0 -4
- package/.idea/vcs.xml +0 -6
- package/dist/demo/exercises.html +0 -283
- package/dist/demo/matrices.html +0 -39
- package/dist/demo/playground.html +0 -20
- package/dist/demo.css +0 -3
- package/dist/pimath.umd.cjs +0 -15
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -78
- package/docs/assets/main.js +0 -59
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1383
- package/docs/classes/Logicalset.Logicalset.html +0 -217
- package/docs/classes/Polynom.Rational.html +0 -397
- package/docs/classes/Vector-1.Vector.html +0 -490
- package/docs/classes/Vector.Point.html +0 -337
- package/docs/classes/algebra_equation.Equation.html +0 -790
- package/docs/classes/algebra_linearSystem.LinearSystem.html +0 -404
- package/docs/classes/algebra_monom.Monom.html +0 -962
- package/docs/classes/algebra_polynom.Polynom.html +0 -1275
- package/docs/classes/coefficients_fraction.Fraction.html +0 -934
- package/docs/classes/geometry_circle.Circle.html +0 -472
- package/docs/classes/geometry_line.Line.html +0 -774
- package/docs/classes/geometry_triangle.Triangle.html +0 -429
- package/docs/classes/numeric.Numeric.html +0 -265
- package/docs/classes/shutingyard.Shutingyard.html +0 -250
- package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +0 -83
- package/docs/enums/geometry_line.LinePropriety.html +0 -97
- package/docs/enums/shutingyard.ShutingyardMode.html +0 -97
- package/docs/enums/shutingyard.ShutingyardType.html +0 -111
- package/docs/index.html +0 -63
- package/docs/interfaces/algebra_equation.ISolution.html +0 -105
- package/docs/interfaces/algebra_polynom.IEuclidian.html +0 -87
- package/docs/interfaces/geometry_triangle.remarquableLines.html +0 -163
- package/docs/modules/Logicalset.html +0 -65
- package/docs/modules/Polynom.html +0 -65
- package/docs/modules/Vector-1.html +0 -65
- package/docs/modules/Vector.html +0 -65
- package/docs/modules/algebra_equation.html +0 -69
- package/docs/modules/algebra_linearSystem.html +0 -61
- package/docs/modules/algebra_monom.html +0 -65
- package/docs/modules/algebra_polynom.html +0 -69
- package/docs/modules/coefficients_fraction.html +0 -65
- package/docs/modules/geometry_circle.html +0 -61
- package/docs/modules/geometry_line.html +0 -65
- package/docs/modules/geometry_triangle.html +0 -65
- package/docs/modules/numeric.html +0 -61
- package/docs/modules/shutingyard.html +0 -75
- package/docs/types/algebra_monom.literalType.html +0 -61
- package/docs/types/algebra_polynom.PolynomParsingType.html +0 -56
- package/docs/types/coefficients_fraction.FractionParsingType.html +0 -56
- package/docs/types/shutingyard.Token.html +0 -63
- package/docs/types/shutingyard.tokenType.html +0 -68
- package/docs/variables/shutingyard.tokenConstant.html +0 -61
- package/index.html +0 -15
- package/public/demo/exercises.html +0 -283
- package/public/demo/matrices.html +0 -39
- package/public/demo/playground.html +0 -20
- package/public/demo.css +0 -3
- package/src/demo/exercises.ts +0 -0
- package/src/demo/matrices.ts +0 -61
- package/src/demo/playground.ts +0 -153
- package/src/main.ts +0 -42
- package/src/maths/algebra/equation.ts +0 -897
- package/src/maths/algebra/linearSystem.ts +0 -370
- package/src/maths/algebra/logicalset.ts +0 -183
- package/src/maths/algebra/monom.ts +0 -1028
- package/src/maths/algebra/polynom.ts +0 -1537
- package/src/maths/algebra/rational.ts +0 -244
- package/src/maths/algebra/study/rationalStudy.ts +0 -287
- package/src/maths/algebra/study.ts +0 -506
- package/src/maths/coefficients/fraction.ts +0 -593
- package/src/maths/coefficients/nthRoot.ts +0 -148
- package/src/maths/geometry/circle.ts +0 -382
- package/src/maths/geometry/line.ts +0 -604
- package/src/maths/geometry/point.ts +0 -215
- package/src/maths/geometry/triangle.ts +0 -368
- package/src/maths/geometry/vector.ts +0 -242
- package/src/maths/numeric.ts +0 -162
- package/src/maths/numexp.ts +0 -184
- package/src/maths/randomization/random.ts +0 -80
- package/src/maths/randomization/randomCore.ts +0 -19
- package/src/maths/randomization/rndFraction.ts +0 -47
- package/src/maths/randomization/rndGeometryCircle.ts +0 -50
- package/src/maths/randomization/rndGeometryLine.ts +0 -53
- package/src/maths/randomization/rndGeometryPoint.ts +0 -69
- package/src/maths/randomization/rndHelpers.ts +0 -107
- package/src/maths/randomization/rndMonom.ts +0 -57
- package/src/maths/randomization/rndPolynom.ts +0 -90
- package/src/maths/randomization/rndTypes.ts +0 -43
- package/src/maths/shutingyard.ts +0 -496
- package/tests/algebra/equation.test.ts +0 -64
- package/tests/algebra/linear.test.ts +0 -58
- package/tests/algebra/monom.test.ts +0 -78
- package/tests/algebra/polynom.test.ts +0 -343
- package/tests/algebra/rationnal.test.ts +0 -64
- package/tests/algebra/study.test.ts +0 -48
- package/tests/coefficients/fraction.test.ts +0 -131
- package/tests/custom.test.ts +0 -33
- package/tests/geometry/circle.test.ts +0 -404
- package/tests/geometry/line.test.ts +0 -36
- package/tests/numeric.test.ts +0 -43
- package/tests/numexp.test.ts +0 -89
- package/tests/shutingyard.test.ts +0 -58
- package/tsconfig.json +0 -52
- package/tsconfig.testing.json +0 -28
- package/typedoc.katex.js +0 -11
- package/vite.config.js +0 -23
- package/webpack-production-min.config.js +0 -26
- package/webpack-production.config.js +0 -26
- package/webpack.config.js +0 -26
|
@@ -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
|
-
}
|