# Set Operations Calculator (Union/Intersection/Difference)

Union, intersection, difference, symmetric difference, and Cartesian product of two comma-separated sets, with cardinalities and capped pair display.

> Canonical page: https://elysiatools.com/en/tools/set-operations-calculator

- **Category:** Math & Numbers

- **Keywords:** set operations, union, intersection, difference, symmetric difference, cartesian product, set theory, discrete math, cardinality, ordered pairs

## Overview

Perform core discrete mathematics set operations on two comma-separated lists, including Union (A ∪ B), Intersection (A ∩ B), Difference (A − B), Symmetric Difference (A △ B), and Cartesian Product (A × B), with automatic deduplication and calculated set cardinalities.

## Inputs

- **Set A (comma-separated)** (text): Elements of A as comma-separated text; comparison is case-sensitive and duplicates collapse.
- **Set B (comma-separated)** (text): Elements of B as comma-separated text.
- **Operation** (select)

## When to use

- When solving discrete mathematics or set theory exercises that require calculating set relations and cardinalities.
- When comparing two discrete lists of keys, tags, or IDs to determine overlapping or exclusive entries.
- When generating all valid ordered pair combinations between two distinct sets of attributes.

## How it works

- Enter the elements for Set A and Set B as comma-separated values, which automatically deduplicate while preserving entry order.
- Select the required operation from the dropdown: Union, Intersection, Difference, Symmetric difference, or Cartesian product.
- Review the resulting output set along with individual and result cardinalities |A|, |B|, and |Result|.

## Use cases

- Comparing feature access lists across two user tiers to isolate unique and shared entitlements.
- Verifying homework solutions in set theory and discrete math courses.
- Generating combinatorial ordered pairs between product sizes and color variants.

## Frequently asked questions

### Are element comparisons case-sensitive?

Yes, element comparisons are case-sensitive, meaning 'abc' and 'ABC' are treated as separate elements.

### How does the tool handle repeated values within an input?

Duplicate values within the same input set are automatically collapsed, keeping only the first occurrence.

### What is the difference between Difference and Symmetric Difference?

Difference (A − B) extracts elements exclusive to Set A, while Symmetric Difference (A △ B) keeps elements that belong to either Set A or Set B, but not both.

### How does the Cartesian product operation work?

It generates all ordered pairs (a, b) where each element from Set A is combined with every element from Set B.

### What does cardinality represent in the output?

Cardinality, written as |A| or |B|, indicates the total count of unique elements in that set.

## Related tools

- [Base-N Radix Converter](https://elysiatools.com/en/tools/base-n-radix-converter): Convert numbers and text between any radix from 2 to 36, with custom alphabets and presets for Base58, Base62, and Crockford Base32.
- [Angular Velocity Converter (rad/s / rpm / deg/s / Hz)](https://elysiatools.com/en/tools/angular-velocity-converter): Convert angular velocity (angular speed) between radian per second (rad/s, SI base), revolutions per minute (rpm = 2π/60 rad/s), degrees per second (deg/s = π/180 rad/s), and hertz (Hz, used as revolution per second = 2π rad/s). Converts via rad/s to the target unit and lists all four equivalents. Note: 1 Hz in angular-frequency context means one full revolution per second, so 1 Hz = 2π rad/s ≈ 6.283185307 rad/s. Reference: vinyl LP 33⅓ rpm ≈ 3.49 rad/s, car engine idle ~800 rpm ≈ 83.8 rad/s.
- [Fatigue Limit Calculator (Goodman / Gerber / Soderberg)](https://elysiatools.com/en/tools/fatigue-limit-calculator): Mean-stress fatigue correction under cyclic loading. Given stress amplitude σ_a, mean stress σ_m, and material σ_uts / σ_-1 (endurance limit) / σ_y, compute safety factors from three classical criteria: Modified Goodman (linear, conservative), Gerber (parabolic, better for ductile metals), and Soderberg (uses σ_y, most conservative). Reports the governing (smallest) value and whether the operating point lies inside the Goodman line.
- [Prime Factorization Calculator](https://elysiatools.com/en/tools/prime-factorization-calculator): Break an integer into prime factors, show the factorization string, and optionally include divisor properties and factorization steps
- [Acronym Generator](https://elysiatools.com/en/tools/acronym-generator): Turn a phrase into an acronym or initialism. Choose contributing words, which letter(s) to take, the separator, and the case.
- [Indented List to ASCII Tree](https://elysiatools.com/en/tools/ascii-tree-from-indented-list): Convert a 2-space / 4-space / Tab indented hierarchical list (Markdown bullets, -, *, 1. prefixes optional) into a copyable ASCII directory tree. Two styles: Unicode box-drawing (├──└──│) for GitHub/Discord and classic ASCII (|--\--|) for plain text. Toggles for full guide lines, trailing spaces, and bracketed leaf nodes like docs/\[api.md\].
- [Glitch Text](https://elysiatools.com/en/tools/glitch-text): Create a glitchy / corrupted look by replacing each letter with neighbouring broken Unicode glyphs — Cyrillic/Greek look-alikes, block elements (█▓▒░), geometric shapes — for a flat smashed data-corruption aesthetic. Intensity slider + optional seed for reproducible results.
- [Hex to String Converter](https://elysiatools.com/en/tools/hex-to-string): Convert text to and from hexadecimal strings with flexible spacing, prefix (0x/\x/U+), and case options

## Samples

- [Android File Operations Java Samples](https://elysiatools.com/en/samples/android-file-operations-java): Android Java file operations examples including text file read/write, file copy/move, directory traversal, and file validation
- [Android File Operations Kotlin Samples](https://elysiatools.com/en/samples/android-file-operations-kotlin): Android Kotlin file operations examples including text file read/write, file copy/move, directory traversal, and file validation
- [macOS File Operations Objective-C Samples](https://elysiatools.com/en/samples/macos-file-operations-objectivec): macOS Objective-C file operations examples including text file read/write, file copy/move, directory traversal, and file validation
- [macOS File Operations Swift Samples](https://elysiatools.com/en/samples/macos-file-operations-swift): macOS Swift file operations examples including text file read/write, file copy/move, directory traversal, and file validation

## Related content

- [Text Case, Encoding, and Normalization Conversion Tools](https://elysiatools.com/en/hubs/text-convert): Compare text case conversion, character-width conversion, encoding conversion, quoted-printable handling, and inline text normalization tools in one hub.
- [Text Tools](https://elysiatools.com/en/hubs/text-utility): Explore 33 text tools for utility workflows and compare closely related utilities quickly.
- [Text Analysis, Readability, and Content Inspection Tools](https://elysiatools.com/en/hubs/text-analyze): Compare text statistics, language detection, readability scoring, sentiment analysis, moderation review, and pattern analysis tools in one hub.
- [Text Redaction, Highlighting, and Presentation Formatting Tools](https://elysiatools.com/en/hubs/text-format): Compare tools for masking sensitive text, finding PII, normalizing phone numbers, highlighting phrases, centering text, and formatting diffs in one hub.
