pimath 0.0.127 → 0.0.129

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 (212) hide show
  1. package/dist/main.d.ts +39 -0
  2. package/{esm → dist}/maths/algebra/equation.d.ts +11 -10
  3. package/{esm → dist}/maths/algebra/linearSystem.d.ts +5 -4
  4. package/{esm → dist}/maths/algebra/monom.d.ts +5 -4
  5. package/{esm → dist}/maths/algebra/polynom.d.ts +11 -13
  6. package/{esm → dist}/maths/algebra/rational.d.ts +7 -9
  7. package/dist/maths/algebra/study/rationalStudy.d.ts +14 -0
  8. package/{esm → dist}/maths/algebra/study.d.ts +4 -7
  9. package/{esm → dist}/maths/geometry/circle.d.ts +9 -8
  10. package/{esm → dist}/maths/geometry/line.d.ts +17 -14
  11. package/{esm → dist}/maths/geometry/point.d.ts +11 -9
  12. package/{esm → dist}/maths/geometry/triangle.d.ts +4 -3
  13. package/{esm → dist}/maths/geometry/vector.d.ts +7 -10
  14. package/{esm → dist}/maths/randomization/random.d.ts +10 -7
  15. package/{esm → dist}/maths/randomization/rndFraction.d.ts +4 -3
  16. package/dist/maths/randomization/rndGeometryCircle.d.ts +13 -0
  17. package/{esm → dist}/maths/randomization/rndGeometryLine.d.ts +4 -3
  18. package/{esm → dist}/maths/randomization/rndGeometryPoint.d.ts +4 -3
  19. package/{esm → dist}/maths/randomization/rndMonom.d.ts +5 -4
  20. package/{esm → dist}/maths/randomization/rndPolynom.d.ts +5 -4
  21. package/{esm → dist}/maths/randomization/rndTypes.d.ts +7 -1
  22. package/dist/pimath.js +4239 -7819
  23. package/package.json +13 -7
  24. package/.eslintrc.js +0 -24
  25. package/.idea/$CACHE_FILE$ +0 -6
  26. package/.idea/PI.iml +0 -14
  27. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  28. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  29. package/.idea/misc.xml +0 -6
  30. package/.idea/modules.xml +0 -8
  31. package/.idea/php.xml +0 -19
  32. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]/shelved.patch +0 -192
  33. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]1/shelved.patch +0 -0
  34. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30__Default_Changelist_.xml +0 -4
  35. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43_[Default_Changelist]/shelved.patch +0 -2404
  36. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43__Default_Changelist_.xml +0 -4
  37. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01_[Default_Changelist]/shelved.patch +0 -1362
  38. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01__Default_Changelist_.xml +0 -4
  39. package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]/shelved.patch +0 -90
  40. package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_.xml +0 -4
  41. package/.idea/vcs.xml +0 -6
  42. package/dev/pimath.js +0 -7945
  43. package/dev/pimath.js.map +0 -1
  44. package/dist/pimath.js.map +0 -1
  45. package/dist/pimath.min.js +0 -2
  46. package/dist/pimath.min.js.map +0 -1
  47. package/docs/.nojekyll +0 -1
  48. package/docs/assets/highlight.css +0 -78
  49. package/docs/assets/main.js +0 -59
  50. package/docs/assets/navigation.js +0 -1
  51. package/docs/assets/search.js +0 -1
  52. package/docs/assets/style.css +0 -1383
  53. package/docs/classes/Logicalset.Logicalset.html +0 -217
  54. package/docs/classes/Polynom.Rational.html +0 -397
  55. package/docs/classes/Vector-1.Vector.html +0 -490
  56. package/docs/classes/Vector.Point.html +0 -337
  57. package/docs/classes/algebra_equation.Equation.html +0 -790
  58. package/docs/classes/algebra_linearSystem.LinearSystem.html +0 -404
  59. package/docs/classes/algebra_monom.Monom.html +0 -962
  60. package/docs/classes/algebra_polynom.Polynom.html +0 -1275
  61. package/docs/classes/coefficients_fraction.Fraction.html +0 -934
  62. package/docs/classes/geometry_circle.Circle.html +0 -472
  63. package/docs/classes/geometry_line.Line.html +0 -774
  64. package/docs/classes/geometry_triangle.Triangle.html +0 -429
  65. package/docs/classes/numeric.Numeric.html +0 -265
  66. package/docs/classes/shutingyard.Shutingyard.html +0 -250
  67. package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +0 -83
  68. package/docs/enums/geometry_line.LinePropriety.html +0 -97
  69. package/docs/enums/shutingyard.ShutingyardMode.html +0 -97
  70. package/docs/enums/shutingyard.ShutingyardType.html +0 -111
  71. package/docs/index.html +0 -63
  72. package/docs/interfaces/algebra_equation.ISolution.html +0 -105
  73. package/docs/interfaces/algebra_polynom.IEuclidian.html +0 -87
  74. package/docs/interfaces/geometry_triangle.remarquableLines.html +0 -163
  75. package/docs/modules/Logicalset.html +0 -65
  76. package/docs/modules/Polynom.html +0 -65
  77. package/docs/modules/Vector-1.html +0 -65
  78. package/docs/modules/Vector.html +0 -65
  79. package/docs/modules/algebra_equation.html +0 -69
  80. package/docs/modules/algebra_linearSystem.html +0 -61
  81. package/docs/modules/algebra_monom.html +0 -65
  82. package/docs/modules/algebra_polynom.html +0 -69
  83. package/docs/modules/coefficients_fraction.html +0 -65
  84. package/docs/modules/geometry_circle.html +0 -61
  85. package/docs/modules/geometry_line.html +0 -65
  86. package/docs/modules/geometry_triangle.html +0 -65
  87. package/docs/modules/numeric.html +0 -61
  88. package/docs/modules/shutingyard.html +0 -75
  89. package/docs/types/algebra_monom.literalType.html +0 -61
  90. package/docs/types/algebra_polynom.PolynomParsingType.html +0 -56
  91. package/docs/types/coefficients_fraction.FractionParsingType.html +0 -56
  92. package/docs/types/shutingyard.Token.html +0 -63
  93. package/docs/types/shutingyard.tokenType.html +0 -68
  94. package/docs/variables/shutingyard.tokenConstant.html +0 -61
  95. package/esm/index.d.ts +0 -38
  96. package/esm/index.js +0 -44
  97. package/esm/index.js.map +0 -1
  98. package/esm/maths/algebra/equation.js +0 -797
  99. package/esm/maths/algebra/equation.js.map +0 -1
  100. package/esm/maths/algebra/linearSystem.js +0 -279
  101. package/esm/maths/algebra/linearSystem.js.map +0 -1
  102. package/esm/maths/algebra/logicalset.js +0 -158
  103. package/esm/maths/algebra/logicalset.js.map +0 -1
  104. package/esm/maths/algebra/monom.js +0 -909
  105. package/esm/maths/algebra/monom.js.map +0 -1
  106. package/esm/maths/algebra/polynom.js +0 -1305
  107. package/esm/maths/algebra/polynom.js.map +0 -1
  108. package/esm/maths/algebra/rational.js +0 -195
  109. package/esm/maths/algebra/rational.js.map +0 -1
  110. package/esm/maths/algebra/study/rationalStudy.d.ts +0 -28
  111. package/esm/maths/algebra/study/rationalStudy.js +0 -244
  112. package/esm/maths/algebra/study/rationalStudy.js.map +0 -1
  113. package/esm/maths/algebra/study.js +0 -380
  114. package/esm/maths/algebra/study.js.map +0 -1
  115. package/esm/maths/coefficients/fraction.js +0 -517
  116. package/esm/maths/coefficients/fraction.js.map +0 -1
  117. package/esm/maths/coefficients/nthRoot.js +0 -137
  118. package/esm/maths/coefficients/nthRoot.js.map +0 -1
  119. package/esm/maths/geometry/circle.js +0 -324
  120. package/esm/maths/geometry/circle.js.map +0 -1
  121. package/esm/maths/geometry/line.js +0 -485
  122. package/esm/maths/geometry/line.js.map +0 -1
  123. package/esm/maths/geometry/point.js +0 -167
  124. package/esm/maths/geometry/point.js.map +0 -1
  125. package/esm/maths/geometry/triangle.js +0 -276
  126. package/esm/maths/geometry/triangle.js.map +0 -1
  127. package/esm/maths/geometry/vector.js +0 -198
  128. package/esm/maths/geometry/vector.js.map +0 -1
  129. package/esm/maths/numeric.js +0 -136
  130. package/esm/maths/numeric.js.map +0 -1
  131. package/esm/maths/numexp.js +0 -186
  132. package/esm/maths/numexp.js.map +0 -1
  133. package/esm/maths/randomization/random.js +0 -79
  134. package/esm/maths/randomization/random.js.map +0 -1
  135. package/esm/maths/randomization/randomCore.js +0 -22
  136. package/esm/maths/randomization/randomCore.js.map +0 -1
  137. package/esm/maths/randomization/rndFraction.js +0 -44
  138. package/esm/maths/randomization/rndFraction.js.map +0 -1
  139. package/esm/maths/randomization/rndGeometryLine.js +0 -46
  140. package/esm/maths/randomization/rndGeometryLine.js.map +0 -1
  141. package/esm/maths/randomization/rndGeometryPoint.js +0 -61
  142. package/esm/maths/randomization/rndGeometryPoint.js.map +0 -1
  143. package/esm/maths/randomization/rndHelpers.js +0 -98
  144. package/esm/maths/randomization/rndHelpers.js.map +0 -1
  145. package/esm/maths/randomization/rndMonom.js +0 -53
  146. package/esm/maths/randomization/rndMonom.js.map +0 -1
  147. package/esm/maths/randomization/rndPolynom.js +0 -75
  148. package/esm/maths/randomization/rndPolynom.js.map +0 -1
  149. package/esm/maths/randomization/rndTypes.js +0 -3
  150. package/esm/maths/randomization/rndTypes.js.map +0 -1
  151. package/esm/maths/shutingyard.js +0 -443
  152. package/esm/maths/shutingyard.js.map +0 -1
  153. package/public/demo.css +0 -3
  154. package/public/index.html +0 -283
  155. package/public/matrices.html +0 -100
  156. package/public/playground.html +0 -168
  157. package/src/index.ts +0 -42
  158. package/src/maths/algebra/equation.ts +0 -897
  159. package/src/maths/algebra/linearSystem.ts +0 -370
  160. package/src/maths/algebra/logicalset.ts +0 -183
  161. package/src/maths/algebra/monom.ts +0 -1028
  162. package/src/maths/algebra/polynom.ts +0 -1537
  163. package/src/maths/algebra/rational.ts +0 -240
  164. package/src/maths/algebra/study/rationalStudy.ts +0 -287
  165. package/src/maths/algebra/study.ts +0 -506
  166. package/src/maths/coefficients/fraction.ts +0 -593
  167. package/src/maths/coefficients/nthRoot.ts +0 -148
  168. package/src/maths/geometry/circle.ts +0 -382
  169. package/src/maths/geometry/line.ts +0 -604
  170. package/src/maths/geometry/point.ts +0 -215
  171. package/src/maths/geometry/triangle.ts +0 -368
  172. package/src/maths/geometry/vector.ts +0 -242
  173. package/src/maths/numeric.ts +0 -162
  174. package/src/maths/numexp.ts +0 -184
  175. package/src/maths/randomization/random.ts +0 -80
  176. package/src/maths/randomization/randomCore.ts +0 -19
  177. package/src/maths/randomization/rndFraction.ts +0 -47
  178. package/src/maths/randomization/rndGeometryCircle.ts +0 -50
  179. package/src/maths/randomization/rndGeometryLine.ts +0 -53
  180. package/src/maths/randomization/rndGeometryPoint.ts +0 -69
  181. package/src/maths/randomization/rndHelpers.ts +0 -107
  182. package/src/maths/randomization/rndMonom.ts +0 -57
  183. package/src/maths/randomization/rndPolynom.ts +0 -90
  184. package/src/maths/randomization/rndTypes.ts +0 -43
  185. package/src/maths/shutingyard.ts +0 -496
  186. package/tests/algebra/equation.test.ts +0 -64
  187. package/tests/algebra/linear.test.ts +0 -58
  188. package/tests/algebra/monom.test.ts +0 -78
  189. package/tests/algebra/polynom.test.ts +0 -343
  190. package/tests/algebra/rationnal.test.ts +0 -64
  191. package/tests/algebra/study.test.ts +0 -48
  192. package/tests/coefficients/fraction.test.ts +0 -131
  193. package/tests/custom.test.ts +0 -33
  194. package/tests/geometry/circle.test.ts +0 -404
  195. package/tests/geometry/line.test.ts +0 -36
  196. package/tests/numeric.test.ts +0 -43
  197. package/tests/numexp.test.ts +0 -89
  198. package/tests/shutingyard.test.ts +0 -58
  199. package/tsconfig.json +0 -41
  200. package/tsconfig.testing.json +0 -28
  201. package/typedoc.katex.js +0 -11
  202. package/webpack-production-min.config.js +0 -26
  203. package/webpack-production.config.js +0 -26
  204. package/webpack.config.js +0 -26
  205. package/{esm → dist}/maths/algebra/logicalset.d.ts +6 -6
  206. package/{esm → dist}/maths/coefficients/fraction.d.ts +0 -0
  207. package/{esm → dist}/maths/coefficients/nthRoot.d.ts +0 -0
  208. package/{esm → dist}/maths/numeric.d.ts +0 -0
  209. package/{esm → dist}/maths/numexp.d.ts +3 -3
  210. /package/{esm → dist}/maths/randomization/randomCore.d.ts +0 -0
  211. /package/{esm → dist}/maths/randomization/rndHelpers.d.ts +0 -0
  212. /package/{esm → dist}/maths/shutingyard.d.ts +0 -0
