math-exercises 3.0.188 → 3.0.190

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 (144) hide show
  1. package/lib/exercises/math/calcul/decimals/decimalFractionToDecimal.d.ts.map +1 -1
  2. package/lib/exercises/math/calcul/decimals/decimalFractionToDecimal.js +5 -4
  3. package/lib/exercises/math/calculLitteral/equation/factorizeEquation.d.ts.map +1 -1
  4. package/lib/exercises/math/calculLitteral/equation/factorizeEquation.js +9 -8
  5. package/lib/exercises/math/calculLitteral/equation/isEqualityTrue.d.ts.map +1 -1
  6. package/lib/exercises/math/calculLitteral/equation/isEqualityTrue.js +7 -6
  7. package/lib/exercises/math/dataRepresentations/barChartInterpreting.d.ts.map +1 -1
  8. package/lib/exercises/math/dataRepresentations/barChartInterpreting.js +5 -4
  9. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving1.d.ts.map +1 -1
  10. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving1.js +3 -2
  11. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving3.d.ts.map +1 -1
  12. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving3.js +3 -2
  13. package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.d.ts.map +1 -1
  14. package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.js +45 -37
  15. package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.d.ts.map +1 -1
  16. package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.js +3 -2
  17. package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.d.ts.map +1 -1
  18. package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.js +3 -2
  19. package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.d.ts.map +1 -1
  20. package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.js +3 -2
  21. package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.d.ts.map +1 -1
  22. package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.js +4 -3
  23. package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.d.ts.map +1 -1
  24. package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.js +20 -64
  25. package/lib/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.d.ts.map +1 -1
  26. package/lib/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.js +3 -2
  27. package/lib/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.d.ts.map +1 -1
  28. package/lib/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.js +3 -2
  29. package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.d.ts.map +1 -1
  30. package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.js +4 -3
  31. package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.d.ts.map +1 -1
  32. package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.js +27 -35
  33. package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.d.ts +8 -0
  34. package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.d.ts.map +1 -0
  35. package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.js +129 -0
  36. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentComplete.d.ts +8 -0
  37. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentComplete.d.ts.map +1 -0
  38. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentComplete.js +108 -0
  39. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.d.ts +8 -0
  40. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.d.ts.map +1 -0
  41. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.js +92 -0
  42. package/lib/exercises/math/functions/affines/adjustment/index.d.ts +4 -0
  43. package/lib/exercises/math/functions/affines/adjustment/index.d.ts.map +1 -0
  44. package/lib/exercises/math/functions/affines/adjustment/index.js +3 -0
  45. package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindX.d.ts.map +1 -1
  46. package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindX.js +8 -6
  47. package/lib/exercises/math/functions/affines/index.d.ts +2 -4
  48. package/lib/exercises/math/functions/affines/index.d.ts.map +1 -1
  49. package/lib/exercises/math/functions/affines/index.js +2 -4
  50. package/lib/exercises/math/functions/affines/situations/affineFromExercise.d.ts +10 -0
  51. package/lib/exercises/math/functions/affines/situations/affineFromExercise.d.ts.map +1 -0
  52. package/lib/exercises/math/functions/affines/situations/affineFromExercise.js +219 -0
  53. package/lib/exercises/math/functions/affines/situations/affineModelisationSituations.d.ts +10 -0
  54. package/lib/exercises/math/functions/affines/situations/affineModelisationSituations.d.ts.map +1 -0
  55. package/lib/exercises/math/functions/affines/situations/affineModelisationSituations.js +69 -0
  56. package/lib/exercises/math/functions/affines/situations/affineSituationComputeAntecedent.d.ts +10 -0
  57. package/lib/exercises/math/functions/affines/situations/affineSituationComputeAntecedent.d.ts.map +1 -0
  58. package/lib/exercises/math/functions/affines/situations/affineSituationComputeAntecedent.js +133 -0
  59. package/lib/exercises/math/functions/affines/situations/affineSituationComputeImage.d.ts +10 -0
  60. package/lib/exercises/math/functions/affines/situations/affineSituationComputeImage.d.ts.map +1 -0
  61. package/lib/exercises/math/functions/affines/situations/affineSituationComputeImage.js +229 -0
  62. package/lib/exercises/math/functions/affines/situations/affineSituationThreshold.d.ts +10 -0
  63. package/lib/exercises/math/functions/affines/situations/affineSituationThreshold.d.ts.map +1 -0
  64. package/lib/exercises/math/functions/affines/situations/affineSituationThreshold.js +166 -0
  65. package/lib/exercises/math/functions/affines/situations/affineSituationVariation.d.ts +9 -0
  66. package/lib/exercises/math/functions/affines/situations/affineSituationVariation.d.ts.map +1 -0
  67. package/lib/exercises/math/functions/affines/situations/affineSituationVariation.js +78 -0
  68. package/lib/exercises/math/functions/affines/situations/index.d.ts +6 -0
  69. package/lib/exercises/math/functions/affines/situations/index.d.ts.map +1 -0
  70. package/lib/exercises/math/functions/affines/situations/index.js +5 -0
  71. package/lib/exercises/math/functions/exponentials/estimateExponentialFunctionImageFromGeometricScatterplot.d.ts +2 -0
  72. package/lib/exercises/math/functions/exponentials/estimateExponentialFunctionImageFromGeometricScatterplot.d.ts.map +1 -0
  73. package/lib/exercises/math/functions/exponentials/estimateExponentialFunctionImageFromGeometricScatterplot.js +155 -0
  74. package/lib/exercises/math/functions/exponentials/exponentialsRawVariations.d.ts +8 -0
  75. package/lib/exercises/math/functions/exponentials/exponentialsRawVariations.d.ts.map +1 -0
  76. package/lib/exercises/math/functions/exponentials/exponentialsRawVariations.js +99 -0
  77. package/lib/exercises/math/functions/exponentials/index.d.ts +3 -0
  78. package/lib/exercises/math/functions/exponentials/index.d.ts.map +1 -1
  79. package/lib/exercises/math/functions/exponentials/index.js +4 -0
  80. package/lib/exercises/math/functions/exponentials/plausibleExponentialFunctionExpressionFromGraph.d.ts +12 -0
  81. package/lib/exercises/math/functions/exponentials/plausibleExponentialFunctionExpressionFromGraph.d.ts.map +1 -0
  82. package/lib/exercises/math/functions/exponentials/plausibleExponentialFunctionExpressionFromGraph.js +138 -0
  83. package/lib/exercises/math/functions/exponentials/readExponentialFunctionParamsOnGraph.d.ts +8 -0
  84. package/lib/exercises/math/functions/exponentials/readExponentialFunctionParamsOnGraph.d.ts.map +1 -0
  85. package/lib/exercises/math/functions/exponentials/readExponentialFunctionParamsOnGraph.js +142 -0
  86. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.d.ts.map +1 -1
  87. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.js +7 -6
  88. package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiBH.d.ts.map +1 -1
  89. package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiBH.js +3 -2
  90. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductComputeBH.d.ts.map +1 -1
  91. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductComputeBH.js +7 -6
  92. package/lib/exercises/math/percent/percentToDecimal.d.ts.map +1 -1
  93. package/lib/exercises/math/percent/percentToDecimal.js +5 -4
  94. package/lib/exercises/math/probaStat/basicStats/calculateFrequencyInList.d.ts.map +1 -1
  95. package/lib/exercises/math/probaStat/basicStats/calculateFrequencyInList.js +5 -4
  96. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
  97. package/lib/exercises/math/probaStat/probaFromTableWithContext.js +7 -8
  98. package/lib/exercises/math/probaStat/randomVariable/index.d.ts +1 -7
  99. package/lib/exercises/math/probaStat/randomVariable/index.d.ts.map +1 -1
  100. package/lib/exercises/math/probaStat/randomVariable/index.js +1 -7
  101. package/lib/exercises/math/probaStat/randomVariable/situations/index.d.ts +8 -0
  102. package/lib/exercises/math/probaStat/randomVariable/situations/index.d.ts.map +1 -0
  103. package/lib/exercises/math/probaStat/randomVariable/situations/index.js +7 -0
  104. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationAverage.d.ts +11 -0
  105. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationAverage.d.ts.map +1 -0
  106. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationAverage.js +112 -0
  107. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationComputeProbability.d.ts +9 -0
  108. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationComputeProbability.d.ts.map +1 -0
  109. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationComputeProbability.js +176 -0
  110. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationIsGameFavorable.d.ts +8 -0
  111. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationIsGameFavorable.d.ts.map +1 -0
  112. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationIsGameFavorable.js +94 -0
  113. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationProbabilityLaw.d.ts +9 -0
  114. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationProbabilityLaw.d.ts.map +1 -0
  115. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationProbabilityLaw.js +166 -0
  116. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationStandardDeviation.d.ts +8 -0
  117. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationStandardDeviation.d.ts.map +1 -0
  118. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationStandardDeviation.js +133 -0
  119. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationValues.d.ts +8 -0
  120. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationValues.d.ts.map +1 -0
  121. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationValues.js +211 -0
  122. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationVariance.d.ts +8 -0
  123. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationVariance.d.ts.map +1 -0
  124. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationVariance.js +113 -0
  125. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituations.d.ts +41 -0
  126. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituations.d.ts.map +1 -0
  127. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituations.js +173 -0
  128. package/lib/exercises/math/probaStat/stats1var/medianWithList.d.ts.map +1 -1
  129. package/lib/exercises/math/probaStat/stats1var/medianWithList.js +5 -4
  130. package/lib/exercises/math/python/list/pyListMutationMix.d.ts.map +1 -1
  131. package/lib/exercises/math/python/list/pyListMutationMix.js +11 -6
  132. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts.map +1 -1
  133. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.js +9 -9
  134. package/lib/exercises/utils/options/arrayedOptions.d.ts +2 -0
  135. package/lib/exercises/utils/options/arrayedOptions.d.ts.map +1 -0
  136. package/lib/exercises/utils/options/arrayedOptions.js +16 -0
  137. package/lib/index.d.ts +56 -24
  138. package/lib/index.d.ts.map +1 -1
  139. package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts.map +1 -1
  140. package/lib/math/utils/sequences/situations/seqArithmeticSituations.js +20 -20
  141. package/lib/tree/utilities/nodeUtils.d.ts +2 -0
  142. package/lib/tree/utilities/nodeUtils.d.ts.map +1 -1
  143. package/lib/tree/utilities/nodeUtils.js +40 -0
  144. package/package.json +1 -1
