Consider a quantum circuit of 2 qubit:

quantumcircuit = QuantumCircuit(2)

If one wishes to apply a Pauli-X operator to the first qubit, one writes: quantumcircuit.x(0)

But how should it be written programmatically if the wish is to apply a Bell measurement bases $\frac{1}{\sqrt{2}}[X - Z]$?


1 Answer 1


The operation $\frac{1}{\sqrt{2}}[X - Z]$ is unitary. You can easily check that:

from qiskit.quantum_info import SparsePauliOp
import numpy as np

op = SparsePauliOp(['X', 'Z'], [1 / np.sqrt(2), -1 / np.sqrt(2)])

So, you can add it to your circuit using QuantumCircuit.unitary() method:

quantumcircuit.unitary(op, [0])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.