Symmetric difference

The elements that lie in exactly one of two sets.
Symmetric difference

A symmetric difference of sets AA and BB is the set of elements that belong to exactly one of them:

AB=(AB)(BA). A\triangle B=(A\setminus B)\cup(B\setminus A).

This operation is built from and . It is symmetric in AA and BB and measures “disagreement” between sets: AB=A\triangle B=\varnothing exactly when A=BA=B.

Examples:

  • {1,2,3}{2,3,4}={1,4}\{1,2,3\}\triangle\{2,3,4\}=\{1,4\}.
  • If AA and BB are disjoint, then AB=ABA\triangle B=A\cup B.