math-exercises 1.4.3 → 1.4.5
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/calcul/addAndSub.d.ts.map +1 -1
- package/lib/exercises/calcul/addAndSub.js +2 -1
- package/lib/exercises/calcul/addAndSubWithoutRelatives.d.ts.map +1 -1
- package/lib/exercises/calcul/addAndSubWithoutRelatives.js +2 -1
- package/lib/exercises/calcul/arithmetics/primeNumbers.d.ts.map +1 -1
- package/lib/exercises/calcul/arithmetics/primeNumbers.js +2 -1
- package/lib/exercises/calcul/fractions/fractionAndIntegerDivision.js +2 -2
- package/lib/exercises/calcul/fractions/fractionAndIntegerProduct.js +2 -2
- package/lib/exercises/calcul/fractions/fractionAndIntegerSum.js +2 -2
- package/lib/exercises/calcul/fractions/fractionToPercentToDecimal.js +1 -1
- package/lib/exercises/calcul/fractions/fractionsDivision.js +2 -2
- package/lib/exercises/calcul/fractions/fractionsProduct.d.ts.map +1 -1
- package/lib/exercises/calcul/fractions/fractionsProduct.js +2 -1
- package/lib/exercises/calcul/fractions/fractionsSum.d.ts.map +1 -1
- package/lib/exercises/calcul/fractions/fractionsSum.js +2 -1
- package/lib/exercises/calcul/fractions/simplifyFraction.d.ts.map +1 -1
- package/lib/exercises/calcul/fractions/simplifyFraction.js +2 -1
- package/lib/exercises/calcul/mentalCaluls.ts/mentalAddAndSub.d.ts.map +1 -1
- package/lib/exercises/calcul/mentalCaluls.ts/mentalAddAndSub.js +2 -1
- package/lib/exercises/calcul/mentalCaluls.ts/mentalDivisions.d.ts.map +1 -1
- package/lib/exercises/calcul/mentalCaluls.ts/mentalDivisions.js +2 -1
- package/lib/exercises/calcul/mentalCaluls.ts/mentalMultiplications.d.ts.map +1 -1
- package/lib/exercises/calcul/mentalCaluls.ts/mentalMultiplications.js +2 -1
- package/lib/exercises/calcul/operations/operationsPriorities.d.ts.map +1 -1
- package/lib/exercises/calcul/operations/operationsPriorities.js +2 -1
- package/lib/exercises/calcul/operations/operationsPrioritiesWithoutRelative.d.ts.map +1 -1
- package/lib/exercises/calcul/operations/operationsPrioritiesWithoutRelative.js +2 -1
- package/lib/exercises/calcul/rounding/rounding.js +5 -5
- package/lib/exercises/calculLitteral/distributivity/doubleDistributivity.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/distributivity/doubleDistributivity.js +2 -1
- package/lib/exercises/calculLitteral/distributivity/firstIdentity.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/distributivity/firstIdentity.js +2 -1
- package/lib/exercises/calculLitteral/distributivity/secondIdentity.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/distributivity/secondIdentity.js +2 -1
- package/lib/exercises/calculLitteral/distributivity/simpleDistributivity.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/distributivity/simpleDistributivity.js +2 -1
- package/lib/exercises/calculLitteral/distributivity/thirdIdentity.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/distributivity/thirdIdentity.js +2 -1
- package/lib/exercises/calculLitteral/equation/equationType1Exercise.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/equation/equationType1Exercise.js +3 -2
- package/lib/exercises/calculLitteral/equation/equationType2Exercise.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/equation/equationType2Exercise.js +2 -1
- package/lib/exercises/calculLitteral/equation/equationType3Exercise.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/equation/equationType3Exercise.js +2 -1
- package/lib/exercises/calculLitteral/equation/equationType4Exercise.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/equation/equationType4Exercise.js +2 -1
- package/lib/exercises/calculLitteral/equation/fractionEquation.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/equation/fractionEquation.js +2 -1
- package/lib/exercises/calculLitteral/equation/multiplicationEquation.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/equation/multiplicationEquation.js +2 -1
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq1.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq1.js +2 -1
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq2.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq2.js +2 -1
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq3.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq3.js +2 -1
- package/lib/exercises/calculLitteral/factorisation/factoType1Exercise.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/factorisation/factoType1Exercise.js +2 -1
- package/lib/exercises/calculLitteral/simplifying/reduceExpression.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/simplifying/reduceExpression.js +2 -1
- package/lib/exercises/exercise.d.ts +2 -2
- package/lib/exercises/exercise.d.ts.map +1 -1
- package/lib/exercises/exercises.d.ts +2 -1
- package/lib/exercises/exercises.d.ts.map +1 -1
- package/lib/exercises/exercises.js +16 -2
- package/lib/exercises/functions/affines/leadingCoefficient.d.ts.map +1 -1
- package/lib/exercises/functions/affines/leadingCoefficient.js +2 -1
- package/lib/exercises/geometry/euclidean/pythagore.d.ts.map +1 -1
- package/lib/exercises/geometry/euclidean/pythagore.js +2 -1
- package/lib/exercises/limits/polynomLimit.d.ts +4 -0
- package/lib/exercises/limits/polynomLimit.d.ts.map +1 -0
- package/lib/exercises/limits/polynomLimit.js +66 -0
- package/lib/exercises/limits/polynomLimitNoFI.d.ts +4 -0
- package/lib/exercises/limits/polynomLimitNoFI.d.ts.map +1 -0
- package/lib/exercises/limits/polynomLimitNoFI.js +67 -0
- package/lib/exercises/limits/rationalFracForbiddenValueLimit.d.ts +4 -0
- package/lib/exercises/limits/rationalFracForbiddenValueLimit.d.ts.map +1 -0
- package/lib/exercises/limits/rationalFracForbiddenValueLimit.js +82 -0
- package/lib/exercises/limits/rationalFracLimit.d.ts +4 -0
- package/lib/exercises/limits/rationalFracLimit.d.ts.map +1 -0
- package/lib/exercises/limits/rationalFracLimit.js +84 -0
- package/lib/exercises/limits/sequencePolynomProductLimit.js +1 -1
- package/lib/exercises/powers/calculateNegativePower.d.ts +4 -0
- package/lib/exercises/powers/calculateNegativePower.d.ts.map +1 -0
- package/lib/exercises/powers/calculateNegativePower.js +76 -0
- package/lib/exercises/powers/calculatePower.d.ts +4 -0
- package/lib/exercises/powers/calculatePower.d.ts.map +1 -0
- package/lib/exercises/powers/calculatePower.js +80 -0
- package/lib/exercises/powers/decimalToScientific.d.ts +4 -0
- package/lib/exercises/powers/decimalToScientific.d.ts.map +1 -0
- package/lib/exercises/powers/decimalToScientific.js +90 -0
- package/lib/exercises/powers/powerDefinition.d.ts +4 -0
- package/lib/exercises/powers/powerDefinition.d.ts.map +1 -0
- package/lib/exercises/powers/powerDefinition.js +69 -0
- package/lib/exercises/powers/powersDivision.d.ts.map +1 -1
- package/lib/exercises/powers/powersDivision.js +2 -1
- package/lib/exercises/powers/powersOfTenToDecimal.d.ts.map +1 -1
- package/lib/exercises/powers/powersOfTenToDecimal.js +2 -1
- package/lib/exercises/powers/powersPower.d.ts.map +1 -1
- package/lib/exercises/powers/powersPower.js +3 -2
- package/lib/exercises/powers/powersProduct.d.ts.map +1 -1
- package/lib/exercises/powers/powersProduct.js +3 -2
- package/lib/exercises/powers/scientificToDecimal.d.ts.map +1 -1
- package/lib/exercises/powers/scientificToDecimal.js +12 -12
- package/lib/exercises/sequences/arithmetic/arithmeticExplicitFormulaUsage.js +1 -1
- package/lib/exercises/sequences/arithmetic/arithmeticReasonUsage.js +1 -1
- package/lib/exercises/sequences/arithmetic/arithmeticRecurrenceFormulaUsage.js +1 -1
- package/lib/exercises/sequences/geometric/geometricExplicitFormulaUsage.js +1 -1
- package/lib/exercises/sequences/geometric/geometricReasonUsage.js +1 -1
- package/lib/exercises/sequences/geometric/geometricRecurrenceFormulaUsage.js +1 -1
- package/lib/exercises/squareRoots/simpifySquareRoot.d.ts.map +1 -1
- package/lib/exercises/squareRoots/simpifySquareRoot.js +2 -1
- package/lib/exercises/trigonometry/mainRemarkableValues.d.ts.map +1 -1
- package/lib/exercises/trigonometry/mainRemarkableValues.js +6 -4
- package/lib/exercises/trigonometry/remarkableValues.d.ts.map +1 -1
- package/lib/exercises/trigonometry/remarkableValues.js +6 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/math/numbers/decimals/decimal.d.ts +4 -1
- package/lib/math/numbers/decimals/decimal.d.ts.map +1 -1
- package/lib/math/numbers/decimals/decimal.js +45 -2
- package/lib/math/numbers/integer/integer.js +1 -1
- package/lib/math/numbers/rationals/rational.d.ts.map +1 -1
- package/lib/math/numbers/rationals/rational.js +5 -2
- package/lib/math/polynomials/polynomial.d.ts +1 -0
- package/lib/math/polynomials/polynomial.d.ts.map +1 -1
- package/lib/math/polynomials/polynomial.js +25 -0
- package/lib/utils/probaFlip.d.ts +2 -0
- package/lib/utils/probaFlip.d.ts.map +1 -0
- package/lib/utils/probaFlip.js +7 -0
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ const uuid_1 = require("uuid");
|
|
|
9
9
|
exports.mainRemarkableValuesExercise = {
|
|
10
10
|
id: 'mainRemarkableValues',
|
|
11
11
|
connector: '=',
|
|
12
|
-
instruction: '
|
|
12
|
+
instruction: '',
|
|
13
13
|
label: 'Valeurs remarquables de $\\cos$ et $\\sin$ sur $[-\\pi, \\pi]$',
|
|
14
14
|
levels: ['1reSpé', 'TermSpé', 'MathComp'],
|
|
15
15
|
isSingleStep: true,
|
|
@@ -49,10 +49,12 @@ function getMainRemarkableValues() {
|
|
|
49
49
|
});
|
|
50
50
|
return (0, exercise_1.shuffleProps)(props, n);
|
|
51
51
|
};
|
|
52
|
+
const statement = isCos
|
|
53
|
+
? `\\cos\\left(${remarkableValue.angle.toTex()}\\right)`
|
|
54
|
+
: `\\sin\\left(${remarkableValue.angle.toTex()}\\right)`;
|
|
52
55
|
const question = {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
: `\\sin\\left(${remarkableValue.angle.toTex()}\\right)`,
|
|
56
|
+
instruction: `Donner la valeur exacte de : $${statement}$`,
|
|
57
|
+
startStatement: statement,
|
|
56
58
|
answer: answer,
|
|
57
59
|
keys: ['pi', 'cos', 'sin'],
|
|
58
60
|
answerFormat: 'tex',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remarkableValues.d.ts","sourceRoot":"","sources":["../../../src/exercises/trigonometry/remarkableValues.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIlE,eAAO,MAAM,wBAAwB,EAAE,YAYtC,CAAC;AAEF,wBAAgB,mBAAmB,IAAI,QAAQ,
|
|
1
|
+
{"version":3,"file":"remarkableValues.d.ts","sourceRoot":"","sources":["../../../src/exercises/trigonometry/remarkableValues.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIlE,eAAO,MAAM,wBAAwB,EAAE,YAYtC,CAAC;AAEF,wBAAgB,mBAAmB,IAAI,QAAQ,CAoD9C"}
|
|
@@ -9,7 +9,7 @@ const uuid_1 = require("uuid");
|
|
|
9
9
|
exports.remarkableValuesExercise = {
|
|
10
10
|
id: 'remarkableValues',
|
|
11
11
|
connector: '=',
|
|
12
|
-
instruction: '
|
|
12
|
+
instruction: '',
|
|
13
13
|
label: 'Valeurs remarquables de $\\cos$ et $\\sin$',
|
|
14
14
|
levels: ['1reSpé', 'TermSpé', 'MathComp'],
|
|
15
15
|
isSingleStep: true,
|
|
@@ -55,10 +55,12 @@ function getRemarkableValues() {
|
|
|
55
55
|
}
|
|
56
56
|
return props;
|
|
57
57
|
};
|
|
58
|
+
const statement = isCos
|
|
59
|
+
? `\\cos\\left(${remarkableValue.angle.toTex()}\\right)`
|
|
60
|
+
: `\\sin\\left(${remarkableValue.angle.toTex()}\\right)`;
|
|
58
61
|
const question = {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
: `\\sin\\left(${remarkableValue.angle.toTex()}\\right)`,
|
|
62
|
+
instruction: `Donner la valeur exacte de : $${statement}$`,
|
|
63
|
+
startStatement: statement,
|
|
62
64
|
answer: answer,
|
|
63
65
|
keys: ['pi', 'cos', 'sin'],
|
|
64
66
|
answerFormat: 'tex',
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIjE,QAAA,MAAM,gBAAgB,gBAAiB,CAAC;AAExC,QAAA,MAAM,4BAA4B;aACT,WAAW;UAAQ,YAAY,EAAE;GAkBzD,CAAC;AAIF,OAAO,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAllMathExercisesBySection = exports.allMathExercises = void 0;
|
|
4
4
|
const exercises_1 = require("./exercises/exercises");
|
|
5
|
+
const decimalToScientific_1 = require("./exercises/powers/decimalToScientific");
|
|
5
6
|
const allMathExercises = [...exercises_1.exercises];
|
|
6
7
|
exports.allMathExercises = allMathExercises;
|
|
7
8
|
const getAllMathExercisesBySection = () => {
|
|
@@ -23,3 +24,4 @@ const getAllMathExercisesBySection = () => {
|
|
|
23
24
|
return data;
|
|
24
25
|
};
|
|
25
26
|
exports.getAllMathExercisesBySection = getAllMathExercisesBySection;
|
|
27
|
+
console.log(decimalToScientific_1.decimalToScientific.generator(10).forEach((q) => q.getPropositions(4)));
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Node } from '../../../tree/nodes/node';
|
|
2
2
|
import { Nombre, NumberType } from '../nombre';
|
|
3
3
|
export declare abstract class DecimalConstructor {
|
|
4
|
-
static randomFracPart(precision: number): string;
|
|
4
|
+
static randomFracPart(precision: number, leadingZeros?: number): string;
|
|
5
5
|
static random(min: number, max: number, precision?: number): Decimal;
|
|
6
6
|
static fromParts(intPart: string, decimalPart: string): Decimal;
|
|
7
|
+
static randomScientific(precision?: number): Decimal;
|
|
7
8
|
}
|
|
8
9
|
export declare class Decimal implements Nombre {
|
|
9
10
|
value: number;
|
|
@@ -20,6 +21,8 @@ export declare class Decimal implements Nombre {
|
|
|
20
21
|
*/
|
|
21
22
|
round(precision: number): Nombre;
|
|
22
23
|
multiplyByPowerOfTen(power: number): Decimal;
|
|
24
|
+
toScientificPart(): Node;
|
|
25
|
+
toScientificNotation(): Node;
|
|
23
26
|
toTree(): Node;
|
|
24
27
|
}
|
|
25
28
|
//# sourceMappingURL=decimal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/decimals/decimal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/decimals/decimal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAK7C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/C,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,GAAE,MAAU,GAAG,MAAM;IAU1E,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;IAI/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;IAoEhC,oBAAoB,CAAC,KAAK,EAAE,MAAM;IAsBlC,gBAAgB,IAAI,IAAI;IAUxB,oBAAoB,IAAI,IAAI;IAgB5B,MAAM,IAAI,IAAI;CAGf"}
|
|
@@ -3,13 +3,20 @@ 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
5
|
const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
|
|
6
|
+
const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
|
|
7
|
+
const powerNode_1 = require("../../../tree/nodes/operators/powerNode");
|
|
6
8
|
const integer_1 = require("../integer/integer");
|
|
7
9
|
const nombre_1 = require("../nombre");
|
|
8
10
|
class DecimalConstructor {
|
|
9
|
-
static randomFracPart(precision) {
|
|
11
|
+
static randomFracPart(precision, leadingZeros = 0) {
|
|
10
12
|
let decimals = '';
|
|
11
13
|
for (let i = 0; i < precision; i++) {
|
|
12
|
-
|
|
14
|
+
if (i < leadingZeros)
|
|
15
|
+
decimals += '0';
|
|
16
|
+
if (i === precision - 1 || (i === 0 && !leadingZeros))
|
|
17
|
+
decimals += (0, randint_1.randint)(1, 10);
|
|
18
|
+
else
|
|
19
|
+
decimals += (0, randint_1.randint)(0, 10);
|
|
13
20
|
}
|
|
14
21
|
return decimals;
|
|
15
22
|
}
|
|
@@ -22,6 +29,13 @@ class DecimalConstructor {
|
|
|
22
29
|
static fromParts(intPart, decimalPart) {
|
|
23
30
|
return new Decimal(Number('' + intPart + '.' + decimalPart));
|
|
24
31
|
}
|
|
32
|
+
//returns X.YYYY where X € [0, 9] and first Y is not zero if X is zero
|
|
33
|
+
static randomScientific(precision) {
|
|
34
|
+
let prec = precision ?? (0, randint_1.randint)(1, 4);
|
|
35
|
+
const int = (0, randint_1.randint)(0, 10) + '';
|
|
36
|
+
const decimals = DecimalConstructor.randomFracPart(prec, 0);
|
|
37
|
+
return DecimalConstructor.fromParts(int, decimals);
|
|
38
|
+
}
|
|
25
39
|
}
|
|
26
40
|
exports.DecimalConstructor = DecimalConstructor;
|
|
27
41
|
class Decimal {
|
|
@@ -134,6 +148,35 @@ class Decimal {
|
|
|
134
148
|
}
|
|
135
149
|
return DecimalConstructor.fromParts(newIntPart, newFracPart);
|
|
136
150
|
}
|
|
151
|
+
toScientificPart() {
|
|
152
|
+
const intString = this.intPart.toString();
|
|
153
|
+
const intSize = intString.length;
|
|
154
|
+
if (intSize === 0 && this.intPart !== 0)
|
|
155
|
+
return this.toTree();
|
|
156
|
+
if (this.intPart === 0) {
|
|
157
|
+
const firstNonZeroIndex = this.decimalPart.split('').findIndex((el) => Number(el) !== 0);
|
|
158
|
+
return new numberNode_1.NumberNode(Number('0.' + this.decimalPart.slice(firstNonZeroIndex)));
|
|
159
|
+
}
|
|
160
|
+
return new numberNode_1.NumberNode(Number(intString[0] + '.' + intString.slice(1) + this.decimalPart));
|
|
161
|
+
}
|
|
162
|
+
toScientificNotation() {
|
|
163
|
+
const intString = this.intPart.toString();
|
|
164
|
+
const intSize = intString.length;
|
|
165
|
+
if (intSize === 0)
|
|
166
|
+
return this.toTree();
|
|
167
|
+
const decNode = this.toScientificPart();
|
|
168
|
+
let leadingZeros = 0;
|
|
169
|
+
const nbs = this.decimalPart.split('').map(Number);
|
|
170
|
+
for (let i = 0; i < nbs.length; i++) {
|
|
171
|
+
if (nbs[i] !== 0)
|
|
172
|
+
break;
|
|
173
|
+
leadingZeros++;
|
|
174
|
+
}
|
|
175
|
+
const power = this.intPart === 0 ? -leadingZeros : intSize - 1;
|
|
176
|
+
if (power === 1)
|
|
177
|
+
return new multiplyNode_1.MultiplyNode(decNode, new numberNode_1.NumberNode(10));
|
|
178
|
+
return new multiplyNode_1.MultiplyNode(decNode, new powerNode_1.PowerNode(new numberNode_1.NumberNode(10), new numberNode_1.NumberNode(power)));
|
|
179
|
+
}
|
|
137
180
|
toTree() {
|
|
138
181
|
return new numberNode_1.NumberNode(this.value);
|
|
139
182
|
}
|
|
@@ -9,7 +9,7 @@ const rational_1 = require("../rationals/rational");
|
|
|
9
9
|
const primes_1 = require("./primes");
|
|
10
10
|
class IntegerConstructor {
|
|
11
11
|
static random(nbOfDigits, excludes) {
|
|
12
|
-
return (0, randint_1.randint)(
|
|
12
|
+
return (0, randint_1.randint)(10 ** (nbOfDigits - 1), 10 ** nbOfDigits, excludes);
|
|
13
13
|
}
|
|
14
14
|
static randomPrime(max = 20) {
|
|
15
15
|
return (0, random_1.random)(primes_1.primes.filter((p) => p < 20));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rational.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/rationals/rational.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rational.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/rationals/rational.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAQ7C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/C,8BAAsB,mBAAmB;IACvC;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,MAAM,GAAE,MAAW;IAW7C,MAAM,CAAC,kBAAkB,CAAC,GAAG,GAAE,MAAW;IAO1C,MAAM,CAAC,0BAA0B,CAAC,GAAG,GAAE,MAAW;CAQnD;AAED,qBAAa,QAAS,YAAW,MAAM;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,OAAO,CAAC;IACtB,IAAI,EAAE,UAAU,CAAC;gBAEL,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAUlD,KAAK;IAIL,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAgBvB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAgB5B,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAgB1B,QAAQ,IAAI,QAAQ;IAIpB,MAAM,IAAI,IAAI;IAKd,QAAQ,IAAI,MAAM;CAMnB"}
|
|
@@ -5,6 +5,7 @@ const coprimesOf_1 = require("../../../math/utils/arithmetic/coprimesOf");
|
|
|
5
5
|
const gcd_1 = require("../../../math/utils/arithmetic/gcd");
|
|
6
6
|
const lcd_1 = require("../../../math/utils/arithmetic/lcd");
|
|
7
7
|
const randint_1 = require("../../../math/utils/random/randint");
|
|
8
|
+
const oppositeNode_1 = require("../../../tree/nodes/functions/oppositeNode");
|
|
8
9
|
const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
|
|
9
10
|
const fractionNode_1 = require("../../../tree/nodes/operators/fractionNode");
|
|
10
11
|
const coinFlip_1 = require("../../../utils/coinFlip");
|
|
@@ -54,11 +55,11 @@ class Rational {
|
|
|
54
55
|
this.denum = denumerator;
|
|
55
56
|
this.value = numerator / denumerator;
|
|
56
57
|
this.isSimplified = Math.abs((0, gcd_1.gcd)(numerator, denumerator)) === 1;
|
|
57
|
-
this.tex =
|
|
58
|
+
this.tex = `${this.num < 0 ? '-' : ''}\\frac{${this.num < 0 ? -this.num : this.num}}{${this.denum}}`;
|
|
58
59
|
this.type = nombre_1.NumberType.Rational;
|
|
59
60
|
}
|
|
60
61
|
toTex() {
|
|
61
|
-
return
|
|
62
|
+
return `${this.num < 0 ? '-' : ''}\\frac{${this.num < 0 ? -this.num : this.num}}{${this.denum}}`;
|
|
62
63
|
}
|
|
63
64
|
add(nb) {
|
|
64
65
|
switch (nb.type) {
|
|
@@ -110,6 +111,8 @@ class Rational {
|
|
|
110
111
|
return new Rational(-this.num, this.denum);
|
|
111
112
|
}
|
|
112
113
|
toTree() {
|
|
114
|
+
if (this.num < 0)
|
|
115
|
+
return new oppositeNode_1.OppositeNode(new fractionNode_1.FractionNode(new numberNode_1.NumberNode(-this.num), new numberNode_1.NumberNode(this.denum)));
|
|
113
116
|
return new fractionNode_1.FractionNode(new numberNode_1.NumberNode(this.num), new numberNode_1.NumberNode(this.denum));
|
|
114
117
|
}
|
|
115
118
|
simplify() {
|
|
@@ -4,6 +4,7 @@ export declare abstract class PolynomialConstructor {
|
|
|
4
4
|
static random(maxOrder: number, variable?: string): Polynomial;
|
|
5
5
|
static randomWithLength(maxOrder: number, length: number, variable?: string): Polynomial;
|
|
6
6
|
static randomWithLengthAndSameSigns(maxOrder: number, length: number, variable?: string): Polynomial;
|
|
7
|
+
static randomNoFI(maxOrder: number, to: '+\\infty' | '-\\infty', length?: number, variable?: string): Polynomial;
|
|
7
8
|
}
|
|
8
9
|
export declare class Polynomial {
|
|
9
10
|
degree: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polynomial.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/polynomial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAW7C,8BAAsB,qBAAqB;IACzC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAa5D,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IActD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAmBhF,MAAM,CAAC,4BAA4B,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;
|
|
1
|
+
{"version":3,"file":"polynomial.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/polynomial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAW7C,8BAAsB,qBAAqB;IACzC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAa5D,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IActD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAmBhF,MAAM,CAAC,4BAA4B,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAmB5F,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,GAAG,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;CAyBzG;AAED,qBAAa,UAAU;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB;;;;OAIG;gBACS,YAAY,EAAE,MAAM,EAAE,EAAE,QAAQ,GAAE,MAAY;IAS1D,MAAM,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO;IAG9B,QAAQ,IAAI,MAAM,EAAE;IA8BpB,GAAG,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU;IAc9B,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU;IAM7B,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU;IAkBnC,QAAQ,IAAI,UAAU;IAOtB,QAAQ,IAAI,UAAU;IAQtB,SAAS,IAAI,UAAU;IAMvB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAM5B,QAAQ,CAAC,EAAE,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM;IAiB7C,MAAM,IAAI,IAAI;IAmCd,KAAK,IAAI,MAAM;IAkBf,QAAQ,IAAI,MAAM;CAGnB"}
|
|
@@ -72,6 +72,31 @@ class PolynomialConstructor {
|
|
|
72
72
|
coefficients.push(sign * (0, randint_1.randint)(0, 10, [0]));
|
|
73
73
|
return new Polynomial(coefficients, variable);
|
|
74
74
|
}
|
|
75
|
+
static randomNoFI(maxOrder, to, length, variable = 'x') {
|
|
76
|
+
if (maxOrder < 0) {
|
|
77
|
+
throw Error('Order must be a non-negative integer');
|
|
78
|
+
}
|
|
79
|
+
const order = (0, randint_1.randint)(1, maxOrder + 1);
|
|
80
|
+
const fixedLength = length ?? order;
|
|
81
|
+
if (to === '+\\infty') {
|
|
82
|
+
return PolynomialConstructor.randomWithLengthAndSameSigns(maxOrder, fixedLength, variable);
|
|
83
|
+
}
|
|
84
|
+
//en -infini les degrés de parité différentes doivent avoir un signe différent
|
|
85
|
+
const coefficients = [];
|
|
86
|
+
const otherTermDegrees = [];
|
|
87
|
+
const signEven = (0, coinFlip_1.coinFlip)() ? 1 : -1;
|
|
88
|
+
for (let i = 0; i < fixedLength - 1; i++) {
|
|
89
|
+
otherTermDegrees.push((0, randint_1.randint)(0, order));
|
|
90
|
+
}
|
|
91
|
+
for (let i = 0; i <= order - 1; i++) {
|
|
92
|
+
if (otherTermDegrees.includes(i))
|
|
93
|
+
coefficients.push((i % 2 === 0 ? signEven : -signEven) * (0, randint_1.randint)(0, 10, [0]));
|
|
94
|
+
else
|
|
95
|
+
coefficients.push(0);
|
|
96
|
+
}
|
|
97
|
+
coefficients.push((order % 2 === 0 ? signEven : -signEven) * (0, randint_1.randint)(0, 10, [0]));
|
|
98
|
+
return new Polynomial(coefficients, variable);
|
|
99
|
+
}
|
|
75
100
|
}
|
|
76
101
|
exports.PolynomialConstructor = PolynomialConstructor;
|
|
77
102
|
class Polynomial {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probaFlip.d.ts","sourceRoot":"","sources":["../../src/utils/probaFlip.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,MAAO,MAAM,YAElC,CAAC"}
|