pimath 0.0.124 → 0.0.126

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 (140) hide show
  1. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  2. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]/shelved.patch +192 -0
  3. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]1/shelved.patch +0 -0
  4. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30__Default_Changelist_.xml +4 -0
  5. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43_[Default_Changelist]/shelved.patch +2404 -0
  6. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43__Default_Changelist_.xml +4 -0
  7. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01_[Default_Changelist]/shelved.patch +1362 -0
  8. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01__Default_Changelist_.xml +4 -0
  9. package/dev/pimath.js +7940 -7930
  10. package/dev/pimath.js.map +1 -1
  11. package/dist/pimath.js +219 -227
  12. package/dist/pimath.js.map +1 -1
  13. package/dist/pimath.min.js +1 -1
  14. package/dist/pimath.min.js.map +1 -1
  15. package/docs/assets/main.js +59 -58
  16. package/docs/assets/navigation.js +1 -0
  17. package/docs/assets/search.js +1 -1
  18. package/docs/assets/style.css +1383 -1367
  19. package/docs/classes/Logicalset.Logicalset.html +217 -221
  20. package/docs/classes/Polynom.Rational.html +397 -391
  21. package/docs/classes/Vector-1.Vector.html +490 -494
  22. package/docs/classes/Vector.Point.html +337 -341
  23. package/docs/classes/algebra_equation.Equation.html +790 -796
  24. package/docs/classes/algebra_linearSystem.LinearSystem.html +404 -408
  25. package/docs/classes/algebra_monom.Monom.html +962 -967
  26. package/docs/classes/algebra_polynom.Polynom.html +1275 -1281
  27. package/docs/classes/coefficients_fraction.Fraction.html +934 -939
  28. package/docs/classes/geometry_circle.Circle.html +472 -476
  29. package/docs/classes/geometry_line.Line.html +774 -779
  30. package/docs/classes/geometry_triangle.Triangle.html +429 -429
  31. package/docs/classes/numeric.Numeric.html +265 -269
  32. package/docs/classes/shutingyard.Shutingyard.html +250 -259
  33. package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +83 -89
  34. package/docs/enums/geometry_line.LinePropriety.html +97 -102
  35. package/docs/enums/shutingyard.ShutingyardMode.html +97 -106
  36. package/docs/enums/shutingyard.ShutingyardType.html +111 -120
  37. package/docs/index.html +63 -63
  38. package/docs/interfaces/algebra_equation.ISolution.html +105 -111
  39. package/docs/interfaces/algebra_polynom.IEuclidian.html +87 -93
  40. package/docs/interfaces/geometry_triangle.remarquableLines.html +163 -150
  41. package/docs/modules/Logicalset.html +65 -69
  42. package/docs/modules/Polynom.html +65 -69
  43. package/docs/modules/Vector-1.html +65 -69
  44. package/docs/modules/Vector.html +65 -69
  45. package/docs/modules/algebra_equation.html +69 -75
  46. package/docs/modules/algebra_linearSystem.html +61 -65
  47. package/docs/modules/algebra_monom.html +65 -70
  48. package/docs/modules/algebra_polynom.html +69 -75
  49. package/docs/modules/coefficients_fraction.html +65 -70
  50. package/docs/modules/geometry_circle.html +61 -65
  51. package/docs/modules/geometry_line.html +65 -70
  52. package/docs/modules/geometry_triangle.html +65 -70
  53. package/docs/modules/numeric.html +61 -65
  54. package/docs/modules/shutingyard.html +75 -84
  55. package/docs/types/algebra_monom.literalType.html +61 -66
  56. package/docs/types/algebra_polynom.PolynomParsingType.html +56 -62
  57. package/docs/types/coefficients_fraction.FractionParsingType.html +56 -61
  58. package/docs/types/shutingyard.Token.html +63 -72
  59. package/docs/types/shutingyard.tokenType.html +68 -77
  60. package/docs/variables/shutingyard.tokenConstant.html +61 -70
  61. package/esm/index.js +1 -1
  62. package/esm/index.js.map +1 -1
  63. package/esm/maths/algebra/monom.d.ts +19 -19
  64. package/esm/maths/algebra/monom.js +66 -66
  65. package/esm/maths/algebra/monom.js.map +1 -1
  66. package/esm/maths/algebra/polynom.d.ts +14 -14
  67. package/esm/maths/algebra/polynom.js +72 -50
  68. package/esm/maths/algebra/polynom.js.map +1 -1
  69. package/esm/maths/numeric.js +3 -48
  70. package/esm/maths/numeric.js.map +1 -1
  71. package/esm/maths/randomization/random.d.ts +1 -1
  72. package/esm/maths/randomization/random.js +2 -2
  73. package/esm/maths/randomization/random.js.map +1 -1
  74. package/esm/maths/randomization/rndHelpers.d.ts +1 -1
  75. package/esm/maths/randomization/rndHelpers.js +25 -4
  76. package/esm/maths/randomization/rndHelpers.js.map +1 -1
  77. package/package.json +1 -1
  78. package/src/index.ts +1 -1
  79. package/src/maths/algebra/monom.ts +138 -130
  80. package/src/maths/algebra/polynom.ts +107 -85
  81. package/src/maths/numeric.ts +61 -90
  82. package/src/maths/randomization/random.ts +2 -2
  83. package/src/maths/randomization/rndHelpers.ts +49 -18
  84. package/tests/algebra/linear.test.ts +1 -1
  85. package/tests/algebra/polynom.test.ts +152 -1
  86. package/tests/algebra/study.test.ts +1 -0
  87. package/tests/geometry/circle.test.ts +124 -25
  88. package/tests/geometry/line.test.ts +8 -17
  89. package/tests/numexp.test.ts +10 -2
  90. package/esm/maths/expressions/ExpressionTree.d.ts +0 -17
  91. package/esm/maths/expressions/ExpressionTree.js +0 -150
  92. package/esm/maths/expressions/ExpressionTree.js.map +0 -1
  93. package/esm/maths/expressions/expression.d.ts +0 -27
  94. package/esm/maths/expressions/expression.js +0 -239
  95. package/esm/maths/expressions/expression.js.map +0 -1
  96. package/esm/maths/expressions/expressionFactor.d.ts +0 -36
  97. package/esm/maths/expressions/expressionFactor.js +0 -156
  98. package/esm/maths/expressions/expressionFactor.js.map +0 -1
  99. package/esm/maths/expressions/expressionMember.d.ts +0 -27
  100. package/esm/maths/expressions/expressionMember.js +0 -199
  101. package/esm/maths/expressions/expressionMember.js.map +0 -1
  102. package/esm/maths/expressions/expressionOperators.d.ts +0 -8
  103. package/esm/maths/expressions/expressionOperators.js +0 -42
  104. package/esm/maths/expressions/expressionOperators.js.map +0 -1
  105. package/esm/maths/expressions/expressionParser.d.ts +0 -14
  106. package/esm/maths/expressions/expressionParser.js +0 -259
  107. package/esm/maths/expressions/expressionParser.js.map +0 -1
  108. package/esm/maths/expressions/factors/ExpFactor.d.ts +0 -7
  109. package/esm/maths/expressions/factors/ExpFactor.js +0 -34
  110. package/esm/maths/expressions/factors/ExpFactor.js.map +0 -1
  111. package/esm/maths/expressions/factors/ExpFactorConstant.d.ts +0 -14
  112. package/esm/maths/expressions/factors/ExpFactorConstant.js +0 -52
  113. package/esm/maths/expressions/factors/ExpFactorConstant.js.map +0 -1
  114. package/esm/maths/expressions/factors/ExpFactorExponential.d.ts +0 -8
  115. package/esm/maths/expressions/factors/ExpFactorExponential.js +0 -22
  116. package/esm/maths/expressions/factors/ExpFactorExponential.js.map +0 -1
  117. package/esm/maths/expressions/factors/ExpFactorNumber.d.ts +0 -14
  118. package/esm/maths/expressions/factors/ExpFactorNumber.js +0 -59
  119. package/esm/maths/expressions/factors/ExpFactorNumber.js.map +0 -1
  120. package/esm/maths/expressions/factors/ExpFactorPower.d.ts +0 -13
  121. package/esm/maths/expressions/factors/ExpFactorPower.js +0 -35
  122. package/esm/maths/expressions/factors/ExpFactorPower.js.map +0 -1
  123. package/esm/maths/expressions/factors/ExpFactorTrigo.d.ts +0 -20
  124. package/esm/maths/expressions/factors/ExpFactorTrigo.js +0 -48
  125. package/esm/maths/expressions/factors/ExpFactorTrigo.js.map +0 -1
  126. package/esm/maths/expressions/factors/ExpFactorVariable.d.ts +0 -13
  127. package/esm/maths/expressions/factors/ExpFactorVariable.js +0 -36
  128. package/esm/maths/expressions/factors/ExpFactorVariable.js.map +0 -1
  129. package/esm/maths/expressions/internals.d.ts +0 -12
  130. package/esm/maths/expressions/internals.js +0 -29
  131. package/esm/maths/expressions/internals.js.map +0 -1
  132. package/esm/maths/expressions/numexp.d.ts +0 -19
  133. package/esm/maths/expressions/numexp.js +0 -186
  134. package/esm/maths/expressions/numexp.js.map +0 -1
  135. package/esm/maths/expressions/polynomexp.bkp.d.ts +0 -33
  136. package/esm/maths/expressions/polynomexp.bkp.js +0 -184
  137. package/esm/maths/expressions/polynomexp.bkp.js.map +0 -1
  138. package/esm/maths/expressions/polynomexp.d.ts +0 -52
  139. package/esm/maths/expressions/polynomexp.js +0 -246
  140. package/esm/maths/expressions/polynomexp.js.map +0 -1
