pimath 0.0.121 → 0.0.123
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/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]/shelved.patch +90 -0
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_.xml +4 -0
- package/LICENSE.md +1 -1
- package/dev/pimath.js +27 -21
- package/dev/pimath.js.map +1 -1
- package/dist/pimath.js +27 -21
- package/dist/pimath.js.map +1 -1
- package/dist/pimath.min.js +1 -1
- package/dist/pimath.min.js.map +1 -1
- package/docs/assets/main.js +58 -58
- package/docs/assets/style.css +1367 -1367
- package/docs/classes/Logicalset.Logicalset.html +220 -220
- package/docs/classes/Polynom.Rational.html +390 -390
- package/docs/classes/Vector-1.Vector.html +493 -493
- package/docs/classes/Vector.Point.html +340 -340
- package/docs/classes/algebra_equation.Equation.html +795 -795
- package/docs/classes/algebra_linearSystem.LinearSystem.html +407 -407
- package/docs/classes/algebra_monom.Monom.html +966 -966
- package/docs/classes/algebra_polynom.Polynom.html +1280 -1280
- package/docs/classes/coefficients_fraction.Fraction.html +938 -938
- package/docs/classes/geometry_circle.Circle.html +475 -475
- package/docs/classes/geometry_line.Line.html +778 -778
- package/docs/classes/geometry_triangle.Triangle.html +428 -428
- package/docs/classes/numeric.Numeric.html +268 -268
- package/docs/classes/shutingyard.Shutingyard.html +258 -258
- package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +88 -88
- package/docs/enums/geometry_line.LinePropriety.html +101 -101
- package/docs/enums/shutingyard.ShutingyardMode.html +105 -105
- package/docs/enums/shutingyard.ShutingyardType.html +119 -119
- package/docs/index.html +62 -62
- package/docs/interfaces/algebra_equation.ISolution.html +110 -110
- package/docs/interfaces/algebra_polynom.IEuclidian.html +92 -92
- package/docs/interfaces/geometry_triangle.remarquableLines.html +149 -149
- package/docs/modules/Logicalset.html +68 -68
- package/docs/modules/Polynom.html +68 -68
- package/docs/modules/Vector-1.html +68 -68
- package/docs/modules/Vector.html +68 -68
- package/docs/modules/algebra_equation.html +74 -74
- package/docs/modules/algebra_linearSystem.html +64 -64
- package/docs/modules/algebra_monom.html +69 -69
- package/docs/modules/algebra_polynom.html +74 -74
- package/docs/modules/coefficients_fraction.html +69 -69
- package/docs/modules/geometry_circle.html +64 -64
- package/docs/modules/geometry_line.html +69 -69
- package/docs/modules/geometry_triangle.html +69 -69
- package/docs/modules/numeric.html +64 -64
- package/docs/modules/shutingyard.html +83 -83
- package/docs/types/algebra_monom.literalType.html +65 -65
- package/docs/types/algebra_polynom.PolynomParsingType.html +61 -61
- package/docs/types/coefficients_fraction.FractionParsingType.html +60 -60
- package/docs/types/shutingyard.Token.html +71 -71
- package/docs/types/shutingyard.tokenType.html +76 -76
- package/docs/variables/shutingyard.tokenConstant.html +69 -69
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/maths/algebra/polynom.js +13 -8
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/algebra/study.d.ts +1 -0
- package/esm/maths/algebra/study.js +9 -8
- package/esm/maths/algebra/study.js.map +1 -1
- package/esm/maths/numexp.d.ts +1 -1
- package/esm/maths/numexp.js.map +1 -1
- package/esm/maths/shutingyard.js +4 -4
- package/esm/maths/shutingyard.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +1 -1
- package/src/maths/algebra/polynom.ts +16 -11
- package/src/maths/algebra/study.ts +11 -9
- package/src/maths/numexp.ts +1 -1
- package/src/maths/shutingyard.ts +6 -4
- package/tests/algebra/polynom.test.ts +8 -0
- package/tests/numexp.test.ts +12 -0
|
@@ -91,6 +91,7 @@ export interface StudyConfig {
|
|
|
91
91
|
derivative?: boolean,
|
|
92
92
|
domain?: boolean,
|
|
93
93
|
name?: string,
|
|
94
|
+
variable?: string,
|
|
94
95
|
signs?: boolean,
|
|
95
96
|
variations?: boolean
|
|
96
97
|
}
|
|
@@ -125,6 +126,7 @@ export class Study {
|
|
|
125
126
|
|
|
126
127
|
this._config = {
|
|
127
128
|
name :'f',
|
|
129
|
+
variable: 'x',
|
|
128
130
|
domain :true,
|
|
129
131
|
asymptotes :true,
|
|
130
132
|
signs :true,
|
|
@@ -136,9 +138,11 @@ export class Study {
|
|
|
136
138
|
if (typeof config === 'string') {
|
|
137
139
|
const d = config.split(',')
|
|
138
140
|
this._config = {}
|
|
139
|
-
let n = d.filter(x=>x.includes('(x)'))
|
|
141
|
+
let n = d.filter(x=>x.includes('(') && x.includes(')'))
|
|
142
|
+
|
|
140
143
|
if(n.length===1){
|
|
141
|
-
this._config.name = n[0].split('(
|
|
144
|
+
this._config.name = n[0].split('(')[0]
|
|
145
|
+
this._config.variable = n[0].split('(')[1].split(')')[0]
|
|
142
146
|
}
|
|
143
147
|
this._config.domain = d.includes('d')
|
|
144
148
|
this._config.asymptotes = d.includes('a')
|
|
@@ -150,18 +154,16 @@ export class Study {
|
|
|
150
154
|
}
|
|
151
155
|
}
|
|
152
156
|
|
|
153
|
-
this._name = this._config?.name ?? 'f'
|
|
154
|
-
|
|
155
157
|
this.makeStudy()
|
|
156
158
|
return this
|
|
157
159
|
}
|
|
158
160
|
|
|
159
161
|
get name(): string {
|
|
160
|
-
return this.
|
|
162
|
+
return this._config.name;
|
|
161
163
|
}
|
|
162
164
|
|
|
163
165
|
set name(value: string) {
|
|
164
|
-
this.
|
|
166
|
+
this._config.name = value;
|
|
165
167
|
}
|
|
166
168
|
|
|
167
169
|
get config(): StudyConfig {
|
|
@@ -468,14 +470,14 @@ export class Study {
|
|
|
468
470
|
|
|
469
471
|
private _makeTexFromTableOfSigns = (tos: ITableOfSigns): string => {
|
|
470
472
|
let factors = tos.factors.map(x => `\\(${x.tex}\\)/1`),
|
|
471
|
-
factorsFx = `\\(${this.
|
|
473
|
+
factorsFx = `\\(${this._config.name}(${this._config.variable})\\)/1.2`,
|
|
472
474
|
zeroes = tos.zeroes
|
|
473
475
|
|
|
474
476
|
// Add the last lines "label"
|
|
475
477
|
if (tos.type === TABLE_OF_SIGNS.GROWS) {
|
|
476
|
-
factorsFx = `\\(${this.
|
|
478
|
+
factorsFx = `\\(${this._config.name}'(${this._config.variable})\\)/1.2,\\(f(x${this._config.variable})\\)/2`
|
|
477
479
|
} else if (tos.type === TABLE_OF_SIGNS.VARIATIONS) {
|
|
478
|
-
factorsFx = `\\(${this.
|
|
480
|
+
factorsFx = `\\(${this._config.name}''(${this._config.variable})\\)/1.2,\\(f(${this._config.variable})\\)/2`
|
|
479
481
|
}
|
|
480
482
|
|
|
481
483
|
// Create the tikzPicture header
|
package/src/maths/numexp.ts
CHANGED
package/src/maths/shutingyard.ts
CHANGED
|
@@ -254,22 +254,23 @@ export class Shutingyard {
|
|
|
254
254
|
crtToken = expr[i]
|
|
255
255
|
nextToken = expr[i + 1]
|
|
256
256
|
normalizedExpr += crtToken
|
|
257
|
+
|
|
257
258
|
if (crtToken.match(/[a-zA-Z]/g)) {
|
|
258
259
|
// Current element is a letter.
|
|
259
260
|
// if the next element is a letter, a number or an opening parentheses, add the multiplication sign.
|
|
260
|
-
if (nextToken
|
|
261
|
+
if (nextToken?.match(/[a-zA-Z\d(]/)) {
|
|
261
262
|
normalizedExpr += '*'
|
|
262
263
|
}
|
|
263
264
|
} else if (crtToken.match(/\d/)) {
|
|
264
265
|
// Current element is a number.
|
|
265
266
|
// if the next element is a letter or a parentheses, add the multiplication sign.
|
|
266
|
-
if (nextToken
|
|
267
|
+
if (nextToken?.match(/[a-zA-Z(]/)) {
|
|
267
268
|
normalizedExpr += '*'
|
|
268
269
|
}
|
|
269
270
|
} else if (crtToken === ')') {
|
|
270
271
|
// Current element is a closing parentheses.
|
|
271
272
|
// if the next element is a letter, a number or an opening parentheses, add the multiplication sign
|
|
272
|
-
if (nextToken
|
|
273
|
+
if (nextToken?.match(/[a-zA-Z\d(]/)) {
|
|
273
274
|
normalizedExpr += '*'
|
|
274
275
|
}
|
|
275
276
|
}
|
|
@@ -279,7 +280,7 @@ export class Shutingyard {
|
|
|
279
280
|
}
|
|
280
281
|
|
|
281
282
|
// add the last token
|
|
282
|
-
return normalizedExpr + nextToken
|
|
283
|
+
return normalizedExpr + (nextToken===undefined?'':nextToken)
|
|
283
284
|
}
|
|
284
285
|
|
|
285
286
|
// /**
|
|
@@ -374,6 +375,7 @@ export class Shutingyard {
|
|
|
374
375
|
// Normalize the input if required.
|
|
375
376
|
if (uniformize || this._uniformize) expr = this.normalize(expr)
|
|
376
377
|
|
|
378
|
+
|
|
377
379
|
let securityLoopLvl1 = 50,
|
|
378
380
|
securityLoopLvl2_default = 50,
|
|
379
381
|
securityLoopLvl2;
|
|
@@ -139,6 +139,14 @@ describe('Polynom tests', () => {
|
|
|
139
139
|
expect(Q.isFactorized('4(2x+5)(x-6)')).to.be.true
|
|
140
140
|
expect(Q.isFactorized('(8x+20)(x-6)')).to.be.false
|
|
141
141
|
expect(Q.isFactorized('(8x+20)(x-6)', true)).to.be.true
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('should check if a polynom is developed', function () {
|
|
145
|
+
let P = new Polynom('x(x+1)')
|
|
146
|
+
|
|
147
|
+
expect(P.isDeveloped('x^(2)+x')).true
|
|
148
|
+
expect(P.isDeveloped('x^2+x')).true
|
|
149
|
+
expect(P.isDeveloped('x(x+1)')).false
|
|
142
150
|
|
|
143
151
|
});
|
|
144
152
|
|
package/tests/numexp.test.ts
CHANGED
|
@@ -61,4 +61,16 @@ describe('Numerical expression', () => { // the tests container
|
|
|
61
61
|
expect(p.evaluate({x: 16})).to.be.equal(2)
|
|
62
62
|
expect(p.evaluate({x: -16})).to.be.NaN
|
|
63
63
|
})
|
|
64
|
+
|
|
65
|
+
it('should work with constant', function () {
|
|
66
|
+
|
|
67
|
+
let k = new NumExp('2pi*x')
|
|
68
|
+
expect(+k.evaluate({x: 1}).toFixed(6)).to.be.equal(6.283185)
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should work with constant but without variables', function () {
|
|
72
|
+
|
|
73
|
+
let k = new NumExp('2pi')
|
|
74
|
+
expect(+k.evaluate().toFixed(6)).to.be.equal(6.283185)
|
|
75
|
+
});
|
|
64
76
|
});
|