math-exercises 1.4.14 → 1.4.16

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.
Files changed (90) hide show
  1. package/lib/exercises/calcul/arithmetics/paritySumsAndProducts.d.ts +4 -0
  2. package/lib/exercises/calcul/arithmetics/paritySumsAndProducts.d.ts.map +1 -0
  3. package/lib/exercises/calcul/arithmetics/paritySumsAndProducts.js +113 -0
  4. package/lib/exercises/calcul/arithmetics/primeNumbers.js +1 -1
  5. package/lib/exercises/calcul/fractions/fractionToPercentToDecimal.js +1 -1
  6. package/lib/exercises/calcul/mentalCaluls.ts/mentalAddAndSub.js +1 -1
  7. package/lib/exercises/calcul/mentalCaluls.ts/mentalDivisions.js +1 -1
  8. package/lib/exercises/calcul/mentalCaluls.ts/mentalMultiplications.js +1 -1
  9. package/lib/exercises/calcul/mentalCaluls.ts/mentalPercentage.js +1 -1
  10. package/lib/exercises/calculLitteral/equation/equationSimpleSquare.js +1 -1
  11. package/lib/exercises/calculLitteral/equation/firstDegreeEquation.d.ts.map +1 -1
  12. package/lib/exercises/calculLitteral/equation/firstDegreeEquation.js +2 -1
  13. package/lib/exercises/calculLitteral/equation/fractionEquation.d.ts.map +1 -1
  14. package/lib/exercises/calculLitteral/equation/fractionEquation.js +2 -3
  15. package/lib/exercises/calculLitteral/equation/logEquation.d.ts.map +1 -1
  16. package/lib/exercises/calculLitteral/equation/logEquation.js +2 -1
  17. package/lib/exercises/calculLitteral/equation/multiplicationEquation.d.ts.map +1 -1
  18. package/lib/exercises/calculLitteral/equation/multiplicationEquation.js +6 -2
  19. package/lib/exercises/combinatory/anagrams.d.ts +4 -0
  20. package/lib/exercises/combinatory/anagrams.d.ts.map +1 -0
  21. package/lib/exercises/combinatory/anagrams.js +128 -0
  22. package/lib/exercises/combinatory/ballsCounting.d.ts +4 -0
  23. package/lib/exercises/combinatory/ballsCounting.d.ts.map +1 -0
  24. package/lib/exercises/combinatory/ballsCounting.js +124 -0
  25. package/lib/exercises/combinatory/diceCounting.d.ts +4 -0
  26. package/lib/exercises/combinatory/diceCounting.d.ts.map +1 -0
  27. package/lib/exercises/combinatory/diceCounting.js +134 -0
  28. package/lib/exercises/conversion/aeraConversion.d.ts.map +1 -1
  29. package/lib/exercises/conversion/aeraConversion.js +1 -1
  30. package/lib/exercises/conversion/capacityConversion.d.ts.map +1 -1
  31. package/lib/exercises/conversion/capacityConversion.js +1 -1
  32. package/lib/exercises/conversion/lengthConversion.d.ts.map +1 -1
  33. package/lib/exercises/conversion/lengthConversion.js +1 -1
  34. package/lib/exercises/conversion/massConversion.d.ts.map +1 -1
  35. package/lib/exercises/conversion/massConversion.js +1 -1
  36. package/lib/exercises/conversion/volumeCapacityConversion.js +1 -1
  37. package/lib/exercises/conversion/volumeConversion.d.ts.map +1 -1
  38. package/lib/exercises/conversion/volumeConversion.js +1 -1
  39. package/lib/exercises/derivation/derivative/inverseFunctionDerivative.js +1 -1
  40. package/lib/exercises/derivation/derivative/rootFunctionDerivative.js +2 -2
  41. package/lib/exercises/derivation/derivative/secondDegreeDerivative.js +1 -1
  42. package/lib/exercises/derivation/derivative/thirdDegreeDerivative.js +3 -2
  43. package/lib/exercises/exercise.d.ts +1 -1
  44. package/lib/exercises/exercise.d.ts.map +1 -1
  45. package/lib/exercises/exercises.d.ts.map +1 -1
  46. package/lib/exercises/exercises.js +39 -26
  47. package/lib/exercises/functions/affines/leadingCoefficientCalculV1.d.ts.map +1 -1
  48. package/lib/exercises/functions/affines/leadingCoefficientCalculV1.js +2 -1
  49. package/lib/exercises/functions/affines/leadingCoefficientCalculV2.d.ts.map +1 -1
  50. package/lib/exercises/functions/affines/leadingCoefficientCalculV2.js +4 -2
  51. package/lib/exercises/functions/basics/inverseImageFunction.js +1 -1
  52. package/lib/exercises/functions/basics/inverseImageFunctionGeogebra.js +2 -2
  53. package/lib/exercises/functions/cube/cubicEquation.js +1 -1
  54. package/lib/exercises/geometry/cartesian/midpoint.js +1 -1
  55. package/lib/exercises/geometry/euclidean/circleArea.js +1 -1
  56. package/lib/exercises/geometry/euclidean/circleCircumference.js +1 -1
  57. package/lib/exercises/geometry/euclidean/rightTriangleArea.js +1 -1
  58. package/lib/exercises/geometry/euclidean/thales.d.ts.map +1 -1
  59. package/lib/exercises/geometry/euclidean/thales.js +1 -3
  60. package/lib/exercises/geometry/euclidean/triangleArea.js +1 -1
  61. package/lib/exercises/geometry/euclidean/trigonometrySideCalcul.js +1 -1
  62. package/lib/exercises/geometry/vectors/coordinatesReading.d.ts +4 -0
  63. package/lib/exercises/geometry/vectors/coordinatesReading.d.ts.map +1 -0
  64. package/lib/exercises/geometry/vectors/coordinatesReading.js +81 -0
  65. package/lib/exercises/percent/applyPercent.js +8 -7
  66. package/lib/exercises/percent/averageEvolutionRate.js +1 -1
  67. package/lib/exercises/percent/globalPercent.js +1 -1
  68. package/lib/exercises/percent/reciprocalPercentage.js +1 -1
  69. package/lib/exercises/powers/powersOfTenToDecimal.js +1 -1
  70. package/lib/exercises/primitve/logarithmePrimitive.js +1 -1
  71. package/lib/exercises/primitve/polynomialPrimitive.d.ts.map +1 -1
  72. package/lib/exercises/primitve/polynomialPrimitive.js +12 -4
  73. package/lib/exercises/probaStat/averageWithTable.js +1 -1
  74. package/lib/exercises/probaStat/cardBasicProbas.d.ts.map +1 -1
  75. package/lib/exercises/probaStat/cardBasicProbas.js +0 -1
  76. package/lib/exercises/probaStat/conditionalProbability.js +1 -1
  77. package/lib/exercises/probaStat/median.js +1 -1
  78. package/lib/exercises/probaStat/medianList.js +1 -1
  79. package/lib/exercises/sets/setBelonging.js +1 -1
  80. package/lib/exercises/squareRoots/squareRootEquation.js +1 -1
  81. package/lib/exercises/utils/geogebra/getAdaptedCoords.d.ts +1 -0
  82. package/lib/exercises/utils/geogebra/getAdaptedCoords.d.ts.map +1 -0
  83. package/lib/exercises/utils/geogebra/getAdaptedCoords.js +1 -0
  84. package/lib/math/complex/complex.d.ts +1 -1
  85. package/lib/math/complex/complex.d.ts.map +1 -1
  86. package/lib/math/complex/complex.js +9 -0
  87. package/lib/tree/nodes/numbers/numberNode.js +3 -3
  88. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  89. package/lib/tree/nodes/operators/fractionNode.js +7 -0
  90. package/package.json +1 -1
