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.
Files changed (73) hide show
  1. package/.eslintrc.js +23 -23
  2. package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]/shelved.patch +90 -0
  3. package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_.xml +4 -0
  4. package/LICENSE.md +1 -1
  5. package/dev/pimath.js +27 -21
  6. package/dev/pimath.js.map +1 -1
  7. package/dist/pimath.js +27 -21
  8. package/dist/pimath.js.map +1 -1
  9. package/dist/pimath.min.js +1 -1
  10. package/dist/pimath.min.js.map +1 -1
  11. package/docs/assets/main.js +58 -58
  12. package/docs/assets/style.css +1367 -1367
  13. package/docs/classes/Logicalset.Logicalset.html +220 -220
  14. package/docs/classes/Polynom.Rational.html +390 -390
  15. package/docs/classes/Vector-1.Vector.html +493 -493
  16. package/docs/classes/Vector.Point.html +340 -340
  17. package/docs/classes/algebra_equation.Equation.html +795 -795
  18. package/docs/classes/algebra_linearSystem.LinearSystem.html +407 -407
  19. package/docs/classes/algebra_monom.Monom.html +966 -966
  20. package/docs/classes/algebra_polynom.Polynom.html +1280 -1280
  21. package/docs/classes/coefficients_fraction.Fraction.html +938 -938
  22. package/docs/classes/geometry_circle.Circle.html +475 -475
  23. package/docs/classes/geometry_line.Line.html +778 -778
  24. package/docs/classes/geometry_triangle.Triangle.html +428 -428
  25. package/docs/classes/numeric.Numeric.html +268 -268
  26. package/docs/classes/shutingyard.Shutingyard.html +258 -258
  27. package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +88 -88
  28. package/docs/enums/geometry_line.LinePropriety.html +101 -101
  29. package/docs/enums/shutingyard.ShutingyardMode.html +105 -105
  30. package/docs/enums/shutingyard.ShutingyardType.html +119 -119
  31. package/docs/index.html +62 -62
  32. package/docs/interfaces/algebra_equation.ISolution.html +110 -110
  33. package/docs/interfaces/algebra_polynom.IEuclidian.html +92 -92
  34. package/docs/interfaces/geometry_triangle.remarquableLines.html +149 -149
  35. package/docs/modules/Logicalset.html +68 -68
  36. package/docs/modules/Polynom.html +68 -68
  37. package/docs/modules/Vector-1.html +68 -68
  38. package/docs/modules/Vector.html +68 -68
  39. package/docs/modules/algebra_equation.html +74 -74
  40. package/docs/modules/algebra_linearSystem.html +64 -64
  41. package/docs/modules/algebra_monom.html +69 -69
  42. package/docs/modules/algebra_polynom.html +74 -74
  43. package/docs/modules/coefficients_fraction.html +69 -69
  44. package/docs/modules/geometry_circle.html +64 -64
  45. package/docs/modules/geometry_line.html +69 -69
  46. package/docs/modules/geometry_triangle.html +69 -69
  47. package/docs/modules/numeric.html +64 -64
  48. package/docs/modules/shutingyard.html +83 -83
  49. package/docs/types/algebra_monom.literalType.html +65 -65
  50. package/docs/types/algebra_polynom.PolynomParsingType.html +61 -61
  51. package/docs/types/coefficients_fraction.FractionParsingType.html +60 -60
  52. package/docs/types/shutingyard.Token.html +71 -71
  53. package/docs/types/shutingyard.tokenType.html +76 -76
  54. package/docs/variables/shutingyard.tokenConstant.html +69 -69
  55. package/esm/index.js +1 -1
  56. package/esm/index.js.map +1 -1
  57. package/esm/maths/algebra/polynom.js +13 -8
  58. package/esm/maths/algebra/polynom.js.map +1 -1
  59. package/esm/maths/algebra/study.d.ts +1 -0
  60. package/esm/maths/algebra/study.js +9 -8
  61. package/esm/maths/algebra/study.js.map +1 -1
  62. package/esm/maths/numexp.d.ts +1 -1
  63. package/esm/maths/numexp.js.map +1 -1
  64. package/esm/maths/shutingyard.js +4 -4
  65. package/esm/maths/shutingyard.js.map +1 -1
  66. package/package.json +5 -5
  67. package/src/index.ts +1 -1
  68. package/src/maths/algebra/polynom.ts +16 -11
  69. package/src/maths/algebra/study.ts +11 -9
  70. package/src/maths/numexp.ts +1 -1
  71. package/src/maths/shutingyard.ts +6 -4
  72. package/tests/algebra/polynom.test.ts +8 -0
  73. 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('(x)')[0]
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._name;
162
+ return this._config.name;
161
163
  }
162
164
 
163
165
  set name(value: string) {
164
- this._name = value;
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._name}(x)\\)/1.2`,
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._name}'(x)\\)/1.2,\\(f(x)\\)/2`
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._name}''(x)\\)/1.2,\\(f(x)\\)/2`
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
@@ -97,7 +97,7 @@ export class NumExp {
97
97
  stack.push(this._numberCorrection(value))
98
98
  }
99
99
 
100
- evaluate(values: { [Key: string]: number }): number {
100
+ evaluate(values?: { [Key: string]: number }): number {
101
101
  const stack: number[] = []
102
102
 
103
103
  if(this._rpn===null){
@@ -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.match(/[a-zA-Z\d(]/)) {
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.match(/[a-zA-Z(]/)) {
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.match(/[a-zA-Z\d(]/)) {
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
 
@@ -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
  });