symop.ccr.algebra.ket.inner

Symbolic inner products for CCR ket expansions.

This module provides a purely symbolic routine to compute inner products between ket expansions represented as sums of normally ordered monomials.

Given two expansions

\[\lvert a \rangle \;\sim\; \sum_i c_i\, M_i, \qquad \lvert b \rangle \;\sim\; \sum_j d_j\, N_j,\]

the inner product is

\[\langle a \mid b \rangle = \sum_{i,j} c_i^* d_j \,\langle 0 \mid M_i^\dagger N_j \mid 0 \rangle.\]

Each contribution is evaluated by forming the operator word corresponding to \(M_i^\dagger N_j\), expanding it into normal order using symop.ccr.algebra.ket.from_word.ket_from_word(), and extracting the scalar (identity) coefficient, which is the only part that survives the vacuum sandwich.

Functions

ket_inner(a, b, *[, eps])

Compute the symbolic inner product \(\langle a \mid b \rangle\).

ket_inner(a: tuple[KetTerm, ...], b: tuple[KetTerm, ...], *, eps: float = 1e-12) complex

Compute the symbolic inner product \(\langle a \mid b \rangle\).

The inputs are tuples of ket terms representing formal expansions

\[\lvert a \rangle \;\sim\; \sum_i c_i\, M_i, \qquad \lvert b \rangle \;\sim\; \sum_j d_j\, N_j,\]

where \(M_i\) and \(N_j\) are normally ordered monomials of ladder operators.

For each pair of terms, the contribution to the inner product is computed as

\[c_i^* d_j \,\langle 0 \mid M_i^\dagger N_j \mid 0 \rangle,\]

which equals the coefficient of the identity operator in the normal-ordered expansion of the word \(M_i^\dagger N_j\). This identity coefficient is obtained by expanding the word with symop.ccr.ket.from_word.ket_from_word() and extracting the identity term via symop.ccr.ket.identity_coeff.identity_coeff().

Parameters:
  • a (tuple[KetTerm, ...]) – Tuple of ket terms representing \(\lvert a \rangle\).

  • b (tuple[KetTerm, ...]) – Tuple of ket terms representing \(\lvert b \rangle\).

  • eps (float) – Coefficient threshold used to skip negligible input terms and to discard negligible terms during intermediate normal ordering.

Returns:

The inner product \(\langle a \mid b \rangle\).

Return type:

complex

Notes

  • The adjoint \(M^\dagger\) is formed by reversing operator order, swapping creators and annihilators, and applying dagger() to each ladder operator.

  • Only the scalar (identity) component of \(M_i^\dagger N_j\) contributes to the vacuum sandwich.

  • This routine is purely symbolic and does not form matrix representations.