@@ -0,0 +1,4 @@
1
+ import { MathExercise, Question } from '../../../exercises/exercise';
2
+ export declare const coordinatesReading: MathExercise;
3
+ export declare function getCoordinatesReadingQuestion(): Question;
4
+ //# sourceMappingURL=coordinatesReading.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinatesReading.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/vectors/coordinatesReading.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,YAAY,EAAe,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAMhH,eAAO,MAAM,kBAAkB,EAAE,YAWhC,CAAC;AAEF,wBAAgB,6BAA6B,IAAI,QAAQ,CAsExD"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCoordinatesReadingQuestion = exports.coordinatesReading = void 0;
4
+ const exercise_1 = require("../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
6
+ const integer_1 = require("../../../math/numbers/integer/integer");
7
+ const uuid_1 = require("uuid");
8
+ exports.coordinatesReading = {
9
+ id: 'coordinatesReading',
10
+ connector: '=',
11
+ instruction: '',
12
+ label: "Lire les coordonnées d'un vecteur",
13
+ levels: ['2nde', '1reESM'],
14
+ isSingleStep: true,
15
+ sections: ['Vecteurs'],
16
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getCoordinatesReadingQuestion, nb),
17
+ qcmTimer: 60,
18
+ freeTimer: 60,
19
+ };
20
+ function getCoordinatesReadingQuestion() {
21
+ const [xA, yA] = integer_1.IntegerConstructor.randomDifferents(-5, 6, 2);
22
+ let xB, yB;
23
+ do {
24
+ [xB, yB] = integer_1.IntegerConstructor.randomDifferents(-5, 6, 2);
25
+ } while (xA === xB && yA === yB);
26
+ const xDelta = xB - xA;
27
+ const yDelta = yB - yA;
28
+ const answer = `\\left(${xDelta};${yDelta}\\right)`;
29
+ const commands = [`Vector((${xA},${yA}), (${xB}, ${yB}))`];
30
+ const xMin = Math.min(xA, xB);
31
+ const yMin = Math.min(yA, yB);
32
+ const xMax = Math.max(xA, xB);
33
+ const yMax = Math.max(yA, yB);
34
+ const coords = [
35
+ xMin === xMax ? xMin - 1 : xMin - 0.2 * Math.abs(xDelta),
36
+ xMin === xMax ? xMax + 1 : xMax + 0.2 * Math.abs(xDelta),
37
+ yMin === yMax ? yMin - 1 : yMin - 0.2 * Math.abs(yDelta),
38
+ yMin === yMax ? yMax + 1 : yMax + 0.2 * Math.abs(yDelta),
39
+ ];
40
+ const getPropositions = (n) => {
41
+ const res = [];
42
+ res.push({
43
+ id: (0, uuid_1.v4)(),
44
+ statement: answer,
45
+ isRightAnswer: true,
46
+ format: 'tex',
47
+ });
48
+ (0, exercise_1.tryToAddWrongProp)(res, `\\left(${xA - xB};${yA - yB}\\right)`);
49
+ (0, exercise_1.tryToAddWrongProp)(res, `\\left(${xA + xB};${yA + yB}\\right)`);
50
+ (0, exercise_1.tryToAddWrongProp)(res, `\\left(${xA - yA};${xB - yB}\\right)`);
51
+ (0, exercise_1.tryToAddWrongProp)(res, `\\left(${yA - xA};${yB - xB}\\right)`);
52
+ const missing = n - res.length;
53
+ for (let i = 0; i < missing; i++) {
54
+ let isDuplicate;
55
+ let proposition;
56
+ do {
57
+ const wrongAnswer = '';
58
+ proposition = {
59
+ id: (0, uuid_1.v4)() + ``,
60
+ statement: wrongAnswer,
61
+ isRightAnswer: false,
62
+ format: 'tex',
63
+ };
64
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
65
+ } while (isDuplicate);
66
+ res.push(proposition);
67
+ }
68
+ return (0, exercise_1.shuffleProps)(res, n);
69
+ };
70
+ const question = {
71
+ answer: answer,
72
+ instruction: `Lire les coordonnées du vecteur $\\overrightarrow u$ représentée ci-dessous :`,
73
+ keys: ['semicolon', 'u', 'overrightarrow', 'equal'],
74
+ getPropositions,
75
+ answerFormat: 'tex',
76
+ commands,
77
+ coords,
78
+ };
79
+ return question;
80
+ }
81
+ exports.getCoordinatesReadingQuestion = getCoordinatesReadingQuestion;
@@ -24,15 +24,16 @@ function getApplyPercentQuestion() {
24
24
  const randNbr = (0, randint_1.randint)(1, 500);
25
25
  const randPercent = (0, randint_1.randint)(1, 100);
26
26
  let instruction = '';
27
- let ans = 0;
27
+ let ans = '';
28
+ let ansNb = 0;
28
29
  if ((0, coinFlip_1.coinFlip)()) {
29
- ans = randNbr * (1 + randPercent / 100);
30
- ans = (0, round_1.round)(ans, 2);
30
+ ansNb = (0, round_1.round)(randNbr * (1 + randPercent / 100), 2);
31
+ ans = (ansNb + '').replace('.', ',');
31
32
  instruction = `Appliquer une hausse de $${randPercent}\\%$ à $${randNbr}$.`;
32
33
  }
33
34
  else {
34
- ans = randNbr * (1 - randPercent / 100);
35
- ans = (0, round_1.round)(ans, 2);
35
+ ansNb = (0, round_1.round)(randNbr * (1 - randPercent / 100), 2);
36
+ ans = (ansNb + '').replace('.', ',');
36
37
  instruction = `Appliquer une baisse de $${randPercent}\\%$ à $${randNbr}$.`;
37
38
  }
38
39
  const getPropositions = (n) => {
@@ -47,10 +48,10 @@ function getApplyPercentQuestion() {
47
48
  let isDuplicate;
48
49
  let proposition;
49
50
  do {
50
- let wrongAnswer = ans;
51
+ let wrongAnswer = ansNb;
51
52
  const deviation = Math.random() < 0.5 ? -1 : 1;
52
53
  const percentDeviation = Math.random() * 20 + 1;
53
- wrongAnswer += deviation * (percentDeviation / 100) * ans;
54
+ wrongAnswer += deviation * (percentDeviation / 100) * ansNb;
54
55
  wrongAnswer = (0, round_1.round)(wrongAnswer, 2);
55
56
  proposition = {
56
57
  id: (0, uuid_1.v4)() + '',
@@ -55,7 +55,7 @@ function getAverageEvolutionRate() {
55
55
  };
56
56
  const question = {
57
57
  instruction,
58
- answer: answer + `\\%`,
58
+ answer: (answer + '').replace('.', ',') + `\\%`,
59
59
  keys: ['percent'],
60
60
  getPropositions,
61
61
  answerFormat: 'tex',
@@ -37,7 +37,7 @@ function getGlobalPercentQuestion() {
37
37
  }
38
38
  ans = (0, mathjs_1.round)((ans - 1) * 100, 2);
39
39
  instruction += ". \nDéterminer le taux d'évolution global du prix de cet article.";
40
- const answer = `${ans}\\%`;
40
+ const answer = `${(ans + '').replace('.', ',')}\\%`;
41
41
  const getPropositions = (n) => {
42
42
  const res = [];
43
43
  res.push({
@@ -57,7 +57,7 @@ function getReciprocalPercentageQuestion() {
57
57
  };
58
58
  const question = {
59
59
  instruction,
60
- answer: `${ans > 0 ? '+' + (0, mathjs_1.round)(ans, 2) : (0, mathjs_1.round)(ans, 2)}\\%`,
60
+ answer: `${(ans > 0 ? '+' + (0, mathjs_1.round)(ans, 2) : '' + (0, mathjs_1.round)(ans, 2)).replace('.', ',')}\\%`,
61
61
  keys: ['percent'],
62
62
  getPropositions,
63
63
  answerFormat: 'tex',
@@ -72,7 +72,7 @@ function getPowersOfTenToDecimalQuestion() {
72
72
  const question = {
73
73
  instruction: `Donner l'écriture décimale de : $${statement.toTex()}$`,
74
74
  startStatement: statement.toTex(),
75
- answer: answerTree.toTex(),
75
+ answer: answerTree.toTex().replace('.', ','),
76
76
  keys: [],
77
77
  getPropositions,
78
78
  answerFormat: 'tex',
@@ -26,7 +26,7 @@ exports.logarithmePrimitive = {
26
26
  function getLogarithmePrimitive() {
27
27
  const u = polynomial_1.PolynomialConstructor.randomWithOrder((0, randint_1.randint)(1, 3));
28
28
  const selectedFunction = new fractionNode_1.FractionNode(u.derivate().toTree(), u.toTree());
29
- const integratedFuction = `ln\|${u.toTex()}\|`;
29
+ const integratedFuction = `\\ln\\left|${u.toTex()}\\right|`;
30
30
  const getPropositions = (n) => {
31
31
  const propositions = [];
32
32
  propositions.push({
@@ -1 +1 @@
1
- {"version":3,"file":"polynomialPrimitive.d.ts","sourceRoot":"","sources":["../../../src/exercises/primitve/polynomialPrimitive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAgB/E,eAAO,MAAM,mBAAmB,EAAE,YAYjC,CAAC;AAkBF,wBAAgB,sBAAsB,IAAI,QAAQ,CAiDjD"}
1
+ {"version":3,"file":"polynomialPrimitive.d.ts","sourceRoot":"","sources":["../../../src/exercises/primitve/polynomialPrimitive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAkB/E,eAAO,MAAM,mBAAmB,EAAE,YAYjC,CAAC;AA0BF,wBAAgB,sBAAsB,IAAI,QAAQ,CAiDjD"}
@@ -2,16 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPolynomialPrimitive = exports.polynomialPrimitive = void 0;
4
4
  const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
5
+ const rational_1 = require("../../math/numbers/rationals/rational");
5
6
  const polynomial_1 = require("../../math/polynomials/polynomial");
6
7
  const randint_1 = require("../../math/utils/random/randint");
8
+ const oppositeNode_1 = require("../../tree/nodes/functions/oppositeNode");
7
9
  const constantNode_1 = require("../../tree/nodes/numbers/constantNode");
8
10
  const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
9
11
  const addNode_1 = require("../../tree/nodes/operators/addNode");
10
- const fractionNode_1 = require("../../tree/nodes/operators/fractionNode");
11
12
  const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
12
13
  const powerNode_1 = require("../../tree/nodes/operators/powerNode");
13
14
  const variableNode_1 = require("../../tree/nodes/variables/variableNode");
14
- const simplify_1 = require("../../tree/parsers/simplify");
15
15
  const shuffle_1 = require("../../utils/shuffle");
16
16
  const uuid_1 = require("uuid");
17
17
  exports.polynomialPrimitive = {
@@ -33,8 +33,16 @@ function getIntegratedPolynomialNode(polynomial) {
33
33
  const coeff = polynomial.coefficients[i];
34
34
  if (coeff === 0)
35
35
  continue;
36
- const nodeCoeff = new fractionNode_1.FractionNode(new numberNode_1.NumberNode(coeff), new numberNode_1.NumberNode(i + 1));
37
- const terme = new multiplyNode_1.MultiplyNode((0, simplify_1.simplifyNode)(nodeCoeff), i + 1 === 1 ? new variableNode_1.VariableNode('x') : new powerNode_1.PowerNode(new variableNode_1.VariableNode('x'), new numberNode_1.NumberNode(i + 1)));
36
+ const nodeCoeff = new rational_1.Rational(coeff, i + 1).simplify().toTree();
37
+ const powerNode = i + 1 === 1 ? new variableNode_1.VariableNode('x') : new powerNode_1.PowerNode(new variableNode_1.VariableNode('x'), new numberNode_1.NumberNode(i + 1));
38
+ let terme;
39
+ if (nodeCoeff.toTex() === '1')
40
+ terme = powerNode;
41
+ else if (nodeCoeff.toTex() === '-1')
42
+ terme = new oppositeNode_1.OppositeNode(powerNode);
43
+ else {
44
+ terme = new multiplyNode_1.MultiplyNode(nodeCoeff, i + 1 === 1 ? new variableNode_1.VariableNode('x') : new powerNode_1.PowerNode(new variableNode_1.VariableNode('x'), new numberNode_1.NumberNode(i + 1)));
45
+ }
38
46
  integralPolynomial = new addNode_1.AddNode(terme, integralPolynomial);
39
47
  }
40
48
  return integralPolynomial;
@@ -68,7 +68,7 @@ function getAverageWithTableQuestion() {
68
68
  |Effectif|${randomEffectives[0]}|${randomEffectives[1]}|${randomEffectives[2]}|${randomEffectives[3]}|${randomEffectives[4]}|
69
69
 
70
70
  Calculer la moyenne de cette série de valeurs.`,
71
- answer: average + '',
71
+ answer: (average + '').replace('.', ','),
72
72
  keys: [],
73
73
  getPropositions,
74
74
  answerFormat: 'tex',
@@ -1 +1 @@
1
- {"version":3,"file":"cardBasicProbas.d.ts","sourceRoot":"","sources":["../../../src/exercises/probaStat/cardBasicProbas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,YAAY,EAAe,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAYhH,eAAO,MAAM,eAAe,EAAE,YAW7B,CAAC;AAEF,wBAAgB,0BAA0B,IAAI,QAAQ,CA2FrD"}
1
+ {"version":3,"file":"cardBasicProbas.d.ts","sourceRoot":"","sources":["../../../src/exercises/probaStat/cardBasicProbas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,YAAY,EAAe,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAYhH,eAAO,MAAM,eAAe,EAAE,YAW7B,CAAC;AAEF,wBAAgB,0BAA0B,IAAI,QAAQ,CA0FrD"}
@@ -39,7 +39,6 @@ function getCardBasicProbasQuestion() {
39
39
  case 'oneCard':
40
40
  value = (0, randomEnumValue_1.randomEnumValue)(cardsData_1.CardsValues);
41
41
  color = (0, randomEnumValue_1.randomEnumValue)(cardsData_1.CardsColor);
42
- console.log(value);
43
42
  target = `${value === 'dame' ? 'une' : 'un'} ${value} de ${color}`;
44
43
  answer = `\\frac{1}{52}`;
45
44
  break;
@@ -94,7 +94,7 @@ function getConditionalProbability() {
94
94
  const question = {
95
95
  instruction,
96
96
  startStatement,
97
- answer,
97
+ answer: answer.replace('.', ','),
98
98
  keys: ['p', 'cap', 'underscore'],
99
99
  getPropositions,
100
100
  answerFormat: 'tex',
@@ -74,7 +74,7 @@ function getMedianWithTable() {
74
74
  |Effectif|${randomEffectives[0]}|${randomEffectives[1]}|${randomEffectives[2]}|${randomEffectives[3]}|${randomEffectives[4]}|
75
75
 
76
76
  Calculer la médiane de cette série de valeurs.`,
77
- answer: median + '',
77
+ answer: (median + '').replace('.', ','),
78
78
  keys: [],
79
79
  getPropositions,
80
80
  answerFormat: 'tex',
@@ -61,7 +61,7 @@ function getMedianList() {
61
61
  const question = {
62
62
  instruction: `On considère la liste suivante : $${randomValeurs.join(';\\ ')}.$
63
63
  $\\\\$Calculer la médiane de cette liste de valeurs.`,
64
- answer: median + '',
64
+ answer: (median + '').replace('.', ','),
65
65
  keys: ['f', 'cap', 'underscore'],
66
66
  getPropositions,
67
67
  answerFormat: 'tex',
@@ -39,7 +39,7 @@ function getSetBelongingQuestion() {
39
39
  break;
40
40
  case 2:
41
41
  nb = decimal_1.DecimalConstructor.random(-50, 50, (0, randint_1.randint)(1, 4)).toTree().toTex();
42
- answer = '\\mathbb{D}';
42
+ answer = '\\mathrm{D}';
43
43
  break;
44
44
  case 3:
45
45
  nb = rational_1.RationalConstructor.randomIrreductible().toTree().toTex();
@@ -19,7 +19,7 @@ exports.squareRootEquation = {
19
19
  };
20
20
  function getSquareRootEquationQuestion() {
21
21
  const k = Math.random() < 0.2 ? (0, randint_1.randint)(-20, 0) : (0, randint_1.randint)(0, 11);
22
- const answer = k < 0 ? 'S=\\emptyset' : `S=\\{${k ** 2}\\}`;
22
+ const answer = k < 0 ? 'S=\\emptyset' : `S=\\left\\{${k ** 2}\\right\\}`;
23
23
  const getPropositions = (n) => {
24
24
  const res = [];
25
25
  res.push({
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=getAdaptedCoords.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAdaptedCoords.d.ts","sourceRoot":"","sources":["../../../../src/exercises/utils/geogebra/getAdaptedCoords.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ "use strict";
@@ -10,7 +10,7 @@ export declare class Complex {
10
10
  constructor(re: number, im: number);
11
11
  moduleSquared(): number;
12
12
  inverseNode(): AddNode;
13
- divideNode(z: Complex): AddNode;
13
+ divideNode(z: Complex): import("../../tree/nodes/node").Node;
14
14
  multiply(z: Complex): Complex;
15
15
  opposite(): Complex;
16
16
  conjugate(): Complex;
@@ -1 +1 @@
1
- {"version":3,"file":"complex.d.ts","sourceRoot":"","sources":["../../../src/math/complex/complex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAO7D,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,MAAM;IAQb,MAAM,CAAC,aAAa;CAQrB;AACD,qBAAa,OAAO;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;gBACC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAIlC,aAAa;IAIb,WAAW;IAQX,UAAU,CAAC,CAAC,EAAE,OAAO;IAOrB,QAAQ,CAAC,CAAC,EAAE,OAAO;IAGnB,QAAQ;IAGR,SAAS;IAGT,MAAM;CAGP"}
1
+ {"version":3,"file":"complex.d.ts","sourceRoot":"","sources":["../../../src/math/complex/complex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAO7D,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,MAAM;IAQb,MAAM,CAAC,aAAa;CAQrB;AACD,qBAAa,OAAO;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;gBACC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAIlC,aAAa;IAIb,WAAW;IAQX,UAAU,CAAC,CAAC,EAAE,OAAO;IAYrB,QAAQ,CAAC,CAAC,EAAE,OAAO;IAGnB,QAAQ;IAGR,SAAS;IAGT,MAAM;CAGP"}
@@ -45,6 +45,15 @@ class Complex {
45
45
  const moduleSq = z.moduleSquared();
46
46
  const newRe = new rational_1.Rational(this.re * z.re + this.im * z.im, moduleSq).simplify().toTree();
47
47
  const newIm = new rational_1.Rational(this.im * z.re - z.im * this.re, moduleSq).simplify().toTree();
48
+ let imNode;
49
+ if (newIm.toTex() === '0')
50
+ return newRe;
51
+ if (newIm.toTex() === '1')
52
+ imNode = new variableNode_1.VariableNode('i');
53
+ else
54
+ imNode = new multiplyNode_1.MultiplyNode(newIm, new variableNode_1.VariableNode('i'));
55
+ if (newRe.toTex() === '0')
56
+ return imNode;
48
57
  return new addNode_1.AddNode(newRe, new multiplyNode_1.MultiplyNode(newIm, new variableNode_1.VariableNode('i')));
49
58
  }
50
59
  multiply(z) {
@@ -6,11 +6,11 @@ class NumberNode {
6
6
  constructor(value, tex, mathString) {
7
7
  this.type = node_1.NodeType.number;
8
8
  this.value = value;
9
- this.tex = tex || value + '';
10
- this.mathString = mathString || this.tex;
9
+ this.tex = tex || (value + '').replace('.', ',');
10
+ this.mathString = mathString || this.value + '';
11
11
  }
12
12
  toMathString() {
13
- return `${this.mathString ? this.mathString : this.tex}`;
13
+ return `${this.mathString}`;
14
14
  }
15
15
  toTex() {
16
16
  return `${this.tex}`;
@@ -1 +1 @@
1
- {"version":3,"file":"fractionNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/fractionNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAY,MAAM,SAAS,CAAC;AACzC,OAAO,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE3D,qBAAa,YAAa,SAAQ,YAAa,YAAW,IAAI;IAC5D;;;OAGG;gBACS,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI;IAI7C,YAAY,IAAI,MAAM;IAGtB,KAAK,IAAI,MAAM;IAIf,QAAQ;CAGT"}
1
+ {"version":3,"file":"fractionNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/fractionNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAY,MAAM,SAAS,CAAC;AACzC,OAAO,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI3D,qBAAa,YAAa,SAAQ,YAAa,YAAW,IAAI;IAC5D;;;OAGG;gBACS,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI;IAI7C,YAAY,IAAI,MAAM;IAGtB,KAAK,IAAI,MAAM;IAYf,QAAQ;CAGT"}
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FractionNode = void 0;
4
4
  const mathjs_1 = require("mathjs");
5
+ const node_1 = require("../node");
5
6
  const operatorNode_1 = require("./operatorNode");
7
+ const functionNode_1 = require("../functions/functionNode");
6
8
  class FractionNode extends operatorNode_1.OperatorNode {
7
9
  /**
8
10
  * @param leftChild num
@@ -15,6 +17,11 @@ class FractionNode extends operatorNode_1.OperatorNode {
15
17
  return `(${this.leftChild.toMathString()}) / (${this.rightChild.toMathString()})`;
16
18
  }
17
19
  toTex() {
20
+ if ((this.leftChild.type === node_1.NodeType.function &&
21
+ this.leftChild.id === functionNode_1.FunctionsIds.opposite) ||
22
+ (this.leftChild.type === node_1.NodeType.number && this.leftChild.value < 0)) {
23
+ return `-\\frac{${this.leftChild.toTex().slice(1)}}{${this.rightChild.toTex()}}`;
24
+ }
18
25
  return `\\frac{${this.leftChild.toTex()}}{${this.rightChild.toTex()}}`;
19
26
  }
20
27
  toMathjs() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-exercises",
3
- "version": "1.4.14",
3
+ "version": "1.4.16",
4
4
  "description": "Math exercises generator for middle school and high school",
5
5
  "main": "lib/index.js",
6
6
  "files": [