Skip to content

Intersection ​

The elements common to all the argument collections.

✓ checked against that system · ! checked, with disagreements (hover a chip)WikipediaIntersection (set theory)MathWorldIntersectionWikidataQ185837FungrimIntersectionWolfram LanguageIntersection!
Intersection(a, b, …)the elements common to every collection, as a SetSet.
Typed signatures
TypePackageApplies
(any+) -> setcompute-enginealways

Domain: Collections

Details
  • Idempotent: A∩A=AA \cap A = A.
  • Disjoint collections intersect to the symbol EmptySetEmptySet, not an empty SetSet.
  • With three or more collections, only elements present in all of them survive.
  • Same counting identity as Union, rearranged: ∣A∣+∣B∣=∣A∪B∣+∣A∩B∣|A| + |B| = |A \cup B| + |A \cap B|.

Examples

Basic #
live ↗
In[1,2,3]∩[2,3,4]\bigl\lbrack1, 2, 3\bigr\rbrack∩\bigl\lbrack2, 3, 4\bigr\rbrackOut{2,3}\lbrace2, 3\rbrace
live ↗
In[1,2,3,4]∩[2,3,4,5]\bigl\lbrack1, 2, 3, 4\bigr\rbrack∩\bigl\lbrack2, 3, 4, 5\bigr\rbrackOut{2,3,4}\lbrace2, 3, 4\rbrace

With three or more collections, only elements common to all of them survive

live ↗
In[1,2,3]∩[2,3,4]∩[2,3,5]\bigl\lbrack1, 2, 3\bigr\rbrack∩\bigl\lbrack2, 3, 4\bigr\rbrack∩\bigl\lbrack2, 3, 5\bigr\rbrackOut{2,3}\lbrace2, 3\rbrace

Duplicates are dropped as well

live ↗
In[1,1,2,3]∩[3,1,4]∩[4,1,3,3]\bigl\lbrack1, 1, 2, 3\bigr\rbrack∩\bigl\lbrack3, 1, 4\bigr\rbrack∩\bigl\lbrack4, 1, 3, 3\bigr\rbrackOut{1,3}\lbrace1, 3\rbrace
Scope #

Symbolic elements

live ↗
In[a,b,c]∩[b,c,d]\bigl\lbrack a, b, c\bigr\rbrack∩\bigl\lbrack b, c, d\bigr\rbrackOut{b,c}\lbrace b, c\rbrace

A single collection comes back as a set

live ↗
InIntersection([1,2,3])\mathrm{Intersection}(\bigl\lbrack1, 2, 3\bigr\rbrack)Out{1,2,3}\lbrace1, 2, 3\rbrace
Applications #

The divisors common to 45 and 78

live ↗
InDivisors(45)∩Divisors(78)\mathrm{Divisors}(45)∩\mathrm{Divisors}(78)Out{1,3}\lbrace1, 3\rbrace
Properties #

IntersectionIntersection is idempotent: A∩A=AA \cap A = A

live ↗
In{1,2,3}∩{1,2,3}={1,2,3}\lbrace1, 2, 3\rbrace∩\lbrace1, 2, 3\rbrace=\lbrace1, 2, 3\rbraceOutTrue\mathrm{True}

The same inclusion-exclusion count, rearranged: ∣A∣+∣B∣=∣A∪B∣+∣A∩B∣|A| + |B| = |A \cup B| + |A \cap B|. See Union

live ↗
InLength([1,2,3])+Length([2,3,4])=Length([1,2,3]∪[2,3,4])+Length([1,2,3]∩[2,3,4])\mathrm{Length}(\bigl\lbrack1, 2, 3\bigr\rbrack)+\mathrm{Length}(\bigl\lbrack2, 3, 4\bigr\rbrack)=\mathrm{Length}(\bigl\lbrack1, 2, 3\bigr\rbrack∪\bigl\lbrack2, 3, 4\bigr\rbrack)+\mathrm{Length}(\bigl\lbrack1, 2, 3\bigr\rbrack∩\bigl\lbrack2, 3, 4\bigr\rbrack)OutTrue\mathrm{True}

Intersecting with the empty set gives the empty set: A∩∅=∅A \cap \varnothing = \varnothing

live ↗
In[1,2,3]∩∅\bigl\lbrack1, 2, 3\bigr\rbrack∩∅Out∅∅
live ↗
In[a,b,c]∩[d,e,f]\bigl\lbrack a, b, c\bigr\rbrack∩\bigl\lbrack d, e, f\bigr\rbrackOut∅∅
Possible issues #

Disjoint collections intersect to the special symbol EmptySetEmptySet, not an empty SetSet

live ↗
InList⁡(1,2)∩List⁡(3,4)\operatorname{List}(1, 2)∩\operatorname{List}(3, 4)Out∅∅

The result is a set, so its elements are in canonical order

live ↗
In[c,b,a]∩List⁡(a,b)\bigl\lbrack c, b, a\bigr\rbrack∩\operatorname{List}(a, b)Out{a,b}\lbrace a, b\rbrace
About
Examples13
Checked againstWolfram Language 10 agree2 differ
CrosswalkWikipediaMathWorldWikidataFungrimWolfram Language

See also: Union, SetMinus