<- qstate(nbits=1)
ket0 ket0
( 1 ) * |0>
Sam Hutchins
September 3, 2023
Wow, how time flies when you’re having fun! We sit back and technology advances.. So now it’s time to leap into the fast-developing concept of Quantum Mechanics. Where do we start? Well, it seems like the beginning might be a starting point. WARNING: This may get into Linear Algebra and matrices as we attempt to understand all this. Also expect mistakes, errors and misconceptions as I try to jump into this. It’s an Adventure !
I suppose we should look at, “just what is a qubit?” A qubit (quantum bit) is a quantum system whose classical state is 0, 1. It’s just a bit, but it can be in a quantum state 3 (superposition). NOTE: There are reams of information about this subject on the Internet, so this is mostly done for my own understanding, not to present new information.
A valid quantum state vector must be such that the sum of the absolute values squared of the entries must be equal to 1. To manipulate the qubits (such as kets and bras), I will use the R package, qsimulatR, which is a quantum simulator for R. BTW, there is a nice four-part series posted on R-Bloggers that goes a long way explaining the operation and usage of the qsimulatR package. The original series shows all four parts.
Now, using qsimulatR, I will define a qubit |0〉.
There are a couple of ways to define a qubit |1〉. The easiest way is using a Pauli X gate (bit flip).
The other way is define the coefficients, obviously more cumbersome.
To compute the sum of the absolute values squared of a quantum state vector, we can use the Mod() function.
which shows a valid 1. I’ve been a bit remiss in not showing where the coefficients (and other elements) are coming from. To display the internal structure of an R object, such as a qubit, we can use the str command from the utils package.
Formal class 'qstate' [package "qsimulatR"] with 5 slots
..@ nbits : int 1
..@ coefs : cplx [1:2] 1+0i 0+0i
..@ basis : chr [1:2] "|0>" "|1>"
..@ noise :List of 4
.. ..$ p : num 0
.. ..$ bits : int 1
.. ..$ error: chr "any"
.. ..$ args : list()
..@ circuit:List of 2
.. ..$ ncbits : num 0
.. ..$ gatelist: list()
So that’s where the coefficients are that add to 1 as noted above.
Superposition is a complete entanglement of a qubit |0〉 and |1〉 states, represented by |
This entanglement, following the above formula, is accomplished by defining the coefficients for each bit, |0> and |1>, as shown here.
( 0.333333333333333+0.666666666666667i ) * |0>
+ ( -0.666666666666667+0i ) * |1>
And to verify |
Also, any valid quantum gate must be reversible.
Quantum gates have to be reversible because quantum mechanics is reversible (and even more specifically it is unitary). It’s just an observed fact about the universe. (Even measurement can be modeled as a reversible unitary operation, inconvenient though that may be.)
Another aspect of entanglement is that two entangled particles, regardless of distance between, are related to each other when measured. So if a particle is measured as ‘spin up’, the other, when measured at the exact same time, will be ‘spin down.’ Referring to distance, that could be many light years apart. All this is very non-intuitive!
The act of measuring a quantum circuit collapses the quantum state to a classical state and only gives probabilities of an answer, not a 0 or 1 answer as in classical computer gates. What this means is an attempt to actually measure a probability state, destroys that state. So, just for the fun of it, here is Schrodinger’s equation. To find the motion of a particle with total energy
That reminds me of the paradox of Schrodinger’s cat. But that’s another story, although it does illustrate the difficulty of observing something that can’t be observed without changing the possible outcome (waveform collapse).
In constructing a quantum circuit, many gates are available, which allow circuits to replicate similar classical circuits such as
So, what function does each gate perform? The list below briefly describes each gate’s action.
All these actions can be demonstrated on the Bloch sphere.
I think perhaps there may be more segments to this post. Check back. We praise God for all things, because He surpasses all of man’s understanding. Be safe!