1
$\begingroup$

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]$?

$\endgroup$

1 Answer 1

3
$\begingroup$

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)])
print(op.is_unitary())

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

quantumcircuit.unitary(op, [0])
$\endgroup$

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.