math-exercises 3.0.178 → 3.0.180

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 (161) hide show
  1. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving1.d.ts +14 -0
  2. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving1.d.ts.map +1 -0
  3. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving1.js +283 -0
  4. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving3.d.ts +15 -0
  5. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving3.d.ts.map +1 -0
  6. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving3.js +296 -0
  7. package/lib/exercises/math/derivation/derivative/exp/expDerivativeOne.js +3 -3
  8. package/lib/exercises/math/derivation/derivative/exp/expDerivativeProductFExp.d.ts +14 -0
  9. package/lib/exercises/math/derivation/derivative/exp/expDerivativeProductFExp.d.ts.map +1 -0
  10. package/lib/exercises/math/derivation/derivative/exp/expDerivativeProductFExp.js +346 -0
  11. package/lib/exercises/math/derivation/derivative/exp/expDerivativeQuotientFExp.d.ts +15 -0
  12. package/lib/exercises/math/derivation/derivative/exp/expDerivativeQuotientFExp.d.ts.map +1 -0
  13. package/lib/exercises/math/derivation/derivative/exp/expDerivativeQuotientFExp.js +435 -0
  14. package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.d.ts +13 -0
  15. package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.d.ts.map +1 -0
  16. package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.js +326 -0
  17. package/lib/exercises/math/derivation/derivativeNumber/signOfDerivativeNumberFromFunctionCurve.d.ts +14 -0
  18. package/lib/exercises/math/derivation/derivativeNumber/signOfDerivativeNumberFromFunctionCurve.d.ts.map +1 -0
  19. package/lib/exercises/math/derivation/derivativeNumber/signOfDerivativeNumberFromFunctionCurve.js +181 -0
  20. package/lib/exercises/math/derivation/derivativeNumber/valueTableImageAndDerivativeFromFunctionExpression.d.ts +10 -0
  21. package/lib/exercises/math/derivation/derivativeNumber/valueTableImageAndDerivativeFromFunctionExpression.d.ts.map +1 -0
  22. package/lib/exercises/math/derivation/derivativeNumber/valueTableImageAndDerivativeFromFunctionExpression.js +272 -0
  23. package/lib/exercises/math/derivation/problems/index.d.ts +5 -0
  24. package/lib/exercises/math/derivation/problems/index.d.ts.map +1 -0
  25. package/lib/exercises/math/derivation/problems/index.js +4 -0
  26. package/lib/exercises/math/derivation/problems/problemMaximizeBoxVolumeFindX.d.ts +8 -0
  27. package/lib/exercises/math/derivation/problems/problemMaximizeBoxVolumeFindX.d.ts.map +1 -0
  28. package/lib/exercises/math/derivation/problems/problemMaximizeBoxVolumeFindX.js +171 -0
  29. package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.d.ts +15 -0
  30. package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.d.ts.map +1 -0
  31. package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.js +328 -0
  32. package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.d.ts +13 -0
  33. package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.d.ts.map +1 -0
  34. package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.js +275 -0
  35. package/lib/exercises/math/derivation/problems/problemProjectileHeightFindAbscissa.d.ts +8 -0
  36. package/lib/exercises/math/derivation/problems/problemProjectileHeightFindAbscissa.d.ts.map +1 -0
  37. package/lib/exercises/math/derivation/problems/problemProjectileHeightFindAbscissa.js +137 -0
  38. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineY.d.ts +10 -0
  39. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineY.d.ts.map +1 -0
  40. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineY.js +478 -0
  41. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineYAndSlope.d.ts +10 -0
  42. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineYAndSlope.d.ts.map +1 -0
  43. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineYAndSlope.js +499 -0
  44. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingPoint.d.ts +10 -0
  45. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingPoint.d.ts.map +1 -0
  46. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingPoint.js +240 -0
  47. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingBuildingTangent.d.ts +12 -0
  48. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingBuildingTangent.d.ts.map +1 -0
  49. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingBuildingTangent.js +436 -0
  50. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingPoint.d.ts +12 -0
  51. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingPoint.d.ts.map +1 -0
  52. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingPoint.js +219 -0
  53. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingSecant.d.ts +13 -0
  54. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingSecant.d.ts.map +1 -0
  55. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingSecant.js +273 -0
  56. package/lib/exercises/math/derivation/tangent/placePointsOfDerivativeFromGraph.d.ts +18 -0
  57. package/lib/exercises/math/derivation/tangent/placePointsOfDerivativeFromGraph.d.ts.map +1 -0
  58. package/lib/exercises/math/derivation/tangent/placePointsOfDerivativeFromGraph.js +295 -0
  59. package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.d.ts +13 -0
  60. package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.d.ts.map +1 -0
  61. package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.js +388 -0
  62. package/lib/exercises/math/derivation/tangent/tangentEquationFromGraph.d.ts +9 -0
  63. package/lib/exercises/math/derivation/tangent/tangentEquationFromGraph.d.ts.map +1 -0
  64. package/lib/exercises/math/derivation/tangent/tangentEquationFromGraph.js +308 -0
  65. package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.d.ts +14 -0
  66. package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.d.ts.map +1 -0
  67. package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.js +439 -0
  68. package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.d.ts +14 -0
  69. package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.d.ts.map +1 -0
  70. package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.js +547 -0
  71. package/lib/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.d.ts +15 -0
  72. package/lib/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.d.ts.map +1 -0
  73. package/lib/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.js +537 -0
  74. package/lib/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.d.ts +15 -0
  75. package/lib/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.d.ts.map +1 -0
  76. package/lib/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.js +639 -0
  77. package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.d.ts +14 -0
  78. package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.d.ts.map +1 -0
  79. package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.js +530 -0
  80. package/lib/exercises/math/derivation/variations/signVarTableProductFExp.d.ts +10 -0
  81. package/lib/exercises/math/derivation/variations/signVarTableProductFExp.d.ts.map +1 -0
  82. package/lib/exercises/math/derivation/variations/signVarTableProductFExp.js +451 -0
  83. package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.d.ts +11 -0
  84. package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.d.ts.map +1 -0
  85. package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.js +514 -0
  86. package/lib/exercises/math/functions/trinoms/sign/signOfProductOfAffineAndTrinom.d.ts.map +1 -1
  87. package/lib/exercises/math/functions/trinoms/sign/signOfProductOfAffineAndTrinom.js +4 -11
  88. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.d.ts.map +1 -1
  89. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.js +32 -17
  90. package/lib/exercises/math/probaStat/conditional/conditionalProbaFromTableWithContext.d.ts +13 -0
  91. package/lib/exercises/math/probaStat/conditional/conditionalProbaFromTableWithContext.d.ts.map +1 -0
  92. package/lib/exercises/math/probaStat/conditional/conditionalProbaFromTableWithContext.js +195 -0
  93. package/lib/exercises/math/probaStat/conditional/conditionalProbaWriteFromFrench.d.ts +9 -0
  94. package/lib/exercises/math/probaStat/conditional/conditionalProbaWriteFromFrench.d.ts.map +1 -0
  95. package/lib/exercises/math/probaStat/conditional/conditionalProbaWriteFromFrench.js +220 -0
  96. package/lib/exercises/math/probaStat/conditional/conditionalProbability.d.ts +15 -0
  97. package/lib/exercises/math/probaStat/conditional/conditionalProbability.d.ts.map +1 -0
  98. package/lib/exercises/math/probaStat/conditional/conditionalProbability.js +332 -0
  99. package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.d.ts +8 -0
  100. package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.d.ts.map +1 -0
  101. package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.js +222 -0
  102. package/lib/exercises/math/probaStat/conditional/index.d.ts +5 -0
  103. package/lib/exercises/math/probaStat/conditional/index.d.ts.map +1 -0
  104. package/lib/exercises/math/probaStat/conditional/index.js +4 -0
  105. package/lib/exercises/math/probaStat/index.d.ts +1 -2
  106. package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
  107. package/lib/exercises/math/probaStat/index.js +1 -2
  108. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts +1 -0
  109. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
  110. package/lib/exercises/math/probaStat/probaFromTableWithContext.js +26 -199
  111. package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationProbabilityLaw.d.ts.map +1 -1
  112. package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationProbabilityLaw.js +6 -2
  113. package/lib/exercises/math/probaStat/randomVariable/utils/randomVariableSituations.d.ts.map +1 -1
  114. package/lib/exercises/math/probaStat/randomVariable/utils/randomVariableSituations.js +6 -5
  115. package/lib/exercises/math/probaStat/trees/buildTreeFromSituation.d.ts.map +1 -1
  116. package/lib/exercises/math/probaStat/trees/buildTreeFromSituation.js +4 -27
  117. package/lib/exercises/math/probaStat/twoEventsSituations.d.ts +29 -0
  118. package/lib/exercises/math/probaStat/twoEventsSituations.d.ts.map +1 -0
  119. package/lib/exercises/math/probaStat/twoEventsSituations.js +145 -0
  120. package/lib/exercises/math/sequences/explicitFormulaUsage.d.ts +4 -1
  121. package/lib/exercises/math/sequences/explicitFormulaUsage.d.ts.map +1 -1
  122. package/lib/exercises/math/sequences/explicitFormulaUsage.js +47 -7
  123. package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.js +1 -1
  124. package/lib/exercises/math/sequences/recurrenceFormulaUsage.d.ts +5 -1
  125. package/lib/exercises/math/sequences/recurrenceFormulaUsage.d.ts.map +1 -1
  126. package/lib/exercises/math/sequences/recurrenceFormulaUsage.js +89 -9
  127. package/lib/exercises/math/trigonometry/circle/associatePoint.d.ts.map +1 -1
  128. package/lib/exercises/math/trigonometry/circle/associatePoint.js +55 -6
  129. package/lib/exercises/math/trigonometry/circle/selectQuadrantOnTrigoCircle.d.ts.map +1 -1
  130. package/lib/exercises/math/trigonometry/circle/selectQuadrantOnTrigoCircle.js +5 -6
  131. package/lib/exercises/math/trigonometry/functions/associateAngleSimplification.d.ts.map +1 -1
  132. package/lib/exercises/math/trigonometry/functions/associateAngleSimplification.js +1 -3
  133. package/lib/exercises/vea/polynomialVEA.d.ts +2 -0
  134. package/lib/exercises/vea/polynomialVEA.d.ts.map +1 -0
  135. package/lib/exercises/vea/polynomialVEA.js +17 -0
  136. package/lib/exercises/vea/valueTableVEA.d.ts +8 -0
  137. package/lib/exercises/vea/valueTableVEA.d.ts.map +1 -0
  138. package/lib/exercises/vea/valueTableVEA.js +12 -0
  139. package/lib/index.d.ts +27 -11
  140. package/lib/index.d.ts.map +1 -1
  141. package/lib/latexTester.d.ts.map +1 -1
  142. package/lib/latexTester.js +1 -1
  143. package/lib/math/utils/polynomial/polynomialInterpolationUtils.d.ts +19 -0
  144. package/lib/math/utils/polynomial/polynomialInterpolationUtils.d.ts.map +1 -0
  145. package/lib/math/utils/polynomial/polynomialInterpolationUtils.js +53 -0
  146. package/lib/math/utils/polynomial/polynomialUtils.d.ts +37 -0
  147. package/lib/math/utils/polynomial/polynomialUtils.d.ts.map +1 -0
  148. package/lib/math/utils/polynomial/polynomialUtils.js +223 -0
  149. package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts.map +1 -1
  150. package/lib/math/utils/sequences/situations/seqArithmeticSituations.js +6 -6
  151. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  152. package/lib/tree/nodes/operators/multiplyNode.js +1 -1
  153. package/lib/tree/nodes/operators/substractNode.d.ts.map +1 -1
  154. package/lib/tree/nodes/operators/substractNode.js +2 -1
  155. package/lib/tree/utilities/nodeUtils.d.ts +6 -0
  156. package/lib/tree/utilities/nodeUtils.d.ts.map +1 -0
  157. package/lib/tree/utilities/nodeUtils.js +24 -0
  158. package/lib/utils/strings/prependArticle.d.ts +2 -0
  159. package/lib/utils/strings/prependArticle.d.ts.map +1 -0
  160. package/lib/utils/strings/prependArticle.js +1 -0
  161. package/package.json +1 -1
