pimath 0.0.16 → 0.0.20

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 (93) hide show
  1. package/dev/index.html +39 -9
  2. package/dev/pi.js +883 -806
  3. package/dev/pi.js.map +1 -1
  4. package/dist/pi.js +1 -1
  5. package/dist/pi.js.map +1 -1
  6. package/esm/main.js +24 -22
  7. package/esm/main.js.map +1 -1
  8. package/esm/maths/algebra/equation.d.ts +3 -1
  9. package/esm/maths/algebra/equation.js +32 -25
  10. package/esm/maths/algebra/equation.js.map +1 -1
  11. package/esm/maths/algebra/index.js +18 -6
  12. package/esm/maths/algebra/index.js.map +1 -1
  13. package/esm/maths/algebra/linearSystem.d.ts +1 -1
  14. package/esm/maths/algebra/linearSystem.js +19 -15
  15. package/esm/maths/algebra/linearSystem.js.map +1 -1
  16. package/esm/maths/algebra/logicalset.js +7 -3
  17. package/esm/maths/algebra/logicalset.js.map +1 -1
  18. package/esm/maths/algebra/monom.d.ts +15 -18
  19. package/esm/maths/algebra/monom.js +182 -84
  20. package/esm/maths/algebra/monom.js.map +1 -1
  21. package/esm/maths/algebra/polynom.d.ts +5 -26
  22. package/esm/maths/algebra/polynom.js +64 -220
  23. package/esm/maths/algebra/polynom.js.map +1 -1
  24. package/esm/maths/algebra/rational.js +15 -10
  25. package/esm/maths/algebra/rational.js.map +1 -1
  26. package/esm/maths/coefficients/fraction.d.ts +20 -10
  27. package/esm/maths/coefficients/fraction.js +83 -15
  28. package/esm/maths/coefficients/fraction.js.map +1 -1
  29. package/esm/maths/coefficients/index.js +14 -2
  30. package/esm/maths/coefficients/index.js.map +1 -1
  31. package/esm/maths/coefficients/nthroot.js +5 -1
  32. package/esm/maths/coefficients/nthroot.js.map +1 -1
  33. package/esm/maths/geometry/circle.d.ts +16 -1
  34. package/esm/maths/geometry/circle.js +95 -14
  35. package/esm/maths/geometry/circle.js.map +1 -1
  36. package/esm/maths/geometry/index.js +17 -5
  37. package/esm/maths/geometry/index.js.map +1 -1
  38. package/esm/maths/geometry/line.d.ts +20 -4
  39. package/esm/maths/geometry/line.js +123 -49
  40. package/esm/maths/geometry/line.js.map +1 -1
  41. package/esm/maths/geometry/point.d.ts +1 -0
  42. package/esm/maths/geometry/point.js +22 -12
  43. package/esm/maths/geometry/point.js.map +1 -1
  44. package/esm/maths/geometry/triangle.js +31 -27
  45. package/esm/maths/geometry/triangle.js.map +1 -1
  46. package/esm/maths/geometry/vector.d.ts +0 -1
  47. package/esm/maths/geometry/vector.js +22 -21
  48. package/esm/maths/geometry/vector.js.map +1 -1
  49. package/esm/maths/numeric.js +5 -1
  50. package/esm/maths/numeric.js.map +1 -1
  51. package/esm/maths/random/index.d.ts +3 -1
  52. package/esm/maths/random/index.js +32 -14
  53. package/esm/maths/random/index.js.map +1 -1
  54. package/esm/maths/random/randomCore.js +5 -1
  55. package/esm/maths/random/randomCore.js.map +1 -1
  56. package/esm/maths/random/rndFraction.d.ts +9 -0
  57. package/esm/maths/random/rndFraction.js +30 -0
  58. package/esm/maths/random/rndFraction.js.map +1 -0
  59. package/esm/maths/random/rndHelpers.js +5 -1
  60. package/esm/maths/random/rndHelpers.js.map +1 -1
  61. package/esm/maths/random/rndMonom.d.ts +2 -2
  62. package/esm/maths/random/rndMonom.js +15 -8
  63. package/esm/maths/random/rndMonom.js.map +1 -1
  64. package/esm/maths/random/rndPolynom.js +14 -11
  65. package/esm/maths/random/rndPolynom.js.map +1 -1
  66. package/esm/maths/random/rndTypes.d.ts +5 -0
  67. package/esm/maths/random/rndTypes.js +2 -1
  68. package/esm/maths/shutingyard.js +5 -1
  69. package/esm/maths/shutingyard.js.map +1 -1
  70. package/package.json +5 -5
  71. package/src/maths/algebra/equation.ts +13 -7
  72. package/src/maths/algebra/linearSystem.ts +3 -3
  73. package/src/maths/algebra/monom.ts +764 -612
  74. package/src/maths/algebra/monom_bck.backup +746 -0
  75. package/src/maths/algebra/polynom.ts +977 -1174
  76. package/src/maths/algebra/rational.ts +6 -6
  77. package/src/maths/coefficients/fraction.ts +98 -27
  78. package/src/maths/geometry/circle.ts +133 -21
  79. package/src/maths/geometry/line.ts +162 -58
  80. package/src/maths/geometry/point.ts +9 -0
  81. package/src/maths/geometry/vector.ts +1 -5
  82. package/src/maths/random/index.ts +7 -1
  83. package/src/maths/random/rndFraction.ts +37 -0
  84. package/src/maths/random/rndMonom.ts +6 -3
  85. package/src/maths/random/rndPolynom.ts +0 -1
  86. package/src/maths/random/rndTypes.ts +5 -0
  87. package/src/maths/shutingyard.ts +2 -0
  88. package/tests/algebra/monom.test.ts +47 -8
  89. package/tests/algebra/polynom.test.ts +13 -22
  90. package/tests/coefficients/fraction.test.ts +35 -38
  91. package/tests/shutingyard.test.ts +0 -1
  92. package/tsconfig.json +2 -2
  93. package/tsconfig.testing.json +28 -0
