Associator
A = associator(X, Y, Z)
A = associator(X, Y, Z) returns (X * Y) * Z - X * (Y * Z). The parameters may be quaternions, octonions, or anything else that makes sense. The multiplication used is matrix multiplication. No check is made on whether the parameters are of compatible types.
Matrix multiplication is associative, so three random real matrices will produce a zero result:
>> A = randn(2); B = randn(2); C = randn(2); >> associator(A, B, C) ans = 1.0e-15 * 0.1110 0 0.2220 -0.0555
Octonions are not associative, but quaternion-like subsets are, as shown below:
>> associator(oi, oj, ok) ans = 0 * I + 0 * J + 0 * K + 0 * L + 0 * M + 0 * N + 0 * O >> associator(oi, ol, oo) ans = 0 * I + 2 * J + 0 * K + 0 * L + 0 * M + 0 * N + 0 * O
Quaternions are associative, so any three chosen at random will have a zero associator.
>> associator(randq, randq, randq) ans = -5.551e-17 * I + 0 * J + 1.11e-16 * K