commute

Matrix commutator.

Syntax
C = commute(A,B)
Description

This function returns the commutator of its two matrix arguments A and B

C = [A,B] = AB - BA.

Examples

The commutator [Sx,Sy] of a spin-1/2 is returned by the following code

Sx = sop(1/2,'x'); Sy = sop(1/2,'y');
C = commute(Sx,Sy)
C =
        0 + 0.5000i        0
        0                  0 - 0.5000i

This is obviously equal to iSz.

See also

ham, sop, stev