@@ -1,78 +0,0 @@
1
- import {expect} from 'chai';
2
- import {Random} from "../../src/maths/randomization/random";
3
- import {describe} from "mocha";
4
- import {Monom} from "../../src/maths/algebra/monom";
5
-
6
- describe('Monom with integer power', () => {
7
- it('parsing', () => {
8
- const M0a = new Monom('3');
9
- expect(M0a.tex).to.be.equal('3')
10
-
11
- const M0b = new Monom('x');
12
- expect(M0b.tex).to.be.equal('x')
13
-
14
- const M0c = new Monom('3x');
15
- expect(M0c.tex).to.be.equal('3x')
16
-
17
- const M1 = new Monom('3x^5');
18
- expect(M1.tex).to.be.equal('3x^{5}')
19
-
20
- const M2 = new Monom('2/3x^2yz^3y^4')
21
- expect(M2.display).to.be.equal('2/3x^(2)y^(5)z^(3)')
22
-
23
- const M3 = new Monom('-3x^(-2)')
24
- expect(M3.tex).to.be.equal('-3x^{-2}')
25
-
26
- const M4 = new Monom('3x^(2/3)')
27
- expect(M4.tex).to.be.equal('3x^{\\tfrac{ 2 }{ 3 }}')
28
-
29
- const M5 = new Monom('-3x^(-2/3)y^(-5)8x^3')
30
- expect(M5.tex).to.be.equal('-24x^{\\tfrac{ 7 }{ 3 }}y^{-5}')
31
- })
32
-
33
- it('basic operations', () => {
34
- const M1 = new Monom('3x'),
35
- M2 = new Monom('2x')
36
-
37
- expect(M1.clone().add(M2).isEqual(new Monom('5x'))).to.be.true
38
- expect(M1.clone().subtract(M2).isEqual(new Monom('x'))).to.be.true
39
- expect(M1.clone().multiply(M2).isEqual(new Monom('6x^2'))).to.be.true
40
- expect(M1.clone().divide(M2).isEqual(new Monom('3/2'))).to.be.true
41
- })
42
-
43
- it('derivative', () => { // the single test
44
- const options = new Monom('7x^3'); // this will be your class
45
-
46
- expect(options.tex).to.be.equal('7x^{3}')
47
- expect(options.derivative().tex).to.be.equal('21x^{2}');
48
- });
49
-
50
- it('integrate', () => { // the single test
51
- const options = new Monom('7x^3'); // this will be your class
52
- expect(options.primitive().display).to.be.equal('7/4x^(4)');
53
- });
54
-
55
- it('randomize', function () {
56
- const M = Random.monom({
57
- letters: 'xyz',
58
- degree: 5,
59
- fraction: false,
60
- zero: false
61
- });
62
-
63
- expect(M.coefficient.isZero()).to.be.false
64
- expect(M.degree().value).to.be.greaterThan(0)
65
- });
66
- })
67
-
68
- describe('Monom with fraction power', () => {
69
- it('should create a numerical expression', () => {
70
- const inputStr: string = '-1/5x^(2/3)'
71
- const M = new Monom(inputStr),
72
- N = new Monom('7x^(4/5)')
73
-
74
- M.multiply(N.clone())
75
-
76
- expect(M.tex).to.be.equal('-\\frac{ 7 }{ 5 }x^{\\tfrac{ 22 }{ 15 }}')
77
- })
78
- })
@@ -1,343 +0,0 @@
1
- import {expect} from 'chai';
2
- import {Random} from "../../src/maths/randomization/random";
3
- import {describe} from "mocha";
4
- import {Polynom} from "../../src/maths/algebra/polynom";
5
- import {Fraction} from "../../src/maths/coefficients/fraction";
6
-
7
-
8
- describe('Polynom tests', () => {
9
- it('Parse polynom', () => {
10
- const options = new Polynom('2x(x+3)^2(x-1)');
11
- options.reorder();
12
- expect(options.tex).to.be.equal('2x^{4}+10x^{3}+6x^{2}-18x');
13
- });
14
-
15
- it('Parse polynom with coefficient as fraction', () => {
16
- const P = new Polynom('-3/5x-2')
17
-
18
- expect(P.tex).to.be.equal('-\\frac{ 3 }{ 5 }x-2')
19
- })
20
-
21
- it('Tex display', () => {
22
- const options = new Polynom('x^2-2x+1');
23
- expect(options.tex).to.be.equal('x^{2}-2x+1');
24
- });
25
-
26
- it('Evaluate a polynom', function () {
27
- const P = new Polynom('2x-3')
28
-
29
- expect(P.evaluate(5).value).to.be.equal(7)
30
- expect(P.evaluate(new Fraction('5/3')).display).to.be.equal('1/3')
31
- });
32
- it('Compare: equals', () => {
33
- let F = new Polynom('x+3'),
34
- Q = new Polynom('3+x'),
35
- P = new Polynom('x-3');
36
- expect(F.isEqual(Q)).to.be.true;
37
- expect(F.isEqual(P)).to.be.false;
38
- })
39
- it('Integrate', () => {
40
- let F = new Polynom('2x^3-3x^2+x-3'),
41
- G = new Polynom('3/5x^2+4')
42
-
43
- expect(F.integrate(0, 2).value).to.be.equal(-4)
44
- expect(G.integrate(-3, 3).display).to.be.equal('174/5')
45
- })
46
- it('Random Polynom of degree 6', () => {
47
- let P = Random.polynom({
48
- degree: 6,
49
- numberOfMonoms: 3,
50
- positive: true,
51
- fraction: {
52
- max: 3
53
- }
54
- })
55
-
56
- expect(P.length).to.be.equal(3)
57
- expect(P.degree().value).to.be.equal(6)
58
- });
59
-
60
- it('should calculate correctly the quotient and reminder', () => {
61
- let P = new Polynom('(x-3)(x^2+5x-4)+12'),
62
- D = new Polynom('x-3')
63
-
64
- let euclidian = P.euclidian(D);
65
-
66
- expect(euclidian.quotient.tex).to.be.equal('x^{2}+5x-4')
67
- expect(euclidian.reminder.tex).to.be.equal('12')
68
- });
69
-
70
- it('should calculate the quotient and reminder with similar polynom', () => {
71
- let P = new Polynom('6x^5+12x^4+3x^3+x^2-7x+6'),
72
- D = new Polynom('x^3+2x^2-2x-4')
73
-
74
- let euclidian = P.euclidian(D);
75
-
76
- expect(euclidian.quotient.display).to.be.equal('6x^(2)+15')
77
- expect(euclidian.reminder.display).to.be.equal('-5x^(2)+23x+66')
78
- })
79
-
80
- it('should reduce', () => {
81
- let P = new Polynom('15x-19x+24+4x-12')
82
- P.reduce()
83
- expect(P.tex).to.be.equal('12')
84
-
85
- })
86
-
87
- it('should factorize the polynom', () => {
88
- let P = new Polynom('x^2-5x+6')
89
-
90
- P.factorize()
91
- expect(P.factors.map(x => x.tex)).to.have.all.members(['x-2', 'x-3'])
92
-
93
- let P2 = new Polynom('x^4-32x^2+256')
94
- P2.factorize()
95
- expect(P2.factors.map(x => x.tex)).to.have.all.members(['x-4', 'x-4', 'x+4', 'x+4'])
96
-
97
- let P3 = new Polynom('6x^2-48x-8')
98
- P3.factorize()
99
- expect(P3.factors.map(x => x.tex)).to.have.all.members(['2', '3x^{2}-24x-4'])
100
- });
101
-
102
- it('should factorize special polynom', function () {
103
- let P = new Polynom('x^6-16x^5-58x^4+1592x^3-1207x^2-37576x+94864')
104
-
105
- P.factorize()
106
- expect(P.factors.map(x => x.tex)).to.have.all.members(['x-4', 'x-4', 'x+7', 'x+7', 'x-11', 'x-11'])
107
- });
108
-
109
- it('should factorize and regroup', function () {
110
- let P = new Polynom('7x(x-3)(x+5)(x^2-9)3x')
111
- P.factorize()
112
- expect(P.texFactors).to.be.equal('21x^{2}\\left( x+3 \\right)\\left( x-3 \\right)^{ 2 }\\left( x+5 \\right)')
113
-
114
- const P2 = new Polynom('-2x^3+18x')
115
- P2.factorize()
116
- expect(P2.texFactors).to.be.equal('-2x\\left( x+3 \\right)\\left( x-3 \\right)')
117
- });
118
-
119
- it('should detect if a polynom is factorized', function () {
120
- let P = new Polynom('x-1')
121
- expect(P.isFactorized('x-1')).to.be.true
122
- expect(P.isFactorized('x-2')).to.be.false
123
-
124
- let R = new Polynom('(x+2)^2')
125
- expect(R.isFactorized('(x+2)^2')).to.be.true
126
-
127
- let Q = new Polynom('(x-1)(x+2)')
128
- expect(Q.isFactorized('(x+2)(x-1)')).to.be.true
129
- expect(Q.isFactorized('x^2+x-2')).to.be.false
130
-
131
- let T = new Polynom('(x-3)(1-x)')
132
- expect(T.isFactorized('(x-1)(3-x)')).to.be.true
133
- expect(T.isFactorized('(x-1)(x-3)')).to.be.false
134
- expect(T.isFactorized('-1(x-1)(x-3)')).to.be.false
135
- })
136
-
137
- it('should detect if a polynom with power is factorized', function () {
138
- let P = new Polynom('(x-2)^3')
139
-
140
- expect(P.isFactorized('(x-2)^3')).to.be.true
141
- expect(P.isFactorized('(x-2)(x-2)(x-2)')).to.be.true
142
- expect(P.isFactorized('(x-2)^2(x-2)')).to.be.true
143
-
144
- let Q = new Polynom('(x-2)^4')
145
- expect(Q.isFactorized('(x-2)^2(x-2)^2')).to.be.true
146
- });
147
-
148
- it('should check if isFactorize with some "soft"', function () {
149
- let P = new Polynom('(2x-6)(x+5)')
150
-
151
- expect(P.isFactorized('2(x-3)(x+5)')).to.be.true
152
- expect(P.isFactorized('2x-6)(x+5)')).to.be.false
153
- expect(P.isFactorized('(2x-6)(x+5)', true)).to.be.true
154
-
155
- let Q = new Polynom('(4x+10)(2x-12)')
156
- expect(Q.isFactorized('4(2x+5)(x-6)')).to.be.true
157
- expect(Q.isFactorized('(8x+20)(x-6)')).to.be.false
158
- expect(Q.isFactorized('(8x+20)(x-6)', true)).to.be.true
159
- });
160
-
161
- it('should check if a polynom is developed', function () {
162
- let P = new Polynom('x(x+1)')
163
-
164
- expect(P.isDeveloped('x^(2)+x')).true
165
- expect(P.isDeveloped('x^2+x')).true
166
- expect(P.isDeveloped('x(x+1)')).false
167
-
168
- });
169
-
170
- it('should reorder polynom', function () {
171
- let P = new Polynom("3x-4+2y")
172
- P.reorder()
173
- expect(P.tex).to.be.equal('3x+2y-4')
174
- });
175
- })
176
-
177
- describe('Polynom parsing with rational power', () => {
178
- it('should parse with rational powers', () => {
179
- const P = new Polynom('3x^(2/3)-5x+5/3');
180
- expect(P.tex).to.be.equal('-5x+3x^{\\tfrac{ 2 }{ 3 }}+\\frac{ 5 }{ 3 }')
181
- })
182
- })
183
-
184
- describe("Polynom with multiple variables", () => {
185
- it('should parse with multiple variables', () => {
186
- const P = new Polynom('ax')
187
- expect(P.display).to.be.equal('ax')
188
- })
189
- })
190
-
191
- // describe("test simple", ()=>{
192
- // it('should parce this one correctly', ()=>{
193
- // const P = new Polynom('-(x+2)(x-1)(x-1)(5x+4)')
194
- // const Q = new Polynom('(2+x)^2(1-x)^3')
195
- // })
196
- // })
197
-
198
- // TODO: working with roots !
199
- // describe('WIP : working with roots', ()=>{
200
- // it('should parse with roots coefficient', ()=>{
201
- // let P = new Polynom('sqrt(x)-5')
202
- //
203
- // expect(P.degree().value).to.be.equal(0.5)
204
- // })
205
- // })
206
- //
207
- // describe('Polynom used as complex number', () => {
208
- // let P = new Polynom('4+3i')
209
- //
210
- // P.pow(2)
211
- //
212
- // P.monoms.forEach(m => {
213
- // const d = m.degree('i').value
214
- // if (d >= 2) {
215
- // if (d % 2 === 0) {
216
- // m.coefficient = m.coefficient.multiply((-1) ** (d / 2))
217
- // m.setLetter('i', 0)
218
- // } else {
219
- // m.coefficient = m.coefficient.multiply((-1) ** ((d - 1) / 2))
220
- // m.setLetter('i', 1)
221
- // }
222
- // }
223
- // })
224
- // // console.log(P.reduce().tex)
225
- //
226
- // })
227
- //
228
- // describe("making my test", () => {
229
- // let models = [
230
- // {
231
- // question: 'B \\cdot A^{K}=C',
232
- // answer: {
233
- // log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(c, b),
234
- // poly: (k: Polynom, p: Polynom) => k.clone()
235
- // }
236
- // },
237
- // {
238
- // question: 'B \\cdot A^{K}=C',
239
- // answer: {
240
- // log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(c, b),
241
- // poly: (k: Polynom, p: Polynom) => k.clone()
242
- // }
243
- // },
244
- // {
245
- // question: 'A^{K}=B \\cdot A^{P}',
246
- // answer: {
247
- // log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(b),
248
- // poly: (k: Polynom, p: Polynom) => k.clone().subtract(p)
249
- // }
250
- // },
251
- // {
252
- // question: 'A^{K}=B \\cdot A^{P}',
253
- // answer: {
254
- // log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(b),
255
- // poly: (k: Polynom, p: Polynom) => k.clone().subtract(p)
256
- // }
257
- // },
258
- // {
259
- // question: 'B \\cdot A^{K} = C \\cdot A^{P}',
260
- // answer: {
261
- // log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(c, b),
262
- // poly: (k: Polynom, p: Polynom) => k.clone().subtract(p)
263
- // }
264
- // },
265
- // {
266
- // question: 'B \\cdot A^{K} = \\frac{ C }{ A^{P} }',
267
- // answer: {
268
- // log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(c, b),
269
- // poly: (k: Polynom, p: Polynom) => k.clone().add(p)
270
- // }
271
- // },
272
- // {
273
- // question: 'C \\cdot A^{K} - B = D',
274
- // answer: {
275
- // log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(d + b, c),
276
- // poly: (k: Polynom, p: Polynom) => k.clone()
277
- // }
278
- // },
279
- // {
280
- // question: 'C \\cdot A^{K} - B = D \\cdot A^{P} ',
281
- // answer: {
282
- // log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(b, c - e),
283
- // poly: (k: Polynom, p: Polynom) => k.clone()
284
- // }
285
- // },
286
- // ]
287
- //
288
- //
289
- // for (let i = 0; i < 15; i++) {
290
- // console.log(`{\\centering \\huge équations logarithmiques \\\\ }\n\nRésoudre les équations suivantes. Donner la réponse sous forme exacte et avec 4 décimales.`)
291
- //
292
- // console.log(`\\begin{enumerate}[(i),itemsep=4em]\n`)
293
- //
294
- // for (let m of models) {
295
- // let a = PiMath.Random.number(2, 9),
296
- // b = PiMath.Random.number(2, 9),
297
- // c = PiMath.Random.number(2, 9),
298
- // d = PiMath.Random.number(1, 9),
299
- // e = PiMath.Random.number(1, c - 1),
300
- // k = PiMath.Random.polynom({degree: 1}),
301
- // p = PiMath.Random.polynom({degree: 1})
302
- //
303
- // if (k.monomByDegree(1).coefficient.isNegative()) {
304
- // k.opposed()
305
- // }
306
- // if (p.monomByDegree(1).coefficient.isNegative()) {
307
- // p.opposed()
308
- // }
309
- //
310
- // let poly = m.answer.poly(k, p),
311
- // pa = poly.monomByDegree(1).coefficient,
312
- // pb = poly.monomByDegree(0).coefficient
313
- //
314
- // if (pa.isZero()) {
315
- // k = k.add('x')
316
- // poly = m.answer.poly(k, p),
317
- // pa = poly.monomByDegree(1).coefficient,
318
- // pb = poly.monomByDegree(0).coefficient
319
- // }
320
- //
321
- // const question = m.question
322
- // .replaceAll('A', a.toString())
323
- // .replaceAll('B', b.toString())
324
- // .replaceAll('C', c.toString())
325
- // .replaceAll('D', d.toString())
326
- // .replaceAll('K', k.tex)
327
- // .replaceAll('P', p.tex)
328
- //
329
- //
330
- // const log = m.answer.log(a, b, c, d, e).reduce()
331
- // let answer = `\\log_{ ${a} }\\left( ${log.tex} \\right)`
332
- // if (!pb.isZero()) answer = `${answer}${pb.clone().opposed().texWithSign}`
333
- // if (!pa.isOne()) answer = `\\frac{ ${answer} }{ ${pa.tex} }`
334
- //
335
- // let value = ((Math.log10(log.value) / Math.log10(a) - pb.value) / pa.value).toFixed(4)
336
- //
337
- // console.log(`\\item \\(\\displaystyle ${question}\\) \\hfill \\( \\trou{ ${answer}=${value} } \\)`)
338
- // }
339
- //
340
- // console.log(`\\end{enumerate}\n\\newpage`)
341
- // }
342
- //
343
- // })
@@ -1,64 +0,0 @@
1
- import {describe} from "mocha";
2
- import {Rational} from "../../src/maths/algebra/rational";
3
- import {Polynom} from "../../src/maths/algebra/polynom";
4
- import {expect} from "chai";
5
-
6
- describe('Rational tests', () => {
7
- it('should calculate correctly the limits to a value', () => {
8
-
9
- const FR = new Rational(
10
- new Polynom('(x+2)'),
11
- new Polynom('(x-4)(x+2)')
12
- )
13
-
14
- expect(FR.limits(4).tex).to.be.equal("+\\infty")
15
- expect(FR.limits(4, 'below').tex).to.be.equal("-\\infty")
16
- expect(FR.limits(4, 'above').tex).to.be.equal("+\\infty")
17
- expect(FR.limits(-2).tex).to.be.equal("-\\frac{ 1 }{ 6 }")
18
- })
19
- it('should calculate the limits to Infinity', () => {
20
- const FR0 = new Rational(
21
- new Polynom('3'),
22
- new Polynom('x-5')
23
- )
24
- const FR2 = new Rational(
25
- new Polynom('2x+5'),
26
- new Polynom('x-5')
27
- )
28
-
29
- const FR3 = new Rational(
30
- new Polynom('2x^2+5'),
31
- new Polynom('x-5')
32
- )
33
-
34
- expect(FR0.limits(Infinity).value).to.be.equal(0)
35
- expect(FR0.limits(-Infinity).value).to.be.equal(0)
36
-
37
- expect(FR2.limits(Infinity).value).to.be.equal(2)
38
- expect(FR2.limits(-Infinity).value).to.be.equal(2)
39
-
40
- expect(FR3.limits(Infinity).value).to.be.equal(Infinity)
41
- expect(FR3.limits(-Infinity).value).to.be.equal(-Infinity)
42
- })
43
-
44
-
45
- it('should calculate the derivative', function () {
46
- const FR = new Rational(
47
- new Polynom('x^2+5x+6'),
48
- new Polynom('x-3')
49
- )
50
-
51
- FR.derivative()
52
- });
53
-
54
- it('should test', function () {
55
- let P = new Rational('245(x-2)', '(3x-5)(2x-3)')
56
-
57
- expect(P.plotFunction).to.be.equal("(245*x-490)/(6*x^(2)-19*x+15)")
58
- });
59
-
60
- it('should reduce withouth creating fraction', function () {
61
- let P = new Rational('4(x+1)', '(x+1)(x-3)')
62
- expect(P.reduce().display).to.be.equal('(4)/(x-3)')
63
- });
64
- })
@@ -1,48 +0,0 @@
1
- import {describe} from "mocha";
2
- import {Rational} from "../../src/maths/algebra/rational";
3
- import {RationalStudy} from "../../src/maths/algebra/study/rationalStudy";
4
- import {expect} from "chai";
5
- import {ASYMPTOTE} from "../../src/maths/algebra/study";
6
-
7
- describe('Study tests', () => {
8
-
9
- it('should get the zeroes', function () {
10
- const study = new RationalStudy(
11
- // new Rational('x^2-4x-4', 'x+7')
12
- new Rational('(3x-2)(x-3)(x+4)', 'x^2-5x+6')
13
- )
14
- let AO = study.asymptotes.filter(x => x.type === ASYMPTOTE.SLOPE)[0]
15
- });
16
-
17
- it('should create draw code block', function () {
18
- const study = new RationalStudy(
19
- new Rational("(3x-4)(2x+5)", "(x-4)(x+4)")
20
- )
21
-
22
- expect(study.drawCode()).to.be.equal("f(x)=(6*x^(2)+7*x-20)/(x^(2)-16)\n" +
23
- "av_1=line x=-4->red,dash\n" +
24
- "av_3=line x=4->red,dash\n" +
25
- "ah=line y=6->orange,dash\n" +
26
- "M_6(-20.950583847231826,5.832940216581962)*\n" +
27
- "M_7(-0.7637018670538883,1.4170597834180383)*\n" +
28
- "Z_8(-2.5,0)*\n" +
29
- "Z_9(1.3333333333333333,0)*")
30
- });
31
-
32
- it('should get the before/after state of asymptotes', function () {
33
- const study = new RationalStudy(
34
- new Rational("x+5", "x-3")
35
- // new Rational("x^2+5", "(x-3)^2")
36
- )
37
-
38
- expect(study.asymptotes[0].position).to.have.all.members(["LB", "RT"])
39
- });
40
-
41
- it('should get only the domain and the signs of a rational', function () {
42
- const R = new Rational('x-3', 'x^2-4')
43
- const study = R.study('\\delta(x),d,signs')
44
-
45
- expect(study.domain).to.be.equal('\\mathbb{R}\\setminus\\left\\{-2;2\\right\\}')
46
- expect(study.signs.signs[0]).to.have.all.members(['', '-', 't', '-', 't', '-', 'z', '+', ''])
47
- });
48
- })
@@ -1,131 +0,0 @@
1
- import {expect} from "chai";
2
- import {Fraction} from "../../src/maths/coefficients/fraction";
3
- import {describe} from "mocha";
4
- import {Random} from "../../src/maths/randomization/random";
5
-
6
-
7
- describe('Fraction tests', () => { // the tests container
8
-
9
- it('Tex display', () => { // the single test
10
- const options = new Fraction(2, 5); // this will be your class
11
- expect(options.frac).to.be.equal('\\frac{ 2 }{ 5 }');
12
- });
13
-
14
- it('Compare: equals', () => {
15
- let F = new Fraction(1, 3),
16
- Q = new Fraction(2, 6),
17
- P = new Fraction(2, 5);
18
- expect(F.isEqual(Q)).to.be.true;
19
- expect(F.isEqual(P)).to.be.false;
20
- })
21
-
22
- it('Operation: sum of two fraction', () => {
23
- let F = new Fraction(1, 3),
24
- Q = new Fraction(2, 7);
25
-
26
- F.add(Q);
27
-
28
- expect(F.numerator).to.be.equal(13);
29
- expect(F.denominator).to.be.equal(21);
30
- })
31
-
32
- it('Reduced', () => {
33
- let F = new Fraction(2, 5),
34
- Q = new Fraction(2, 6)
35
-
36
- expect(F.isReduced()).to.be.true
37
- expect(Q.isReduced()).to.be.false
38
- })
39
-
40
- it('Should parse a number with lots of decimals', ()=>{
41
- let A = 3.45,
42
- B = 3.3333333333333,
43
- C = 5.314171717171717
44
-
45
- let FA = new Fraction(A),
46
- FB = new Fraction(B, 1),
47
- FC = new Fraction(C, 2)
48
-
49
- expect(FA.display).to.be.equal('69/20')
50
- expect(FB.display).to.be.equal('10/3')
51
- expect(FC.display).to.be.equal('526103/99000')
52
- })
53
- })
54
-
55
- describe("Fraction static functions", ()=>{
56
- it('should sort fractions', function () {
57
- let list = [
58
- new Fraction('3.5'),
59
- new Fraction('-2.5'),
60
- new Fraction('3.1'),
61
- new Fraction('3.54'),
62
- new Fraction('1.5')
63
- ]
64
-
65
- expect(Fraction.sort(list).map(x=>x.value)).to.eql([ -2.5, 1.5, 3.1, 3.5, 3.54 ])
66
- });
67
-
68
- it('should make a list of fractions unique', function () {
69
- let list = [
70
- new Fraction('3.5'),
71
- new Fraction('-2.5'),
72
- new Fraction('7/2'),
73
- new Fraction('3.50'),
74
- new Fraction('1.5')
75
- ]
76
-
77
- expect(Fraction.unique(list, true).map(x=>x.value)).to.be.eql([ -2.5, 1.5, 3.5 ])
78
-
79
- });
80
-
81
- it('shoudl get the average of fractions', function() {
82
- let list = [
83
- new Fraction('3.5'),
84
- new Fraction('-2.5'),
85
- new Fraction('7/2'),
86
- new Fraction('3.50'),
87
- new Fraction('1.5')
88
- ]
89
-
90
- expect(Fraction.average(...list).tex).to.be.equal('\\frac{ 19 }{ 10 }')
91
- })
92
-
93
- it('should multiply and not reduce', function () {
94
- let list = [
95
- new Fraction('1/2'),
96
- new Fraction('4/3'),
97
- 2.5,
98
- 3
99
- ]
100
-
101
- expect(new Fraction().xMultiply(...list).display).to.be.equal("60/12")
102
- });
103
- })
104
-
105
- describe("Evaluate fraction", () => {
106
- it('should evaluate and convert to decimal if not exact', function () {
107
- let F = new Fraction(Math.sqrt(2))
108
-
109
- expect(F.isApproximative()).to.be.true
110
- expect(F.isExact()).to.be.false
111
-
112
- let G = new Fraction('1/7')
113
- expect(G.isApproximative()).to.be.false
114
- expect(G.isExact()).to.be.true
115
- });
116
- })
117
-
118
- describe('Generate function', ()=>{
119
- it('should generate a non natural fraction', function () {
120
- let F, result = true
121
-
122
- for(let i=0; i<100; i++){
123
- F = Random.fraction()
124
- if(!F.isRelative()){
125
- result = false
126
- break
127
- }
128
- }
129
- expect(F.isNatural()).to.be.false;
130
- });
131
- })