IBM Quantum Experience and other Algorithm Creators generally draw the CZ gates like this:

enter image description here

Does it not matter which qubit is the control and which is the target? If so why?

  • 1
    $\begingroup$ Have you reviewed the matrix for the CZ gate? $\endgroup$
    – Mark S
    May 27, 2021 at 17:32
  • $\begingroup$ Yes but I'm trying to understand it intuitively. To me, I think of the CZ gate as "if (control qubit) flip phase of target qubit" similar to a CNOT, but obviously this isn't the case $\endgroup$ May 27, 2021 at 17:45
  • 2
    $\begingroup$ Perhaps a better intuitive way to understand the CZ gate is: "flip the sign of the amplitude on the $|11\rangle$ state and do nothing to $|00\rangle$, $|01\rangle$ and $|10\rangle$". Mathematically, CZ maps $\alpha|00\rangle + \beta|01\rangle + \gamma|10\rangle + \delta|11\rangle$ to $\alpha|00\rangle + \beta|01\rangle + \gamma|10\rangle - \delta|11\rangle$. Clearly, the qubit roles are symmetric. $\endgroup$ May 27, 2021 at 18:24
  • $\begingroup$ I think it is matter that the first qubit you put in cz(c,t) is the one that control the phase and the second qubit you put in is the target one. The picture which Qiskit illustrate is just a way to show the gate in circuit $\endgroup$ May 27, 2021 at 18:26

1 Answer 1


First, note that the Controlled-X gate can be written as:

$$ CX = |0\rangle \langle 0| \otimes I + |1 \rangle \langle 1| \otimes X $$

This tells us that the first qubit is the controlled, and the second qubit is the target. And when the controlled qubit is $|0\rangle$ we do nothing hence the Idenity operator. When the controlled-qubit is a $|1\rangle$ we apply the $X$ operator. So when you look at $CX$ gate you see something like:

enter image description here

to indicate that the first qubit is the controlled and the second is the target since it matters. Also note that $CX$ has the matrix representation in the compuational basis as: $$ CX= \begin{pmatrix}1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 1\\ 0 & 0 & 1 & 0 \end{pmatrix} $$

Now, if you look at the the controlled-Z ($CZ$) gate matrix representation in the computational basis, you will see: $$ CZ = \begin{pmatrix}1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & -1 \end{pmatrix} $$

But note that this can be written as:

$$ CZ = |0\rangle \langle0| \otimes I + |1\rangle\langle1|\otimes Z = I \otimes |0\rangle\langle0| + Z \otimes |1\rangle\langle1| $$

what this tells us is that it's symmetric... it doesn't matter which qubit is the controlled or target. So why not just create a controlled gate with both being the controlled qubits... that is why you see $CZ$ usually shown as;

enter image description here

  • $\begingroup$ Note that for this to work you need (the conventional) $Z=|0\rangle\langle0| - |1\rangle\langle1|$, contrary to what you'd usually have when you write a qubit Hamiltonian with $\sigma_z$. $\endgroup$
    – Daniel
    Mar 7 at 21:16

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