Friday, June 18, 2010

First Week of Coding

This week, I split my time between learning more about Quantum Computation and actual coding for my project.

So far, I have taught my code how to create a single Qbit of definite state and build the single Qbit gates that are to operate on it. I have built into the gate classes the ability to represent themselves in different bases (right now I have only implemented the |0> |1> and |+> |-> bases). To see how this all works, let me show an example of me creating an XGate operating on a single Qbit of definite state |1> and then representing it in the |0> |1> basis:

In [2]: circuit = XGate(0)*Qbit(1)

In [3]: circuit
Out[3]: X(0)⋅|1>

In [5]: represent(circuit, ZBasisSet())
[1.0]
[ 0]

This is exactly what we would expect as the XGate acts in the same way as a classical NOT gate would, switching the Qbit from the state |0> to the state |1>. We can of course make the number of gates we apply more complicated, with a Gate having an X, Hadamard and Z gate applied to it in that order:

In [7]: circuit = ZGate(0)*HadamardGate(0)*XGate(0)*Qbit(1)

In [8]: circuit
Out[8]: Z(0)⋅H(0)⋅X(0)⋅|1>

In [9]: represent(circuit, ZBasisSet())
[ 0.707106781186547]
[-0.707106781186547]

A quick matrix multiplication confirms that this is the expected result.

In the future, I will want to make the 'represent' function output in the standard |ket> notation. Also, I will need to implement a simplify function which will make any obvious simplifications to the gates. To generalize these gates so they can operate on multiple Qbits, the code will need to take the Kronecker Product of the 2x2 matrix with several unity matrices. Also, I will want to create tests to automatically test the code.

Much of this week I spent reading through relevant resources. I thoroughly read the first chapter of Mermin's book "Quantum Computer Science: An Introduction". This book introduces Quantum Computation by first discussing reversible classical gates (some not all that useful) and then generalizes these gates to quantum computation; the book goes through quite a few gate equivalences that I will want to teach the code to recognize.

I also started digging through a article describing the Solovay-Kitaev algorithm which allows an arbitrary single qbit operator to efficiently be approximated in terms of our set of universal gates; I will want to teach my code how to do this.

1 comment:

  1. Just a note on your branch, you have whitespace errors. The test_code_quality.py test will reveal these to you and the bin/strip_whitespace.py script will fix them. See if you can setup your text editor to strip them for you automatically.

    ReplyDelete