Students build upon their understanding of booleans and simple inequalities to compose compound inequalities using the concepts of union and intersection.

Lesson Goals

Students will be able to:

• Understand how the conjunctions and and or differ

• Describe how functions can work together

• Describe the solution set of a compound inequality

Student-Facing Lesson Goals

• I can explain the difference between how and and or are used in programming

• I can use two or more inequalities together and describe the area they enclose

Materials

Preparation

• Make sure all materials have been gathered

• Decide how students will be grouped in pairs

Language Table

 Types Functions Values Number +, -, *, /, num-expt, num-sqr, num-sqrt 4, -1.2, 2/3, pi String string-length, string-repeat, string-contains "hello", "91" Boolean <, >, <>, <=, >=, <, >, ==, <>, >=, and, or true, false Image star, triangle, circle, square, rectangle, rhombus, ellipse, regular-polygon, radial-star, text, overlay, above, beside, rotate, scale, flip-horizontal, flip-vertical 🔵🔺🔶
Glossary
function

a mathematical object that consumes inputs and produces an output

intersection

the set of values that makes both inequalities true

union

the set of values that makes either or both of a set of inequalities true

🔗Introducing Compound Inequalities

Overview

Students consider the need to compose inequalities, and think about how to write them.

Launch

We use inequalities for lots of things:

• Is it hot out? (temperature > 80°$\displaystyle temperature \gt 80°$)

• Did I get paid enough for painting that fence? (paid \ge $100$\displaystyle paid \ge 100$) • Are the cookies finished baking? (timer = 0$\displaystyle timer = 0$) Have students come up with other examples. Many times we need to combine inequalities: • Should I go to the beach? (temperature > 80°$\displaystyle temperature \gt 80°$ and weather = "sunny"$\displaystyle weather = "sunny"$) • Was this burrito worth the price? (taste = "delicious"$\displaystyle taste = "delicious"$ and price ≤$15$\displaystyle price \leq 15$)

Have students come up with other examples.

Guide students through other examples of and and or with various statements, such as "I’m wearing a red shirt AND I’m a math teacher, true or false?" or "I’m an NBA basketball star OR I’m having pizza for lunch, true or false?". This can make for a good sit-down, stand-up activity, where students take turns saying compound boolean statements and everyone stands if that statement is true for them.

Investigate

Both mathematics and programming have ways of combining - or composing - inequalities.

Synthesize

Be really careful to check for understanding here.

• Expressions using and only produce true if both of their sub-expressions are true.

• Expressions using or produce true if either of their sub-expressions are true.

 Strategies for English Language Learners When describing compound inequalities, be careful not to use "english shortcuts". For example, we might say "I am holding a marker and an eraser" instead of "I am holding a marker and I am holding an eraser." These sentences mean the same thing, but the first one obscures the fact that "and" joins two complete phrases. For ELL/ESL students, this is unecessarily adds to cognitive load!

🔗Solutions and Non-Solutions of Compound Inequalities

Launch

Have students identify 4 solutions and 4 non-solutions for each of the following inequalities.

• x > 5$\displaystyle x \gt 5$

• x \le 15$\displaystyle x \le 15$

What about the solution set of x > 5$\displaystyle x \gt 5$ and x \le 15$\displaystyle x \le 15$? What numbers make both of these inequality expressions true?

How would that be different from x > 5$\displaystyle x \gt 5$ or x \le 15$\displaystyle x \le 15$? What numbers make at least one of these inequality expressions true?

Investigate

Have students log in to the Compound Inequalities Starter File (Pyret), read the code carefully and click run to see the graphs they’ve just considered.

This starter file includes two special functions.

and-intersection takes in two functions and a list of numbers and produces a graph with the points and the shaded intersection of values that make both of the inequalities true.

fun gt5​(​x​): x > 5 end

fun lte15​(​x​): x <= 15 end

and-intersection​(​gt5, lte15, [list: -5, -2.1, 0, 5, 10, 39/5, 15, 20]​)

fun lt5​(​x​): x < 5 end

fun gte15​(​x​): x >= 15 end

and-intersection​(​lt5, gte15, [list: -5, -2.1, 0, 5, 10, 39/5, 15, 20]​)

Note: Some pairs of inequalities do not intersect at all and therefore have no solutions.

or-union takes in two functions and a list of numbers and produces a graph with the points and the shaded union of values that make either or both of the inequalities true.

fun lt5​(​x​): x < 5 end

fun gte15​(​x​): x >= 15 end

or-union​(​lt5, gte15, [list: -5, -2.1, 0, 5, 10, 39/5, 15, 20]​)

fun gt5​(​x​): x > 5 end

fun lte15​(​x​): x <= 15 end

or-union​(​gt5, lte15, [list: -5, -2.1, 0, 5, 10, 39/5, 15, 20]​)

Note: Some unions, like the one below, include all real numbers; they have have infinite solutions that satisfy at least one of the inequalities.

Turn to Compound Inequalities: Solutions & Non-Solutions (Page 70) and explore the compound inequalities listed using the Compound Inequalities Starter File , identifying solutions and non-solutions for each.

Instead of defining two functions as simple inequalities, we could produce the same graph by defining one function to be a compound inequality.

fun fiveto15​(​x​): (​x > 5​) and (​x <= 15​) end inequality​(​fiveto15, [list: -5, -2.1, 0, 5, 10, 12, 15, 20]​)

Turn to Compound Inequality Functions (Page 71) and have students write code to describe the compound inequalities pictured.

If you have time, have students open to Matching Compound Inequality Functions and plots (Desmos)

Synthesize

• How did the graphs of intersections and unions differ?