# Expectation values for Clifford quantum circuit

A quantum circuit made up of only Clifford gates can me simulated classically in an efficient way. Is it possibile to calculate the exact expectation value of an observable $$\langle \psi | O | \psi \rangle$$ (where $$\psi$$ is the output state at the end of the clifford quantum circuit) ? Or the only way to simulate these quantum circuits is through sampling (measurements) ?

If it is possible, is there a way to do that in python (any package) ?

• Perhaps it is worth pointing out that you cannot compute the expectation value of any observable in a stabilizer state efficiently. Generally, this is only the case for Pauli observables, or for overlaps with stabilizer code projectors. Commented Feb 2, 2023 at 7:43

In a stabilizer simulation all expectations are 0%, 50%, or 100%. Basically it comes down to whether the observable anticommutes with the set of stabilizer generators and, if it does commute, whether it or its negative is in the stabilizer set.

stim.TableauSimulator.peek_observable_expectation tells you the expected value of an observable given the current state of the simulator.

Keep in mind this is an expectation about the current state, not about the circuit. Assuming all preceding operations are Cliffords, this is the same thing as the total overall expectation for the observable at the end of the circuit from the start of the circuit. But if there are any non-deterministic or dissipative processes on the way, such as measurements or noise, then you are seeing the expectation given that certain measurement outcomes occurred and certain noise channels were chosen.

In Qiskit, you can use StabilizerState.expectation_value() as follows:

from qiskit.quantum_info import random_clifford, StabilizerState
from qiskit.quantum_info.operators.symplectic import Pauli

# Create sample circuit for testing:
clifford = random_clifford(num_qubits = 50, seed = 1)
circ = clifford.to_circuit()
print('Circuit Depth:', circ.depth())

# Calculate the expectation value:
op = Pauli('XY' * 25)
print('Observable:', op)
state = StabilizerState(circ)
exp_val = state.expectation_value(op)
print('Exp_Val:', exp_val)