Set Builder Notation Converter
Numbers separated by commas or spaces. Duplicates are removed and the set is sorted.
- 5
- Cardinality |A|
- arithmetic, step 2
- Pattern
- 32
- Subsets
{ 2, 4, 6, 8, 10 }
{ x ∈ Z | x = 2 + 2n, 0 ≤ n ≤ 4 }
Paste a list of numbers and this writes the set in both roster form and set-builder notation, over the domain you choose. Where the numbers form an arithmetic sequence it produces the compact conditional form rather than restating the list, which is the part of the conversion actually worth doing by machine.
How it works
Your input is first turned into a genuine set: split on commas or spaces, non-numbers discarded, duplicates removed, and the result sorted. A set has no repeats and no order, so 3, 1, 3 and 1, 3 are the same set and are written the same way.
- If consecutive values differ by a constant step, the set is arithmetic and takes a conditional form.
- A step of 1 gives a range condition, such as 5 ≤ x ≤ 9.
- Any other constant step gives a parametric condition, such as x = 2 + 2n with 0 ≤ n ≤ 4.
- With no pattern, the honest answer is membership of the roster. Inventing a rule that happens to fit five values would be worse than saying there is not one.
The domain (ℕ, ℤ, ℚ or ℝ) is stated in the notation because it changes what the set contains. The condition 5 ≤ x ≤ 9 describes five integers or infinitely many reals, and the condition alone does not say which.
Examples
An arithmetic set
Numbers
2, 4, 6, 8, 10
Domain
ℤ
Result
{ x ∈ ℤ | x = 2 + 2n, 0 ≤ n ≤ 4 }A constant step of 2 over five values. The parameter n runs from 0 to 4. One less than the count, because it starts at zero.
Consecutive integers
Numbers
5 6 7 8 9
Domain
ℤ
Result
{ x ∈ ℤ | 5 ≤ x ≤ 9 }A step of 1 collapses to a plain range, which is the form most textbooks expect. Over ℝ the same condition would describe infinitely many numbers.
No pattern
Numbers
2, 3, 5, 7, 11
Domain
ℤ
Result
{ x ∈ ℤ | x ∈ { 2, 3, 5, 7, 11 } }The primes have no arithmetic step, so no compact condition exists. Writing membership of the roster is correct; a fitted formula would be a fabrication.
Frequently asked questions
Why does it sometimes just repeat my list back inside the braces?
Because the numbers have no arithmetic pattern, so no shorter condition describes exactly them. Membership of the roster is the correct set-builder statement in that case, and it is more honest than fitting a formula to a handful of values.
Should I use a vertical bar or a colon?
Either is standard and both read as "such that". The colon is often preferred when the condition itself contains a vertical bar, such as an absolute value, to stop the two colliding visually. This uses the bar, the more common of the two.
Why does the domain appear in the notation?
Because it changes what the set contains. The condition 5 ≤ x ≤ 9 holds for five integers or for uncountably many reals, and the condition alone does not say which is meant. Stating x ∈ ℤ removes the ambiguity.
Does ℕ include zero?
It depends on convention, and the split is genuine. Most set theory and computer science texts include zero; many analysis texts start at one. Say which you mean when it matters, the notation states the domain, but not that particular choice.
What happens to duplicates in my list?
They are removed, because a set contains each element once. Entering 1, 2, 2, 3 gives the set with three members. If repetition matters to what you are describing, you want a sequence or a multiset rather than a set.