Home › Calculators › Set Calculator

Set Calculator

Type up to four sets and get every union, intersection, difference, symmetric difference and complement at once, with a Venn diagram that counts the elements in each region. Enter your own expression, such as (A ∪ B)′ ∩ C, to shade it on the diagram.

Last updated:

Number of sets

Separate elements with commas, spaces or new lines; ranges like 1-20 work too

Used for complements. Leave empty to use the union of all sets.

Operators: ∪ | + u (union), ∩ & (intersection), − - \ (difference), △ ^ (symmetric difference), ′ ' (complement). ∩ binds tighter than the others; use parentheses.

Enter your values to see the result.
Advertisement
Advertisement

How to use the Set Calculator

  1. Choose 2, 3 or 4 sets with the buttons at the top.
  2. Type the elements of each set, separated by commas, spaces or new lines. Duplicates are removed automatically and ranges like 1-20 are expanded.
  3. Add a universal set U if you need complements relative to a larger set; otherwise U is the union of your sets.
  4. Optionally type an expression such as A ∩ B, A - B or (A u B)' & C. The result appears at the top and is shaded on the Venn diagram.
  5. Read the tables for every operation, the Venn regions and subset checks, and download any of them as CSV.

Set operations at a glance

A set is an unordered collection of distinct elements, so {3, 1, 2, 2} is the same set as {1, 2, 3}. This calculator treats every element as text, which means numbers, words, letters and codes all work. Numbers are sorted numerically and everything else alphabetically.

OperationSymbolType it asContainsA = {1,2,3}, B = {2,3,4}
UnionA ∪ BA ∪ B, A | B, A + B, A u Belements in A or B (or both){1, 2, 3, 4}
IntersectionA ∩ BA ∩ B, A & B, A * Belements in both A and B{2, 3}
DifferenceA − BA - B, A \ Belements in A but not in B{1}
Symmetric differenceA △ BA △ B, A ^ B, A xor Belements in exactly one set{1, 4}
ComplementA′, AᶜA', A^c, ~Aelements of U not in Awith U = {1,…,5}: {4, 5}
Universal / empty setU, ∅U, ∅, {}everything / nothing—

Useful identities

  • De Morgan's laws: (A ∪ B)′ = A′ ∩ B′ and (A ∩ B)′ = A′ ∪ B′. Try both sides in the expression box: the results match.
  • Difference as intersection: A − B = A ∩ B′.
  • Distributive laws: A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) and A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C).
  • Counting: |A ∪ B| = |A| + |B| − |A ∩ B|, and |A △ B| = |A| + |B| − 2|A ∩ B|.
  • Subsets: A ⊆ B exactly when A ∩ B = A, which is the same as A − B = ∅.

Reading the Venn diagram

Two sets split the universal set into 4 regions, three sets into 8 and four sets into 16 (the 4-set diagram uses ellipses, because four circles cannot show every combination). Each number on the diagram is the count of elements that belong to exactly that combination of sets; hover a number to see the elements. The Venn diagram regions table lists the same counts with a ✓ for each set the region belongs to. When you enter an expression, the regions that make up its result are shaded.

Frequently asked questions

What is the difference between union and intersection?

The union A ∪ B contains every element that is in A, in B, or in both. The intersection A ∩ B contains only the elements that are in both sets. For A = {1, 2, 3} and B = {2, 3, 4}, the union is {1, 2, 3, 4} and the intersection is {2, 3}.

What is A − B (set difference)?

A − B, also written A \ B, is the set of elements in A that are not in B. Order matters: with A = {1, 2, 3} and B = {2, 3, 4}, A − B = {1} but B − A = {4}.

What is the symmetric difference?

The symmetric difference A △ B contains the elements that are in exactly one of the two sets. It equals (A − B) ∪ (B − A), or (A ∪ B) − (A ∩ B). For the sets above it is {1, 4}.

How is the complement calculated?

The complement A′ (also written Aᶜ) is everything in the universal set U that is not in A, so |A′| = |U| − |A|. The result depends on U, which is why you can enter your own universal set. If you leave U empty, the calculator uses the union of all your sets.

What order are operations done in an expression?

Parentheses come first, then complements (′), then intersections (∩). Union, difference and symmetric difference have equal priority and are done from left to right. Textbooks do not all agree on precedence, so adding parentheses, for example (A − B) ∪ C, is the safest way to say what you mean.

How do I count the elements of a union?

Use the inclusion–exclusion principle: |A ∪ B| = |A| + |B| − |A ∩ B|. For three sets, |A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |A ∩ C| − |B ∩ C| + |A ∩ B ∩ C|. The calculator shows these sums with your numbers so you can check homework.

How many subsets does a set have?

A set with n elements has 2ⁿ subsets, including the empty set and the set itself, and 2ⁿ − 1 proper subsets. A 4-element set has 16 subsets. The calculator lists them all for sets of up to 6 elements (64 subsets).

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Venn Diagram MakerMake 2- or 3-circle Venn diagrams from lists; overlaps are found for you. Export PNG or SVG.Permutation and Combination CalculatorCalculate nPr and nCr, with or without repetition, as exact big numbers.Combinations GeneratorList every k-combination of your items, with or without repetition, and copy or export them.Compare Two ListsFind items only in list A, only in list B, in both lists, or in either, with copy and sort.Graphing CalculatorPlot multiple functions with zoom, pan, intersections and a value table.Exponent CalculatorRaise any number to a power, including negative and fractional exponents.Logarithm CalculatorCalculate log in any base, ln, log10, log2 and antilog with change-of-base steps.Quadratic Equation SolverSolve ax² + bx + c = 0 with exact roots, steps, vertex and a parabola graph.Matrix CalculatorAdd, multiply, invert and row-reduce matrices up to 5×5 with exact fractions and steps.Prime Number CheckerCheck if a number is prime, factor it with a factor tree and list primes in a range.GCF and LCM CalculatorFind the GCF and LCM of two or more numbers with Euclid steps and prime factorization.Cubic Yard CalculatorConvert length, width and depth in any unit to cubic yards, cubic feet, m³ and material weight.Factorial CalculatorExact n! up to 5000! with digit count, trailing zeros and double factorial.Prime Factorization CalculatorFind prime factors in exponent form with a factor tree, divisor count and divisors list.Modulo CalculatorCalculate a mod n and the quotient, with floored, truncated and Euclidean rules.Exponential Growth CalculatorExponential growth and decay: final amount, rate or time, discrete or continuous.Linear Regression CalculatorLeast-squares line of best fit: slope, intercept, r, r², predictions and a scatter plot.System of Equations SolverSolve 2×2, 3×3 and 4×4 linear systems with exact fractions and step-by-step working.Cubic Equation SolverSolve ax³ + bx² + cx + d = 0 for real and complex roots with steps and a graph.Summation CalculatorEvaluate sigma notation: sum any expression in n from a to b with partial sums and a chart.Arithmetic Sequence CalculatorFind the n-th term, sum and full list of an arithmetic sequence, or d from two terms.Geometric Sequence CalculatorFind the n-th term, sum and infinite sum of a geometric sequence, or r from two terms.Fibonacci CalculatorExact n-th Fibonacci number (BigInt), sequence lists, Fibonacci check and golden ratio.Factors CalculatorAll factors and factor pairs of a number, prime factors, divisor count and perfect check.Depth of Field CalculatorNear and far focus limits, depth of field and hyperfocal distance for any camera or lens.Crop Factor CalculatorCrop factor, full-frame equivalent focal length and aperture, and field of view for any sensor.Completing the Square CalculatorRewrite ax² + bx + c in vertex form a(x − h)² + k step by step and solve it.Derivative CalculatorSymbolic derivative of any f(x) up to 5th order, with steps, slope at a point and a graph.Exposure Value CalculatorEV from aperture, shutter and ISO, or solve any missing setting with sunny 16 presets.Factoring Trinomials CalculatorFactor trinomials and polynomials: GCF, ac method, difference of squares, cubes, with steps.Integral CalculatorDefinite integral of f(x) from a to b with adaptive Simpson, area graph and antiderivative.Least Common Denominator CalculatorFind the LCD of two or more fractions and rewrite them as equivalent fractions, with steps.Limiting Reactant CalculatorFind the limiting reactant, theoretical yield and leftover excess from an equation.Parabola CalculatorVertex, focus, directrix, axis, intercepts and graph of a parabola from its equation.Polynomial Root FinderFind all real and complex roots of a polynomial up to degree 10, with the factored form.Prime Number List GeneratorList all primes in a range or the first N primes with a fast sieve; copy or download the list.Quadratic Regression CalculatorFit y = ax² + bx + c (or up to degree 6) to x, y data with R², predictions and a graph.Scatter Plot MakerPaste X,Y pairs for a scatter plot with trendline, equation, r and R². Download PNG.Limit CalculatorEvaluate limits at a point or at infinity, one-sided or two-sided, with steps, table and graph.Linear Interpolation CalculatorInterpolate or extrapolate y for any x from two points or a data table, with steps and a plot.Matrix Inverse CalculatorFind the inverse of a 2×2 to 8×8 matrix in exact fractions with Gauss–Jordan or adjugate steps.Partial Derivative CalculatorPartial derivatives ∂/∂x, ∂/∂y, second and mixed orders with steps, gradient and Hessian.RREF CalculatorRow reduce any matrix to RREF with exact fractions, every row operation, pivots and rank.Stem and Leaf Plot MakerMake stem-and-leaf plots (standard, split stems or back-to-back) with a key; copy or save PNG.Taylor Series CalculatorTaylor and Maclaurin polynomials of any f(x) to order n, with exact coefficients and a graph.Antilog CalculatorInverse logarithm (antilog) in base 10, e, 2 or any base, with steps and scientific notation.Asymptote CalculatorFind vertical, horizontal and slant asymptotes and holes of a function, with graph and reasoning.Cramer's Rule CalculatorSolve 2x2 and 3x3 linear systems by Cramer's rule with every determinant shown step by step.Dot Plot MakerMake a dot plot or line plot from data or a frequency table; download PNG or SVG.Exponential Regression CalculatorFit y = a·bˣ or y = a·e^(kx) to data with r², predictions, residuals and a plot.Extended Euclidean Algorithm CalculatorFind gcd(a, b) and Bézout coefficients x, y with the full step-by-step division table.Factor Tree GeneratorDraw the prime factor tree of any number as a printable diagram, with exponent form and steps.Function Composition CalculatorFind f(g(x)), g(f(x)), f + g, f · g and f / g with values at a point and domains.X and Y Intercept CalculatorFind the x- and y-intercepts of lines, curves and functions with steps and a graph.Line Intersection CalculatorFind where two lines cross from equations, points or slopes, with parallel checks and a graph.Linear Programming SolverSolve max/min linear programs with the simplex method: tableau steps and a 2-variable graph.Modular Exponentiation CalculatorCompute a^b mod m for huge numbers with square-and-multiply steps (BigInt).Modular Inverse CalculatorFind a⁻¹ mod m with the extended Euclidean algorithm, step by step, for huge numbers too.Nth Term CalculatorFind the nth term formula of a sequence: arithmetic, geometric, quadratic or cubic.Partial Fraction Decomposition CalculatorSplit a rational function into partial fractions with the setup, equations and solution.Perpendicular Line CalculatorEquation of the perpendicular and parallel line through a point, with distance and a graph.Polar Graphing CalculatorGraph polar equations r = f(θ): roses, cardioids, spirals, with a θ range slider and PNG export.Polynomial CalculatorAdd, subtract, multiply, divide and evaluate polynomials; see roots, degree and a graph.Polynomial Long Division CalculatorDivide polynomials with the full long division layout, quotient, remainder and steps.Scale Factor CalculatorScale factor between similar figures, plus scaled lengths, areas (k²) and volumes (k³).Table of Values CalculatorMake an x/y table for any function with a start, end and step, then plot it or copy CSV.Synthetic Division CalculatorDivide polynomials by x − c (synthetic table) or any polynomial (long division) with steps.3D Graphing CalculatorPlot z = f(x, y) surfaces and 3D parametric curves; rotate, zoom, add contours, save PNG.
See all 74 Algebra & Calculus Calculators →