Understanding the set-builder notation calculator — concept and principle
This calculator converts between set-builder notation and roster form. Choose the kind of number, the bounds and an extra condition to list the elements and count them, or enter a list to get a set-builder rule. Use it for discrete maths, algebra and set theory homework.
How it is calculated
- Number types: natural numbers ℕ = {1, 2, 3, …}, whole numbers ℕ₀ = {0, 1, 2, …}, integers ℤ.
- Bounds can be included (≤) or not (<).
- Extra conditions: even, odd, multiple of k, perfect square or prime.
- The calculator lists every number that satisfies all the conditions and counts them: n(A).
- Reverse direction: it sorts the list, removes repeats and looks for a constant difference d; then each element is x = d·n + c for n = 1, 2, …, N.
An empty result is the empty set ∅. Rosters longer than 30 elements are shortened with "…".
The principle
A set can be described by listing its elements (roster method) or by stating the rule its elements satisfy (set-builder notation). {x ∈ ℤ | condition} is read "the set of all integers x such that the condition holds"; the bar means "such that". Set-builder notation is essential for large or infinite sets, where listing is impossible. Interval notation describes the bounds for real numbers: [−3, 12) includes −3 but not 12. The number of elements, n(A), is the cardinality of the set.
Worked example
Default inputs: integers, −3 ≤ x < 12, x is even.
- Integers from −3 up to but not including 12: −3, −2, …, 11.
- Keep the even ones: −2, 0, 2, 4, 6, 8, 10.
- Roster: {−2, 0, 2, 4, 6, 8, 10}, with n(A) = 7.
- Set-builder: {x ∈ ℤ | −3 ≤ x < 12, x is even}.
- Smallest −2, largest 10; the bound interval in real numbers is [−3, 12).
| Upper bound | Number of elements n(A) |
|---|---|
| 3 | 3 |
| 6 | 4 |
| 9 | 6 |
| 12 | 7 |
| 15 | 9 |
| 18 | 10 |
| 24 | 13 |
How to read the result
n(A) tells you how many elements meet the rule. The smallest and largest elements show whether the bounds behaved as expected, especially whether an endpoint was included. In the reverse direction, a found pattern such as x = 4n − 1 gives a compact rule; if no constant difference exists, the set is described by listing it.
Common mistakes
- Including an endpoint marked with < or excluding one marked with ≤.
- Forgetting that ℕ starts at 1 here; some books include 0.
- Counting 0 as neither even nor odd; 0 is even.
- Reading the bar | as "divides" in this context; here it means "such that".
Frequently asked questions
What does the vertical bar mean in set-builder notation?
"Such that". {x | x > 2} is the set of all x such that x > 2.
Is 0 a natural number?
It depends on the convention. This calculator uses ℕ = {1, 2, 3, …} and ℕ₀ when 0 is included.
How do I write the empty set?
∅ or { }, a set with no elements.
Sources: OpenStax, Contemporary Mathematics (2023), §1.1 Basic Set Concepts