# Teaching Algebraic Expressions with Tracking Arithmetic

## Step 1: Solve an easy instance.

• 4 line segments — one from (-3, 3) to (3, 3) for the top; one from (-3, -3) to (3, -3) for the bottom, one from (-4, 2) to (-4, -2) for the left side, and one from (4, 2) to (4, -2) for the right side.
• Four arcs for the corners — one from 0° to 90° centered at (3, 2); one from 90° to 180° centered at (-3, 2); one from 180° to 270° centered at (-3, -2); and one from 270° to 360° centered at (3, -2). Each arc has a radius of 1 unit.
`pic = polyline([(-3,  3), ( 3,  3)])    & polyline([(-3, -3), ( 3, -3)])    & polyline([(-4, -2), (-4,  2)])    & polyline([( 4, -2), ( 4,  2)])    & translated(arc(  0,  90, 1),  3,  2)    & translated(arc( 90, 180, 1), -3,  2)    & translated(arc(180, 270, 1), -3, -2)    & translated(arc(270, 360, 1),  3, -2)`

## Step 2: Solve an instance with “weird” numbers.

`pic = polyline([(-5.5,  4), ( 5.5,  4)])    & polyline([(-5.5, -4), ( 5.5, -4)])    & polyline([(-6.5, -3), (-6.5,  3)])    & polyline([( 6.5, -3), ( 6.5,  3)])    & translated(arc(  0,  90, 1),  5.5,  3)    & translated(arc( 90, 180, 1), -5.5,  3)    & translated(arc(180, 270, 1), -5.5, -3)    & translated(arc(270, 360, 1),  5.5, -3)`

## Step 3: Solve the same problem without doing arithmetic.

`pic = polyline([(-13/2 + 1,  8/2    ), ( 13/2 - 1,  8/2    )])    & polyline([(-13/2 + 1, -8/2    ), ( 13/2 - 1, -8/2    )])    & polyline([(-13/2,     -8/2 + 1), (-13/2,      8/2 - 1)])    & polyline([( 13/2,     -8/2 + 1), ( 13/2,      8/2 - 1)])    & translated(arc(  0,  90, 1),  13/2 - 1,  8/2 - 1)    & translated(arc( 90, 180, 1), -13/2 + 1,  8/2 - 1)    & translated(arc(180, 270, 1), -13/2 + 1, -8/2 + 1)    & translated(arc(270, 360, 1),  13/2 - 1, -8/2 + 1)`

## Step 4: Replace the special numbers with variables.

`roundedRect(w, h, r)    = polyline([(-w/2 + r,  h/2    ), ( w/2 - r,  h/2    )])    & polyline([(-w/2 + r, -h/2    ), ( w/2 - r, -h/2    )])    & polyline([(-w/2,     -h/2 + r), (-w/2,      h/2 - r)])    & polyline([( w/2,     -h/2 + r), ( w/2,      h/2 - r)])    & translated(arc(  0,  90, r),  w/2 - r,  h/2 - r)    & translated(arc( 90, 180, r), -w/2 + r,  h/2 - r)    & translated(arc(180, 270, r), -w/2 + r, -h/2 + r)    & translated(arc(270, 360, r),  w/2 - r, -h/2 + r)`

--

--

--

## More from Chris Smith

Software engineer, volunteer K-12 math and computer science teacher, author of the CodeWorld platform, amateur ring theorist, and Haskell enthusiast.

Love podcasts or audiobooks? Learn on the go with our new app.

## Chris Smith

Software engineer, volunteer K-12 math and computer science teacher, author of the CodeWorld platform, amateur ring theorist, and Haskell enthusiast.