Associator
A = associator(X, Y, Z, option)
This function is provided for octonions only, since quaternion multiplication is associative and the function would return either zero or one, depending on the option in the quaternion case, regardless of the data parameters.
A = associator(X, Y, Z) returns (X .* Y) .* Z - X .* (Y .* Z). The same result is returned with option 'diff'.
A = associator(X, Y, Z, 'prod') returns that octonion that multiplies the product (X .* Y) .* Z on the right to give the result of the product X .* (Y .* Z)
Octonions are not associative, but quaternion-like subsets are, as shown below (this shows the difference associator, which is zero when the three parameters associate):
>> 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 * OThree octonions chosen at random have two evaluation orders for their product in a given order, and the associator multiplies one of these results to give the other:
>> x = rando; y = rando; z = rando; >> ((x .* y) .* z) .* associator(x, y, z, 'prod') ans = 0.2046 - 0.3172 * I + 0.3426 * J - 0.2111 * K + 0.4448 * L - 0.423 * M + 0.005592 * N - 0.5646 * O >> x .* (y .* z) ans = 0.2046 - 0.3172 * I + 0.3426 * J - 0.2111 * K + 0.4448 * L - 0.423 * M + 0.005592 * N - 0.5646 * O