# Angular Momentum Commutators In Symbolics.jl

**URL:** https://discourse.julialang.org/t/angular-momentum-commutators-in-symbolics-jl/103493
**Category:** Modelling & Simulations
**Tags:** question, quantum, physics, chemistry, symbolics
**Created:** [September 3, 2023, 8:32pm UTC](https://discourse.julialang.org/t/angular-momentum-commutators-in-symbolics-jl/103493 "2023-09-03T20:32:39Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![wes648](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wes648/32/43541_2.png) [@wes648](https://discourse.julialang.org/u/wes648)
#### Post date: [September 3, 2023, 8:32pm UTC](https://discourse.julialang.org/t/angular-momentum-commutators-in-symbolics-jl/103493/1 "2023-09-03T20:32:39Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)
#### Post date: [September 4, 2023, 11:01am UTC](https://discourse.julialang.org/t/angular-momentum-commutators-in-symbolics-jl/103493/2 "2023-09-04T11:01:15Z")

</div>

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)

---

<div class="post-metadata">

### Author: ![jamblejoe](https://avatars.discourse-cdn.com/v4/letter/j/ee7513/32.png) [@jamblejoe](https://discourse.julialang.org/u/jamblejoe)
#### Post date: [September 20, 2023, 1:21pm UTC](https://discourse.julialang.org/t/angular-momentum-commutators-in-symbolics-jl/103493/3 "2023-09-20T13:21:59Z")

</div>

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