Teaching Algebraic Expressions with Tracking Arithmetic

An 8 x 6 rectangle with rounded corners of radius 1

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)
A smorgasbord of rounded rectangles using a general formula.

--

--

--

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.

Recommended from Medium

CS371p Spring 2021 Week 3

The Most Common 3D File Formats

Using Query Rescore — ElasticSearch

TDD in Flutter Part 3: Testing your widgets

Life is a journey of twists and turns, peaks and valleys, mountains to climb and oceans to explore.

On Linux Netlink

A case study of contributing to a Terraform Provider

How you can point your Google domain to an S3 bucket

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Chris Smith

Chris Smith

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

More from Medium

Introducing OrgFlow’s New Snapshots and Rollback Feature

Marty McFly (Michael J. Fox) in front of the flying DeLorean time machine from Back To the Future

Arduino Morse Encoder — Part 2: WiFi extension

Contracts and Shared Records Are Going to Blockchain. Are You Keeping Up?