So we want to make a quantum application with Python, but since we do not own any quantum computer we need to have a simulator first. Simulation will not have the same performance as an actual quantum computer but we will be able to run applications. We have a choice from three simulators: PyQu , QuTip and Qitensor. We decided to pick QuTip as it has a very large code base and as it has the most recent changes. PyQu hasn’t been updated since 2010 and Qitensor since a year or so.
Quantum Computing: An Applied Approach
We use a Unix machine in this tutorial, but you should be fine with any other operating system. Install using:
sudo add-apt-repository ppa:jrjohansson/qutip-releases
sudo apt-get update
sudo apt-get install python-qutip
We then start Python from the command line and type the commands listed below ( >>> ).
This indicates that Qutip has been correctly installed.
The Quantum data structure
In quantum systems we need a data structure that is capable of encapsulating the properties of a quantum operator and ket/bra vectors, we use the Qobj data structure for that. In other words, to effectively simulate a quantum application we need to use the appropriate data structure. Consider the example below:
And execute with:
This will output the quantum object:
Quantum object: dims = [, ], shape = [4, 4], type = oper, isherm = False
If you want to specify user input yourself you could use:
This quantum object will simply hold your user given data:
Quantum object: dims = [, ], shape = [5, 1], type = ket
Quantum states and operators
A quantum system is not a simple two-level system, it has multiple states. QuTip includes some predefined states and quantum operators which are listed here.
Qubits and operators
We create a Qubit to hold data. Th Qubit is the quantum analogue of the classical bit. Unlike traditional bits, the qubit can be in a superposition of both states at the same time, a property which is fundamental to quantum computing. The code below will create a qubit:
You can now apply quantum system operators on the qubit:
To describe the states of two coupled qubits we need to take the tensor product of the state vectors for each of the system components. Let us try that:
The output we will get is:
Quantum object: dims = [, ], shape = [2, 1], type = ket
We have built some very simply quantum applications using this simple introduction. Perhaps you want to create an actually useful application, if so you could study more about quantum computing and complete the tutorial at http://qutip.org/docs/latest/index.html