symop.ccr.algebra.ket.apply

Apply operator words to symbolic kets.

A symbolic ket is represented as a finite linear combination of normally-ordered monomials,

\[\lvert \psi \rangle \sim \sum_k c_k\, M_k,\]

where each \(M_k\) is a normally-ordered monomial in ladder operators.

This module implements left-multiplication by an operator word

\[W = \hat o_1 \hat o_2 \cdots \hat o_L,\]

acting as \(\lvert \psi \rangle \mapsto W \lvert \psi \rangle\), and also the action of a linear combination of words.

Functions

ket_apply_word(ket, word, *[, eps])

Apply a single operator word to a symbolic ket.

ket_apply_words_linear(ket, terms, *[, eps])

Apply a linear combination of operator words to a ket.

ket_apply_word(ket: tuple[KetTerm, ...], word: Iterable[LadderOp], *, eps: float = 1e-12) tuple[KetTerm, ...]

Apply a single operator word to a symbolic ket.

The operator word (an ordered sequence of ladder operators) is expanded into a normally-ordered ket via ket_from_word(). The resulting expansion is then multiplied with the input ket using ket_multiply(), yielding the normally-ordered result of left multiplication by the given operator product.

Parameters:
  • ket (tuple[KetTerm, ...]) – Input ket as a tuple of ket terms.

  • word (Iterable[LadderOp]) – Iterable of ladder operators forming the operator product to apply on the left.

  • eps (float) – Numerical tolerance forwarded to normal ordering / canonicalization

Returns:

The resulting ket terms, normally ordered.

Return type:

tuple[KetTermProto, …]

Notes

This performs symbolic normal ordering only; no matrix representation is involved.

ket_apply_words_linear(ket: tuple[KetTerm, ...], terms: Iterable[tuple[complex, Iterable[LadderOp]]], *, eps: float = 1e-12) tuple[KetTerm, ...]

Apply a linear combination of operator words to a ket.

For each pair (c, word) in terms, this computes ket_apply_word() and scales the result by c. All partial results are concatenated and canonicalized using combine_like_terms_ket().

Parameters:
  • ket (tuple[KetTerm, ...]) – Input ket as a tuple of ket terms.

  • terms (Iterable[tuple[complex, Iterable[LadderOp]]]) – Iterable of pairs (coeff, word) describing the linear combination.

  • eps (float) – Numerical tolerance forwarded to normal ordering / canonicalization

Returns:

The resulting ket terms, combined into a canonical form.

Return type:

tuple[KetTermProto, …]