14
$\begingroup$

I'm trying to teach myself about quantum computing, and I have a decent-ish understanding of linear algebra.

I got through the NOT gate, which wasn't too bad, but then I got to the Hadamard gate. And I got stuck. Mainly because while I "understand" the manipulations, I don't understand what they really do or why you'd want to do them, if that makes sense.

For example, when the Hadamard gate takes in $|0\rangle$ it gives $\frac{|0\rangle + |1\rangle}{\sqrt{2}}$. What does this mean? For the NOT gate, it takes in $|0\rangle$ and gives $|1\rangle$. Nothing unclear about that; it gives the "opposite" of the bit (for the superposition, it takes in $\alpha|0\rangle+\beta|1\rangle$ and gives $\beta|0\rangle + \alpha|1\rangle$) and I understand why that is useful; for the same reasons (basically) that it is useful in a classical computer. But what (for example) is the Hadamard gate doing geometrically to a vector $\begin{bmatrix}\alpha \\ \beta \end{bmatrix}$? And why is this useful?

$\endgroup$

2 Answers 2

13
$\begingroup$

The Hadamard gate might be your first encounter with superposition creation. When you say you can relate the usefulness of the Pauli $X$ gate (a.k.a. NOT) to its classical counterpart – well, Hadamard is exactly where you leave the realm of classical analogue, then. It is useful for exactly the same reason, however, namely that it is often used to form a universal set of gates (like clasical AND with NOT and fan-out, or NOR with fan-out alone).

While a single $H$ gate is somewhat directly useful in random number generation (as Yuval Filmus said), its true power shows when appearing in more instances or in combination with other gates. When you have $n$ qubits initialized in $|0\rangle$, for example, and apply one $H$ to each of them in any order, what you get is $$(|0\rangle + |1\rangle) \otimes (|0\rangle + |1\rangle) \otimes \ldots \otimes (|0\rangle + |1\rangle) / 2^{n/2}$$ which can be expanded to $$1/2^{n/2} \cdot (|00\ldots00\rangle + |00\ldots01\rangle + |00\ldots11\rangle + \ldots + |11\ldots11\rangle)$$ Voilà, we can now evaluate functions on $2^n$ different inputs in parallel! This is, for example, the first step in Grover's algorithm.

Another popular use is a Hadamard on one qubit followed by a CNOT controlled with the qubit you just put into a superposition. See: $$CNOT \big(2^{-1/2}(|0\rangle+|1\rangle)\otimes|0\rangle \big) = 2^{-1/2} CNOT(|00\rangle + |10\rangle) = 2^{-1/2} (|00\rangle + |11\rangle)$$ That's a Bell state which is a cornerstone of various quantum key distribution protocols, measurement-based computation, quantum teleportation and many more applications. You can also use a CNOT repeatedly on more zero-initialized target qubits (with the same control) to create $$2^{-1/2} (|00\ldots00\rangle + |11\ldots11\rangle)$$ which is known as the GHZ state, also immensely useful.

Last but not least, it's a quite useful basis transform that is self-reversible. So another Hadamard gate undoes, in a sense, what a previous application did ($H^2 = I$). You can experiment around what happens if you use it to "sandwich" other operations, for example put one on the target qubit of a CNOT gate and another after it. Or on both of the qubits (for a total of 4 Hadamards). Try it yourself and you'll certainly learn a lot about Quantum computation!


Re "what is the Hadamard gate doing geometrically to a vector": read up on the Bloch sphere, you'll going to hear about it everywhere. In this representation, a Hadamard gate does a 180° rotation about a certain slanted axis. The Pauli gates (NOT being one out of three) also do 180° rotations but only about $x$ or $y$ or $z$. Because such geometrical operations are quite restricted, these gates alone can't really do much. (Indeed, if you restrict yourself to those and a CNOT in your quantum computer, you just build a very expensive and uneffective classical device.) Rotating about something tilted is important, and one more ingredient you usually need is also rotating by a smaller fraction of the angle, like 45° (like in the Phase shift gate).

$\endgroup$
13
$\begingroup$

The Hadamard gate operates on a single qubit. The state of a single qubit can be described as $\alpha \left|0\right\rangle + \beta \left|1\right\rangle$, where $|\alpha|^2 + |\beta|^2 = 1$. If you measure the qubit, the output is $0$ with probability $|\alpha|^2$, and $1$ with probability $|\beta|^2$. From a linear-algebraic perspective, the state of a qubit is just a unit norm vector of length two over the complex numbers. The two vectors $\left|0\right\rangle,\left|1\right\rangle$ span a vector space of dimension two (over the complex numbers), and every unit norm vector in that vector space can be the state of a qubit.

Since the state always has unit norm, the only linear operators possible on qubits are those that preserve norms. From linear algebra, we know that these are exactly the Hermitian operators. To describe an operator, it suffice to describe its effect on a basis. For example, the value of your operator on the vector $\left| 0 \right\rangle$ is $\frac{\left| 0 \right\rangle + \left| 1 \right\rangle}{\sqrt{2}}$.

According to Wikipedia, the Hadamard gate is used to form a "random input". If applied to a constant qubit (i.e., $\left| 0 \right\rangle$, $\left| 1 \right\rangle$, or a rotation of these by a unit norm complex number), the Hadamard gate forms a "uniformly random" qubit, which when measured behaves like a fair coin toss. This is the kind of behavior we want when "trying all possibilities in parallel".

I suggest you continue your reading on quantum computation; when you get to quantum algorithms (like Grover's and Shor's), you will understand what all these quantum gates are useful for.

$\endgroup$
1
  • 5
    $\begingroup$ "unit norm vector of length two" was confusing to me because I'm used to using norm and length interchangeably. $\endgroup$
    – adrianN
    Commented Sep 26, 2016 at 8:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.