2
$\begingroup$

Imagine one wants to represent the and function for any number of qubits in Dirac notation. The and gate flips the target qubit if all the control qubits are in state 1. This is its matrix representation : $$\begin {bmatrix} 1 & 0 & 0 & \cdots & 0 & 0 \\ 0 & 1 & 0 & \cdots & 0 & 0\\ 0 & 0 & \ddots & & \vdots & \vdots \\ \vdots & \vdots & & 1 & 0 & 0 \\ 0 & 0 & \cdots & 0 & 0 & 1 \\ 0 & 0 & \cdots & 0 & 1 & 0 \\ \end{bmatrix}$$

It can be decomposed into two parts : $$\begin{bmatrix} 1 & 0 & 0 & \cdots & 0 & 0 \\ 0 & 1 & 0 & \cdots & 0 & 0\\ 0 & 0 & \ddots & & \vdots & \vdots \\ \vdots & \vdots & & 1 & 0 & 0 \\ 0 & 0 & \cdots & 0 & 0 & 0 \\ 0 & 0 & \cdots & 0 & 0 & 0 \\ \end{bmatrix}= \begin{bmatrix} 1 & 0 & \cdots & 0 & 0 \\ 0 & 1 & \cdots & 0 & 0\\ \vdots & \vdots & \ddots & & \vdots \\ 0 & 0 & & 1 & 0 \\ 0 & 0 & \cdots & 0 & 0 \\ \end{bmatrix} \otimes I = \begin{bmatrix} 1 & 0 & \cdots & 0 & 0 \\ 0 & 1 & \cdots & 0 & 0\\ \vdots & \vdots & \ddots & & \vdots \\ 0 & 0 & & 1 & 0 \\ 0 & 0 & \cdots & 0 & 1 \\ \end{bmatrix} \otimes I- \begin{bmatrix} 0 & 0 & \cdots & 0 & 0 \\ 0 & 0 & \cdots & 0 & 0\\ \vdots & \vdots & \ddots & & \vdots \\ 0 & 0 & & 0 & 0 \\ 0 & 0 & \cdots & 0 & 1 \\ \end{bmatrix} \otimes I = (I-|1\cdots1\rangle\langle1\cdots1| ) \otimes I \tag{1}$$ and $$\begin {bmatrix} 0 & 0 & 0 & \cdots & 0 & 0 \\ 0 & 0 & 0 & \cdots & 0 & 0\\ 0 & 0 & \ddots & & \vdots & \vdots \\ \vdots & \vdots & & 0 & 0 & 0 \\ 0 & 0 & \cdots & 0 & 0 & 1 \\ 0 & 0 & \cdots & 0 & 1 & 0 \\ \end{bmatrix} = \begin{bmatrix} 0 & 0 & \cdots & 0 & 0 \\ 0 & 0 & \cdots & 0 & 0\\ \vdots & \vdots & \ddots & & \vdots \\ 0 & 0 & & 0 & 0 \\ 0 & 0 & \cdots & 0 & 1 \\ \end{bmatrix} \otimes X = |1\cdots1\rangle\langle1\cdots1| \otimes X \tag{2}$$ So combining (1) and (2), we get : $$U_{and} = (I-|1\cdots1\rangle\langle1\cdots1| ) \otimes I + |1\cdots1\rangle\langle1\cdots1| \otimes X$$

This is still pretty easy to see, the example complicates a lot when we have an or gate : $$U_{or} = U_{or} = |0...0\rangle\langle 0...0|\otimes I + \big(I - |0...0\rangle\langle 0...0|\big) \otimes X$$ which applies the X gate on the target qubit if there is at least 1 control qubits in the $|1\rangle$ state.

My question is : is there any way to see these transformations in Dirac notation to use them in a program ? To gain some intuition on the decomposition.

$\endgroup$
4
  • 1
    $\begingroup$ Is there any point to this decomposition? the (1-|1...1><1...1|) and (1-|0...0><0...0|) terms arent unitary so there is no advantage from an implementation standpoint $\endgroup$ – Bertrand Einstein IV Jan 22 at 23:08
  • $\begingroup$ I don't fully understand the question. You are already writing the matrices in braket notation here $\endgroup$ – glS Jan 24 at 15:41
  • $\begingroup$ I know this question is a bit hard to ask, but I want to know if there is any use in decomposing a gate in such a way, and furthermore, if there is a method for decomposing a gate in such a way. $\endgroup$ – BrockenDuck Jan 25 at 8:44
  • $\begingroup$ However, I answered my questions already myself, should I close it, or answer it myself ? $\endgroup$ – BrockenDuck Jan 25 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.