Let's say we have a circuit with $2$ Hadamard gates:

enter image description here

Let's take the $|00\rangle$ state as input. The vector representation of $|00\rangle$ state is $[1 \ 0 \ 0 \ 0]$, but this is the representation of $2$ qubits and H accepts just $1$ qubit, so should we apply the first H gate to $[1 \ 0]$ and the second H gate to $[0 \ 0]$? Or should we input $[1 \ 0]$ in each H gate, because we are applying H gates to just one qubit of state $|0\rangle$ each time?


Or should we input $[1 \ 0]$ in each H gate, because we are applying H gates to just qubit of state $|0\rangle$ each time?

Yes, when you have a two-qubit state (say you label the two qubits as $A$ and $B$ respectively), you need to apply the two Hadamard gates separately on each qubit's state. The final state will be the tensor product of the two "transformed" single-qubit states.

If your input is $|0\rangle_A\otimes|0\rangle_B$, the output will simply be $$\left(\frac{|0\rangle+|1\rangle}{\sqrt{2}}\right)_A\otimes\left(\frac{|0\rangle+|1\rangle}{\sqrt{2}}\right)_B$$


If the two input qubits are entangled, the above method won't work since you won't be able to represent the input state as a tensor product of the states of the two qubits. So, I'm outlining a more general method here.

When two gates are in parallel, like in your case, you can consider the tensor product of the two gates and apply that on the 2-qubit state vector. You'll end up with the same result.

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

Now, on applying this matrix on the 2-qubit state $\begin{bmatrix}1\\0\\0\\0\end{bmatrix}$ you get:

$$\frac{1}{2}\begin{bmatrix}1&1&1&1\\1&-1&1&-1\\1&1&-1&-1\\1&-1&-1&1 \end{bmatrix} \begin{bmatrix}1\\0\\0\\0\end{bmatrix}=\begin{bmatrix}1/2\\1/2\\1/2\\1/2\end{bmatrix}$$

which is equivalent to $$\left(\frac{|0\rangle+|1\rangle}{\sqrt{2}}\right)_A\otimes\left(\frac{|0\rangle+|1\rangle}{\sqrt{2}}\right)_B$$


Tensor product of linear maps:

The tensor product also operates on linear maps between vector spaces. Specifically, given two linear maps $S : V \to X$ and $T : W \to Y$ between vector spaces, the tensor product of the two linear maps $S$ and $T$ is a linear map $(S\otimes T)(v\otimes w) = S(v) \otimes T(w)$ defined by $(S\otimes T)(v\otimes w) = S(v) \otimes T(w)$.

Thus, $$(\mathbf H|0\rangle_A) \otimes (\mathbf H|0\rangle_B) = (\mathbf H\otimes \mathbf H)(|0\rangle_A \otimes |0\rangle_B)$$

| improve this answer | |

It's the second option. So, you would apply both Hardmard gates to the state $|0\rangle$, to obtain two $\frac{1}{\sqrt{2}} \left (|0\rangle + |1\rangle \right)$. Therefore, the final two-qubit state would be

\begin{align} \frac{1}{\sqrt{2}} \left (|0\rangle + |1\rangle \right) \otimes \frac{1}{\sqrt{2}} \left (|0\rangle + |1\rangle \right) &= \frac{1}{2} \left( |00\rangle + |01\rangle + |10\rangle + |11\rangle\right) \end{align}

We can easily verify that this is a valid quantum state by checking the normalization condition.

\begin{align} \left| \frac{1}{2} \right|^2 + \left| \frac{1}{2} \right|^2 + \left| \frac{1}{2} \right|^2 + \left| \frac{1}{2} \right|^2 &= \frac{1}{4} + \frac{1}{4} + \frac{1}{4} + \frac{1}{4} \\ &= 1 \end{align}

In general, in this context, it's more intuitive if you use Dirac's bra-ket notation (i.e. use $|00 \rangle$ instead of the column vector $(1, 0, 0, 0)^T$). Then, if you have to apply a gate to a subset of the qubits, you can proceed in an analogous way as I did above.

| improve this answer | |

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.