# Quantum computer: Hadamard-Gates and Qubits

I'm learning about the quantum computer basics and got confused about qubits and the hadamard-gate. What I understood:

A qubit can (naturally) be in the states $\lvert 0 \rangle$, $\lvert 1 \rangle$ or any superposition $\alpha \lvert 0 \rangle + \beta \lvert 1 \rangle$

The hadamard-gate transforms a qubit from state $\lvert 0 \rangle$ to the superposition $\frac{1}{\sqrt{2}}( \lvert 0 \rangle + \lvert 1 \rangle)$ and therefore creates a uniform random generator that will probably be useful for further (cryptographic?) algorithms/applications.

Question: How can one be sure, that the state of the input qubit really is $\lvert 0\rangle$? Couldn't it also be in $\lvert 1\rangle$ or any superposition of them? And as we cannot measure the input qubits, as they will fall randomly into one of the two base states, we cannot be sure about it, no?

And what if the input qubit was in a superposition? What will the hadamard gate do to it?

• As a rule, preparing the initial qubits in the state $\left| 0 \right\rangle$ is possible -- simply take a measurement, and apply a correction if you didn't get $\left| 0 \right\rangle$ May 18, 2017 at 13:21

Your description of the Hadamard gate is not quite complete. It transforms $|0\rangle$ to $\frac{1}{\sqrt{2}} (|0\rangle + |1\rangle)$, but also $|1\rangle$ to $\frac{1}{\sqrt{2}} (|0\rangle - |1\rangle)$. So its effect on a general state is easily calculated to be $$\hat{H}_\mathrm{ad} (\alpha |0\rangle + \beta |1\rangle) = \frac{(\alpha + \beta)}{\sqrt{2}} |0\rangle + \frac{(\alpha - \beta)}{\sqrt{2}} |1\rangle$$
You are right insofar as this is only usable as a random number generator right after initialization of the input bits to $|0\rangle$ or $|1\rangle$.