pimath 0.0.119 → 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.
- package/.eslintrc.js +23 -23
- package/.idea/PI.iml +7 -1
- package/dev/pimath.js +7929 -0
- package/dev/pimath.js.map +1 -0
- package/dist/{pi.js → pimath.js} +7612 -7829
- package/dist/pimath.js.map +1 -0
- package/dist/pimath.min.js +2 -0
- package/dist/pimath.min.js.map +1 -0
- package/docs/assets/main.js +3 -3
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +450 -363
- package/docs/classes/Logicalset.Logicalset.html +119 -110
- package/docs/classes/Polynom.Rational.html +230 -227
- package/docs/classes/Vector-1.Vector.html +319 -273
- package/docs/classes/Vector.Point.html +189 -190
- package/docs/classes/algebra_equation.Equation.html +489 -446
- package/docs/classes/algebra_linearSystem.LinearSystem.html +228 -217
- package/docs/classes/algebra_monom.Monom.html +564 -507
- package/docs/classes/algebra_polynom.Polynom.html +774 -753
- package/docs/classes/coefficients_fraction.Fraction.html +573 -565
- package/docs/classes/geometry_circle.Circle.html +299 -299
- package/docs/classes/geometry_line.Line.html +511 -451
- package/docs/classes/geometry_triangle.Triangle.html +273 -264
- package/docs/classes/numeric.Numeric.html +138 -132
- package/docs/classes/shutingyard.Shutingyard.html +144 -133
- package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +47 -46
- package/docs/enums/geometry_line.LinePropriety.html +58 -58
- package/docs/enums/shutingyard.ShutingyardMode.html +62 -58
- package/docs/enums/shutingyard.ShutingyardType.html +74 -70
- package/docs/index.html +31 -33
- package/docs/interfaces/algebra_equation.ISolution.html +61 -59
- package/docs/interfaces/algebra_polynom.IEuclidian.html +47 -46
- package/docs/interfaces/geometry_triangle.remarquableLines.html +74 -74
- package/docs/modules/Logicalset.html +33 -38
- package/docs/modules/Polynom.html +33 -38
- package/docs/modules/Vector-1.html +33 -38
- package/docs/modules/Vector.html +33 -38
- package/docs/modules/algebra_equation.html +35 -41
- package/docs/modules/algebra_linearSystem.html +31 -37
- package/docs/modules/algebra_monom.html +33 -39
- package/docs/modules/algebra_polynom.html +35 -41
- package/docs/modules/coefficients_fraction.html +33 -39
- package/docs/modules/geometry_circle.html +31 -37
- package/docs/modules/geometry_line.html +33 -39
- package/docs/modules/geometry_triangle.html +33 -39
- package/docs/modules/numeric.html +31 -37
- package/docs/modules/shutingyard.html +41 -47
- package/docs/types/algebra_monom.literalType.html +33 -37
- package/docs/types/algebra_polynom.PolynomParsingType.html +33 -37
- package/docs/types/coefficients_fraction.FractionParsingType.html +32 -36
- package/docs/types/shutingyard.Token.html +38 -42
- package/docs/types/shutingyard.tokenType.html +40 -44
- package/docs/variables/shutingyard.tokenConstant.html +37 -41
- package/esm/index.d.ts +38 -41
- package/esm/index.js +43 -46
- package/esm/index.js.map +1 -1
- package/esm/maths/algebra/equation.d.ts +119 -117
- package/esm/maths/algebra/equation.js +796 -785
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/algebra/linearSystem.d.ts +39 -38
- package/esm/maths/algebra/linearSystem.js +278 -262
- package/esm/maths/algebra/linearSystem.js.map +1 -1
- package/esm/maths/algebra/logicalset.d.ts +28 -28
- package/esm/maths/algebra/logicalset.js +157 -157
- package/esm/maths/algebra/monom.d.ts +206 -206
- package/esm/maths/algebra/monom.js +908 -908
- package/esm/maths/algebra/monom.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +157 -157
- package/esm/maths/algebra/polynom.js +1277 -1277
- package/esm/maths/algebra/rational.d.ts +45 -45
- package/esm/maths/algebra/rational.js +183 -183
- package/esm/maths/algebra/study/rationalStudy.d.ts +28 -28
- package/esm/maths/algebra/study/rationalStudy.js +243 -243
- package/esm/maths/algebra/study.d.ts +142 -142
- package/esm/maths/algebra/study.js +377 -377
- package/esm/maths/algebra/study.js.map +1 -1
- package/esm/maths/coefficients/fraction.d.ts +90 -90
- package/esm/maths/coefficients/fraction.js +516 -516
- package/esm/maths/coefficients/fraction.js.map +1 -1
- package/esm/maths/coefficients/nthRoot.d.ts +23 -23
- package/esm/maths/coefficients/nthRoot.js +136 -136
- package/esm/maths/geometry/circle.d.ts +45 -45
- package/esm/maths/geometry/circle.js +323 -323
- package/esm/maths/geometry/line.d.ts +99 -99
- package/esm/maths/geometry/line.js +481 -481
- package/esm/maths/geometry/line.js.map +1 -1
- package/esm/maths/geometry/point.d.ts +34 -34
- package/esm/maths/geometry/point.js +166 -166
- package/esm/maths/geometry/point.js.map +1 -1
- package/esm/maths/geometry/triangle.d.ts +85 -85
- package/esm/maths/geometry/triangle.js +268 -268
- package/esm/maths/geometry/vector.d.ts +41 -41
- package/esm/maths/geometry/vector.js +197 -197
- package/esm/maths/geometry/vector.js.map +1 -1
- package/esm/maths/numeric.d.ts +28 -28
- package/esm/maths/numeric.js +180 -169
- package/esm/maths/numeric.js.map +1 -1
- package/esm/maths/numexp.d.ts +19 -0
- package/esm/maths/numexp.js +186 -0
- package/esm/maths/numexp.js.map +1 -0
- package/esm/maths/randomization/random.d.ts +23 -23
- package/esm/maths/randomization/random.js +78 -78
- package/esm/maths/randomization/random.js.map +1 -1
- package/esm/maths/randomization/randomCore.d.ts +7 -7
- package/esm/maths/randomization/randomCore.js +21 -21
- package/esm/maths/randomization/rndFraction.d.ts +12 -12
- package/esm/maths/randomization/rndFraction.js +43 -43
- package/esm/maths/randomization/rndGeometryLine.d.ts +12 -12
- package/esm/maths/randomization/rndGeometryLine.js +45 -45
- package/esm/maths/randomization/rndGeometryPoint.d.ts +12 -12
- package/esm/maths/randomization/rndGeometryPoint.js +60 -60
- package/esm/maths/randomization/rndHelpers.d.ts +23 -23
- package/esm/maths/randomization/rndHelpers.js +76 -76
- package/esm/maths/randomization/rndMonom.d.ts +12 -12
- package/esm/maths/randomization/rndMonom.js +52 -52
- package/esm/maths/randomization/rndPolynom.d.ts +13 -13
- package/esm/maths/randomization/rndPolynom.js +74 -74
- package/esm/maths/randomization/rndTypes.d.ts +34 -34
- package/esm/maths/randomization/rndTypes.js +2 -2
- package/esm/maths/shutingyard.d.ts +59 -59
- package/esm/maths/shutingyard.js +442 -442
- package/esm/maths/shutingyard.js.map +1 -1
- package/package.json +11 -11
- package/public/index.html +50 -81
- package/public/playground.html +7 -8
- package/src/index.ts +2 -5
- package/src/maths/algebra/equation.ts +16 -0
- package/src/maths/algebra/linearSystem.ts +20 -0
- package/src/maths/algebra/study.ts +1 -1
- package/src/maths/numeric.ts +49 -48
- package/src/maths/{expressions/numexp.ts → numexp.ts} +2 -2
- package/tests/algebra/equation.test.ts +19 -5
- package/tests/algebra/linear.test.ts +3 -11
- package/tests/algebra/polynom.test.ts +7 -8
- package/tests/algebra/rationnal.test.ts +1 -1
- package/tests/algebra/study.test.ts +2 -9
- package/tests/coefficients/fraction.test.ts +8 -8
- package/tests/custom.test.ts +33 -37
- package/tests/numeric.test.ts +1 -2
- package/tests/numexp.test.ts +1 -5
- package/tests/shutingyard.test.ts +3 -3
- package/webpack-production-min.config.js +1 -1
- package/webpack-production.config.js +1 -1
- package/webpack.config.js +1 -1
- package/dist/pi.js.map +0 -1
- package/dist/pi.min.js +0 -2
- package/dist/pi.min.js.map +0 -1
- package/docs/classes/expressions_numexp.NumExp.html +0 -236
- package/docs/classes/expressions_polynomexp.PolynomExpFactor.html +0 -317
- package/docs/classes/expressions_polynomexp.PolynomExpProduct.html +0 -285
- package/docs/modules/expressions_numexp.html +0 -71
- package/docs/modules/expressions_polynomexp.html +0 -73
- package/docs/modules.html +0 -76
- package/graph.svg +0 -1033
- package/src/maths/expressions/ExpressionTree.ts +0 -172
- package/src/maths/expressions/expression.ts +0 -286
- package/src/maths/expressions/expressionFactor.ts +0 -190
- package/src/maths/expressions/expressionMember.ts +0 -233
- package/src/maths/expressions/expressionOperators.ts +0 -49
- package/src/maths/expressions/expressionParser.ts +0 -295
- package/src/maths/expressions/factors/ExpFactor.ts +0 -39
- package/src/maths/expressions/factors/ExpFactorConstant.ts +0 -60
- package/src/maths/expressions/factors/ExpFactorExponential.ts +0 -26
- package/src/maths/expressions/factors/ExpFactorNumber.ts +0 -72
- package/src/maths/expressions/factors/ExpFactorPower.ts +0 -42
- package/src/maths/expressions/factors/ExpFactorTrigo.ts +0 -53
- package/src/maths/expressions/factors/ExpFactorVariable.ts +0 -45
- package/src/maths/expressions/internals.ts +0 -14
- package/src/maths/expressions/polynomexp.bkp.ts +0 -221
- package/src/maths/expressions/polynomexp.ts +0 -310
- package/tests/expressions/expressions.test.ts +0 -145
- package/tests/expressions/expressiontree.test.ts +0 -11
- package/tests/polynomexp.test.ts +0 -12
|
@@ -1,379 +1,379 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Rational polynom module contains everything necessary to handle rational polynoms.
|
|
4
|
-
* @module Polynom
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.Study = exports.TABLE_OF_SIGNS = exports.FUNCTION_EXTREMA = exports.ASYMPTOTE_POSITION = exports.ASYMPTOTE = exports.ZEROTYPE = void 0;
|
|
8
|
-
const fraction_1 = require("../coefficients/fraction");
|
|
9
|
-
const numexp_1 = require("../
|
|
10
|
-
var ZEROTYPE;
|
|
11
|
-
(function (ZEROTYPE) {
|
|
12
|
-
ZEROTYPE["ZERO"] = "z";
|
|
13
|
-
ZEROTYPE["DEFENCE"] = "d";
|
|
14
|
-
ZEROTYPE["NOTHING"] = "t";
|
|
15
|
-
})(ZEROTYPE
|
|
16
|
-
var ASYMPTOTE;
|
|
17
|
-
(function (ASYMPTOTE) {
|
|
18
|
-
ASYMPTOTE["VERTICAL"] = "av";
|
|
19
|
-
ASYMPTOTE["HORIZONTAL"] = "ah";
|
|
20
|
-
ASYMPTOTE["SLOPE"] = "ao";
|
|
21
|
-
ASYMPTOTE["HOLE"] = "hole";
|
|
22
|
-
})(ASYMPTOTE
|
|
23
|
-
var ASYMPTOTE_POSITION;
|
|
24
|
-
(function (ASYMPTOTE_POSITION) {
|
|
25
|
-
ASYMPTOTE_POSITION["LT"] = "LT";
|
|
26
|
-
ASYMPTOTE_POSITION["RT"] = "RT";
|
|
27
|
-
ASYMPTOTE_POSITION["LB"] = "LB";
|
|
28
|
-
ASYMPTOTE_POSITION["RB"] = "RB";
|
|
29
|
-
})(ASYMPTOTE_POSITION
|
|
30
|
-
var FUNCTION_EXTREMA;
|
|
31
|
-
(function (FUNCTION_EXTREMA) {
|
|
32
|
-
FUNCTION_EXTREMA["MIN"] = "min";
|
|
33
|
-
FUNCTION_EXTREMA["MAX"] = "max";
|
|
34
|
-
FUNCTION_EXTREMA["FLAT"] = "flat";
|
|
35
|
-
FUNCTION_EXTREMA["NOTHING"] = "";
|
|
36
|
-
})(FUNCTION_EXTREMA
|
|
37
|
-
var TABLE_OF_SIGNS;
|
|
38
|
-
(function (TABLE_OF_SIGNS) {
|
|
39
|
-
TABLE_OF_SIGNS["SIGNS"] = "signs";
|
|
40
|
-
TABLE_OF_SIGNS["GROWS"] = "grows";
|
|
41
|
-
TABLE_OF_SIGNS["VARIATIONS"] = "variatins";
|
|
42
|
-
})(TABLE_OF_SIGNS
|
|
43
|
-
/**
|
|
44
|
-
* The study class is a "function study" class that will get:
|
|
45
|
-
* fx : get the function
|
|
46
|
-
* domain : string
|
|
47
|
-
* zeroes : Object (tex, IZero)
|
|
48
|
-
* signs : table of signs + tex output using tkz-tab
|
|
49
|
-
* av : vertical asymptotic
|
|
50
|
-
* ah : horizontal asymptotic
|
|
51
|
-
* ao : obliques
|
|
52
|
-
* deltaX : position relative
|
|
53
|
-
* dx : derivative
|
|
54
|
-
* grows : growing table + tex output using tkz-tab
|
|
55
|
-
* ddx : dérivée seconde
|
|
56
|
-
* variations : variation table + tex output using tkz-tab
|
|
57
|
-
*/
|
|
58
|
-
class Study {
|
|
59
|
-
constructor(fx, config) {
|
|
60
|
-
this.makeStudy = () => {
|
|
61
|
-
this._zeroes = this.makeZeroes();
|
|
62
|
-
if (this._config.signs)
|
|
63
|
-
this._signs = this.makeSigns();
|
|
64
|
-
if (this._config.asymptotes)
|
|
65
|
-
this._asymptotes = this.makeAsymptotes();
|
|
66
|
-
if (this._config.derivative)
|
|
67
|
-
this._derivative = this.makeDerivative();
|
|
68
|
-
if (this._config.variations)
|
|
69
|
-
this._variations = this.makeVariation();
|
|
70
|
-
// Table of signs / derivative / variation
|
|
71
|
-
if (this._config.signs)
|
|
72
|
-
this._signs.tex = this.texSigns;
|
|
73
|
-
if (this._config.derivative)
|
|
74
|
-
this._derivative.tex = this.texGrows;
|
|
75
|
-
if (this._config.variations)
|
|
76
|
-
this._variations.tex = this.texVariations;
|
|
77
|
-
};
|
|
78
|
-
this.indexOfZero = (zeroes, zero) => {
|
|
79
|
-
for (let i = 0; i < zeroes.length; i++) {
|
|
80
|
-
if (zeroes[i].tex === zero.tex) {
|
|
81
|
-
return i;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return -1;
|
|
85
|
-
};
|
|
86
|
-
this.makeOneLineForSigns = (factor, zeroes, zeroSign) => {
|
|
87
|
-
let oneLine = [], currentZero = factor.getZeroes().map(x => x.tex);
|
|
88
|
-
// First +/- sign, before the first zero
|
|
89
|
-
oneLine.push('');
|
|
90
|
-
if (factor.degree().isZero()) {
|
|
91
|
-
oneLine.push(factor.monoms[0].coefficient.sign() === 1 ? '+' : '-');
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
oneLine.push(factor.evaluate(zeroes[0].value - 1).sign() === 1 ? '+' : '-');
|
|
95
|
-
}
|
|
96
|
-
for (let i = 0; i < zeroes.length; i++) {
|
|
97
|
-
// Add the zero if it's the current one
|
|
98
|
-
oneLine.push(currentZero.includes(zeroes[i].tex) ? zeroSign : ZEROTYPE.NOTHING);
|
|
99
|
-
// + / - sign after the current zero
|
|
100
|
-
if (i < zeroes.length - 1) {
|
|
101
|
-
oneLine.push(factor.evaluate((zeroes[i].value + zeroes[i + 1].value) / 2).sign() === 1 ? '+' : '-');
|
|
102
|
-
}
|
|
103
|
-
else if (i === zeroes.length - 1) {
|
|
104
|
-
oneLine.push(factor.evaluate(zeroes[i].value + 1).sign() === 1 ? '+' : '-');
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
oneLine.push('');
|
|
108
|
-
return oneLine;
|
|
109
|
-
};
|
|
110
|
-
this.makeSignsResult = (signs) => {
|
|
111
|
-
// Initialize the result line with the first line of the signs table
|
|
112
|
-
let resultLine = signs[0].map((x, index) => {
|
|
113
|
-
if (index === 0 || index === signs[0].length - 1) {
|
|
114
|
-
return '';
|
|
115
|
-
}
|
|
116
|
-
if (index % 2 === 0) {
|
|
117
|
-
return 't';
|
|
118
|
-
}
|
|
119
|
-
return '+';
|
|
120
|
-
});
|
|
121
|
-
// Go through each lines (except the first)
|
|
122
|
-
for (let current of signs) {
|
|
123
|
-
for (let i = 0; i < current.length; i++) {
|
|
124
|
-
if (i % 2 === 0) {
|
|
125
|
-
// t, z or d
|
|
126
|
-
if (resultLine[i] === 'd') {
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
if (current[i] !== 't') {
|
|
130
|
-
resultLine[i] = current[i];
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
// + or -
|
|
135
|
-
if (current[i] === '-') {
|
|
136
|
-
resultLine[i] = resultLine[i] === '+' ? '-' : '+';
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return resultLine;
|
|
142
|
-
};
|
|
143
|
-
this.makeGrowsResult = (tos) => {
|
|
144
|
-
// Use the last line (=> resultLine) to grab the necessary information
|
|
145
|
-
let signsAsArray = Object.values(tos.signs), resultLine = signsAsArray[signsAsArray.length - 1], growsLine = [], extremes = {}, zeroes = tos.zeroes;
|
|
146
|
-
// Get the extremes
|
|
147
|
-
for (let i = 0; i < zeroes.length; i++) {
|
|
148
|
-
// Get the corresponding item in the resultLine.
|
|
149
|
-
let pos = 2 * i + 2;
|
|
150
|
-
if (resultLine[pos] === 'z') {
|
|
151
|
-
// It's a zero. Get the coordinates
|
|
152
|
-
let x, y, zero = zeroes[i].exact, pt, xTex, yTex, pointType;
|
|
153
|
-
// TODO: NumExp should parse something that isn't yet plotFunction
|
|
154
|
-
let exp = new numexp_1.NumExp(this.fx.plotFunction);
|
|
155
|
-
if (zero instanceof fraction_1.Fraction) {
|
|
156
|
-
let value = zero, evalY = this.fx.evaluate(value);
|
|
157
|
-
x = zero.value;
|
|
158
|
-
y = evalY.value;
|
|
159
|
-
xTex = zero.tex;
|
|
160
|
-
yTex = evalY.tex;
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
x = zeroes[i].value;
|
|
164
|
-
y = exp.evaluate({ x });
|
|
165
|
-
xTex = x.toFixed(2);
|
|
166
|
-
yTex = y.toFixed(2);
|
|
167
|
-
}
|
|
168
|
-
// Determine the type of the zero.
|
|
169
|
-
if (resultLine[pos - 1] === resultLine[pos + 1]) {
|
|
170
|
-
pointType = FUNCTION_EXTREMA.FLAT;
|
|
171
|
-
}
|
|
172
|
-
else if (resultLine[pos - 1] === '+') {
|
|
173
|
-
pointType = FUNCTION_EXTREMA.MAX;
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
pointType = FUNCTION_EXTREMA.MIN;
|
|
177
|
-
}
|
|
178
|
-
// Add the point to the list
|
|
179
|
-
extremes[zeroes[i].tex] = {
|
|
180
|
-
type: pointType,
|
|
181
|
-
tex: { x: xTex, y: yTex },
|
|
182
|
-
value: { x, y }
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
// Create the grows line, based on tkz-tab
|
|
187
|
-
// \tkzTabLine{ , + , z , - , d , - , z , + , }
|
|
188
|
-
// \tkzTabVar{ -/ , +/$3$ , -D+/ , -/$1$ , +/ }
|
|
189
|
-
growsLine.push(resultLine[1] === '+' ? '-/' : '+/');
|
|
190
|
-
for (let i = 1; i < resultLine.length - 1; i++) {
|
|
191
|
-
if (resultLine[i] === "z") {
|
|
192
|
-
let extr = extremes[zeroes[(i - 2) / 2].tex];
|
|
193
|
-
growsLine.push(`${resultLine[i - 1]}/\\(${extr.type}(${extr.tex.x};${extr.tex.y})\\)`);
|
|
194
|
-
}
|
|
195
|
-
else if (resultLine[i] === 'd') {
|
|
196
|
-
growsLine.push(`${resultLine[i - 1]}D${resultLine[i + 1] === '+' ? '-' : '+'}/`);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
growsLine.push(`${resultLine[resultLine.length - 2]}/`);
|
|
200
|
-
return { growsLine, extremes };
|
|
201
|
-
};
|
|
202
|
-
this.makeVariationsResult = (tos) => {
|
|
203
|
-
// TODO: make variations result is not yet implemented.
|
|
204
|
-
let extremes = {}, varsLine = [];
|
|
205
|
-
return { varsLine, extremes };
|
|
206
|
-
};
|
|
207
|
-
this.drawCode = () => {
|
|
208
|
-
// Function as string
|
|
209
|
-
let code = `f(x)=${this.fx.plotFunction}`;
|
|
210
|
-
// Asymptotes
|
|
211
|
-
let i = 1;
|
|
212
|
-
this.asymptotes.forEach(asymptote => {
|
|
213
|
-
if (asymptote.type === ASYMPTOTE.VERTICAL) {
|
|
214
|
-
code += `\nav_${i}=line x=${asymptote.zero.value}->red,dash`;
|
|
215
|
-
i++;
|
|
216
|
-
}
|
|
217
|
-
else if (asymptote.type === ASYMPTOTE.HORIZONTAL) {
|
|
218
|
-
code += `\nah=line y=${asymptote.fx.monoms[0].coefficient.value}->orange,dash`;
|
|
219
|
-
}
|
|
220
|
-
else if (asymptote.type === ASYMPTOTE.SLOPE) {
|
|
221
|
-
code += `\nao=line y=${asymptote.fx.plotFunction}->red,dash`;
|
|
222
|
-
}
|
|
223
|
-
i++;
|
|
224
|
-
});
|
|
225
|
-
// Extremes
|
|
226
|
-
for (let zero in this.derivative.extremes) {
|
|
227
|
-
let extreme = this.derivative.extremes[zero];
|
|
228
|
-
code += `\nM_${i}(${extreme.value.x},${extreme.value.y})*`;
|
|
229
|
-
i++;
|
|
230
|
-
}
|
|
231
|
-
// Zeroes
|
|
232
|
-
this.zeroes.forEach(zero => {
|
|
233
|
-
if (zero.type === ZEROTYPE.ZERO) {
|
|
234
|
-
code += `\nZ_${i}(${zero.value},0)*`;
|
|
235
|
-
i++;
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
return code;
|
|
239
|
-
};
|
|
240
|
-
this._makeTexFromTableOfSigns = (tos) => {
|
|
241
|
-
let factors = tos.factors.map(x => `\\(${x.tex}\\)/1`), factorsFx = `\\(${this._name}(x)\\)/1.2`, zeroes = tos.zeroes;
|
|
242
|
-
// Add the last lines "label"
|
|
243
|
-
if (tos.type === TABLE_OF_SIGNS.GROWS) {
|
|
244
|
-
factorsFx = `\\(${this._name}'(x)\\)/1.2,\\(f(x)\\)/2`;
|
|
245
|
-
}
|
|
246
|
-
else if (tos.type === TABLE_OF_SIGNS.VARIATIONS) {
|
|
247
|
-
factorsFx = `\\(${this._name}''(x)\\)/1.2,\\(f(x)\\)/2`;
|
|
248
|
-
}
|
|
249
|
-
// Create the tikzPicture header
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Rational polynom module contains everything necessary to handle rational polynoms.
|
|
4
|
+
* @module Polynom
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.Study = exports.TABLE_OF_SIGNS = exports.FUNCTION_EXTREMA = exports.ASYMPTOTE_POSITION = exports.ASYMPTOTE = exports.ZEROTYPE = void 0;
|
|
8
|
+
const fraction_1 = require("../coefficients/fraction");
|
|
9
|
+
const numexp_1 = require("../numexp");
|
|
10
|
+
var ZEROTYPE;
|
|
11
|
+
(function (ZEROTYPE) {
|
|
12
|
+
ZEROTYPE["ZERO"] = "z";
|
|
13
|
+
ZEROTYPE["DEFENCE"] = "d";
|
|
14
|
+
ZEROTYPE["NOTHING"] = "t";
|
|
15
|
+
})(ZEROTYPE || (exports.ZEROTYPE = ZEROTYPE = {}));
|
|
16
|
+
var ASYMPTOTE;
|
|
17
|
+
(function (ASYMPTOTE) {
|
|
18
|
+
ASYMPTOTE["VERTICAL"] = "av";
|
|
19
|
+
ASYMPTOTE["HORIZONTAL"] = "ah";
|
|
20
|
+
ASYMPTOTE["SLOPE"] = "ao";
|
|
21
|
+
ASYMPTOTE["HOLE"] = "hole";
|
|
22
|
+
})(ASYMPTOTE || (exports.ASYMPTOTE = ASYMPTOTE = {}));
|
|
23
|
+
var ASYMPTOTE_POSITION;
|
|
24
|
+
(function (ASYMPTOTE_POSITION) {
|
|
25
|
+
ASYMPTOTE_POSITION["LT"] = "LT";
|
|
26
|
+
ASYMPTOTE_POSITION["RT"] = "RT";
|
|
27
|
+
ASYMPTOTE_POSITION["LB"] = "LB";
|
|
28
|
+
ASYMPTOTE_POSITION["RB"] = "RB";
|
|
29
|
+
})(ASYMPTOTE_POSITION || (exports.ASYMPTOTE_POSITION = ASYMPTOTE_POSITION = {}));
|
|
30
|
+
var FUNCTION_EXTREMA;
|
|
31
|
+
(function (FUNCTION_EXTREMA) {
|
|
32
|
+
FUNCTION_EXTREMA["MIN"] = "min";
|
|
33
|
+
FUNCTION_EXTREMA["MAX"] = "max";
|
|
34
|
+
FUNCTION_EXTREMA["FLAT"] = "flat";
|
|
35
|
+
FUNCTION_EXTREMA["NOTHING"] = "";
|
|
36
|
+
})(FUNCTION_EXTREMA || (exports.FUNCTION_EXTREMA = FUNCTION_EXTREMA = {}));
|
|
37
|
+
var TABLE_OF_SIGNS;
|
|
38
|
+
(function (TABLE_OF_SIGNS) {
|
|
39
|
+
TABLE_OF_SIGNS["SIGNS"] = "signs";
|
|
40
|
+
TABLE_OF_SIGNS["GROWS"] = "grows";
|
|
41
|
+
TABLE_OF_SIGNS["VARIATIONS"] = "variatins";
|
|
42
|
+
})(TABLE_OF_SIGNS || (exports.TABLE_OF_SIGNS = TABLE_OF_SIGNS = {}));
|
|
43
|
+
/**
|
|
44
|
+
* The study class is a "function study" class that will get:
|
|
45
|
+
* fx : get the function
|
|
46
|
+
* domain : string
|
|
47
|
+
* zeroes : Object (tex, IZero)
|
|
48
|
+
* signs : table of signs + tex output using tkz-tab
|
|
49
|
+
* av : vertical asymptotic
|
|
50
|
+
* ah : horizontal asymptotic
|
|
51
|
+
* ao : obliques
|
|
52
|
+
* deltaX : position relative
|
|
53
|
+
* dx : derivative
|
|
54
|
+
* grows : growing table + tex output using tkz-tab
|
|
55
|
+
* ddx : dérivée seconde
|
|
56
|
+
* variations : variation table + tex output using tkz-tab
|
|
57
|
+
*/
|
|
58
|
+
class Study {
|
|
59
|
+
constructor(fx, config) {
|
|
60
|
+
this.makeStudy = () => {
|
|
61
|
+
this._zeroes = this.makeZeroes();
|
|
62
|
+
if (this._config.signs)
|
|
63
|
+
this._signs = this.makeSigns();
|
|
64
|
+
if (this._config.asymptotes)
|
|
65
|
+
this._asymptotes = this.makeAsymptotes();
|
|
66
|
+
if (this._config.derivative)
|
|
67
|
+
this._derivative = this.makeDerivative();
|
|
68
|
+
if (this._config.variations)
|
|
69
|
+
this._variations = this.makeVariation();
|
|
70
|
+
// Table of signs / derivative / variation
|
|
71
|
+
if (this._config.signs)
|
|
72
|
+
this._signs.tex = this.texSigns;
|
|
73
|
+
if (this._config.derivative)
|
|
74
|
+
this._derivative.tex = this.texGrows;
|
|
75
|
+
if (this._config.variations)
|
|
76
|
+
this._variations.tex = this.texVariations;
|
|
77
|
+
};
|
|
78
|
+
this.indexOfZero = (zeroes, zero) => {
|
|
79
|
+
for (let i = 0; i < zeroes.length; i++) {
|
|
80
|
+
if (zeroes[i].tex === zero.tex) {
|
|
81
|
+
return i;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return -1;
|
|
85
|
+
};
|
|
86
|
+
this.makeOneLineForSigns = (factor, zeroes, zeroSign) => {
|
|
87
|
+
let oneLine = [], currentZero = factor.getZeroes().map(x => x.tex);
|
|
88
|
+
// First +/- sign, before the first zero
|
|
89
|
+
oneLine.push('');
|
|
90
|
+
if (factor.degree().isZero()) {
|
|
91
|
+
oneLine.push(factor.monoms[0].coefficient.sign() === 1 ? '+' : '-');
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
oneLine.push(factor.evaluate(zeroes[0].value - 1).sign() === 1 ? '+' : '-');
|
|
95
|
+
}
|
|
96
|
+
for (let i = 0; i < zeroes.length; i++) {
|
|
97
|
+
// Add the zero if it's the current one
|
|
98
|
+
oneLine.push(currentZero.includes(zeroes[i].tex) ? zeroSign : ZEROTYPE.NOTHING);
|
|
99
|
+
// + / - sign after the current zero
|
|
100
|
+
if (i < zeroes.length - 1) {
|
|
101
|
+
oneLine.push(factor.evaluate((zeroes[i].value + zeroes[i + 1].value) / 2).sign() === 1 ? '+' : '-');
|
|
102
|
+
}
|
|
103
|
+
else if (i === zeroes.length - 1) {
|
|
104
|
+
oneLine.push(factor.evaluate(zeroes[i].value + 1).sign() === 1 ? '+' : '-');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
oneLine.push('');
|
|
108
|
+
return oneLine;
|
|
109
|
+
};
|
|
110
|
+
this.makeSignsResult = (signs) => {
|
|
111
|
+
// Initialize the result line with the first line of the signs table
|
|
112
|
+
let resultLine = signs[0].map((x, index) => {
|
|
113
|
+
if (index === 0 || index === signs[0].length - 1) {
|
|
114
|
+
return '';
|
|
115
|
+
}
|
|
116
|
+
if (index % 2 === 0) {
|
|
117
|
+
return 't';
|
|
118
|
+
}
|
|
119
|
+
return '+';
|
|
120
|
+
});
|
|
121
|
+
// Go through each lines (except the first)
|
|
122
|
+
for (let current of signs) {
|
|
123
|
+
for (let i = 0; i < current.length; i++) {
|
|
124
|
+
if (i % 2 === 0) {
|
|
125
|
+
// t, z or d
|
|
126
|
+
if (resultLine[i] === 'd') {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (current[i] !== 't') {
|
|
130
|
+
resultLine[i] = current[i];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
// + or -
|
|
135
|
+
if (current[i] === '-') {
|
|
136
|
+
resultLine[i] = resultLine[i] === '+' ? '-' : '+';
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return resultLine;
|
|
142
|
+
};
|
|
143
|
+
this.makeGrowsResult = (tos) => {
|
|
144
|
+
// Use the last line (=> resultLine) to grab the necessary information
|
|
145
|
+
let signsAsArray = Object.values(tos.signs), resultLine = signsAsArray[signsAsArray.length - 1], growsLine = [], extremes = {}, zeroes = tos.zeroes;
|
|
146
|
+
// Get the extremes
|
|
147
|
+
for (let i = 0; i < zeroes.length; i++) {
|
|
148
|
+
// Get the corresponding item in the resultLine.
|
|
149
|
+
let pos = 2 * i + 2;
|
|
150
|
+
if (resultLine[pos] === 'z') {
|
|
151
|
+
// It's a zero. Get the coordinates
|
|
152
|
+
let x, y, zero = zeroes[i].exact, pt, xTex, yTex, pointType;
|
|
153
|
+
// TODO: NumExp should parse something that isn't yet plotFunction
|
|
154
|
+
let exp = new numexp_1.NumExp(this.fx.plotFunction);
|
|
155
|
+
if (zero instanceof fraction_1.Fraction) {
|
|
156
|
+
let value = zero, evalY = this.fx.evaluate(value);
|
|
157
|
+
x = zero.value;
|
|
158
|
+
y = evalY.value;
|
|
159
|
+
xTex = zero.tex;
|
|
160
|
+
yTex = evalY.tex;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
x = zeroes[i].value;
|
|
164
|
+
y = exp.evaluate({ x });
|
|
165
|
+
xTex = x.toFixed(2);
|
|
166
|
+
yTex = y.toFixed(2);
|
|
167
|
+
}
|
|
168
|
+
// Determine the type of the zero.
|
|
169
|
+
if (resultLine[pos - 1] === resultLine[pos + 1]) {
|
|
170
|
+
pointType = FUNCTION_EXTREMA.FLAT;
|
|
171
|
+
}
|
|
172
|
+
else if (resultLine[pos - 1] === '+') {
|
|
173
|
+
pointType = FUNCTION_EXTREMA.MAX;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
pointType = FUNCTION_EXTREMA.MIN;
|
|
177
|
+
}
|
|
178
|
+
// Add the point to the list
|
|
179
|
+
extremes[zeroes[i].tex] = {
|
|
180
|
+
type: pointType,
|
|
181
|
+
tex: { x: xTex, y: yTex },
|
|
182
|
+
value: { x, y }
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// Create the grows line, based on tkz-tab
|
|
187
|
+
// \tkzTabLine{ , + , z , - , d , - , z , + , }
|
|
188
|
+
// \tkzTabVar{ -/ , +/$3$ , -D+/ , -/$1$ , +/ }
|
|
189
|
+
growsLine.push(resultLine[1] === '+' ? '-/' : '+/');
|
|
190
|
+
for (let i = 1; i < resultLine.length - 1; i++) {
|
|
191
|
+
if (resultLine[i] === "z") {
|
|
192
|
+
let extr = extremes[zeroes[(i - 2) / 2].tex];
|
|
193
|
+
growsLine.push(`${resultLine[i - 1]}/\\(${extr.type}(${extr.tex.x};${extr.tex.y})\\)`);
|
|
194
|
+
}
|
|
195
|
+
else if (resultLine[i] === 'd') {
|
|
196
|
+
growsLine.push(`${resultLine[i - 1]}D${resultLine[i + 1] === '+' ? '-' : '+'}/`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
growsLine.push(`${resultLine[resultLine.length - 2]}/`);
|
|
200
|
+
return { growsLine, extremes };
|
|
201
|
+
};
|
|
202
|
+
this.makeVariationsResult = (tos) => {
|
|
203
|
+
// TODO: make variations result is not yet implemented.
|
|
204
|
+
let extremes = {}, varsLine = [];
|
|
205
|
+
return { varsLine, extremes };
|
|
206
|
+
};
|
|
207
|
+
this.drawCode = () => {
|
|
208
|
+
// Function as string
|
|
209
|
+
let code = `f(x)=${this.fx.plotFunction}`;
|
|
210
|
+
// Asymptotes
|
|
211
|
+
let i = 1;
|
|
212
|
+
this.asymptotes.forEach(asymptote => {
|
|
213
|
+
if (asymptote.type === ASYMPTOTE.VERTICAL) {
|
|
214
|
+
code += `\nav_${i}=line x=${asymptote.zero.value}->red,dash`;
|
|
215
|
+
i++;
|
|
216
|
+
}
|
|
217
|
+
else if (asymptote.type === ASYMPTOTE.HORIZONTAL) {
|
|
218
|
+
code += `\nah=line y=${asymptote.fx.monoms[0].coefficient.value}->orange,dash`;
|
|
219
|
+
}
|
|
220
|
+
else if (asymptote.type === ASYMPTOTE.SLOPE) {
|
|
221
|
+
code += `\nao=line y=${asymptote.fx.plotFunction}->red,dash`;
|
|
222
|
+
}
|
|
223
|
+
i++;
|
|
224
|
+
});
|
|
225
|
+
// Extremes
|
|
226
|
+
for (let zero in this.derivative.extremes) {
|
|
227
|
+
let extreme = this.derivative.extremes[zero];
|
|
228
|
+
code += `\nM_${i}(${extreme.value.x},${extreme.value.y})*`;
|
|
229
|
+
i++;
|
|
230
|
+
}
|
|
231
|
+
// Zeroes
|
|
232
|
+
this.zeroes.forEach(zero => {
|
|
233
|
+
if (zero.type === ZEROTYPE.ZERO) {
|
|
234
|
+
code += `\nZ_${i}(${zero.value},0)*`;
|
|
235
|
+
i++;
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
return code;
|
|
239
|
+
};
|
|
240
|
+
this._makeTexFromTableOfSigns = (tos) => {
|
|
241
|
+
let factors = tos.factors.map(x => `\\(${x.tex}\\)/1`), factorsFx = `\\(${this._name}(x)\\)/1.2`, zeroes = tos.zeroes;
|
|
242
|
+
// Add the last lines "label"
|
|
243
|
+
if (tos.type === TABLE_OF_SIGNS.GROWS) {
|
|
244
|
+
factorsFx = `\\(${this._name}'(x)\\)/1.2,\\(f(x)\\)/2`;
|
|
245
|
+
}
|
|
246
|
+
else if (tos.type === TABLE_OF_SIGNS.VARIATIONS) {
|
|
247
|
+
factorsFx = `\\(${this._name}''(x)\\)/1.2,\\(f(x)\\)/2`;
|
|
248
|
+
}
|
|
249
|
+
// Create the tikzPicture header
|
|
250
250
|
let tex = `\\begin{tikzpicture}
|
|
251
|
-
\\tkzTabInit[lgt=3,espcl=2,deltacl=0]{/1.2,${factors.join(',')},/.1,${factorsFx} }{{\\scriptsize \\hspace{1cm} \\(-\\infty\\)},\\(${zeroes.map(x => x.tex).join('\\),\\(')}\\),{\\scriptsize \\hspace{-1cm} \\(+\\infty\\)}}`;
|
|
252
|
-
let pos;
|
|
253
|
-
for (pos = 0; pos < tos.factors.length; pos++) {
|
|
254
|
-
tex += (`\n\\tkzTabLine{${tos.signs[pos].join(',')}}`);
|
|
255
|
-
}
|
|
256
|
-
// Add the result line
|
|
257
|
-
tex += (`\n\\tkzTabLine{${tos.signs[pos].join(',')}}`);
|
|
258
|
-
// Add the grows / vars line
|
|
259
|
-
if (tos.type === TABLE_OF_SIGNS.GROWS) {
|
|
260
|
-
tex += (`\n\\tkzTabVar{${tos.signs[pos + 1].join(',')}}`);
|
|
261
|
-
}
|
|
262
|
-
else if (tos.type === TABLE_OF_SIGNS.VARIATIONS) {
|
|
263
|
-
// TODO: Check variations table for as tex
|
|
264
|
-
tex += (`\n\\tkzTabVar{${tos.signs[pos + 1].join(',')}}`);
|
|
265
|
-
}
|
|
266
|
-
tex += `\n\\end{tikzpicture}`;
|
|
267
|
-
return tex;
|
|
268
|
-
};
|
|
269
|
-
this.fx = fx;
|
|
270
|
-
this._config = {
|
|
271
|
-
name: 'f',
|
|
272
|
-
domain: true,
|
|
273
|
-
asymptotes: true,
|
|
274
|
-
signs: true,
|
|
275
|
-
derivative: true,
|
|
276
|
-
variations: true,
|
|
277
|
-
};
|
|
278
|
-
if (config) {
|
|
279
|
-
if (typeof config === 'string') {
|
|
280
|
-
const d = config.split(',');
|
|
281
|
-
this._config = {};
|
|
282
|
-
let n = d.filter(x => x.includes('(x)'));
|
|
283
|
-
if (n.length === 1) {
|
|
284
|
-
this._config.name = n[0].split('(x)')[0];
|
|
285
|
-
}
|
|
286
|
-
this._config.domain = d.includes('d');
|
|
287
|
-
this._config.asymptotes = d.includes('a');
|
|
288
|
-
this._config.signs = d.includes('signs');
|
|
289
|
-
this._config.derivative = d.includes('dx');
|
|
290
|
-
this._config.variations = d.includes('ddx');
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
this._config = config;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
this._name = this._config?.name ?? 'f';
|
|
297
|
-
this.makeStudy();
|
|
298
|
-
return this;
|
|
299
|
-
}
|
|
300
|
-
get name() {
|
|
301
|
-
return this._name;
|
|
302
|
-
}
|
|
303
|
-
set name(value) {
|
|
304
|
-
this._name = value;
|
|
305
|
-
}
|
|
306
|
-
get config() {
|
|
307
|
-
return this._config;
|
|
308
|
-
}
|
|
309
|
-
set config(value) {
|
|
310
|
-
this._config = value;
|
|
311
|
-
}
|
|
312
|
-
get zeroes() {
|
|
313
|
-
return this._zeroes;
|
|
314
|
-
}
|
|
315
|
-
get domain() {
|
|
316
|
-
return this.fx.domain();
|
|
317
|
-
}
|
|
318
|
-
get signs() {
|
|
319
|
-
return this._signs;
|
|
320
|
-
}
|
|
321
|
-
get asymptotes() {
|
|
322
|
-
return this._asymptotes;
|
|
323
|
-
}
|
|
324
|
-
get derivative() {
|
|
325
|
-
return this._derivative;
|
|
326
|
-
}
|
|
327
|
-
get texSigns() {
|
|
328
|
-
return this._makeTexFromTableOfSigns(this._signs);
|
|
329
|
-
}
|
|
330
|
-
get texGrows() {
|
|
331
|
-
return this._makeTexFromTableOfSigns(this._derivative);
|
|
332
|
-
}
|
|
333
|
-
get texVariations() {
|
|
334
|
-
return this._makeTexFromTableOfSigns(this._variations);
|
|
335
|
-
}
|
|
336
|
-
makeZeroes() {
|
|
337
|
-
return [];
|
|
338
|
-
}
|
|
339
|
-
;
|
|
340
|
-
makeSigns() {
|
|
341
|
-
return {
|
|
342
|
-
type: TABLE_OF_SIGNS.SIGNS,
|
|
343
|
-
fx: null,
|
|
344
|
-
factors: [],
|
|
345
|
-
zeroes: [],
|
|
346
|
-
signs: [],
|
|
347
|
-
extremes: {},
|
|
348
|
-
tex: ''
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
;
|
|
352
|
-
makeAsymptotes() {
|
|
353
|
-
return [];
|
|
354
|
-
}
|
|
355
|
-
makeDerivative() {
|
|
356
|
-
return {
|
|
357
|
-
type: TABLE_OF_SIGNS.GROWS,
|
|
358
|
-
fx: null,
|
|
359
|
-
factors: [],
|
|
360
|
-
zeroes: [],
|
|
361
|
-
signs: [],
|
|
362
|
-
extremes: {},
|
|
363
|
-
tex: ''
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
makeVariation() {
|
|
367
|
-
return {
|
|
368
|
-
type: TABLE_OF_SIGNS.VARIATIONS,
|
|
369
|
-
fx: null,
|
|
370
|
-
factors: [],
|
|
371
|
-
zeroes: [],
|
|
372
|
-
signs: [],
|
|
373
|
-
extremes: {},
|
|
374
|
-
tex: ''
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
exports.Study = Study;
|
|
251
|
+
\\tkzTabInit[lgt=3,espcl=2,deltacl=0]{/1.2,${factors.join(',')},/.1,${factorsFx} }{{\\scriptsize \\hspace{1cm} \\(-\\infty\\)},\\(${zeroes.map(x => x.tex).join('\\),\\(')}\\),{\\scriptsize \\hspace{-1cm} \\(+\\infty\\)}}`;
|
|
252
|
+
let pos;
|
|
253
|
+
for (pos = 0; pos < tos.factors.length; pos++) {
|
|
254
|
+
tex += (`\n\\tkzTabLine{${tos.signs[pos].join(',')}}`);
|
|
255
|
+
}
|
|
256
|
+
// Add the result line
|
|
257
|
+
tex += (`\n\\tkzTabLine{${tos.signs[pos].join(',')}}`);
|
|
258
|
+
// Add the grows / vars line
|
|
259
|
+
if (tos.type === TABLE_OF_SIGNS.GROWS) {
|
|
260
|
+
tex += (`\n\\tkzTabVar{${tos.signs[pos + 1].join(',')}}`);
|
|
261
|
+
}
|
|
262
|
+
else if (tos.type === TABLE_OF_SIGNS.VARIATIONS) {
|
|
263
|
+
// TODO: Check variations table for as tex
|
|
264
|
+
tex += (`\n\\tkzTabVar{${tos.signs[pos + 1].join(',')}}`);
|
|
265
|
+
}
|
|
266
|
+
tex += `\n\\end{tikzpicture}`;
|
|
267
|
+
return tex;
|
|
268
|
+
};
|
|
269
|
+
this.fx = fx;
|
|
270
|
+
this._config = {
|
|
271
|
+
name: 'f',
|
|
272
|
+
domain: true,
|
|
273
|
+
asymptotes: true,
|
|
274
|
+
signs: true,
|
|
275
|
+
derivative: true,
|
|
276
|
+
variations: true,
|
|
277
|
+
};
|
|
278
|
+
if (config) {
|
|
279
|
+
if (typeof config === 'string') {
|
|
280
|
+
const d = config.split(',');
|
|
281
|
+
this._config = {};
|
|
282
|
+
let n = d.filter(x => x.includes('(x)'));
|
|
283
|
+
if (n.length === 1) {
|
|
284
|
+
this._config.name = n[0].split('(x)')[0];
|
|
285
|
+
}
|
|
286
|
+
this._config.domain = d.includes('d');
|
|
287
|
+
this._config.asymptotes = d.includes('a');
|
|
288
|
+
this._config.signs = d.includes('signs');
|
|
289
|
+
this._config.derivative = d.includes('dx');
|
|
290
|
+
this._config.variations = d.includes('ddx');
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
this._config = config;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
this._name = this._config?.name ?? 'f';
|
|
297
|
+
this.makeStudy();
|
|
298
|
+
return this;
|
|
299
|
+
}
|
|
300
|
+
get name() {
|
|
301
|
+
return this._name;
|
|
302
|
+
}
|
|
303
|
+
set name(value) {
|
|
304
|
+
this._name = value;
|
|
305
|
+
}
|
|
306
|
+
get config() {
|
|
307
|
+
return this._config;
|
|
308
|
+
}
|
|
309
|
+
set config(value) {
|
|
310
|
+
this._config = value;
|
|
311
|
+
}
|
|
312
|
+
get zeroes() {
|
|
313
|
+
return this._zeroes;
|
|
314
|
+
}
|
|
315
|
+
get domain() {
|
|
316
|
+
return this.fx.domain();
|
|
317
|
+
}
|
|
318
|
+
get signs() {
|
|
319
|
+
return this._signs;
|
|
320
|
+
}
|
|
321
|
+
get asymptotes() {
|
|
322
|
+
return this._asymptotes;
|
|
323
|
+
}
|
|
324
|
+
get derivative() {
|
|
325
|
+
return this._derivative;
|
|
326
|
+
}
|
|
327
|
+
get texSigns() {
|
|
328
|
+
return this._makeTexFromTableOfSigns(this._signs);
|
|
329
|
+
}
|
|
330
|
+
get texGrows() {
|
|
331
|
+
return this._makeTexFromTableOfSigns(this._derivative);
|
|
332
|
+
}
|
|
333
|
+
get texVariations() {
|
|
334
|
+
return this._makeTexFromTableOfSigns(this._variations);
|
|
335
|
+
}
|
|
336
|
+
makeZeroes() {
|
|
337
|
+
return [];
|
|
338
|
+
}
|
|
339
|
+
;
|
|
340
|
+
makeSigns() {
|
|
341
|
+
return {
|
|
342
|
+
type: TABLE_OF_SIGNS.SIGNS,
|
|
343
|
+
fx: null,
|
|
344
|
+
factors: [],
|
|
345
|
+
zeroes: [],
|
|
346
|
+
signs: [],
|
|
347
|
+
extremes: {},
|
|
348
|
+
tex: ''
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
;
|
|
352
|
+
makeAsymptotes() {
|
|
353
|
+
return [];
|
|
354
|
+
}
|
|
355
|
+
makeDerivative() {
|
|
356
|
+
return {
|
|
357
|
+
type: TABLE_OF_SIGNS.GROWS,
|
|
358
|
+
fx: null,
|
|
359
|
+
factors: [],
|
|
360
|
+
zeroes: [],
|
|
361
|
+
signs: [],
|
|
362
|
+
extremes: {},
|
|
363
|
+
tex: ''
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
makeVariation() {
|
|
367
|
+
return {
|
|
368
|
+
type: TABLE_OF_SIGNS.VARIATIONS,
|
|
369
|
+
fx: null,
|
|
370
|
+
factors: [],
|
|
371
|
+
zeroes: [],
|
|
372
|
+
signs: [],
|
|
373
|
+
extremes: {},
|
|
374
|
+
tex: ''
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
exports.Study = Study;
|
|
379
379
|
//# sourceMappingURL=study.js.map
|