1

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 as

  • using 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:

Microsoft Article

I think this is weird. Can someone explain it?

Glorfindel
  • 620
  • 1
  • 9
  • 24
Oli
  • 57
  • 5
  • 2
    "I think it is weird." Unclear what "it" refers to, and which part you're finding weird. – Frank Yellin Nov 30 '22 at 02:05
  • Also useful would be this answer: https://quantumcomputing.stackexchange.com/questions/14066/how-do-i-apply-the-hadamard-gate-to-one-qubit-in-a-two-qubit-pure-state – Mike Ryan Nov 30 '22 at 02:35
  • The equation after "Building the register: reg1 := q0 tensor q1 =" is not correct. As Frank Yellin says in his answer below, the vector you wrote is $|+\rangle \otimes |0\rangle$, whereas you are looking for $|0\rangle \otimes |+\rangle = \begin{bmatrix} 1/\sqrt{2} \ 1/\sqrt{2} \ 0 \ 0 \end{bmatrix}$. Then if you follow your logic after that, you will get the same result as your first method. – sheesymcdeezy Jan 06 '23 at 13:14

1 Answers1

1

I'm not sure what you find confusing. You start off with with the matrix:

$$\begin{bmatrix} 1/\sqrt2 \\ 0 \\ 1/\sqrt2 \\ 0 \end{bmatrix}$$ which is $|+\rangle \otimes |0\rangle$.

Then: $$(H\otimes I)(|+\rangle \otimes |0\rangle) = (H|+\rangle) \otimes (I|0\rangle) = |0\rangle|0\rangle$$

$$(I\otimes H)(|+\rangle \otimes |0\rangle) = (I|+\rangle) \otimes (H|0\rangle) = |+\rangle|+\rangle$$

Which is exactly what you got in your calculations.

Frank Yellin
  • 713
  • 2
  • 8