Skip to content
Tutorials Center
My learning

Topics

Lesson 23 of 38 · Inequalities

Compound Inequalities: And, Or and Between

Learn to read, solve and graph compound inequalities such as 2 < x ≤ 7 (and) and x < 1 or x > 5 (or), with number-line pictures and checked examples.

Sometimes one inequality is not enough. A shower should be warm: not below 35 °C and not above 45 °C. A password must be at least 8 characters, but no more than 20. A drawer is rejected if its width is too small or too large. Putting two inequalities together gives a compound inequality. There are two kinds: "and" (both must be true) and "or" (at least one must be true).

"And" inequalities: between two values

An and inequality asks for numbers that satisfy both conditions at once. The solutions sit in the overlap of two shaded regions.

Take x > 2 and x ≤ 7. We can write it in one line as:

Text
2 < x ≤ 7

Read it as "x is greater than 2 and less than or equal to 7", or "x is between 2 and 7, not counting 2 but counting 7". On the number line you draw an open circle at 2, a closed circle at 7, and shade between them.

Text
2 < x ≤ 7:   --o===========●--------
                2  3  4  5  6  7

Check some values: 5 is a solution (5 > 2 and 5 ≤ 7). 7 is a solution. 2 is not, since 2 > 2 is false. 8 is not.

The compact form a < x < b works only when both inequality symbols point the same way, so the variable is truly sandwiched between two numbers.

"Or" inequalities: outside an interval

An or inequality asks for numbers that satisfy at least one condition. The solution is the combined shading of both pieces.

Take x < 1 or x > 5. You cannot write this as a single sandwich, since no number is both below 1 and above 5. The solution set is two separate pieces:

Text
x < 1 or x > 5:   <=======o------------o=======>
                          1  2  3  4  5

Here 0 is a solution (0 < 1). So is 6 (6 > 5). But 3 is not: it fails both conditions.

flowchart TD
  A["Compound inequality"] --> B["AND: both true"]
  A --> C["OR: at least one true"]
  B --> D["Shading overlaps<br/>one connected piece"]
  C --> E["Shading combines<br/>often two pieces"]

"And" keeps the overlap; "or" keeps everything shaded by either condition.

Solving compound inequalities

Solve each part like a normal inequality. For the sandwich form, do the same step to all three parts at once.

Example 1. Solve -3 < 2x + 1 ≤ 9.

Text
-3 < 2x + 1 ≤ 9
-4 < 2x ≤ 8        (subtract 1 from all three parts)
-2 < x ≤ 4         (divide all three parts by 2)

Check x = 0: 2(0) + 1 = 1, and -3 < 1 ≤ 9 is true. Check x = 4: 2(4) + 1 = 9, and 9 ≤ 9 is true. Check x = -2: 2(-2) + 1 = -3, and -3 < -3 is false, so -2 is correctly excluded.

Example 2. Solve 3x - 2 < 4 or x + 5 > 12.

First: 3x < 6, so x < 2. Second: x > 7. The answer is x < 2 or x > 7.

Example 3 (flip rule inside a sandwich). Solve -6 ≤ -2x < 8.

Divide all three parts by -2 and flip both symbols:

Text
3 ≥ x > -4

Rewrite with the smaller number on the left to read it more easily: -4 < x ≤ 3. Check x = 0: -2(0) = 0, and -6 ≤ 0 < 8 is true.

When you divide a sandwich inequality by a negative number, both symbols flip, and the end numbers swap places. Always rewrite the result in increasing order and test a value.

A compound-inequality checker

The tool below tests many values against an "and" or "or" rule and prints the ones that work. Change the bounds to explore.

Python Test values against and / or rules

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The last line prints an empty list: the solved form -2 < x ≤ 4 and the original agree on every value tested.

Drawing the pieces

You can draw a compound inequality with matplotlib by stacking the number lines for each condition. This helps you see why "and" is the overlap and "or" is the union.

Python Overlap versus union on number lines

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The first two rows are the individual conditions. The third row is the part where both are shaded. The fourth shows a separate "or" example with two pieces.

Real-life examples

  • A shower between 35 °C and 45 °C: 35 ≤ T ≤ 45.
  • A bus fare for children aged 5 to 12 inclusive: 5 ≤ a ≤ 12.
  • A reject rule for a machine part: reject if length L < 49.5 mm or L > 50.5 mm. Accepted parts satisfy 49.5 ≤ L ≤ 50.5.

Common mistakes

  • Writing 5 < x < 1, which is impossible. In a sandwich the smaller number goes on the left.
  • Turning an "or" into a sandwich.
  • Forgetting to flip both symbols when dividing by a negative.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. Which values satisfy 1 < x ≤ 4?

    1 is excluded (open circle) and 4 is included (closed circle). The whole numbers are 2, 3 and 4.
  2. 2. Solve -5 < 3x + 1 < 10.

    Subtract 1: -6 < 3x < 9. Divide by 3: -2 < x < 3.
  3. 3. Which compound inequality is satisfied by x = 3?

    3 is greater than 1 and less than 5. It fails both pieces of the 'or' inequality, and no number satisfies the 'and' version in option 2.
  4. 4. After dividing -6 ≤ -2x < 8 by -2, what do you get?

    Dividing by a negative flips both symbols: 3 ≥ x > -4, which means -4 < x ≤ 3.

Summary

  • A compound inequality joins two inequalities with "and" or "or".
  • "And" gives the overlap and can often be written as a sandwich a < x < b.
  • "Or" gives the union and often has two separate pieces.
  • Do the same operation to all three parts of a sandwich; flip both symbols when dividing by a negative.
  • Test a value in each region to confirm your answer.

Next: Number Patterns and Rules