1
$\begingroup$

I asked this already in reddit but got now answers, so I hope here is the right place.

Question in short:

Is there a general form of the CNOT Gate, so I can apply it to an arbitrary entangled state with any target and control bit of my choosing?

In other words: I am looking for a general Matrix represantation of the CNOT Gate

My Problem a bit more in detail:

The CNOT gate normally acts on 2 qubits.

$CNOT^2=\begin{pmatrix} 1&0&0&0\\ 0&1&0&0\\0&0&0&1\\0&0&1&0 \end{pmatrix}$

I also now how I would apply the CNOT gate on any consecutive qubits for larger states. The answer is a simple tensor product between CNOT and the Identity

eg:for a three qubit state

$$ CNOT^3_{12}=(CNOT^2\otimes I) $$ $$ CNOT^3_{23}=(I\otimes CNOT^2) $$ but how would I implement it acting on the first as control and the third as target qubit?\ Is there a general $CNOT_{i_k}$ formulation?

In my program I would need $|0_c00_t000\rangle$ and $|00_c00_t00\rangle$


folllow up question regarding Jitandras answer

Okay, sorry for the misunderstandings, it was quite late yeasterday and I couldn't really process what you said anymore. Yes, what I need is the Matrix.

Regarding your answer:

I don't understand why you chose the state of the first pariticle as up the one of the last as down. Can they be chosen arbitrarily?

To check if the formula you wrote gives the desired result I calculated the CNOT for the case that I have a three qubit state where the first is the control and the second is the target one. Which flips if the control qubit is one, while the last one stays untouched. $$ CNOT(a|110\rangle+b|100\rangle+c|000\rangle+d|010\rangle+e|111\rangle+f|101\rangle+g|001\rangle+h|001\rangle ) = a|100\rangle+b|110\rangle c|000\rangle+d|010\rangle+e|111\rangle+f|101\rangle+g|001\rangle+h|001\rangle $$

I know that the following works:

$CNOT^3_{12} = \begin{pmatrix} 1& 0& 0&0\\0 &1 & 0& 0\\0 & 0& 0& 1\\ 0&0&1&0 \end{pmatrix}\otimes\begin{pmatrix} 1 &0\\0&1\end{pmatrix}$

Resulting in a 8x8 Matrix.

If undestand your formula correctly this would mean for a complete distciption $$CNOT^3_{12} = |100\rangle\langle100|\otimes\sigma_x + |000\rangle\langle000|\otimes I + |110\rangle\langle110|\otimes\sigma_x + |010\rangle\langle010|\otimes I +|101\rangle\langle101|\otimes\sigma_x + |001\rangle\langle001|\otimes I + |111\rangle\langle111|\otimes\sigma_x + |011\rangle\langle011|\otimes I $$

I get a completely different 16x16 Matrix. Where is my mistake?

$\endgroup$
1
$\begingroup$

As a general idea CNOT flips target based on control. I choose to flip the target if control is $\uparrow (= [1\ 0]^T)$, you may choose it $\downarrow (= [0\ 1]^T)$ too. So assume any general multiparticle state $|\phi\rangle=|\uparrow_1\downarrow_2\downarrow_3....\uparrow_{n-1}\downarrow_n\rangle$. Now you choose your control and target, lets say $i'th$ is control and $k'th$ is target. Applying CNOT on $|\phi\rangle$ will be just \begin{equation} CNOT|\phi\rangle=CNOT|\uparrow_1\downarrow_2...\uparrow_i...\uparrow_k...\uparrow_{n-1}\downarrow_n\rangle= |\uparrow_1\downarrow_2...\uparrow_i...\downarrow_k...\uparrow_{n-1}\downarrow_n\rangle \end{equation}

To construct the matrix of such CNOT gate we apply $\sigma_x$($x$-Pauli matrix) if $i'th$ state is up and we apply $I$($2\times2$ Identity) if $i'th$ state is down. Mathematically, \begin{equation} CNOT = \Big[|\uparrow_1...\uparrow_i...\uparrow_{k-1}\rangle\langle\uparrow_1...\uparrow_i...\uparrow_{k-1}|\otimes\sigma_x\otimes|\uparrow_{k+1}...\uparrow_n\rangle\langle\uparrow_{k+1}...\uparrow_n| + all\ permutations\ of\ states\ other\ then\ i'th\Big] + \Big[|\uparrow_1...\downarrow_i...\uparrow_{k-1}\rangle\langle\uparrow_1...\downarrow_i...\uparrow_{k-1}|\otimes I\otimes|\uparrow_{k+1}...\uparrow_n\rangle\langle\uparrow_{k+1}...\uparrow_n| + all\ permutations\ of\ states\ other\ then\ i'th\Big] \end{equation}

Note $k'th$ state(target) is excluded while creating the permutation matrix and at $k'th$ position the operator $\sigma_x$ or $I$ is written.

Take an example of five qubits in which $2^{nd}$ qubit is target and $4^{th}$ is control. Lets build the permutation matrix of $CNOT$. I take, if control is $\uparrow$ flip the target. You can take vice-versa too.

