thchr / GellMannMatrices.jl

Generalized Gell-Mann bases for Hermitian matrices
MIT License
4 stars 0 forks source link

Incorrect (or nonstandard?) normalization of the eigth Gell Mann Matrix #2

Closed MasonProtter closed 1 year ago

MasonProtter commented 1 year ago
julia> using GellMannMatrices

julia> map(gellmann(3)) do λi
           tr(λi * λi)
       end
8-element Vector{ComplexF64}:
 2.0 + 0.0im
 2.0 + 0.0im
 2.0 + 0.0im
 2.0 + 0.0im
 2.0 + 0.0im
 2.0 + 0.0im
 2.0 + 0.0im
 6.0 + 0.0im

Normally the final Gell Mann matrix has a normalization factor of 1/sqrt(3)

thchr commented 1 year ago

There's a normalize kwarg that'll enable this. From the doc-string:

"""
    gellmann([T::Type{<:AbstractMatrix} = Matrix{ComplexF64},] d::Integer;
             skip_identity = true, normalize = false)

## Keyword arguments
[...]
- `normalize` (default, `false`): if `true`, matrices are normalized in a manner that
  ensures the orthonormality relation `tr(Mᵢ'*Mⱼ) = 2δᵢⱼ`; if `false`, a choice of matrix
  elements favoring simplicity is made (i.e., integer elements).
[...]

So that:

julia> map(gellmann(3; normalize=true)) do λi
           tr(λi * λi)
       end
8-element Vector{ComplexF64}:
 2.0 + 0.0im
 2.0 + 0.0im
 2.0 + 0.0im
 2.0 + 0.0im
 2.0 + 0.0im
 2.0 + 0.0im
 2.0 + 0.0im
 2.0 + 0.0im

I suppose we could flip the default (it's false because i preferred simplicity of elements for the application I needed this for).

JaniPenttala commented 1 year ago
julia> map(gellmann(4,normalize=true)) do λi
                  tr(λi * λi)
              end
15-element Vector{ComplexF64}:
                2.0 + 0.0im
                2.0 + 0.0im
                2.0 + 0.0im
                2.0 + 0.0im
                2.0 + 0.0im
                2.0 + 0.0im
                2.0 + 0.0im
                6.0 + 0.0im
                2.0 + 0.0im
                2.0 + 0.0im
                2.0 + 0.0im
                2.0 + 0.0im
                2.0 + 0.0im
                2.0 + 0.0im
 1.9999999999999998 + 0.0im

It seems that there is some bug in normalizing Gell-Mann matrices for higher dimensions. Note that in this example the 8th matrix is normalized to 6.

thchr commented 1 year ago

Ah, thanks - there was a bug; I hadn't passed on the normalization kwarg recursively for the diagonal matrices: fixed now by https://github.com/thchr/GellMannMatrices.jl/commit/35068d152130a8167722f3adad553be0dbd0500d (and fixed on latest version on the registry).

thchr commented 1 year ago

Re. the original issue: I've updated the README to now include the normalization kwarg.

With that, I'll close this for now. If you feel we should normalize the matrices by default, I'd be open to that also (but let me know then).