A primer on Qubits, Quantum gates and Quantum Operations


Introduction: After my initial encounter with IBM’s Quantum Experience, and my playing around with qubits, quantum gates and trying out the Bell experiment I can now say that I am fairly hooked to quantum computing.

So, I decided that  before going any  further,  that I  needed to  spend a little time more, getting to know more about the basics of Dirac’s bra-ket notation, qubits and ensuring that my knowledge is properly “chunked” ( See Learning to Learn: Powerful mental tools to master tough subjects, a really good course!!)

So, I started to look around for material on Quantum Computing, and finally landed on the classic course “Quantum Mechanics and Quantum Computing”, from University of California, Berkeley by Prof Umesh V Vazirani at edX. I have started to audit the course (listen in, without doing the assignments). The Prof is unbelievably good, and makes the topic both interesting and absorbing. This post is based on my notes of week 1 & 2 lectures. I have tried to articulate as best as I can, what I have understood of the lectures, though I would strongly recommend  you to, at least audit the archived course. By the way, I also had to refresh my knowledge of basic trigonometry and linear algebra. My knowledge of the basics of matrix manipulation, vectors etc. were buried deep within the sands of time. Luckily for me, they were reasonably intact.

A) Quantum states
A hydrogen atom has 1 electron in orbit. The electron can be either in the idle state or in the excited state. We can represent the idle state with |0> and the excited state with |1>, which is Dirac’s ‘ket’ notation.

Untitled

This electron will be in a superposition state which is represented by
Ψ = α |0> + β |1> where α & β are complex numbers and obey | α|2 + | β|2 = 1
For e.g. we could have the superposition state
\varphi= \frac{1}{2} + \frac{1i}{2}|0> + \frac{1}{\sqrt{2}}|1>
It can be seen that | α|2 = \frac{1}{2} and | β|2 = = \frac{1}{2}
For a complex number α = a+ bi  == > | α| = \sqrt{a^{2} + b^{2}}

B) Measurement
However, when the electron or the qubit is measured,  the state of superposition collapses to either |0> or |1> with the following probability’s

The resulting state is
|0> with probability | α|2
|1> with probability | β |2

And | α|2 + | β|2 = 1 because the sum of the probabilities must add up to 1  i.e. \sum p_{i} = 1

C) Geometric interpretation
Let us consider a qubit that is in a superposition state
Ψ = α |0> + β |1> where α & β are complex numbers and obey | α|2 + | β|2 = 1

We can write this as a vector  \begin{pmatrix} \alpha\\ \beta \end{pmatrix} representing the state of the electron

It can be seen that if
\alpha=1 and \beta=0 then |0> = \begin{pmatrix}1\\ 0\end{pmatrix}
and
\alpha=0 and \beta=1  then |1> = \begin{pmatrix}0\\ 1\end{pmatrix}
Untitled

Measuring a qubit in standard basis
If we represent the qubit geometrically then the superposition can be represented as a vector which makes an angle theta with |0>
\varphi = cos\theta|0> + sin\theta|1>

Measuring this  \varphi is the projection of on one of the standard basis |0> or |1>
The output is is |0> with probability cos^{2}\theta and
|1> with probability sin^{2}\theta

D) Measuring a qubit in any basis
Untitled
The qubit can be measured in any arbitrary basis. For e.g.  if
Ψ = α |0> + β |1>   and we have the diagonal basis
|u>| and |u’> as shown and Ψ makes an angle \theta with |u> then we can write

|u> with probability cos2Θ
And |u’> with probability sin2Θ

E) K Qubit system
Let us assume that we have a Quantum System with k qubits
|0>, |1>, |2>… |k-1>

The qubit will be in a superimposed state
Ψ = α0 |0>+ α1 |1> + α2|2> + … + αk-1 |k-1>
Where αj is a complex vector with the property ∑ αj = 1