@@ -1,9 +1,11 @@
1
- import { Monom } from './monom';
2
- import { Shutingyard } from '../shutingyard';
3
- import { Numeric } from '../numeric';
4
- import { Random } from "../random";
5
- import { Fraction } from "../coefficients";
6
- export class Polynom {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Polynom = void 0;
4
+ const monom_1 = require("./monom");
5
+ const shutingyard_1 = require("../shutingyard");
6
+ const numeric_1 = require("../numeric");
7
+ const coefficients_1 = require("../coefficients");
8
+ class Polynom {
7
9
  _rawString;
8
10
  _monoms;
9
11
  _factors;
@@ -16,10 +18,6 @@ export class Polynom {
16
18
  }
17
19
  return this;
18
20
  }
19
- get isPolynom() {
20
- return true;
21
- }
22
- ;
23
21
  get monoms() {
24
22
  return this._monoms;
25
23
  }
@@ -107,9 +105,7 @@ export class Polynom {
107
105
  this._rawString = inputStr;
108
106
  if (inputStr !== '' && !isNaN(Number(inputStr))) {
109
107
  this.empty();
110
- let m = new Monom();
111
- m.coefficient = new Fraction(inputStr);
112
- m.literalStr = '';
108
+ let m = new monom_1.Monom(inputStr);
113
109
  this.add(m);
114
110
  return this;
115
111
  }
@@ -117,11 +113,11 @@ export class Polynom {
117
113
  }
118
114
  else if (/^[a-z]/.test(inputStr)) {
119
115
  this.empty();
120
- let fractions = values.map(x => new Fraction(x));
116
+ let fractions = values.map(x => new coefficients_1.Fraction(x));
121
117
  if (inputStr.length > 1) {
122
118
  let letters = inputStr.split(''), i = 0;
123
119
  for (let F of fractions) {
124
- let m = new Monom();
120
+ let m = new monom_1.Monom();
125
121
  m.coefficient = F.clone();
126
122
  m.literalStr = letters[i] || '';
127
123
  this.add(m);
@@ -131,7 +127,7 @@ export class Polynom {
131
127
  else {
132
128
  let n = fractions.length - 1;
133
129
  for (let F of fractions) {
134
- let m = new Monom();
130
+ let m = new monom_1.Monom();
135
131
  m.coefficient = F.clone();
136
132
  m.literalStr = `${inputStr}^${n}`;
137
133
  this.add(m);
@@ -145,7 +141,7 @@ export class Polynom {
145
141
  }
146
142
  };
147
143
  shutingYardToReducedPolynom = (inputStr) => {
148
- const SY = new Shutingyard().parse(inputStr);
144
+ const SY = new shutingyard_1.Shutingyard().parse(inputStr);
149
145
  const rpn = SY.rpn;
150
146
  let m1;
151
147
  let m2;
@@ -153,7 +149,7 @@ export class Polynom {
153
149
  for (const element of rpn) {
154
150
  if (element.tokenType === 'coefficient' || element.tokenType === 'variable') {
155
151
  tempPolynom = new Polynom().zero();
156
- tempPolynom.monoms = [new Monom(element.token)];
152
+ tempPolynom.monoms = [new monom_1.Monom(element.token)];
157
153
  stack.push(tempPolynom.clone());
158
154
  }
159
155
  else if (element.tokenType === 'operation') {
@@ -189,13 +185,13 @@ export class Polynom {
189
185
  };
190
186
  zero = () => {
191
187
  this._monoms = [];
192
- this._monoms.push(new Monom().zero());
188
+ this._monoms.push(new monom_1.Monom().zero());
193
189
  this._rawString = '0';
194
190
  return this;
195
191
  };
196
192
  one = () => {
197
193
  this._monoms = [];
198
- this._monoms.push(new Monom().one());
194
+ this._monoms.push(new monom_1.Monom().one());
199
195
  this._rawString = '1';
200
196
  return this;
201
197
  };
@@ -204,99 +200,52 @@ export class Polynom {
204
200
  this._rawString = '';
205
201
  return this;
206
202
  };
207
- random(config) {
208
- return Random.polynom(config);
209
- }
210
- _randomizeDefaults = {
211
- degree: 2,
212
- unit: true,
213
- fractions: false,
214
- factorable: false,
215
- letters: 'x',
216
- allowNullMonom: false,
217
- numberOfMonoms: false
218
- };
219
- get randomizeDefaults() {
220
- return this._randomizeDefaults;
221
- }
222
- set randomizeDefaults(value) {
223
- this._randomizeDefaults = value;
224
- }
225
- randomize = (config) => {
226
- let P = new Polynom();
227
- if (config === undefined) {
228
- config = {};
229
- }
230
- for (let k in this._randomizeDefaults) {
231
- if (config[k] === undefined) {
232
- config[k] = this._randomizeDefaults[k];
233
- }
234
- }
235
- return P;
236
- };
237
- rndFactorable = (degree = 2, unit = false, letters = 'x') => {
238
- this._factors = [];
239
- for (let i = 0; i < degree; i++) {
240
- let factorUnit = unit === true || i >= unit, p = Random.polynom({
241
- degree: 1,
242
- unit: factorUnit,
243
- fraction: false,
244
- letters
245
- });
246
- this._factors.push(p);
247
- }
248
- this.empty().monoms = this._factors[0].monoms;
249
- for (let i = 1; i < this._factors.length; i++) {
250
- this.multiply(this._factors[i]);
251
- }
252
- return this;
253
- };
254
203
  opposed = () => {
255
204
  this._monoms = this._monoms.map(m => m.opposed());
256
205
  return this;
257
206
  };
258
207
  add = (...values) => {
259
208
  for (let value of values) {
260
- if (value.isPolynom) {
209
+ if (value instanceof Polynom) {
261
210
  this._monoms = this._monoms.concat(value.monoms);
262
211
  }
263
- else if (value.isMonom) {
212
+ else if (value instanceof monom_1.Monom) {
264
213
  this._monoms.push(value.clone());
265
214
  }
266
215
  else if (Number.isSafeInteger(value)) {
267
- this._monoms.push(new Monom(value.toString()));
216
+ this._monoms.push(new monom_1.Monom(value.toString()));
268
217
  }
269
218
  else {
270
- this._monoms.push(new Monom(value));
219
+ this._monoms.push(new monom_1.Monom(value));
271
220
  }
272
221
  }
273
222
  return this.reduce();
274
223
  };
275
224
  subtract = (...values) => {
276
225
  for (let value of values) {
277
- if (value.isPolynom) {
226
+ if (value instanceof Polynom) {
278
227
  this._monoms = this._monoms.concat(value.clone().opposed().monoms);
279
228
  }
280
- else if (value.isMonom) {
229
+ else if (value instanceof monom_1.Monom) {
281
230
  this._monoms.push(value.clone().opposed());
282
231
  }
283
232
  else if (Number.isSafeInteger(value)) {
284
- this._monoms.push(new Monom(value.toString()).opposed());
233
+ this._monoms.push(new monom_1.Monom(value.toString()).opposed());
285
234
  }
286
235
  else {
287
- this._monoms.push(new Monom(value).opposed());
236
+ this._monoms.push(new monom_1.Monom(value).opposed());
288
237
  }
289
238
  }
290
239
  return this.reduce();
291
240
  };
292
241
  multiply = (value) => {
293
- if (value.isPolynom) {
242
+ if (value instanceof Polynom) {
294
243
  return this.multiplyByPolynom(value);
295
244
  }
296
- else if (value.isFraction) {
245
+ else if (value instanceof coefficients_1.Fraction) {
297
246
  return this.multiplyByFraction(value);
298
247
  }
299
- else if (value.isMonom) {
248
+ else if (value instanceof monom_1.Monom) {
300
249
  return this.multiplyByMonom(value);
301
250
  }
302
251
  else if (Number.isSafeInteger(value)) {
@@ -308,7 +257,7 @@ export class Polynom {
308
257
  const M = [];
309
258
  for (const m1 of this._monoms) {
310
259
  for (const m2 of P.monoms) {
311
- M.push(Monom.xmultiply(m1, m2));
260
+ M.push(monom_1.Monom.xmultiply(m1, m2));
312
261
  }
313
262
  }
314
263
  this._monoms = M;
@@ -321,7 +270,7 @@ export class Polynom {
321
270
  return this.reduce();
322
271
  };
323
272
  multiplyByInteger = (nb) => {
324
- return this.multiplyByFraction(new Fraction(nb));
273
+ return this.multiplyByFraction(new coefficients_1.Fraction(nb));
325
274
  };
326
275
  multiplyByMonom = (M) => {
327
276
  for (const m of this._monoms) {
@@ -339,9 +288,9 @@ export class Polynom {
339
288
  const maxMP = P.monomByDegree(undefined, letter);
340
289
  const degreeP = P.degree(letter);
341
290
  let newM;
342
- let MaxIteration = this.degree(letter) * 2;
343
- while (reminder.degree(letter) >= degreeP && MaxIteration >= 0) {
344
- MaxIteration--;
291
+ let MaxIteration = this.degree(letter).clone().multiply(2);
292
+ while (reminder.degree(letter) >= degreeP && MaxIteration.isPositive()) {
293
+ MaxIteration.subtract(1);
345
294
  newM = reminder.monomByDegree(undefined, letter).clone().divide(maxMP);
346
295
  if (newM.isZero()) {
347
296
  break;
@@ -360,7 +309,7 @@ export class Polynom {
360
309
  }
361
310
  };
362
311
  divideByInteger = (nb) => {
363
- const nbF = new Fraction(nb);
312
+ const nbF = new coefficients_1.Fraction(nb);
364
313
  for (const m of this._monoms) {
365
314
  m.coefficient.divide(nbF);
366
315
  }
@@ -396,7 +345,7 @@ export class Polynom {
396
345
  const cP2 = P.clone().reduce().reorder();
397
346
  switch (sign) {
398
347
  case '=':
399
- if (cP1.length !== cP2.length || cP1.degree() !== cP2.degree()) {
348
+ if (cP1.length !== cP2.length || cP1.degree().isNotEqual(cP2.degree())) {
400
349
  return false;
401
350
  }
402
351
  for (const i in cP1.monoms) {
@@ -520,14 +469,14 @@ export class Polynom {
520
469
  };
521
470
  reorder = (letter = 'x') => {
522
471
  this._monoms.sort(function (a, b) {
523
- return b.degree(letter) - a.degree(letter);
472
+ return b.degree(letter).clone().subtract(a.degree(letter)).value;
524
473
  });
525
474
  return this.reduce();
526
475
  };
527
476
  degree = (letter) => {
528
- let d = 0;
477
+ let d = new coefficients_1.Fraction().zero();
529
478
  for (const m of this._monoms) {
530
- d = Math.max(m.degree(letter), d);
479
+ d = coefficients_1.Fraction.max(m.degree(letter).value, d);
531
480
  }
532
481
  return d;
533
482
  };
@@ -542,20 +491,20 @@ export class Polynom {
542
491
  let pow;
543
492
  const resultPolynom = new Polynom().zero();
544
493
  for (const m of this.monoms) {
545
- if (m.literal[letter] === undefined || m.literal[letter] === 0) {
494
+ if (m.literal[letter] === undefined || m.literal[letter].isZero()) {
546
495
  resultPolynom.add(m.clone());
547
496
  }
548
497
  else {
549
- pow = +m.literal[letter];
498
+ pow = m.literal[letter].clone();
550
499
  delete m.literal[letter];
551
- resultPolynom.add(P.clone().pow(pow).multiply(m));
500
+ resultPolynom.add(P.clone().pow(Math.abs(pow.numerator)).multiply(m));
552
501
  }
553
502
  }
554
503
  this._monoms = resultPolynom.reduce().reorder().monoms;
555
504
  return this;
556
505
  };
557
506
  evaluate = (values) => {
558
- const r = new Fraction().zero();
507
+ const r = new coefficients_1.Fraction().zero();
559
508
  this._monoms.forEach(monom => {
560
509
  r.add(monom.evaluate(values));
561
510
  });
@@ -581,59 +530,10 @@ export class Polynom {
581
530
  letter = 'x';
582
531
  }
583
532
  let valuesA = {}, valuesB = {};
584
- valuesA[letter] = a;
585
- valuesB[letter] = b;
533
+ valuesA[letter] = new coefficients_1.Fraction(a);
534
+ valuesB[letter] = new coefficients_1.Fraction(b);
586
535
  return primitive.evaluate(valuesB).subtract(primitive.evaluate(valuesA));
587
536
  };
588
- factorize_OLD = (maxValue) => {
589
- this._factors = [];
590
- let P = this.clone(), nbFactorsFound = 0;
591
- if (P.monomByDegree().coefficient.numerator < 0) {
592
- this._factors.push(new Polynom('-1'));
593
- }
594
- let M = P.commonMonom();
595
- if (!M.isOne()) {
596
- let commonPolynom = new Polynom();
597
- commonPolynom.monoms = [M];
598
- if (this._factors.length === 0) {
599
- this._factors.push(commonPolynom);
600
- }
601
- else {
602
- this._factors = [];
603
- this._factors.push(commonPolynom.opposed());
604
- }
605
- P = P.euclidian(commonPolynom).quotient;
606
- nbFactorsFound = commonPolynom.degree();
607
- }
608
- if (P.degree() <= 1) {
609
- this._factors.push(P.clone());
610
- }
611
- else {
612
- let Q = new Fraction(), F, degree = P.degree();
613
- maxValue = maxValue === undefined ? 20 : maxValue;
614
- for (let a = 1; a <= maxValue; a++) {
615
- for (let b = -maxValue; b <= maxValue; b++) {
616
- Q.parse(-b, a);
617
- if (P.evaluate({ x: Q })) {
618
- F = new Polynom(`${a}x+${b}`);
619
- while (P.evaluate({ x: Q }).value === 0) {
620
- this._factors.push(F.clone());
621
- nbFactorsFound++;
622
- P = P.euclidian(F).quotient;
623
- }
624
- }
625
- if (nbFactorsFound > degree) {
626
- return this;
627
- }
628
- }
629
- }
630
- if (P.degree() > 1) {
631
- this._factors.push(P.clone());
632
- return this;
633
- }
634
- }
635
- return this;
636
- };
637
537
  factorize = (letter) => {
638
538
  let factors = [];
639
539
  let P = this.clone().reorder(), M = P.commonMonom(), tempPolynom;
@@ -643,7 +543,7 @@ export class Polynom {
643
543
  factors = [tempPolynom.clone()];
644
544
  P = P.euclidian(tempPolynom).quotient;
645
545
  }
646
- let securityLoop = P.degree() * 2;
546
+ let securityLoop = P.degree().clone().multiply(2).value;
647
547
  while (securityLoop >= 0) {
648
548
  securityLoop--;
649
549
  if (P.monoms.length < 2) {
@@ -726,14 +626,14 @@ export class Polynom {
726
626
  a = this.monomByDegree(2, letter);
727
627
  b = this.monomByDegree(1, letter);
728
628
  c = this.monomByDegree(0, letter);
729
- if (a.isLitteralSquare() && c.isLitteralSquare()) {
629
+ if (a.isLiteralSquare() && c.isLiteralSquare()) {
730
630
  if (b.clone().pow(2).isSameAs(a.clone().multiply(c))) {
731
631
  let xPolynom = new Polynom('x', a.coefficient, b.coefficient, c.coefficient);
732
632
  let xFactors = xPolynom._factorize2ndDegree('x');
733
633
  let factors = [], xyzPolynom;
734
634
  if (xFactors.length >= 2) {
735
635
  for (let p of xFactors) {
736
- if (p.degree() === 0) {
636
+ if (p.degree().isZero()) {
737
637
  factors.push(p.clone());
738
638
  }
739
639
  else {
@@ -755,7 +655,7 @@ export class Polynom {
755
655
  };
756
656
  getZeroes = () => {
757
657
  const Z = [];
758
- switch (this.degree()) {
658
+ switch (this.degree().value) {
759
659
  case 0:
760
660
  if (this._monoms[0].coefficient.value === 0) {
761
661
  return [true];
@@ -765,7 +665,7 @@ export class Polynom {
765
665
  }
766
666
  case 1:
767
667
  if (this._monoms.length === 1) {
768
- return [new Fraction().zero()];
668
+ return [new coefficients_1.Fraction().zero()];
769
669
  }
770
670
  else {
771
671
  const P = this.clone().reduce().reorder();
@@ -777,14 +677,14 @@ export class Polynom {
777
677
  }
778
678
  let zeroes = [], zeroesAsTex = [];
779
679
  for (let P of this._factors) {
780
- if (P.degree() > 2) {
680
+ if (P.degree().greater(2)) {
781
681
  }
782
- else if (P.degree() === 2) {
682
+ else if (P.degree().value === 2) {
783
683
  let A = P.monomByDegree(2).coefficient, B = P.monomByDegree(1).coefficient, C = P.monomByDegree(0).coefficient, D = B.clone().pow(2).subtract(A.clone().multiply(C).multiply(4));
784
684
  if (D.value > 0) {
785
685
  let x1 = (-(B.value) + Math.sqrt(D.value)) / (2 * A.value), x2 = (-(B.value) - Math.sqrt(D.value)) / (2 * A.value);
786
- zeroes.push(new Fraction(x1.toFixed(3)).reduce());
787
- zeroes.push(new Fraction(x2.toFixed(3)).reduce());
686
+ zeroes.push(new coefficients_1.Fraction(x1.toFixed(3)).reduce());
687
+ zeroes.push(new coefficients_1.Fraction(x2.toFixed(3)).reduce());
788
688
  }
789
689
  else if (D.value === 0) {
790
690
  }
@@ -814,11 +714,11 @@ export class Polynom {
814
714
  }
815
715
  const M = this.clone().reduce();
816
716
  for (const m of M._monoms) {
817
- if (m.degree(letter) === degree) {
717
+ if (m.degree(letter).isEqual(degree)) {
818
718
  return m.clone();
819
719
  }
820
720
  }
821
- return new Monom().zero();
721
+ return new monom_1.Monom().zero();
822
722
  };
823
723
  monomsByDegree = (degree, letter) => {
824
724
  if (degree === undefined) {
@@ -840,7 +740,7 @@ export class Polynom {
840
740
  return m.clone();
841
741
  }
842
742
  }
843
- return new Monom().zero();
743
+ return new monom_1.Monom().zero();
844
744
  };
845
745
  getDenominators = () => {
846
746
  const denominators = [];
@@ -857,89 +757,33 @@ export class Polynom {
857
757
  return numerators;
858
758
  };
859
759
  lcmDenominator = () => {
860
- return Numeric.lcm(...this.getDenominators());
760
+ return numeric_1.Numeric.lcm(...this.getDenominators());
861
761
  };
862
762
  gcdDenominator = () => {
863
- return Numeric.gcd(...this.getDenominators());
763
+ return numeric_1.Numeric.gcd(...this.getDenominators());
864
764
  };
865
765
  lcmNumerator = () => {
866
- return Numeric.lcm(...this.getNumerators());
766
+ return numeric_1.Numeric.lcm(...this.getNumerators());
867
767
  };
868
768
  gcdNumerator = () => {
869
- return Numeric.gcd(...this.getNumerators());
769
+ return numeric_1.Numeric.gcd(...this.getNumerators());
870
770
  };
871
771
  commonMonom = () => {
872
- let M = new Monom().one(), numerator, denominator, degree = this.degree();
772
+ let M = new monom_1.Monom().one(), numerator, denominator, degree = this.degree();
873
773
  numerator = this.gcdNumerator();
874
774
  denominator = this.gcdDenominator();
875
- M.coefficient = new Fraction(numerator, denominator);
775
+ M.coefficient = new coefficients_1.Fraction(numerator, denominator);
876
776
  for (let L of this.variables) {
877
777
  M.setLetter(L, degree);
878
778
  for (let m of this._monoms) {
879
- M.setLetter(L, Math.min(m.degree(L), M.degree(L)));
880
- if (M.degree(L) === 0) {
779
+ M.setLetter(L, coefficients_1.Fraction.min(m.degree(L), M.degree(L)));
780
+ if (M.degree(L).isZero()) {
881
781
  break;
882
782
  }
883
783
  }
884
784
  }
885
785
  return M;
886
786
  };
887
- makeItComplicate = (complexity = 1) => {
888
- this._texString = '';
889
- if (this.degree() < 1) {
890
- return this;
891
- }
892
- const mDegree = Random.number(0, this.degree() - 1);
893
- return this;
894
- };
895
- factorizePartial = (forceSign) => {
896
- this._texString = '';
897
- if (this.length <= 1) {
898
- return this;
899
- }
900
- let mMain, mCheck, mFactor, pFactor, g, sign;
901
- for (let i = 0; i < this.length; i++) {
902
- mMain = this._monoms[i].clone();
903
- for (let j = i + 1; j < this.length; j++) {
904
- mCheck = this._monoms[j].clone();
905
- g = Numeric.gcd(mMain.coefficient.numerator, mCheck.coefficient.numerator);
906
- if (g !== 1) {
907
- mFactor = Monom.lcm(mMain, mCheck);
908
- sign = mMain.coefficient.sign() === 1 ? '+' : '-';
909
- this._texString = `${forceSign === true ? sign : (sign === '+' ? '' : sign)}${mFactor.tex}`;
910
- pFactor = new Polynom().add(mMain.divide(mFactor)).add(mCheck.divide(mFactor));
911
- this._texString += pFactor.genDisplay('tex', false, true);
912
- this._texString += this.clone().subtract(pFactor.clone().multiply(mFactor)).genDisplay('tex', true, false);
913
- return this;
914
- }
915
- }
916
- }
917
- this._texString = this.genDisplay('tex', forceSign);
918
- return this;
919
- };
920
- minify = () => {
921
- this.multiply(this.lcmDenominator()).divide(this.gcdNumerator()).reduce();
922
- return this.reduce();
923
- };
924
- canDivide = (P, letter = 'x') => {
925
- const d = P.degree();
926
- const evalValue = {};
927
- if (d === 0) {
928
- return !P.isZero;
929
- }
930
- if (d === 1) {
931
- const z = P.getZeroes();
932
- if (z[0] === true || z[0] === false) {
933
- return false;
934
- }
935
- evalValue[letter] = z[0];
936
- return this.evaluate(evalValue).value === 0;
937
- }
938
- if (d > 1) {
939
- console.log('Currently, only first degree polynom are supported');
940
- return false;
941
- }
942
- return false;
943
- };
944
787
  }
788
+ exports.Polynom = Polynom;
945
789
  //# sourceMappingURL=polynom.js.map