symop.ccr.algebra.ket.from_word¶
Symbolic normal ordering of ladder-operator words for ket expansions.
This module provides routines that expand ordered products of ladder operators (operator words) into linear combinations of normally ordered monomials acting on kets.
Given a word
with \(\hat o_k\) bosonic ladder operators (creation or annihilation), the goal is to compute a symbolic normal-ordered expansion
where each monomial \(M_k\) has all creation operators to the left of all annihilation operators.
The rewrite uses the canonical commutation relations (CCR)
allowing for non-orthogonal modes via the overlap factor \(\langle m_i \mid m_j \rangle\).
Algorithmic strategy¶
The expansion is performed left-to-right. When inserting a creation operator into a partially normal-ordered monomial, the algorithm:
Appends the creation operator to the creator list.
Contracts it once with each existing annihilator, removing that annihilator and multiplying the coefficient by the CCR scalar.
This “single-sided contraction” convention avoids double counting and yields the exact normal-ordered form.
Scope¶
This module performs purely symbolic algebra. It does not:
Evaluate states numerically.
Apply the result to a vacuum state.
Perform basis changes or approximations.
Higher-level operations (e.g. applying to vacuum or combining like terms across polynomials) are handled in other modules of the CCR layer.
Design notes¶
Monomials preserve operator order within creators and annihilators.
Structural identity is defined via stable, hashable signatures.
No pretty-printing or presentation logic is included here.
This file sits near the core of the CCR ket algebra and should remain dependency-light and algorithmically transparent.
Functions
|
Expand a ladder-operator word into normally ordered ket terms. |
- ket_from_word(*, ops: Iterable[LadderOp], eps: float = 1e-12) tuple[KetTerm, ...]¶
Expand a ladder-operator word into normally ordered ket terms.
This function takes an ordered product (a word) of ladder operators
\[W = \hat o_1 \hat o_2 \cdots \hat o_L,\]and rewrites it symbolically into a finite linear combination of normally ordered monomials (all creators to the left of all annihilators):
\[W = \sum_k c_k\, M_k.\]The rewrite uses the canonical commutation relations (CCR) for bosonic ladder operators, allowing non-orthogonal modes via a mode overlap factor:
\[[\hat a_i, \hat a_j^\dagger] = \langle m_i \mid m_j \rangle.\]Here the scalar commutator value is provided by the ladder-operator implementation (typically via
a.commutator(adag)).Algorithm¶
The implementation processes operators left-to-right, maintaining a linear combination of normally ordered monomials.
If the next operator is an annihilator, it is appended to the monomial’s annihilator list (normal order is preserved).
If the next operator is a creator, it is appended to the creator list. Additionally, it is contracted once with each existing annihilator in the monomial, producing extra terms where that annihilator is removed and the coefficient is multiplied by the CCR scalar.
This “single-sided contraction” convention avoids double counting and produces the exact normal-ordered expansion of the input word.
- type ops:
Iterable[LadderOp]- param ops:
Ladder operators forming the word to be expanded, processed left-to-right.
- type eps:
- param eps:
Coefficient threshold. Terms with \(|c| \le \texttt{eps}\) are discarded.
- returns:
Ket terms \((c_k, M_k)\) representing the normal-ordered expansion, sorted by monomial signature.
- rtype:
tuple[KetTerm, …]
Notes
This routine performs symbolic normal ordering only. It does not evaluate the action on a vacuum state. If you need \(W\lvert 0\rangle\), apply a separate step that discards any term containing annihilation operators.