Last active
November 19, 2020 05:13
-
-
Save splch/400ed9bcdcd8547a49adbbeea75b643c to your computer and use it in GitHub Desktop.
Circuit for Grover's Algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"/opt/conda/lib/python3.7/site-packages/qiskit/providers/ibmq/ibmqfactory.py:192: UserWarning: Timestamps in IBMQ backend properties, jobs, and job results are all now in local time instead of UTC.\n", | |
" warnings.warn('Timestamps in IBMQ backend properties, jobs, and job results '\n" | |
] | |
} | |
], | |
"source": [ | |
"%matplotlib inline\n", | |
"# Importing standard Qiskit libraries and configuring account\n", | |
"from qiskit import QuantumCircuit, execute, Aer, IBMQ\n", | |
"from qiskit.compiler import transpile, assemble\n", | |
"from qiskit.quantum_info import Operator\n", | |
"from qiskit.tools.jupyter import *\n", | |
"from qiskit.visualization import *\n", | |
"# Loading your IBM Q account(s)\n", | |
"provider = IBMQ.load_account()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def initialize_s(qc, qubits):\n", | |
" \"\"\"Apply a H-gate to 'qubits' in qc\"\"\"\n", | |
" for q in qubits:\n", | |
" qc.h(q)\n", | |
" return qc" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"n = 2\n", | |
"grover_circuit = QuantumCircuit(n)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAH0AAAB7CAYAAABZ2Y84AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliI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5J4//arff5cq/Az4/uvYX1fJx/t/2dzchM1mC1ubnp5GT08PpqamkJycDJfLFbPg8cow0S8uLuD3++F0OsPWCwoKsLq6qtOujMkw0dPS0nBzc6P3NuKCkl/I0cfF6AIxukCMLhCjC8ToAjG6QIb5Pl0vOc/i796Geu+dYoOPd4EYXSBGF4jRBWJ0gRhdIEYXiNEFYnSBGF0gRheI0QVidIH4o9UHcAq0QJwCTXGB0QVidIEYXSBGF4jRBWJ0gRhdIKWjG3EgsBEoHb2vrw+jo6MYGBjA0tISOjo64HA4sLe3p+xYMU6B/h84EPjjUfakRzoQeGRkBBaLBSaTCW63W4+tGo6S0aMZCNzU1ITl5WXU1tY+9TYNS8nHe6QDgYF3Q4AfI9LJyd+99OLz0rqorr3x+hV+W5wMW/v7rwvkfvFVVNfRtBX80FAf0cdG83uoSkb/cCBwS0tLaP3uQGBVqT4FWsnoTzEQONKToeeYULu9Du6x2P8muZL/pkc6EJgeR8mTDgAWiwVerzdsrbu7G2VlZTCbzTrtKj4YahJFaWkpbDYbZmdnQ2vDw8OYnZ3F6ekp0tLSYDaboWkaCgsLY3LPeJwCreTj/T7vBwLffVNmdHQUgUAAV1dXOD8/RyAQiFnweKXs4/0uDgSOHcOcdIodRheI0QVidIEYXSBGF4jRBTLM9+l64UBgigt8vAvE6AIxukCMLhCjC8ToAjG6QIwuEKMLxOgCMbpAjC4QowvE6AIxukCMLhCjC8ToAv0DANrDwCwYM0cAAAAASUVORK5CYII=\n", | |
"text/plain": [ | |
"<Figure size 146.652x144.48 with 1 Axes>" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"grover_circuit = initialize_s(grover_circuit, [0,1])\n", | |
"grover_circuit.draw()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAANgAAAB7CAYAAAAWqE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F/uesWZqayDGmKIUnJMmA6nQ56vR7l5eWIiIhATEwMTCYT6urqAMAnAfN0K5Jn35Du78EMhgyYyvy3Zcpo2JPDYMiAY5d8tpmR5RJRoVCgpqYGSUlJKC4uRkFBAbRaLdavXw+lUul8wEH+YbPbMDwyiJHLwwCA4ZFBDI8MevxDaiyT5QwGAAkJCWhoaHBpy8/Px5w5cxAaGipRVWPTX997EZWvFDi/Xrbpyv1/8ZenEBVxrURVBYaA2rZt9uzZSEtLQ1VVlbNt69atqKqqwrlz56DRaBAaGgqz2YzY2Fif9CnlEjE2EnjoNv/1NxqWiNy27Xvq6+uDxWL52hvMpaWlsFqtGBoaQk9PD6xWq8/CRXS1ZLtE/H8ajQY2m03qMoi8EjAzGFEgYsCIBGLAiARiwIgEYsCIBGLAiARiwIgECpj3waQSEz52+g6L9G9/IshtDAH1USmiQMMlIpFADBiRQAwYkUAMGJFADBiRQAwYkUAMGJFADBiRQAwYkUAMGJFADBiRQAwYkUAMGJFADBiRQAwYkUAMGJFADBiRQAwYkUD/AYP5q6xjfgHBAAAAAElFTkSuQmCC\n", | |
"text/plain": [ | |
"<Figure size 267.052x144.48 with 1 Axes>" | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"oracle = Operator([[1, 0, 0, 0],\n", | |
" [0, -1, 0, 0],\n", | |
" [0, 0, 1, 0],\n", | |
" [0, 0, 0, 1]])\n", | |
"grover_circuit.unitary(oracle, [0, 1], label='Paths')\n", | |
"grover_circuit.draw()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAY0AAAB7CAYAAACIG9xhAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAAL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bB/ATMV/jxGYOOsAAAAAElFTkSuQmCC\n", | |
"text/plain": [ | |
"<Figure size 507.852x144.48 with 1 Axes>" | |
] | |
}, | |
"execution_count": 6, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# Diffusion operator (U_s)\n", | |
"grover_circuit.h([0,1])\n", | |
"grover_circuit.z([0,1])\n", | |
"grover_circuit.cz(0,1)\n", | |
"grover_circuit.h([0,1])\n", | |
"grover_circuit.draw()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/latex": [ | |
"$\\displaystyle \n", | |
"$$ |\\psi\\rangle =\\begin{bmatrix}\n", | |
"0 \\\\\n", | |
"1 \\\\\n", | |
"0 \\\\\n", | |
"0\\end{bmatrix} $" | |
], | |
"text/plain": [ | |
"<IPython.core.display.Math object>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"sv_sim = Aer.get_backend('statevector_simulator')\n", | |
"job_sim = execute(grover_circuit, sv_sim)\n", | |
"statevec = job_sim.result().get_statevector()\n", | |
"from qiskit_textbook.tools import vector2latex\n", | |
"vector2latex(statevec, pretext=\"|\\\\psi\\\\rangle =\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAc0AAAE6CAYAAAB00gm8AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAAZQElEQVR4nO3df7RdZZ3f8fcXMgiY4JAwhNxcEGNY0klE0IMDeIHoMqVAFyJYgaJpSiUljkRk2Y4uhTEUf1RHBuqUcci0QtBOGXBG6xggDhrjgnDxJtMoYpN0gNSEmxsy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ZlvIzNuA28a7DqndRERfZtbGuw6pnY1laG4DXgKmDmqfCmwZZpstw4x/sT5f7MWckiTtlTE7p5mZu4DVwNxBXXOprngdyqphxvdl5gt7OackSXtlrH+evQm4MyIeAR6kujq2C/gyQEQsBcjMefXxXwY+FBE3A38GvA2YD1xWOqekYp62kEYxpqGZmXdFxBTgk8A04FHgvMzcWB9y3KDxT0TEecAfU91C8hSwKDO/3sSckgrUz/dLGkFk5njXIEnSK4Jrz0qSVMjQlCSpkKEpSVIhQ1OSpEKGpiRJhQxNqQNFxGHjXYP0SmRoSh0mIo4E1kXEn0bE2yIiGvoa358YEUeMS5FSmzI0pc7zPqr1md8CrAT+b0TcEBFvyPqN2xFxLPAXVE8+kVTn4gZSh4mIJVQPOrie6vF7lwHvAWYAPwT+OzAF+ERmThyvOqV21HGPBpM6WUS8CngMODwztwJbgR9FxOeAU4F/DXyKKkz/cLzqlNqVR5pSh6kH55GZuSUiDgYyM3/T0D8H+C5wXGZuGp8qpfbkOU2pg0REZOZO4PCImJqZL+0OzIaLgM4CnjQwpZfz51mpQ0TE0cD7I+Jaqp9lX4yIfuBu4K8y89f14NwCLBrHUqW25c+zUoeIiNuBWcC3gGeAycApwInAJuALmbl83AqUXgEMTakD1I8gf0n1rNmVDW3dwGnAlcBrgcsyc824FSq1Oc9pSp3hd4EngF27G7Lys8y8G/iXVKH6r8apPukVwdCUOsPjVOcx/zgiToiIf/JvPzN3AXcA545HcdIrhaEpdYDMfA74BHAYsBSYFxHHRsREgIg4HDgbeHT8qpTan+c0pQ4SEbOB64ALgF8Dq4CngXcC/cAHMvPH41eh1N4MTakD1W8/OR+4EHie6gjz7sz8P+NZl9TuDE2pw0XEQY0rAkkanqEpSVIhLwSSJKmQoSlJUiFDU5KkQoamJEmFDE1JkgoZmpIkFTI0JUkq9P8B4GHknFyXhkAAAAAASUVORK5CYII=\n", | |
"text/plain": [ | |
"<Figure size 504x360 with 1 Axes>" | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"grover_circuit.measure_all()\n", | |
"\n", | |
"qasm_simulator = Aer.get_backend('qasm_simulator')\n", | |
"shots = 1024\n", | |
"results = execute(grover_circuit, backend=qasm_simulator, shots=shots).result()\n", | |
"answer = results.get_counts()\n", | |
"plot_histogram(answer)" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.7.8" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment