pimath 0.0.40 → 0.0.41
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/pi.js +288 -92
- package/dist/pi.js.map +1 -1
- package/dist/pi.min.js +1 -1
- package/dist/pi.min.js.map +1 -1
- package/docs/assets/search.js +1 -1
- package/esm/index.d.ts +2 -2
- package/esm/index.js +2 -2
- package/esm/maths/algebra/equation.d.ts +6 -2
- package/esm/maths/algebra/equation.js +49 -9
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +2 -1
- package/esm/maths/algebra/polynom.js +98 -62
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/algebra/rational.d.ts +10 -0
- package/esm/maths/algebra/rational.js +101 -10
- package/esm/maths/algebra/rational.js.map +1 -1
- package/esm/maths/coefficients/fraction.d.ts +3 -1
- package/esm/maths/coefficients/fraction.js +33 -4
- package/esm/maths/coefficients/fraction.js.map +1 -1
- package/esm/maths/coefficients/{nthroot.d.ts → nthRoot.d.ts} +5 -5
- package/esm/maths/coefficients/{nthroot.js → nthRoot.js} +5 -5
- package/esm/maths/coefficients/{nthroot.js.map → nthRoot.js.map} +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -2
- package/src/maths/algebra/equation.ts +58 -12
- package/src/maths/algebra/polynom.ts +100 -68
- package/src/maths/algebra/rational.ts +136 -20
- package/src/maths/coefficients/fraction.ts +39 -5
- package/src/maths/coefficients/{nthroot.ts → nthRoot.ts} +5 -5
- package/tests/algebra/equation.test.ts +38 -0
- package/tests/algebra/monom.test.ts +1 -4
- package/tests/algebra/rationnal.test.ts +29 -5
- package/tests/coefficients/fraction.test.ts +43 -1
- package/tests/geometry/circle.test.ts +4 -2
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
import {Equation} from "../../src/maths/algebra/equation";
|
|
6
|
+
|
|
7
|
+
describe('Equations tests', () => {
|
|
8
|
+
it('should get the solutions', () => {
|
|
9
|
+
|
|
10
|
+
let E1 = new Equation('3x+8', '0')
|
|
11
|
+
E1.solve()
|
|
12
|
+
expect(E1.solutions[0].tex).to.be.equal('-\\frac{ 8 }{ 3 }')
|
|
13
|
+
|
|
14
|
+
let E2 = new Equation('x^2+5x+6', '0')
|
|
15
|
+
E2.solve()
|
|
16
|
+
expect(E2.solutions.map(x=>x.tex)).to.have.all.members(['-3', '-2'])
|
|
17
|
+
|
|
18
|
+
let E3 = new Equation('(x-3)(x+2)(3x-5)', '0')
|
|
19
|
+
E3.solve()
|
|
20
|
+
expect(E3.solutions.map(x=>x.tex)).to.have.all.members([ '-2', '3', '\\frac{ 5 }{ 3 }' ])
|
|
21
|
+
|
|
22
|
+
let E4 = new Equation('x^2+x+10', '0')
|
|
23
|
+
E4.solve()
|
|
24
|
+
expect(E4.solutions.map(x=>x.tex)).to.have.all.members([ '\\varnothing' ])
|
|
25
|
+
|
|
26
|
+
let E5 = new Equation('(x-3)(x+2)(x-5)(x-7)(x+2)', 0)
|
|
27
|
+
E5.solve()
|
|
28
|
+
expect(E5.solutions.map(x=>x.tex)).to.have.all.members([ '-2', '3', '5', '7' ] )
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
let E6 = new Equation('5x^2+7x-31', 0)
|
|
32
|
+
E6.solve()
|
|
33
|
+
expect(E6.solutions.map(x=>x.tex)).to.have.all.members([
|
|
34
|
+
'\\dfrac{-7 - \\sqrt{669} }{ 10 }',
|
|
35
|
+
'\\dfrac{-7 + \\sqrt{669} }{ 10 }'
|
|
36
|
+
] )
|
|
37
|
+
})
|
|
38
|
+
})
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import {expect} from 'chai';
|
|
2
|
-
import {Monom} from "../../src/maths/algebra";
|
|
3
2
|
import {Random} from "../../src/maths/randomization/random";
|
|
4
3
|
import {describe} from "mocha";
|
|
5
|
-
import {
|
|
6
|
-
import {Shutingyard} from "../../src/maths/shutingyard";
|
|
7
|
-
import {log} from "util";
|
|
4
|
+
import {Monom} from "../../src/maths/algebra/monom";
|
|
8
5
|
|
|
9
6
|
describe('Monom with integer power', () => {
|
|
10
7
|
it('parsing', () => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {describe} from "mocha";
|
|
2
2
|
import {Rational} from "../../src/maths/algebra/rational";
|
|
3
3
|
import {Polynom} from "../../src/maths/algebra/polynom";
|
|
4
|
-
import {Fraction} from "../../src/maths/coefficients/fraction";
|
|
5
4
|
import {expect} from "chai";
|
|
6
5
|
|
|
7
6
|
describe('Rational tests', () => {
|
|
@@ -12,12 +11,12 @@ describe('Rational tests', () => {
|
|
|
12
11
|
new Polynom('(x-4)(x+2)')
|
|
13
12
|
)
|
|
14
13
|
|
|
15
|
-
expect(FR.limits(4).tex).to.be.equal("
|
|
16
|
-
expect(FR.limits(4, 'below').tex).to.be.equal("
|
|
17
|
-
expect(FR.limits(4, 'above').tex).to.be.equal("
|
|
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")
|
|
18
17
|
expect(FR.limits(-2).tex).to.be.equal("-\\frac{ 1 }{ 6 }")
|
|
19
18
|
})
|
|
20
|
-
it('should calculate the limits to Infinity', ()=>{
|
|
19
|
+
it('should calculate the limits to Infinity', () => {
|
|
21
20
|
const FR0 = new Rational(
|
|
22
21
|
new Polynom('3'),
|
|
23
22
|
new Polynom('x-5')
|
|
@@ -41,4 +40,29 @@ describe('Rational tests', () => {
|
|
|
41
40
|
expect(FR3.limits(Infinity).value).to.be.equal(Infinity)
|
|
42
41
|
expect(FR3.limits(-Infinity).value).to.be.equal(-Infinity)
|
|
43
42
|
})
|
|
43
|
+
|
|
44
|
+
it('should make a table of signs', function () {
|
|
45
|
+
|
|
46
|
+
// const FR = new Rational(
|
|
47
|
+
// new Polynom('(x-2)'),
|
|
48
|
+
// new Polynom('(x+2)')
|
|
49
|
+
// )
|
|
50
|
+
// let tos = FR.makeTableOfSigns()
|
|
51
|
+
// expect(tos.zeroes.map(x => x.tex)).to.have.all.members(['-2', '2'])
|
|
52
|
+
// expect(tos.signs).to.be.eql([['', '-', 't', '-', 'z', '+', ''], ['', '-', 'd', '+', 't', '+', ''], [], ['', '+', 'd', '-', 'z', '+', '']])
|
|
53
|
+
const FR2 = new Rational(
|
|
54
|
+
new Polynom('(x-2)(x+5)(x^2+5x-31'),
|
|
55
|
+
new Polynom('(x+2)')
|
|
56
|
+
)
|
|
57
|
+
let tos2 = FR2.makeTableOfSigns()
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should calculate the derivative', function () {
|
|
61
|
+
const FR = new Rational(
|
|
62
|
+
new Polynom('x^2+5x+6'),
|
|
63
|
+
new Polynom('x-3')
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
FR.derivative()
|
|
67
|
+
});
|
|
44
68
|
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {expect} from "chai";
|
|
2
|
-
import {Fraction} from "../../src/maths/coefficients";
|
|
2
|
+
import {Fraction} from "../../src/maths/coefficients/fraction";
|
|
3
|
+
import {describe} from "mocha";
|
|
3
4
|
|
|
4
5
|
describe('Fraction tests', () => { // the tests container
|
|
5
6
|
|
|
@@ -33,4 +34,45 @@ describe('Fraction tests', () => { // the tests container
|
|
|
33
34
|
expect(F.isReduced()).to.be.true
|
|
34
35
|
expect(Q.isReduced()).to.be.false
|
|
35
36
|
})
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
describe("Fraction static functions", ()=>{
|
|
42
|
+
it('should sort fractions', function () {
|
|
43
|
+
let list = [
|
|
44
|
+
new Fraction('3.5'),
|
|
45
|
+
new Fraction('-2.5'),
|
|
46
|
+
new Fraction('3.1'),
|
|
47
|
+
new Fraction('3.54'),
|
|
48
|
+
new Fraction('1.5')
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
expect(Fraction.sort(list).map(x=>x.value)).to.eql([ -2.5, 1.5, 3.1, 3.5, 3.54 ])
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should make a list of fractions unique', function () {
|
|
55
|
+
let list = [
|
|
56
|
+
new Fraction('3.5'),
|
|
57
|
+
new Fraction('-2.5'),
|
|
58
|
+
new Fraction('7/2'),
|
|
59
|
+
new Fraction('3.50'),
|
|
60
|
+
new Fraction('1.5')
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
expect(Fraction.unique(list, true).map(x=>x.value)).to.be.eql([ -2.5, 1.5, 3.5 ])
|
|
64
|
+
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('shoudl get the average of fractions', function() {
|
|
68
|
+
let list = [
|
|
69
|
+
new Fraction('3.5'),
|
|
70
|
+
new Fraction('-2.5'),
|
|
71
|
+
new Fraction('7/2'),
|
|
72
|
+
new Fraction('3.50'),
|
|
73
|
+
new Fraction('1.5')
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
expect(Fraction.average(...list).tex).to.be.equal('\\frac{ 19 }{ 10 }')
|
|
77
|
+
})
|
|
36
78
|
})
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {describe} from "mocha";
|
|
2
|
-
import {Circle, Line, Point} from "../../src/maths/geometry";
|
|
3
|
-
import {Fraction} from "../../src/maths/coefficients";
|
|
4
2
|
import {expect} from "chai";
|
|
3
|
+
import {Circle} from "../../src/maths/geometry/circle";
|
|
4
|
+
import {Line} from "../../src/maths/geometry/line";
|
|
5
|
+
import {Point} from "../../src/maths/geometry/point";
|
|
6
|
+
import {Fraction} from "../../src/maths/coefficients/fraction";
|
|
5
7
|
|
|
6
8
|
describe('Circle', function () {
|
|
7
9
|
it('should calculate the intersection of a circle and a line', function () {
|