# Superposition in Quantum Computing

The concept of superposition is also used in quantum computing.

What is quantum computing?

In traditional computing, a bit can have a value of either zero or one. Quantum computing uses qubits (quantum bits). Qubits can have a certain probability to be zero or one. This is represented as $\alpha \ket{0} + \beta \ket{1}$ where $\alpha^2$ is the probability that the qubit has a value of zero and $\beta^2$ is the probability the qubit has the value one (so $\alpha^2 + \beta^2 = 1$, or in other words a qubit is a vector of unit length)

Therefore a qubit with the value $\ket{0}$ has the value zero with 1.0 probability, a qubit with the value $\ket{1}$ has the value one with 1.0 probability.

And a qubit with the value $\frac{1}{\sqrt{2}}\ket{0} + \frac{1}{\sqrt{2}}\ket{1}$ could be zero or one with 0.5 probability each. Another way of looking at it is, the value is zero AND one until the moment we measure the value and find out what it actually is.

So why is this useful? Consider we want to search for a number to solve some problem, eg, finding prime factors of a huge number. In traditional computing, we would need certain number of bits to store this number, and since those bits can represent only a single number, we will have to loop through all the numbers from 0 upto the target number checking one by one which value solves the problem.

With quantum computing, we can create a set of qubits, each having the value $\frac{1}{\sqrt{2}}\ket{0} + \frac{1}{\sqrt{2}}\ket{1}$. Since each qubit is both zero and one simultaneously, such a set of qubits represents not a single number, but a superposition of ALL possible numbers upto the target number.

So how do we find the actual answer to the problem? Algorithms exist that can iteratively change the weights of $\ket{0}$ and $\ket{1}$ for each qubit towards the correct solution (an analogy is how the weights of a deep learning network are iteratively adjusted towards the right answer). Eventually every qubit will be either $\ket{0}$ (100% value is zero) or $\ket{1}$ (100% value is one). At that point, we have our answer.