\begin{align} CNOT & = |\uparrow_1\rangle\langle\uparrow_1|\otimes\sigma_x\otimes|\uparrow_3\uparrow_4\uparrow_5\rangle\langle\uparrow_3\uparrow_4\uparrow_5|\\ & +|\uparrow_1\rangle\langle\uparrow_1|\otimes\sigma_x\otimes|\uparrow_3\uparrow_4\downarrow_5\rangle\langle\uparrow_3\uparrow_4\downarrow_5|\\ & +|\uparrow_1\rangle\langle\uparrow_1|\otimes\sigma_x\otimes|\downarrow_3\uparrow_4\uparrow_5\rangle\langle\downarrow_3\uparrow_4\uparrow_5|\\ & +|\uparrow_1\rangle\langle\uparrow_1|\otimes\sigma_x\otimes|\downarrow_3\uparrow_4\downarrow_5\rangle\langle\downarrow_3\uparrow_4\downarrow_5|\\ & +|\downarrow_1\rangle\langle\downarrow_1|\otimes\sigma_x\otimes|\uparrow_3\uparrow_4\uparrow_5\rangle\langle\uparrow_3\uparrow_4\uparrow_5|\\ & +|\downarrow_1\rangle\langle\downarrow_1|\otimes\sigma_x\otimes|\uparrow_3\uparrow_4\downarrow_5\rangle\langle\uparrow_3\uparrow_4\downarrow_5|\\ & +|\downarrow_1\rangle\langle\downarrow_1|\otimes\sigma_x\otimes|\downarrow_3\uparrow_4\uparrow_5\rangle\langle\downarrow_3\uparrow_4\uparrow_5|\\ & +|\downarrow_1\rangle\langle\downarrow_1|\otimes\sigma_x\otimes|\downarrow_3\uparrow_4\downarrow_5\rangle\langle\downarrow_3\uparrow_4\downarrow_5|\\ & +|\uparrow_1\rangle\langle\uparrow_1|\otimes I\otimes|\uparrow_3\downarrow_4\uparrow_5\rangle\langle\uparrow_3\downarrow_4\uparrow_5|\\ & +|\uparrow_1\rangle\langle\uparrow_1|\otimes I\otimes|\uparrow_3\downarrow_4\downarrow_5\rangle\langle\uparrow_3\downarrow_4\downarrow_5|\\ & +|\uparrow_1\rangle\langle\uparrow_1|\otimes I\otimes|\downarrow_3\downarrow_4\uparrow_5\rangle\langle\downarrow_3\downarrow_4\uparrow_5|\\ & +|\uparrow_1\rangle\langle\uparrow_1|\otimes I\otimes|\downarrow_3\downarrow_4\downarrow_5\rangle\langle\downarrow_3\downarrow_4\downarrow_5|\\ & +|\downarrow_1\rangle\langle\downarrow_1|\otimes I\otimes|\uparrow_3\downarrow_4\uparrow_5\rangle\langle\uparrow_3\uparrow_4\downarrow_5|\\ & +|\downarrow_1\rangle\langle\downarrow_1|\otimes I\otimes|\uparrow_3\downarrow_4\downarrow_5\rangle\langle\uparrow_3\downarrow_4\downarrow_5|\\ & +|\downarrow_1\rangle\langle\downarrow_1|\otimes I\otimes|\downarrow_3\downarrow_4\uparrow_5\rangle\langle\downarrow_3\downarrow_4\uparrow_5|\\ & +|\downarrow_1\rangle\langle\downarrow_1|\otimes I\otimes|\downarrow_3\downarrow_4\downarrow_5\rangle\langle\downarrow_3\downarrow_4\downarrow_5| \end{align}

$\endgroup$
  • 1
    $\begingroup$ Thank you for your contribution, I should have made clearer that my Problem lies in the Implementation of said operation in my computer program. I know how cNOT works on paper and checked the whole quantum circuit already. $\endgroup$ – user204824 Aug 24 '18 at 23:43
  • $\begingroup$ Please include better formatting in your question. It's tough to understand what you are saying. I have already given you a way to construct CNOT on arbitrary control and target. $\endgroup$ – Jitendra Aug 24 '18 at 23:52
  • $\begingroup$ @user204824 - I'm confused about what you're asking for, too. You ask how do you "implement" or "formulate" a cNot gate acting a many-qubit state. What does that mean? My best guess would be that you were asking for a concrete matrix representation like Jitendra showed but, no, you want something else. What then? It's up to you to explain your question clearly. $\endgroup$ – Samuel Weir Aug 25 '18 at 2:54
  • $\begingroup$ A general matrixrepresentation is what I asked for, sorry for the confusion. Implementing said matrix in my program is up to me. $\endgroup$ – user204824 Aug 25 '18 at 9:17
  • $\begingroup$ @Jitendra I edited my question for clarification, For me it seems that the formula you gave, results in a matrix with twice the dimension I actually need. It wouldn't fit into the edit section so I put my follow up question in my original post. $\endgroup$ – user204824 Aug 25 '18 at 12:00

Your Answer

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

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