pimath 0.0.128 → 0.0.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.d.ts +39 -0
- package/dist/maths/algebra/equation.d.ts +120 -0
- package/dist/maths/algebra/linearSystem.d.ts +40 -0
- package/dist/maths/algebra/logicalset.d.ts +28 -0
- package/dist/maths/algebra/monom.d.ts +207 -0
- package/dist/maths/algebra/polynom.d.ts +155 -0
- package/dist/maths/algebra/rational.d.ts +44 -0
- package/dist/maths/algebra/study/rationalStudy.d.ts +14 -0
- package/dist/maths/algebra/study.d.ts +140 -0
- package/dist/maths/coefficients/fraction.d.ts +90 -0
- package/dist/maths/coefficients/nthRoot.d.ts +23 -0
- package/dist/maths/geometry/circle.d.ts +46 -0
- package/dist/maths/geometry/line.d.ts +102 -0
- package/dist/maths/geometry/point.d.ts +36 -0
- package/dist/maths/geometry/triangle.d.ts +92 -0
- package/dist/maths/geometry/vector.d.ts +38 -0
- package/dist/maths/numeric.d.ts +28 -0
- package/dist/maths/numexp.d.ts +19 -0
- package/dist/maths/randomization/random.d.ts +26 -0
- package/dist/maths/randomization/randomCore.d.ts +7 -0
- package/dist/maths/randomization/rndFraction.d.ts +13 -0
- package/dist/maths/randomization/rndGeometryCircle.d.ts +13 -0
- package/dist/maths/randomization/rndGeometryLine.d.ts +13 -0
- package/dist/maths/randomization/rndGeometryPoint.d.ts +13 -0
- package/dist/maths/randomization/rndHelpers.d.ts +23 -0
- package/dist/maths/randomization/rndMonom.d.ts +13 -0
- package/dist/maths/randomization/rndPolynom.d.ts +14 -0
- package/dist/maths/randomization/rndTypes.d.ts +40 -0
- package/dist/maths/shutingyard.d.ts +59 -0
- package/dist/pimath.js +85 -85
- package/lib/main.ts +42 -0
- package/{src → lib}/maths/algebra/equation.ts +52 -58
- package/{src → lib}/maths/algebra/linearSystem.ts +5 -6
- package/lib/maths/algebra/logicalset.ts +183 -0
- package/{src → lib}/maths/algebra/monom.ts +7 -8
- package/{src → lib}/maths/algebra/polynom.ts +2 -2
- package/{src → lib}/maths/algebra/study.ts +9 -9
- package/{src → lib}/maths/coefficients/fraction.ts +4 -4
- package/{src → lib}/maths/geometry/circle.ts +6 -9
- package/{src → lib}/maths/geometry/line.ts +1 -1
- package/{src → lib}/maths/geometry/vector.ts +35 -34
- package/{src → lib}/maths/numexp.ts +91 -77
- package/{src → lib}/maths/randomization/rndHelpers.ts +1 -1
- package/{src → lib}/maths/randomization/rndMonom.ts +13 -13
- package/{src → lib}/maths/randomization/rndPolynom.ts +24 -24
- package/package.json +11 -12
- package/.eslintrc.js +0 -24
- package/.idea/$CACHE_FILE$ +0 -6
- package/.idea/PI.iml +0 -14
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/php.xml +0 -19
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]/shelved.patch +0 -192
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]1/shelved.patch +0 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30__Default_Changelist_.xml +0 -4
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43_[Default_Changelist]/shelved.patch +0 -2404
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43__Default_Changelist_.xml +0 -4
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01_[Default_Changelist]/shelved.patch +0 -1362
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01__Default_Changelist_.xml +0 -4
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]/shelved.patch +0 -90
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_.xml +0 -4
- package/.idea/vcs.xml +0 -6
- package/dist/demo/exercises.html +0 -283
- package/dist/demo/matrices.html +0 -39
- package/dist/demo/playground.html +0 -20
- package/dist/demo.css +0 -3
- package/dist/pimath.umd.cjs +0 -15
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -78
- package/docs/assets/main.js +0 -59
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1383
- package/docs/classes/Logicalset.Logicalset.html +0 -217
- package/docs/classes/Polynom.Rational.html +0 -397
- package/docs/classes/Vector-1.Vector.html +0 -490
- package/docs/classes/Vector.Point.html +0 -337
- package/docs/classes/algebra_equation.Equation.html +0 -790
- package/docs/classes/algebra_linearSystem.LinearSystem.html +0 -404
- package/docs/classes/algebra_monom.Monom.html +0 -962
- package/docs/classes/algebra_polynom.Polynom.html +0 -1275
- package/docs/classes/coefficients_fraction.Fraction.html +0 -934
- package/docs/classes/geometry_circle.Circle.html +0 -472
- package/docs/classes/geometry_line.Line.html +0 -774
- package/docs/classes/geometry_triangle.Triangle.html +0 -429
- package/docs/classes/numeric.Numeric.html +0 -265
- package/docs/classes/shutingyard.Shutingyard.html +0 -250
- package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +0 -83
- package/docs/enums/geometry_line.LinePropriety.html +0 -97
- package/docs/enums/shutingyard.ShutingyardMode.html +0 -97
- package/docs/enums/shutingyard.ShutingyardType.html +0 -111
- package/docs/index.html +0 -63
- package/docs/interfaces/algebra_equation.ISolution.html +0 -105
- package/docs/interfaces/algebra_polynom.IEuclidian.html +0 -87
- package/docs/interfaces/geometry_triangle.remarquableLines.html +0 -163
- package/docs/modules/Logicalset.html +0 -65
- package/docs/modules/Polynom.html +0 -65
- package/docs/modules/Vector-1.html +0 -65
- package/docs/modules/Vector.html +0 -65
- package/docs/modules/algebra_equation.html +0 -69
- package/docs/modules/algebra_linearSystem.html +0 -61
- package/docs/modules/algebra_monom.html +0 -65
- package/docs/modules/algebra_polynom.html +0 -69
- package/docs/modules/coefficients_fraction.html +0 -65
- package/docs/modules/geometry_circle.html +0 -61
- package/docs/modules/geometry_line.html +0 -65
- package/docs/modules/geometry_triangle.html +0 -65
- package/docs/modules/numeric.html +0 -61
- package/docs/modules/shutingyard.html +0 -75
- package/docs/types/algebra_monom.literalType.html +0 -61
- package/docs/types/algebra_polynom.PolynomParsingType.html +0 -56
- package/docs/types/coefficients_fraction.FractionParsingType.html +0 -56
- package/docs/types/shutingyard.Token.html +0 -63
- package/docs/types/shutingyard.tokenType.html +0 -68
- package/docs/variables/shutingyard.tokenConstant.html +0 -61
- package/index.html +0 -15
- package/public/demo/exercises.html +0 -283
- package/public/demo/matrices.html +0 -39
- package/public/demo/playground.html +0 -20
- package/public/demo.css +0 -3
- package/src/demo/exercises.ts +0 -0
- package/src/demo/matrices.ts +0 -61
- package/src/demo/playground.ts +0 -153
- package/src/main.ts +0 -42
- package/src/maths/algebra/logicalset.ts +0 -183
- package/tests/algebra/equation.test.ts +0 -64
- package/tests/algebra/linear.test.ts +0 -58
- package/tests/algebra/monom.test.ts +0 -78
- package/tests/algebra/polynom.test.ts +0 -343
- package/tests/algebra/rationnal.test.ts +0 -64
- package/tests/algebra/study.test.ts +0 -48
- package/tests/coefficients/fraction.test.ts +0 -131
- package/tests/custom.test.ts +0 -33
- package/tests/geometry/circle.test.ts +0 -404
- package/tests/geometry/line.test.ts +0 -36
- package/tests/numeric.test.ts +0 -43
- package/tests/numexp.test.ts +0 -89
- package/tests/shutingyard.test.ts +0 -58
- package/tsconfig.json +0 -52
- package/tsconfig.testing.json +0 -28
- package/typedoc.katex.js +0 -11
- package/vite.config.js +0 -23
- package/webpack-production-min.config.js +0 -26
- package/webpack-production.config.js +0 -26
- package/webpack.config.js +0 -26
- /package/{src → lib}/maths/algebra/rational.ts +0 -0
- /package/{src → lib}/maths/algebra/study/rationalStudy.ts +0 -0
- /package/{src → lib}/maths/coefficients/nthRoot.ts +0 -0
- /package/{src → lib}/maths/geometry/point.ts +0 -0
- /package/{src → lib}/maths/geometry/triangle.ts +0 -0
- /package/{src → lib}/maths/numeric.ts +0 -0
- /package/{src → lib}/maths/randomization/random.ts +0 -0
- /package/{src → lib}/maths/randomization/randomCore.ts +0 -0
- /package/{src → lib}/maths/randomization/rndFraction.ts +0 -0
- /package/{src → lib}/maths/randomization/rndGeometryCircle.ts +0 -0
- /package/{src → lib}/maths/randomization/rndGeometryLine.ts +0 -0
- /package/{src → lib}/maths/randomization/rndGeometryPoint.ts +0 -0
- /package/{src → lib}/maths/randomization/rndTypes.ts +0 -0
- /package/{src → lib}/maths/shutingyard.ts +0 -0
|
@@ -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
|
-
})
|
package/tests/custom.test.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// describe('Custom test', () => { // the tests container
|
|
2
|
-
// it('Build sqrt value', () => {
|
|
3
|
-
//
|
|
4
|
-
// let a = 1, b = 27, c = 50
|
|
5
|
-
//
|
|
6
|
-
// a = Random.number(2,20)
|
|
7
|
-
// b = Random.number(2,20)
|
|
8
|
-
// c = Random.number(2,20)
|
|
9
|
-
//
|
|
10
|
-
// let nthB = new NthRoot(b).reduce(),
|
|
11
|
-
// nthC = new NthRoot(c).reduce(),
|
|
12
|
-
// nthD = new NthRoot(nthB.radical * nthC.radical).reduce(),
|
|
13
|
-
// F = new Fraction(a*nthB.coefficient*nthD.coefficient, nthC.radical*nthC.coefficient).reduce(),
|
|
14
|
-
// answer = ''
|
|
15
|
-
//
|
|
16
|
-
// if(F.numerator>1){
|
|
17
|
-
// answer = `${F.numerator}`
|
|
18
|
-
// }
|
|
19
|
-
// if(nthD.radical>1){
|
|
20
|
-
// answer = `${answer}sqrt${nthD.radical}`
|
|
21
|
-
// }
|
|
22
|
-
// if(F.denominator>1){
|
|
23
|
-
// answer = `${answer}/${F.denominator}`
|
|
24
|
-
// }
|
|
25
|
-
// console.log(`${a}sqrt${b}/sqrt${c}`, answer)
|
|
26
|
-
// })
|
|
27
|
-
//
|
|
28
|
-
// it('should generate a line', function () {
|
|
29
|
-
// let L = Random.Geometry.line({
|
|
30
|
-
// A: {x: 3, y: 7}
|
|
31
|
-
// })
|
|
32
|
-
// });
|
|
33
|
-
// });
|