pimath 0.0.132 → 0.0.133
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 -1
- package/package.json +2 -3
- package/dist/pimath.d.ts +0 -39
- package/lib/main.ts +0 -1
- package/lib/maths/algebra/equation.ts +0 -891
- package/lib/maths/algebra/linearSystem.ts +0 -369
- package/lib/maths/algebra/logicalset.ts +0 -183
- package/lib/maths/algebra/monom.ts +0 -1027
- package/lib/maths/algebra/polynom.ts +0 -1537
- package/lib/maths/algebra/rational.ts +0 -244
- package/lib/maths/algebra/study/rationalStudy.ts +0 -287
- package/lib/maths/algebra/study.ts +0 -506
- package/lib/maths/coefficients/fraction.ts +0 -593
- package/lib/maths/coefficients/nthRoot.ts +0 -148
- package/lib/maths/geometry/circle.ts +0 -379
- package/lib/maths/geometry/line.ts +0 -604
- package/lib/maths/geometry/point.ts +0 -215
- package/lib/maths/geometry/triangle.ts +0 -368
- package/lib/maths/geometry/vector.ts +0 -243
- package/lib/maths/numeric.ts +0 -162
- package/lib/maths/numexp.ts +0 -198
- package/lib/maths/randomization/random.ts +0 -80
- package/lib/maths/randomization/randomCore.ts +0 -19
- package/lib/maths/randomization/rndFraction.ts +0 -47
- package/lib/maths/randomization/rndGeometryCircle.ts +0 -50
- package/lib/maths/randomization/rndGeometryLine.ts +0 -53
- package/lib/maths/randomization/rndGeometryPoint.ts +0 -69
- package/lib/maths/randomization/rndHelpers.ts +0 -107
- package/lib/maths/randomization/rndMonom.ts +0 -57
- package/lib/maths/randomization/rndPolynom.ts +0 -90
- package/lib/maths/randomization/rndTypes.ts +0 -43
- package/lib/maths/shutingyard.ts +0 -496
- package/lib/pimath.ts +0 -40
|
@@ -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.ts";
|
|
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
|
-
}
|