Here Ψ is a unit vector in a K dimensional complex vector space, known as Hilbert Space
For e.g. a 3 qubit quantum system
\varphi = \frac{1}{2}+\frac{i}{2}|0> - \frac{1}{2} |1> + \frac{1}{2}|2>
Then P(0) = ½ P(1) = ¼ and P(2) = ¼   ∑Pj = 1

We could also write
\varphi = \begin{pmatrix} \alpha_{0}\\ \alpha_{1}\\ .. \\\alpha_{k-1}\\\end{pmatrix}
Or
Ψ = α0 |0>+ α1 |1> + α2|2> + … + αk-1 |k-1>

F) Measuring the angle between 2 complex vectors
To measure the angle between 2 complex vectors
\varphi = \begin{pmatrix} \alpha_{0}\\ \alpha_{1}\\\alpha_{2}\\\end{pmatrix}
And
\phi = \begin{pmatrix} \beta_{0}\\ \beta_{1}\\\beta_{2}\\\end{pmatrix}
we need to take the inner product of the complex conjugate of the 1st vector and the 2nd
cosΘ = inner product  => \bar{\varphi} . \phi
cos\theta = \bar\alpha_{0}\beta_{0} + \bar\alpha_{1}\beta_{1} + \bar\alpha_{2}\beta_{2}

For e.g.
If \varphi = \frac{1}{2} |0> + \frac{\sqrt 3}{2}|1> which makes 60 degrees with the |0> basis
And
\phi = \frac{1}{\sqrt 2} |0> + \frac{1}{\sqrt 2}|1> which is the diagonal |+> basis
Then the angle between these 2 vectors are obtained by taking the inner product
cosΘ =  ½ * 1/√2 + √3/2 * ½

G) Measuring Ψ in |+> or |-> basis
For e.g. if
\varphi = \frac{1}{2} |0> + \frac{\sqrt 3}{2}|1>   – (A)

Then we can specify/measure Ψ in |+> or |-> basis as follow
|+> = 1/√2(|0> + |1>) and |-> = 1/√2(|0> – |1>)
Or |0> = 1/√2(|+> + |->)   and |1> = 1/√2(|+> – |->)

We can write
Ψ= α|+> + β|->

Substituting for |0> and |1>  in (A) we get
\varphi = \frac{1+ \sqrt 3}{2 \sqrt 2} |+> \frac{1 - \sqrt 3 }{2 \sqrt 2} |->

H) Quantum gates
I) Clifford gates
Pauli gates
a) Pauli X
The Pauli X gate does a bit flip
|0> ==>  X|0> ==> |1>
|1> ==>  X|1> ==> |0>
and is represented
\begin{pmatrix}0&1\\1&0\end{pmatrix}

b) Pauli Z
This gates does a phase flip and is represented as the 2 x 2 unitary matrix
\begin{pmatrix}1&0\\0&-1\end{pmatrix}

c) Pauli Y
The Pauli operator Y  does both  a bit and a phase flip. The Y operator is represented as
\begin{pmatrix}0&-i\\i&0\end{pmatrix}

K) Superposition gates
Superposition is the concept that adding quantum states together results in a new quantum state. There are 3 gates that perform superposition of qubits the H, S and S’ gate.
a) H gate (Hadamard gate)
The H gate, also known as the Hadamard Gate when applied |0> state results in the qubit being half the time in  |0> and the other half in |1>
The H gate can be represented as
1/√2 \begin{pmatrix}1 & 1\\ 1 & -1\end{pmatrix}

b) S gate
The S gate can be represented as
\begin{pmatrix}1 & 0\\ 0 & i\end{pmatrix}

c) S’ gate
And the S’ gate is
\begin{pmatrix}1 & 0\\ 0 & -i\end{pmatrix}

L) Non-Clifford Gates
The quantum gates discussed in my earlier post Pauli X, Y, Z, H, S and S1 are members of a special group of gates known as the ‘Clifford group’.
The non-Clifford gates, discussed are the T and  Tǂ gates

