math-exercises 2.0.20 → 2.0.21
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/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType0.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType0.js +1 -1
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType1.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType1.js +1 -1
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType2.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType2.js +1 -1
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType3.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType3.js +1 -1
- package/lib/exercises/geometry/vectors/alignementViaColinearity.d.ts +12 -0
- package/lib/exercises/geometry/vectors/alignementViaColinearity.d.ts.map +1 -0
- package/lib/exercises/geometry/vectors/alignementViaColinearity.js +61 -0
- package/lib/exercises/geometry/vectors/colinearity.d.ts +10 -0
- package/lib/exercises/geometry/vectors/colinearity.d.ts.map +1 -0
- package/lib/exercises/geometry/vectors/colinearity.js +59 -0
- package/lib/exercises/geometry/vectors/index.d.ts +1 -0
- package/lib/exercises/geometry/vectors/index.d.ts.map +1 -1
- package/lib/exercises/geometry/vectors/index.js +2 -0
- package/lib/exercises/probaStat/independancy.d.ts +9 -0
- package/lib/exercises/probaStat/independancy.d.ts.map +1 -0
- package/lib/exercises/probaStat/independancy.js +59 -0
- package/lib/exercises/probaStat/index.d.ts +1 -0
- package/lib/exercises/probaStat/index.d.ts.map +1 -1
- package/lib/exercises/probaStat/index.js +1 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/line.d.ts +10 -0
- package/lib/math/geometry/line.d.ts.map +1 -1
- package/lib/math/geometry/line.js +34 -0
- package/lib/math/geometry/point.d.ts +4 -15
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +28 -20
- package/lib/math/geometry/vector.d.ts +8 -5
- package/lib/math/geometry/vector.d.ts.map +1 -1
- package/lib/math/geometry/vector.js +13 -3
- package/lib/math/numbers/decimals/decimal.d.ts +1 -2
- package/lib/math/numbers/decimals/decimal.d.ts.map +1 -1
- package/lib/math/numbers/decimals/decimal.js +31 -87
- package/lib/server.js +19 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firstDegreeInequationsType0.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType0.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAW3C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;
|
|
1
|
+
{"version":3,"file":"firstDegreeInequationsType0.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType0.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAW3C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AA6DF,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAAC,WAAW,CAajE,CAAC"}
|
|
@@ -21,7 +21,7 @@ const getFirstDegreeInequationsQuestion = () => {
|
|
|
21
21
|
const answer = `x${ineqType.symbol}${result}`;
|
|
22
22
|
const question = {
|
|
23
23
|
answer: answer,
|
|
24
|
-
instruction: `Résoudre l'inéquation : $${affine.toTex()} ${ineqType} ${c}$ `,
|
|
24
|
+
instruction: `Résoudre l'inéquation : $${affine.toTex()} ${ineqType.symbol} ${c}$ `,
|
|
25
25
|
keys: inequationKeys_1.inequationKeys,
|
|
26
26
|
answerFormat: "tex",
|
|
27
27
|
identifiers: { ineqType: ineqType.symbol, b: affine.b, c },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firstDegreeInequationsType1.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType1.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"firstDegreeInequationsType1.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType1.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAS3C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AAqEF,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAAC,WAAW,CAcjE,CAAC"}
|
|
@@ -22,7 +22,7 @@ const getFirstDegreeInequationsQuestion = () => {
|
|
|
22
22
|
const answer = `x${affine.a > 0 ? ineqType.symbol : invIneqType}${result}`;
|
|
23
23
|
const question = {
|
|
24
24
|
answer: answer,
|
|
25
|
-
instruction: `Résoudre l'inéquation : $${affine.toTex()} ${ineqType} ${b}$ `,
|
|
25
|
+
instruction: `Résoudre l'inéquation : $${affine.toTex()} ${ineqType.symbol} ${b}$ `,
|
|
26
26
|
keys: inequationKeys_1.inequationKeys,
|
|
27
27
|
answerFormat: "tex",
|
|
28
28
|
identifiers: { a: affine.a, b, ineqType: ineqType.symbol },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firstDegreeInequationsType2.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAc3C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;
|
|
1
|
+
{"version":3,"file":"firstDegreeInequationsType2.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAc3C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAwEF,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAAC,WAAW,CAajE,CAAC"}
|
|
@@ -25,7 +25,7 @@ const getFirstDegreeInequationsQuestion = () => {
|
|
|
25
25
|
const answer = `x${affine.a > 0 ? ineqType.symbol : invIneqType}${result}`;
|
|
26
26
|
const question = {
|
|
27
27
|
answer: answer,
|
|
28
|
-
instruction: `Résoudre l'inéquation : $${affine.toTex()} ${ineqType} ${c}$ `,
|
|
28
|
+
instruction: `Résoudre l'inéquation : $${affine.toTex()} ${ineqType.symbol} ${c}$ `,
|
|
29
29
|
keys: inequationKeys_1.inequationKeys,
|
|
30
30
|
answerFormat: "tex",
|
|
31
31
|
identifiers: { a: affine.a, b: affine.b, c, ineqType: ineqType.symbol },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firstDegreeInequationsType3.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAW3C,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;
|
|
1
|
+
{"version":3,"file":"firstDegreeInequationsType3.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAW3C,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAoFF,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAAC,WAAW,CAajE,CAAC"}
|
|
@@ -26,7 +26,7 @@ const getFirstDegreeInequationsQuestion = () => {
|
|
|
26
26
|
const answer = `x${coeff > 0 ? ineqType.symbol : invIneqType}${result}`;
|
|
27
27
|
const question = {
|
|
28
28
|
answer: answer,
|
|
29
|
-
instruction: `Résoudre l'inéquation : $${affine1.toTex()} ${ineqType} ${affine2.toTex()}$ `,
|
|
29
|
+
instruction: `Résoudre l'inéquation : $${affine1.toTex()} ${ineqType.symbol} ${affine2.toTex()}$ `,
|
|
30
30
|
keys: inequationKeys_1.inequationKeys,
|
|
31
31
|
answerFormat: "tex",
|
|
32
32
|
identifiers: {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MathExercise } from "../../../exercises/exercise";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
xA: number;
|
|
4
|
+
xB: number;
|
|
5
|
+
xC: number;
|
|
6
|
+
yA: number;
|
|
7
|
+
yB: number;
|
|
8
|
+
yC: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const alignementViaColinearity: MathExercise<Identifiers>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=alignementViaColinearity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alignementViaColinearity.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/vectors/alignementViaColinearity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EASb,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA8CF,eAAO,MAAM,wBAAwB,EAAE,YAAY,CAAC,WAAW,CAY9D,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.alignementViaColinearity = void 0;
|
|
4
|
+
const exercise_1 = require("../../../exercises/exercise");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const line_1 = require("../../../math/geometry/line");
|
|
7
|
+
const point_1 = require("../../../math/geometry/point");
|
|
8
|
+
const coinFlip_1 = require("../../../utils/coinFlip");
|
|
9
|
+
const shuffle_1 = require("../../../utils/shuffle");
|
|
10
|
+
const getAlignementViaColinearityQuestion = () => {
|
|
11
|
+
const points = point_1.PointConstructor.randomDifferent(["A", "B"]);
|
|
12
|
+
const line = new line_1.Line(points[0], points[1]);
|
|
13
|
+
let C;
|
|
14
|
+
const isAligned = (0, coinFlip_1.coinFlip)();
|
|
15
|
+
if (isAligned) {
|
|
16
|
+
do {
|
|
17
|
+
C = line.getRandomPoint("C");
|
|
18
|
+
} while (C.equals(points[0]) || C.equals(points[1]));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
do {
|
|
22
|
+
C = point_1.PointConstructor.random("C");
|
|
23
|
+
} while (C.equals(points[0]) || C.equals(points[1]) || line.includes(C));
|
|
24
|
+
}
|
|
25
|
+
const answer = isAligned ? "Oui" : "Non";
|
|
26
|
+
const question = {
|
|
27
|
+
answer,
|
|
28
|
+
instruction: `Soient trois points $${points[0].toTexWithCoords()}$, $${points[1].toTexWithCoords()}$ et $${C.toTexWithCoords()}$. Les points $A$, $B$ et $C$ sont-ils alignés ?`,
|
|
29
|
+
keys: [],
|
|
30
|
+
answerFormat: "raw",
|
|
31
|
+
identifiers: {
|
|
32
|
+
xA: points[0].x.evaluate({}),
|
|
33
|
+
xB: points[1].x.evaluate({}),
|
|
34
|
+
xC: C.x.evaluate({}),
|
|
35
|
+
yA: points[0].y.evaluate({}),
|
|
36
|
+
yB: points[1].y.evaluate({}),
|
|
37
|
+
yC: C.y.evaluate({}),
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
return question;
|
|
41
|
+
};
|
|
42
|
+
const getPropositions = (n, { answer }) => {
|
|
43
|
+
const propositions = [];
|
|
44
|
+
(0, exercise_1.addValidProp)(propositions, answer, "raw");
|
|
45
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, "Oui", "raw");
|
|
46
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, "Non", "raw");
|
|
47
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, "On ne peut pas savoir", "raw");
|
|
48
|
+
return (0, shuffle_1.shuffle)(propositions);
|
|
49
|
+
};
|
|
50
|
+
exports.alignementViaColinearity = {
|
|
51
|
+
id: "alignementViaColinearity",
|
|
52
|
+
label: "",
|
|
53
|
+
levels: ["2nde", "1reSpé"],
|
|
54
|
+
isSingleStep: true,
|
|
55
|
+
sections: ["Vecteurs", "Droites"],
|
|
56
|
+
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getAlignementViaColinearityQuestion, nb),
|
|
57
|
+
qcmTimer: 60,
|
|
58
|
+
freeTimer: 60,
|
|
59
|
+
getPropositions,
|
|
60
|
+
answerType: "QCM",
|
|
61
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MathExercise } from "../../../exercises/exercise";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
xu: number;
|
|
4
|
+
yu: number;
|
|
5
|
+
xv: number;
|
|
6
|
+
yv: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const colinearity: MathExercise<Identifiers>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=colinearity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colinearity.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/vectors/colinearity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EASb,MAAM,0BAA0B,CAAC;AAQlC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAyCF,eAAO,MAAM,WAAW,EAAE,YAAY,CAAC,WAAW,CAWjD,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.colinearity = void 0;
|
|
4
|
+
const exercise_1 = require("../../../exercises/exercise");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const vector_1 = require("../../../math/geometry/vector");
|
|
7
|
+
const randint_1 = require("../../../math/utils/random/randint");
|
|
8
|
+
const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
|
|
9
|
+
const coinFlip_1 = require("../../../utils/coinFlip");
|
|
10
|
+
const shuffle_1 = require("../../../utils/shuffle");
|
|
11
|
+
const getColinearityQuestion = () => {
|
|
12
|
+
const u = vector_1.VectorConstructor.random("u", false);
|
|
13
|
+
const isColinear = (0, coinFlip_1.coinFlip)();
|
|
14
|
+
let v;
|
|
15
|
+
if (isColinear) {
|
|
16
|
+
const coeff = new numberNode_1.NumberNode((0, randint_1.randint)(-5, 5));
|
|
17
|
+
v = u.times(coeff, "v");
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
do {
|
|
21
|
+
v = vector_1.VectorConstructor.random("v", false);
|
|
22
|
+
} while (u.isColinear(v));
|
|
23
|
+
}
|
|
24
|
+
// const isColinear = u.isColinear(v);
|
|
25
|
+
const answer = isColinear ? "Oui" : "Non";
|
|
26
|
+
const question = {
|
|
27
|
+
answer,
|
|
28
|
+
instruction: `Soit deux vecteurs $${u.toTexWithCoords()}$ et $${v.toTexWithCoords()}$. $${u.toTex()}$ et $${v.toTex()}$ sont-ils colinéaires ?`,
|
|
29
|
+
keys: [],
|
|
30
|
+
answerFormat: "raw",
|
|
31
|
+
identifiers: {
|
|
32
|
+
xu: u.x.evaluate({}),
|
|
33
|
+
xv: v.x.evaluate({}),
|
|
34
|
+
yu: u.y.evaluate({}),
|
|
35
|
+
yv: v.y.evaluate({}),
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
return question;
|
|
39
|
+
};
|
|
40
|
+
const getPropositions = (n, { answer }) => {
|
|
41
|
+
const propositions = [];
|
|
42
|
+
(0, exercise_1.addValidProp)(propositions, answer, "raw");
|
|
43
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, "Oui", "raw");
|
|
44
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, "Non", "raw");
|
|
45
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, "On ne peut pas savoir", "raw");
|
|
46
|
+
return (0, shuffle_1.shuffle)(propositions);
|
|
47
|
+
};
|
|
48
|
+
exports.colinearity = {
|
|
49
|
+
id: "colinearity",
|
|
50
|
+
label: "Déterminer si deux vecteurs sont colinéaires",
|
|
51
|
+
levels: ["2nde", "1reSpé"],
|
|
52
|
+
isSingleStep: true,
|
|
53
|
+
sections: ["Vecteurs"],
|
|
54
|
+
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getColinearityQuestion, nb),
|
|
55
|
+
qcmTimer: 60,
|
|
56
|
+
freeTimer: 60,
|
|
57
|
+
getPropositions,
|
|
58
|
+
answerType: "QCM",
|
|
59
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/vectors/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/vectors/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC"}
|
|
@@ -20,3 +20,5 @@ __exportStar(require("./determinant"), exports);
|
|
|
20
20
|
__exportStar(require("./scalarProductViaCoords"), exports);
|
|
21
21
|
__exportStar(require("./vectorCoordinatesFromTwoPoints"), exports);
|
|
22
22
|
__exportStar(require("./scalarProductViaCos"), exports);
|
|
23
|
+
__exportStar(require("./colinearity"), exports);
|
|
24
|
+
// export * from "./alignementViaColinearity";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"independancy.d.ts","sourceRoot":"","sources":["../../../src/exercises/probaStat/independancy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EASb,MAAM,0BAA0B,CAAC;AAYlC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAiDF,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,WAAW,CAalD,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.independancy = void 0;
|
|
4
|
+
const exercise_1 = require("../../exercises/exercise");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const decimal_1 = require("../../math/numbers/decimals/decimal");
|
|
7
|
+
const frenchify_1 = require("../../math/utils/latex/frenchify");
|
|
8
|
+
const randint_1 = require("../../math/utils/random/randint");
|
|
9
|
+
const round_1 = require("../../math/utils/round");
|
|
10
|
+
const coinFlip_1 = require("../../utils/coinFlip");
|
|
11
|
+
const shuffle_1 = require("../../utils/shuffle");
|
|
12
|
+
const getIndependancyQuestion = () => {
|
|
13
|
+
const pA = decimal_1.DecimalConstructor.random(0, 1, (0, randint_1.randint)(1, 3));
|
|
14
|
+
const pATree = pA.toTree();
|
|
15
|
+
const pB = decimal_1.DecimalConstructor.random(0, 1, (0, randint_1.randint)(1, 3));
|
|
16
|
+
const pBTree = pB.toTree();
|
|
17
|
+
const areIndependants = (0, coinFlip_1.coinFlip)();
|
|
18
|
+
const answer = areIndependants ? "Oui" : "Non";
|
|
19
|
+
let pUnion;
|
|
20
|
+
const unionValueIfIndependants = (0, round_1.round)(pA.value + pB.value - pA.value * pB.value, 5);
|
|
21
|
+
if (areIndependants)
|
|
22
|
+
pUnion = unionValueIfIndependants;
|
|
23
|
+
else {
|
|
24
|
+
do {
|
|
25
|
+
pUnion = decimal_1.DecimalConstructor.random(0, 1, (0, randint_1.randint)(1, 3)).value;
|
|
26
|
+
} while ((pUnion < pA.value && pUnion < pB.value) ||
|
|
27
|
+
pUnion === unionValueIfIndependants ||
|
|
28
|
+
pUnion > pA.value + pB.value);
|
|
29
|
+
}
|
|
30
|
+
const question = {
|
|
31
|
+
answer,
|
|
32
|
+
instruction: `Soient deux événements $A$ et $B$ tels que $P(A) = ${(0, frenchify_1.frenchify)(pA.value)}$, $P(B) = ${(0, frenchify_1.frenchify)(pB.value)}$ et $P(A\\cup B) = ${(0, frenchify_1.frenchify)(pUnion)}$. Les événements $A$ et $B$ sont-ils indépendants ?`,
|
|
33
|
+
keys: [],
|
|
34
|
+
answerFormat: "raw",
|
|
35
|
+
identifiers: { pA: pA.value, pB: pB.value, pUnion },
|
|
36
|
+
};
|
|
37
|
+
return question;
|
|
38
|
+
};
|
|
39
|
+
const getPropositions = (n, { answer }) => {
|
|
40
|
+
const propositions = [];
|
|
41
|
+
(0, exercise_1.addValidProp)(propositions, answer, "raw");
|
|
42
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, "Oui", "raw");
|
|
43
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, "Non", "raw");
|
|
44
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, "On ne peut pas savoir", "raw");
|
|
45
|
+
return (0, shuffle_1.shuffle)(propositions);
|
|
46
|
+
};
|
|
47
|
+
exports.independancy = {
|
|
48
|
+
id: "independancy",
|
|
49
|
+
connector: "=",
|
|
50
|
+
label: "Déterminer l'indépendance de deux événements via la formule de Poincaré",
|
|
51
|
+
levels: ["1reSpé", "TermTech"],
|
|
52
|
+
isSingleStep: true,
|
|
53
|
+
sections: ["Probabilités"],
|
|
54
|
+
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getIndependancyQuestion, nb),
|
|
55
|
+
qcmTimer: 60,
|
|
56
|
+
freeTimer: 60,
|
|
57
|
+
getPropositions,
|
|
58
|
+
answerType: "QCM",
|
|
59
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/probaStat/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/probaStat/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -510,6 +510,11 @@ declare const mathExercises: (import("./exercises/exercise").MathExercise<{
|
|
|
510
510
|
AB: number;
|
|
511
511
|
AC: number;
|
|
512
512
|
trigoPoint: string;
|
|
513
|
+
}> | import("./exercises/exercise").MathExercise<{
|
|
514
|
+
xu: number;
|
|
515
|
+
yu: number;
|
|
516
|
+
xv: number;
|
|
517
|
+
yv: number;
|
|
513
518
|
}> | import("./exercises/exercise").MathExercise<{
|
|
514
519
|
coeffs: number[];
|
|
515
520
|
to: string;
|
|
@@ -652,6 +657,10 @@ declare const mathExercises: (import("./exercises/exercise").MathExercise<{
|
|
|
652
657
|
}> | import("./exercises/exercise").MathExercise<{
|
|
653
658
|
xValues: number[];
|
|
654
659
|
yValues: number[];
|
|
660
|
+
}> | import("./exercises/exercise").MathExercise<{
|
|
661
|
+
pA: number;
|
|
662
|
+
pB: number;
|
|
663
|
+
pUnion: number;
|
|
655
664
|
}> | import("./exercises/exercise").MathExercise<{
|
|
656
665
|
firstValue: number;
|
|
657
666
|
askedRank: number;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqCA,QAAA,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqCA,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAA2B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
|
|
2
|
+
import { Point } from "./point";
|
|
1
3
|
export declare class Line {
|
|
4
|
+
pointA: Point;
|
|
5
|
+
pointB: Point;
|
|
6
|
+
isVertical: boolean;
|
|
7
|
+
a: AlgebraicNode | undefined;
|
|
8
|
+
b: AlgebraicNode | undefined;
|
|
9
|
+
constructor(pointA: Point, pointB: Point);
|
|
10
|
+
includes(point: Point): boolean;
|
|
11
|
+
getRandomPoint(name?: string): Point;
|
|
2
12
|
}
|
|
3
13
|
//# sourceMappingURL=line.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/line.ts"],"names":[],"mappings":"AAAA,qBAAa,IAAI;
|
|
1
|
+
{"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAO/D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,qBAAa,IAAI;IACf,MAAM,EAAE,KAAK,CAAC;IACd,MAAM,EAAE,KAAK,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAC7B,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;gBACjB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK;IAkBxC,QAAQ,CAAC,KAAK,EAAE,KAAK;IAWrB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM;CAY7B"}
|
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Line = void 0;
|
|
4
|
+
const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
|
|
5
|
+
const addNode_1 = require("../../tree/nodes/operators/addNode");
|
|
6
|
+
const fractionNode_1 = require("../../tree/nodes/operators/fractionNode");
|
|
7
|
+
const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
|
|
8
|
+
const substractNode_1 = require("../../tree/nodes/operators/substractNode");
|
|
9
|
+
const randint_1 = require("../utils/random/randint");
|
|
10
|
+
const point_1 = require("./point");
|
|
4
11
|
class Line {
|
|
12
|
+
constructor(pointA, pointB) {
|
|
13
|
+
this.pointA = pointA;
|
|
14
|
+
this.pointB = pointB;
|
|
15
|
+
this.isVertical = pointA.x.equals(pointB.x);
|
|
16
|
+
if (this.isVertical) {
|
|
17
|
+
this.a = undefined;
|
|
18
|
+
this.b = undefined;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
this.a = new fractionNode_1.FractionNode(new substractNode_1.SubstractNode(this.pointB.y, this.pointA.y), new substractNode_1.SubstractNode(this.pointB.x, this.pointA.x)).simplify();
|
|
22
|
+
this.b = new substractNode_1.SubstractNode(this.pointA.y, new multiplyNode_1.MultiplyNode(this.a, this.pointA.x)).simplify();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
includes(point) {
|
|
26
|
+
if (this.isVertical) {
|
|
27
|
+
return point.x.equals(this.pointA.x);
|
|
28
|
+
}
|
|
29
|
+
return (new substractNode_1.SubstractNode(point.y, new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(this.a, point.x), this.b)).evaluate({}) === 0);
|
|
30
|
+
}
|
|
31
|
+
getRandomPoint(name) {
|
|
32
|
+
if (this.isVertical) {
|
|
33
|
+
return new point_1.Point(name ?? "A", this.pointA.x, new numberNode_1.NumberNode((0, randint_1.randint)(-10, 10)));
|
|
34
|
+
}
|
|
35
|
+
const x = new numberNode_1.NumberNode((0, randint_1.randint)(-10, 10));
|
|
36
|
+
const y = new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(this.a, x), this.b).simplify();
|
|
37
|
+
return new point_1.Point(name ?? "A", x, y);
|
|
38
|
+
}
|
|
5
39
|
}
|
|
6
40
|
exports.Line = Line;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { MathSet } from "../sets/mathSet";
|
|
2
1
|
import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
|
|
3
2
|
export declare abstract class PointConstructor {
|
|
4
|
-
static random(
|
|
3
|
+
static random(name: string): Point;
|
|
4
|
+
static randomDifferent(names: string[]): Point[];
|
|
5
5
|
}
|
|
6
6
|
export declare class Point {
|
|
7
7
|
name: string;
|
|
@@ -15,18 +15,7 @@ export declare class Point {
|
|
|
15
15
|
getYnumber(): number;
|
|
16
16
|
midpoint(B: Point, name?: string): Point;
|
|
17
17
|
distanceTo(B: Point): number;
|
|
18
|
+
equals(B: Point): boolean;
|
|
19
|
+
isAligned(B: Point, C: Point): boolean;
|
|
18
20
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Droite{
|
|
21
|
-
* constructor :
|
|
22
|
-
* depuis 2 points : A,B --> Droite
|
|
23
|
-
* depuis 1 point + coeff dir --> Droite
|
|
24
|
-
* avec une équation de droite --> Droite
|
|
25
|
-
*
|
|
26
|
-
* méthodes :
|
|
27
|
-
* toEquation() --> y = 3x+2
|
|
28
|
-
* toCoeffDIr --> a
|
|
29
|
-
|
|
30
|
-
* }
|
|
31
|
-
*/
|
|
32
21
|
//# sourceMappingURL=point.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/point.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/point.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAI/D,8BAAsB,gBAAgB;IACpC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK;IAKlC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE;CAevC;AAED,qBAAa,KAAK;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;gBACL,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa;IAM5D,KAAK,IAAI,MAAM;IAIf,eAAe,IAAI,MAAM;IAGzB,QAAQ,IAAI,MAAM;IAIlB,UAAU,IAAI,MAAM;IAMpB,UAAU,IAAI,MAAM;IAMpB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,SAAM,GAAG,KAAK;IAiBrC,UAAU,CAAC,CAAC,EAAE,KAAK,GAAG,MAAM;IAM5B,MAAM,CAAC,CAAC,EAAE,KAAK,GAAG,OAAO;IAGzB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK;CAK7B"}
|
|
@@ -3,15 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Point = exports.PointConstructor = void 0;
|
|
4
4
|
const node_1 = require("../../tree/nodes/node");
|
|
5
5
|
const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
|
|
6
|
-
const intervals_1 = require("../sets/intervals/intervals");
|
|
7
6
|
const rational_1 = require("../numbers/rationals/rational");
|
|
7
|
+
const vector_1 = require("./vector");
|
|
8
|
+
const randint_1 = require("../utils/random/randint");
|
|
8
9
|
class PointConstructor {
|
|
9
|
-
static random(
|
|
10
|
-
const x =
|
|
11
|
-
const y =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
static random(name) {
|
|
11
|
+
const x = (0, randint_1.randint)(-10, 11);
|
|
12
|
+
const y = (0, randint_1.randint)(-10, 11);
|
|
13
|
+
return new Point(name, new numberNode_1.NumberNode(x), new numberNode_1.NumberNode(y));
|
|
14
|
+
}
|
|
15
|
+
static randomDifferent(names) {
|
|
16
|
+
const res = [];
|
|
17
|
+
const points = [];
|
|
18
|
+
for (let i = 0; i < names.length; i++) {
|
|
19
|
+
let x;
|
|
20
|
+
let y;
|
|
21
|
+
do {
|
|
22
|
+
x = (0, randint_1.randint)(-10, 11);
|
|
23
|
+
y = (0, randint_1.randint)(-10, 11);
|
|
24
|
+
} while (points.some((point) => point[0] === x && point[1] === y));
|
|
25
|
+
res.push(new Point(names[i], new numberNode_1.NumberNode(x), new numberNode_1.NumberNode(y)));
|
|
26
|
+
}
|
|
27
|
+
return res;
|
|
15
28
|
}
|
|
16
29
|
}
|
|
17
30
|
exports.PointConstructor = PointConstructor;
|
|
@@ -56,18 +69,13 @@ class Point {
|
|
|
56
69
|
const dy = this.getYnumber() - B.getYnumber();
|
|
57
70
|
return Math.sqrt(dx ** 2 + dy ** 2);
|
|
58
71
|
}
|
|
72
|
+
equals(B) {
|
|
73
|
+
return this.x.equals(B.x) && this.y.equals(B.y);
|
|
74
|
+
}
|
|
75
|
+
isAligned(B, C) {
|
|
76
|
+
const AB = vector_1.VectorConstructor.fromPoints(this, B);
|
|
77
|
+
const AC = vector_1.VectorConstructor.fromPoints(this, C);
|
|
78
|
+
return AB.isColinear(AC);
|
|
79
|
+
}
|
|
59
80
|
}
|
|
60
81
|
exports.Point = Point;
|
|
61
|
-
/**
|
|
62
|
-
* Droite{
|
|
63
|
-
* constructor :
|
|
64
|
-
* depuis 2 points : A,B --> Droite
|
|
65
|
-
* depuis 1 point + coeff dir --> Droite
|
|
66
|
-
* avec une équation de droite --> Droite
|
|
67
|
-
*
|
|
68
|
-
* méthodes :
|
|
69
|
-
* toEquation() --> y = 3x+2
|
|
70
|
-
* toCoeffDIr --> a
|
|
71
|
-
|
|
72
|
-
* }
|
|
73
|
-
*/
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
+
import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
|
|
1
2
|
import { Node } from "../../tree/nodes/node";
|
|
2
3
|
import { Point } from "./point";
|
|
3
4
|
export declare abstract class VectorConstructor {
|
|
4
5
|
static fromPoints(origin: Point, end: Point): Vector;
|
|
5
|
-
static random(name: string): Vector;
|
|
6
|
+
static random(name: string, allowNull?: boolean): Vector;
|
|
6
7
|
}
|
|
7
8
|
export declare class Vector {
|
|
8
9
|
name: string;
|
|
9
10
|
tex: string;
|
|
10
|
-
x:
|
|
11
|
-
y:
|
|
12
|
-
constructor(name: string, x:
|
|
11
|
+
x: AlgebraicNode;
|
|
12
|
+
y: AlgebraicNode;
|
|
13
|
+
constructor(name: string, x: AlgebraicNode, y: AlgebraicNode);
|
|
13
14
|
toTex(): string;
|
|
14
15
|
toTexWithCoords(): string;
|
|
15
|
-
|
|
16
|
+
isColinear(v: Vector): boolean;
|
|
17
|
+
determinant(v: Vector): AlgebraicNode;
|
|
18
|
+
times(k: AlgebraicNode, name?: string): Vector;
|
|
16
19
|
scalarProduct(v: Vector): Node;
|
|
17
20
|
}
|
|
18
21
|
//# sourceMappingURL=vector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/vector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAY,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/vector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAY,MAAM,uBAAuB,CAAC;AAKvD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,8BAAsB,iBAAiB;IACrC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,MAAM;IAOpD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,MAAM;CAOtD;AAED,qBAAa,MAAM;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;gBACL,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa;IAO5D,KAAK,IAAI,MAAM;IAIf,eAAe,IAAI,MAAM;IAMzB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAI9B,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,aAAa;IAcrC,KAAK,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM;IAOrC,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;CAa/B"}
|
|
@@ -3,14 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Vector = exports.VectorConstructor = void 0;
|
|
4
4
|
const node_1 = require("../../tree/nodes/node");
|
|
5
5
|
const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
|
|
6
|
+
const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
|
|
6
7
|
const substractNode_1 = require("../../tree/nodes/operators/substractNode");
|
|
7
8
|
const randint_1 = require("../utils/random/randint");
|
|
8
9
|
class VectorConstructor {
|
|
9
10
|
static fromPoints(origin, end) {
|
|
10
|
-
return new Vector(`${origin.name}${end.name}`, new substractNode_1.SubstractNode(end.x, origin.x), new substractNode_1.SubstractNode(end.y, origin.y));
|
|
11
|
+
return new Vector(`${origin.name}${end.name}`, new substractNode_1.SubstractNode(end.x, origin.x).simplify(), new substractNode_1.SubstractNode(end.y, origin.y).simplify());
|
|
11
12
|
}
|
|
12
|
-
static random(name) {
|
|
13
|
-
|
|
13
|
+
static random(name, allowNull = true) {
|
|
14
|
+
const x = new numberNode_1.NumberNode((0, randint_1.randint)(-10, 11));
|
|
15
|
+
const y = new numberNode_1.NumberNode((0, randint_1.randint)(-10, 11, !allowNull && x.value === 0 ? [0] : undefined));
|
|
16
|
+
return new Vector(name, x, y);
|
|
14
17
|
}
|
|
15
18
|
}
|
|
16
19
|
exports.VectorConstructor = VectorConstructor;
|
|
@@ -27,6 +30,10 @@ class Vector {
|
|
|
27
30
|
toTexWithCoords() {
|
|
28
31
|
return `\\overrightarrow{${this.name}}\\begin{pmatrix}${this.x.toTex()} \\\\ ${this.y.toTex()} \\end{pmatrix}`;
|
|
29
32
|
}
|
|
33
|
+
isColinear(v) {
|
|
34
|
+
const det = this.determinant(v);
|
|
35
|
+
return det.evaluate({}) === 0;
|
|
36
|
+
}
|
|
30
37
|
determinant(v) {
|
|
31
38
|
if ([this.x.type, this.y.type, v.x.type, v.y.type].some((el) => el !== node_1.NodeType.number))
|
|
32
39
|
throw Error("general determinant not implemented");
|
|
@@ -36,6 +43,9 @@ class Vector {
|
|
|
36
43
|
const vyValue = v.y.value;
|
|
37
44
|
return new numberNode_1.NumberNode(xValue * vyValue - yValue * vxValue);
|
|
38
45
|
}
|
|
46
|
+
times(k, name) {
|
|
47
|
+
return new Vector(name ?? "v", new multiplyNode_1.MultiplyNode(this.x, k).simplify(), new multiplyNode_1.MultiplyNode(this.y, k).simplify());
|
|
48
|
+
}
|
|
39
49
|
scalarProduct(v) {
|
|
40
50
|
if ([this.x.type, this.y.type, v.x.type, v.y.type].some((el) => el !== node_1.NodeType.number))
|
|
41
51
|
throw Error("general determinant not implemented");
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { NumberNode } from "../../../tree/nodes/numbers/numberNode";
|
|
2
2
|
import { MultiplyNode } from "../../../tree/nodes/operators/multiplyNode";
|
|
3
|
-
import { Integer } from "../integer/integer";
|
|
4
3
|
import { Nombre, NumberType } from "../nombre";
|
|
5
4
|
import { Rational } from "../rationals/rational";
|
|
6
5
|
export declare abstract class DecimalConstructor {
|
|
@@ -26,7 +25,7 @@ export declare class Decimal implements Nombre {
|
|
|
26
25
|
multiplyByPowerOfTen(power: number): Decimal;
|
|
27
26
|
toScientificPart(): NumberNode;
|
|
28
27
|
toScientificNotation(): NumberNode | MultiplyNode;
|
|
29
|
-
toRational(): Rational | Integer;
|
|
28
|
+
toRational(): Rational | import("../integer/integer").Integer;
|
|
30
29
|
toTree(): NumberNode;
|
|
31
30
|
}
|
|
32
31
|
//# sourceMappingURL=decimal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/decimals/decimal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/decimals/decimal.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAEvE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,GAAE,MAAU,GAAG,MAAM;IAY1E,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO;IAMpE,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO;IAK/D,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO;CAMrD;AAED,qBAAa,OAAQ,YAAW,MAAM;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,aAAsB;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;gBACR,KAAK,EAAE,MAAM;IASzB;;;;OAIG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAIhC,oBAAoB,CAAC,KAAK,EAAE,MAAM;IAkClC,gBAAgB;IA2BhB,oBAAoB;IAsBpB,UAAU;IAMV,MAAM;CAGP"}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Decimal = exports.DecimalConstructor = void 0;
|
|
4
4
|
const randint_1 = require("../../../math/utils/random/randint");
|
|
5
|
+
const round_1 = require("../../../math/utils/round");
|
|
5
6
|
const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
|
|
6
7
|
const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
|
|
7
8
|
const powerNode_1 = require("../../../tree/nodes/operators/powerNode");
|
|
8
|
-
const integer_1 = require("../integer/integer");
|
|
9
9
|
const nombre_1 = require("../nombre");
|
|
10
10
|
const rational_1 = require("../rationals/rational");
|
|
11
11
|
class DecimalConstructor {
|
|
@@ -21,6 +21,7 @@ class DecimalConstructor {
|
|
|
21
21
|
}
|
|
22
22
|
return decimals;
|
|
23
23
|
}
|
|
24
|
+
//! a refacto, pour inclure "-0" et des min/max décimaux
|
|
24
25
|
static random(min, max, precision) {
|
|
25
26
|
let prec = precision ?? (0, randint_1.randint)(1, 4);
|
|
26
27
|
const int = (0, randint_1.randint)(min, max) + "";
|
|
@@ -57,84 +58,14 @@ class Decimal {
|
|
|
57
58
|
* @returns
|
|
58
59
|
*/
|
|
59
60
|
round(precision) {
|
|
60
|
-
|
|
61
|
-
if (precision < 0) {
|
|
62
|
-
if (precision < -intPartString.length)
|
|
63
|
-
throw Error("can't round to higher precision");
|
|
64
|
-
return new integer_1.Integer(this.intPart).round(-precision);
|
|
65
|
-
}
|
|
66
|
-
if (precision > this.precision)
|
|
67
|
-
throw Error("can't round to higher precision");
|
|
68
|
-
if (precision === this.precision)
|
|
69
|
-
return this;
|
|
70
|
-
let newFracPart = "", newIntPart = "";
|
|
71
|
-
const shouldRoundUp = Number(this.decimalPart[precision]) > 4;
|
|
72
|
-
if (shouldRoundUp) {
|
|
73
|
-
let retenue = true;
|
|
74
|
-
let i = precision - 1;
|
|
75
|
-
while (retenue) {
|
|
76
|
-
if (i > -1) {
|
|
77
|
-
const nb = (Number(this.decimalPart[i]) + 1) % 10;
|
|
78
|
-
if (nb || newFracPart) {
|
|
79
|
-
newFracPart = nb.toString() + newFracPart;
|
|
80
|
-
}
|
|
81
|
-
if (nb !== 0) {
|
|
82
|
-
retenue = false;
|
|
83
|
-
for (let j = i - 1; j > -1; j--) {
|
|
84
|
-
newFracPart = this.decimalPart[j] + newFracPart;
|
|
85
|
-
}
|
|
86
|
-
newIntPart = intPartString;
|
|
87
|
-
}
|
|
88
|
-
else
|
|
89
|
-
i--;
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
const nb = (Number(intPartString[i + intPartString.length]) + 1) % 10;
|
|
93
|
-
newIntPart = nb + "" + newIntPart;
|
|
94
|
-
if (nb !== 0) {
|
|
95
|
-
retenue = false;
|
|
96
|
-
for (let j = i + intPartString.length - 1; j > -1; j--) {
|
|
97
|
-
newIntPart = intPartString[j] + newIntPart;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else
|
|
101
|
-
i--;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
let retenue = true;
|
|
107
|
-
let i = precision - 1;
|
|
108
|
-
while (retenue) {
|
|
109
|
-
if (i > -1) {
|
|
110
|
-
const nb = Number(this.decimalPart[i]);
|
|
111
|
-
if (nb || newFracPart) {
|
|
112
|
-
newFracPart = nb.toString() + newFracPart;
|
|
113
|
-
}
|
|
114
|
-
if (nb !== 0) {
|
|
115
|
-
retenue = false;
|
|
116
|
-
for (let j = i - 1; j > -1; j--) {
|
|
117
|
-
newFracPart = this.decimalPart[j] + newFracPart;
|
|
118
|
-
}
|
|
119
|
-
newIntPart = intPartString;
|
|
120
|
-
}
|
|
121
|
-
else
|
|
122
|
-
i--;
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
newIntPart = intPartString;
|
|
126
|
-
retenue = false;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return DecimalConstructor.fromParts(newIntPart, newFracPart);
|
|
61
|
+
return new Decimal((0, round_1.round)(this.value, precision));
|
|
131
62
|
}
|
|
132
63
|
multiplyByPowerOfTen(power) {
|
|
133
64
|
if (power === 0)
|
|
134
65
|
return this;
|
|
135
66
|
let newIntPart = "", newFracPart = "";
|
|
136
|
-
if (power >
|
|
137
|
-
newIntPart = this.
|
|
67
|
+
if (power > 0) {
|
|
68
|
+
newIntPart = (this.value + "").split(".")[0];
|
|
138
69
|
for (let i = 0; i < power; i++) {
|
|
139
70
|
newIntPart +=
|
|
140
71
|
i > this.decimalPart.length - 1 ? "0" : this.decimalPart[i];
|
|
@@ -142,35 +73,46 @@ class Decimal {
|
|
|
142
73
|
newFracPart = this.decimalPart.slice(power);
|
|
143
74
|
}
|
|
144
75
|
else {
|
|
145
|
-
const intPartString = this.intPart
|
|
76
|
+
const intPartString = this.intPart.toString().replace("-", "");
|
|
77
|
+
const isNegative = this.value < 0;
|
|
146
78
|
newFracPart = this.decimalPart;
|
|
147
79
|
for (let i = intPartString.length - 1; i > intPartString.length - 1 + power; i--) {
|
|
148
80
|
newFracPart = (i < 0 ? "0" : intPartString[i]) + newFracPart;
|
|
149
81
|
}
|
|
150
82
|
if (power + intPartString.length < 1)
|
|
151
|
-
newIntPart = "0";
|
|
83
|
+
newIntPart = isNegative ? "-0" : "0";
|
|
152
84
|
else
|
|
153
|
-
newIntPart =
|
|
85
|
+
newIntPart =
|
|
86
|
+
(isNegative ? "-" : "") +
|
|
87
|
+
intPartString.slice(0, power + intPartString.length);
|
|
154
88
|
}
|
|
89
|
+
console.log("in", newIntPart, newFracPart);
|
|
155
90
|
return DecimalConstructor.fromParts(newIntPart, newFracPart);
|
|
156
91
|
}
|
|
157
92
|
toScientificPart() {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
93
|
+
if (!this.decimalPart.length)
|
|
94
|
+
return new numberNode_1.NumberNode(this.intPart);
|
|
95
|
+
// const intString = this.intPart.toString();
|
|
96
|
+
// const intSize = intString.length;
|
|
97
|
+
// if (intSize === 0 && this.intPart !== 0) return this.toTree();
|
|
162
98
|
if (this.intPart === 0) {
|
|
99
|
+
//true for -0
|
|
163
100
|
const firstNonZeroIndex = this.decimalPart
|
|
164
101
|
.split("")
|
|
165
102
|
.findIndex((el) => Number(el) !== 0);
|
|
166
|
-
return new numberNode_1.NumberNode(Number("0."
|
|
103
|
+
return new numberNode_1.NumberNode(Number((this.tex[0] === "-" ? "-0." : "0.") +
|
|
104
|
+
this.decimalPart.slice(firstNonZeroIndex)));
|
|
167
105
|
}
|
|
168
|
-
|
|
106
|
+
const intString = this.intPart + "";
|
|
107
|
+
return new numberNode_1.NumberNode(Number((this.tex[0] === "-" ? "-" + this.tex[1] : this.tex[0]) +
|
|
108
|
+
"." +
|
|
109
|
+
(this.tex[0] === "-" ? intString.slice(2) : intString.slice(1)) +
|
|
110
|
+
this.decimalPart));
|
|
169
111
|
}
|
|
170
112
|
toScientificNotation() {
|
|
171
|
-
const intString = this.intPart
|
|
172
|
-
const intSize = intString.length;
|
|
173
|
-
if (
|
|
113
|
+
const intString = this.intPart + "";
|
|
114
|
+
// const intSize = intString.length + (this.value < 0 ? 1 : 0);
|
|
115
|
+
if (this.intPart > -10 && this.intPart < 10 && this.intPart !== 0)
|
|
174
116
|
return this.toTree();
|
|
175
117
|
const decNode = this.toScientificPart();
|
|
176
118
|
let leadingZeros = 0;
|
|
@@ -180,7 +122,9 @@ class Decimal {
|
|
|
180
122
|
break;
|
|
181
123
|
leadingZeros++;
|
|
182
124
|
}
|
|
183
|
-
const power = this.intPart === 0 ? -leadingZeros :
|
|
125
|
+
const power = this.intPart === 0 ? -leadingZeros : (this.intPart + "").length - 1;
|
|
126
|
+
if (power === 0)
|
|
127
|
+
return this.toTree();
|
|
184
128
|
if (power === 1)
|
|
185
129
|
return new multiplyNode_1.MultiplyNode(decNode, new numberNode_1.NumberNode(10));
|
|
186
130
|
return new multiplyNode_1.MultiplyNode(decNode, new powerNode_1.PowerNode(new numberNode_1.NumberNode(10), new numberNode_1.NumberNode(power)));
|
package/lib/server.js
CHANGED
|
@@ -35,6 +35,7 @@ const express_1 = __importDefault(require("express"));
|
|
|
35
35
|
const body_parser_1 = __importDefault(require("body-parser"));
|
|
36
36
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
37
37
|
const cors_1 = __importDefault(require("cors"));
|
|
38
|
+
const decimal_1 = require("./math/numbers/decimals/decimal");
|
|
38
39
|
const jsonParser = body_parser_1.default.json();
|
|
39
40
|
const allExercises = [...exercises];
|
|
40
41
|
const runServer = () => {
|
|
@@ -51,6 +52,24 @@ const runServer = () => {
|
|
|
51
52
|
// console.log(parsed?.evaluate({ x: 1 }));
|
|
52
53
|
// console.log("time", Date.now() - before);
|
|
53
54
|
// tokenize(string);
|
|
55
|
+
// const a = DecimalConstructor.random(-4, 8);
|
|
56
|
+
// const a = new Decimal(-0.0009343);
|
|
57
|
+
// console.log(a.value, a.multiplyByPowerOfTen(-2).toTree().toTex());
|
|
58
|
+
// const b = new Decimal(0.0009343);
|
|
59
|
+
// console.log(b.value, b.multiplyByPowerOfTen(-2).toTree().toTex());
|
|
60
|
+
// const c = new Decimal(-2.00009343);
|
|
61
|
+
// console.log(c.value, c.multiplyByPowerOfTen(-2).toTree().toTex());
|
|
62
|
+
// const d = new Decimal(2.009343);
|
|
63
|
+
// console.log(d.value, d.multiplyByPowerOfTen(-2).toTree().toTex());
|
|
64
|
+
const power = 1;
|
|
65
|
+
const a = new decimal_1.Decimal(-0.00400250009343);
|
|
66
|
+
console.log(a.value, a.multiplyByPowerOfTen(power).toTree().toTex());
|
|
67
|
+
const b = new decimal_1.Decimal(0.04010009343);
|
|
68
|
+
console.log(b.value, b.multiplyByPowerOfTen(power).toTree().toTex());
|
|
69
|
+
const c = new decimal_1.Decimal(-23.00009343);
|
|
70
|
+
console.log(c.value, c.multiplyByPowerOfTen(power).toTree().toTex());
|
|
71
|
+
const d = new decimal_1.Decimal(20.4009343);
|
|
72
|
+
console.log(d.value, d.multiplyByPowerOfTen(power).toTree().toTex());
|
|
54
73
|
app.get("/", (req, res) => {
|
|
55
74
|
res.json(allExercises);
|
|
56
75
|
});
|