Sub topic 11
Testing Commutativity and Associativity with Numbers
This chapter assumes you can evaluate a defined operation by substitution, handle negative and fractional inputs, and evaluate nested expressions from the inside out. Those skills are the whole toolkit here. Testing a property means evaluating the same operation twice in two different arrangements and comparing the results.
What the two properties claim
An operation ★ is commutative if swapping the two inputs never changes the result. In symbols, a★b = b★a for every pair of inputs.
An operation ★ is associative if regrouping three inputs never changes the result. In symbols, (a★b)★c = a★(b★c) for every triple of inputs.
Both definitions say "for every". That wording sets the rules for testing:
- One pair or triple that fails is enough to prove the property false. This is a counterexample.
- Any number of pairs or triples that pass does not prove the property true. Passing examples only make it plausible.
Ordinary addition and multiplication have both properties. Subtraction and division have neither, and exponentiation has neither. A made-up operation can have one, both, or neither, so you cannot guess from how it looks.
The basic test for commutativity
Take the operation a★b = 2a + b², used throughout this tutorial. Choose two different numbers and evaluate both orders.
- 3★4 = 2(3) + 4² = 6 + 16 = 22
- 4★3 = 2(4) + 3² = 8 + 9 = 17
Since 22 ≠ 17, the operation is not commutative. One pair settles the question.
The basic test for associativity
Associativity needs three inputs and two groupings. Use 1, 2, and 3.
- Left grouping: (1★2)★3. First 1★2 = 2 + 4 = 6. Then 6★3 = 12 + 9 = 21.
- Right grouping: 1★(2★3). First 2★3 = 4 + 9 = 13. Then 1★13 = 2 + 169 = 171.
Since 21 ≠ 171, the operation is not associative.
Notice that the inner parentheses are always evaluated first, but they sit in different places in the two groupings. That is why the results can differ.
Choosing test values well
A bad choice of test values can make a failing property look true. Avoid these traps.
- Equal inputs. Commutativity always holds when a = b, because you are comparing a★a with itself. Always pick two different numbers.
- Identity-like values. Inputs such as 0 and 1 make many operations collapse. For example, 0 + anything and 1 × anything hide differences.
- Accidental coincidences. For a★b = 2a + b², setting 2a + b² = 2b + a² and rearranging gives (a − b)(a + b − 2) = 0. So the operation commutes whenever a = b or a + b = 2. The pair (0, 2) gives 0★2 = 4 and 2★0 = 4, which match. A test using only that pair would wrongly suggest commutativity.
- Positive-only values. Squares and absolute values behave differently for negatives, so include at least one negative number.
A good default set is two small distinct integers, one of them negative, plus one fraction if the operation divides. For example, test (−2, 3) rather than (1, 1).
Four operations compared
The table shows four operations and which properties they have. Each row was checked with the methods above.
| Operation | Commutative? | Associative? | Counterexample or reason |
|---|---|---|---|
| a★b = 2a + b² | No | No | 3★4 = 22 but 4★3 = 17 |
| a◆b = (a + b)/2 (average) | Yes | No | (0◆4)◆8 = 5 but 0◆(4◆8) = 3 |
| a∘b = a (returns the first input) | No | Yes | 1∘2 = 1 but 2∘1 = 2 |
| a⊕b = a + b + ab | Yes | Yes | a⊕b = (a + 1)(b + 1) − 1 |
The average operation shows that commutative does not imply associative. The "first input" operation shows the reverse: associative does not imply commutative. Check the ◆ row yourself. 0◆4 = 2, then 2◆8 = 5. Also 4◆8 = 6, then 0◆6 = 3.
For ⊕, the shortcut is worth knowing. Because a⊕b + 1 = (a + 1)(b + 1), ⊕ inherits both properties from ordinary multiplication. Rewriting an operation as a familiar one is a legitimate way to prove a property for all inputs, but the GRE rarely requires it.
A decision routine
The diagram shows the order of work when a question asks whether an operation has a property.
For commutativity, the two arrangements are a★b and b★a. For associativity, they are (a★b)★c and a★(b★c).
Automating the test in Python
The script below searches a grid of values for counterexamples. It uses Fraction so division stays exact. A return value of None means no counterexample was found in the grid, which supports the property but does not prove it.
from itertools import product
from fractions import Fraction
def star(a, b):
return 2 * a + b ** 2
def avg(a, b):
return Fraction(a + b, 2)
def first(a, b):
return a
def plus_times(a, b):
return a + b + a * b
def commutative_counterexample(op, values):
for a, b in product(values, repeat=2):
if op(a, b) != op(b, a):
return (a, b, op(a, b), op(b, a))
return None
def associative_counterexample(op, values):
for a, b, c in product(values, repeat=3):
left = op(op(a, b), c)
right = op(a, op(b, c))
if left != right:
return (a, b, c, left, right)
return None
values = [-2, -1, 0, 1, 2, 3]
operations = [star, avg, first, plus_times]
for op in operations:
print(op.__name__)
print(" commutative counterexample:", commutative_counterexample(op, values))
print(" associative counterexample:", associative_counterexample(op, values))For first, the commutativity search returns (-2, -1, -2, -1), because first(-2, -1) is -2 and first(-1, -2) is -1. The associativity search returns None, which matches the table. For star, both searches return a tuple, so both properties fail. For avg, the commutativity search returns None and the associativity search returns a tuple.
The grid includes negatives and zero but is small. That is enough for most GRE-style operations, but a grid can still miss a rare failure.
Algebraic checks
Sometimes algebra is faster than hunting for numbers. To test commutativity, write a★b and b★a in full and see whether they are the same expression.
- For a★b = a² + b², swapping gives b² + a², which is identical. The operation is commutative.
- For a★b = a² − b, swapping gives b² − a. These differ in general, so it is not commutative. The pair (3, 1) confirms it: 3★1 = 8 and 1★3 = −2.
For associativity, the algebra gets long, so numbers are usually quicker for disproving. Use algebra when you suspect the property holds and want to see why.
A useful shortcut: if an operation contains subtraction or division of the inputs, or treats the two inputs differently, such as a² + b or 2a + b, suspect that commutativity fails. Then confirm with a pair of distinct numbers.
How the properties show up on the GRE
You will usually meet these ideas in three forms.
- Direct property question. "Which of the following must be true about ★?" The answer choices may include "★ is commutative." Test each claim with a counterexample and eliminate the false ones.
- Quantity comparison. Column A is a★b and Column B is b★a for specific values. This is only evaluation. Do not assume the columns are equal. Compute both.
- Hidden use of a property. A problem may let you rearrange, such as writing (x★y)★z as x★(y★z), only if the problem tells you the operation is associative. If the problem does not say so, do not assume it.
On "must be true" questions, a single counterexample eliminates a choice. On "could be true" questions, one example that works is enough to keep it.
Common errors
- Declaring a property true from one passing example. Passing tests never prove a "for every" claim.
- Testing equal inputs. The pair (a, a) always satisfies commutativity.
- Evaluating the right grouping in the wrong order. In a★(b★c), the inner operation b★c comes first, and its value becomes the second input of the outer operation. In a nonsymmetric operation, putting it in the first slot gives a wrong answer.
- Mixing up the two properties. Commutativity is about order of two inputs. Associativity is about grouping of three.
- Forgetting that squaring a negative input gives a positive result. In 2★(−3), the second term is (−3)² = 9, not −9.
Exercise
Define a★b = 3a − b. Show that ★ is not commutative by using the pair (5, 2), and then find the one condition on a and b under which a★b = b★a.
Show answer
5★2 = 15 − 2 = 13, and 2★5 = 6 − 5 = 1. Since 13 ≠ 1, ★ is not commutative. For the condition, set 3a − b = 3b − a, which gives 4a = 4b, so a = b. The two orders agree only when the inputs are equal.
Exercise
Define a▲b = |a − b|, the distance between a and b. Is ▲ commutative? Is it associative? Test with the triple (1, 3, 6) for associativity.
Show answer
It is commutative, because |a − b| = |b − a|. It is not associative. Left grouping: (1▲3)▲6 = |1 − 3|▲6 = 2▲6 = 4. Right grouping: 1▲(3▲6) = 1▲|3 − 6| = 1▲3 = 2. Since 4 ≠ 2, the operation is not associative.
Exercise
Define a♦b = a + b − 2. A student tests only (1, 1) and (0, 2) and concludes that ♦ is associative. Evaluate (3♦4)♦5 and 3♦(4♦5) and state whether the student's conclusion is supported.
Show answer
3♦4 = 5, then 5♦5 = 8. Also 4♦5 = 7, then 3♦7 = 8. The two groupings agree, so the conclusion is correct for this triple. In fact, both groupings equal a + b + c − 4 for all inputs, so ♦ is associative. However, the student's evidence was weak, since (1, 1) uses equal inputs and (0, 2) is a special pair, and neither is a three-input test. The conclusion happened to be right, but it needed a triple or an algebraic argument.