# How does the graphical notation used to denote doubly-controlled gates work?

$$\qquad$$ $$\qquad$$

What is the difference between solid and hollow? How to express the corresponding matrix of these figures? In addition, if they are not adjacent, what should be done in the middle of several qubits (such as in more than 3 qubits)

The black (white) dot means a condition that the corresponding qubit should be in $$|1\rangle$$ state ($$|0\rangle$$ state) in order to apply the gate. The first circuit implements the Hadamard gate only if the first qubit is in $$|1\rangle$$ state and the second qubit is in $$|0 \rangle$$ state (similar discussions can be found here). In other words, if the combined state of the first two qubits is $$|10\rangle$$ the $$H$$ gate is applied, otherwise, we apply $$I$$ (nothing). Mathematically it looks like this:

\begin{align}C_{B}C_{W}\_H =& |00\rangle\langle 00| \otimes I + |01\rangle\langle 01| \otimes I + |10\rangle\langle 10| \otimes H + |11\rangle\langle 11| \otimes I\\ =& |10\rangle\langle 10| \otimes H + (I-|10\rangle\langle 10|)\otimes I,\end{align}

where $$C_{B}$$ is denoted here as the control with a black dot and $$C_{W}$$ is the control with a white dot. By taking this into account the corresponding matrix will look like this:

$$C_{B}C_{W}\_H = \begin{pmatrix} 1&0&0&0&0&0&0&0 \\ 0&1&0&0&0&0&0&0 \\ 0&0&1&0&0&0&0&0 \\ 0&0&0&1&0&0&0&0 \\ 0&0&0&0&1/\sqrt{2}&1/\sqrt{2}&0&0 \\ 0&0&0&0&1/\sqrt{2}&-1/\sqrt{2}&0&0 \\ 0&0&0&0&0&0&1&0 \\ 0&0&0&0&0&0&0&1 \\ \end{pmatrix}$$

The matrixes for the other two gates can be constructed in a similar way. Here is an answer about not adjacent controlled gates. Note that for $$n$$ qubit gate we will need $$2^n \times 2^n$$ matrices, so it is not always convenient to use matrices.

• Hi, I found this question by accident. The answer is good! Expressing the gate in the form of $C_{B}C_{W}\_H = |00\rangle\langle 00| \otimes I + |01\rangle\langle 01| \otimes I + |10\rangle\langle 10| \otimes H + |11\rangle\langle 11| \otimes I$ is very good! My question, where does this approach come from, can you read it somewhere? Surely there must be something like that in a book or a lecture? Because I thought of this formula: $I \otimes X \otimes H$ which is wrong (I was just thinking about it for a second, I think that would be the answer if the qubits weren't connected...)! Jul 14 '20 at 11:08
• thank you very much! It is clear! Jul 14 '20 at 11:33
• @Despriobaby, you are welcome :) Jul 14 '20 at 11:43
• @P_Gate, unfortunately, I don't remember a lecture/book where similar things were discussed. Jul 14 '20 at 11:44