Commutativity: Examples

Pos­i­tive examples

Addition

\(x+y = y+x\) for all num­bers \(x\) and \(y,\) so ad­di­tion com­mutes. One easy way to see this fact is to con­sider a phys­i­cal sys­tem that im­ple­ments ad­di­tion, e.g., by tak­ing two piles of poker chips (where a poker chip with nn chips rep­re­sents the num­ber nn) in on two in­put belts, and pro­duc­ing a pile of poker chips on the out­put belt. This func­tion can be im­ple­mented by sim­ply shov­ing both in­put piles onto the out­put pile. Be­cause a pile of chips rep­re­sents the same num­ber re­gard­less of how those chips are ar­ranged on the out­put belt, it doesn’t mat­ter which pile comes in on which in­put belt, so ad­di­tion is com­mu­ta­tive.

Multiplication

\(x \times y = y \times x\) for all num­bers \(x\) and \(y,\) so mul­ti­pli­ca­tion also com­mutes. It is a bit harder to see why this must be so in the case of mul­ti­pli­ca­tion, as \(x \times y\) can be in­ter­preted as “take the \(x\) in­put and stretch it out ac­cord­ing to the \(y\) in­put,” and it’s not en­tirely ob­vi­ous that “stretch­ing the \(x\) in­put ac­cord­ing to \(y\)” should yield the same re­sult as “stretch­ing the \(y\) in­put ac­cord­ing to \(x.\)

To see that mul­ti­pli­ca­tion com­mutes, it is helpful to vi­su­al­ize copy­ing \(x\) (rather than stretch­ing it out) into \(y\) many rows. This al­lows us to vi­su­al­ize \(x \times y\) as a square di­vided into \(x\) parts along one side and \(y\) parts along the other side, which makes it clearer that mul­ti­pli­ca­tion com­mutes.

Multiplicaiton commutes

It is worth not­ing that the con­cept of “mul­ti­pli­ca­tion” gen­er­al­izes be­yond the con­cept of “num­bers,” and in those con­texts, “stretch­ing \(x\) out ac­cord­ing to \(y\)” and “stretch­ing \(y\) out ac­cord­ing to \(x\)” might be quite differ­ent op­er­a­tions. For ex­am­ple, mul­ti­pli­ca­tion of ma­tri­ces does not com­mute.

Max­i­mum and minimum

The max and min func­tions com­mute, be­cause “which of these el­e­ments is largest/​small­est?” is a ques­tion that doesn’t de­pend upon the or­der that the el­e­ments are pre­sented in.

Rock, Paper, Scissors

The ques­tion of who won in a game of rock-pa­per-scis­sors is com­mu­ta­tive. Writ­ing \(r\) for rock, \(p\) for pa­per, \(s\) for scis­sors, and \(?\) for the bi­nary op­er­a­tor say­ing who won, we have \(r ? p = p,\) \(r ? s = r,\) and \(p ? s = s,\) and so on. This func­tion is com­mu­ta­tive: who won a game of rock-pa­per-scis­sors does not de­pend upon which side of the judge they were stand­ing on.

This pro­vides an ex­am­ple of a com­mu­ta­tive func­tion that is not as­so­ci­a­tive: \(r?p=p?r\) and so on, but \((r?p)?s=s\) while \(r?(p?s)=r.\) In other words, who won a game of rock-pa­per-scis­sors does not de­pend on which side of the judge they were stand­ing on, but if you have a line of peo­ple throw “rock,” “pa­per,” or “scis­sors,” then the ques­tion “who won?” does de­pend on which end of the line you start from.

Nega­tive examples

Concatenation

Any func­tion that in­cludes its in­puts in its out­puts in or­der is not com­mu­ta­tive. For ex­am­ple, the func­tion pair which puts its in­puts into a pair (such that pair(x, y) = (x, y)) is not com­mu­ta­tive. The func­tion con­cat, which also sticks its in­puts to­gether in or­der, is also not com­mu­ta­tive, though it is as­so­ci­a­tive.

Division

Divi­sion is not com­mu­ta­tive, be­cause \(x / y\) does not equal \(y / x\) in gen­eral. In this case, the func­tion is us­ing \(x\) and \(y\) in a very differ­ent way. One is in­ter­preted as a nu­mer­a­tor that will be cut up, the other is treated as a de­nom­i­na­tor that says how many times to cut the nu­mer­a­tor up. Numer­a­tor and de­nom­i­na­tor are not ex­change­able con­cepts: Divi­sion needs to know which in­put is in­tended to be the nu­mer­a­tor and which is in­tended to be the de­nom­i­na­tor.

Ma­trix multiplication

Ma­trix mul­ti­pli­ca­tion is not only non-com­mu­ta­tive, it may fail to even make sense. Two ma­tri­ces can be mul­ti­plied if and only if the num­ber of columns in the left-hand ma­trix is equal to the num­ber of rows in the right-hand ma­trix. Thus, a \(2 \times 3\) ma­trix can be mul­ti­plied with a \(3 \times 5\) ma­trix if and only if the \(2 \times 3\) ma­trix is on the left. Clearly, then, ma­trix mul­ti­pli­ca­tion does not com­mute.

Parents: