The key is to not jump to “a qubit is 0 and 1 at the same time”. That statement is useful initially, but it can lead to the wrong intuition.
A classical bit has two possible states: 0 or 1
If you have 3 bits, there are 8 possible combinations:
000
001
010
011
100
101
110
111
A qubit is
A qubit can be either 0 or 1 or has a state: ∣ψ⟩=α∣0⟩+β∣1⟩
Probability of measuring 0 = 50%
Probability of measuring 1 = 50%
Note – understand the notations used in above equation
|1⟩ – Ket 1 , |ψ⟩ – Ket Psi , |0⟩ – Ket 0. (thats how we pronounce them, this is covered in our previous article)
Now let’s use 2 qubits
Two classical bits can represent:
00
01
10
11
only one of these exists at a time.
But two qubits can be placed into a superposition:
squared magnitudes give: 1/ 4 = 25%
for each state below statement holds good
25% amplitude → 00
25% amplitude → 01
25% amplitude → 10
25% amplitude → 11
Adding More Qubuits
3 qubits – 8 states,
10 qubits – 210 = 1024 states,
100 qubits – 2100 = ?? huge possibilities
Don’t think: “Quantum computer is powerful because 100 qubits can calculate 2 100 things simultaneously.”
Let us understand how it works in Quantum
Problem: Search for a marked item
Imagine we have 1,000,000 database records, and exactly one record satisfies some condition:
For simplicity, suppose our condition is:
def is_target(record): return record["id"] == 837291
in Classical programming, iterate and check all transactions against the condition. worst case would be 1,000,000 records, means 1,000,000 checks O(N)
Where do the qubits come in?
20 qubits – 2 20 possibilities , 1,048,576 possible records
Put all possibilities into superposition
what is happening here ? 20 qubits can represent a superposition of 1,048,576 possible states. The conditon is applied to that superposition, marking the state(s) that satisfy our condition. Grover’s algorithm then uses amplitude amplification to increase the probability of measuring the correct state
Imagine this way we use bit wise operations to represent user roles
Coordinator = 001
Reviewer = 010
Student = 100
A user can have multiple roles.
user with role Coordinator + Student001100---101using this i can avoid if else checks if role == "coordinator": ...elif role == "reviewer": ...elif role == "student": ...//see the magic const COORDINATOR = 1; // 001const REVIEWER = 2; // 010const STUDENT = 4; // 100// User has Coordinator + Studentconst userRoles = COORDINATOR | STUDENT; // 101console.log((userRoles & COORDINATOR) !== 0); // trueconsole.log((userRoles & REVIEWER) !== 0); // falseconsole.log((userRoles & STUDENT) !== 0); // true
Somewhat similar to this is how qubits being used to do more operations without literally looping through millions of records
To understand how Grover’s algorithm works read this
One thought on “Understanding Qubits and Superposition”