Skip to main content
Calcimator

Set Theory Calculator

Calculate union, intersection, difference, symmetric difference, and complements for two sets with similarity metrics.

About this calculator

This calculator derives every standard two-set relationship — union, intersection, the two one-way differences, symmetric difference, and both complements — from just three cardinalities: Set A Size, Set B Size, and the Overlap (A ∩ B) between them. Union (A ∪ B) is setASize + setBSize − overlapCount (line 13), so Set A Size is the single strongest driver of it at the calculator's defaults — a 10% nudge to Set A Size (50) is 5, while the same 10% nudge to Set B Size (30) is only 3, so Set A Size moves Union about 1.7 times as much simply because its default value is larger; with equal-sized sets, the two inputs would move Union equally. Increasing the Overlap, by contrast, pulls Union down, since a larger shared region means fewer elements are being counted twice.

Universal Set Size never enters the Union formula at all; it only affects Complement of A and Complement of B, and the engine silently raises it to at least setASize + setBSize − overlapCount (line 7-10) if you type a smaller value, rather than rejecting the entry. Overlap Count itself is clamped to never exceed the smaller of the two set sizes (line 6), since a shared region can't be larger than either set it belongs to. This calculator only models two sets — it has no way to represent a three-way (or higher) overlap, such as a three-circle Venn diagram, where the pairwise overlap counts alone aren't enough to determine how much of all three sets intersect at once.

Inputs

Results

Union (A ∪ B)

70

Intersection (A ∩ B)

10

Difference (A − B)40
Difference (B − A)20
Symmetric Diff (A Δ B)60
Complement of A50
Complement of B70
Jaccard Index0.1429
Overlap Coefficient0.3333
How to Use This Calculator
  1. Enter the sizes of Set A and Set B, plus their Overlap (A ∩ B) and the Universal Set Size.
  2. All set operations — union, intersection, both differences, and symmetric difference — are calculated automatically from those sizes.
  3. Review the resulting cardinalities, including the Complement of A and Complement of B.
  4. Check the Set Region Sizes bar chart to visualize the overlap.
  5. Use the cardinality outputs to verify set relationships in database queries or combinatorics problems.

How the result changes with Set A Size

Set A SizeUnion (A ∪ B)Intersection (A ∩ B)
254510
385810
759510
12514510

What each input means

Set A Size
Number of elements in set A
Set B Size
Number of elements in set B
Overlap (A ∩ B)
Number of elements shared by both A and B
Universal Set Size
Total elements in the universal set (must be ≥ union size)

How this is calculated

Worked example, using the default values

  1. Identify Input Parameters
    4 parameters
    Set A Size = 50, Set B Size = 30, Overlap (A ∩ B) = 10, Universal Set Size = 100 = 4 input(s) provided
  2. Calculate Union
    Union
    70 = 70
  3. Calculate Intersection
    Intersection
    10 = 10
  4. Calculate Difference
    Difference
    40 = 40
  5. Calculate Difference
    Difference
    20 = 20

Engine last updated . Checked against 4 independently-derived tests — how we verify calculators. Built by Paul Gunder, a software engineer, not a licensed financial, medical, or legal professional.

Frequently Asked Questions

Does Set A Size or Set B Size move the Union size more?

Set A Size does, at the calculator's default values — Union is setASize + setBSize − overlapCount (line 13), a straight sum, but Set A Size defaults to 50 versus Set B Size's 30, so the same proportional nudge to Set A Size produces a larger absolute swing in Union. With equal-sized sets, the two would move it equally.

Why doesn't Universal Set Size change the Union?

Union (A ∪ B) is computed directly as setASize + setBSize − overlapCount (line 13) and never references Universal Set Size at all. Universal Set Size only feeds into Complement of A and Complement of B, which measure what's outside each set relative to the universe you declare.

What happens if I set Universal Set Size smaller than the union of A and B?

The engine won't let it shrink that far: it silently raises Universal Set Size to at least setASize + setBSize − overlapCount (lines 7-10) before using it, since a universal set can never be smaller than a union it's supposed to contain. You won't see an error, just a larger effective value.

Can I set Overlap (A ∩ B) larger than either set?

No. The engine clamps Overlap Count to Math.min(setASize, setBSize) (line 6), because the number of elements shared between two sets can never exceed the size of the smaller set — typing a larger overlap just gets capped down automatically rather than rejected.

The questions that sit next to this one — chosen by subject, including calculators filed under a different category.

More in Math & Statistics.