Set Operations

Understanding Set Theory is fundamental to understanding advanced mathematics. Iv wrote these scripts so that users could begin to play with the different set operations that are taught in a basic set theory course. Here, the sets are limited to positive integers and we're only looking at a few operations, in particular the union, intersection, difference, symmetric difference, and cross product of two sets. I will explain what each of these is below.

The **union** of the sets S_{1} and S_{2} is the set S_{1} [union] S_{2}, which contains the elements that are in S_{1} or S_{2} (or in both).

Note: S_{1} [union] S_{2} is the same as S_{2} [union] S_{1}.

The **intersection** of the sets S_{1} and S_{2} is the set S_{1} [intersect] S_{2}, which contains the elements that are in BOTH S_{1} and S_{2}.

Note: S_{1} [intersect] S_{2} is the same as S_{2} [intersect] S_{1}.

The **difference** between the sets S_{1} and S_{2} is the set S_{1} / S_{2}, which contains the elements that are in S_{1} and not in S_{2}.

.
Note. S_{1} / S_{2} IS NOT the same as S_{2} / S_{1}.

Note. S_{1} / S_{2} is the same as S_{1} [intersect] [not]S_{2}.

The **symmetric difference** between the sets S_{1} and S_{2} is the set S_{1} [symm diff] S_{2}, which contains the elements that are in S_{1} and not in S_{2}, or the elements that are in S_{2} and not in S_{1}.

Note. S_{1} [symm diff] S_{2} is the same as S_{2} [symm diff] S_{1}.

Note. S_{1} [symm diff] S_{2} is the same as (S_{1} [intersect] [not] S_{2}) [union] (S_{2} [intersect] [not] S_{1}).

The **Cartesian product** of the two sets S_{1} and S_{2} is the set of all ordered pairs *(a, b)*, where *a* [in] S_{1} and *b* [in] S_{2}.