# What's the matrix representation of this 3-qubit CZ circuit?

How do I calculate the matrix representation of this part of a teleportation circuit? It must be a matrix of dimension 8.

• Hi, Nillmer. Welcome to Quantum Computing! I recommend trying to figure it by yourself. Start here. It looks like a simple controlled-$Z$ gate to me. Commented Nov 10, 2018 at 20:36

One way to do it is to build a sort of quantum IF statement. You have in quantum computing projector operators telling you whether a qubit is 0 or 1: $$P_0 = \begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix}$$

$$P_1 = \begin{pmatrix} 0 & 0 \\ 0 & 1 \end{pmatrix}$$

Then we have the Z gate :

$$Z= \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}$$

To build the unitary for your controlled operation, we do : $$CZ = P_0 \otimes I \otimes I + P_1 \otimes I \otimes Z$$

with $$\otimes$$ the tensor product. That means, if your first qubit is in the $$|0\rangle$$ state, we apply the identity operation, otherwise we apply the Z operator only on the third qubit.

• Just a side note: $P_0 = |0\rangle\langle 0|$ and $P_1 = |1\rangle\langle 1|$.
– upe
Commented Feb 19 at 11:58