I want to implement a Hadamard gate on a single qubit in a register.
Given two qubits
q0 := $|0\rangle$ and
q1 := $|+\rangle$
I would like to use a Hadamard gate on the first qubit (q0).
My intuition is that
using Hadamard on the first qubit and building the register afterwards:
Apply: q0' = Had(q0) = \begin{bmatrix} 1/\sqrt{2} \\ 1/\sqrt{2} \end{bmatrix}
Build Register: reg0 := q0' tensor q1 = \begin{bmatrix} 1/2 \\ 1/2 \\ 1/2 \\ 1/2 \end{bmatrix}
would lead to the same result asusing Hadamard Gate (H) on the first qubit after building the register:
Building the register: reg1 := q0 tensor q1 = \begin{bmatrix} 1/\sqrt{2} \\ 0 \\ 1/\sqrt{2} \\ 0 \end{bmatrix} Apply: H tensor I mul reg1 =
\begin{bmatrix} 1/\sqrt{2} && 0 && 1/\sqrt{2} && 0 \\ 0 && 1/\sqrt{2} && 0 && 1/\sqrt{2} \\ 1/\sqrt{2} && 0 && -1/\sqrt{2} && 0 \\ 0 && 1/\sqrt{2} && 0 && -1/\sqrt{2} \end{bmatrix} mul reg1 = \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix} So this is not the same. But what would be same is when we swap H and I: I tensor H mul reg1 = \begin{bmatrix} 1/\sqrt{2} && 1/\sqrt{2} && 0 && 0 \\ 1/\sqrt{2} && -1/\sqrt{2} && 0 && 0 \\ 0 && 0 && 1/\sqrt{2} && 1/\sqrt{2} \\ 0 && 0 && 1/\sqrt{2} && -1/\sqrt{2} \end{bmatrix} mul reg1 = \begin{bmatrix} 1/2 \\ 1/2 \\ 1/2 \\ 1/2 \end{bmatrix}
I found a Microsoft article and I think it has something to with that. It says:
I think this is weird. Can someone explain it?
