math-exercises 1.3.57 → 1.3.59
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 +4 -0
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType0.d.ts.map +1 -0
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType0.js +69 -0
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType1.d.ts +4 -0
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType1.d.ts.map +1 -0
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType1.js +70 -0
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType2.d.ts +4 -0
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType2.d.ts.map +1 -0
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType2.js +70 -0
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType3.d.ts +4 -0
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType3.d.ts.map +1 -0
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType3.js +71 -0
- package/lib/exercises/exercise.d.ts +2 -1
- package/lib/exercises/exercise.d.ts.map +1 -1
- package/lib/exercises/exercises.d.ts.map +1 -1
- package/lib/exercises/exercises.js +71 -32
- package/lib/exercises/functions/cube/cubicEquation.d.ts +4 -0
- package/lib/exercises/functions/cube/cubicEquation.d.ts.map +1 -0
- package/lib/exercises/functions/cube/cubicEquation.js +65 -0
- package/lib/exercises/functions/trinoms/deltaTrinom.d.ts +4 -0
- package/lib/exercises/functions/trinoms/deltaTrinom.d.ts.map +1 -0
- package/lib/exercises/functions/trinoms/deltaTrinom.js +73 -0
- package/lib/exercises/functions/trinoms/extremumTypeFromAlgebricForm.d.ts.map +1 -1
- package/lib/exercises/functions/trinoms/extremumTypeFromAlgebricForm.js +1 -0
- package/lib/exercises/functions/trinoms/rootsFromDevForm.d.ts +4 -0
- package/lib/exercises/functions/trinoms/rootsFromDevForm.d.ts.map +1 -0
- package/lib/exercises/functions/trinoms/rootsFromDevForm.js +56 -0
- package/lib/exercises/functions/trinoms/rootsFromFactorizedForm.d.ts +4 -0
- package/lib/exercises/functions/trinoms/rootsFromFactorizedForm.d.ts.map +1 -0
- package/lib/exercises/functions/trinoms/rootsFromFactorizedForm.js +92 -0
- package/lib/exercises/geometry/vectors/chasles.d.ts +4 -0
- package/lib/exercises/geometry/vectors/chasles.d.ts.map +1 -0
- package/lib/exercises/geometry/vectors/chasles.js +72 -0
- package/lib/exercises/geometry/vectors/determinant.d.ts +4 -0
- package/lib/exercises/geometry/vectors/determinant.d.ts.map +1 -0
- package/lib/exercises/geometry/vectors/determinant.js +67 -0
- package/lib/exercises/sets/intervalsUnion.d.ts +4 -0
- package/lib/exercises/sets/intervalsUnion.d.ts.map +1 -0
- package/lib/exercises/sets/intervalsUnion.js +53 -0
- package/lib/exercises/squareRoots/squareRootEquation.d.ts +4 -0
- package/lib/exercises/squareRoots/squareRootEquation.d.ts.map +1 -0
- package/lib/exercises/squareRoots/squareRootEquation.js +70 -0
- package/lib/math/geometry/vector.d.ts +2 -0
- package/lib/math/geometry/vector.d.ts.map +1 -1
- package/lib/math/geometry/vector.js +8 -0
- package/lib/math/polynomials/trinom.d.ts +5 -0
- package/lib/math/polynomials/trinom.d.ts.map +1 -1
- package/lib/math/polynomials/trinom.js +45 -0
- package/lib/math/sets/intervals/intervals.d.ts.map +1 -1
- package/lib/tree/nodes/functions/oppositeNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/oppositeNode.js +3 -0
- package/lib/tree/nodes/functions/sqrtNode.js +1 -1
- package/lib/tree/parsers/simplify.js +3 -0
- package/package.json +1 -1
|
@@ -11,6 +11,8 @@ const variableNode_1 = require("../../tree/nodes/variables/variableNode");
|
|
|
11
11
|
const simplify_1 = require("../../tree/parsers/simplify");
|
|
12
12
|
const point_1 = require("../geometry/point");
|
|
13
13
|
const integer_1 = require("../numbers/integer/integer");
|
|
14
|
+
const rational_1 = require("../numbers/rationals/rational");
|
|
15
|
+
const squareRoot_1 = require("../numbers/reals/squareRoot");
|
|
14
16
|
const discreteSet_1 = require("../sets/discreteSet");
|
|
15
17
|
const intervals_1 = require("../sets/intervals/intervals");
|
|
16
18
|
const polynomial_1 = require("./polynomial");
|
|
@@ -29,6 +31,13 @@ class TrinomConstructor {
|
|
|
29
31
|
const c = a.value * alpha.value ** 2 + beta.value;
|
|
30
32
|
return new Trinom(a.value, b, c);
|
|
31
33
|
}
|
|
34
|
+
static randomFactorized(domainA = new intervals_1.Interval('[[-10; 10]]').difference(new discreteSet_1.DiscreteSet([new integer_1.Integer(0)])), domainX1 = new intervals_1.Interval('[[-10; 10]]'), domainX2 = new intervals_1.Interval('[[-10; 10]]')) {
|
|
35
|
+
const a = domainA.getRandomElement();
|
|
36
|
+
const x1 = domainX1.getRandomElement();
|
|
37
|
+
const x2 = domainX2.getRandomElement();
|
|
38
|
+
//a*x^2 + ax*-x2 + a*-x1*x + a*-x1*-x2
|
|
39
|
+
return new Trinom(a.value, -a.value * (x1.value + x2.value), a.value * x1.value * x2.value);
|
|
40
|
+
}
|
|
32
41
|
}
|
|
33
42
|
exports.TrinomConstructor = TrinomConstructor;
|
|
34
43
|
class Trinom extends polynomial_1.Polynomial {
|
|
@@ -45,6 +54,34 @@ class Trinom extends polynomial_1.Polynomial {
|
|
|
45
54
|
getDeltaNode() {
|
|
46
55
|
return new numberNode_1.NumberNode(this.getDelta());
|
|
47
56
|
}
|
|
57
|
+
getRoots() {
|
|
58
|
+
const delta = this.getDelta();
|
|
59
|
+
if (delta < 0)
|
|
60
|
+
return [];
|
|
61
|
+
if (delta === 0)
|
|
62
|
+
return [-this.b / (2 * this.a)];
|
|
63
|
+
return [(-this.b - Math.sqrt(delta)) / (2 * this.a), (-this.b + Math.sqrt(delta)) / (2 * this.a)];
|
|
64
|
+
}
|
|
65
|
+
//! la simplification de mathjs est foireuse, exemple (4+4sqrt(3))/16 est simplifiée mais pas (4-4sqrt(3))/16 ??
|
|
66
|
+
getRootsNode() {
|
|
67
|
+
const delta = this.getDelta();
|
|
68
|
+
if (delta < 0)
|
|
69
|
+
return [];
|
|
70
|
+
if (delta === 0)
|
|
71
|
+
return [new rational_1.Rational(-this.b, 2 * this.a).simplify().toTree()];
|
|
72
|
+
return [
|
|
73
|
+
(0, simplify_1.simplifyNode)(new fractionNode_1.FractionNode(new substractNode_1.SubstractNode(new numberNode_1.NumberNode(-this.b), new squareRoot_1.SquareRoot(delta).simplify().toTree()), new numberNode_1.NumberNode(2 * this.a))),
|
|
74
|
+
(0, simplify_1.simplifyNode)(new fractionNode_1.FractionNode(new addNode_1.AddNode(new numberNode_1.NumberNode(-this.b), new squareRoot_1.SquareRoot(delta).simplify().toTree()), new numberNode_1.NumberNode(2 * this.a))),
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
getRootsEquationSolutionTex() {
|
|
78
|
+
const roots = this.getRootsNode();
|
|
79
|
+
if (!roots.length)
|
|
80
|
+
return `S = \\emptyset`;
|
|
81
|
+
if (roots.length === 1)
|
|
82
|
+
return `S = \\left\\lbrace ${roots[0].toTex()} \\right\\rbrace`;
|
|
83
|
+
return `S = \\left\\lbrace ${roots[0].toTex()} ; ${roots[1].toTex()} \\right\\rbrace`;
|
|
84
|
+
}
|
|
48
85
|
getAlpha() {
|
|
49
86
|
return -this.b / (2 * this.a);
|
|
50
87
|
}
|
|
@@ -57,6 +94,14 @@ class Trinom extends polynomial_1.Polynomial {
|
|
|
57
94
|
getBetaNode() {
|
|
58
95
|
return (0, simplify_1.simplifyNode)(new fractionNode_1.FractionNode(new numberNode_1.NumberNode(-this.getDelta()), new numberNode_1.NumberNode(4 * this.a)));
|
|
59
96
|
}
|
|
97
|
+
getFactorizedForm() {
|
|
98
|
+
const roots = this.getRootsNode();
|
|
99
|
+
if (!roots.length)
|
|
100
|
+
return this.toTree();
|
|
101
|
+
if (roots.length === 1)
|
|
102
|
+
return (0, simplify_1.simplifyNode)(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(this.a), new powerNode_1.PowerNode(new substractNode_1.SubstractNode(new variableNode_1.VariableNode('x'), roots[0]), new numberNode_1.NumberNode(2))));
|
|
103
|
+
return (0, simplify_1.simplifyNode)(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(this.a), new multiplyNode_1.MultiplyNode(new substractNode_1.SubstractNode(new variableNode_1.VariableNode('x'), roots[0]), new substractNode_1.SubstractNode(new variableNode_1.VariableNode('x'), roots[1]))));
|
|
104
|
+
}
|
|
60
105
|
getCanonicalForm() {
|
|
61
106
|
return (0, simplify_1.simplifyNode)(new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(this.a), new powerNode_1.PowerNode(new substractNode_1.SubstractNode(new variableNode_1.VariableNode(this.variable), this.getAlphaNode()), new numberNode_1.NumberNode(2))), new numberNode_1.NumberNode(this.getBeta())));
|
|
62
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intervals.d.ts","sourceRoot":"","sources":["../../../../src/math/sets/intervals/intervals.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"intervals.d.ts","sourceRoot":"","sources":["../../../../src/math/sets/intervals/intervals.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAI/D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,aAAK,SAAS;IACZ,EAAE,UAAU;IACZ,EAAE,UAAU;IACZ,EAAE,UAAU;IACZ,EAAE,UAAU;CACb;AAED,qBAAa,QAAS,YAAW,gBAAgB;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,SAAS,CAAC;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;gBACS,GAAG,SAAc;IA+C7B,OAAO,CAAC,EAAE,EAAE,MAAM;IAWlB,UAAU,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO;IAYrC,KAAK,IAAI,MAAM;IAIf,gBAAgB,CAAC,SAAS,GAAE,MAAiD,GAAG,MAAM;CAYvF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oppositeNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/oppositeNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAY,MAAM,SAAS,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAgB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"oppositeNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/oppositeNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAY,MAAM,SAAS,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAG5D,qBAAa,YAAa,SAAQ,YAAa,YAAW,IAAI;gBAChD,KAAK,EAAE,IAAI;IAGvB,YAAY,IAAI,MAAM;IAGtB,KAAK,IAAI,MAAM;IAcf,QAAQ;CAGT"}
|
|
@@ -19,6 +19,9 @@ class OppositeNode extends functionNode_1.FunctionNode {
|
|
|
19
19
|
const operatorChild = this.child;
|
|
20
20
|
needBrackets || (needBrackets = [operatorNode_1.OperatorIds.add, operatorNode_1.OperatorIds.substract].includes(operatorChild.id));
|
|
21
21
|
}
|
|
22
|
+
if (this.child.type === node_1.NodeType.number && childTex[0] === '-') {
|
|
23
|
+
return childTex.substring(1);
|
|
24
|
+
}
|
|
22
25
|
if (needBrackets)
|
|
23
26
|
childTex = `(${childTex})`;
|
|
24
27
|
return `-${childTex}`;
|
|
@@ -10,7 +10,7 @@ class SqrtNode extends functionNode_1.FunctionNode {
|
|
|
10
10
|
this.type = node_1.NodeType.function;
|
|
11
11
|
}
|
|
12
12
|
toMathString() {
|
|
13
|
-
return `
|
|
13
|
+
return `sqr(${this.child.toMathString()})`;
|
|
14
14
|
}
|
|
15
15
|
toMathjs() {
|
|
16
16
|
return (0, mathjs_1.sqrt)(this.child.toMathjs());
|
|
@@ -56,6 +56,9 @@ const mathjsNodeToNode = (mathjsNode) => {
|
|
|
56
56
|
else if (mathjsNode.isFunctionNode) {
|
|
57
57
|
const fn = mathjsNode.fn;
|
|
58
58
|
switch (fn.name) {
|
|
59
|
+
//mathjs arrondit les racines carrées, on truc avec sqr pour bypass
|
|
60
|
+
case 'sqr':
|
|
61
|
+
return new sqrtNode_1.SqrtNode(mathjsNodeToNode(mathjsNode.args[0]));
|
|
59
62
|
case 'sqrt':
|
|
60
63
|
return new sqrtNode_1.SqrtNode(mathjsNodeToNode(mathjsNode.args[0]));
|
|
61
64
|
case 'log':
|