##// END OF EJS Templates
Merge branch 'stdin'...
Merge branch 'stdin' Changes stdin channel from REQ-REQ to ROUTER-DEALER, fixing the round-robin load-balancing of stdin_requests across frontends. stdin_requests now go to the client that made the execute_request that prompted the stdin request. stdin_requests from frontends that do not support stdin will raise an error, rather than hanging on input that will never arrive. reviewed by @fperez closes #673

File last commit:

r4637:d919e2ec
r4954:6e92ffd9 merge
Show More
qft.ipynb
163 lines | 35.6 KiB | text/plain | TextLexer
Brian E. Granger
Converting notebooks to JSON format.
r4634 {
"nbformat": 2,
Brian E. Granger
Implemented metadata for notebook format.
r4637 "metadata": {
"name": "qft"
},
Brian E. Granger
Converting notebooks to JSON format.
r4634 "worksheets": [
{
"cells": [
{
"source": "<h1>Quantum Fourier Transform</h1>",
"cell_type": "markdown"
},
{
"cell_type": "code",
"language": "python",
"outputs": [],
"collapsed": true,
"prompt_number": 1,
"input": "%load_ext sympyprinting"
},
{
"cell_type": "code",
"language": "python",
"outputs": [],
"collapsed": true,
"prompt_number": 2,
"input": "from sympy import sqrt, symbols, Rational\nfrom sympy import expand, Eq, Symbol, simplify, exp, sin\nfrom sympy.physics.quantum import *\nfrom sympy.physics.quantum.qubit import *\nfrom sympy.physics.quantum.gate import *\nfrom sympy.physics.quantum.grover import *\nfrom sympy.physics.quantum.qft import QFT, IQFT, Fourier\nfrom sympy.physics.quantum.circuitplot import circuit_plot"
},
{
"source": "QFT is useful for a quantum algorithm for factoring numbers which is exponentially faster than what is thought to be possible on a classical machine.<br>\nThe transform does a DFT on the state of a quantum system<br>\nThere is a simple decomposition of the QFT in terms of a few elementary gates.",
"cell_type": "markdown"
},
{
"source": "<h2>QFT Gate and Circuit</h2>",
"cell_type": "markdown"
},
{
"source": "Build a 3 qubit QFT and decompose it into primitive gates.",
"cell_type": "markdown"
},
{
"cell_type": "code",
"language": "python",
"outputs": [
{
"output_type": "pyout",
"latex": "$$SWAP_{0,2} H_{0} C_{0}{\\left(S_{1}\\right)} H_{1} C_{0}{\\left(T_{2}\\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H13\ns2O27yMLyHFmIpsZI7HH07TmCthVl3b73Bv5YcUidAMfRW7j24bs7EWL0fshJ/7bMVNwxS1CJ7Rz\n5VO7NPPVq2hOlNE2n9i5b/GpOj3I2b44XchOzhWx93ppvgH5eZp/WaXVdemEz6JxxyE7fXGeQpKt\nG9nd2lHAf564raCd2rnyqV2aZdGrSE6U0Taf2IEEHy67AoFAINAujsB+T10gEAhUHtutMoFAIBAI\nBAKBQCAQCAQCgUAgEAgEPPkfTF7L9pqXFtoAAAAASUVORK5CYII=\n",
"text": "SWAP \u22c5H \u22c5C \u239bS \u239e\u22c5H \u22c5C \u239bT \u239e\u22c5C \u239bS \u239e\u22c5H \n 0,2 0 0\u239d 1\u23a0 1 0\u239d 2\u23a0 1\u239d 2\u23a0 2"
}
],
"collapsed": false,
"prompt_number": 3,
"input": "fourier = QFT(0,3).decompose(); fourier\n"
},
{
"cell_type": "code",
"language": "python",
"outputs": [
{
"output_type": "pyout",
"prompt_number": 4,
"text": "&lt;sympy.physics.quantum.circuitplot.CircuitPlot object at 0x4992910&gt;"
},
{
"output_type": "display_data",
"png": "iVBORw0KGgoAAAANSUhEUgAAAa8AAADFCAYAAADjc32JAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEnhJREFUeJzt3X9MVfXjx/HXuZeuAiECSZlOizkXGjVrECEgQbq0WWHa\nomXpVpNpzbIflLVafxi12qzW/FSzH1t/kJm1Ya5mTn7IbentF7OoGFFiq8RMELho/DjfP5p8Y9yL\ngJd77vv6fGznn/PWw+vNkfvivM+5V8u2bVsAABjE5XQAAABGi/ICABiH8gIAGIfyAgAYh/ICABiH\n8gIAGIfyAgAYh/ICABiH8gIAGIfyAgAYh/ICABiH8gIAGIfyAgAYh/ICABiH8gIAGIfyAgAYh/IC\nABiH8gIAGIfyAgAYh/ICABiH8gIAGIfyAgAYh/ICABiH8gIAGIfyAgAYh/ICABgnKsorOTlZlmWN\n25acnOz0FAeEcq6RNC9pfM5jpM0RQGhYtm3bToc4W5ZlaTynMd7HH41QZomkeUnjkyfS5gggNKLi\nygsAcG6hvAAAxqG8AADGifryWrZsmdLT0+VyueTxeDRv3jytWbNGknTo0CEVFhZq+vTpcrlcSkxM\nVFZWlrZs2eJw6rHp7e3VK6+8opUrV6qkpETFxcV666231NXVpaVLlzodb1QOHjwol8slt9utOXPm\naPHixbr22msHzuN1112nxYsXKycnR/Hx8XK73ero6HA6NoBwsaPAmabxxRdf2JZl2Q888EDA8fLy\nctuyLPv9998f0/HDKVgWv99v33jjjfamTZsG7S8vL7dnz55tl5SUjPhYTvlvno0bN9orVqywOzs7\nB/Z9//33tmVZ9urVqwf9vYMHD9qTJ08+4zEBRI+ov/KSpNraWknSkiVLAo5XVVXJ7XZr0aJF4YwV\nUnfddZemTZumjRs3Dtr/2GOPqbOzU9dff71Dycbm66+/VkVFheLj4wf21dTUSJIWLlw46M9efvnl\nmj9/fljzAecKv98/ZF9/f7+6u7sdSPP/zonyqqmpkcfjUW5u7pCxnp4eeb1eZWRkKDEx0YF0Z6+9\nvV2VlZVasWJFwPGMjAwVFRWFOdXYffPNN8rPz5fb7R60//QvIfn5+YP29/X16YILLghbPuBc0dXV\npblz5w787En/Fte9996rp59+2sFk50B59ff3y+v1KjMzU7GxsUPGfT6f/H7/kBdEk9TV1amnp0eN\njY0Bx/Py8jRz5swwpxq7o0ePatWqVUP219bW6tJLL9W0adMG7e/p6Ql6VQ1g7OLj47V161YtX75c\ntbW1A8XV1NSkp556ytFsMY5+9TCor69Xe3u7CgoKAo5XVVVJkhYsWBDGVKGVnZ0tt9utDRs26Jdf\nftEtt9yia665RjEx/57eJ554wuGEoxNo+bapqUl//PGH7r777iFjEydO1G233RaOaMA5p6ioSBUV\nFVq+fLkyMzPV2dmpXbt26fzzz3c2WLCbYZKM2oJ56aWXbMuy7KysLPuGG24YsqWkpNgul8v+66+/\ngh7D6bmNZK4vvPCCPWHCBNuyLNuyLDs+Pt5et26d3dbWZsy8hjuPb775pm1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XgAA41BeAADjUF4AAONQXgAA41BeAADjUF4AAONQXgAA41BeAADjUF4AAONQXgAA41BeAADjUF4A\nAONQXgAA41BeAADjUF4AAONQXgAA41BewDhLTk6WZVnjtiUnJzs9RUmhnWekzAmRy7Jt23Y6BELL\nsixF82k1bX7jnTdSvh+hzBEpc8JgkXReuPICABiH8gIAGIfyAhyybNkypaeny+VyyePxaN68eVqz\nZo0k6dChQyosLNT06dPlcrmUmJiorKwsbdmyxeHUY9fb26tXXnlFK1euVElJiYqLi/XWW2+pq6tL\nS5cudToeDEN5AQ758MMP9c4770iS1q1bp2+++Uavv/66JGnmzJnau3ev7rvvPknS1q1bdeDAAa1d\nu9apuGelu7tbt9xyizo7O/Xuu++qoqJCH330kVpbW3XVVVcpISHB6YgwDOUFOKi2tlaStGTJkoDj\nVVVVcrvdWrRoUThjhdxdd92ladOmaePGjYP2P/bYY+rs7NT111/vUDKYKsbpAAit1tZWSVJPT4/O\nO+88h9PgTGpqauTxeJSbmztkrKenR16vVxkZGUpMTHQgXWi0t7ersrJSu3btCjiekZGhoqKiMKeC\n6bjyihLd3d1avny5ZsyYIUmaMmWKtm/f7nAqDKe/v19er1eZmZmKjY0dMu7z+eT3+5Wfn+9AutCp\nq6tTT0+PGhsbA47n5eVp5syZYU4F01FeUeKhhx7Srl27dOrUKUn//ra7atUq/fTTTw4nQzD19fVq\nb29XQUFBwPGqqipJ0oIFC8KYKvSys7Pldru1YcMGPfLII/J6vert7R0Yf+KJJxxMB1PxJuUoER8f\nL7/fP2hfTEyMHn30UW3atMmhVOMjkt4oORLB8r788st68MEHlZmZGfATJXw+n44fP67W1lalpKSM\n+vjhNlyOF198UU8++aT++ecfSVJcXJxWrVqlTZs2BVwSjZQ5YbCIOi92EJLY2NhCtAVSXFxsn3fe\neXZXV9eQsd7eXjsuLs6eO3dusB/RiPxZHc6PP/5oP/3003Z+fr7t8Xhsy7Ls5cuXR/yc2CJz48or\nStx000365JNPBi3HxMXFaffu3Zo/f76DyUIvon77G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Unp4+sO90gbW3\ntzuYjE/YAICggn2ixO23367t27frjz/+UGpq6pDxiy66SJMmTVJjY+OYjo8zY9kQAEbh1KlTqq6u\nVlpaWsDiqq+vV2trq+bPn+9AunMH5QUAI9DS0qIFCxYoPT1dR48eVUtLi3Jzc/Xaa69J+ve+bE5O\njhYuXCjLslRZWamCggLHP4kiWrFsCABB8J9RRi6uvAAAxqG8AADGobwAAMbhfV4AMIzxfD9hUlLS\nuB072lFeABAED1NELpYNAQDGobwAAMahvAAAxqG8AADGobwAAMahvAAAxqG8AADGobwAAMahvAAA\nxqG8AADGobwAAMahvAAAxqG8AADGobwAAMahvAAAxqG8AADGobwAAMahvAAAxqG8AADGobwAAMah\nvAAAxqG8AADGobwAAMahvAAAxqG8AADGobwAAMahvAAAxqG8AADGobwAAMahvAAAxqG8AADGobwA\nAMahvAAAxqG8AADG+T9bnbupimRS1gAAAABJRU5ErkJggg==\n"
}
],
"collapsed": false,
"prompt_number": 4,
"input": "circuit_plot(fourier, nqubits=3)"
},
{
"source": "The QFT circuit can be represented in various symbolic forms.",
"cell_type": "markdown"
},
{
"cell_type": "code",
"language": "python",
"outputs": [],
"collapsed": true,
"prompt_number": 5,
"input": "m = represent(fourier, nqubits=3)"
},
{
"cell_type": "code",
"language": "python",
"outputs": [
{
"output_type": "pyout",
"latex": "$$\\left(\\begin{smallmatrix}\\frac{1}{4} \\sqrt{2} & \\frac{1}{4} \\sqrt{2} & \\frac{1}{4} \\sqrt{2} & \\frac{1}{4} \\sqrt{2} & \\frac{1}{4} \\sqrt{2} & \\frac{1}{4} \\sqrt{2} & \\frac{1}{4} \\sqrt{2} & \\frac{1}{4} \\sqrt{2}\\\\\\frac{1}{4} \\sqrt{2} & \\frac{1}{4} \\sqrt{2} e^{\\frac{1}{4} \\mathbf{\\imath} \\pi} & \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} & \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} e^{\\frac{1}{4} \\mathbf{\\imath} \\pi} & - \\frac{1}{4} \\sqrt{2} & - \\frac{1}{4} \\sqrt{2} e^{\\frac{1}{4} \\mathbf{\\imath} \\pi} & - \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} & - \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} e^{\\frac{1}{4} \\mathbf{\\imath} \\pi}\\\\\\frac{1}{4} \\sqrt{2} & \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} & - \\frac{1}{4} \\sqrt{2} & - \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} & \\frac{1}{4} \\sqrt{2} & \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} & - \\frac{1}{4} \\sqrt{2} & - \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath}\\\\\\frac{1}{4} \\sqrt{2} & \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} e^{\\frac{1}{4} \\mathbf{\\imath} \\pi} & - \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} & \\frac{1}{4} \\sqrt{2} e^{\\frac{1}{4} \\mathbf{\\imath} \\pi} & - \\frac{1}{4} \\sqrt{2} & - \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} e^{\\frac{1}{4} \\mathbf{\\imath} \\pi} & \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} & - \\frac{1}{4} \\sqrt{2} e^{\\frac{1}{4} \\mathbf{\\imath} \\pi}\\\\\\frac{1}{4} \\sqrt{2} & - \\frac{1}{4} \\sqrt{2} & \\frac{1}{4} \\sqrt{2} & - \\frac{1}{4} \\sqrt{2} & \\frac{1}{4} \\sqrt{2} & - \\frac{1}{4} \\sqrt{2} & \\frac{1}{4} \\sqrt{2} & - \\frac{1}{4} \\sqrt{2}\\\\\\frac{1}{4} \\sqrt{2} & - \\frac{1}{4} \\sqrt{2} e^{\\frac{1}{4} \\mathbf{\\imath} \\pi} & \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} & - \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} e^{\\frac{1}{4} \\mathbf{\\imath} \\pi} & - \\frac{1}{4} \\sqrt{2} & \\frac{1}{4} \\sqrt{2} e^{\\frac{1}{4} \\mathbf{\\imath} \\pi} & - \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} & \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} e^{\\frac{1}{4} \\mathbf{\\imath} \\pi}\\\\\\frac{1}{4} \\sqrt{2} & - \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} & - \\frac{1}{4} \\sqrt{2} & \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} & \\frac{1}{4} \\sqrt{2} & - \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} & - \\frac{1}{4} \\sqrt{2} & \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath}\\\\\\frac{1}{4} \\sqrt{2} & - \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} e^{\\frac{1}{4} \\mathbf{\\imath} \\pi} & - \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} & - \\frac{1}{4} \\sqrt{2} e^{\\frac{1}{4} \\mathbf{\\imath} \\pi} & - \\frac{1}{4} \\sqrt{2} & \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} e^{\\frac{1}{4} \\mathbf{\\imath} \\pi} & \\frac{1}{4} \\sqrt{2} \\mathbf{\\imath} & \\frac{1}{4} \\sqrt{2} e^{\\frac{1}{4} \\mathbf{\\imath} \\pi}\\end{smallmatrix}\\right)$$",
"prompt_number": 6,
"text": "\u23a1 \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \n\u23a2\u2572\u2571 2 \u2572\u2571 2 \u2572\u2571 2 \u2572\u2571 2 \u2572\u2571 2 \u2572\u2571 2 \u2572\u2571 2 \n\u23a2\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500 \n\u23a2 4 4 4 4 4 4 4 \n\u23a2 \n\u23a2 \u2148\u22c5\u03c0 \u2148\u22c5\u03c0 \u2148\u22c5\u03c0 \n\u23a2 \u2500\u2500\u2500 \u2500\u2500\u2500 \u2500\u2500\u2500 \n\u23a2 \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd 4 \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd 4 \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd 4 \u23bd\u23bd\u23bd \n\u23a2\u2572\u2571 2 \u2572\u2571 2 \u22c5\u212f \u2572\u2571 2 \u22c5\u2148 \u2572\u2571 2 \u22c5\u2148\u22c5\u212f -\u2572\u2571 2 -\u2572\u2571 2 \u22c5\u212f -\u2572\u2571 2 \u22c5\n\u23a2\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\u23a2 4 4 4 4 4 4 4 \n\u23a2 \n\u23a2 \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd\n\u23a2\u2572\u2571 2 \u2572\u2571 2 \u22c5\u2148 -\u2572\u2571 2 -\u2572\u2571 2 \u22c5\u2148 \u2572\u2571 2 \u2572\u2571 2 \u22c5\u2148 -\u2572\u2571 2 \n\u23a2\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\n\u23a2 4 4 4 4 4 4 4 \n\u23a2 \n\u23a2 \u2148\u22c5\u03c0 \u2148\u22c5\u03c0 \u2148\u22c5\u03c0 \n\u23a2 \u2500\u2500\u2500 \u2500\u2500\u2500 \u2500\u2500\u2500 \n\u23a2 \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd 4 \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd 4 \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd 4 \u23bd\u23bd\u23bd \n\u23a2\u2572\u2571 2 \u2572\u2571 2 \u22c5\u2148\u22c5\u212f -\u2572\u2571 2 \u22c5\u2148 \u2572\u2571 2 \u22c5\u212f -\u2572\u2571 2 -\u2572\u2571 2 \u22c5\u2148\u22c5\u212f \u2572\u2571 2 \u22c5\u2148\n\u23a2\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\u23a2 4 4 4 4 4 4 4 \n\u23a2 \n\u23a2 \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \n\u23a2\u2572\u2571 2 -\u2572\u2571 2 \u2572\u2571 2 -\u2572\u2571 2 \u2572\u2571 2 -\u2572\u2571 2 \u2572\u2571 2 \n\u23a2\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500 \n\u23a2 4 4 4 4 4 4 4 \n\u23a2 \n\u23a2 \u2148\u22c5\u03c0 \u2148\u22c5\u03c0 \u2148\u22c5\u03c0 \n\u23a2 \u2500\u2500\u2500 \u2500\u2500\u2500 \u2500\u2500\u2500 \n\u23a2 \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd 4 \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd 4 \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd 4 \u23bd\u23bd\u23bd \n\u23a2\u2572\u2571 2 -\u2572\u2571 2 \u22c5\u212f \u2572\u2571 2 \u22c5\u2148 -\u2572\u2571 2 \u22c5\u2148\u22c5\u212f -\u2572\u2571 2 \u2572\u2571 2 \u22c5\u212f -\u2572\u2571 2 \u22c5\n\u23a2\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\u23a2 4 4 4 4 4 4 4 \n\u23a2 \n\u23a2 \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd\n\u23a2\u2572\u2571 2 -\u2572\u2571 2 \u22c5\u2148 -\u2572\u2571 2 \u2572\u2571 2 \u22c5\u2148 \u2572\u2571 2 -\u2572\u2571 2 \u22c5\u2148 -\u2572\u2571 2 \n\u23a2\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\n\u23a2 4 4 4 4 4 4 4 \n\u23a2 \n\u23a2 \u2148\u22c5\u03c0 \u2148\u22c5\u03c0 \u2148\u22c5\u03c0 \n\u23a2 \u2500\u2500\u2500 \u2500\u2500\u2500 \u2500\u2500\u2500 \n\u23a2 \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd 4 \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd 4 \u23bd\u23bd\u23bd \u23bd\u23bd\u23bd 4 \u23bd\u23bd\u23bd \n\u23a2\u2572\u2571 2 -\u2572\u2571 2 \u22c5\u2148\u22c5\u212f -\u2572\u2571 2 \u22c5\u2148 -\u2572\u2571 2 \u22c5\u212f -\u2572\u2571 2 \u2572\u2571 2 \u22c5\u2148\u22c5\u212f \u2572\u2571 2 \u22c5\u2148\n\u23a2\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\u23a3 4 4 4 4 4 4 4 \n\n \u23bd\u23bd\u23bd \u23a4\n \u2572\u2571 2 \u23a5\n \u2500\u2500\u2500\u2500\u2500 \u23a5\n 4 \u23a5\n \u23a5\n \u2148\u22c5\u03c0\u23a5\n \u2500\u2500\u2500\u23a5\n \u23bd\u23bd\u23bd 4 \u23a5\n\u2148 -\u2572\u2571 2 \u22c5\u2148\u22c5\u212f \u23a5\n\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u23a5\n 4 \u23a5\n \u23a5\n \u23bd\u23bd\u23bd \u23a5\n -\u2572\u2571 2 \u22c5\u2148 \u23a5\n \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u23a5\n 4 \u23a5\n \u23a5\n \u2148\u22c5\u03c0 \u23a5\n \u2500\u2500\u2500 \u23a5\n \u23bd\u23bd\u23bd 4 \u23a5\n -\u2572\u2571 2 \u22c5\u212f \u23a5\n \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u23a5\n 4 \u23a5\n \u23a5\n \u23bd\u23bd\u23bd \u23a5\n -\u2572\u2571 2 \u23a5\n \u2500\u2500\u2500\u2500\u2500\u2500 \u23a5\n 4 \u23a5\n \u23a5\n \u2148\u22c5\u03c0 \u23a5\n \u2500\u2500\u2500 \u23a5\n \u23bd\u23bd\u23bd 4 \u23a5\n\u2148 \u2572\u2571 2 \u22c5\u2148\u22c5\u212f \u23a5\n\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u23a5\n 4 \u23a5\n \u23a5\n \u23bd\u23bd\u23bd \u23a5\n \u2572\u2571 2 \u22c5\u2148 \u23a5\n \u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u23a5\n 4 \u23a5\n \u23a5\n \u2148\u22c5\u03c0 \u23a5\n \u2500\u2500\u2500 \u23a5\n \u23bd\u23bd\u23bd 4 \u23a5\n \u2572\u2571 2 \u22c5\u212f \u23a5\n \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u23a5\n 4 \u23a6"
}
],
"collapsed": false,
"prompt_number": 6,
"input": "m"
},
{
"cell_type": "code",
"language": "python",
"outputs": [
{
"output_type": "pyout",
"latex": "$$\\left(\\begin{smallmatrix}1 & 1 & 1 & 1 & 1 & 1 & 1 & 1\\\\1 & \\omega & \\omega^{2} & \\omega^{3} & \\omega^{4} & \\omega^{5} & \\omega^{6} & \\omega^{7}\\\\1 & \\omega^{2} & \\omega^{4} & \\omega^{6} & 1 & \\omega^{2} & \\omega^{4} & \\omega^{6}\\\\1 & \\omega^{3} & \\omega^{6} & \\omega & \\omega^{4} & \\omega^{7} & \\omega^{2} & \\omega^{5}\\\\1 & \\omega^{4} & 1 & \\omega^{4} & 1 & \\omega^{4} & 1 & \\omega^{4}\\\\1 & \\omega^{5} & \\omega^{2} & \\omega^{7} & \\omega^{4} & \\omega & \\omega^{6} & \\omega^{3}\\\\1 & \\omega^{6} & \\omega^{4} & \\omega^{2} & 1 & \\omega^{6} & \\omega^{4} & \\omega^{2}\\\\1 & \\omega^{7} & \\omega^{6} & \\omega^{5} & \\omega^{4} & \\omega^{3} & \\omega^{2} & \\omega\\end{smallmatrix}\\right)$$",
"prompt_number": 7,
"text": "\u23a11 1 1 1 1 1 1 1 \u23a4\n\u23a2 \u23a5\n\u23a2 2 3 4 5 6 7\u23a5\n\u23a21 \u03c9 \u03c9 \u03c9 \u03c9 \u03c9 \u03c9 \u03c9 \u23a5\n\u23a2 \u23a5\n\u23a2 2 4 6 2 4 6\u23a5\n\u23a21 \u03c9 \u03c9 \u03c9 1 \u03c9 \u03c9 \u03c9 \u23a5\n\u23a2 \u23a5\n\u23a2 3 6 4 7 2 5\u23a5\n\u23a21 \u03c9 \u03c9 \u03c9 \u03c9 \u03c9 \u03c9 \u03c9 \u23a5\n\u23a2 \u23a5\n\u23a2 4 4 4 4\u23a5\n\u23a21 \u03c9 1 \u03c9 1 \u03c9 1 \u03c9 \u23a5\n\u23a2 \u23a5\n\u23a2 5 2 7 4 6 3\u23a5\n\u23a21 \u03c9 \u03c9 \u03c9 \u03c9 \u03c9 \u03c9 \u03c9 \u23a5\n\u23a2 \u23a5\n\u23a2 6 4 2 6 4 2\u23a5\n\u23a21 \u03c9 \u03c9 \u03c9 1 \u03c9 \u03c9 \u03c9 \u23a5\n\u23a2 \u23a5\n\u23a2 7 6 5 4 3 2 \u23a5\n\u23a31 \u03c9 \u03c9 \u03c9 \u03c9 \u03c9 \u03c9 \u03c9 \u23a6"
}
],
"collapsed": false,
"prompt_number": 7,
"input": "represent(Fourier(0,3), nqubits=3)*4/sqrt(2)\n"
},
{
"source": "<h2>QFT in Action</h2>",
"cell_type": "markdown"
},
{
"source": "Build a 3 qubit state to take the QFT of.",
"cell_type": "markdown"
},
{
"cell_type": "code",
"language": "python",
"outputs": [
{
"output_type": "pyout",
"latex": "$$\\frac{1}{2} \\left({\\left|000\\right\\rangle } + {\\left|010\\right\\rangle } + {\\left|100\\right\\rangle } + {\\left|110\\right\\rangle }\\right)$$",
"prompt_number": 8,
"png": "iVBORw0KGgoAAAANSUhEUgAAAP4AAAAiCAYAAAB/amQFAAAABHNCSVQICAgIfAhkiAAABR5JREFU\neJztnFtoHFUYx3/bJNamphoraRvFVq2YQgQt+iBKKyqiguLlIYJQQX3wQbG+FC8g61MplGoror3g\nBXzwpYhI9UG0iohaBUWrBkGFWm94b1Mqac368M24k3Eu58yeMzuZ/X6w7M6Z/358/z2ZmXMNKIqi\nZDAM9Hc7CUVRymE+sAb4BljR3VQURXHBPAPNBDAEnOU5F0VRKkgLfeIrSi0weeIrilIzev3CPx24\nuNtJlEQveQX1m0mfReAmsBX40zKhKANIgoeAG4HJ2Pn5wL3AzcAFwBTwc0IcV7op4G5gbyE3dsT9\nmnoAaAAbgQ+A6RRNlb2GuPBhqpsrfk11RfyeA/yRn342nfbx+xFzpwTHzdj5PuAj4KHgeBHwCbDO\ns+4eYIm5jcI0I59Ncwu1TyK//2kpsavsNcSlj7r4NdUV9bsRufgL0wgS62RkfzNwbuS4GTt/G/AX\n0ioIWQccYXbyrnWnAvcb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qEySS9A5i0wpznDK2fFaFXvIK9fC7BdknY80Q8BjSjAC5AbQwvxPGCffj1wXb5bVz\nmV7yCvXwu8JVoPXIZoGBPKGiKPVgDHgXae4ritIDjCL985OD417/X32KUnsWAw/Tbt6vBq7pXjqK\nonRK3nTeScjE/zTtHXejwBXI1j9FUeYgeQt4BpEFA1Fa6EWvKIqiKIqiKIqiKIqiKF3nX7rsUf7i\n3lIWAAAAAElFTkSuQmCC\n",
"text": "\u2758000\u27e9 + \u2758010\u27e9 + \u2758100\u27e9 + \u2758110\u27e9\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n 2"
}
],
"collapsed": false,
"prompt_number": 8,
"input": "state = (Qubit('000') + Qubit('010') + Qubit('100') + Qubit('110'))/sqrt(4); state\n"
},
{
"source": "Perform the QFT.",
"cell_type": "markdown"
},
{
"cell_type": "code",
"language": "python",
"outputs": [
{
"output_type": "pyout",
"latex": "$$\\frac{1}{2} \\sqrt{2} {\\left|000\\right\\rangle } + \\frac{1}{2} \\sqrt{2} {\\left|100\\right\\rangle }$$",
"prompt_number": 9,
"png": "iVBORw0KGgoAAAANSUhEUgAAANAAAAAkCAYAAAD4p7R7AAAABHNCSVQICAgIfAhkiAAABZBJREFU\neJzt3HuoZVUdwPHPHW/jndEcLa1rTtofaQY5QxSpo85cSwJj1ATFB8rIdKuxmogJ0nxOYY3+4SP6\nJ6lImIEoRhKNfCGoJCgOgoMjgX/I0EMlFYuRolFuf/zOxnP23edxz9mPc6/rC5vDXfu3915nf89e\ne63f2vuSSCQSiUQTTDRdgT7MlbCPcf+OS53j8LcS9rPoPZ6AqZqPuRsfqvmYS5nksGSWDRCzGpdj\nD6arrU4Hn8V+vFnjMZcqyWGDnIu1ojv1iRqPu0vc/hOjkxxWxOQAMQ9WXov5nIS38fcGjr0USQ7H\ngDpb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pnkj8B35dYRwxuTgM45bG\nzhjVIcN7bKfXBVSLxyYeJj2Ae/BDPKM4A9KNb4j+94T4cc3i67gZf+mz7R48LVr0jHX4KG6rMG4D\nnuhTt8XGKA4ZzWM7h7Q+i9LqY+PxGNHS7MCPdd7ShuVE8QzTQl71PVVkgrpli07JxW9oLe1Miz78\nTjEbv1f03/OUGfcjw7/PX9YdaFwcUo7HL4vEw3Otbd4VD3/+TDwNkVG5x35iJ0XW5bviS1/X2vFa\n0T8chY+J2+SgTOPkHuufEnXMyFqlgwWxK0QLs1/vf1xSRtwR4oc2DLNirDFKsmCcHFKOx2wcWMQ+\n85035nEN/uq9gdPRrR1/caE7SgzFZvG/DEYhOWyQKfFuR/ZY92px8tc1VqP3F2U8jZ0cjhHb8ajx\nfJM1MRjbJYeNcBoe1jlISywuksOGOBl3iJeyluGDzVYnMQTJYUMcL1J7WcbudHypueokhiA5rIh+\naewPi3fF2yeqjsRn8GpVlUqUSnJYIf0uoFXmT2zNiVx9YnGQHCYSiUQikUgkEolEohT+D0ZODNW4\nMHDVAAAAAElFTkSuQmCC\n",
"text": "\u23bd\u23bd\u23bd \u23bd\u23bd\u23bd \n\u2572\u2571 2 \u22c5\u2758000\u27e9 \u2572\u2571 2 \u22c5\u2758100\u27e9\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 + \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n 2 2"
}
],
"collapsed": false,
"prompt_number": 9,
"input": "qapply(fourier*state)\n"
}
]
}
]
}