Commutator
C = commutator(X, Y, option)
C = commutator(X, Y) returns X .* Y - Y .* X and C = commutator(X, Y, 'diff') returns the same result.
C = commutator(X, Y, 'prod') returns the quaternion c that multiplies the product X .* Y on the right to give the result of the product Y .* X.
>> x = randq; y = randq; >> x .* y .* commutator(x, y, 'prod') ans = 0.254 + 0.8994 * I + 0.313 * J + 0.169 * K >> y .* x ans = 0.254 + 0.8994 * I + 0.313 * J + 0.169 * K
Reals commute so the commutator of any two reals will be zero:
>> commutator(randn, randn) ans = 0