Skip to content

About

A python script to calculate the Kac matrix of Virasoro algebra in conformal field theory.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Virasoro Kac Matrix

A Python script that computes the Kac matrix (Gram matrix) of the Verma module for the Virasoro algebra at a given level. The entries are symbolic polynomials in the central charge c and the highest weight h.

Mathematical background

The Virasoro algebra is the infinite‑dimensional Lie algebra generated by L_n (n ∈ ℤ) with commutation relations $$[L_m, L_n] = (m - n) L_{m+n} + c/12 (m³ - m) δ_{m+n,0}$$

A highest‑weight representation is built on a state |h⟩ satisfying L_0|h⟩ = h|h⟩ and L_n|h⟩ = 0 for n > 0. The states of the Verma module at integer level N are spanned by $$L_{-λ₁} L_{-λ₂} … L_{-λ_k} |h⟩ $$ where λ = (λ₁, λ₂, …) is a partition of N into positive integers, usually written in non‑increasing order.

The Kac matrix (or Gram matrix) M(N) records the inner products between these basis states. Its determinant, the Kac determinant, gives the condition for the existence of singular (null) vectors. The matrix elements are computed recursively using the algebra commutation relations.

What the script does

  • Generates all integer partitions of the given level N.
  • For every pair of partitions, builds the appropriate product of Virasoro generators and evaluates the vacuum expectation value ⟨h| … |h⟩ symbolically.
  • Returns the symmetric matrix of inner products as SymPy expressions.
  • Caches intermediate results (functools.lru_cache) for speed.
  • Prints the matrix in both SymPy pretty‑print and a plain‑text format (with ^ for exponentiation and no * for multiplication).

Dependencies

  • Python ≥ 3.8
  • SymPy (install with pip install sympy)

The script uses only the standard library and SymPy; NumPy is not required.

Usage

Run from the command line:

python kac.py [level]

If no level is given, the default is 4.

Example:

python3 Kac.py 3
Kac matrix for level 3:
⎡24⋅h⋅(h + 1)⋅(2⋅h + 1)  12⋅h⋅(3⋅h + 1)     24⋅h   ⎤
⎢                                                  ⎥
⎢    12⋅h⋅(3⋅h + 1)      h⋅(c + 8⋅h + 8)    10⋅h   ⎥
⎢                                                  ⎥
⎣         24⋅h                10⋅h        2⋅c + 6⋅h⎦

String matrix (with '^' and no '*'):
['24h(h + 1)(2h + 1)', '12h(3h + 1)', '24h']
['12h(3h + 1)', 'h(c + 8h + 8)', '10h']
['24h', '10h', '2c + 6h']

Performance

The number of partitions grows rapidly (≈ $p(N) ~ e^{π√(2N/3)} / 4N√3$), so computation becomes expensive for N > 8–9. Memoization greatly reduces the number of recursive calls, but the exponential complexity remains. For higher levels you may need to add more optimisations or use a dedicated determinant formula.

License

This project is released under the MIT License. Feel free to use, modify, and distribute it.

About

A python script to calculate the Kac matrix of Virasoro algebra in conformal field theory.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages