2
$\begingroup$

I want to simulate a circuit similar to the one below in MATLAB. If you have a state matrix describing the state of 3 qubits, I understand that you could apply a CNOT matrix tensored with and identity matrix to $\psi_{0} $ get $\psi_{1}$, but if you want to apply a controlled operation to the 1st and 3rd qubit to get $\psi_2$, how can you do this? It's like you need "remove" the information about the second qubit, apply a CNOT gate, and then somehow integrate the result back with the superposition of the second qubit... I do not understand how to do this.

In general if I have a superposition of N qubits, how do I apply a controlled operation on qubits i and j?

Simple Quantum Circuit

$\endgroup$
1
$\begingroup$

I think this will answer your question. How does the CNOT between qubits one and three work? $$\left|000\right\rangle \to \left|000\right\rangle$$ $$\left|001\right\rangle \to \left|001\right\rangle$$ $$\left|010\right\rangle \to \left|010\right\rangle$$ $$\left|011\right\rangle \to \left|011\right\rangle$$ $$\left|100\right\rangle \to \left|101\right\rangle$$ $$\left|101\right\rangle \to \left|100\right\rangle$$ $$\left|110\right\rangle \to \left|111\right\rangle$$ $$\left|111\right\rangle \to \left|110\right\rangle$$

So its matrix would look like:

$$\left(\begin{array}{cccccccc} 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 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ \end{array}\right)$$

$\endgroup$
  • $\begingroup$ That's a good start. But what if you wanted to simulate a bigger circuit with say n input qubits. Is there a general form that could simplify and not need to write out a (2^n)x(2^n) matrix? $\endgroup$ – Scott Apr 20 '14 at 22:03
  • $\begingroup$ @Scott Let me answer your question with this, if there was an efficient way of simulating generic quantum states and their operators on a classical computer, then ... $\endgroup$ – Ali Apr 20 '14 at 22:24
  • $\begingroup$ @Scott Matlab has support for "sparse" matrices if many entries are zeros. $\endgroup$ – rob May 19 '14 at 13:40
  • $\begingroup$ @Scott rob is right(actually many modern programming languages support sparse arrays, including Mathematica and Matlab). There are algorithms for sparse matrices, but even in that case you would need to specify $\mathcal O \left(2^n\right)$ elements for your matrices, which is still huge. $\endgroup$ – Ali May 19 '14 at 16:12

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.