Sub topic 11
Testing Commutativity and Associativity with Numbers
Assume you know order of operations, substitution into algebraic expressions, and basic equations. This chapter uses those skills to test properties of a made-up operation with actual numbers.
Two Properties to Test
A defined operation is a rule. For example:
a \star b = 2a+b^2The symbol \(\star\) has no standard meaning here. Always use the definition that the question gives.
Two useful properties are commutativity and associativity.
An operation is commutative if switching the inputs does not change the result:
a\star b=b\star aAn operation is associative if changing the grouping does not change the result:
(a\star b)\star c=a\star(b\star c)These properties describe the operation itself. They are not automatically true just because the operation uses familiar arithmetic.
Testing Commutativity
To test commutativity, calculate both orders using the same two values.
Use \(a=3\) and \(b=4\):
3\star4=2(3)+4^2=6+16=22Now reverse the inputs:
4\star3=2(4)+3^2=8+9=17Because \(22\ne17\), the operation is not commutative.
One unequal pair is enough to disprove commutativity. If a question asks whether the operation is commutative, you can answer “no” after finding one counterexample. A counterexample is a specific case that disproves a claim.
A matching pair does not prove commutativity. For example, some choices might accidentally give equal results. You would need an algebraic proof or enough information about the rule to show equality for every possible pair.
| Test | First calculation | Reversed calculation | Conclusion |
|---|---|---|---|
| \(a=3,b=4\) | \(3\star4=22\) | \(4\star3=17\) | Not commutative |
The order matters because the first input is multiplied by 2, while the second input is squared. These positions have different jobs.
def star(a, b):
return 2 * a + b ** 2
print(star(3, 4)) # 22
print(star(4, 3)) # 17Testing Associativity
Associativity compares two different groupings of three inputs:
(a\star b)\star c
\quad\text{and}\quad
a\star(b\star c)Use \(a=1\), \(b=2\), and \(c=3\).
First calculate the left grouping:
1\star2=2(1)+2^2=6Then use 6 as the first input:
(1\star2)\star3=6\star3=2(6)+3^2=21Now calculate the right grouping:
2\star3=2(2)+3^2=13Then use 13 as the second input:
1\star(2\star3)=1\star13=2(1)+13^2=171Since \(21\ne171\), this operation is not associative.
def star(a, b):
return 2 * a + b ** 2
left = star(star(1, 2), 3)
right = star(1, star(2, 3))
print(left) # 21
print(right) # 171The parentheses determine which operation happens first. Do not treat the expression as though \(\star\) were ordinary addition or multiplication.
A Reliable GRE Routine
When a GRE question asks about commutativity or associativity:
- Copy the definition exactly.
- Choose small integers unless the question supplies values.
- Substitute carefully, keeping parentheses around negative or compound inputs.
- Evaluate the left and right sides separately.
- Compare the final values.
- Check that you did not reverse the input positions.
For a commutativity question, compare \(a\star b\) with \(b\star a\). For an associativity question, compare \((a\star b)\star c\) with \(a\star(b\star c)\).
Exercise
For the operation a star b = a - 2b, is the operation commutative? Is it associative? Use a = 1, b = 2, and c = 3 to test both properties.
Show answer
It is not commutative because 1 star 2 = -3, while 2 star 1 = 0. It is not associative because (1 star 2) star 3 = -9, while 1 star (2 star 3) = 11.