Union and Intersection Calculator

Find the union, intersection, and differences of two sets instantly.

Set operations
Enter each set as comma-separated numbers, words, or symbols.

About union and intersection

Sets are collections of distinct elements, and set operations describe how collections relate. The union of two sets contains every element appearing in either set. The intersection contains only elements shared by both sets. These ideas provide a concise language for grouping, filtering, probability, database queries, logic, and Venn diagrams. This calculator accepts comma-separated values for Set A and Set B. It trims surrounding spaces and removes repeated entries within each input. The union is formed by combining both lists and keeping each value once. The intersection checks the first set for values also found in the second. Two additional results show the relative complements: elements only in A and elements only in B. Output uses square brackets so it remains easy to read and copy. Element matching is textual. For example, the number written as 02 is not automatically converted to 2, and Apple may differ from apple. Consistent spelling and capitalization are therefore important. This behavior also lets the calculator work with labels, codes, names, and symbols instead of limiting inputs to numbers. A comma serves as the separator, so an individual element should not contain a comma. Empty entries between repeated separators are ignored, which keeps accidental extra commas from creating unnamed elements in the displayed result. Union and intersection obey useful algebraic laws. Both are commutative, meaning swapping A and B does not change those two results. They are also associative and idempotent. Union corresponds broadly to logical OR, while intersection corresponds to logical AND. In probability, the union is the event that at least one condition occurs, and the intersection is the event that both occur. Use the results to check homework, prepare Venn diagrams, compare categories, or understand overlaps in real data. The tool performs deterministic set operations and exposes each region clearly, making it easier to verify reasoning without manually sorting duplicate values.

Examples

SetsResultExplanation
A: 1, 2, 3; B: 2, 3, 4Union [1, 2, 3, 4]; intersection [2, 3]Two values are shared.
A: red, blue; B: green, blueUnion [red, blue, green]; intersection [blue]Blue belongs to both sets.
A: a, b; B: c, dUnion [a, b, c, d]; intersection emptyThe sets are disjoint.

How to use the calculator

  1. Enter the elements of Set A separated by commas.
  2. Enter the elements of Set B using the same format.
  3. Select Calculate Set Operations.
  4. Review the union, intersection, and elements unique to each set.

Frequently asked questions

What is the union of two sets?

The union contains every distinct element found in either set. Duplicate values appear only once in the result.

What is the intersection of two sets?

The intersection contains only elements present in both sets. It is empty when the sets have no common elements.

Does order matter?

Mathematically, set order does not matter. The calculator preserves a practical display order based on the entered lists.

Can I use words instead of numbers?

Yes, elements are treated as text and may be words, labels, or numeric strings. Separate every element with a comma.

How are duplicates handled?

Repeated values in an input are reduced to one set element. This follows the definition of a set as a collection of distinct members.