Skip to content
Math

Set Builder Calculator

Enter two finite sets as comma-separated values and pick an operation to get the result instantly. This calculator supports union, intersection, difference, symmetric difference, complement, power set, and Cartesian product. You also get the cardinality of every set, a subset check, and a full step-by-step explanation of the computation. Both numeric and alphabetic elements are accepted.

Your details

Enter elements separated by commas. Numbers and letters both work. Duplicates are removed automatically.
The second set. Used for all binary operations.
The universal set used when computing the complement of A or B. Must contain all elements of both sets for the complement to be meaningful.
Choose the set operation to perform. Complement requires a Universal Set. Power set grows as 2^n so is capped for large inputs.
Result
{1, 2, 3, 4, 5, 6, 7}

The computed set or answer in roster notation

|A| (cardinality of A)5
|B| (cardinality of B)5
|Result| (cardinality)7
A ⊆ BNo
B ⊆ ANo
A = BNo
|A|5
|B|5
|Result|7

Operation: Union (A ∪ B)

  • A and B share 3 elements in common: 3, 4, 5.
  • The result has 7 elements.
  • Set builder notation {x | condition} describes sets by a rule; roster notation lists the elements explicitly.

Next stepTry the symmetric difference to find elements unique to each set, or the power set to see all possible subsets.

What is a set and how is it written?

A set is an unordered collection of distinct objects called elements. Two standard notations describe sets: roster notation lists every element explicitly between braces, for example {1, 2, 3}; set builder notation defines the set by a rule or property, for example {x | x is a positive integer less than 4}. Both represent the same set. This calculator works with finite sets entered in roster notation: type the elements separated by commas, and duplicates are stripped automatically. Elements can be numbers, letters, or words.

The eight operations this calculator supports

Union (A ∪ B) collects every element that belongs to A, to B, or to both, with no element counted twice. The cardinality formula is |A ∪ B| = |A| + |B| - |A ∩ B|, which avoids double-counting the shared elements. Intersection (A ∩ B) returns only the elements that appear in both sets simultaneously. Difference (A - B) keeps only the elements of A that are absent from B, and the reverse, B - A, keeps only those in B absent from A. Symmetric difference (A Δ B) keeps elements in exactly one set, equivalent to the union minus the intersection, and its cardinality is |A| + |B| - 2|A ∩ B|. Complement (A′) collects every element of a universal set U that is not in A. Cartesian product (A x B) forms every ordered pair (a, b) with a drawn from A and b drawn from B, giving |A| x |B| pairs. Power set P(A) lists every possible subset of A including the empty set and A itself, always containing 2^|A| members.

Set builder notation explained

Set builder notation writes a set as {variable | condition}, read as 'the set of all variable such that condition'. For example, {x | x is an even number and 1 <= x <= 10} equals {2, 4, 6, 8, 10} in roster form. The vertical bar means 'such that'; a colon is an equivalent alternative. This notation is especially useful when a set would be too large or infinite to list in full, such as {x | x is a prime number}. In algebra and calculus the condition can be an inequality, a divisibility rule, or membership in another set.

Key set theory laws

Several laws simplify expressions involving multiple operations. The commutative laws state that A ∪ B = B ∪ A and A ∩ B = B ∩ A. The associative laws allow reordering nested unions or intersections. The distributive laws link union and intersection: A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C). De Morgan's laws connect complement with union and intersection: the complement of (A ∪ B) equals the intersection of the complements, and the complement of (A ∩ B) equals the union of the complements. The identity laws state that A ∪ {} = A and A ∩ U = A. These laws let you rewrite any set expression into an equivalent but simpler form.

Set theory operations reference

OperationNotationDescriptionCardinality formula
UnionA ∪ BAll elements in A, B, or both|A| + |B| - |A ∩ B|
IntersectionA ∩ BOnly elements in both A and BCounted directly
DifferenceA − BElements in A but not in B|A| - |A ∩ B|
Symmetric DifferenceA Δ BElements in exactly one of A or B|A| + |B| - 2|A ∩ B|
ComplementA'Elements in U but not in A|U| - |A|
Cartesian ProductA × BAll ordered pairs (a, b)|A| × |B|
Power SetP(A)All subsets of A (including {} and A)2^|A|

Standard operations on two finite sets A and B with universal set U.

Frequently asked questions

What is the difference between union and intersection?

Union (A ∪ B) combines all elements from both sets into one set, never repeating an element that appears in both. Intersection (A ∩ B) returns only the elements that the two sets share. For example, if A = {1, 2, 3} and B = {3, 4, 5}, the union is {1, 2, 3, 4, 5} and the intersection is {3}.

How do I write a set in set builder notation?

Use the form {x | condition}. The variable before the vertical bar names a general element; the condition after it specifies which values qualify. For example, {x | x is a natural number and x < 6} describes {1, 2, 3, 4, 5}. You can also write {x ∈ ℕ | x < 6} to restrict x to the natural numbers explicitly.

What is the complement of a set?

The complement of A, written A' or A^c, contains every element of the universal set U that is not in A. The result depends entirely on what U is. If U = {1, 2, 3, 4, 5} and A = {1, 3, 5}, then A' = {2, 4}. Always specify the universal set clearly, because without it the complement has no fixed meaning.

How large does the power set get?

The power set of A has 2^|A| elements. For small sets the growth is manageable: a 3-element set has 8 subsets and a 4-element set has 16. But it grows rapidly: a 10-element set has 1,024 subsets and a 20-element set has over one million. This calculator caps the displayed output at 256 subsets for clarity, but it still reports the correct total cardinality.

What does the Cartesian product produce?

The Cartesian product A x B is the set of all ordered pairs (a, b) where a comes from A and b comes from B. The order within each pair matters: (1, 2) and (2, 1) are different pairs. The total number of pairs is |A| x |B|. For A = {1, 2} and B = {x, y}, the product is {(1, x), (1, y), (2, x), (2, y)}.

What is the symmetric difference and when is it useful?

The symmetric difference A Δ B keeps elements that belong to exactly one of the two sets, discarding anything in the intersection. It equals (A - B) ∪ (B - A). It's commonly used in data comparison to find rows that exist in one table but not another, or to highlight what changed between two versions of a list.

How do I check whether one set is a subset of another?

A is a subset of B (A ⊆ B) if every element of A is also in B. A is a proper subset if it is a subset but A does not equal B. An easy check: compute A - B; if the result is the empty set, then A ⊆ B. This calculator performs the check automatically and also shows whether B is a subset of A and whether the two sets are equal.

Sources

Written by Dr. Rajiv Menon, PhD Applied Mathematician · Bengaluru, India

Applied mathematician bridging algebraic theory and computational tools for students, engineers, and everyday problem-solvers.

Search 3,500+ calculators

Loading search…