# Understanding the effect of a quantum gate on an entangled system

Recently I've been learning about quantum mechanics through studying quantum computers. I understand how a unitary transformation can be used to effect the amplitudes of a single qubit; for example, the Hadamard gate will do this:

$$H(\alpha|0\rangle + \beta|1\rangle) \rightarrow \frac{\alpha + \beta}{\sqrt 2}|0\rangle + \frac{\alpha - \beta}{\sqrt 2}|1\rangle$$

So that, when the qubit is measured, we will see it is in state $|1\rangle$ with a probability of $\left|\frac{\alpha - \beta}{\sqrt 2}\right|^2$. However, this seems a lot more complicated to me when you take into account that qubits' states can be entangled with one another. My question is, what exactly happens when you apply a transformation to a single qubit in a many qubit system?

This is easy when the state is separable. For example, if the state of a 3-qubit quantum register is this:

$$(\alpha|0\rangle + \beta|1\rangle)\otimes(\gamma|0\rangle + \delta|1\rangle)\otimes(\epsilon|0\rangle + \eta|1\rangle)$$

then applying Hadamard to the second qubit will result in this:

$$(\alpha|0\rangle + \beta|1\rangle)\otimes\left(\frac{\gamma + \delta}{\sqrt 2}|0\rangle + \frac{\gamma - \delta}{\sqrt 2}|1\rangle\right)\otimes(\epsilon|0\rangle + \eta|1\rangle)$$

This calculation doesn't work in general though, because you can't necessarily write down the global state as a tensor product of separate qubits to begin with. In a quantum register, all you really know at any given time is that you have a vector of amplitudes:

$$\begin{bmatrix} \alpha_{000} & \alpha_{001} & \alpha_{010} & \alpha_{011} & \alpha_{100} & \alpha_{101} & \alpha_{110} & \alpha_{111} \end{bmatrix}$$

such that $\sum |\alpha_i|^2 = 1$. Mathematically, what is the result of applying a transformation to a single qubit? How would I calculate the final state with a pen and paper?

I have an idea (which I'm not sure about), that passing a qubit to a quantum gate means measuring it first, which would implicitly mean measuring any other qubits it's entangled with. For example, if I measured the second qubit and saw it was $|0\rangle$, then every amplitude contradicting that measurement would collapse to zero, and the new (renormalized) vector would look like this:

$$\begin{bmatrix} \alpha^\prime_{000} & \alpha^\prime_{001} & 0 & 0 & \alpha^\prime_{100} & \alpha^\prime_{101} & 0 & 0 \end{bmatrix}$$

I don't know if I'm thinking about this wrongly, but I'm at least still missing something. I still can't construct the new vector like so:

$$(\alpha|0\rangle + \beta|1\rangle)\otimes H(|0\rangle)\otimes(\epsilon|0\rangle + \eta|1\rangle)$$

because if the first and third qubits are entangled, then decomposing the state into a tensor product will still be impossible -- even after measuring the second qubit! So how does a quantum gate actually change the state of the system in a quantum circuit?

• A quantum gate is a unitary transformation, there is no measurement. – CuriousOne Aug 1 '16 at 23:25
• Hint: quantum gates are linear operations, and all (pure) quantum states can be decomposed as a linear combination of tensor product states. – Mark Mitchison Aug 1 '16 at 23:29
• Welcome to Physics.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. 4) If you get a satisfactory answer, remember to accept it by clicking on the green checkmark. – heather Aug 2 '16 at 0:43
• Group by the unaffected qubits, and apply the operation within each group. – Craig Gidney Aug 2 '16 at 9:10

If you know how to apply a linear operation to separable states and you want to extend it to an entangled state, then first you express your state in terms of separable states, $$|\psi⟩ = \sum_n |a_n⟩\otimes|b_n⟩\otimes \cdots \otimes |c_n⟩,$$ and then you apply your operation term by term, $$H|\psi⟩ = \sum_n |a_n⟩\otimes(H|b_n⟩)\otimes \cdots \otimes |c_n⟩,$$ which must hold by linearity. Since you know what the $H|b_n⟩$ are, you're done.

In general, an arbitrary entangled state can indeed be expressed as a column vector with a bunch of entries in a given tensor basis. In that case, if you want a matrix representation of a single-qubit operator, you need to use a Kronecker product of its matrix in the relevant sub-basis with a bunch of identity matrices on the left and on the right to make it address the correct part of the tensor product.

Reading a bit further on this stackexchange, I found this answer which showed me what I was looking for through its use of notation. Specifically, they write a Hadamard transformation on the first of two qubits as $H_A \otimes I_B |0_A0_B\rangle$, which is exactly what I needed to see!

By the same logic, in my example of applying $H$ to the second qubit of a 3-qubit system, the overall transformation applied to the state vector would be $I \otimes H \otimes I =$

$$\begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \otimes \frac{1}{\sqrt 2} \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} \otimes \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}$$

In general, applying a unitary transformation, $U$, to the $n$th qubit in an $N$-qubit system would have the effect of applying the following transformation to the system:

$$\bigotimes_{i \in \mathbb Z_N} \begin{cases} U & i = n \\ I & \text{otherwise} \end{cases}$$

Essentially, a quantum gate can be thought of as the tensor product of all the operations being done to the individual qubits in the circuit - including the identity transformations on the channels not passing through the gate.

EDIT: Just to clear the misconception in the second half of the question: quantum gates do not measure their inputs. That whole thing about collapsing the amplitudes is wrong.