(Also available in Pyret)
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:

StudentFacing Lesson Goals 

Materials 
 function

a relation from a set of inputs to a set of possible outputs, where each input is related to exactly one 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°)

Did I get paid enough for painting that fence? (paid \ge $100)

Are the cookies finished baking? (timer = 0)
Have students come up with other examples.
Many times we need to combine inequalities:

Should I go to the beach? (temperature > 80° and weather = "sunny")

Was this burrito worth the price? (taste = "delicious" and price ≤ $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 sitdown, standup 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 producetrue
if both of their subexpressions aretrue
. 
Expressions using
or
producetrue
if either of their subexpressions aretrue
.
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 NonSolutions of Compound Inequalities
Launch
Have students identify 4 solutions and 4 nonsolutions for each of the following inequalities.

x > 5

x \le 15
What about the solution set of x > 5 and
x \le 15? What numbers make both of these inequality expressions true?
How would that be different from x > 5 or
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, read the code carefully and click "Run" to see the graphs they’ve just considered.
This starter file includes two special functions.
andintersection
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.
(define (gt5 x) (> x 5))
(define (lte15 x) (<= x 15))
(andintersection gt5 lte15 (list 5 2.1 0 5 10 39/5 15 20))
A compound inequality displayed on a number line, showing the intersection of two simple inequalities 🖼Show image
(define (lt5 x) (< x 5))
(define (gte15 x) (>= x 15))
(andintersection 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.
A compound inequality displayed on a number line, showing no intersection and therefore no solutions 🖼Show image
orunion
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.
(define (lt5 x) (< x 5))
(define (gte15 x) (>= x 15))
(orunion lt5 gte15 (list 5 2.1 0 5 10 39/5 15 20))
A compound inequality displayed on a number line, showing the union of two simple inequalities 🖼Show image
(define (gt5 x) (> x 5))
(define (lte15 x) (<= x 15))
(orunion 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 infinite solutions that satisfy at least one of the inequalities.
A compound inequality displayed on a number line, showing an infinite union 🖼Show image
Turn to Compound Inequalities: Solutions & NonSolutions and explore the compound inequalities listed using the Compound Inequalities Starter File, identifying solutions and nonsolutions 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.
(define (fiveto15 x) (and (> x 5) (<= x 15)))
(inequality fiveto15 (list 5 2.1 0 5 10 12 15 20))
Turn to Compound Inequality Functions and have students write code to describe the compound inequalities pictured.
Synthesize

How did the graphs of intersections and unions differ?
🔗Additional Exercises:
These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). Bootstrap by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.