The difference of the set \(A\) from the set \(B\) is the set \(\{x : x \in B\) and \(x \not\in A\}.\) The notation for the difference is \(B - A,\) but \(B \backslash A\) is also common.
For example, if \(A = \{1, 2, 4\}\) and \(B = \{1, 2, 3, 5\},\) then \[B - A = \{1, 2, 3, 5\} - \{1, 2, 4\} = \{3, 5\}\] The elements \(1\) and \(2\) are lost in the set difference, since those are elements of \(A.\) The elements \(3\) and \(5\) remain, since they are not in \(A.\) The \(4\) does nothing, since it is not in \(B\) to begin with.
The following picture shows two sets, \(A\) and \(B\).
This picture shows the set difference \(B - A\). The set \(B - A\) is the set \(B\) with the part overlapping with \(A\) missing.
The symmetric difference of the sets \(A\) and \(B\) is the set \((A \cup B) - (A \cap B).\) The notation for the symmetric difference is \(A \triangle B.\) Conceptually, \(A \triangle B\) is the set of elements that are in \(A\) or \(B,\) but not both.
For example, if \(A = \{1, 2, 4\}\) and \(B = \{1, 2, 3, 5\},\) then \[A \triangle B = \{1, 2, 3, 5\} \triangle \{1, 2, 4\} = \{3, 4, 5\}\] The elements \(3, 4,\) and \(5\) are in \(A\) or \(B,\) but not both.
The following picture shows two sets, \(A\) and \(B\).
This picture shows the symmetric difference \(A \triangle B\).
The symmetric difference is logically related to exclusive or: \[x \in A \triangle B = (x \in A) \oplus (x \in B)\]