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.
- package/dist/main.d.ts +39 -0
- package/{esm → dist}/maths/algebra/equation.d.ts +11 -10
- package/{esm → dist}/maths/algebra/linearSystem.d.ts +5 -4
- package/{esm → dist}/maths/algebra/monom.d.ts +5 -4
- package/{esm → dist}/maths/algebra/polynom.d.ts +11 -13
- package/{esm → dist}/maths/algebra/rational.d.ts +7 -9
- package/dist/maths/algebra/study/rationalStudy.d.ts +14 -0
- package/{esm → dist}/maths/algebra/study.d.ts +4 -7
- package/{esm → dist}/maths/geometry/circle.d.ts +9 -8
- package/{esm → dist}/maths/geometry/line.d.ts +17 -14
- package/{esm → dist}/maths/geometry/point.d.ts +11 -9
- package/{esm → dist}/maths/geometry/triangle.d.ts +4 -3
- package/{esm → dist}/maths/geometry/vector.d.ts +7 -10
- package/{esm → dist}/maths/randomization/random.d.ts +10 -7
- package/{esm → dist}/maths/randomization/rndFraction.d.ts +4 -3
- package/dist/maths/randomization/rndGeometryCircle.d.ts +13 -0
- package/{esm → dist}/maths/randomization/rndGeometryLine.d.ts +4 -3
- package/{esm → dist}/maths/randomization/rndGeometryPoint.d.ts +4 -3
- package/{esm → dist}/maths/randomization/rndMonom.d.ts +5 -4
- package/{esm → dist}/maths/randomization/rndPolynom.d.ts +5 -4
- package/{esm → dist}/maths/randomization/rndTypes.d.ts +7 -1
- package/dist/pimath.js +4239 -7819
- package/package.json +13 -7
- 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/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/dev/pimath.js +0 -7945
- package/dev/pimath.js.map +0 -1
- package/dist/pimath.js.map +0 -1
- package/dist/pimath.min.js +0 -2
- package/dist/pimath.min.js.map +0 -1
- 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/esm/index.d.ts +0 -38
- package/esm/index.js +0 -44
- package/esm/index.js.map +0 -1
- package/esm/maths/algebra/equation.js +0 -797
- package/esm/maths/algebra/equation.js.map +0 -1
- package/esm/maths/algebra/linearSystem.js +0 -279
- package/esm/maths/algebra/linearSystem.js.map +0 -1
- package/esm/maths/algebra/logicalset.js +0 -158
- package/esm/maths/algebra/logicalset.js.map +0 -1
- package/esm/maths/algebra/monom.js +0 -909
- package/esm/maths/algebra/monom.js.map +0 -1
- package/esm/maths/algebra/polynom.js +0 -1305
- package/esm/maths/algebra/polynom.js.map +0 -1
- package/esm/maths/algebra/rational.js +0 -195
- package/esm/maths/algebra/rational.js.map +0 -1
- package/esm/maths/algebra/study/rationalStudy.d.ts +0 -28
- package/esm/maths/algebra/study/rationalStudy.js +0 -244
- package/esm/maths/algebra/study/rationalStudy.js.map +0 -1
- package/esm/maths/algebra/study.js +0 -380
- package/esm/maths/algebra/study.js.map +0 -1
- package/esm/maths/coefficients/fraction.js +0 -517
- package/esm/maths/coefficients/fraction.js.map +0 -1
- package/esm/maths/coefficients/nthRoot.js +0 -137
- package/esm/maths/coefficients/nthRoot.js.map +0 -1
- package/esm/maths/geometry/circle.js +0 -324
- package/esm/maths/geometry/circle.js.map +0 -1
- package/esm/maths/geometry/line.js +0 -485
- package/esm/maths/geometry/line.js.map +0 -1
- package/esm/maths/geometry/point.js +0 -167
- package/esm/maths/geometry/point.js.map +0 -1
- package/esm/maths/geometry/triangle.js +0 -276
- package/esm/maths/geometry/triangle.js.map +0 -1
- package/esm/maths/geometry/vector.js +0 -198
- package/esm/maths/geometry/vector.js.map +0 -1
- package/esm/maths/numeric.js +0 -136
- package/esm/maths/numeric.js.map +0 -1
- package/esm/maths/numexp.js +0 -186
- package/esm/maths/numexp.js.map +0 -1
- package/esm/maths/randomization/random.js +0 -79
- package/esm/maths/randomization/random.js.map +0 -1
- package/esm/maths/randomization/randomCore.js +0 -22
- package/esm/maths/randomization/randomCore.js.map +0 -1
- package/esm/maths/randomization/rndFraction.js +0 -44
- package/esm/maths/randomization/rndFraction.js.map +0 -1
- package/esm/maths/randomization/rndGeometryLine.js +0 -46
- package/esm/maths/randomization/rndGeometryLine.js.map +0 -1
- package/esm/maths/randomization/rndGeometryPoint.js +0 -61
- package/esm/maths/randomization/rndGeometryPoint.js.map +0 -1
- package/esm/maths/randomization/rndHelpers.js +0 -98
- package/esm/maths/randomization/rndHelpers.js.map +0 -1
- package/esm/maths/randomization/rndMonom.js +0 -53
- package/esm/maths/randomization/rndMonom.js.map +0 -1
- package/esm/maths/randomization/rndPolynom.js +0 -75
- package/esm/maths/randomization/rndPolynom.js.map +0 -1
- package/esm/maths/randomization/rndTypes.js +0 -3
- package/esm/maths/randomization/rndTypes.js.map +0 -1
- package/esm/maths/shutingyard.js +0 -443
- package/esm/maths/shutingyard.js.map +0 -1
- package/public/demo.css +0 -3
- package/public/index.html +0 -283
- package/public/matrices.html +0 -100
- package/public/playground.html +0 -168
- package/src/index.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 -240
- 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 -41
- package/tsconfig.testing.json +0 -28
- package/typedoc.katex.js +0 -11
- package/webpack-production-min.config.js +0 -26
- package/webpack-production.config.js +0 -26
- package/webpack.config.js +0 -26
- package/{esm → dist}/maths/algebra/logicalset.d.ts +6 -6
- package/{esm → dist}/maths/coefficients/fraction.d.ts +0 -0
- package/{esm → dist}/maths/coefficients/nthRoot.d.ts +0 -0
- package/{esm → dist}/maths/numeric.d.ts +0 -0
- package/{esm → dist}/maths/numexp.d.ts +3 -3
- /package/{esm → dist}/maths/randomization/randomCore.d.ts +0 -0
- /package/{esm → dist}/maths/randomization/rndHelpers.d.ts +0 -0
- /package/{esm → dist}/maths/shutingyard.d.ts +0 -0
|
@@ -1,506 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rational polynom module contains everything necessary to handle rational polynoms.
|
|
3
|
-
* @module Polynom
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import {Rational} from "./rational";
|
|
7
|
-
import {ISolution} from "./equation";
|
|
8
|
-
import {Polynom} from "./polynom";
|
|
9
|
-
import {Fraction} from "../coefficients/fraction";
|
|
10
|
-
import {Point} from "../geometry/point";
|
|
11
|
-
import {NumExp} from "../numexp";
|
|
12
|
-
|
|
13
|
-
export type StudyableFunction = Rational
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export enum ZEROTYPE {
|
|
17
|
-
ZERO = 'z',
|
|
18
|
-
DEFENCE = 'd',
|
|
19
|
-
NOTHING = 't'
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface IZero extends ISolution {
|
|
23
|
-
extrema: FUNCTION_EXTREMA,
|
|
24
|
-
type: ZEROTYPE
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export enum ASYMPTOTE {
|
|
28
|
-
VERTICAL = "av",
|
|
29
|
-
HORIZONTAL = "ah",
|
|
30
|
-
SLOPE = "ao",
|
|
31
|
-
HOLE = "hole"
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export enum ASYMPTOTE_POSITION {
|
|
35
|
-
"LT" = "LT",
|
|
36
|
-
"RT" = "RT",
|
|
37
|
-
"LB" = "LB",
|
|
38
|
-
"RB" = "RB"
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface IAsymptote {
|
|
42
|
-
deltaX: StudyableFunction
|
|
43
|
-
display: string,
|
|
44
|
-
fx: Polynom,
|
|
45
|
-
limits: string,
|
|
46
|
-
position: ASYMPTOTE_POSITION[]
|
|
47
|
-
tableOfSign: ITableOfSigns,
|
|
48
|
-
tex: string,
|
|
49
|
-
type: ASYMPTOTE,
|
|
50
|
-
zero: IZero,
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export enum FUNCTION_EXTREMA {
|
|
54
|
-
MIN = "min",
|
|
55
|
-
MAX = "max",
|
|
56
|
-
FLAT = "flat",
|
|
57
|
-
NOTHING = ""
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface IExtrema {
|
|
61
|
-
tex: {
|
|
62
|
-
x: string,
|
|
63
|
-
y: string
|
|
64
|
-
},
|
|
65
|
-
type: FUNCTION_EXTREMA,
|
|
66
|
-
value: {
|
|
67
|
-
x: number,
|
|
68
|
-
y: number
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface ITableOfSigns {
|
|
74
|
-
extremes: { [Key: string]: IExtrema },
|
|
75
|
-
factors: Polynom[],
|
|
76
|
-
fx: StudyableFunction,
|
|
77
|
-
signs: (string[])[],
|
|
78
|
-
tex: string
|
|
79
|
-
type: TABLE_OF_SIGNS
|
|
80
|
-
zeroes: IZero[],
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export enum TABLE_OF_SIGNS {
|
|
84
|
-
SIGNS = "signs",
|
|
85
|
-
GROWS = "grows",
|
|
86
|
-
VARIATIONS = "variatins"
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export interface StudyConfig {
|
|
90
|
-
asymptotes?: boolean,
|
|
91
|
-
derivative?: boolean,
|
|
92
|
-
domain?: boolean,
|
|
93
|
-
name?: string,
|
|
94
|
-
variable?: string,
|
|
95
|
-
signs?: boolean,
|
|
96
|
-
variations?: boolean
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* The study class is a "function study" class that will get:
|
|
101
|
-
* fx : get the function
|
|
102
|
-
* domain : string
|
|
103
|
-
* zeroes : Object (tex, IZero)
|
|
104
|
-
* signs : table of signs + tex output using tkz-tab
|
|
105
|
-
* av : vertical asymptotic
|
|
106
|
-
* ah : horizontal asymptotic
|
|
107
|
-
* ao : obliques
|
|
108
|
-
* deltaX : position relative
|
|
109
|
-
* dx : derivative
|
|
110
|
-
* grows : growing table + tex output using tkz-tab
|
|
111
|
-
* ddx : dérivée seconde
|
|
112
|
-
* variations : variation table + tex output using tkz-tab
|
|
113
|
-
*/
|
|
114
|
-
export class Study {
|
|
115
|
-
fx: StudyableFunction
|
|
116
|
-
private _asymptotes: IAsymptote[]
|
|
117
|
-
private _derivative: ITableOfSigns
|
|
118
|
-
private _signs: ITableOfSigns
|
|
119
|
-
private _variations: ITableOfSigns
|
|
120
|
-
private _zeroes: IZero[]
|
|
121
|
-
private _config: StudyConfig
|
|
122
|
-
private _name: string
|
|
123
|
-
|
|
124
|
-
constructor(fx: StudyableFunction, config?: StudyConfig | string) {
|
|
125
|
-
this.fx = fx
|
|
126
|
-
|
|
127
|
-
this._config = {
|
|
128
|
-
name :'f',
|
|
129
|
-
variable: 'x',
|
|
130
|
-
domain :true,
|
|
131
|
-
asymptotes :true,
|
|
132
|
-
signs :true,
|
|
133
|
-
derivative :true,
|
|
134
|
-
variations :true,
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (config) {
|
|
138
|
-
if (typeof config === 'string') {
|
|
139
|
-
const d = config.split(',')
|
|
140
|
-
this._config = {}
|
|
141
|
-
let n = d.filter(x=>x.includes('(') && x.includes(')'))
|
|
142
|
-
|
|
143
|
-
if(n.length===1){
|
|
144
|
-
this._config.name = n[0].split('(')[0]
|
|
145
|
-
this._config.variable = n[0].split('(')[1].split(')')[0]
|
|
146
|
-
}
|
|
147
|
-
this._config.domain = d.includes('d')
|
|
148
|
-
this._config.asymptotes = d.includes('a')
|
|
149
|
-
this._config.signs = d.includes('signs')
|
|
150
|
-
this._config.derivative = d.includes('dx')
|
|
151
|
-
this._config.variations = d.includes('ddx')
|
|
152
|
-
} else {
|
|
153
|
-
this._config = config
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
this.makeStudy()
|
|
158
|
-
return this
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
get name(): string {
|
|
162
|
-
return this._config.name;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
set name(value: string) {
|
|
166
|
-
this._config.name = value;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
get config(): StudyConfig {
|
|
170
|
-
return this._config;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
set config(value: StudyConfig) {
|
|
174
|
-
this._config = value;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
get zeroes(): IZero[] {
|
|
178
|
-
return this._zeroes;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
get domain(): string {
|
|
182
|
-
return this.fx.domain()
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
get signs(): ITableOfSigns {
|
|
186
|
-
return this._signs;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
get asymptotes(): IAsymptote[] {
|
|
190
|
-
return this._asymptotes;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
get derivative(): ITableOfSigns {
|
|
194
|
-
return this._derivative;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
get texSigns(): string {
|
|
198
|
-
return this._makeTexFromTableOfSigns(this._signs)
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
get texGrows(): string {
|
|
202
|
-
return this._makeTexFromTableOfSigns(this._derivative)
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
get texVariations(): string {
|
|
206
|
-
return this._makeTexFromTableOfSigns(this._variations)
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
makeStudy = (): void => {
|
|
210
|
-
this._zeroes = this.makeZeroes()
|
|
211
|
-
|
|
212
|
-
if (this._config.signs) this._signs = this.makeSigns()
|
|
213
|
-
|
|
214
|
-
if (this._config.asymptotes) this._asymptotes = this.makeAsymptotes()
|
|
215
|
-
|
|
216
|
-
if (this._config.derivative) this._derivative = this.makeDerivative()
|
|
217
|
-
|
|
218
|
-
if (this._config.variations) this._variations = this.makeVariation()
|
|
219
|
-
|
|
220
|
-
// Table of signs / derivative / variation
|
|
221
|
-
if (this._config.signs) this._signs.tex = this.texSigns
|
|
222
|
-
|
|
223
|
-
if (this._config.derivative) this._derivative.tex = this.texGrows
|
|
224
|
-
|
|
225
|
-
if (this._config.variations) this._variations.tex = this.texVariations
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
indexOfZero = (zeroes: IZero[], zero: IZero | ISolution): number => {
|
|
229
|
-
for (let i = 0; i < zeroes.length; i++) {
|
|
230
|
-
if (zeroes[i].tex === zero.tex) {
|
|
231
|
-
return i
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return -1
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
makeOneLineForSigns = (factor: Polynom, zeroes: IZero[], zeroSign: ZEROTYPE): string[] => {
|
|
238
|
-
let oneLine: string[] = [],
|
|
239
|
-
currentZero = factor.getZeroes().map(x => x.tex)
|
|
240
|
-
|
|
241
|
-
// First +/- sign, before the first zero
|
|
242
|
-
oneLine.push('')
|
|
243
|
-
if (factor.degree().isZero()) {
|
|
244
|
-
oneLine.push(factor.monoms[0].coefficient.sign() === 1 ? '+' : '-')
|
|
245
|
-
} else {
|
|
246
|
-
oneLine.push(factor.evaluate(zeroes[0].value - 1).sign() === 1 ? '+' : '-')
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
for (let i = 0; i < zeroes.length; i++) {
|
|
250
|
-
// Add the zero if it's the current one
|
|
251
|
-
oneLine.push(currentZero.includes(zeroes[i].tex) ? zeroSign : ZEROTYPE.NOTHING)
|
|
252
|
-
|
|
253
|
-
// + / - sign after the current zero
|
|
254
|
-
if (i < zeroes.length - 1) {
|
|
255
|
-
oneLine.push(factor.evaluate((zeroes[i].value + zeroes[i + 1].value) / 2).sign() === 1 ? '+' : '-')
|
|
256
|
-
} else if (i === zeroes.length - 1) {
|
|
257
|
-
oneLine.push(factor.evaluate(zeroes[i].value + 1).sign() === 1 ? '+' : '-')
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
oneLine.push('')
|
|
262
|
-
|
|
263
|
-
return oneLine
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
makeSignsResult = (signs: (string[])[]): string[] => {
|
|
267
|
-
|
|
268
|
-
// Initialize the result line with the first line of the signs table
|
|
269
|
-
let resultLine: string[] = signs[0].map((x, index) => {
|
|
270
|
-
if (index === 0 || index === signs[0].length - 1) {
|
|
271
|
-
return ''
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (index % 2 === 0) {
|
|
275
|
-
return 't'
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
return '+'
|
|
279
|
-
})
|
|
280
|
-
|
|
281
|
-
// Go through each lines (except the first)
|
|
282
|
-
for (let current of signs) {
|
|
283
|
-
|
|
284
|
-
for (let i = 0; i < current.length; i++) {
|
|
285
|
-
if (i % 2 === 0) {
|
|
286
|
-
// t, z or d
|
|
287
|
-
if (resultLine[i] === 'd') {
|
|
288
|
-
continue
|
|
289
|
-
}
|
|
290
|
-
if (current[i] !== 't') {
|
|
291
|
-
resultLine[i] = current[i]
|
|
292
|
-
}
|
|
293
|
-
} else {
|
|
294
|
-
// + or -
|
|
295
|
-
if (current[i] === '-') {
|
|
296
|
-
resultLine[i] = resultLine[i] === '+' ? '-' : '+'
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
return resultLine
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
makeGrowsResult = (tos: ITableOfSigns): { growsLine: string[], extremes: { [Key: string]: IExtrema } } => {
|
|
306
|
-
|
|
307
|
-
// Use the last line (=> resultLine) to grab the necessary information
|
|
308
|
-
let signsAsArray = Object.values(tos.signs),
|
|
309
|
-
resultLine = signsAsArray[signsAsArray.length - 1],
|
|
310
|
-
growsLine: string[] = [],
|
|
311
|
-
extremes: { [Key: string]: IExtrema } = {},
|
|
312
|
-
zeroes = tos.zeroes
|
|
313
|
-
|
|
314
|
-
// Get the extremes
|
|
315
|
-
for (let i = 0; i < zeroes.length; i++) {
|
|
316
|
-
|
|
317
|
-
// Get the corresponding item in the resultLine.
|
|
318
|
-
let pos = 2 * i + 2
|
|
319
|
-
if (resultLine[pos] === 'z') {
|
|
320
|
-
|
|
321
|
-
// It's a zero. Get the coordinates
|
|
322
|
-
let x: number, y: number, zero = zeroes[i].exact,
|
|
323
|
-
pt: Point,
|
|
324
|
-
xTex: string, yTex: string,
|
|
325
|
-
pointType: FUNCTION_EXTREMA
|
|
326
|
-
|
|
327
|
-
// TODO: NumExp should parse something that isn't yet plotFunction
|
|
328
|
-
let exp = new NumExp(this.fx.plotFunction)
|
|
329
|
-
|
|
330
|
-
if (zero instanceof Fraction) {
|
|
331
|
-
let value: Fraction = zero,
|
|
332
|
-
evalY = this.fx.evaluate(value)
|
|
333
|
-
|
|
334
|
-
x = zero.value
|
|
335
|
-
y = evalY.value
|
|
336
|
-
xTex = zero.tex
|
|
337
|
-
yTex = evalY.tex
|
|
338
|
-
} else {
|
|
339
|
-
x = zeroes[i].value
|
|
340
|
-
y = exp.evaluate({x})
|
|
341
|
-
|
|
342
|
-
xTex = x.toFixed(2)
|
|
343
|
-
yTex = y.toFixed(2)
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
// Determine the type of the zero.
|
|
347
|
-
if (resultLine[pos - 1] === resultLine[pos + 1]) {
|
|
348
|
-
pointType = FUNCTION_EXTREMA.FLAT
|
|
349
|
-
} else if (resultLine[pos - 1] === '+') {
|
|
350
|
-
pointType = FUNCTION_EXTREMA.MAX
|
|
351
|
-
} else {
|
|
352
|
-
pointType = FUNCTION_EXTREMA.MIN
|
|
353
|
-
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
// Add the point to the list
|
|
357
|
-
extremes[zeroes[i].tex] = {
|
|
358
|
-
type: pointType,
|
|
359
|
-
tex: {x: xTex, y: yTex},
|
|
360
|
-
value: {x, y}
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// Create the grows line, based on tkz-tab
|
|
366
|
-
// \tkzTabLine{ , + , z , - , d , - , z , + , }
|
|
367
|
-
// \tkzTabVar{ -/ , +/$3$ , -D+/ , -/$1$ , +/ }
|
|
368
|
-
growsLine.push(resultLine[1] === '+' ? '-/' : '+/')
|
|
369
|
-
for (let i = 1; i < resultLine.length - 1; i++) {
|
|
370
|
-
if (resultLine[i] === "z") {
|
|
371
|
-
let extr = extremes[zeroes[(i - 2) / 2].tex]
|
|
372
|
-
|
|
373
|
-
growsLine.push(`${resultLine[i - 1]}/\\(${extr.type}(${extr.tex.x};${extr.tex.y})\\)`)
|
|
374
|
-
} else if (resultLine[i] === 'd') {
|
|
375
|
-
growsLine.push(`${resultLine[i - 1]}D${resultLine[i + 1] === '+' ? '-' : '+'}/`)
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
growsLine.push(`${resultLine[resultLine.length - 2]}/`)
|
|
379
|
-
|
|
380
|
-
return {growsLine, extremes}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
makeVariationsResult = (tos: ITableOfSigns): { varsLine: string[], extremes: { [Key: string]: IExtrema } } => {
|
|
384
|
-
// TODO: make variations result is not yet implemented.
|
|
385
|
-
let extremes = {},
|
|
386
|
-
varsLine: string[] = []
|
|
387
|
-
return {varsLine, extremes}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
makeZeroes(): IZero[] {
|
|
391
|
-
return []
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
makeSigns(): ITableOfSigns {
|
|
395
|
-
return {
|
|
396
|
-
type: TABLE_OF_SIGNS.SIGNS,
|
|
397
|
-
fx: null,
|
|
398
|
-
factors: [],
|
|
399
|
-
zeroes: [],
|
|
400
|
-
signs: [],
|
|
401
|
-
extremes: {},
|
|
402
|
-
tex: ''
|
|
403
|
-
}
|
|
404
|
-
};
|
|
405
|
-
|
|
406
|
-
makeAsymptotes(): IAsymptote[] {
|
|
407
|
-
return []
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
makeDerivative(): ITableOfSigns {
|
|
411
|
-
return {
|
|
412
|
-
type: TABLE_OF_SIGNS.GROWS,
|
|
413
|
-
fx: null,
|
|
414
|
-
factors: [],
|
|
415
|
-
zeroes: [],
|
|
416
|
-
signs: [],
|
|
417
|
-
extremes: {},
|
|
418
|
-
tex: ''
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
makeVariation(): ITableOfSigns {
|
|
423
|
-
return {
|
|
424
|
-
type: TABLE_OF_SIGNS.VARIATIONS,
|
|
425
|
-
fx: null,
|
|
426
|
-
factors: [],
|
|
427
|
-
zeroes: [],
|
|
428
|
-
signs: [],
|
|
429
|
-
extremes: {},
|
|
430
|
-
tex: ''
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
drawCode = (): string => {
|
|
435
|
-
// Function as string
|
|
436
|
-
let code = `f(x)=${this.fx.plotFunction}`
|
|
437
|
-
|
|
438
|
-
// Asymptotes
|
|
439
|
-
let i: number = 1
|
|
440
|
-
this.asymptotes.forEach(asymptote => {
|
|
441
|
-
if (asymptote.type === ASYMPTOTE.VERTICAL) {
|
|
442
|
-
code += `\nav_${i}=line x=${asymptote.zero.value}->red,dash`
|
|
443
|
-
i++
|
|
444
|
-
} else if (asymptote.type === ASYMPTOTE.HORIZONTAL) {
|
|
445
|
-
code += `\nah=line y=${asymptote.fx.monoms[0].coefficient.value}->orange,dash`
|
|
446
|
-
} else if (asymptote.type === ASYMPTOTE.SLOPE) {
|
|
447
|
-
code += `\nao=line y=${asymptote.fx.plotFunction}->red,dash`
|
|
448
|
-
}
|
|
449
|
-
i++
|
|
450
|
-
})
|
|
451
|
-
|
|
452
|
-
// Extremes
|
|
453
|
-
for (let zero in this.derivative.extremes) {
|
|
454
|
-
let extreme = this.derivative.extremes[zero]
|
|
455
|
-
|
|
456
|
-
code += `\nM_${i}(${extreme.value.x},${extreme.value.y})*`
|
|
457
|
-
i++
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
// Zeroes
|
|
461
|
-
this.zeroes.forEach(zero => {
|
|
462
|
-
if (zero.type === ZEROTYPE.ZERO) {
|
|
463
|
-
code += `\nZ_${i}(${zero.value},0)*`
|
|
464
|
-
i++
|
|
465
|
-
}
|
|
466
|
-
})
|
|
467
|
-
|
|
468
|
-
return code
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
private _makeTexFromTableOfSigns = (tos: ITableOfSigns): string => {
|
|
472
|
-
let factors = tos.factors.map(x => `\\(${x.tex}\\)/1`),
|
|
473
|
-
factorsFx = `\\(${this._config.name}(${this._config.variable})\\)/1.2`,
|
|
474
|
-
zeroes = tos.zeroes
|
|
475
|
-
|
|
476
|
-
// Add the last lines "label"
|
|
477
|
-
if (tos.type === TABLE_OF_SIGNS.GROWS) {
|
|
478
|
-
factorsFx = `\\(${this._config.name}'(${this._config.variable})\\)/1.2,\\(f(x${this._config.variable})\\)/2`
|
|
479
|
-
} else if (tos.type === TABLE_OF_SIGNS.VARIATIONS) {
|
|
480
|
-
factorsFx = `\\(${this._config.name}''(${this._config.variable})\\)/1.2,\\(f(${this._config.variable})\\)/2`
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
// Create the tikzPicture header
|
|
484
|
-
let tex = `\\begin{tikzpicture}
|
|
485
|
-
\\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\\)}}`
|
|
486
|
-
|
|
487
|
-
let pos
|
|
488
|
-
for (pos = 0; pos < tos.factors.length; pos++) {
|
|
489
|
-
tex += (`\n\\tkzTabLine{${tos.signs[pos].join(',')}}`)
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
// Add the result line
|
|
493
|
-
tex += (`\n\\tkzTabLine{${tos.signs[pos].join(',')}}`)
|
|
494
|
-
// Add the grows / vars line
|
|
495
|
-
if (tos.type === TABLE_OF_SIGNS.GROWS) {
|
|
496
|
-
tex += (`\n\\tkzTabVar{${tos.signs[pos + 1].join(',')}}`)
|
|
497
|
-
} else if (tos.type === TABLE_OF_SIGNS.VARIATIONS) {
|
|
498
|
-
// TODO: Check variations table for as tex
|
|
499
|
-
tex += (`\n\\tkzTabVar{${tos.signs[pos + 1].join(',')}}`)
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
tex += `\n\\end{tikzpicture}`
|
|
503
|
-
|
|
504
|
-
return tex
|
|
505
|
-
}
|
|
506
|
-
}
|