Angular Momentum Commutators In Symbolics.jl

Could I get some help defining the angular momentum commutators symbolicaly in Julia?

I’ve tried using SymbolicUtils @acrules to define Nx*Ny - Ny*Nx => im*Nz but then when I run Nx*Ny - Ny*Nx it returns zero. I also tried defining the syms as Matrices but that returns errors about lack of methods or unknown dimensions.

Does anyone know how to get this to work? Thanks in advance!

4 Likes

The ac in @acrules stands for “associative, commutative”. You’re trying to handle a non-commutative operation, so you can’t use @acrules for this. Last I checked, it’s a bit hard to handle non-commutative operators still in Symbolics.jl (but maybe it’s better now, I’m not sure)

2 Likes

I would be very happy about a tutorial on how to implement simple, non-commutative algebra with Symbolics.jl, too!