These are given by
T = \begin{pmatrix}1 & 0\\ 0 & e^{^{i\prod /4}}\end{pmatrix}
Tǂ =\begin{pmatrix}1 & 0\\ 0 & e^{^{-i\prod /4}}\end{pmatrix}

M) 2 qubit system
A 2 qubit system
Untitled

A 2 qubit system is a superposition of all possible 2 qubit states. A 2 qubit system and can be represented as

Ψ = α00 |00> + α01 |01> + α10 |10> + α11 |11>

Measuring the 2 qubit system, as earlier, results in the collapse of the superposition and the result is one of 4 qubit states. The probability of the measure state is the square of the amplitude | αij|2

N) Entanglement
A  2 qubit system in which we have
Ψ = α0 |0> + α1 |1> and Φ= β0 |0> + β1 |1> the superimposed state is obtained by taking the tensor product of the 2 qubits
\chi = (\alpha_{0} |0> + \alpha_{1}|1>)\otimes  (\beta_{0} |0> + \beta_{1} |1>)
Where  \otimes is the tensor product

The state
Ψ = 1/√2|00> + 1/√2|11>
Is called an ‘entangled’ state because it cannot  be reduced to a product of 2 vectors

N) 2 qubit gates

Untitled

A 2 qubit system is a superposition of all possible 2 qubit states. A 2 qubit system and can be represented as
Ψ = α00 |00> + α01 |01> + α10 |10> + α11 |11>

Measuring the 2 qubit system, as earlier, results in the collapse of the superposition and the result is one of 4 qubit states. The probability of the measure state is the square of the amplitude | αij|2
More specifically a 2 qubit system in which we have
Ψ = α0 |0> + α1 |1> and Φ= β0 |0> + β1 |1> the superimposed state is obtained by taking the tensor product of the 2 qubits
\chi = (\alpha_{0} |0> + \alpha_{1}|1>)\otimes  (\beta_{0} |0> + \beta_{1} |1>)

Where \otimes is the tensor product
The state
Ψ = 1/√2|00> + 1/√2|11>
Is called an ‘entangled’ state because it cannot  be reduced to a product of 2 vectors
A quantum gate is a 2 x 2 unitary matrix U such that
α0 |0> + α1 |1>    == > Quantum Gate == > β0|0> + β1 |1>

Unitary functions: In mathematics, a complex square matrix U is unitary if its conjugate transpose U* is also its inverse
If
U=\begin{pmatrix}a & c \\b & d\end{pmatrix}
And U* = \begin{pmatrix}\bar a & \bar b \\ \bar c & \bar d\end{pmatrix}
Then
UU* = I where I is the Identity matrix

2 qubit gates is  4 x 4 unitary matrix
For a 2 qubit that is in the superposition state
Ψ = α00 |00> + α01 |01> + α10 |10> + α11 |11>

A 2 qubit gate’s operation on Ψ is
\begin{pmatrix}a & e & i & m \\ b & f & j & n\\ c & g & k & o\\ d & h & l & p\end{pmatrix} * \begin{pmatrix}\alpha_{00}\\ \alpha_{01}\\ \alpha_{10}\\\alpha_{11}\end{pmatrix}

One important 2 qubit gate is the CNOT gate which is shown  below

Untitled

 

The CNOT gate is represented by the following unitary matrix
\begin{pmatrix}1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 \\0 & 0  & 0  & 1\\ 0 & 0 & 1 & 0\end{pmatrix}

If 2  2×2 qubit gates were applied to 2 qubits the composite gate would be Tensor product of the 2 matrices