@@ -0,0 +1,37 @@
1
+ import { AlgebraicNode } from "../../../tree/nodes/algebraicNode.js";
2
+ import { VariableNode } from "../../../tree/nodes/variables/variableNode.js";
3
+ /**
4
+ *
5
+ * @param nodeA
6
+ * @param arrNodeRoot
7
+ * @returns a(x - root1)...(x - rootn)
8
+ */
9
+ export declare function createNodeFPolynomialFromRoots(nodeA: AlgebraicNode, arrNodeRoot: AlgebraicNode[]): AlgebraicNode;
10
+ /**
11
+ *
12
+ * @param nodePolynomial
13
+ * @returns for example: [nodeCoeffC, nodeCoeffB, nodeCoeffA] if nodePolynomial is a trinom
14
+ */
15
+ export declare function getArrNodeCoeffOfPolynomialNode(nodePolynomial: AlgebraicNode): AlgebraicNode[];
16
+ /**
17
+ *
18
+ * @param arrNodeCoeff
19
+ * @returns coeffN x^N + ... + coeff2 x^2 + coeff1 x^1 + coeff0
20
+ */
21
+ export declare function createNodeFPolynomialFromCoeffs(arrNodeCoeff: AlgebraicNode[]): AlgebraicNode | import("../../../tree/nodes/operators/multiplyNode.js").MultiplyNode;
22
+ /**
23
+ *
24
+ * @param arrNodeCoeff
25
+ * @returns discriminator
26
+ */
27
+ export declare function createNodeDiscriminator(arrNodeCoeff: AlgebraicNode[]): import("../../../tree/nodes/operators/substractNode.js").SubstractNode;
28
+ export declare const getTexSolveSecondDegreeEquation: (nodePolynomial: AlgebraicNode, opts?: {
29
+ nodeVar: VariableNode;
30
+ isShouldApprox: boolean;
31
+ }) => string;
32
+ export declare const getAnswerStuffSolveSecondDegreePolynomial: (nodePolynomial: AlgebraicNode) => {
33
+ nodePolynomial: AlgebraicNode;
34
+ arrNodeX: AlgebraicNode[];
35
+ };
36
+ export declare function createIntegratedPolynomialNode(nodePolynomial: AlgebraicNode, nodeC: AlgebraicNode): AlgebraicNode;
37
+ //# sourceMappingURL=polynomialUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polynomialUtils.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/polynomial/polynomialUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEd,MAAM,mCAAmC,CAAC;AAQ3C,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAM1E;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,aAAa,EACpB,WAAW,EAAE,aAAa,EAAE,iBAO7B;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,cAAc,EAAE,aAAa,mBAe5E;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,YAAY,EAAE,aAAa,EAAE,qFAgB5E;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,aAAa,EAAE,uEAGpE;AAaD,eAAO,MAAM,+BAA+B,GAC1C,gBAAgB,aAAa,EAC7B,OAAM;IAAE,OAAO,EAAE,YAAY,CAAC;IAAC,cAAc,EAAE,OAAO,CAAA;CAGrD,WAoGF,CAAC;AAEF,eAAO,MAAM,yCAAyC,GACpD,gBAAgB,aAAa;;;CA+C9B,CAAC;AAEF,wBAAgB,8BAA8B,CAC5C,cAAc,EAAE,aAAa,EAC7B,KAAK,EAAE,aAAa,iBAQrB"}
@@ -0,0 +1,223 @@
1
+ import { opposite } from "../../../tree/nodes/functions/oppositeNode.js";
2
+ import { sqrt } from "../../../tree/nodes/functions/sqrtNode.js";
3
+ import { add } from "../../../tree/nodes/operators/addNode.js";
4
+ import { frac } from "../../../tree/nodes/operators/fractionNode.js";
5
+ import { multiply } from "../../../tree/nodes/operators/multiplyNode.js";
6
+ import { power } from "../../../tree/nodes/operators/powerNode.js";
7
+ import { substract } from "../../../tree/nodes/operators/substractNode.js";
8
+ import { alignTex } from "../../../utils/latex/alignTex.js";
9
+ import { factorial } from "../arithmetic/factorial.js";
10
+ import { nodeBySubstitutingVar } from "../functions/functionComposition.js";
11
+ import { round } from "../round.js";
12
+ /**
13
+ *
14
+ * @param nodeA
15
+ * @param arrNodeRoot
16
+ * @returns a(x - root1)...(x - rootn)
17
+ */
18
+ export function createNodeFPolynomialFromRoots(nodeA, arrNodeRoot) {
19
+ const nodeVarX = "x".toTree();
20
+ const nodePolynomial = arrNodeRoot.reduce((acc, nodeCoeff) => {
21
+ return multiply(acc, substract(nodeVarX, nodeCoeff));
22
+ }, nodeA);
23
+ return nodePolynomial;
24
+ }
25
+ /**
26
+ *
27
+ * @param nodePolynomial
28
+ * @returns for example: [nodeCoeffC, nodeCoeffB, nodeCoeffA] if nodePolynomial is a trinom
29
+ */
30
+ export function getArrNodeCoeffOfPolynomialNode(nodePolynomial) {
31
+ const arrNodeCoeff = [];
32
+ let nodeWork = nodePolynomial;
33
+ let counter = 0;
34
+ do {
35
+ const nodeVarX = "x".toTree();
36
+ const nodeCoeff = frac(nodeBySubstitutingVar(nodeWork, (0).toTree(), nodeVarX).simplify(), factorial(counter)).simplify();
37
+ arrNodeCoeff.push(nodeCoeff);
38
+ nodeWork = nodeWork.derivative().simplify();
39
+ counter++;
40
+ } while (nodeWork.evaluate({ x: 0 }) !== 0);
41
+ return arrNodeCoeff;
42
+ }
43
+ /**
44
+ *
45
+ * @param arrNodeCoeff
46
+ * @returns coeffN x^N + ... + coeff2 x^2 + coeff1 x^1 + coeff0
47
+ */
48
+ export function createNodeFPolynomialFromCoeffs(arrNodeCoeff) {
49
+ const nodeVarX = "x".toTree();
50
+ const nodePolynomial = arrNodeCoeff
51
+ .map((nodeCoeff, i) => {
52
+ switch (i) {
53
+ case 0:
54
+ return nodeCoeff;
55
+ case 1:
56
+ return multiply(nodeCoeff, nodeVarX);
57
+ default:
58
+ return multiply(nodeCoeff, power(nodeVarX, i));
59
+ }
60
+ })
61
+ .toReversed()
62
+ .reduce((acc, node) => add(acc, node));
63
+ return nodePolynomial;
64
+ }
65
+ /**
66
+ *
67
+ * @param arrNodeCoeff
68
+ * @returns discriminator
69
+ */
70
+ export function createNodeDiscriminator(arrNodeCoeff) {
71
+ const [nodeC, nodeB, nodeA] = arrNodeCoeff;
72
+ return substract(power(nodeB, 2), multiply(4, multiply(nodeA, nodeC)));
73
+ }
74
+ const tryToSimplify = (node, simplifyOptions) => {
75
+ try {
76
+ return node.simplify(simplifyOptions);
77
+ }
78
+ catch (_) {
79
+ return node;
80
+ }
81
+ };
82
+ export const getTexSolveSecondDegreeEquation = (nodePolynomial, opts = {
83
+ nodeVar: "x".toTree(),
84
+ isShouldApprox: false,
85
+ }) => {
86
+ const nodeVarX = "x".toTree();
87
+ const { nodeVar, isShouldApprox } = opts;
88
+ const arrNodeCoeff = getArrNodeCoeffOfPolynomialNode(nodePolynomial);
89
+ const nodePolynomialExpanded = createNodeFPolynomialFromCoeffs(arrNodeCoeff);
90
+ const degree = arrNodeCoeff.length - 1;
91
+ return `On veut résoudre l'équation :
92
+
93
+ $$
94
+ ${nodeBySubstitutingVar(nodePolynomialExpanded, nodeVar, nodeVarX).toTex()} = 0
95
+ $$
96
+
97
+ ${(() => {
98
+ if (degree === 2) {
99
+ const [_nodeC, nodeB, nodeA] = arrNodeCoeff;
100
+ const nodeDiscr = createNodeDiscriminator(arrNodeCoeff);
101
+ const discr = nodeDiscr.evaluate();
102
+ if (discr > 0) {
103
+ const [nodeX1, nodeX2] = [add, substract].map((addSub) => frac(addSub(opposite(nodeB), sqrt(tryToSimplify(nodeDiscr, {}))), multiply(2, nodeA)));
104
+ return `On a :
105
+
106
+ ${alignTex([
107
+ ["\\Delta", "=", nodeDiscr.toTex()],
108
+ ["\\Delta", "=", nodeDiscr.simplify().toTex()],
109
+ ["\\Delta", ">", "0"],
110
+ ])}
111
+
112
+ Les deux racines sont :
113
+
114
+ ${alignTex([
115
+ [`${nodeVar.name}_1`, "=", nodeX1.toTex()],
116
+ isShouldApprox
117
+ ? ["", "\\approx", round(nodeX1.evaluate(), 2).frenchify()]
118
+ : ["", "=", tryToSimplify(nodeX1, {}).toTex()],
119
+ [`${nodeVar.name}_2`, "=", nodeX2.toTex()],
120
+ isShouldApprox
121
+ ? ["", "\\approx", round(nodeX2.evaluate(), 2).frenchify()]
122
+ : ["", "=", tryToSimplify(nodeX2, {}).toTex()],
123
+ ])}
124
+
125
+ `;
126
+ }
127
+ else if (discr === 0) {
128
+ const nodeX = frac(opposite(nodeB), multiply(2, nodeA));
129
+ return `On a :
130
+
131
+ ${alignTex([
132
+ ["\\Delta", "=", nodeDiscr.toTex()],
133
+ ["\\Delta", "=", tryToSimplify(nodeDiscr, {}).toTex()],
134
+ ["\\Delta", "=", "0"],
135
+ ])}
136
+
137
+ Il y a une racine double :
138
+
139
+ ${alignTex([
140
+ [`${nodeVar.name}`, "=", nodeX.toTex()],
141
+ isShouldApprox
142
+ ? ["", "\\approx", round(nodeX.evaluate(), 2).frenchify()]
143
+ : ["", "=", tryToSimplify(nodeX, {}).toTex()],
144
+ ])}
145
+
146
+ `;
147
+ }
148
+ else {
149
+ return `On a :
150
+
151
+ ${alignTex([
152
+ ["\\Delta", "=", nodeDiscr.toTex()],
153
+ ["\\Delta", "=", tryToSimplify(nodeDiscr, {}).toTex()],
154
+ ["\\Delta", "<", "0"],
155
+ ])}
156
+
157
+ Il n'y a pas de solutions réelles.
158
+
159
+ `;
160
+ }
161
+ }
162
+ else if (degree === 1) {
163
+ const [nodeB, nodeA] = arrNodeCoeff;
164
+ const nodeX = frac(opposite(nodeB), nodeA);
165
+ return `On a :
166
+
167
+ ${alignTex([
168
+ [`${nodeVar.name}`, "=", nodeX.toTex()],
169
+ ["", "=", tryToSimplify(nodeX, {}).toTex()],
170
+ ])}
171
+
172
+ `;
173
+ }
174
+ else {
175
+ throw new Error("Unsupported degree: " + degree);
176
+ }
177
+ })()}
178
+
179
+ `;
180
+ };
181
+ export const getAnswerStuffSolveSecondDegreePolynomial = (nodePolynomial) => {
182
+ const arrNodeCoeff = getArrNodeCoeffOfPolynomialNode(nodePolynomial);
183
+ const degree = arrNodeCoeff.length - 1;
184
+ const arrNodeX = (() => {
185
+ if (degree === 2) {
186
+ const [nodeC, nodeB, nodeA] = arrNodeCoeff;
187
+ const nodeDiscr = substract(power(nodeB, 2), multiply(4, multiply(nodeA, nodeC)));
188
+ const discr = nodeDiscr.evaluate();
189
+ if (discr > 0) {
190
+ const [nodeX1, nodeX2] = [add, substract].map((addSub) => tryToSimplify(frac(addSub(opposite(nodeB), sqrt(nodeDiscr)), multiply(2, nodeA)), {}));
191
+ return [nodeX1, nodeX2];
192
+ }
193
+ else if (discr === 0) {
194
+ const nodeX = tryToSimplify(frac(opposite(nodeB), multiply(2, nodeA)), {});
195
+ return [nodeX];
196
+ }
197
+ else {
198
+ return [];
199
+ }
200
+ }
201
+ else if (degree === 1) {
202
+ const [nodeB, nodeA] = arrNodeCoeff;
203
+ const nodeX = tryToSimplify(frac(opposite(nodeB), nodeA), {});
204
+ return [nodeX];
205
+ }
206
+ else {
207
+ return [];
208
+ }
209
+ })();
210
+ const arrNodeXSortedAsc = arrNodeX.toSorted((nodeX1, nodeX2) => nodeX1.evaluate() - nodeX2.evaluate());
211
+ return {
212
+ nodePolynomial,
213
+ arrNodeX: arrNodeXSortedAsc,
214
+ };
215
+ };
216
+ export function createIntegratedPolynomialNode(nodePolynomial, nodeC) {
217
+ const arrNodeCoeff = getArrNodeCoeffOfPolynomialNode(nodePolynomial);
218
+ const nodeVarX = "x".toTree();
219
+ return arrNodeCoeff.reduce((acc, nodeCoeff, i) => {
220
+ const nodeTerm = frac(multiply(nodeCoeff, power(nodeVarX, i + 1)), i + 1);
221
+ return add(nodeTerm, acc).simplify();
222
+ }, nodeC);
223
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"seqArithmeticSituations.d.ts","sourceRoot":"","sources":["../../../../../src/math/utils/sequences/situations/seqArithmeticSituations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAiBlE,MAAM,MAAM,4BAA4B,GAAG;IACzC,cAAc,CAAC,EAAE,CACf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,OAAO,EAAE;;;;IAw4G9B,CAAC"}
1
+ {"version":3,"file":"seqArithmeticSituations.d.ts","sourceRoot":"","sources":["../../../../../src/math/utils/sequences/situations/seqArithmeticSituations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAiBlE,MAAM,MAAM,4BAA4B,GAAG;IACzC,cAAc,CAAC,EAAE,CACf,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,GAAG,SAAS,EAAE,OAAO,EAAE,KACpB,MAAM,CAAC;IAEZ,aAAa,EAAE,CACb,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,GAAG,SAAS,EAAE,OAAO,EAAE,KACpB,aAAa,CAAC;IAEnB,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,OAAO,EAAE,KAAK,MAAM,CAAC;IAChE,kBAAkB,EAAE,CAClB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,GAAG,SAAS,EAAE,OAAO,EAAE,KACpB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,cAAc,EAAE,CAAC,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;IACzE,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,aAAa,CAAC;CACpE,CAAC;AAEF,MAAM,MAAM,4CAA4C,GAAG;IACzD,cAAc,CAAC,EAAE,CACf,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,GAAG,SAAS,EAAE,OAAO,EAAE,KACpB,MAAM,CAAC;IAEZ,cAAc,EAAE,CACd,OAAO,EAAE,MAAM,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H,MAAM,gBACH,OAAO,EAAE;;;;;sCA2Bd,MAAM,UACP,MAAM,aACH,MAAM,gBACH,OAAO,EAAE;;;;;;;sCAiChB,MAAM,UACP,MAAM,aACH,MAAM,gBACH,OAAO,EAAE;;;;;sCAsCd,MAAM,UACP,MAAM,aACH,MAAM,gBACH,OAAO,EAAE;;;;;sCAoDd,MAAM,UACP,MAAM,aACH,MAAM,gBACH,OAAO,EAAE;;;;IAo4G9B,CAAC"}
@@ -193,7 +193,7 @@ const templatesSituationsArithmetic = [
193
193
  },
194
194
  getStrSituation: (initial, reason, firstRank, superfluousData) => {
195
195
  if (superfluousData === undefined) {
196
- return `On suppose qu'une plante, d'une hauteur initiale (jour $${firstRank.frPretty(2)}$) de $${initial.frPretty(2)}\\ \\textrm{cm}$,
196
+ return `On suppose qu'une plante, d'une hauteur initiale (jour $${firstRank.frenchify()}$) de $${initial.frPretty(2)}\\ \\textrm{cm}$,
197
197
  croît chaque jour de $${reason.frPretty(2)}\\ \\textrm{cm}$.
198
198
  On note $u_n$ la hauteur de la plante relevée le jour $n$, en $\\textrm{cm}$.`;
199
199
  }
@@ -202,7 +202,7 @@ On note $u_n$ la hauteur de la plante relevée le jour $n$, en $\\textrm{cm}$.`;
202
202
  case 0:
203
203
  {
204
204
  const [wateringPeriodInDays] = superfluousData.values;
205
- return `On suppose qu'une plante, d'une hauteur initiale (jour $${firstRank.frPretty(2)}$) de $${initial.frPretty(2)}\\ \\textrm{cm}$ et
205
+ return `On suppose qu'une plante, d'une hauteur initiale (jour $${firstRank.frenchify()}$) de $${initial.frPretty(2)}\\ \\textrm{cm}$ et
206
206
  arrosée en moyenne tous les $${wateringPeriodInDays.frPretty(2)}$ jours,
207
207
  croît chaque jour de $${reason.frPretty(2)}\\ \\textrm{cm}$.
208
208
  On note $u_n$ la hauteur de la plante relevée le jour $n$, en $\\textrm{cm}$.`;
@@ -212,7 +212,7 @@ On note $u_n$ la hauteur de la plante relevée le jour $n$, en $\\textrm{cm}$.`;
212
212
  {
213
213
  const [potDiameterInCm] = superfluousData.values;
214
214
  return `On suppose qu'on a mis une plante dans un pot de diamètre $${potDiameterInCm.frPretty(2)} \\ \\textrm{cm}$.
215
- La plante a alors une hauteur initiale (jour $${firstRank.frPretty(2)}$) de $${initial.frPretty(2)}\\ \\textrm{cm}$.
215
+ La plante a alors une hauteur initiale (jour $${firstRank.frenchify()}$) de $${initial.frPretty(2)}\\ \\textrm{cm}$.
216
216
  La plante croît chaque jour de $${reason.frPretty(2)}\\ \\textrm{cm}$.
217
217
  On note $u_n$ la hauteur de la plante relevée le jour $n$, en $\\textrm{cm}$.`;
218
218
  }
@@ -1189,7 +1189,7 @@ Par exemple, le montant de ses économies après $${target2.frPretty(2)}$ semain
1189
1189
  const target = rankAsked - firstRank;
1190
1190
  return `Quelle est la nature de la suite $u_n$ ?
1191
1191
 
1192
- Utilise le terme général de $u_n$ pour déterminer le montant des économies de Manon $${target.frPretty(2)}$ semaines après le début de septembre.`;
1192
+ Utilise le terme général de $u_n$ pour déterminer le montant des économies de Manon $${target.frenchify()}$ semaines après le début de septembre.`;
1193
1193
  },
1194
1194
  getCorrectionStuff: (initial, reason, _firstRank, ..._otherArgs) => {
1195
1195
  const target1 = 10;
@@ -1680,8 +1680,8 @@ Le niveau de charge est donc une suite arithmétique de premier terme $${initial
1680
1680
  },
1681
1681
  getStrSituation: (initial, reason, firstRank, superfluousData) => {
1682
1682
  if (superfluousData === undefined) {
1683
- return `Un gigantesque buffet est organisé. Au départ, sur les tables de service, il y a $${initial.frPretty(2)}$ amuse-bouches.
1684
- $${(-reason).frPretty(2)}$ amuse-bouches sont mangés toutes les minutes.
1683
+ return `Un gigantesque buffet est organisé. Au départ, sur les tables de service, il y a $${initial.frenchify()}$ amuse-bouches.
1684
+ $${(-reason).frenchify()}$ amuse-bouches sont mangés toutes les minutes.
1685
1685
  On note $u_n$ le nombre d'amuse-bouches restant après $${getStrFactor(firstRank)} \\ \\textrm{min}$.`;
1686
1686
  }
1687
1687
  else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AE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IAUpB;;OAEG;IACH,OAAO,qBAIL;IAEF,UAAU,qBAER;IACF,YAAY,IAAI,MAAM;IAItB,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM;IAgFrC,SAAS;IAkDT,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,YAAY,EAAE;IAyFrD,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAG5C,aAAa;;;;;;;;;IAYb,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAOtC,IAAI;IAGJ,cAAc;IACd,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,EAAE,GAAG,UAAQ,GAAG,aAAa;IAiK5D,mBAAmB,CAAC,IAAI,CAAC,EAAE,eAAe;IAM1C,mBAAmB;IAOnB,MAAM,CAAC,IAAI,EAAE,aAAa;IAU1B,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAQxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;CAMxD"}
@@ -249,7 +249,7 @@ export class MultiplyNode {
249
249
  // return multiply(this.leftChild.toMathjs(), this.rightChild.toMathjs());
250
250
  // }
251
251
  evaluate(vars) {
252
- return this.leftChild.evaluate(vars) * this.rightChild.evaluate(vars);
252
+ return round(this.leftChild.evaluate(vars) * this.rightChild.evaluate(vars), 12);
253
253
  }
254
254
  copy() {
255
255
  return new MultiplyNode(this.leftChild, this.rightChild, this.opts);
@@ -1 +1 @@
1
- {"version":3,"file":"substractNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/substractNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CA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AAE,eAAe;IAM/B,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAOpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAMxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;IAMvD,OAAO,uBAGL;CACH"}
@@ -5,6 +5,7 @@ import { opposite, OppositeNode } from "../functions/oppositeNode.js";
5
5
  import { add, AddNode } from "./addNode.js";
6
6
  import { coinFlip } from "../../../utils/alea/coinFlip.js";
7
7
  import { colorize } from "../../../utils/latex/colorize.js";
8
+ import { round } from "../../../math/utils/round.js";
8
9
  export function isSubstractNode(a) {
9
10
  return isOperatorNode(a) && a.id === OperatorIds.substract;
10
11
  }
@@ -86,7 +87,7 @@ export class SubstractNode {
86
87
  return this.toTex();
87
88
  }
88
89
  evaluate(vars) {
89
- return this.leftChild.evaluate(vars) - this.rightChild.evaluate(vars);
90
+ return round(this.leftChild.evaluate(vars) - this.rightChild.evaluate(vars), 12);
90
91
  }
91
92
  // toMathjs() {
92
93
  // return subtract(this.leftChild.toMathjs(), this.rightChild.toMathjs());
@@ -0,0 +1,6 @@
1
+ import { AlgebraicNode } from "../nodes/algebraicNode.js";
2
+ export declare abstract class NodeUtils {
3
+ static getDepth: <T extends AlgebraicNode>(algebraicNode: T) => number;
4
+ static getChildren(algebraicNode: AlgebraicNode): AlgebraicNode[];
5
+ }
6
+ //# sourceMappingURL=nodeUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeUtils.d.ts","sourceRoot":"","sources":["../../../src/tree/utilities/nodeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAI1D,8BAAsB,SAAS;IAC7B,MAAM,CAAC,QAAQ,GAAI,CAAC,SAAS,aAAa,EAAE,eAAe,CAAC,KAAG,MAAM,CASnE;IAEF,MAAM,CAAC,WAAW,CAAC,aAAa,EAAE,aAAa;CAShD"}
@@ -0,0 +1,24 @@
1
+ import { isFunctionNode } from "../nodes/functions/functionNode.js";
2
+ import { isOperatorNode } from "../nodes/operators/operatorNode.js";
3
+ export class NodeUtils {
4
+ static getDepth = (algebraicNode) => {
5
+ const children = this.getChildren(algebraicNode);
6
+ if (children.length === 0) {
7
+ return 0;
8
+ }
9
+ else {
10
+ return (1 + Math.max(...children.map((nodeChild) => this.getDepth(nodeChild))));
11
+ }
12
+ };
13
+ static getChildren(algebraicNode) {
14
+ if (isOperatorNode(algebraicNode)) {
15
+ return [algebraicNode.leftChild, algebraicNode.rightChild];
16
+ }
17
+ else if (isFunctionNode(algebraicNode)) {
18
+ return [algebraicNode.child];
19
+ }
20
+ else {
21
+ return [];
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=prependArticle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prependArticle.d.ts","sourceRoot":"","sources":["../../../src/utils/strings/prependArticle.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "math-exercises",
3
3
  "type": "module",
4
- "version": "3.0.178",
4
+ "version": "3.0.180",
5
5
  "description": "Math exercises generator for middle school and high school",
6
6
  "main": "lib/index.js",
7
7
  "files": [