Adding and Subtracting Fractions with Like and Unlike Denominators

Adding and Subtracting Fractions with Like and Unlike Denominators
Loading the math board and drawing, please wait…
2023-05-30 22:49
This example demonstrates adding and subtracting fractions with like and unlike denominators using a number line and interactive area models. It shows how to use models and pictures to explain the process and record the results. The example uses commands such as RandomUniform, Take, Element, If, Remove, Min, Max, PixelsToPoint, Sequence, Point, Numerator, Denominator, Mod, Polygon, Flatten, Vector, Zip, Join, Corner, PointToPixels, Translate, Segment, Text. Suitable for 4-5 grade students to learn adding and subtracting fractions and mixed numbers.

GeoGebra Commands & Parameters

  1. RandomUniform(0, 0.99, 200) → allRandomSeeds, {0.8819549171902377, 0.7839227597875107, 0.5885739173243362, 0.35688808870371314, 0.14699979483365885, 0.7203370503205309, 0.5421706189015314, 0.26007554442469644, 0.5069722313904086, 0.5402904061410444, 0.7124188600297885, 0.248289764945615, 0.39740508790627627, 0.554487950878196, 0.1950956043585404, 0.5150736139779096, 0.5559657631180086, 0.5266404941174392, 0.7411567190300394, 0.17260757109649313, 0.7799765701262624, 0.8556187673885347, 0.27333923991304626, 0.1276171281278989, 0.81493820942269, 0.12097945264792817, 0.7487160423857004, 0.16023836808512748, 0.08739933767083216, 0.6214928653189897, 0.6906780244572683, 0.2968149572855948, 0.3241390985995963, 0.7667221427463032, 0.07291014227203466, 0.767237182476234, 0.9466887494508995, 0.13806087802185338, 0.4104582471201836, 0.8480110355794895, 0.8757176535308915, 0.4279314939713765, 0.23894868651571952, 0.95375793887351, 0.8437438597059059, 0.8040787679290738, 0.30242879142264206, 0.5922978649134029, 0.8570027167688968, 0.1300629159416832, 0.1631366405423781, 0.8018563994640551, 0.1481174418291301, 0.2131641121684015, 0.4627887125691146, 0.08326320365600813, 0.14046400010265084, 0.3769554325071177, 0.9346904319248793, 0.7852724030643269, 0.44280728844558087, 0.007782879220801726, 0.5091291889953226, 0.5873371743117177, 0.3389097806624269, 0.13231227173416144, 0.10110068233305457, 0.44130876525452417, 0.37137360922195684, 0.707159040687846, 0.7194495857483831, 0.2616071757320607, 0.8319751809107528, 0.4114125863946256, 0.17997138645090494, 0.532423791816135, 0.4221872925675935, 0.5285991151392904, 0.15192732670769085, 0.6604674875416383, 0.1274563389763332, 0.9162966766869052, 0.9277654653718578, 0.16265489245281103, 0.5971133437567224, 0.6192236856904856, 0.009621202582045798, 0.3099709154574156, 0.488544614055499, 0.17516701684602332, 0.5833857995502904, 0.36149012161603883, 0.8994346713150783, 0.5525983349553416, 0.9617878338194759, 0.8462498003638487, 0.14551587517496276, 0.9842470516873482, 0.8620219859910966, 0.15530524405688662, 0.9633205710815496, 0.8622559726398208, 0.21099107026283312, 0.971873142360545, 0.22792939422032124, 0.42784019013353447, 0.8221922124224342, 0.10398302653202833, 0.3446446445994989, 0.921602918284856, 0.282683714764244, 0.2615077010984195, 0.34089108910501575, 0.4298309543934959, 0.6164100136885623, 0.8078325524393443, 0.250456951189008, 0.5272007808083443, 0.1814418025320602, 0.445749476945527, 0.5164357191210148, 0.7873706012018388, 0.743405590774825, 0.9674250321529766, 0.8019151524829004, 0.9199163424575415, 0.19553037348282373, 0.9594934269224575, 0.7885829332435027, 0.244989446702331, 0.4873314650777703, 0.8164639869699672, 0.05297885131573664, 0.23593179124057154, 0.39898121278236165, 0.6387082551368906, 0.7781214710117668, 0.7248778942126204, 0.4668818754176847, 0.16530649334452244, 0.2446726434843402, 0.4071072070293129, 0.8678617107546956, 0.8669834456822373, 0.9306767486819383, 0.17657862511209418, 0.6047560075777552, 0.3402529153814694, 0.2922215900720383, 0.20768782980424555, 0.9849146313679229, 0.770716004696325, 0.3691159311197566, 0.3468317971925247, 0.9153944122346138, 0.7412222769576614, 0.2798647690005923, 0.8718480373617424, 0.4042486854593097, 0.0593037328695361, 0.42884564099219014, 0.5778158508588137, 0.8764185609190529, 0.787930413775981, 0.4256507683995801, 0.46406417002242784, 0.5352593807375366, 0.6042125762351815, 0.42205676715374935, 0.4695256568783557, 0.3267028737434456, 0.4521881378575192, 0.9860204042773846, 0.9518088303881909, 0.70245981606602, 0.07828489865974195, 0.1444710295893115, 0.8295306429467115, 0.13150935293652716, 0.741436503144056, 0.9074809750241145, 0.6975582277287161, 0.2154014157665573, 0.9241561132246363, 0.12564415374126026, 0.5008547139049326, 0.11261414854599752, 0.7961366628790396, 0.21017691479435044, 0.774605246677646, 0.010363880515256142, 0.7481468183362193, 0.7713802747023831, 0.7662203447136069, 0.8988559026826833, 0.39113097225077714, 0.44566151972770524, 0.29867017124689876, 0.7429942989374749, 0.7734974848236994}
  2. Take(allRandomSeeds, randIndex, randIndex + numRandoms - 1) → currentRandomSeeds
  3. Element(denAOps, denIndex) → denA
  4. If(denA ≟ 4, Element[{1, 3}, 1 + floor((currentRandomSeeds(2) * 2))], 1 + floor((currentRandomSeeds(2) * (denA - 1)))) → numerA
  5. Element(denBOps, denIndex) → denB
  6. Remove(Element[{{}, {1}, {1, 2}, {1, 3}, {1, 2, 3, 4}, {}, {1, 2, 3, 4, 5, 6}}, denB], If[sameDen, {numerA}, {}]) → possibleNumerB
  7. Element(possibleNumerB, 1 + floor((currentRandomSeeds(3) * Length[possibleNumerB]))) → numerB
  8. Min(numberA, numberB) → numberRight
  9. Max(numberA, numberB) → numberLeft
  10. If(isSubtract, numberLeft - numberRight, numberLeft + numberRight) → answerVal
  11. PixelsToPoint((xMin, yMin), (xMax, yMax), (800, 500), (50, layoutB)) → AnchorLineA
  12. Sequence(AnchorLineA + ((tickIncrement * A), 0), A, 0, (studentDen * 5)) → tickPositions
  13. Sequence((A * 1 / studentDen), A, 1, Length[tickPositions]) → possibleValues, {0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5}
  14. Point(tickPositions) → studentPoint
  15. PixelsToPoint((xMin, yMin), (xMax, yMax), (800, 500), (layoutXHint, layoutHint)) → HintAnchor
  16. Min((x(AnchorLineB) - x(HintAnchor) - (5 * gap)) / maxBlocks - gap, 4) → unitSize
  17. If(numberA > numberB, 1, 2) → indexLeft
  18. Element({numerA, numerB}, indexLeft) → numPartsLeft
  19. If(indexLeft ≟ 1, 2, 1) → indexRight
  20. Element({numerA, numerB}, indexRight) → numerRight
  21. Element({numerB, numerA}, indexRight) → numerLeft
  22. Element({denA, denB}, indexRight) → denRight
  23. Element({denA, denB}, indexLeft) → denLeft
  24. If(animateControl ≟ animateCount, 1, animateControl - floor(animateControl)) → animateCurrent
  25. Element({numUnitsA, If[testSum ≥ 5 ∧ (¬isSubtract), numUnitsB - 1, numUnitsB]}, indexRight) → numUnitsRight
  26. Element({numUnitsA, numUnitsB}, indexLeft) → numUnitsLeft
  27. If(sameDen, numerRight, (numerRight * denLeft)) → numCommonRight
  28. If(isBorrow, numUnitsLeft - 1, numUnitsLeft) → numUnitsLeft2
  29. If(animateCount < slideIndex, 0, If[animateCount > slideIndex, 1, animateCurrent]) → animateSlide
  30. If(sameDen, denLeft, (denLeft * denRight)) → denCommon
  31. Numerator(answerVal) → answerNumer
  32. Denominator(answerVal) → answerDen
  33. Mod(answerNumer, answerDen) → answerRemainder
  34. Element({numerA, numerB}, indexRight) → numPartsRight
  35. Polygon({(0, 0), (0, unitSize), (unitSize, unitSize), (unitSize, 0)}) → templateUnitBox
  36. Sequence(AnchorLeft + ((K * spacing), 0), K, 0, 2) → anchorsLeft
  37. Flatten(Sequence[Sequence[AnchorSolnParts + ((i * unitSize / denLeft), (j * unitSize / If[sameDen, 1, denRight])), i, 0, denLeft - 1], j, 0, (2 * denRight)]) → anchorSolnPartsAll
  38. Vector(anchorSolnPartsAll(1), anchorSolnUnits(numUnitsSoln)) → vCarry
  39. If(animateCount < fade2Index + 1, 0, If[animateCount ≟ fade2Index + 1, animateCurrent, 1]) → animateCarry
  40. Sequence(AnchorRight + ((K * spacing), 0), K, 0, 2) → anchorsRight
  41. If(sameDen, 0, If[animateCount ≤ 3, 0, If[animateCount < 5, animateCurrent, 1]]) → animateStage1b
  42. If(sameDen, Polygon[{(0, 0), (unitSize / denRight, 0), (unitSize / denRight, unitSize), (0, unitSize)}], Polygon[{(0, 0), (unitSize, 0), (unitSize, unitSize / denRight), (0, unitSize / denRight)}]) → templatePartRight
  43. Sequence(anchorsRight(3) + If[sameDen, ((A * unitSize / denRight), 0), (0, (A * unitSize / denRight))], A, 0, denRight - 1) → anchorRightParts
  44. Zip(Translate[templatePartRight, A], A, anchorRightParts) → outlinePartsRight
  45. Flatten(Sequence[Sequence[anchorsRight(3) + ((i * unitSize / denLeft), (j * unitSize / denRight)), i, 0, If[sameDen, numerRight - 1, denLeft - 1]], j, 0, If[sameDen, 0, numerRight - 1]]) → anchorRightPartsCD
  46. Flatten(Sequence[Sequence[anchorsLeft(2) + ((i * unitSize / denLeft), (j * unitSize / denRight)), i, 0, denLeft - 1], j, 0, If[sameDen, 0, denRight - 1]]) → anchorLeftPartsBorrow
  47. Join({Flatten[Sequence[Sequence[anchorsLeft(3) + ((i * unitSize / denLeft), (j * unitSize / denRight)), i, 0, numerLeft - 1], j, 0, If[sameDen, 0, denRight - 1]]], If[isBorrow, anchorLeftPartsBorrow, {}]}) → anchorLeftPartsCD
  48. Take(anchorSolnPartsAll, 1, Length[anchorLeftPartsCD] + If[caseNum ≟ caseSUBTRACT, 0, Length[anchorRightPartsCD]]) → anchorSolnPartsCurrent
  49. If(animateCount < fade1Index + numUnitsRight, 0, If[animateCount ≥ fade1Index + numUnitsRight + numCommonRight, numCommonRight + If[animateCount ≥ fade2Index, 1, 0], animateCount - fade1Index - numUnitsRight]) → moveRightPart
  50. Polygon({(0, 0), (unitSize / denLeft, 0), (unitSize / denLeft, unitSize / If[sameDen, 1, denRight]), (0, unitSize / If[sameDen, 1, denRight])}) → templateCommon
  51. Vector(anchorSolnPartsCurrent(If[isSubtract, numCommonLeft - moveRightPart + 1, numCommonLeft + moveRightPart]) - anchorRightPartsCD(moveRightPart)) → vMovePartRight
  52. If(animateCount - sizeStageA ≤ 0, 0, If[animateCount - sizeStageA ≤ numUnitsLeft2, animateCount - sizeStageA, numUnitsLeft2 + 1]) → moveLeftUnit
  53. If(animateCount - sizeStageA ≤ moveLeftUnit, 0, If[moveLeftUnit < animateCount - sizeStageA ≤ moveLeftUnit + numCommonLeft, animateCount - sizeStageA - moveLeftUnit, numCommonLeft]) → moveLeftPart
  54. Sequence(anchorsRight(2 - A), A, 0, numUnitsRight - 1) → anchorUnitsRight
  55. If(animateCount ≤ fade1Index, 0, If[fade1Index < animateCount ≤ fade1Index + numUnitsRight, animateCount - fade1Index, numUnitsRight]) → moveRightUnit
  56. Sequence(anchorsLeft(2 - A), A, 0, numUnitsLeft - 1) → anchorUnitsLeft
  57. If(isBorrow, Element[{{}, {anchorUnitsLeft(2)}}, numUnitsLeft], anchorUnitsLeft) → anchorUnitsLeft2
  58. If(isSubtract, "\minus", "\plus") → caseOperator
  59. If(sameDen, "", (((((((((("\text{ \dfrac{" * fracLeftnumer) * "}{") * answerDen) * "} ") * caseOperator) * " \dfrac{") * fracRightNumer) * "}{") * answerDen) * "} = }")) → commonDenText
  60. If(answerNumer < answerDen, "", (((("\text{ \dfrac{" * answerNumer) * "}{") * answerDen) * "} = }")) → improperText
  61. Vector(anchorSolnUnits(moveLeftUnit) - anchorUnitsLeft2(moveLeftUnit)) → vMoveLeftUnit
  62. If(sameDen, 0, 2) → lengthMoveBars
  63. If(sameDen, 0, 1) → denCase
  64. Corner(5) → layoutAppSize
  65. PointToPixels(Corner[onboardingDisplayText, 2], Corner[1], Corner[3], Corner[5]) → layoutOnboarding
  66. If(sameDen, "") → makeCommonDen
  67. Sequence(anchorsLeft(3) + (A, 0), A, 0, unitSize - unitSize / denLeft, unitSize / denLeft) → anchorLeftParts
  68. If(animateControl < 4, 0, animateControl - floor(animateControl)) → animateUnitBox
  69. Vector(anchorSolnUnits(If[isSubtract, numUnitsLeft2 - moveRightUnit + 1, numUnitsLeft2 + moveRightUnit]) - anchorUnitsRight(moveRightUnit)) → vMoveRightUnit
  70. Translate(templateUnitBox, anchorUnitsRight(moveRightUnit) + (animateCurrent * vMoveRightUnit)) → moveUnitRight
  71. Translate(templateUnitBox, anchorUnitsLeft2(moveLeftUnit) + (animateCurrent * vMoveLeftUnit)) → moveUnitLeft
  72. Element({If[sameDen, answerNumer, 2 + answerNumer] + 1, lengthMoveBars + 2 + numUnitsA + numUnitsB}, caseNum) → lengthSlider
  73. Polygon({(0, 0), (unitSize / denLeft, 0), (unitSize / denLeft, unitSize), (0, unitSize)}) → templatePartLeft
  74. Zip(Translate[templatePartLeft, A], A, Take[anchorLeftParts, 1, denLeft]) → outlinePartsLeft
  75. Zip(Translate[templatePartLeft, A], A, Take[anchorLeftParts, 1, numPartsLeft]) → fracPartsLeft
  76. Zip(Translate[templateUnitBox, A], A, anchorUnitsLeft) → unitBoxesLeft
  77. Zip(Translate[templateUnitBox, A], A, anchorUnitsRight) → unitBoxesRight
  78. If(animateCount < fade1Index ∨ (¬isSubtract), 0, If[animateCount > fade1Index, 1, animateCurrent]) → animateFade1
  79. If(animateCount < fade2Index, 0, If[animateCount > fade2Index, 1, animateCurrent]) → animateFade2
  80. Zip(Translate[templateUnitBox, A], A, Take[anchorSolnUnits, 1, numUnitsSoln]) → solnUnitBoxesFinal
  81. If(sameDen, 0, If[animateCount ≤ 1, 0, If[animateCount < 3, animateCurrent, 1]]) → animateStage1a
  82. Zip(Translate[A, (animateStage1a * (AnchorRight - AnchorLeft))], A, outlinePartsLeft) → barsLeft
  83. Zip(Translate[A, (animateStage1b * (AnchorLeft - AnchorRight))], A, outlinePartsRight) → barsRight
  84. Zip(Translate[templatePartRight, A], A, Take[anchorRightParts, 1, numerRight]) → fracPartsRight
  85. Zip(Translate[templateUnitBox, A], A, Join[{anchorUnitsLeft, anchorUnitsRight, {anchorsLeft(3), anchorsRight(3)}}]) → outlineUnits
  86. Translate(templateCommon, anchorRightPartsCD(moveRightPart) + (animateCurrent * vMovePartRight)) → movePartRight
  87. Translate(templateCommon, anchorLeftPartsCD(moveLeftPart) + (animateCurrent * vMoveLeftPart)) → movePartLeft
  88. If(isSubtract, numCommonLeft, numCommonLeft + 1) → indexStage3B
  89. If(moveRightUnit > 1 ∨ animateCount > numUnitsRight + fade1Index, Sequence[Translate[templateUnitBox, Vector[anchorSolnUnits(numUnitsLeft2 - A + 1)]], A, 1, If[animateCount > fade1Index + numUnitsRight, numUnitsRight, moveRightUnit - 1]], {}) → solnUnitBoxesRightSubtract
  90. If(moveRightUnit > 1 ∨ animateCount > numUnitsRight + fade1Index, Sequence[Translate[templateUnitBox, Vector[anchorSolnUnits(numUnitsLeft2 + A)]], A, 1, If[animateCount > fade1Index + numUnitsRight, numUnitsRight, moveRightUnit - 1]], {}) → solnUnitBoxesRight
  91. Zip(Translate[templateCommon, A], A, Reverse[Take[anchorSolnPartsCurrent, numCommonLeft + 2 - moveRightPart]]) → solnPartBoxesRightSubtract
  92. Zip(Translate[templateCommon, A], A, Take[anchorLeftPartsCD, moveLeftPart + 1]) → remainingLeftParts
  93. Zip(Translate[templateUnitBox, A], A, Take[anchorUnitsLeft2, moveLeftUnit + 1]) → remainingLeftUnits
  94. Zip(Translate[templateUnitBox, A], A, Take[anchorUnitsRight, moveRightUnit + 1]) → remainingRightUnits
  95. Translate(templateUnitBox, anchorSolnPartsAll(1) + (If[Defined[IndexOf[answerVal, {1, 2, 3}]], 0, animateCarry] * vCarry)) → unitCarry
  96. If(sameDen, 0, 5) → startStage1c
  97. If(¬isBorrow, 0, If[animateCount < startStage1c, 0, If[animateCount ≤ startStage1c + 1, animateCurrent, 1]]) → animateStage1c
  98. Zip(Translate[templateUnitBox, A], A, Take[anchorSolnUnits, 1, moveLeftUnit - 1]) → solnUnitsLeft
  99. Zip(Translate[templateCommon, A], A, Take[anchorSolnPartsCurrent, 1, Min[numCommonLeft, animateCount - sizeStageA - numUnitsLeft2 - 2]]) → solnPartBoxesLeft
  100. Zip(Translate[templateCommon, A], A, Take[anchorSolnPartsCurrent, numCommonLeft + 1, numCommonLeft + moveRightPart - 1]) → solnPartBoxesRightAdd
  101. Zip(Translate[templateCommon, A], A, Take[anchorRightPartsCD, moveRightPart + 1]) → remainingRightParts
  102. Zip(Translate[templateUnitBox, A], A, Take[anchorSolnUnits, 1, numUnitsSoln - If[isCarry, 1, 0]]) → solnUnitsFinal
  103. Zip(Translate[templateCommon, A - If[isCarry, (0, (-unitSize) + (animateCarry * unitSize)), (0, 0)]], A, Take[anchorSolnPartsAll, 1, numPartsSoln]) → solnPartsFinal
  104. PointToPixels(AnchorLineA, Corner[1], Corner[3], Corner[5]) → LineStartPX
  105. Segment(AnchorLineA - (1, 0), AnchorLineB + (1, 0)) → numberLine
  106. Zip(Segment[A - (0, 0.2), A + (0, 0.2)], A, tickPositions) → smallTicks
  107. Sequence(Text[("" * Element[{0, 1, 2, 3, 4, 5}, A + 1]), tickPositions((A * studentDen) + 1) + (0, 1), true, true, 0, 0], A, 0, 5, 1) → lblLine
  108. Text(("" * MixedNumber[numberLeft]), LblPosLeft, true, true, 0, 0) → lblLeft
  109. Text(("" * MixedNumber[numberRight]), LblPosRight, true, true, 0, 0) → lblRight
  110. Text(("" * caseOperator), Midpoint[LblPosLeft, LblPosRight], true, true, 0, 0) → opHint
  111. circlePixels(studentPoint, 7 + (7 * pulsing), Corner[1], Corner[3], Corner[5]) → pulsingPoint
  112. Element({(AnchorSolnParts * 1), anchorSolnUnits(1), anchorSolnUnits(2)}, Min[2, numUnitsSoln] + 1) → FirstSolnPoint
  113. Element({-2, -1, 0}, ceil(numberLeft)) → test
  114. Text(caseOperator, AnchorLeft + ((3.25 * unitSize) + (2 * gap), (0.5 * unitSize)), true, true, 0, 0) → hintOperator
  115. Text("=", AnchorRight + ((3.25 * unitSize) + (2 * gap), (0.5 * unitSize)), true, true, 0, 0) → hintEqual
  116. Sequence(Segment[tickPositions(A + 1) - (0, 0.3), tickPositions(A + 1) + (0, 0.3)], A, 0, (5 * studentDen), studentDen) → bigTicks

AI Drawing Prompt Reference

Draw a horizontal number line with evenly spaced tick marks showing several candidate values. Under the number line, place two area-model grids made of equal unit squares to represent two fractions. On the left grid, subdivide using the first denominator and highlight the number of squares equal to its numerator. On the right grid, subdivide using the second denominator and highlight the corresponding fraction of squares. If the denominators match, align and combine the highlighted parts directly; if they differ, subdivide to a common denominator so both models line up square-for-square before combining or removing depending on whether the operation is addition or subtraction. Finally, indicate the resulting fraction on the diagram and keep the visual alignment between the models and the number line.
The prompt above was compiled from the original drawing commands and is for reference only.