Skip to content

observe

Compute the expectation value of an observable for a given state.

observe

observe(
    state: Union[MPS, MPO, Sequence[Tensor]],
    observable: Union[MPO, Sequence[Tensor]],
) -> float

Compute the expectation value of an observable for a given state.

Dispatches to the appropriate contraction routine based on the type of state:

  • MPS (or a plain sequence of tensors): evaluates ⟨ψ|O|ψ⟩ via a left-to-right MPS-MPO-MPS transfer-matrix sweep.
  • MPO (thermal density matrix): not yet implemented.

Parameters:

Name Type Description Default
state Union[MPS, MPO, Sequence[Tensor]]

The state to evaluate. Either an MPS object, or a plain sequence of MPS site tensors.

required
observable Union[MPO, Sequence[Tensor]]

The observable encoded as an MPO object, or a plain sequence of MPO site tensors, of the same length as state.

required

Returns:

Type Description
float

The expectation value of the observable.

Raises:

Type Description
TypeError

If state is not an MPS or a sequence of tensors.

NotImplementedError

If state is an MPO (thermal density matrix support is pending).

Notes

observe performs a left-to-right MPS–MPO–MPS transfer-matrix sweep. At each site it contracts the bra (conjugated MPS tensor), the MPO tensor, and the ket (MPS tensor) into an updated environment. The final environment is a 1×1×1 tensor; the scalar value — corrected for SU(2) Bridge normalization — is returned.

See Also