# Does control and target matter in the CZ (Controlled-Z) Gate? [duplicate]

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

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

• Have you reviewed the matrix for the CZ gate? Commented May 27, 2021 at 17:32
• 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 Commented May 27, 2021 at 17:45
• 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. Commented May 27, 2021 at 18:24
• 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 Commented May 27, 2021 at 18:26

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:

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;

• 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$. Commented Mar 7, 2022 at 21:16