Skip to content
FiftyCalc Free calculators for all 50 states

Union and Intersection Calculator

Test cases replayed : 3 of 3 match · Methodology · No outside source listed

Enter the sizes of two sets and of their intersection (or their probabilities, with a universe of 1) to get the union and every region of the Venn diagram.

Result

Sample figures

Union n(A ∪ B) = n(A) + n(B) − n(A ∩ B)—

Only A, n(A − B) —

  • Only B, n(B − A)—
  • Symmetric difference n(A △ B)—
  • Neither A nor B, n(U) − n(A ∪ B)—

Estimate for planning only, not tax, legal, financial or medical advice. This calculator uses the method explained on this page.

Union and Intersection Calculator

Size of set A, n(A): enter 0 or more. Prefilled example: 20.

Size of set B, n(B): enter 0 or more. Prefilled example: 15.

Size of the intersection, n(A ∩ B): enter 0 or more. Prefilled example: 5.

Size of the universal set U (0 if unknown; 1 for probabilities): enter 0 or more. Prefilled example: 50.

How to use this calculator

Fill in the fields in this order; each step takes you to its field.

  1. Size of set A, n(A): enter 0 or more.
  2. Size of set B, n(B): enter 0 or more.
  3. Size of the intersection, n(A ∩ B): enter 0 or more.
  4. Size of the universal set U (0 if unknown; 1 for probabilities): enter 0 or more.
  5. Read the result: Union n(A ∪ B) = n(A) + n(B) − n(A ∩ B); the panel also shows Only A, n(A − B), Only B, n(B − A), Symmetric difference n(A △ B) and Neither A nor B, n(U) − n(A ∪ B).

How this calculator works

The inclusion–exclusion principle for two finite sets: n(A ∪ B) = n(A) + n(B) − n(A ∩ B). The intersection is subtracted once because its elements are counted in both n(A) and n(B).

The other regions follow: only A = n(A) − n(A ∩ B), only B = n(B) − n(A ∩ B), symmetric difference = n(A) + n(B) − 2n(A ∩ B), and neither = n(U) − n(A ∪ B). The same rule holds for probabilities: P(A or B) = P(A) + P(B) − P(A and B).

The formula

  1. Un={a+b−iif i≤min⁡(a,b)−1otherwise
Symbols used in the formula
SymbolMeaning
aSize of set A, n(A)
bSize of set B, n(B)
iSize of the intersection, n(A ∩ B)
UnUnion n(A ∪ B) = n(A) + n(B) − n(A ∩ B)
min(a, b, …)the smallest of the values.

Worked example

Size of set A, n(A)20
Size of set B, n(B)15
Size of the intersection, n(A ∩ B)5
Size of the universal set U (0 if unknown; 1 for probabilities)50
Only A, n(A − B)15
Only B, n(B − A)10
Symmetric difference n(A △ B)25
Neither A nor B, n(U) − n(A ∪ B)20
  1. Un=20+15−5=30

Union n(A ∪ B) = n(A) + n(B) − n(A ∩ B) 30

Each step uses the unrounded value of the step before it; figures on this page are rounded for display.

Frequently asked questions

A class has 20 students in chess and 15 in band, 5 in both. How many are in at least one?

20 + 15 − 5 = 30. In a class of 50, the other 20 are in neither.

Does this work for probabilities?

Yes. With P(A) = 0.5, P(B) = 0.4 and P(A and B) = 0.2, P(A or B) = 0.7 and P(neither) = 0.3.

Questions answered

Related calculators