u1 = \begin{pmatrix}a & c\\ b & d\end{pmatrix}
u2 = \begin{pmatrix}e & g\\ f & h\end{pmatrix}
then
U= u1 \otimes u2
U = \begin{pmatrix}a\begin{pmatrix}e & g\\ f & h\end{pmatrix} & c\begin{pmatrix}a & c\\ b & d\end{pmatrix}\\ b \begin{pmatrix}a & c \\ b & d\end{pmatrix}& d\begin{pmatrix}a & c\\ b & d\end{pmatrix}\end{pmatrix}
The above product is also known as the Kronecker product

O) Tensor product of 2 qubits
Ψ = α0 |0> + α1 |1> and Φ= β0 |0> + β1 |1>
$latex \varphi \otimes \phi= α0 β0|0>|0> + α0 β1|0>|1> + α1 β0|1>|0> + α1 β1|1>|1>
= α0 β0|00> + α0 β1|01> + α1 β0|10> + α1 β1|11>
Untitled

If a Z gate and a Hadamard gate H were applied on 2 qubits, it is interest to know what the resulting composite gate would be.

Z = \begin{pmatrix}1 & 0\\ 0 & -1\end{pmatrix} and H = \begin{pmatrix}\frac{1}{\sqrt 2} & \frac{1}{\sqrt 2} \\ \frac{1}{\sqrt 2} & \frac{-1}{\sqrt 2}\end{pmatrix}
The composite gate is obtained by the tensor product of
Z \otimes H
Hence the result of the composite gate is
=\begin{pmatrix}1\begin{pmatrix}\frac{1}{\sqrt 2}   & \frac{1}{\sqrt 2}\\  \frac{1}{\sqrt 2}& \frac{-1}{\sqrt 2}\end{pmatrix} & 0\\ 0 & -1\begin{pmatrix}\frac{1}{\sqrt 2} & \frac{1}{\sqrt 2}\\ \frac{1}{\sqrt 2} &\frac{-1}{\sqrt 2} \end{pmatrix}\end{pmatrix}
=\begin{pmatrix}\begin{pmatrix}\frac{1}{\sqrt 2}   & \frac{1}{\sqrt 2}\\  \frac{1}{\sqrt 2}& \frac{-1}{\sqrt 2}\end{pmatrix} & 0\\ 0 & -\begin{pmatrix}\frac{-1}{\sqrt 2} & \frac{-1}{\sqrt 2}\\ \frac{-1}{\sqrt 2} &\frac{1}{\sqrt 2} \end{pmatrix}\end{pmatrix}

which is the entangled state.

Conclusion: This post includes most of the required basics to get started on Quantum Computing. I will probably add another post detailing the operations of the Quantum Gates on qubits.

Note:
1.The equations and matrices have been created using LaTeX notation using the online LaTex equation creator
2. The figures have been created using the app Bamboo Paper, which I think is cooler than creating in Powerpoint

Also see
1.Venturing into IBM’s Quantum Experience
2. Going deeper into IBM’s Quantum Experience!

You may also like
1.  Sixer – R package cricketr’s new Shiny avatar
2. Natural language processing: What would Shakespeare say?
3. Sea shells on the seashore
4. How to program – Some essential tips
5. Rock N’ Roll with Bluemix, Cloudant & NodeExpress
6. The Many Faces of Latency

Advertisements

7 thoughts on “A primer on Qubits, Quantum gates and Quantum Operations

  1. Pingback: Exploring Quantum Gate operations with QCSimulator | Giga thoughts …

  2. Yes, Vazirani’s course on edx is really good. For beginners I would suggest another very good set of lectures by Micheal Nielsen, they are available on Youtube (titled Quantum Computing for the Determined).

  3. Pingback: Taking a closer look at Quantum gates and their operations | Giga thoughts …

  4. Pingback: Introducing QCSimulator: A 5-qubit quantum computing simulator in R | Giga thoughts …

  5. Pingback: cricketr sizes up legendary All-rounders of yesteryear | Giga thoughts …

  6. Pingback: Inswinger: yorkr swings into International T20s | Giga thoughts …

  7. Pingback: Inswinger: yorkr swings into International T20s - Use-R!Use-R!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s