@@ -14,7 +14,12 @@ import { SetVEA } from "../../../../exercises/vea/setVEA.js";
14
14
  import { dividersOf } from "../../../../math/utils/arithmetic/dividersOf.js";
15
15
  import { probaFlip } from "../../../../utils/alea/probaFlip.js";
16
16
  import { nodeBySubstitutingVar } from "../../../../math/utils/functions/functionComposition.js";
17
+ import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
17
18
  import { NodeUtils } from "../../../../tree/utilities/nodeUtils.js";
19
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
20
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
21
+ import { power } from "../../../../tree/nodes/operators/powerNode.js";
22
+ import { defaultArrayedOptsWhereNeeded } from "../../../../exercises/utils/options/arrayedOptions.js";
18
23
  const tryToSimplify = (node, simplifyOptions) => {
19
24
  try {
20
25
  return node.simplify(simplifyOptions);
@@ -399,12 +404,21 @@ const isIdentifiersQCPassed = (identifiers) => {
399
404
  return false;
400
405
  }
401
406
  };
402
- return isSolutionPrettyAndNotExploding(identifiers);
407
+ const isVEAOk = (identifiers) => {
408
+ try {
409
+ const answer = getAnswer(identifiers);
410
+ return isAnswerValid(answer, { answer, ...identifiers });
411
+ }
412
+ catch (_) {
413
+ return false;
414
+ }
415
+ };
416
+ return isSolutionPrettyAndNotExploding(identifiers) && isVEAOk(identifiers);
403
417
  };