@@ -9,8 +9,8 @@ export class rndHelpers {
9
9
  * Random boolean with a percent ratio
10
10
  * @param percent
11
11
  */
12
- static randomBool(percent:number=0.5):boolean{
13
- return Math.random()<percent;
12
+ static randomBool(percent: number = 0.5): boolean {
13
+ return Math.random() < percent;
14
14
  }
15
15
 
16
16
  /**
@@ -18,10 +18,35 @@ export class rndHelpers {
18
18
  * @param a (number) : From this value to the second value. If the second is ommited, this value is the max value.
19
19
  * @param b (number) : To this value. If this is ommited.
20
20
  */
21
- static randomInt(a:number, b?:number):number{
22
- if(b===undefined){return this.randomInt(0,a);}
21
+ static randomInt(a: number, b?: number, exclude?: number[]): number {
22
+ if (b === undefined) {
23
+ if (a >= 0) {
24
+ return this.randomInt(0, a);
25
+ } else {
26
+ return this.randomInt(a, 0);
27
+ }
28
+ }
29
+
30
+ // Same start and end values
31
+ if (a === b) {
32
+ return a
33
+ }
23
34
 
24
- return Math.floor(Math.random() * (b - a + 1) + a);
35
+ // No exclusion
36
+ if (exclude === undefined) {
37
+ return Math.floor(Math.random() * (b - a + 1) + a);
38
+ }
39
+
40
+ // With exclusion
41
+ if (Math.abs(b - a) <= exclude.length) {
42
+ throw new Error('The number of excluded values is too high.')
43
+ }
44
+
45
+ let r = this.randomInt(a, b)
46
+ while (exclude.includes(r)) {
47
+ r = this.randomInt(a, b)
48
+ }
49
+ return r
25
50
  }
26
51
 
27
52
  /**
@@ -29,35 +54,41 @@ export class rndHelpers {
29
54
  * @param max (number) : determine the limits.
30
55
  * @param zero (bool) : determine if zero is allowed or not.
31
56
  */
32
- static randomIntSym(max:number, zero?:boolean):number{
33
- if(zero===false){
34
- return this.randomBool()?this.randomInt(1,max):-this.randomInt(1,max);
35
- }else{
57
+ static randomIntSym(max: number, zero?: boolean): number {
58
+ if (zero === false) {
59
+ return this.randomBool() ? this.randomInt(1, max) : -this.randomInt(1, max);
60
+ } else {
36
61
  return this.randomInt(-max, max);
37
62
  }
38
63
  }
39
64
 
40
65
  static randomPrime(max: number): number {
41
66
  let primes = Numeric.primes()
42
- if(max!==undefined){
43
- primes = primes.filter(x=>x<max)
67
+ if (max !== undefined) {
68
+ primes = primes.filter(x => x < max)
44
69
  }
45
70
  return this.randomItem(primes)
46
71
  }
47
72
 
48
- static randomArray(arr: any[], number?:number):any[]{
49
- if(number===undefined){number = 1}
73
+ static randomArray(arr: any[], number?: number): any[] {
74
+ if (number === undefined) {
75
+ number = 1
76
+ }
50
77
 
51
78
  // Return a clone array
52
- if(arr.length<=0){return Object.values(arr)}
79
+ if (arr.length <= 0) {
80
+ return Object.values(arr)
81
+ }
53
82
 
54
83
  // Randomize the array and return the n first elements.
55
- return rndHelpers.shuffleArray(arr).slice(0,number);
84
+ return rndHelpers.shuffleArray(arr).slice(0, number);
56
85
  }
57
86
 
58
- static randomItem(arr: any[]): any{
59
- if(arr.length===0){return ''}
60
- return this.randomArray(arr, 1)[0]
87
+ static randomItem(arr: any[]): any {
88
+ if (arr.length === 0) {
89
+ return ''
90
+ }
91
+ return arr[this.randomInt(0, arr.length - 1)]
61
92
  }
62
93
 
63
94
  static shuffleArray(arr: any[]): any[] {
@@ -40,7 +40,7 @@ describe('Linear systems tests', () => {
40
40
  E2 = new Polynom('-6x+21y-3z')
41
41
 
42
42
  E1.add(E2);
43
- expect(E1.display).to.be.equal('42y-6z')
43
+ expect(E1.reduce().display).to.be.equal('42y-6z')
44
44
  });
45
45
 
46
46
  it('should use a reduced linear reducation', function () {
@@ -67,6 +67,13 @@ describe('Polynom tests', () => {
67
67
  expect(euclidian.reminder.tex).to.be.equal('12')
68
68
  });
69
69
 
70
+ it('should reduce', () => {
71
+ let P = new Polynom('15x-19x+24+4x-12')
72
+ P.reduce()
73
+ expect(P.tex).to.be.equal('12')
74
+
75
+ })
76
+
70
77
  it('should factorize the polynom', () => {
71
78
  let P = new Polynom('x^2-5x+6')
72
79
 
@@ -99,7 +106,7 @@ describe('Polynom tests', () => {
99
106
  expect(P2.texFactors).to.be.equal('-2x\\left( x+3 \\right)\\left( x-3 \\right)')
100
107
  });
101
108
 
102
- it('should detect if a polynom is factorized', function (){
109
+ it('should detect if a polynom is factorized', function () {
103
110
  let P = new Polynom('x-1')
104
111
  expect(P.isFactorized('x-1')).to.be.true
105
112
  expect(P.isFactorized('x-2')).to.be.false
@@ -164,6 +171,12 @@ describe('Polynom parsing with rational power', () => {
164
171
  })
165
172
  })
166
173
 
174
+ describe("Polynom with multiple variables", () => {
175
+ it('should parse with multiple variables', () => {
176
+ const P = new Polynom('ax')
177
+ expect(P.display).to.be.equal('ax')
178
+ })
179
+ })
167
180
 
168
181
  // describe("test simple", ()=>{
169
182
  // it('should parce this one correctly', ()=>{
@@ -180,3 +193,141 @@ describe('Polynom parsing with rational power', () => {
180
193
  // expect(P.degree().value).to.be.equal(0.5)
181
194
  // })
182
195
  // })
196
+ //
197
+ // describe('Polynom used as complex number', () => {
198
+ // let P = new Polynom('4+3i')
199
+ //
200
+ // P.pow(2)
201
+ //
202
+ // P.monoms.forEach(m => {
203
+ // const d = m.degree('i').value
204
+ // if (d >= 2) {
205
+ // if (d % 2 === 0) {
206
+ // m.coefficient = m.coefficient.multiply((-1) ** (d / 2))
207
+ // m.setLetter('i', 0)
208
+ // } else {
209
+ // m.coefficient = m.coefficient.multiply((-1) ** ((d - 1) / 2))
210
+ // m.setLetter('i', 1)
211
+ // }
212
+ // }
213
+ // })
214
+ // // console.log(P.reduce().tex)
215
+ //
216
+ // })
217
+ //
218
+ // describe("making my test", () => {
219
+ // let models = [
220
+ // {
221
+ // question: 'B \\cdot A^{K}=C',
222
+ // answer: {
223
+ // log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(c, b),
224
+ // poly: (k: Polynom, p: Polynom) => k.clone()
225
+ // }
226
+ // },
227
+ // {
228
+ // question: 'B \\cdot A^{K}=C',
229
+ // answer: {
230
+ // log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(c, b),
231
+ // poly: (k: Polynom, p: Polynom) => k.clone()
232
+ // }
233
+ // },
234
+ // {
235
+ // question: 'A^{K}=B \\cdot A^{P}',
236
+ // answer: {
237
+ // log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(b),
238
+ // poly: (k: Polynom, p: Polynom) => k.clone().subtract(p)
239
+ // }
240
+ // },
241
+ // {
242
+ // question: 'A^{K}=B \\cdot A^{P}',
243
+ // answer: {
244
+ // log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(b),
245
+ // poly: (k: Polynom, p: Polynom) => k.clone().subtract(p)
246
+ // }
247
+ // },
248
+ // {
249
+ // question: 'B \\cdot A^{K} = C \\cdot A^{P}',
250
+ // answer: {
251
+ // log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(c, b),
252
+ // poly: (k: Polynom, p: Polynom) => k.clone().subtract(p)
253
+ // }
254
+ // },
255
+ // {
256
+ // question: 'B \\cdot A^{K} = \\frac{ C }{ A^{P} }',
257
+ // answer: {
258
+ // log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(c, b),
259
+ // poly: (k: Polynom, p: Polynom) => k.clone().add(p)
260
+ // }
261
+ // },
262
+ // {
263
+ // question: 'C \\cdot A^{K} - B = D',
264
+ // answer: {
265
+ // log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(d + b, c),
266
+ // poly: (k: Polynom, p: Polynom) => k.clone()
267
+ // }
268
+ // },
269
+ // {
270
+ // question: 'C \\cdot A^{K} - B = D \\cdot A^{P} ',
271
+ // answer: {
272
+ // log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(b, c - e),
273
+ // poly: (k: Polynom, p: Polynom) => k.clone()
274
+ // }
275
+ // },
276
+ // ]
277
+ //
278
+ //
279
+ // for (let i = 0; i < 15; i++) {
280
+ // console.log(`{\\centering \\huge équations logarithmiques \\\\ }\n\nRésoudre les équations suivantes. Donner la réponse sous forme exacte et avec 4 décimales.`)
281
+ //
282
+ // console.log(`\\begin{enumerate}[(i),itemsep=4em]\n`)
283
+ //
284
+ // for (let m of models) {
285
+ // let a = PiMath.Random.number(2, 9),
286
+ // b = PiMath.Random.number(2, 9),
287
+ // c = PiMath.Random.number(2, 9),
288
+ // d = PiMath.Random.number(1, 9),
289
+ // e = PiMath.Random.number(1, c - 1),
290
+ // k = PiMath.Random.polynom({degree: 1}),
291
+ // p = PiMath.Random.polynom({degree: 1})
292
+ //
293
+ // if (k.monomByDegree(1).coefficient.isNegative()) {
294
+ // k.opposed()
295
+ // }
296
+ // if (p.monomByDegree(1).coefficient.isNegative()) {
297
+ // p.opposed()
298
+ // }
299
+ //
300
+ // let poly = m.answer.poly(k, p),
301
+ // pa = poly.monomByDegree(1).coefficient,
302
+ // pb = poly.monomByDegree(0).coefficient
303
+ //
304
+ // if (pa.isZero()) {
305
+ // k = k.add('x')
306
+ // poly = m.answer.poly(k, p),
307
+ // pa = poly.monomByDegree(1).coefficient,
308
+ // pb = poly.monomByDegree(0).coefficient
309
+ // }
310
+ //
311
+ // const question = m.question
312
+ // .replaceAll('A', a.toString())
313
+ // .replaceAll('B', b.toString())
314
+ // .replaceAll('C', c.toString())
315
+ // .replaceAll('D', d.toString())
316
+ // .replaceAll('K', k.tex)
317
+ // .replaceAll('P', p.tex)
318
+ //
319
+ //
320
+ // const log = m.answer.log(a, b, c, d, e).reduce()
321
+ // let answer = `\\log_{ ${a} }\\left( ${log.tex} \\right)`
322
+ // if (!pb.isZero()) answer = `${answer}${pb.clone().opposed().texWithSign}`
323
+ // if (!pa.isOne()) answer = `\\frac{ ${answer} }{ ${pa.tex} }`
324
+ //
325
+ // let value = ((Math.log10(log.value) / Math.log10(a) - pb.value) / pa.value).toFixed(4)
326
+ //
327
+ // console.log(`\\item \\(\\displaystyle ${question}\\) \\hfill \\( \\trou{ ${answer}=${value} } \\)`)
328
+ // }
329
+ //
330
+ // console.log(`\\end{enumerate}\n\\newpage`)
331
+ // }
332
+ //
333
+ // })
@@ -5,6 +5,7 @@ import {expect} from "chai";
5
5
  import {ASYMPTOTE} from "../../src/maths/algebra/study";
6
6
 
7
7
  describe('Study tests', () => {
8
+
8
9
  it('should get the zeroes', function () {
9
10
  const study = new RationalStudy(
10
11
  // new Rational('x^2-4x-4', 'x+7')
@@ -8,10 +8,10 @@ import {Fraction} from "../../src/maths/coefficients/fraction";
8
8
  describe('Circle', function () {
9
9
  it('should calculate the intersection of a circle and a line', function () {
10
10
  let C = new Circle(
11
- new Point(8, 6),
12
- 20,
13
- true
14
- ),
11
+ new Point(8, 6),
12
+ 20,
13
+ true
14
+ ),
15
15
  LT = new Line('2x+y-32=0'),
16
16
  LS = new Line('3x-y-8=0'),
17
17
  IPT = C.lineIntersection(LT),
@@ -28,7 +28,7 @@ describe('Circle', function () {
28
28
  expect(IPS[1].y.value).to.be.equal(10)
29
29
  });
30
30
 
31
- it('should calculate tangents', function(){
31
+ it('should calculate tangents', function () {
32
32
 
33
33
  // Through one point on the circle
34
34
  const C = new Circle(
@@ -37,18 +37,18 @@ describe('Circle', function () {
37
37
  true
38
38
  ), P = new Point(-5, 7);
39
39
 
40
- expect(C.tangents(P).map(x=>x.tex.canonical)).to.have.all.members(['3x-4y+43=0'])
40
+ expect(C.tangents(P).map(x => x.tex.canonical)).to.have.all.members(['3x-4y+43=0'])
41
41
 
42
42
  // With a slope
43
43
  const D = new Circle('x^2+y^2+10x=2y-6'),
44
44
  slope = new Fraction(-2, 1)
45
45
 
46
- expect(D.tangents(slope).map(x=>x.tex.canonical)).to.have.all.members(['2x+y-1=0', '2x+y+19=0'])
46
+ expect(D.tangents(slope).map(x => x.tex.canonical)).to.have.all.members(['2x+y-1=0', '2x+y+19=0'])
47
47
 
48
48
  const E = new Circle('(x-2)^2+(y-1)^2=5'),
49
49
  P2 = new Point(6, -2)
50
50
 
51
- expect(E.tangents(P2).map(x=>x.tex.canonical)).to.have.all.members(['2x+y-10=0','2x+11y+10=0'])
51
+ expect(E.tangents(P2).map(x => x.tex.canonical)).to.have.all.members(['2x+y-10=0', '2x+11y+10=0'])
52
52
 
53
53
  let P3 = new Point(2, 2)
54
54
  expect(E.tangents(P3)).to.be.empty
@@ -58,27 +58,126 @@ describe('Circle', function () {
58
58
  const C = new Circle('(x-3)^2+(y+4)^2=16'),
59
59
  pts = C.getPointsOnCircle()
60
60
 
61
- expect(pts.map(x=>x.x.display + ',' + x.y.display)).to.have.all.members([ '3,0', '3,-8', '7,-4', '-1,-4' ])
61
+ expect(pts.map(x => x.x.display + ',' + x.y.display)).to.have.all.members(['3,0', '3,-8', '7,-4', '-1,-4'])
62
62
  });
63
63
 
64
- it('should calculate the circle from center and radius', function(){
64
+ it('should calculate the circle from center and radius', function () {
65
65
  let circle = new Circle("x^2+6x+y^2-8y+12=0")
66
66
 
67
- console.log(circle.tex)
67
+ // console.log(circle.tex)
68
68
  })
69
69
 
70
- it('should parse a line', function () {
71
- let a1 = 133.33333333333331,
72
- b1 = 700,
73
- a2 = 134.33333333333331,
74
- b2 = 700.75
75
-
76
- let A = new Point(a1, a2),
77
- B = new Point(b1, b2)
78
-
79
- console.log(A.tex, B.tex)
80
-
81
- let L = new Line(A, B)
82
- console.log(L.tex.canonical)
83
- });
70
+
71
+ // it('temp tests', () => {
72
+ // for (let i = 0; i < 30; i++) {
73
+ // let A = Random.Geometry.point({axis: false}),
74
+ // B = Random.Geometry.point({axis: false})
75
+ //
76
+ // if (Random.bool()) {
77
+ // B.x = new Fraction().zero()
78
+ // } else {
79
+ // B.y = new Fraction().zero()
80
+ // }
81
+ //
82
+ // const c1 = new Circle(A, Random.number(1, 10)),
83
+ // c2 = new Circle(B, Random.number(1, 10))
84
+ //
85
+ // console.log(`(exercice ${i + 1}): déterminer la forme \\textbf{centre-rayon} des équations cartésiennes suivantes. En déduire le centre et le rayon du cercle.
86
+ // \\begin{enumerate}[label=\\Alph*]
87
+ // \\item \\( (\\Gamma_1): ${c1.developed}\\) \\iftoggle{master}{\\(${c1.tex}\\)}{}
88
+ // \\item \\( (\\Gamma_2): ${c2.developed}\\) \\iftoggle{master}{\\(${c2.tex}\\)}{}
89
+ // \\end{enumerate}
90
+ // \\vfill
91
+ // ${i % 2 === 1 ? '\\newpage' : ''}
92
+ // `)
93
+ // }
94
+ // })
95
+ //
96
+ // it('temp tests 2', () => {
97
+ // const q = `(I): Soit \\(\\Gamma_1\\) et \\(\\Gamma_2\\) deux cercles. Déterminer leur position relative à l'aide des informations ci-dessous.
98
+ //
99
+ // \\[(\\Gamma_1): @G1 \\qquad (\\Gamma_2): @G2 \\]
100
+ // \\[\\trou{@R1} \\]
101
+ //
102
+ // \\vspace{3cm}
103
+ // (II): Soit \\((\\Gamma_3): @G3\\) un cercle. Déterminer l'équation cartésienne, sous sa forme centre-sommet, des cercles \\(\\Gamma_4\\) de rayon \\(@RAYON\\) qui sont tangents à \\(\\Gamma_3\\) en sachant que les deux centres ont la même @AXE.\\\\
104
+ // Préciser la position relative entre \\(\\Gamma_3\\) et \\(\\Gamma_4\\)
105
+ // \\[ \\trou{@R2a} \\]
106
+ // \\[ \\trou{@R2b} \\]
107
+ // `
108
+ //
109
+ // for (let i = 0; i < 30; i++) {
110
+ // let A = Random.Geometry.point({axis: false}),
111
+ // triplet = Random.item(Numeric.pythagoricianTripletsWithTarget(
112
+ // Random.item([5, 13, 17, 25, 29, 37, 41])
113
+ // ).filter(tr => {
114
+ // // remove all items with zero values.
115
+ // return tr.every(x => x !== 0)
116
+ // })),
117
+ // B = new Point(
118
+ // A.x.value + triplet[0],
119
+ // A.y.value + triplet[1]
120
+ // ),
121
+ // delta = Random.number(2, triplet[2] - 1),
122
+ // positionRelative = ['extérieure', 'intérieure', 'sécante', 'disjointe'][i % 4],
123
+ // // positionRelative = Random.item(['extérieure', 'intérieure', 'sécante', 'disjointe']),
124
+ // c1: Circle, c2: Circle
125
+ //
126
+ // if (positionRelative === 'extérieure') {
127
+ // c1 = new Circle(A, triplet[2] - delta)
128
+ // c2 = new Circle(B, delta)
129
+ // } else if (positionRelative === 'intérieure') {
130
+ // c1 = new Circle(A, triplet[2] + delta)
131
+ // c2 = new Circle(B, delta)
132
+ // } else if (positionRelative === 'sécante') {
133
+ // c1 = new Circle(A, triplet[2] + delta - Random.number(1, delta - 1))
134
+ // c2 = new Circle(B, delta)
135
+ // } else if (positionRelative === 'disjointe') {
136
+ // c1 = new Circle(A, triplet[2] + delta + 1)
137
+ // c2 = new Circle(B, delta)
138
+ // }
139
+ //
140
+ // const R1 = `\\delta(O_1;O_2)=${A.distanceTo(B).value}\\qquad r_1=${c1.radius.value} \\qquad ${c2.radius.value} \\qquad \\implies \\text{${positionRelative}} `
141
+ //
142
+ //
143
+ // let C = Random.Geometry.point({axis: false}),
144
+ // r1 = Random.number(2, 10),
145
+ // c3 = new Circle(C, r1),
146
+ // // Get a random number from 2 to 10 that is not equal to r1
147
+ // r2 = Random.number(2, 10, [r1]),
148
+ // axis = Random.item(['abscisse', 'ordonnée']),
149
+ // centers: Point[] = []
150
+ //
151
+ // const c3x = c3.center.x.value,
152
+ // c3y = c3.center.y.value
153
+ // if (axis === 'abscisse') {
154
+ //
155
+ // centers = [
156
+ // new Point(c3x, c3y - (r1 + r2)),
157
+ // new Point(c3x, c3y - (r2 - r1)),
158
+ // new Point(c3x, c3y - (r1 - r2)),
159
+ // new Point(c3x, c3y + (r1 + r2))
160
+ // ]
161
+ // } else {
162
+ // centers = [
163
+ // new Point(c3x - (r1 + r2), c3y),
164
+ // new Point(c3x - (r2 - r1), c3y),
165
+ // new Point(c3x - (r1 - r2), c3y),
166
+ // new Point(c3x + (r1 + r2), c3y)
167
+ // ]
168
+ // }
169
+ //
170
+ // console.log(`(exercice ${i + 1}): ` + q
171
+ // .replaceAll('@G1', c1.tex)
172
+ // .replaceAll('@R1', R1)
173
+ // .replaceAll('@G2', c2.tex)
174
+ // .replaceAll('@G3', c3.developed)
175
+ // .replaceAll('@RAYON', r2.toString())
176
+ // .replaceAll('@AXE', axis)
177
+ // .replaceAll('@R2a', centers.slice(0, 2).map(x => new Circle(x, r2).tex).join(' \\qquad '))
178
+ // .replaceAll('@R2b', centers.slice(2, 4).map(x => new Circle(x, r2).tex).join(' \\qquad '))
179
+ // + '\\vfill' + (i % 2 === 1 ? '\\newpage' : '')
180
+ // )
181
+ // }
182
+ // })
84
183
  });
@@ -2,44 +2,35 @@ import {describe} from "mocha";
2
2
  import {Line} from "../../src/maths/geometry/line";
3
3
  import {Point} from "../../src/maths/geometry/point";
4
4
  import {expect} from "chai";
5
- import {Equation} from "../../src/maths/algebra/equation";
6
- import {Polynom} from "../../src/maths/algebra/polynom";
7
- import {Monom} from "../../src/maths/algebra/monom";
8
5
 
9
6
  describe('Geometry Line', function () {
10
7
  it('should evaluate coordinates', function () {
11
8
  let L = new Line('3x-4y+5=0')
12
9
 
13
10
  let y = L.getValueAtX(0)
14
- console.log(y.tex)
11
+ expect(y.display).to.be.equal('5/4')
15
12
  });
16
13
 
17
14
  it('should output nice Tex', function () {
18
15
  let L = new Line('9x-8y-96=0'),
19
16
  tex = L.tex
20
17
 
21
- console.log(tex.canonical)
22
- console.log(tex.equation)
23
- console.log(tex.mxh)
24
- console.log(tex.parametric)
25
-
26
- console.log(tex.system)
18
+ expect(tex.canonical).to.be.equal('9x-8y-96=0')
19
+ expect(tex.equation).to.be.equal('9x-8y=96')
20
+ expect(tex.mxh).to.be.equal('y=\\frac{ 9 }{ 8 }x-12')
21
+ expect(tex.parametric).to.be.equal('\\begin{pmatrix} x \\\\ y \\end{pmatrix} = \\begin{pmatrix} 0 \\\\ -96 \\end{pmatrix} + k\\cdot \\begin{pmatrix} -8 \\\\ -9 \\end{pmatrix}')
22
+ // console.log(tex.system)
27
23
  });
28
24
 
29
25
  it('should parse line from canonical coefficient', function () {
26
+ // parse by canonical coefficients ax+by+c=0
27
+ // a=3, b=2, c=1
30
28
  let L = new Line(3, 2, 1)
31
29
 
32
30
  let P1 = new Point(-2, 3),
33
31
  P2 = new Point(-3, 4)
34
32
  expect(L.isOnLine(P1)).to.be.false
35
33
  expect(L.isOnLine(P2)).to.be.true
36
-
37
- console.log(
38
- (new Polynom(L.OA.y)
39
- .add(new Monom(L.d.y).multiply(new Monom('k'))))
40
- .reorder('k', true)
41
- .tex
42
- )
43
34
  })
44
35
 
45
36
  });
@@ -31,7 +31,7 @@ describe('Numerical expression', () => { // the tests container
31
31
  expect(exprInvalid.isValid).to.be.false
32
32
  });
33
33
 
34
- it('souldd detect invalid expression withouth crahsing', function() {
34
+ it('souldd detect invalid expression withouth crahsing', function () {
35
35
  const exprPourrie = new NumExp('3xsi'),
36
36
  exprOk = new NumExp('3xsin(x)')
37
37
 
@@ -52,7 +52,7 @@ describe('Numerical expression', () => { // the tests container
52
52
  expect(expr2.evaluate({x: 2})).to.be.equal(1)
53
53
  });
54
54
 
55
- it('should calculate sqrt from exp', function(){
55
+ it('should calculate sqrt from exp', function () {
56
56
  let k = new NumExp('nthrt(x,3)')
57
57
  expect(k.evaluate({x: -8})).to.be.equal(-2)
58
58
  expect(k.evaluate({x: 27})).to.be.equal(3)
@@ -78,4 +78,12 @@ describe('Numerical expression', () => { // the tests container
78
78
  let k = new NumExp('ln(3)')
79
79
  expect(+k.evaluate().toFixed(6)).to.be.equal(1.098612)
80
80
  });
81
+
82
+ it('should parse with sqrt and root', () => {
83
+ const expr1 = new NumExp('sqrt(9)');
84
+ expect(expr1.evaluate()).to.be.equal(3);
85
+
86
+ const expr2 = new NumExp('nthrt(8,3)');
87
+ expect(expr2.evaluate()).to.be.equal(2);
88
+ })
81
89
  });
@@ -1,17 +0,0 @@
1
- export declare class ExpressionTree {
2
- private _root;
3
- private _rpn;
4
- constructor(value: string);
5
- get tex(): string;
6
- print(): string;
7
- private _parse;
8
- }
9
- export declare class ExpressionNode {
10
- private _children;
11
- private _op;
12
- constructor(op: string, ...children: (ExpressionNode | string)[]);
13
- get op(): string;
14
- get tex(): string;
15
- isSingle(): boolean;
16
- print(tab: number, stack: string[]): string[];
17
- }