Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

When using the cartesian product, and you have three collections, do you take two collections at a time OR all three together to calculate the product?

My question is if you have more than two collections, let's say A, B and C

A = {1,2,3}
B = {4,5,6}
C = {7,8}

A x B x C
{1,2,3} x {4,5,6} x {7,8}

Do you with the cartesian product calculate A x B, then B x C? And maybe A x C? Which means you take only two collections at a time.

OR

Do you take all three collections at the same time A x B x C?

share|improve this question

migrated from stackoverflow.com Jan 30 '12 at 16:40

This question came from our site for professional and enthusiast programmers.

    
A X B X C = {(1,4,7), (1,4,8), ... , (3,6,8)} –  Alin Purcaru Jan 30 '12 at 15:56
    
A Cartesian Product is usually defined as a product of two sets, but when you are going to find the n-ary product, the product set will contain all possible triplets. –  0605002 Jan 30 '12 at 15:58
1  
Do you want the fully formal answer, or just a simple, easy-to-us answer? –  Arturo Magidin Jan 30 '12 at 16:44
    
In the usual formal buildup, it is in principle two at a time. However, let $I_n$ be a fixed $n$-element set, say the set $\{1,2, \dots,n\}$. We could define the $n$-fold Cartesian product $A_1\times\cdots\times A_n$ as the set of all functions $f$ from $I_n$ to $\cup A_i$ such that $f(i)\in A_i$ for $i=1$ to $n$. –  André Nicolas Jan 30 '12 at 17:20

3 Answers 3

For $n \in \mathbb{N}$, the $n$-ary Cartesian product of $n$ sets $A_1, \dots, A_n$, denoted $A_1 \times \cdots \times A_n$, is defined to be the set of all $n$-tuples $(a_1, \dots, a_n)$ for which $a_i \in A_i$ for each $i$.

So in particular

$$A \times B \times C = \{ (a,b,c)\, :\, a \in A,\ b \in B,\ c \in C \}$$

This is distinct from

$$(A \times B) \times C = \{ ((a,b),c)\, :\, a \in A,\ b \in B,\ c \in C \}$$

each of whose elements is an ordered pair, the first 'coordinate' of which is itself an ordered pair.

Nonetheless, there is a very natural bijection

$$\begin{align} A \times B \times C & \to (A \times B) \times C \\ (a,b,c) &\mapsto ((a,b),c) \end{align}$$

and similarly for $A \times (B \times C)$.

share|improve this answer

The cartesian product is an operation defined on two sets. Given the sets A and B the product A x B is not equal to the product B x A. So you will have to use two sets at a time and you will need to define an order, you want to apply the operation in, since (A x B) x C is not equal to A x (B x C).

share|improve this answer

all three sets at the same time.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.