Associative Property of numbers says that we can re-group two
multiplication terms so that one is evaluated before the other without changing the value of the expression.
The formulation of this property is the same for addition and multiplication:
(a + b) + c = a + (b + c)
(a * b) * c = a * (b * c)
Interestingly, applying the associative property of numbers to a binary expression tree is a standard tree operation called a "node rotation."
(a + b) + c = a + (b + c) (y) + + (x) / \ / \ / \ / \ (x) + c -> a + (y) / \ / \ / \ / \ a b b c
(a * b) * c = a * (b * c) (x) * * (y) / \ / \ / \ / \ (y) * c <- a * (x) / \ / \ / \ / \ a b b c
All the examples shown below are drawn from the mathy test suite that verifies the expected input/output combinations for rule transformations.
|1f + 98i + 3f + 14t||1f + (98i + 3f) + 14t||✔|
|8x^2 * (9b * 7)||(8x^2 * 9b) * 7||✔|
|2 + 1 + 6||2 + (1 + 6)||✔|
|2 + (1 + 6)||2 + 1 + 6||✔|
|(2 + x) + 9||2 + (x + 9)||✔|