Skip to content

Instantly share code, notes, and snippets.

@JoshCheek
Created June 9, 2016 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshCheek/63c649b1e8837231ecbd2515a9c754ce to your computer and use it in GitHub Desktop.
Save JoshCheek/63c649b1e8837231ecbd2515a9c754ce to your computer and use it in GitHub Desktop.
How I think Quantum Computers work
A qubit is a "quantum bit"
normal bits can have one of two states, lets say 0 and 1
qubits, when measured, will also be in one of those two states
But *before being measured, THEY ARE IN BOTH STATES*, this is called "superposition"
(possibly, they are in some probability of both states rather than fully in them both,
I'd test this by coercing the double slit experiment so that its more likely to go through
one slit than the other, and expect the interference pattern to change accordingly)
Going from both states to one state is called "collapsing" it
Qubits implemented through things like electron "spin"
Spin is actually just magnetic orientation (pretty sure)
When we measure it, it will be "up" or "down", hence 2 states, a bit
"Spin up" means it has the same orientation of the magnetic field used to measure it
"Spin down" means it has the opposite orientation to the magnetic field used to measure it.
Prior to measurement, superposition allows qubits to be in all states concurrently
Thus n qubits are in 2^n states (if that's not obvious, consider how many states can be stored in 1 bit, 2 bits, 3 bits, 4 bits, ...)
So 3 bits have 8 possible states
normal bits are only in one of them
qubits are in all 8 until measured and only 1 after being measured
Thus, calculations on qubits are done against all states of the data
This because it does not collapse the qubit when performing the operation
The operation might be something like comparing the bits to a bunch of db records to locate the one you want
You can manipulate the probability of how a measurement will turn out
When measuring spin, the way you orient the magnetic measuring field affects the probability of the result
Quantum Entanglement allows you to reason about bits without measuring them
Quantum entanglement is the same as normal entanglement (example below) except that quantum particles are actually in both states.
Example of (non-quantum) entanglement:
I put the a red, green, and blue crayon in a jar
I can pull them out in 6 possible ways: RGB, RBG, GRB, GBR, BRG, BGR
There are 2 of 6 ways for any given colour to show up in any given position
So they each have a 1/3 chance of being in any particular position
But after I pull out the first crayon, and see that it's Green, that affects what the remaining crayons can be
Now we have only 2 possible states: GRB, GBR
So there's a 100% chance that the first crayon is green, and each other crayon has a 50% chance of being in spot 2 and a 50% chance of being in spot 3
So my measurement of the first crayon has affected what the second crayon can be
Their entanglement allows me to reason about them
Collapse the superposition into the desired state
Now that you've done the calculations, you want to collapse the qubits into the the state that has to the desired output
Using the previous example
Lets say my goal is to pull blue out last (b/c that's the one that I get to take home, and I find it prettier than the others)
Right now, it's only 1/3 to be pulled last
But, I have a lucky glove that's really likely to pull out Red
And if I pull out red first, then the probability that blue comes out last shoots up to 50%
So I put on the glove and take out the first crayon, it's red!
So, without pulling out the last crayon, I've caused it to be more likely to be the blue one
What's our "lucky glove"?
It's the orientation of the magnetic field we use to measure the qubit's spin
There's some really good videos that describe it in here: https://www.youtube.com/user/LookingGlassUniverse/videos
We can change the probability of what we will measure the bits to be
Which changes the probability of what the unmeasured bits will be
So we measure in a way that the remaining ones are more likely to be the value of the answer we are looking for
Deal with improbability by running the calculation again
There's an algorithm called the Grover Algorithm, which decides how many times you have to run it
But, even though you can't guarantee the right answer, you can probabilistically determine how many times you need to run it
a search on unordered items is normally O(n), but in quantum computers, it is O(n^(1/2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment