# cirq.wavefunction_partial_trace_as_mixture¶

cirq.wavefunction_partial_trace_as_mixture(wavefunction: numpy.ndarray, keep_indices: List[int], *, atol: Union[int, float] = 1e-08) → Tuple[Tuple[float, numpy.ndarray], …][source]

Returns a mixture representing a wavefunction with only some qubits kept.

The input wavefunction must have shape (2,) * n or (2 ** n) where
wavefunction is expressed over n qubits. States in the output mixture will
retain the same type of shape as the input wavefunction, either (2 ** k)
or (2,) * k where k is the number of qubits kept.
If the wavefunction cannot be factored into a pure state over keep_indices
then eigendecomposition is used and the output mixture will not be unique.
Parameters
• wavefunction – A wavefunction to express over a qubit subset.

• keep_indices – Which indices to express the wavefunction on.

• atol – The tolerance for determining that a factored state is pure.

Returns

A single-component mixture in which the factored wavefunction has probability ‘1’ if the factored state is pure, or else a mixture of the default eigendecomposition of the mixed state’s partial trace.

Raises
• ValueError – if the input wavefunction is not an array of length

• (2 ** n) or a tensor with a shape of (2,) * n