pimath 0.0.97 → 0.0.99
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/pi.js +35 -23
- package/dist/pi.js.map +1 -1
- package/dist/pi.min.js +1 -1
- package/dist/pi.min.js.map +1 -1
- package/esm/maths/algebra/polynom.js +1 -1
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/algebra/rational.d.ts +2 -1
- package/esm/maths/algebra/rational.js +2 -2
- package/esm/maths/algebra/rational.js.map +1 -1
- package/esm/maths/algebra/study/rationalStudy.d.ts +1 -1
- package/esm/maths/algebra/study/rationalStudy.js.map +1 -1
- package/esm/maths/algebra/study.d.ts +6 -2
- package/esm/maths/algebra/study.js +32 -20
- package/esm/maths/algebra/study.js.map +1 -1
- package/package.json +1 -1
- package/src/maths/algebra/polynom.ts +1 -1
- package/src/maths/algebra/rational.ts +3 -2
- package/src/maths/algebra/study/rationalStudy.ts +1 -1
- package/src/maths/algebra/study.ts +38 -22
- package/tests/algebra/polynom.test.ts +24 -0
- package/tests/algebra/study.test.ts +15 -2
|
@@ -117,13 +117,13 @@ export class Study {
|
|
|
117
117
|
private _signs: ITableOfSigns
|
|
118
118
|
private _variations: ITableOfSigns
|
|
119
119
|
private _zeroes: IZero[]
|
|
120
|
-
private
|
|
121
|
-
private
|
|
120
|
+
private _config: StudyConfig
|
|
121
|
+
private _name: string
|
|
122
122
|
|
|
123
123
|
constructor(fx: StudyableFunction, config?: StudyConfig | string) {
|
|
124
124
|
this.fx = fx
|
|
125
125
|
|
|
126
|
-
this.
|
|
126
|
+
this._config = {
|
|
127
127
|
name :'f',
|
|
128
128
|
domain :true,
|
|
129
129
|
asymptotes :true,
|
|
@@ -135,27 +135,43 @@ export class Study {
|
|
|
135
135
|
if (config) {
|
|
136
136
|
if (typeof config === 'string') {
|
|
137
137
|
const d = config.split(',')
|
|
138
|
-
this.
|
|
138
|
+
this._config = {}
|
|
139
139
|
let n = d.filter(x=>x.includes('(x)'))
|
|
140
140
|
if(n.length===1){
|
|
141
|
-
this.
|
|
141
|
+
this._config.name = n[0].split('(x)')[0]
|
|
142
142
|
}
|
|
143
|
-
this.
|
|
144
|
-
this.
|
|
145
|
-
this.
|
|
146
|
-
this.
|
|
147
|
-
this.
|
|
143
|
+
this._config.domain = d.includes('d')
|
|
144
|
+
this._config.asymptotes = d.includes('a')
|
|
145
|
+
this._config.signs = d.includes('signs')
|
|
146
|
+
this._config.derivative = d.includes('dx')
|
|
147
|
+
this._config.variations = d.includes('ddx')
|
|
148
148
|
} else {
|
|
149
|
-
this.
|
|
149
|
+
this._config = config
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
this.
|
|
153
|
+
this._name = this._config?.name ?? 'f'
|
|
154
154
|
|
|
155
155
|
this.makeStudy()
|
|
156
156
|
return this
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
get name(): string {
|
|
160
|
+
return this._name;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
set name(value: string) {
|
|
164
|
+
this._name = value;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
get config(): StudyConfig {
|
|
168
|
+
return this._config;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
set config(value: StudyConfig) {
|
|
172
|
+
this._config = value;
|
|
173
|
+
}
|
|
174
|
+
|
|
159
175
|
get zeroes(): IZero[] {
|
|
160
176
|
return this._zeroes;
|
|
161
177
|
}
|
|
@@ -191,20 +207,20 @@ export class Study {
|
|
|
191
207
|
makeStudy = (): void => {
|
|
192
208
|
this._zeroes = this.makeZeroes()
|
|
193
209
|
|
|
194
|
-
if (this.
|
|
210
|
+
if (this._config.signs) this._signs = this.makeSigns()
|
|
195
211
|
|
|
196
|
-
if (this.
|
|
212
|
+
if (this._config.asymptotes) this._asymptotes = this.makeAsymptotes()
|
|
197
213
|
|
|
198
|
-
if (this.
|
|
214
|
+
if (this._config.derivative) this._derivative = this.makeDerivative()
|
|
199
215
|
|
|
200
|
-
if (this.
|
|
216
|
+
if (this._config.variations) this._variations = this.makeVariation()
|
|
201
217
|
|
|
202
218
|
// Table of signs / derivative / variation
|
|
203
|
-
if (this.
|
|
219
|
+
if (this._config.signs) this._signs.tex = this.texSigns
|
|
204
220
|
|
|
205
|
-
if (this.
|
|
221
|
+
if (this._config.derivative) this._derivative.tex = this.texGrows
|
|
206
222
|
|
|
207
|
-
if (this.
|
|
223
|
+
if (this._config.variations) this._variations.tex = this.texVariations
|
|
208
224
|
};
|
|
209
225
|
|
|
210
226
|
indexOfZero = (zeroes: IZero[], zero: IZero | ISolution): number => {
|
|
@@ -452,14 +468,14 @@ export class Study {
|
|
|
452
468
|
|
|
453
469
|
private _makeTexFromTableOfSigns = (tos: ITableOfSigns): string => {
|
|
454
470
|
let factors = tos.factors.map(x => `\\(${x.tex}\\)/1`),
|
|
455
|
-
factorsFx = `\\(${this.
|
|
471
|
+
factorsFx = `\\(${this._name}(x)\\)/1.2`,
|
|
456
472
|
zeroes = tos.zeroes
|
|
457
473
|
|
|
458
474
|
// Add the last lines "label"
|
|
459
475
|
if (tos.type === TABLE_OF_SIGNS.GROWS) {
|
|
460
|
-
factorsFx = `\\(${this.
|
|
476
|
+
factorsFx = `\\(${this._name}'(x)\\)/1.2,\\(f(x)\\)/2`
|
|
461
477
|
} else if (tos.type === TABLE_OF_SIGNS.VARIATIONS) {
|
|
462
|
-
factorsFx = `\\(${this.
|
|
478
|
+
factorsFx = `\\(${this._name}''(x)\\)/1.2,\\(f(x)\\)/2`
|
|
463
479
|
}
|
|
464
480
|
|
|
465
481
|
// Create the tikzPicture header
|
|
@@ -99,6 +99,18 @@ describe('Polynom tests', () => {
|
|
|
99
99
|
P2.factorize()
|
|
100
100
|
expect(P2.texFactors).to.be.equal('-2x\\left( x+3 \\right)\\left( x-3 \\right)')
|
|
101
101
|
});
|
|
102
|
+
|
|
103
|
+
it('should detect if a polynom is factorized', function (){
|
|
104
|
+
let P = new Polynom('x-1')
|
|
105
|
+
|
|
106
|
+
expect(P.isFactorized('x-1')).to.be.true
|
|
107
|
+
expect(P.isFactorized('x-2')).to.be.false
|
|
108
|
+
|
|
109
|
+
let Q = new Polynom('(x-1)(x+2)')
|
|
110
|
+
|
|
111
|
+
expect(Q.isFactorized('(x+2)(x-1)')).to.be.true
|
|
112
|
+
expect(Q.isFactorized('x^2+x-2')).to.be.false
|
|
113
|
+
})
|
|
102
114
|
})
|
|
103
115
|
|
|
104
116
|
describe('Polynom parsing with rational power', () => {
|
|
@@ -109,6 +121,18 @@ describe('Polynom parsing with rational power', () => {
|
|
|
109
121
|
})
|
|
110
122
|
|
|
111
123
|
|
|
124
|
+
describe("test simple", ()=>{
|
|
125
|
+
it('should parce this one correctly', ()=>{
|
|
126
|
+
const P = new Polynom('-(x+2)(x-1)(x-1)(5x+4)')
|
|
127
|
+
const Q = new Polynom('(2+x)^2(1-x)^3')
|
|
128
|
+
|
|
129
|
+
console.log(Q.tex)
|
|
130
|
+
console.log(Q.derivative().tex)
|
|
131
|
+
console.log(P.tex)
|
|
132
|
+
console.log(P.displayFactors)
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
|
|
112
136
|
// TODO: working with roots !
|
|
113
137
|
// describe('WIP : working with roots', ()=>{
|
|
114
138
|
// it('should parse with roots coefficient', ()=>{
|
|
@@ -11,8 +11,6 @@ describe('Study tests', () => {
|
|
|
11
11
|
new Rational('(3x-2)(x-3)(x+4)', 'x^2-5x+6')
|
|
12
12
|
)
|
|
13
13
|
let AO = study.asymptotes.filter(x => x.type === ASYMPTOTE.SLOPE)[0]
|
|
14
|
-
|
|
15
|
-
console.log(AO.tableOfSign.signs)
|
|
16
14
|
});
|
|
17
15
|
|
|
18
16
|
it('should create draw code block', function () {
|
|
@@ -38,4 +36,19 @@ describe('Study tests', () => {
|
|
|
38
36
|
|
|
39
37
|
expect(study.asymptotes[0].position).to.have.all.members(["LB", "RT"])
|
|
40
38
|
});
|
|
39
|
+
|
|
40
|
+
it('should get only the domain and the signs of a rational', function () {
|
|
41
|
+
const R = new Rational('x-3', 'x^2-4')
|
|
42
|
+
const study = R.study('\\delta(x),d,signs')
|
|
43
|
+
|
|
44
|
+
console.log('CONFIG')
|
|
45
|
+
console.log(study.config)
|
|
46
|
+
console.log('DOMAIN')
|
|
47
|
+
console.log(study.domain)
|
|
48
|
+
console.log('SIGNS')
|
|
49
|
+
console.log(Object.keys(study.signs))
|
|
50
|
+
|
|
51
|
+
console.log(study.signs.tex)
|
|
52
|
+
console.log(study.signs.signs)
|
|
53
|
+
});
|
|
41
54
|
})
|