<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Python &#187; Quantum computing</title>
	<atom:link href="/python/category/quantum-computing/feed/" rel="self" type="application/rss+xml" />
	<link>https://talkera.org/python</link>
	<description>Programming Blog</description>
	<lastBuildDate>Sun, 01 Feb 2015 17:15:10 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.1</generator>
	<item>
		<title>An Introduction to Building Quantum Computing Applications with Python</title>
		<link>https://talkera.org/python/an-introduction-to-building-quantum-computing-applications-with-python/</link>
		<comments>https://talkera.org/python/an-introduction-to-building-quantum-computing-applications-with-python/#comments</comments>
		<pubDate>Tue, 20 Jan 2015 15:06:46 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[Quantum computing]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Quantum]]></category>
		<category><![CDATA[qubit]]></category>
		<category><![CDATA[sigmam]]></category>
		<category><![CDATA[sigmap]]></category>

		<guid isPermaLink="false">https://talkera.org/python/?p=53</guid>
		<description><![CDATA[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 , [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>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:  <a href="https://code.google.com/p/pyqu/" target="_blank">PyQu</a> , <a href="https://code.google.com/p/qutip/" target="_blank">QuTip</a> and <a href="http://www.stahlke.org/dan/qitensor/" target="_blank">Qitensor</a>.  We decided to pick QuTip as it has a very large code base and as it has the most recent changes.  PyQu hasn&#8217;t been updated since 2010 and Qitensor since a year or so.</p>
<p><strong>Installing</strong><br />
We use a Unix machine in this tutorial, but you should be fine with any other operating system. Install using:</p><pre class="crayon-plain-tag">sudo add-apt-repository ppa:jrjohansson/qutip-releases
sudo apt-get update
sudo apt-get install python-qutip</pre><p>We then start Python from the command line and type the commands listed below ( &gt;&gt;&gt; ).</p><pre class="crayon-plain-tag">$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:38) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; from qutip import *
&gt;&gt;&gt; about()

QuTiP: Quantum Toolbox in Python
Copyright (c) 2011 and later.
Paul D. Nation &amp; Robert J. Johansson

QuTiP Version:      3.1.0
Numpy Version:      1.8.2
Scipy Version:      0.13.3
Cython Version:     0.20.1post0
Matplotlib Version: 1.3.1
Fortran mcsolver:   True
scikits.umfpack:    False
Python Version:     2.7.6
Platform Info:      Linux (i686)
Installation path:  /usr/lib/python2.7/dist-packages/qutip</pre><p>This indicates that Qutip has been correctly installed.</p>
<p><strong>The Quantum data structure</strong><br />
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:</p><pre class="crayon-plain-tag">#!/usr/bin/env python
from qutip import *
from scipy import *

r = rand(4, 4)
print Qobj(r)</pre><p>And execute with:</p><pre class="crayon-plain-tag">python quantum.py</pre><p>This will output the quantum object:</p><pre class="crayon-plain-tag">Quantum object: dims = [[4], [4]], shape = [4, 4], type = oper, isherm = False
Qobj data =
[[ 0.25529374  0.75548592  0.85680266  0.1438253 
 [ 0.75070138  0.68628867  0.97435624  0.77396516]
 [ 0.69819458  0.81714756  0.2604015   0.69051901]
 [ 0.0898242   0.05292657  0.49134431  0.4433644 ]]</pre><p>If you want to specify user input yourself you could use:</p><pre class="crayon-plain-tag">#!/usr/bin/env python
from qutip import *
from scipy import *

x = array([[1],[2],[3],[4],[5]])
q = Qobj(x)
print q</pre><p>This quantum object will simply hold your user given data:</p><pre class="crayon-plain-tag">Quantum object: dims = [[5], [1]], shape = [5, 1], type = ket
Qobj data =
[[ 1.]
 [ 2.]
 [ 3.]
 [ 4.]
 [ 5.]]</pre><p><strong> Quantum states and operators</strong><br />
A quantum system is not a simple two-level system, it has multiple states.  QuTip includes some predefined states and quantum operators which are <a href="http://qutip.org/docs/2.2.0/guide/guide-basics.html#first-things-first" target="_blank">listed here. </a></p>
<p><strong>Qubits and operators</strong><br />
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:</p><pre class="crayon-plain-tag">#!/usr/bin/env python
from qutip import *
from scipy import *

spin = basis(2, 0)
print spin</pre><p>You can now apply quantum system operators on the qubit:</p><pre class="crayon-plain-tag">#!/usr/bin/env python
from qutip import *
from scipy import *

spin = basis(2, 0)
print sigmam() * spin
print sigmap() * spin</pre><p><strong>Combining qubits</strong><br />
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:</p><pre class="crayon-plain-tag">#!/usr/bin/env python
from qutip import *
from scipy import *

q1 = basis(2, 0)
q2 = basis(2,0)

print q1
print q2
print tensor(q1,q2)</pre><p>The output we will get is:</p><pre class="crayon-plain-tag">Quantum object: dims = [[2], [1]], shape = [2, 1], type = ket
Qobj data =
[[ 1.]
 [ 0.]]
Quantum object: dims = [[2], [1]], shape = [2, 1], type = ket
Qobj data =
[[ 1.]
 [ 0.]]
Quantum object: dims = [[2, 2], [1, 1]], shape = [4, 1], type = ket
Qobj data =
[[ 1.]
 [ 0.]
 [ 0.]
 [ 0.]]</pre><p><strong>Whats next?</strong><br />
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 <a href="http://qutip.org/docs/2.2.0/index.html" target="_blank">http://qutip.org/docs/2.2.0/index.html</a></p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Ftalkera.org%2Fpython%2Fan-introduction-to-building-quantum-computing-applications-with-python%2F&amp;linkname=An%20Introduction%20to%20Building%20Quantum%20Computing%20Applications%20with%20Python" title="Facebook" rel="nofollow" target="_blank"></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Ftalkera.org%2Fpython%2Fan-introduction-to-building-quantum-computing-applications-with-python%2F&amp;linkname=An%20Introduction%20to%20Building%20Quantum%20Computing%20Applications%20with%20Python" title="Twitter" rel="nofollow" target="_blank"></a><a class="a2a_button_google_plus" href="http://www.addtoany.com/add_to/google_plus?linkurl=http%3A%2F%2Ftalkera.org%2Fpython%2Fan-introduction-to-building-quantum-computing-applications-with-python%2F&amp;linkname=An%20Introduction%20to%20Building%20Quantum%20Computing%20Applications%20with%20Python" title="Google+" rel="nofollow" target="_blank"></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Ftalkera.org%2Fpython%2Fan-introduction-to-building-quantum-computing-applications-with-python%2F&amp;linkname=An%20Introduction%20to%20Building%20Quantum%20Computing%20Applications%20with%20Python" title="Reddit" rel="nofollow" target="_blank"></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Ftalkera.org%2Fpython%2Fan-introduction-to-building-quantum-computing-applications-with-python%2F&amp;linkname=An%20Introduction%20to%20Building%20Quantum%20Computing%20Applications%20with%20Python" title="StumbleUpon" rel="nofollow" target="_blank"></a><a class="a2a_button_pinterest" href="http://www.addtoany.com/add_to/pinterest?linkurl=http%3A%2F%2Ftalkera.org%2Fpython%2Fan-introduction-to-building-quantum-computing-applications-with-python%2F&amp;linkname=An%20Introduction%20to%20Building%20Quantum%20Computing%20Applications%20with%20Python" title="Pinterest" rel="nofollow" target="_blank"></a><a class="a2a_dd a2a_target addtoany_share_save" href="https://www.addtoany.com/share_save#url=http%3A%2F%2Ftalkera.org%2Fpython%2Fan-introduction-to-building-quantum-computing-applications-with-python%2F&amp;title=An%20Introduction%20to%20Building%20Quantum%20Computing%20Applications%20with%20Python" id="wpa2a_2"></a></p>]]></content:encoded>
			<wfw:commentRss>https://talkera.org/python/an-introduction-to-building-quantum-computing-applications-with-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