404
418
  const getFindExtremaFromFunctionExpressionQuestion = (optsIn) => {
405
- const arrayedOptions = optsIn ?? arrayedOptsDefault;
406
- const typeF = random(arrayedOptions.typeF);
407
- const typeRoots = random(arrayedOptions.typeRoots);
419
+ const arrayedOpts = defaultArrayedOptsWhereNeeded(optsIn, arrayedOptsDefault);
420
+ const typeF = random(arrayedOpts.typeF);
421
+ const typeRoots = random(arrayedOpts.typeRoots);
408
422
  let identifiers;
409
423
  let isValid = false;
410
424
  let counter = -1;
@@ -418,67 +432,9 @@ const getFindExtremaFromFunctionExpressionQuestion = (optsIn) => {
418
432
  }
419
433
  if (!isValid) {
420
434
  // console.log("will use identifiersDefault");
435
+ const nodeF = frac(add(multiply(30, new VariableNode("x")), 10), add(add(multiply(6, power(new VariableNode("x"), 2)), multiply(3, new VariableNode("x"))), 1));
421
436
  const identifiersDefault = {
422
- nodeIdsF: {
423
- id: 3,
424
- leftChild: {
425
- id: 0,
426
- leftChild: {
427
- id: 2,
428
- leftChild: {
429
- id: 7,
430
- value: 30,
431
- },
432
- rightChild: {
433
- id: 10,
434
- name: "x",
435
- },
436
- },
437
- rightChild: {
438
- id: 7,
439
- value: 10,
440
- },
441
- },
442
- rightChild: {
443
- id: 0,
444
- leftChild: {
445
- id: 0,
446
- leftChild: {
447
- id: 2,
448
- leftChild: {
449
- id: 7,
450
- value: 6,
451
- },
452
- rightChild: {
453
- id: 5,
454
- leftChild: {
455
- id: 10,
456
- name: "x",
457
- },
458
- rightChild: {
459
- id: 7,
460
- value: 2,
461
- },
462
- },
463
- },
464
- rightChild: {
465
- id: 2,
466
- leftChild: {
467
- id: 7,
468
- value: 3,
469
- },
470
- rightChild: {
471
- id: 10,
472
- name: "x",
473
- },
474
- },
475
- },
476
- rightChild: {
477
- id: 7,
478
- value: 1,
479
- },
480
- },
481
- },
437
+ nodeIdsF: nodeF.toIdentifiers(),
482
438
  typeF: "$\\frac{dx+m}{ax^2+bx+c}$",
483
439
  typeRoots: "entières",
484
440
  };
@@ -1 +1 @@
1
- {"version":3,"file":"plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AA6J7C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,eAAe,EAAE,eAAe,EAAE,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAubF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAoCF,eAAO,MAAM,iEAAiE,EAAE,QAAQ,CACtF,WAAW,EACX,OAAO,CAuBR,CAAC"}
1
+ {"version":3,"file":"plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AA6J7C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,eAAe,EAAE,eAAe,EAAE,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAqbF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAoCF,eAAO,MAAM,iEAAiE,EAAE,QAAQ,CACtF,WAAW,EACX,OAAO,CAuBR,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { GeneratorOptionTarget, GeneratorOptionType, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { defaultArrayedOptsWhereNeeded } from "../../../../exercises/utils/options/arrayedOptions.js";
3
4
  import { blueMain, greenMain } from "../../../../geogebra/colors.js";
4
5
  import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
5
6
  import { ggbPointToCoords } from "../../../../geogebra/parsers/ggbPointToCoords.js";
@@ -313,8 +314,8 @@ const isGGBAnswerValid = (ggbAns, { ggbAnswer: _ggbAnswer, ...identifiers }) =>
313
314
  }
314
315
  };
315
316
  const getPlausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomialQuestion = (optsIn) => {
316
- const arrayedOptions = optsIn ?? arrayedOptsDefault;
317
- const typeF = random(arrayedOptions.typeF);
317
+ const arrayedOpts = defaultArrayedOptsWhereNeeded(optsIn, arrayedOptsDefault);
318
+ const typeF = random(arrayedOpts.typeF);
318
319
  const [arrX, nodeF] = (() => {
319
320
  let arrX;
320
321
  let nodeF;
@@ -1 +1 @@
1
- {"version":3,"file":"plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAYtC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAkK7C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,eAAe,EAAE,eAAe,EAAE,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAokBF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAkCF,eAAO,MAAM,iEAAiE,EAAE,QAAQ,CACtF,WAAW,EACX,OAAO,CAuBR,CAAC"}
1
+ {"version":3,"file":"plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAYtC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAkK7C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,eAAe,EAAE,eAAe,EAAE,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAkkBF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAkCF,eAAO,MAAM,iEAAiE,EAAE,QAAQ,CACtF,WAAW,EACX,OAAO,CAuBR,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { GeneratorOptionTarget, GeneratorOptionType, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { defaultArrayedOptsWhereNeeded } from "../../../../exercises/utils/options/arrayedOptions.js";
3
4
  import { blueMain, greenMain, orange } from "../../../../geogebra/colors.js";
4
5
  import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
5
6
  import { ggbPointsToPoints } from "../../../../geogebra/parsers/ggbPointsToPoints.js";
@@ -417,8 +418,8 @@ const isGGBAnswerValid = (ggbAns, { ggbAnswer: _ggbAnswer, ...identifiers }) =>
417
418
  }
418
419
  };
419
420
  const getPlausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomialQuestion = (optsIn) => {
420
- const arrayedOptions = optsIn ?? arrayedOptsDefault;
421
- const typeF = random(arrayedOptions.typeF);
421
+ const arrayedOpts = defaultArrayedOptsWhereNeeded(optsIn, arrayedOptsDefault);
422
+ const typeF = random(arrayedOpts.typeF);
422
423
  const [arrX, nodeF] = (() => {
423
424
  let arrX;
424
425
  let nodeF;
@@ -1 +1 @@
1
- {"version":3,"file":"signVarTableFromFunctionExpression.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/signVarTableFromFunctionExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAYrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAgM7C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAmXF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAyCF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CACvD,WAAW,EACX,OAAO,CAuBR,CAAC"}
1
+ {"version":3,"file":"signVarTableFromFunctionExpression.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/signVarTableFromFunctionExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAarC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAgM7C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAkXF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAyCF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CACvD,WAAW,EACX,OAAO,CAuBR,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { GeneratorOptionTarget, GeneratorOptionType, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { defaultArrayedOptsWhereNeeded } from "../../../../exercises/utils/options/arrayedOptions.js";
3
4
  import { varSignTableVEA } from "../../../../exercises/vea/varSignTableVEA.js";
4
5
  import { dividersOf } from "../../../../math/utils/arithmetic/dividersOf.js";
5
6
  import { nodeBySubstitutingVar } from "../../../../math/utils/functions/functionComposition.js";
@@ -374,9 +375,9 @@ const createRandomIdentifiers = (typeF, typeRoots) => {
374
375
  return identifiers;
375
376
  };
376
377
  const getSignVarTableFromFunctionExpressionQuestion = (optsIn) => {
377
- const arrayedOptions = optsIn ?? arrayedOptsDefault;
378
- const typeF = random(arrayedOptions.typeF);
379
- const typeRoots = random(arrayedOptions.typeRoots);
378
+ const arrayedOpts = defaultArrayedOptsWhereNeeded(optsIn, arrayedOptsDefault);
379
+ const typeF = random(arrayedOpts.typeF);
380
+ const typeRoots = random(arrayedOpts.typeRoots);
380
381
  let identifiers;
381
382
  let isValid = false;
382
383
  let counter = -1;
@@ -1 +1 @@
1
- {"version":3,"file":"signVarTableQuotientFExp.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/signVarTableQuotientFExp.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAsIrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAubF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAiBF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAmBnE,CAAC"}
1
+ {"version":3,"file":"signVarTableQuotientFExp.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/signVarTableQuotientFExp.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AA6HrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAqbF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAiBF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAmBnE,CAAC"}
@@ -10,29 +10,27 @@ import { opposite } from "../../../../tree/nodes/functions/oppositeNode.js";
10
10
  import { InequationSolutionNode } from "../../../../tree/nodes/inequations/inequationSolutionNode.js";
11
11
  import { MinusInfinityNode, PlusInfinityNode, } from "../../../../tree/nodes/numbers/infiniteNode.js";
12
12
  import { frac, isFractionNode, } from "../../../../tree/nodes/operators/fractionNode.js";
13
- import { isMultiplyNode, multiply, } from "../../../../tree/nodes/operators/multiplyNode.js";
14
13
  import { substract } from "../../../../tree/nodes/operators/substractNode.js";
15
14
  import { ClosureType } from "../../../../tree/nodes/sets/closure.js";
16
15
  import { IntervalNode } from "../../../../tree/nodes/sets/intervalNode.js";
17
16
  import { isUnionIntervalNode, UnionIntervalNode, } from "../../../../tree/nodes/sets/unionIntervalNode.js";
17
+ import { NodeSimplifier } from "../../../../tree/utilities/nodeSimplifier.js";
18
18
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
19
19
  import { zip } from "../../../../utils/arrays/arrayZip.js";
20
20
  import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
21
21
  import { alignTex } from "../../../../utils/latex/alignTex.js";
22
- const _simplifyMore = (node) => {
23
- if (isMultiplyNode(node)) {
24
- const nodeLeft = node.leftChild;
25
- const nodeRight = node.rightChild;
22
+ const tryToSimplify = (node) => {
23
+ try {
24
+ return NodeSimplifier.simplifyByVibrating(node, 5, true);
25
+ }
26
+ catch (_) {
26
27
  try {
27
- return multiply(nodeLeft.simplify({ forbidFactorize: true, towardsDistribute: true }), nodeRight.simplify({ forbidFactorize: true, towardsDistribute: true }));
28
+ return NodeSimplifier.simplifyByVibrating(node, 5, false);
28
29
  }
29
30
  catch (_) {
30
31
  return node;
31
32
  }
32
33
  }
33
- else {
34
- return node;
35
- }
36
34
  };
37
35
  const getInstructionNode = (a, b, c, isFOverExp) => {
38
36
  const nodeF = getNodeF(a, b, c);
@@ -42,10 +40,10 @@ const getInstructionNode = (a, b, c, isFOverExp) => {
42
40
  };
43
41
  const getNodeF = (a, b, c) => {
44
42
  if (a !== undefined) {
45
- return TrinomConstructor.fromCoeffs([c, b, a]).toTree().simplify();
43
+ return tryToSimplify(TrinomConstructor.fromCoeffs([c, b, a]).toTree());
46
44
  }
47
45
  else if (b !== undefined) {
48
- return AffineConstructor.fromCoeffs([c, b]).toTree().simplify();
46
+ return tryToSimplify(AffineConstructor.fromCoeffs([c, b]).toTree());
49
47
  }
50
48
  else {
51
49
  return c.toTree();
@@ -67,7 +65,7 @@ const getRootNodesOfDerivative = (a, b, c) => {
67
65
  }
68
66
  else {
69
67
  const [c, b] = coeffs;
70
- return [frac(opposite(c), b).simplify()];
68
+ return [tryToSimplify(frac(opposite(c), b))];
71
69
  }
72
70
  };
73
71
  const getTrinomInequationSolutionNode = (coeffs, ineqType) => {
@@ -144,11 +142,9 @@ const getAnswerTable = (identifiers) => {
144
142
  x: rootNodeMinus1.evaluate(),
145
143
  });
146
144
  const [strSignHPrimeRootMinus1, strSignHPrimeRootPlus1] = hPrimeRootMinus1 > 0 ? ["+", "-"] : ["-", "+"];
147
- const nodeHRoot = nodeH
148
- .toDetailedEvaluation({
145
+ const nodeHRoot = tryToSimplify(nodeH.toDetailedEvaluation({
149
146
  x: rootNode,
150
- })
151
- .simplify();
147
+ }));
152
148
  return [
153
149
  ["$x$", "-\\infty", "\\ ", rootNode.toTex(), "\\ ", "+\\infty"],
154
150
  //sign
@@ -181,11 +177,9 @@ const getAnswerTable = (identifiers) => {
181
177
  x: root1Minus1.evaluate(),
182
178
  });
183
179
  const [strSignHPrimeRoot1Minus1, strSignHPrimeRootAvg, strSignHPrimeRoot2Plus1,] = hPrimeRoot1Minus1 > 0 ? ["+", "-", "+"] : ["-", "+", "-"];
184
- const [nodeHRoot1, nodeHRoot2] = [rootNode1, rootNode2].map((nodeX) => nodeH
185
- .toDetailedEvaluation({
180
+ const [nodeHRoot1, nodeHRoot2] = [rootNode1, rootNode2].map((nodeX) => tryToSimplify(nodeH.toDetailedEvaluation({
186
181
  x: nodeX,
187
- })
188
- .simplify());
182
+ })));
189
183
  return [
190
184
  [
191
185
  "$x$",
@@ -301,32 +295,30 @@ const getCorrection = (identifiers) => {
301
295
  const signs = hPrimeRootMinus1 > 0 ? ["+", "-"] : ["-", "+"];
302
296
  const signWords = signs.map((strSign) => strSign === "+" ? "positive" : "négative");
303
297
  const words = signs.map((strSign) => strSign === "+" ? "croissante" : "décroissante");
304
- const image = nodeH
305
- .toDetailedEvaluation({
298
+ const image = tryToSimplify(nodeH.toDetailedEvaluation({
306
299
  x: rootNode,
307
- })
308
- .simplify();
300
+ }));
309
301
  return `On calcule $h'$ :
310
302
 
311
303
  $$
312
- h'(x) = ${nodeHPrime.simplify().toTex()}
304
+ h'(x) = ${tryToSimplify(nodeHPrime).toTex()}
313
305
  $$
314
306
 
315
307
  On détermine ensuite le signe de $h'(x)$ :
316
308
 
317
309
  ${alignTex([
318
310
  ["", "h'(x) \\geq 0"],
319
- ["\\iff", nodeHPrime.simplify().toTex() + "\\geq 0"],
311
+ ["\\iff", tryToSimplify(nodeHPrime).toTex() + "\\geq 0"],
320
312
  [
321
313
  "\\iff",
322
314
  (() => {
323
315
  if (isFOverExp) {
324
- return frac(nodeHPrime, exp(opposite("x".toTree()))).simplify();
316
+ return tryToSimplify(frac(nodeHPrime, exp(opposite("x".toTree()))));
325
317
  }
326
318
  else {
327
- const nodeWithoutExp = frac(nodeHPrime, exp("x".toTree())).simplify();
319
+ const nodeWithoutExp = tryToSimplify(frac(nodeHPrime, exp("x".toTree())));
328
320
  if (isFractionNode(nodeWithoutExp)) {
329
- return nodeWithoutExp.leftChild.simplify({ towardsDistribute: true });
321
+ return tryToSimplify(nodeWithoutExp.leftChild);
330
322
  }
331
323
  else {
332
324
  return nodeWithoutExp;
@@ -344,7 +336,7 @@ On en conclut que $h$ est ${words[0]} sur $]-\\infty; ${rootTex}]$, puis ${words
344
336
  Pour compléter le tableau, il ne reste plus qu'à calculer l'image par $h$ de $${rootTex}$ :
345
337
 
346
338
  $$
347
- h\\left(${rootTex}\\right) = ${image.toTex()} = ${image.simplify().toTex()}
339
+ h\\left(${rootTex}\\right) = ${image.toTex()} = ${tryToSimplify(image).toTex()}
348
340
  $$`;
349
341
  }
350
342
  else {
@@ -361,24 +353,24 @@ $$`;
361
353
  return `On calcule $h'$ :
362
354
 
363
355
  $$
364
- h'(x) = ${nodeHPrime.simplify().toTex()}
356
+ h'(x) = ${tryToSimplify(nodeHPrime).toTex()}
365
357
  $$
366
358
 
367
359
  On détermine ensuite le signe de $h'(x)$ :
368
360
 
369
361
  ${alignTex([
370
362
  ["", "h'(x) \\geq 0"],
371
- ["\\iff", nodeHPrime.simplify().toTex() + "\\geq 0"],
363
+ ["\\iff", tryToSimplify(nodeHPrime).toTex() + "\\geq 0"],
372
364
  [
373
365
  "\\iff",
374
366
  (() => {
375
367
  if (isFOverExp) {
376
- return frac(nodeHPrime, exp(opposite("x".toTree()))).simplify();
368
+ return tryToSimplify(frac(nodeHPrime, exp(opposite("x".toTree()))));
377
369
  }
378
370
  else {
379
- const nodeWithoutExp = frac(nodeHPrime, exp("x".toTree())).simplify();
371
+ const nodeWithoutExp = tryToSimplify(frac(nodeHPrime, exp("x".toTree())));
380
372
  if (isFractionNode(nodeWithoutExp)) {
381
- return nodeWithoutExp.leftChild.simplify({ towardsDistribute: true });
373
+ return tryToSimplify(nodeWithoutExp.leftChild);
382
374
  }
383
375
  else {
384
376
  return nodeWithoutExp;
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ xValues: number[];
4
+ yValues: number[];
5
+ };
6
+ export declare const affineAdjustmentExercise: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=affineAdjustment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"affineAdjustment.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/affines/adjustment/affineAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAgBrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AA8KF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAa1D,CAAC"}
@@ -0,0 +1,129 @@
1
+ import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randfloat } from "../../../../../math/utils/random/randfloat.js";
4
+ import { randint } from "../../../../../math/utils/random/randint.js";
5
+ import { round } from "../../../../../math/utils/round.js";
6
+ import { leastSquares } from "../../../../../math/utils/stats/leastSquares.js";
7
+ import { EqualNode } from "../../../../../tree/nodes/equations/equalNode.js";
8
+ import { NumberNode } from "../../../../../tree/nodes/numbers/numberNode.js";
9
+ import { AddNode } from "../../../../../tree/nodes/operators/addNode.js";
10
+ import { MultiplyNode } from "../../../../../tree/nodes/operators/multiplyNode.js";
11
+ import { SubstractNode } from "../../../../../tree/nodes/operators/substractNode.js";
12
+ import { VariableNode } from "../../../../../tree/nodes/variables/variableNode.js";
13
+ import { dollarize } from "../../../../../utils/latex/dollarize.js";
14
+ import { mdTable } from "../../../../../utils/markdown/mdTable.js";
15
+ const getInstruction = ({ xValues, yValues }) => {
16
+ const dataTable = mdTable([
17
+ ["$x$", ...xValues.map((n) => dollarize(n.frenchify()))],
18
+ ["$y$", ...yValues.map((n) => dollarize(n.frenchify()))],
19
+ ]);
20
+ return `On considère la série statistique ci-dessous. Déterminer l'équation de la droite d'ajustement obtenue par la méthode des moindres carrés.
21
+
22
+ ${dataTable}
23
+
24
+ Arrondir les coefficients au dixième.
25
+ `;
26
+ };
27
+ function generateLinearData(n) {
28
+ const slope = randint(-500, 500, [0]) / 100;
29
+ const intercept = randint(100, 5000) / 100;
30
+ const data = [];
31
+ const generatedXs = new Set();
32
+ let counter = 0;
33
+ while (data.length < n) {
34
+ counter++;
35
+ if (counter > 1000) {
36
+ throw new Error("affineAdjustement too many iterations");
37
+ }
38
+ let x = randint(1, 100);
39
+ let cnt = 0;
40
+ while (generatedXs.has(x)) {
41
+ cnt++;
42
+ if (cnt > 1000) {
43
+ throw new Error("affineAdjustement too many iterations");
44
+ }
45
+ x = randint(1, 100);
46
+ }
47
+ generatedXs.add(x);
48
+ const y = round(slope * x + intercept, 2);
49
+ data.push({ x, y });
50
+ }
51
+ return data;
52
+ }
53
+ const getAnswer = (identifiers) => {
54
+ const { xValues, yValues } = identifiers;
55
+ const { a, b } = leastSquares(xValues, yValues);
56
+ const aFixed = round(a, 1);
57
+ const bFixed = round(b, 1);
58
+ const answer = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(aFixed), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true })).toTex();
59
+ return answer;
60
+ };
61
+ const getAffineAdjustmentQuestion = () => {
62
+ const data = generateLinearData(5);
63
+ data.sort((a, b) => a.x - b.x);
64
+ const xValues = data.map((point) => point.x);
65
+ const yValues = data.map((point) => point.y);
66
+ const identifiers = { xValues, yValues };
67
+ return getQuestionFromIdentifiers(identifiers);
68
+ };
69
+ const getQuestionFromIdentifiers = (identifiers) => {
70
+ const question = {
71
+ answer: getAnswer(identifiers),
72
+ instruction: getInstruction(identifiers),
73
+ keys: ["equal", "y", "x", "a", "b"],
74
+ answerFormat: "tex",
75
+ identifiers,
76
+ style: {
77
+ tableOptions: {
78
+ firstCellIsDivided: false,
79
+ firstColumnIsHeader: true,
80
+ firstRowIsHeader: false,
81
+ },
82
+ },
83
+ };
84
+ return question;
85
+ };
86
+ const getPropositions = (n, { answer, xValues, yValues }) => {
87
+ const propositions = [];
88
+ addValidProp(propositions, answer, "tex");
89
+ const { a, b } = leastSquares(xValues, yValues);
90
+ const aFixed = round(a, 1);
91
+ const bFixed = round(b, 1);
92
+ const wrongAnswer1 = new EqualNode(new VariableNode("y"), new SubstractNode(new MultiplyNode(new NumberNode(aFixed), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true }));
93
+ const awrong = randfloat(-5, 5, 1, [0]);
94
+ const bwrong = randfloat(-20, 20, 1);
95
+ const wrongAnswer2 = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(round(awrong, 1)), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true }));
96
+ const wrongAnswer3 = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(aFixed), new VariableNode("x")), new NumberNode(round(bwrong, 1))).simplify({ forbidFactorize: true }));
97
+ const wrongAnswer4 = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(round(awrong, 1)), new VariableNode("x")), new NumberNode(round(bwrong, 1))).simplify({ forbidFactorize: true }));
98
+ tryToAddWrongProp(propositions, wrongAnswer1.toTex());
99
+ tryToAddWrongProp(propositions, wrongAnswer2.toTex());
100
+ tryToAddWrongProp(propositions, wrongAnswer3.toTex());
101
+ tryToAddWrongProp(propositions, wrongAnswer4.toTex());
102
+ propWhile(propositions, n, () => {
103
+ const a = randint(-10, 10, [0]);
104
+ const b = randint(-10, 10);
105
+ const wrongAnswer = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(a), new VariableNode("x")), new NumberNode(b)).simplify({ forbidFactorize: true }));
106
+ tryToAddWrongProp(propositions, wrongAnswer.toTex());
107
+ });
108
+ return shuffleProps(propositions, n);
109
+ };
110
+ const isAnswerValid = (ans, { xValues, yValues }) => {
111
+ const { a, b } = leastSquares(xValues, yValues);
112
+ const aFixed = round(a, 1);
113
+ const bFixed = round(b, 1);
114
+ const valid = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(aFixed), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true }));
115
+ const latexs = valid.toAllValidTexs({ allowRawRightChildAsSolution: true });
116
+ return latexs.includes(ans);
117
+ };
118
+ export const affineAdjustmentExercise = {
119
+ id: "affineAdjustment",
120
+ label: "Déterminer l'équation de la droite d'ajustement à partir d'un tableau de données",
121
+ isSingleStep: true,
122
+ generator: (nb) => getDistinctQuestions(getAffineAdjustmentQuestion, nb),
123
+ qcmTimer: 60,
124
+ freeTimer: 60,
125
+ getPropositions,
126
+ isAnswerValid,
127
+ subject: "Mathématiques",
128
+ getQuestionFromIdentifiers,
129
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ xValues: number[];
4
+ yValues: number[];
5
+ };
6
+ export declare const affineAdjustmentCompleteExercise: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=affineAdjustmentComplete.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"affineAdjustmentComplete.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/affines/adjustment/affineAdjustmentComplete.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAmBrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AA4JF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAalE,CAAC"}
@@ -0,0 +1,108 @@
1
+ import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randfloat } from "../../../../../math/utils/random/randfloat.js";
4
+ import { randint } from "../../../../../math/utils/random/randint.js";
5
+ import { round } from "../../../../../math/utils/round.js";
6
+ import { generateAffineCloud } from "../../../../../math/utils/stats/generateAffineCloud.js";
7
+ import { leastSquares } from "../../../../../math/utils/stats/leastSquares.js";
8
+ import { rSquared } from "../../../../../math/utils/stats/rSquared.js";
9
+ import { EqualNode } from "../../../../../tree/nodes/equations/equalNode.js";
10
+ import { NumberNode } from "../../../../../tree/nodes/numbers/numberNode.js";
11
+ import { AddNode } from "../../../../../tree/nodes/operators/addNode.js";
12
+ import { MultiplyNode } from "../../../../../tree/nodes/operators/multiplyNode.js";
13
+ import { PowerNode } from "../../../../../tree/nodes/operators/powerNode.js";
14
+ import { SubstractNode } from "../../../../../tree/nodes/operators/substractNode.js";
15
+ import { VariableNode } from "../../../../../tree/nodes/variables/variableNode.js";
16
+ import { dollarize } from "../../../../../utils/latex/dollarize.js";
17
+ import { mdTable } from "../../../../../utils/markdown/mdTable.js";
18
+ const getAnswer = (identifiers) => {
19
+ const { xValues, yValues } = identifiers;
20
+ const { a, b } = leastSquares(xValues, yValues);
21
+ const aFixed = round(a, 1);
22
+ const bFixed = round(b, 1);
23
+ const answerEq = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(aFixed), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true })).toTex();
24
+ const r2 = round(rSquared(xValues, yValues), 2);
25
+ const answerR = new EqualNode(new PowerNode(new VariableNode("R"), new NumberNode(2)), r2.toTree()).toTex();
26
+ return `${answerEq}\\newline ${answerR}`;
27
+ };
28
+ const getInstruction = (identifiers) => {
29
+ const { xValues, yValues } = identifiers;
30
+ const dataTable = mdTable([
31
+ ["$x$", ...xValues.map((n) => dollarize(n.frenchify()))],
32
+ ["$y$", ...yValues.map((n) => dollarize(n.frenchify()))],
33
+ ]);
34
+ return `On considère la série statistique ci-dessous. A l'aide de la calculatrice, déterminer l'équation de la droite d'ajustement et la valeur du coefficient de détermination. ${dataTable}
35
+ `;
36
+ };
37
+ const getAffineAdjustmentCompleteQuestion = () => {
38
+ const data = generateAffineCloud(6);
39
+ data.sort((a, b) => a.x - b.x);
40
+ const xValues = data.map((point) => point.x);
41
+ const yValues = data.map((point) => point.y);
42
+ const identifiers = {
43
+ xValues,
44
+ yValues,
45
+ };
46
+ return getQuestionFromIdentifiers(identifiers);
47
+ };
48
+ const getQuestionFromIdentifiers = (identifiers) => {
49
+ const question = {
50
+ answer: getAnswer(identifiers),
51
+ instruction: getInstruction(identifiers),
52
+ keys: [],
53
+ answerFormat: "tex",
54
+ identifiers,
55
+ style: {
56
+ tableOptions: {
57
+ firstCellIsDivided: false,
58
+ firstColumnIsHeader: true,
59
+ firstRowIsHeader: false,
60
+ },
61
+ },
62
+ };
63
+ return question;
64
+ };
65
+ const getPropositions = (n, { answer, xValues, yValues }) => {
66
+ const propositions = [];
67
+ addValidProp(propositions, answer, "tex");
68
+ const { a, b } = leastSquares(xValues, yValues);
69
+ const r2 = round(rSquared(xValues, yValues), 2);
70
+ const aFixed = round(a, 1);
71
+ const bFixed = round(b, 1);
72
+ const answerEq = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(aFixed), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true })).toTex();
73
+ const answerR = new EqualNode(new PowerNode(new VariableNode("R"), new NumberNode(2)), r2.toTree()).toTex();
74
+ const wrongAnswerEq1 = new EqualNode(new VariableNode("y"), new SubstractNode(new MultiplyNode(new NumberNode(aFixed), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true })).toTex();
75
+ const awrong = randfloat(1, 10, 1);
76
+ const wrongAnswerEq2 = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(round(awrong, 1)), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true })).toTex();
77
+ const wrongAnswerR1 = new EqualNode(new VariableNode("R"), r2.toTree()).toTex();
78
+ const wrongAnswerR2 = new EqualNode(new PowerNode(new VariableNode("R"), new NumberNode(2)), (r2 + 0.01).toTree()).toTex();
79
+ const wrongAnswer1 = `${answerEq}\\newline ${wrongAnswerR1}`;
80
+ const wrongAnswer2 = `${answerEq}\\newline ${wrongAnswerR2}`;
81
+ const wrongAnswer3 = `${wrongAnswerEq1}\\newline ${answerR}`;
82
+ const wrongAnswer4 = `${wrongAnswerEq2}\\newline ${answerR}`;
83
+ tryToAddWrongProp(propositions, wrongAnswer1);
84
+ tryToAddWrongProp(propositions, wrongAnswer2);
85
+ tryToAddWrongProp(propositions, wrongAnswer3);
86
+ tryToAddWrongProp(propositions, wrongAnswer4);
87
+ propWhile(propositions, n, () => {
88
+ const a = randint(-10, 10, [0]);
89
+ const b = randint(-10, 10);
90
+ const wrongAnswerEq = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(a), new VariableNode("x")), new NumberNode(b)).simplify({ forbidFactorize: true })).toTex();
91
+ const wrongAnswerR = new EqualNode(new PowerNode(new VariableNode("R"), new NumberNode(2)), round(Math.random(), 2).toTree()).toTex();
92
+ const wrongAnswer = `${wrongAnswerEq}\\newline ${wrongAnswerR}`;
93
+ tryToAddWrongProp(propositions, wrongAnswer);
94
+ });
95
+ return shuffleProps(propositions, n);
96
+ };
97
+ export const affineAdjustmentCompleteExercise = {
98
+ id: "affineAdjustmentComplete",
99
+ label: "Déterminer l'équation de la droite d'ajustement et le coefficient de détermination",
100
+ isSingleStep: true,
101
+ generator: (nb) => getDistinctQuestions(getAffineAdjustmentCompleteQuestion, nb),
102
+ qcmTimer: 60,
103
+ freeTimer: 60,
104
+ getPropositions,
105
+ subject: "Mathématiques",
106
+ getQuestionFromIdentifiers,
107
+ answerType: "QCU",
108
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ xValues: number[];
4
+ yValues: number[];
5
+ };
6
+ export declare const affineAdjustmentRsquaredExercise: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=affineAdjustmentRsquared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"affineAdjustmentRsquared.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAqHF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAalE,CAAC"}