# Measuring tensor products of Pauli operators

Is there a neat way to derive and efficiently implement a measurement circuit for tensor products of arbitrary Pauli operators like $$XZZXZ$$ in Qiskit ?

I tried using the pauli_measurement function, where I used a PauliOperator object initialized from a corresponding label, but this function seems to perform single-qubit post-rotations for each part of the label and I am not sure if this is what I actually want to measure. I assume, that a generalization of what is described here https://github.com/MicrosoftDocs/quantum-docs/blob/main/articles/concepts-pauli-measurements.md would fit this measurement scenario.

• If you want your measurements in the Z basis, then you could simply implement your Pauli string in the specific qubits and then measure. Aug 2 '21 at 15:16

If you don't want to write your own function to do this then one way to do this is through qiskit pauli_measurement.

For example:

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.quantum_info import Pauli
from qiskit.aqua.operators.legacy import pauli_measurement
qr = QuantumRegister(4)
cr = ClassicalRegister(4)
qc = QuantumCircuit(qr,cr)
pauli_measurement(qc, Pauli('XYZX'), qr , cr  )
print(qc)

┌───┐       ┌─┐
q2_0: ┤ H ├───────┤M├────────
└┬─┬┘       └╥┘
q2_1: ─┤M├─────────╫─────────
└╥┘ ┌─────┐ ║ ┌───┐┌─┐
q2_2: ──╫──┤ SDG ├─╫─┤ H ├┤M├
║  └┬───┬┘ ║ └┬─┬┘└╥┘
q2_3: ──╫───┤ H ├──╫──┤M├──╫─
║   └───┘  ║  └╥┘  ║
c2: 4/══╩══════════╩═══╩═══╩═
1          0   3   2