diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/README.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/README.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_0-Hello_Quantum_World/README.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_0-Hello_Quantum_World/README.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_0-Hello_Quantum_World/latex/.ipynb_checkpoints/main-checkpoint.tex b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_0-Hello_Quantum_World/latex/.ipynb_checkpoints/main-checkpoint.tex deleted file mode 100755 index 51cf77a18..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_0-Hello_Quantum_World/latex/.ipynb_checkpoints/main-checkpoint.tex +++ /dev/null @@ -1,282 +0,0 @@ -\documentclass[aspectratio=43]{beamer} -\usepackage[utf8]{inputenc} - -%%%%%%%%%%%%%%%%%%%%%%%% THEME -\usetheme{material} -\useLightTheme -\usePrimaryTeal -\useAccentGreen - -\usepackage{macros} % must come after theme - -\title{Hello \qw} -\keywords{\qm,\qc} - -\begin{document} - -\begin{frame} - \titlepage -\end{frame} - - -\begin{frame}{Table of contents} - \begin{card} - \tableofcontents - \end{card} -\end{frame} - -\section{Motivation} -\begin{frame}{Motivation} -\begin{card}[Why] - \begin{chapquote}[2pt]{\href{https://en.wikipedia.org/wiki/Seth_Lloyd}{Seth Lloyd}} - ``Classical computation is like a solo voice - one line of pure tones succeeding each other. Quantum computation is like a symphony - many lines of tones interfering with one another.'' - \end{chapquote} -\end{card} - -\pagenumber -\end{frame} - -\begin{frame}{Motivation} -\begin{card}[How] - \qc can be seen as leveraging the phenomena that happen at the atomic and subatomic levels - in the \qw\xspace- to produce computations that, ultimately, surpass \cc. -\end{card} -\pagenumber -\end{frame} - -\begin{frame}{About this course} -\begin{card} - This course is suited for beginners in \qm and \qc. If you are already familiar with the concepts of a given week, you are encouraged to move forward in the course. - - This course brings novelty in that it focuses on \textbf{learning by doing}, and that is why you will also learn about \qk and \ibmqe. - - The author believes both that learning should be fun and that derision is a wonderful attention gripper, so humour will be used as the powerful tool that it is, wisely. -\end{card} -\pagenumber -\end{frame} - -\begin{frame}{About this course - Study plan} -\begin{card} - \begin{itemize} - \item \qm 101 - \item \qk and \ibmqe - \item \qi - \item Designing \qcts - \item \qa (Deutsch, Grover, Shor) - \item \qc applications - \item \q Computers - state of the art - \item Implications and ethical considerations throughout - \end{itemize} -\end{card} -\pagenumber -\end{frame} - -\section{Introduction} -\begin{frame}{Introduction} -\begin{card} - In this first week, we will start by defining what \qc is and how it compares to \cc. Next, a walk-through the novelty that \qm brings and how it compares to \cp. As a starting point to understanding how these quantum properties can be used to tackle problems algorithmically, we will introduce the concepts of \textbf{superposition} and \textbf{measurement}, that of \textbf{entanglement} will be introduced later, at a stage where it makes more sense and is easier to assimilate. -\end{card} -\pagenumber -\end{frame} - - -\section{\qp vs \cp} - -\begin{frame}{\cp} -\begin{card} - \cp (also \cm) describes the world \textit{as we see it}, in its macro level. Some of its properties: - \begin{description} - \item[size] objects with $size \gtrsim 1nm\ (10^{-9}m)$ - \item[speed] objects of $speed \lesssim \speedoflight$ - \end{description} -\end{card} -\pagenumber -\end{frame} - - -\begin{frame}{\qp} -\begin{card} - \qp (also \qm) describes the world \textit{as we see it}, in its macro level. Some of its properties: - \begin{description} - \item[size] objects with $size \lesssim 1nm$ - \item[speed] objects of $speed \lesssim \speedoflight$ - \end{description} -\end{card} -\pagenumber -\end{frame} - -\begin{frame}{The kingdoms of \cl and \qm} -\begin{card} - \centering\cardImg{classical_vs_quantum_dimensions.png}{\textwidth} -\end{card} -\pagenumber -\end{frame} - -\section{Principles of \qm} -\subsubsection{\qsp} -\begin{frame}{\qsp} - \begin{card} - A \q state (of a particle) can be seen as being composed by more than one different states, simultaneously. It is not in state A \textbf{or} B, it is in state A \textbf{and} state B, at the same time. This defies classical views of the world, where two things are never true at the same time and requires some mental effort!\\ - The state is, therefore, in a kind of superposition. - \end{card} -\pagenumber -\end{frame} - -\begin{frame}{\qsp - Schrödinger's cat} - \textbf{Thought experiment:} Imagine a cat locked inside a box, along with a poison releasing mechanism. The mechanism has a 50\% chance of having been activated at the time the box is about to be opened. At that moment, we cannot be sure of the cat's living state. Perhaps, we should assume the cat is both dead and alive, at the same time. With each state having the same probability. - \begin{center} - \cardImg{img/cat.png}{0.5\textwidth} - \end{center} - \begin{center} - To worlds, inside one. - \end{center} -\pagenumber -\end{frame} - - -\begin{frame}{\qsp} - \begin{cardTiny} - Formally, such states are represented using the \textbf{Ket notation} (as defined by \textit{Paul Dirac}). State 0 would be \ket{0}. - \end{cardTiny} - \begin{cardTiny} - \begin{multicols}{2} - Consider the electron of a Hydrogen atom, orbiting around the nucleus, with only two (simplification) possible energy states. As this is a \q particle, these energy states are quantized, that is, they take only discrete (quantified) values. - \begin{center} - \includegraphics[width=0.4\textwidth]{hydrogen} - \end{center} - \end{multicols} - \end{cardTiny} -\pagenumber -\end{frame} - -\begin{frame}{\qsp} - \begin{card} - When we have no evidence of the electron's state, we assume that it is in a superposition of both positions. This \qsp $\ket{\phi}$ is written as: - \begin{equation*} - \superpos - \end{equation*} - \end{card} - \begin{cardTiny} - $\alpha$ and $\beta$ represent how likely each of the two states is. These are complex numbers such that $|\alpha|^2 + |\beta|^2 = 1$. - \end{cardTiny} - \begin{cardTiny} - \small{ - So, why and how does \qsp actually work?\\ \textbf{We do not know!} (this statement pops up frequently in \q) However, some \href{https://arxiv.org/abs/1707.09483}{interesting experiments} might just be able to answer us soon enough... - } - \end{cardTiny} -\pagenumber -\end{frame} - -\begin{frame}{\qsp\space- Plane representation} - \begin{cardTiny} - \begin{multicols}{2} - Another important remark to make is that a superposition can be projected as unit vector onto a 2D plane (even though $\alpha$ and $\beta$ are complex numbers). In essence, this allows us to convert a superposition in the $\ket{0}\ket{1}$ basis, as is $\ket{\psi}$, onto other basis. Basis are orthonormal. - \begin{center} - \input{mathcha/superpos_projection.tex} - \end{center} - \end{multicols} - \end{cardTiny} -\pagenumber -\end{frame} - -\begin{frame}{\qsp\space- Vector representation} - \begin{cardTiny} - Moreover, a quantum state $\superpos$ can be seen as a unit vector in the complex bi-dimensional space ($\mathbb{C}^2$) \begin{bmatrix}$\alpha$ \\ $\beta$\end{bmatrix}, such that: - \begin{equation*} - \alpha \ket{0} + \beta \ket{1} = - \begin{bmatrix}$\alpha$ \\ $\beta$\end{bmatrix}^\intercal - \times - \begin{bmatrix}1 & 0\\ 0 & 1\end{bmatrix} - \end{equation*} - Given the following as the basis vectors (this is the zero-one basis): - \begin{equation*} - \ket{0} = \begin{bmatrix}1 \\ 0\end{bmatrix},\\ - \ket{1} = \begin{bmatrix}0 \\ 1\end{bmatrix} - \end{equation*} - \end{cardTiny} -\pagenumber -\end{frame} - -\begin{frame}{\qsp\space- Basis} - \begin{multicols}{2} - As a matter of fact, any linearly independent pair of unit vectors can act as basis. One well known basis is the $\ket{+}\ket{-}$ (plus-minus) basis: - \begin{equation*} - \ket{+} = \begin{bmatrix}\osqrt \\ \osqrt\end{bmatrix},\\ - \ket{-} = \begin{bmatrix}\osqrt \\ -\osqrt\end{bmatrix} - \end{equation*} - This is simply the $\ket{0}\ket{1}$ basis rotated by $\frac{\pi}{4}$($45º$). - \begin{center} - \input{mathcha/plus_minus.tex} - \end{center} - \end{multicols} -\pagenumber -\end{frame} - - - - -\subsubsection{\qmt} -\begin{frame}{\qmt} - \begin{cardTiny} - From a pragmatic perspective, what happens when we open the box and look at the cat? From that moment on, only one state remains, either death \textbf{or} life. And we cannot close the box again and expect a different outcome. - \end{cardTiny} - \begin{cardTiny} - \centering\textit{The cat is out of the box.} - \end{cardTiny} - \begin{cardTiny} - A \textbf{Measurement} causes the system to stabilise, in a non-reversible way. When we perform a measurement on the electron's state (let this process be a technicality, for now), we get $\ket{0}$ \textbf{or} $\ket{1}$. If we repeat the measurement, the result will be the same, \textbf{always}. - \end{cardTiny} -\pagenumber -\end{frame} - -\begin{frame}{\qmt} -\begin{cardTiny} -\small{ - To better understand what a measurement is, it is important to understand that it is \textbf{basis-specific}, meaning we could measure on the $\ket{0}\ket{1}$ or on the $\ket{+}\ket{-}$ basis (or another \href{http://mathworld.wolfram.com/LinearlyIndependent.html}{LI}). Example:\\ - You have a qubit in a superposition $\osqrt\alpha+\osqrt\beta$, you measure (zero-one basis) it into a bit and the result is 0 (horizontal). Now, if you convert it to the plus-minus basis you will get $\psi = \osqrt\ket{+} + \osqrt\ket{-}$.\\ - Imagine that the measurement had not happened and was instead performed on the plus-minus basis, the result would be $+$ (since $\ket{+}=\osqrt\ket{0}+\osqrt\ket{1}$). -} -\end{cardTiny} -\begin{cardTiny} - \small{You can now see the impact of choosing a given basis to perform a measurement. We will return to this later, the simple notion of this consideration is what you should absorb now.} -\end{cardTiny} -\pagenumber -\end{frame} - -\begin{frame}{\qmt} -\begin{cardTiny} -\small{ - Pragmatically speaking, \qmt requires a few considerations. Firstly, it produces a single output form a state that is stochastic, meaning that doing it once is not enough to be sure of the probability distribution. So, typically, each experiment is executed a large number of times (hundreds and sometimes thousands) so that the confidence in the results meets the expectations.\\ - Furthermore, as you will see when deploying to real quantum devices, current experimental setups are not perfect (and hardly ever will be) so even the simplest of programs may produce buggy results and a \q Scientist should be aware of it.\\As a matter of fact \href{https://quantumexperience.ng.bluemix.net/qx/editor}{\ibmqe}'s devices are usually well described even in the average error (noise) ratios you should expect. -} -\end{cardTiny} -\pagenumber -\end{frame} - -\section{Why \q?} -\begin{frame}{Why \q?} - To end this introductory week to the \qw, there are a few useful considerations to make: - \begin{itemize} - \item \qc is worth our time because it brings the promise of revolutionising the amount of computation within human reach, from tackling currently impossible problems to rendering most encryption standards useless. - \item \qc works because it allows for the massive parallelisation of computations hitherto unattainable with such ease in \cc, because humans are not defining this parallelism, Mother Nature is! That and the \qm at play (some yet to see) give it even more out-of-the-box characteristics adding to its enormous potential. - \end{itemize} -\pagenumber -\end{frame} - -\begin{frameImg}[width]{dilbert} - - -\end{frameImg} - -\section{Where to learn more?} -\begin{frame}{Where to learn more?} -\begin{card} - \begin{itemize} - \item \href{https://www.quantiki.org/wiki/introduction-quantum-theory}{Introduction to Quantum Theory, Quantiki} - \item \href{https://www.khanacademy.org/science/physics/quantum-physics/quantum-numbers-and-orbitals/a/the-quantum-mechanical-model-of-the-atom}{Khan Academy, The quantum mechanical model of the atom} - \item \href{https://www.goodreads.com/book/show/331680.Programming_the_Universe}{Programming the Universe: A Quantum Computer Scientist Takes on the Cosmos} - \item \href{https://www.goodreads.com/book/show/260142.The_Principles_of_Quantum_Mechanics}{The Principles of Quantum Mechanics, \textit{Paul Dirac}} - \end{itemize} -\end{card} -\end{frame} - -\end{document} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/.ipynb_checkpoints/README-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/.ipynb_checkpoints/README-checkpoint.ipynb deleted file mode 100755 index 0fbb6545c..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/.ipynb_checkpoints/README-checkpoint.ipynb +++ /dev/null @@ -1,56 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Week 1 - Quantum Tools\n", - "\n", - " * Python and Pip\n", - " * Jupyter\n", - " * Google Colaboratory\n", - " * Binder\n", - " * Qiskit (and its composing parts)\n", - " * Community and VSCode extension\n", - " * IBMQ and IBMQ Experience\n", - " \n", - "# Exercises\n", - " * Installing software\n", - " * Creating IBMQ account\n", - " * Local setup by running [this notebook](exercises/IBMQ_setup.ipynb) on your machine. (You can [clone](https://help.github.com/articles/cloning-a-repository/) or download this repo)\n", - " \n", - "## Resources\n", - " * [PDF slides](slides.pdf)\n", - " * [slides src](latex/main.tex) Latex files and image resources used in the presentation (useful for PR on slide typos and such)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/.ipynb_checkpoints/README-checkpoint.md b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/.ipynb_checkpoints/README-checkpoint.md deleted file mode 100755 index 74251cabe..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/.ipynb_checkpoints/README-checkpoint.md +++ /dev/null @@ -1,18 +0,0 @@ -# Week 1 - Quantum Tools - - * Python and Pip - * Jupyter - * Google Colaboratory - * Binder - * Qiskit (and its composing parts) - * Community and VSCode extension - * IBMQ and IBMQ Experience - -# Exercises - * Installing software - * Creating IBMQ account - * Local setup by running [this notebook](exercises/IBMQ_setup.ipynb) on your machine. (You can [clone](https://help.github.com/articles/cloning-a-repository/) or download this repo) - -## Resources - * [PDF slides](slides.pdf) - * [slides src](latex/) Latex files and image resources used in the presentation (useful for PR on slide typos and such) diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/.ipynb_checkpoints/slides-checkpoint.pdf b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/.ipynb_checkpoints/slides-checkpoint.pdf deleted file mode 100755 index bcddb6326..000000000 Binary files a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/.ipynb_checkpoints/slides-checkpoint.pdf and /dev/null differ diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/README.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/README.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/exercises/.ipynb_checkpoints/IBMQ_setup-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/exercises/.ipynb_checkpoints/IBMQ_setup-checkpoint.ipynb deleted file mode 100755 index 048be9731..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/exercises/.ipynb_checkpoints/IBMQ_setup-checkpoint.ipynb +++ /dev/null @@ -1,192 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# IBM Q setup\n", - "This tutorial will walk you through the configuration for your IBM Q Experience account so that, in the future, you are able to run your Quantum Programs in both online simulators as well as real Quantum Computers.\n", - "\n", - "We assume you have installed Qiskit if not please look at [qiskit.org](http://www.qiskit.org) or the install [documentation](https://github.com/qiskit/qiskit-tutorial/blob/master/INSTALL.md). \n", - "\n", - "To test this run the following commands" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import qiskit" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Execute on a Real Device (IBM Q Experience)\n", - "\n", - "You can use Qiskit to run your circuits on real quantum computers using the IBMQ provider. They are small and noisy but are advancing at a fast pace. In the future, more information will be given regarding this environment, but for now lets go ahead and set it up!\n", - "\n", - "To access IBMQ devices, you'll need an API token. For the public Quantum Experience devices, you can generate an API token [here](https://quantumexperience.ng.bluemix.net/qx/account/advanced) (create an account if you don't already have one). For Q Network devices, login to the q-console, click your hub, group, and project, and expand \"Get Access\" to generate your API token and access url." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "from qiskit import IBMQ # requires qiskit version >= 0.6" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "After generating your API token, call:" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "IBMQ.save_account(\"MY_TOKEN\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "For Q Network users, you'll also need to include your access url:\n", - "\n", - "`IBMQ.save_account('MY_TOKEN', 'URL')`\n", - "\n", - "This will store your IBMQ credentials in a local file. Unless your registration information has changed, you only need to do this once. \n", - "\n", - "You may now (or in any other exercise) load your accounts by calling:" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "IBMQ.load_accounts()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Which Backends are available right now?\n", - "A backend is either an online Quantum simulator or a Quantum Computer.\n", - "\n", - "This is how you can list them by name:" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "ibmqx4\n", - "ibmqx5\n", - "ibmqx2\n", - "ibmq_16_melbourne\n", - "ibmq_qasm_simulator\n" - ] - } - ], - "source": [ - "for backend in IBMQ.backends():\n", - " print(backend)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Additionally, you can get all of their configurations, like so:" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'local': False, 'name': 'ibmqx4', 'version': '1.2.0', 'description': '5 qubit transmon bowtie chip 3', 'gate_set': 'SU2+CNOT', 'basis_gates': 'u1,u2,u3,cx,id', 'online_date': '2017-09-18T00:00:00.000Z', 'chip_name': 'Raven', 'deleted': False, 'url': 'https://ibm.biz/qiskit-ibmqx4', 'internal_id': '5ae875670f020500393162b3', 'simulator': False, 'allow_q_object': False, 'n_qubits': 5, 'coupling_map': [[1, 0], [2, 0], [2, 1], [3, 2], [3, 4], [4, 2]]}\n" - ] - } - ], - "source": [ - "backend_0 = IBMQ.backends()[0] # retrieve the Backend at index 0\n", - "print(backend_0.configuration())" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Go check its specification at https://ibm.biz/qiskit-ibmqx4\n" - ] - } - ], - "source": [ - "print(\"Go check its specification at %s\" % backend_0.configuration()[\"url\"])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "That's it for this week, if you have reached this point your local machine is now ready for the next steps 💪" - ] - } - ], - "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.6.4" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/exercises/.ipynb_checkpoints/README-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/exercises/.ipynb_checkpoints/README-checkpoint.ipynb deleted file mode 100755 index f6524f95a..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/exercises/.ipynb_checkpoints/README-checkpoint.ipynb +++ /dev/null @@ -1,49 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Overview\n", - "\n", - "For this week, there are some boring tasks:\n", - " * Install Python (and pip)\n", - " * Install Jupyter\n", - " * Install QSKit\n", - " * Create an account on IBM Q Experience\n", - " \n", - "As well as some interesting tasks:\n", - " * Checkout the community for QSKit\n", - " * Follow this week's Jupyter Notebook (local setup of IBM Q account)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/exercises/IBMQ_setup.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/exercises/IBMQ_setup.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/exercises/README.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_1-Quantum_Tools/exercises/README.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_2-Quantum_Information_Science/.ipynb_checkpoints/README-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_2-Quantum_Information_Science/.ipynb_checkpoints/README-checkpoint.ipynb deleted file mode 100755 index 77cc398ad..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_2-Quantum_Information_Science/.ipynb_checkpoints/README-checkpoint.ipynb +++ /dev/null @@ -1,54 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Week 2 - Quantum Information Science\n", - "\n", - " * Quantum Information Science\n", - " * Classical bits/egisters\n", - " * Quantum bits/registers\n", - " * Hands-on on Qskit\n", - " * Visualizing circuits\n", - " * Qasm language\n", - " \n", - "# Exercises\n", - " * [QSKit basics and circuit visualization](exercises/w2_01.ipynb)\n", - " * Run a Qasm specification on IBM Q Experience, and on a Real Processor (see slides for instructions)\n", - " \n", - "## Resources\n", - " * [PDF slides](slides.pdf)\n", - " * [slides src](latex/main.tex) Latex files and image resources used in the presentation (useful for PR on slide typos and such)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_2-Quantum_Information_Science/.ipynb_checkpoints/README-checkpoint.md b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_2-Quantum_Information_Science/.ipynb_checkpoints/README-checkpoint.md deleted file mode 100755 index 83057c0cc..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_2-Quantum_Information_Science/.ipynb_checkpoints/README-checkpoint.md +++ /dev/null @@ -1,16 +0,0 @@ -# Week 2 - Quantum Information Science - - * Quantum Information Science - * Classical bits/egisters - * Quantum bits/registers - * Hands-on on Qskit - * Visualizing circuits - * Qasm language - -# Exercises - * [QSKit basics and circuit visualization](exercises/w2_01.ipynb) - * Run a Qasm specification on IBM Q Experience, and on a Real Processor (see slides for instructions) - -## Resources - * [PDF slides](slides.pdf) - * [slides src](latex/) Latex files and image resources used in the presentation (useful for PR on slide typos and such) diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_2-Quantum_Information_Science/README.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_2-Quantum_Information_Science/README.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_2-Quantum_Information_Science/exercises/.ipynb_checkpoints/README-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_2-Quantum_Information_Science/exercises/.ipynb_checkpoints/README-checkpoint.ipynb deleted file mode 100755 index 0a8d7d45b..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_2-Quantum_Information_Science/exercises/.ipynb_checkpoints/README-checkpoint.ipynb +++ /dev/null @@ -1,41 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Exercises\n", - " * [QSKit basics and circuit visualization](w2_01.ipynb)\n", - " * Run a Qasm specification on IBM Q Experience, and on a Real Processor (see slides for instructions)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_2-Quantum_Information_Science/exercises/.ipynb_checkpoints/w2_01-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_2-Quantum_Information_Science/exercises/.ipynb_checkpoints/w2_01-checkpoint.ipynb deleted file mode 100755 index e6d3486ea..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_2-Quantum_Information_Science/exercises/.ipynb_checkpoints/w2_01-checkpoint.ipynb +++ /dev/null @@ -1,216 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Classical and Quantum Registers in Qiskit" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "from qiskit import ClassicalRegister\n", - "# Create a Classical Register with 2 bits.\n", - "c = ClassicalRegister(2)" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "from qiskit import QuantumRegister\n", - "# Create a Quantum Register with 2 qubits.\n", - "q = QuantumRegister(2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Quantum Circuits in Qiskit" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "from qiskit import QuantumCircuit\n", - "# Create a Quantum Circuit\n", - "qc = QuantumCircuit(q, c)\n", - "# perform a measurement of our qubits into our bits\n", - "qc.measure(q, c); # ; hides the output" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Visualization\n", - "There are two options:\n", - " * [matplotlib](https://matplotlib.org/) which is a python module (`pip install matplotlib`)\n", - " * LaTeX visualization, which requires some more configuration, check the [official instructions](https://github.com/Qiskit/qiskit-tutorial/blob/master/INSTALL.md#5-visualizing-circuits-with-latex) for configuration. This was an old feature and is therefore less important to us." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Matplotlib" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "# Jupyter command to activate matplotlib and allow the preview of our circuit\n", - "%matplotlib inline" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPgAAADYCAYAAADGfS49AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAFNpJREFUeJzt3X9M03f+B/BnASnIr2JR+U4tFYxTUdaKP5iKiHPXGfmx4bF8kwNjFoOJWzamIyXOZN6d7IpnjHM37+RuJ56G5GbcCcZ9UbdMcnOXXk5WjbtkRvklN6eAQHcw9Arv7x+GHr8Grbaftm+ej6TJx8/n/enrVfDJ+/OjUJUQQoCIpBTk6waIyHsYcCKJMeBEEmPAiSTGgBNJjAEnkhgDTiQxBpxIYgw4kcQYcCKJMeBEEmPAiSTGgBNJjAEnkhgDTiQxBpxIYgw4kcQYcCKJMeBEEmPAiSTGgBNJjAEnkhgDTiQxBpxIYgw4kcQYcCKJMeBEEmPAiSTGgBNJLMTXDRA9qeLiYthsNsXrGgwGHDp0SPG67uAMTgHPZrMpHnBf1HwcnMFJCg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ASDRXQASei8fn8jS5E5D0MOJHEGHAiiTHgRBJjwIkkxoATSYwBJ5IYA04kMQacSGIMOJHEGHAiiTHgRBJjwIkkxoATSYwBJ5IYA04kMQacSGIMOJHEGHAiiTHgRBJjwIkkxoATSYwBJ5IYA04kMQacSGIMOJHEGHAiif0/7fvNqZqR5kkAAAAASUVORK5CYII=\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "from qiskit.tools.visualization import matplotlib_circuit_drawer as draw\n", - "draw(qc) # visualize quantum circuit" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAUYAAAEcCAIAAAA0oIo2AAAtQklEQVR4nO3de1wTV/o/8CfhFgIUUFhQqQUFhQUvoLW22i8XrSy2iqgRdQWL1S6ulW6tVtHXirdaUJeyLbiU77dg1eIFxNLF6gvrHddWq+IFtNyvgqIIEiWkufz+OP3NRkgwmUyYZHjefw2TmZPnKJ+ZZObMgadUKgEhE7F06dKvv/6a7SpoOnv2bGBgoKHfxdzQb4AQgzw9PXk83qFDh9guRDelpaWbNm2ytbXtg/fCSCNTYmFhAQAikYjtQnRz7ty5Pnsvfp+9E0KoD2CkEeKU/hhpmUwmlUoZaaqrq4uRdhBiSn+M9PLlyxcvXsxIU+7u7rt372akKWSKbt261dTUxHYVz+mPkW5ubm5ubmakqYCAgC+//JKRppDJefjw4f/8z/+kpqayXchzmIm0XC6vqKg4ffp0SUmJQqFgpE12admjmJiYu3fv/vTTT31ZGzISmzdvlkgk77//PtuFPEffSCsUipSUlKFDh3p5eU2ZMsXPz8/Dw8OkT1w69WjmzJkDBw7MzMzs4yIR6yorKzMyMlatWvXKK6+wXcvzlHqQSCSzZ8+mmhIKhdSySCSSy+X6NG4477zzTlBQkNqXaPQoLi7upZdeevr0qYGrRkqlUrlr1y4ej8d2FUqlUjlr1ixnZ+e2tjZtNj579iwA/PLLL4auSq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Nbt68mZaW1m1ldHQ0AEgkkm7PHgPA1q1byUe+mJgYBuvUnynWjPoLZmdU2LNnD2l20KBBhw8fbmlpefbsWXl5+bfffjtr1iw+n//BBx/03Is8xcHj8TIyMqiVqamp5JN8eHi4prdbt24dAKSkpNAuWCQSubm5ubm5kXuA2qNdM0IGxXCkFQrFn/70J02HD3t7e2riG1UNDQ3UXAIBAQFz586lvoW6u7s3NTVpejv9Ix0UFETeqKKiQqcdadeMkEExP/dYV1dXQkKCo6Ojapi9vb137tzZ3t6uaa+mpqaQkJBuh4DQ0ND79+/38l4sRpp2zQgZlKHuT/z222/kNrW9vb27u7uWD0Vcv369sLCwpaXFzc0tJCSEul2kSXx8fGJiYkpKSl8OCO1G15oRMihDPS9tYWEREBCg617+/v7+/v6GqMdwTLFmxGHsTyeIEGIQRhohTjGuP3OnpR9++IGM0Lp06RIA/PjjjxKJBAAmTpxIJtxFqN8yyeG7MTEx1A1wVevWrfvss8/6vByEjMj/A/XksKLo/fagAAAAAElFTkSuQmCC\n", - "text/plain": [ - "" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# Try both and use the one you like best\n", - "from qiskit.tools.visualization import circuit_drawer as draw2\n", - "draw2(qc) # visualize quantum circuit" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ - "# if you want to save it to a file\n", - "from qiskit.tools.visualization import circuit_drawer\n", - "diagram = circuit_drawer(qc, filename=\"my_first_quantum_circuit.png\")" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [], - "source": [ - "diagram.show() # or even open it on an external program (no need to save first)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Open Quantum Assembly Language (QASM)\n", - "To learn more about this standard, check [the original paper](https://arxiv.org/abs/1707.03429), the [github repo](https://github.com/Qiskit/openqasm), the [language documentation](https://github.com/Qiskit/openqasm/blob/master/spec/qasm2.rst) and the [wikipedia entry](https://en.wikipedia.org/wiki/OpenQASM)." - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "OPENQASM 2.0;\n", - "include \"qelib1.inc\";\n", - "qreg q0[2];\n", - "creg c0[2];\n", - "measure q0[0] -> c0[0];\n", - "measure q0[1] -> c0[1];\n", - "\n" - ] - } - ], - "source": [ - "# get the QASM representation of our circuit\n", - "print(qc.qasm())" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Suggested exercises\n", - "\n", - "* Change the number of bits in the classical register to a negative number.\n", - "\n", - "`That is your first QiskitError error and they are usually easy to interpret.`\n", - "* Change the number of bits in the quantum register to a positive number not equal to 2 (5 for example) and run the blocks until you get an error, try to understand it.\n", - "\n", - "`This is because you cannot read 5 qubits into 2 bits without losing information!`\n", - "* Now, update the number of bits accordingly and visualize your circuit.\n", - "\n", - "`Guarantee that the changes in the circuit diagram make sense`\n", - "* You can keep on trying to tweek with some settings, for instance, you can *name* your registers, like `c = ClassicalRegister(2, name=\"class\")` and this will reflect in the diagram.\n", - "* Checkout more [configuration options](https://github.com/Qiskit/qiskit-tutorial/blob/master/qiskit/basics/circuit_drawing.ipynb#Visualize%20Circuit) for the layout of your diagrams" - ] - } - ], - "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.6.4" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_2-Quantum_Information_Science/exercises/README.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_2-Quantum_Information_Science/exercises/README.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_2-Quantum_Information_Science/exercises/w2_01.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_2-Quantum_Information_Science/exercises/w2_01.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_3-Quantum_Gates/.ipynb_checkpoints/README-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_3-Quantum_Gates/.ipynb_checkpoints/README-checkpoint.ipynb deleted file mode 100755 index 34988414e..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_3-Quantum_Gates/.ipynb_checkpoints/README-checkpoint.ipynb +++ /dev/null @@ -1,56 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Week 3 - Quantum Gates\n", - "\n", - " * Algebra reminders: Conjugate Transpose, Hermitian, Unitary operators\n", - " * Quantum Gates\n", - " * one qubit gates: Hadamard, Pauli gates (X, Y, Z)\n", - " * \\>1 qubit gates: Controlled gates, CNOT\n", - " * Preview of other gates\n", - " * Qiskit examples\n", - " * Circuit representation of gates\n", - "\n", - "# Exercises\n", - " * Pen and paper exercises for testing unitary transformations [slides](slides.pdf)\n", - " * [Jupyter notebook with exercises](exercises/w3_01.ipynb): implementing gates, visualizing, executing locally and in remote machines, implement some simple circuits, discussion on practical setups\n", - " * [Jupyter notebook with solutions](exercises/w3_01_s.ipynb)\n", - "\n", - "## Resources\n", - " * [PDF slides](slides.pdf)\n", - " * [slides src](latex/main.tex) Latex files and image resources used in the presentation (useful for PR on slide typos and such)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_3-Quantum_Gates/.ipynb_checkpoints/README-checkpoint.md b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_3-Quantum_Gates/.ipynb_checkpoints/README-checkpoint.md deleted file mode 100755 index c7d9d48e9..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_3-Quantum_Gates/.ipynb_checkpoints/README-checkpoint.md +++ /dev/null @@ -1,18 +0,0 @@ -# Week 3 - Quantum Gates - - * Algebra reminders: Conjugate Transpose, Hermitian, Unitary operators - * Quantum Gates - * one qubit gates: Hadamard, Pauli gates (X, Y, Z) - * \>1 qubit gates: Controlled gates, CNOT - * Preview of other gates - * Qiskit examples - * Circuit representation of gates - -# Exercises - * Pen and paper exercises for testing unitary transformations [slides](slides.pdf) - * [Jupyter notebook with exercises](exercises/w3_01.ipynb): implementing gates, visualizing, executing locally and in remote machines, implement some simple circuits, discussion on practical setups - * [Jupyter notebook with solutions](exercises/w3_01_s.ipynb) - -## Resources - * [PDF slides](slides.pdf) - * [slides src](latex/) Latex files and image resources used in the presentation (useful for PR on slide typos and such) diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_3-Quantum_Gates/README.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_3-Quantum_Gates/README.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_3-Quantum_Gates/exercises/.ipynb_checkpoints/README-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_3-Quantum_Gates/exercises/.ipynb_checkpoints/README-checkpoint.ipynb deleted file mode 100755 index 0e046deef..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_3-Quantum_Gates/exercises/.ipynb_checkpoints/README-checkpoint.ipynb +++ /dev/null @@ -1,42 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Exercises\n", - " * Pen and paper exercises for testing unitary transformations [slides](../slides.pdf)\n", - " * [Jupyter notebook with exercises](w3_01.ipynb): implementing gates, visualizing, executing locally and in remote machines, implement some simple circuits, discussion on practical setups\n", - " * [Jupyter notebook with solutions](w3_01_s.ipynb)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_3-Quantum_Gates/exercises/README.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_3-Quantum_Gates/exercises/README.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_3-Quantum_Gates/exercises/w3_01.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_3-Quantum_Gates/exercises/w3_01.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_3-Quantum_Gates/exercises/w3_01_s.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_3-Quantum_Gates/exercises/w3_01_s.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/.ipynb_checkpoints/README-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/.ipynb_checkpoints/README-checkpoint.ipynb deleted file mode 100755 index 65826ab36..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/.ipynb_checkpoints/README-checkpoint.ipynb +++ /dev/null @@ -1,55 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Week 4 - Quantum Facts\n", - "\n", - " * Universal Classical Gates\n", - " * Universal Quantum Gates\n", - " * How unitary transformations allow for cyclic basis conversion\n", - " * Entanglement\n", - " * Big O Notation\n", - " * BQP\n", - "\n", - "# Exercises\n", - " * Pen and paper exercises for basis conversion using single qubit gates [slides](slides.pdf)\n", - " * [Jupyter notebook with exercises](exercises/w4_01.ipynb): implementing and understanding entanglement, observing entanglement in lab settings\n", - " * [Jupyter notebook with solutions](exercises/w4_01_s.ipynb)\n", - "\n", - "## Resources\n", - " * [PDF slides](slides.pdf)\n", - " * [slides src](latex/main.tex) Latex files and image resources used in the presentation (useful for PR on slide typos and such)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/.ipynb_checkpoints/README-checkpoint.md b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/.ipynb_checkpoints/README-checkpoint.md deleted file mode 100755 index a4a1b7646..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/.ipynb_checkpoints/README-checkpoint.md +++ /dev/null @@ -1,17 +0,0 @@ -# Week 4 - Quantum Facts - - * Universal Classical Gates - * Universal Quantum Gates - * How unitary transformations allow for cyclic basis conversion - * Entanglement - * Big O Notation - * BQP - -# Exercises - * Pen and paper exercises for basis conversion using single qubit gates [slides](slides.pdf) - * [Jupyter notebook with exercises](exercises/w4_01.ipynb): implementing and understanding entanglement, observing entanglement in lab settings - * [Jupyter notebook with solutions](exercises/w4_01_s.ipynb) - -## Resources - * [PDF slides](slides.pdf) - * [slides src](latex/) Latex files and image resources used in the presentation (useful for PR on slide typos and such) diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/README.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/README.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/exercises/.ipynb_checkpoints/README-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/exercises/.ipynb_checkpoints/README-checkpoint.ipynb deleted file mode 100755 index f3fad80cd..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/exercises/.ipynb_checkpoints/README-checkpoint.ipynb +++ /dev/null @@ -1,42 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Exercises\n", - " * Pen and paper exercises for basis conversion using single qubit gates [../slides](slides.pdf)\n", - " * [Jupyter notebook with exercises](w4_01.ipynb): implementing and understanding entanglement, observing entanglement in lab settings\n", - " * [Jupyter notebook with solutions](w4_01_s.ipynb)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/exercises/.ipynb_checkpoints/w4_01_s-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/exercises/.ipynb_checkpoints/w4_01_s-checkpoint.ipynb deleted file mode 100755 index 3b56ddfa9..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/exercises/.ipynb_checkpoints/w4_01_s-checkpoint.ipynb +++ /dev/null @@ -1,789 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Quantum Facts in Qiskit\n", - "Here some useful topics will be covered and others recalled to make you more familiar with quantum terms and concepts.\n", - "\n", - "Start by some typical setup and definition of useful functions, which you are encouraged to look at.\n", - "\n", - "Then, head to the [exercises start](#Exercises-Start-Here) to start coding!" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister\n", - "from qiskit import execute" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "# Choose the drawer you like best:\n", - "from qiskit.tools.visualization import matplotlib_circuit_drawer as draw\n", - "#from qiskit.tools.visualization import circuit_drawer as draw" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "from qiskit import IBMQ\n", - "IBMQ.load_accounts() # make sure you have setup your token locally to use this" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "%matplotlib inline" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Utils for visualizing experimental results" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "import matplotlib.pyplot as plt\n", - "\n", - "def show_results(D):\n", - " # D is a dictionary with classical bits as keys and count as value\n", - " # example: D = {'000': 497, '001': 527}\n", - " plt.bar(range(len(D)), list(D.values()), align='center')\n", - " plt.xticks(range(len(D)), list(D.keys()))\n", - " plt.show()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Utils for executing circuits" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Aer backends: [, , , , , ]\n" - ] - } - ], - "source": [ - "from qiskit import Aer\n", - "# See a list of available local simulators\n", - "print(\"Aer backends: \", Aer.backends())" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "IBMQ Backends: [, , , , ]\n" - ] - } - ], - "source": [ - "# see a list of available remote backends (these are freely given by IBM)\n", - "print(\"IBMQ Backends: \", IBMQ.backends())" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Execute locally" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [], - "source": [ - "# execute circuit and either display a histogram of the results\n", - "def execute_locally(qc, draw_circuit=False):\n", - " # Compile and run the Quantum circuit on a simulator backend\n", - " backend_sim = Aer.get_backend('qasm_simulator')\n", - " job_sim = execute(qc, backend_sim)\n", - " result_sim = job_sim.result()\n", - " result_counts = result_sim.get_counts(qc)\n", - " \n", - " # Print the results\n", - " print(\"simulation: \", result_sim, result_counts)\n", - " \n", - " if draw_circuit: # draw the circuit\n", - " draw(qc)\n", - " else: # or show the results\n", - " show_results(result_counts)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Execute remotely" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [], - "source": [ - "from qiskit.backends.ibmq import least_busy\n", - "import time\n", - "# Compile and run on a real device backend\n", - "def execute_remotely(qc, draw_circuit=False):\n", - " if draw_circuit: # draw the circuit\n", - " draw(qc)\n", - " try:\n", - " # select least busy available device and execute.\n", - " least_busy_device = least_busy(IBMQ.backends(simulator=False))\n", - " print(\"Running on current least busy device: \", least_busy_device)\n", - "\n", - " # running the job\n", - " job_exp = execute(qc, backend=least_busy_device, shots=1024, max_credits=10)\n", - "\n", - " lapse, interval = 0, 10\n", - " while job_exp.status().name != 'DONE':\n", - " print('Status @ {} seconds'.format(interval * lapse))\n", - " print(job_exp.status())\n", - " time.sleep(interval)\n", - " lapse += 1\n", - " print(job_exp.status())\n", - " exp_result = job_exp.result()\n", - " result_counts = exp_result.get_counts(qc)\n", - "\n", - " # Show the results\n", - " print(\"experiment: \", exp_result, result_counts)\n", - " if not draw_circuit: # show the results\n", - " show_results(result_counts)\n", - " except:\n", - " print(\"All devices are currently unavailable.\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Building the circuit" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [], - "source": [ - "def new_circuit(size):\n", - " # Create a Quantum Register with size qubits\n", - " qr = QuantumRegister(size)\n", - "\n", - " # Create a Classical Register with size bits\n", - " cr = ClassicalRegister(size)\n", - "\n", - " # Create a Quantum Circuit acting on the qr and cr register\n", - " return qr, cr, QuantumCircuit(qr, cr)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "

Exercises Start Here

\n", - "\n", - "Make sure you ran all the above cells in order, as the following exercises use functions defined and imported above." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Creating Entanglement\n", - "Although, you have already entangled qubits on the previous week, you were not aware of it.\n", - "\n", - "Naturally, we will redo some of those tasks and focus on interpreting their results." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Hadamard + CNOT\n", - "\n", - "**TASK:** Create a new circuit with 2 qubits using `new_circuit` (very useful to reconstruct your circuit in Jupyter)" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [], - "source": [ - "qr, cr, circuit = new_circuit(2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**TASK:** Add a Hadamard on qubit 0" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [], - "source": [ - "# H gate on qubit 0\n", - "circuit.h(qr[0]);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**TASK:** Add a CX (CNOT) gate on control qubit 0 and target qubit 1" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [], - "source": [ - "circuit.cx(qr[0], qr[1]);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**TASK:** Perform a measurement" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [], - "source": [ - "# measure the qubits\n", - "circuit.measure(qr, cr);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**TASK:** check the result using `execute_locally` test both `True` and `False` for the `draw_circuit` option" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "simulation: COMPLETED {'00': 504, '11': 520}\n" - ] - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAVMAAADYCAYAAABWSwDbAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAGvZJREFUeJzt3XlQlPf9B/A3gqCBXRZBxZ8ICK05UATBMzHrlaxGxGto7HhiDWmMidSjS4yjxKBdbOvV6kzQKk6sf0i0QdTBjI0Sa3SHiEiwbVLD7RGOAOsRkeP7+yN1C4Kwq9/dh8X3a2ZnNs9+n+fzwX145zm+uzgJIQSIiOiJdFO6ASKiroBhSkQkAcOUiEgChikRkQQMUyIiCRimREQSMEyJiCRgmBIRScAwJSKSgGFKRCQBw5SISAKGKRGRBAxTIiIJGKZERBIwTImIJGCYEhFJwDAlIpKAYUpEJAHDlIhIAoYpEZEEDFMiIgkYpkREEjBMiYgkYJgSEUnAMCUikoBhSkQkAcOUiEgChikRkQQMUyIiCVyUboA6j/j4eOTm5ipSOywsDNu2bVOkNllOqX3EEfYPHpmSWW5uriK/KErVJesp8V45yv7BI1NqISwsDGfOnLFrzXHjxtm1Hj0Ze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IL/B85AA0CCfCXNAAAAAElFTkSuQmCC\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "# Try both commands:\n", - "execute_locally(circuit,draw_circuit=True)\n", - "# execute_locally(circuit,draw_circuit=False)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The result should be something like `COMPLETED {'00': 506, '11': 518}`.\n", - "\n", - "**TASK:** What does this mean?" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "> Given two qubits, we could end up with the measurements `00`, `01`, `10` and `11` (4 possibilities)\n", - "> \n", - "> However, we got only `00` and `11` (2 cases)! This is due to the fact that our qubits are **entangled**!\n", - ">\n", - "> The state of qubit 1 is correlated to that of qubit 0 (control bit). Correlation means the implication is true in both directions.\n", - ">\n", - "> By making them entangled, we have ensured that `00` and `11` are the only possible states: if qubit 0 measures to 1 the other qubit, according to our circuit, could never have been 0, as it will be flipped from a starting state of 0.\n", - ">\n", - "> Furthermore, we could apply the gates, take both qubits elsewhere (apart from each other) without destroying any superposition, perform the measurements and the result would not change... curious, right?\n", - ">\n", - "> This particular disposition of entangled qubits describes what is known as a [Bell state](https://en.wikipedia.org/wiki/Bell_state). " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Bell state in IBMQ\n", - "**TASK:** Get the QASM specification for your code and use it on [IBMQ QASM editor](https://quantumexperience.ng.bluemix.net/qx/qasm)" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "OPENQASM 2.0;\n", - "include \"qelib1.inc\";\n", - "qreg q0[2];\n", - "creg c0[2];\n", - "h q0[0];\n", - "cx q0[0],q0[1];\n", - "measure q0[0] -> c0[0];\n", - "measure q0[1] -> c0[1];\n", - "\n" - ] - } - ], - "source": [ - "print(circuit.qasm())" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "> You will probably get an error for trying to execute this QASM, like:\n", - ">\n", - "> `Error in line 6: CX gate between q2[0], q2[1] is not allowed in this topology`\n", - ">\n", - "> To sort it, simply apply the Hadamard to `q2[1]` and change the CNOT to `cx q2[1] q2[0]`:\n", - "```qasm\n", - "OPENQASM 2.0;\n", - "include \"qelib1.inc\";\n", - "qreg q2[2];\n", - "creg c2[2];\n", - "h q2[1];\n", - "cx q2[1],q2[0];\n", - "measure q2[0] -> c2[0];\n", - "measure q2[1] -> c2[1];\n", - "```\n", - "> This is exactly the same circuit, but the norm seems to prefer this orientation rather than our original one (With the control qubit on the CNOT underneath the target qubit)." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "### More entanglement\n", - "**TASK:** Repeat the previous circuit, but add a bit-flip on the target qubit" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [], - "source": [ - "# create the circuit\n", - "qr, cr, circuit = new_circuit(2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**TASK:** Add a Hadamard on qubit 0" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [], - "source": [ - "# H gate on qubit 0\n", - "circuit.h(qr[0]);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**TASK:** Add an X gate on qubit 1" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [], - "source": [ - "# X gate on qubit 1\n", - "circuit.x(qr[1]);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**TASK:** Add a CX (CNOT) gate on control qubit 0 and target qubit 1" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [], - "source": [ - "circuit.cx(qr[0], qr[1]);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**TASK:** Perform a measurement" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [], - "source": [ - "# measure the qubits\n", - "circuit.measure(qr, cr);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**TASK:** check the result using `execute_locally` test both `True` and `False` for the `draw_circuit` option" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "simulation: COMPLETED {'01': 513, '10': 511}\n" - ] - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAVMAAADYCAYAAABWSwDbAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAHRJJREFUeJzt3X9UU/f9P/AngkQKCYloxa8KiJv9gVoUFbWl+KuNVkRbR6vH38yyldqWaR3Wdi2l6oLdFN3qOUWnOFvXU6oTUQ/2uAp1VnOoiIxua2v5Jf5CKBDRBiG8v3/4MTOiEvSd3ASfj3PuOfGd973vV25unt7cvBM8hBACRER0T7ooXQARUWfAMCUikoBhSkQkAcOUiEgChikRkQQMUyIiCRimREQSMEyJiCRgmBIRScAwJSKSgGFKRCQBw5SISAKGKRGRBAxTIiIJGKZERBIwTImIJGCYEhFJwDAlIpKAYUpEJAHDlIhIAoYpEZEEDFMiIgkYpkREEjBMiYgkYJgSEUnAMCUikoBhSkQkAcOUiEgChikRkQReShdAriMpKQlFRUWKjB0eHo709HRFxib7KXWMuMPxwTNTsioqKlLkhaLUuNRxSjxX7nJ88MyUbISHhyMvL8+pY44dO9ap49G9cfYx4i7HB89MiYgkYJgSEUnAMCUikoBhSkQkAcOUiEgChikRkQScGkVEDmMymXDixAn897//hdlshp+fH4YMGYLBgwejW7dubfoLIbB+/XpMnz4dISEhzi/4HjBMiUgqIQQOHDiADz74APv27YMQok2fbt26YebMmVi8eDEiIiKs66WkpCA1NRXV1dVYvXq1s0u/J/ft2/zMzMwOTwaOiIjA559/7piCyGnOnz+Pl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HXa3ft29fyRVdo9VqERQUhMLCQmtbaWkpTCZThy4XEDmCzl/NIHVBip6ZRkREoKysDDk5OZgyZQpMJhOMRiP0ej2Aa9OTmpubcfXqVQCA2WwGAKhUqrsOYHslJCQgLS0N48aNQ0BAAJKTk6HX6xESEuLQca/j23wi12D3u0ShsMzMTDFw4EDh6+srAgMDxYoVK6z3bd26VQBos5SVldn0ee+99+44xqpVq8Sjjz7aobpaWlrE0qVLRUBAgPDz8xPPPvusuHjxYoe2QUT3D7f/1ajMzExUVVVJ/QCKiKij3DpM4+PjYTQa0dTUhEceeQQ5OTlKl0RE9ym3DlMiIleh+KR9IqLOgGFKRCQBw5SISAKGKRGRBAxTIiIJGKZERBIwTImIJGCYEhFJwDAlIpKAYUpEJAHDlIhIAoYpEZEEDFMiIgkYpkREEjBMiYgkYJgSEUnAMCUikoBhSkQkAcOUiEgChikRkQQMUyIiCRimREQSMEyJiCRgmBIRScAwJSKSgGFKRCQBw5SISIL/D/uUEwjC+2QTAAAAAElFTkSuQmCC\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "# Try both commands:\n", - "execute_locally(circuit,draw_circuit=True)\n", - "# execute_locally(circuit,draw_circuit=False)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**TASK:** Observe the results" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "> The same phenomena happened, however the states now were `01` and `10`, only 2 out of 4 possibilities!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Quantum measurement in different basis\n", - "Given any of our previous circuits, we are going to measure them on both the zero-one basis as well as on the plus-minus basis." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**TASK:** Reconstruct one of the previous circuits (do not apply the measurement yet)" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [], - "source": [ - "# create the circuit\n", - "qr, cr, circuit = new_circuit(2)\n", - "circuit.h(qr[0])\n", - "circuit.cx(qr[0], qr[1]);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**TASK:** Add a Hadamard after each qubit" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [], - "source": [ - "circuit.h(qr);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**TASK:** perform the measurement now and execute" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "simulation: COMPLETED {'00': 517, '11': 507}\n" - ] - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAa4AAADYCAYAAACz+QfyAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAHqNJREFUeJzt3X9QVPX+P/AnLkgKu0KAECKLP8bPpwhdRERtFMEMS5JuXG/d/PEVE6yrpfnjrpfKH1ykpdt4jSmbSzfBG9n9al5DtJEmQHJKd0gDw5lM5Tcf1EBgQwUVzvePPu7XDZRdXM7ZNz4fM2dmfe/77PsFHnhy3vs+Z50kSZJAREQkiEFKF0BERGQLBhcREQmFwUVEREJhcBERkVAYXEREJBQGFxERCYXBRUREQmFwERGRUBhcREQkFAYXEREJhcFFRERCYXAREZFQGFxERCQUBhcREQmFwUVEREJhcBERkVAYXEREJBQGFxERCYXBRUREQmFwERGRUBhcREQkFAYXEREJhcFFRERCYXAREZFQGFxERCQUBhcREQmFwUVEREJhcBERkVAYXEREJBRnpQsgx7F69WqUlpYqMrZOp8P27dsVGZsGNlGPa6XqFuFnkWdcZFZaWqrID4pS49L9QdTjWom6RflZ5BkXWdDpdDhy5IisY86cOVPW8ej+I+pxLXfdovws8oyLiIiEwuAiIiKhMLiIiEgoDC4iIhIKg4uIiITC4CIiIqFwO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LiIiEgqDi4iIhMLgIiIioTC4iIhIKAwuIiISCoOLiIiE8v8AS5u8Iwp8nhwAAAAASUVORK5CYII=\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "circuit.measure(qr, cr)\n", - "execute_locally(circuit,draw_circuit=True)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**TASK:** Why is this measurement different from the previous one?" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "> Since we applied the Hadamard gate on our qubits, their superposition was shifted accordingly, meaning the $\\alpha$ and $\\beta$ on the superposition were rotated by 45º. Once we measure, now, the result should be interpreted in the plus-minus basis, meaning that 1 is |+> and 0 is |->." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Free flow\n", - "Take a look at the following explanation of Entanglement, taken from the [qiskit-tutorial](https://github.com/Qiskit/qiskit-tutorial/blob/master/community/terra/qis_intro/entanglement_introduction.ipynb)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Entanglement\n", - "\n", - "The core idea behind the second Principle is *entanglement*. Upon reading the Principle, one might be inclined to think that entanglement is simply strong correlation between two entitities -- but entanglement goes well beyond mere perfect (classical) correlation. If you and I read the same paper, we will have learned the same information. If a third person comes along and reads the same paper they also will have learned this information. All three persons in this case are perfectly correlated, and they will remain correlated even if they are separated from each other. \n", - "\n", - "The situation with quantum entanglement is a bit more subtle. In the quantum world, you and I could read the same quantum paper, and yet we will not learn what information is actually contained in the paper until we get together and share our information. However, when we are together, we find that we can unlock more information from the paper than we initially thought possible. Thus, quantum entanglement goes much further than perfect correlation.\n", - "\n", - "To demonstrate this, we will define the controlled-NOT (CNOT) gate and the composition of two systems. The convention we use Qiskit is to label states by writing the first qubit's name in the rightmost position, thereby allowing us to easily convert from binary to decimal. As a result, we define the tensor product between operators $q_0$ and $q_1$ by $q_1\\otimes q_0$. \n", - "\n", - "Taking $q_0$ as the control and $q_1$ as the target, the CNOT with this representation is given by\n", - "\n", - "$$ CNOT =\\begin{pmatrix} 1 & 0 & 0 & 0\\\\ 0 & 0 & 0 & 1\\\\0& 0& 1 & 0\\\\0 & 1 & 0 & 0 \\end{pmatrix},$$\n", - "\n", - "which is non-standard in the quantum community, but more easily connects to classical computing, where the least significant bit (LSB) is typically on the right. An entangled state of the two qubits can be made via an $H$ gate on the control qubit, followed by the CNOT gate. This generates a particular maximally entangled two-qubit state known as a Bell state, named after John Stewart Bell ([learn more about Bell and his contributions to quantum physics and entanglement](https://en.wikipedia.org/wiki/John_Stewart_Bell)). \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Entanglement on a real device\n", - "**TASK:** Create a simple entanglement and execute it on a real device." - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [], - "source": [ - "qr, cr, circuit = new_circuit(2)\n", - "circuit.h(qr[0])\n", - "circuit.cx(qr[0], qr[1])\n", - "circuit.h(qr)\n", - "circuit.measure(qr, cr);" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Running on current least busy device: ibmq_16_melbourne\n", - "Status @ 0 seconds\n", - "JobStatus.INITIALIZING\n", - "Status @ 10 seconds\n", - "JobStatus.QUEUED\n", - "Status @ 20 seconds\n", - "JobStatus.QUEUED\n", - "Status @ 30 seconds\n", - "JobStatus.QUEUED\n", - "Status @ 40 seconds\n", - "JobStatus.QUEUED\n", - "Status @ 50 seconds\n", - "JobStatus.RUNNING\n", - "Status @ 60 seconds\n", - "JobStatus.RUNNING\n", - "JobStatus.DONE\n", - "experiment: COMPLETED {'00': 455, '01': 41, '10': 51, '11': 477}\n" - ] - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEg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+4HtU1rfxW7g8auql6vqzeku7eJXVc8D75w2vI2l3znwd++cBh2/qjpSVZfqhzVHZuhX5my3d3ivqj48bUxn8vYY43d1VZ0AaI9XTXk9uggZ+pUZdHuHNQPGfCvTYCPdHkPSeBn6lRl0e4e3gHVJ1i4bO+OWDwJGvD2GVuTtJNcAtMeTU16PLkKGfmXOdnuHZ4EvtDk7gQNTWt/FzttjjN9Bln7nwN89nYWhX4F2Hf7U7R2OAE+02zt8BbgvyTxwJbBvequ8eJ3t+CX5rSQLLJ3hv5rkq9Nc58UqydeAvwd+PslCkl3A/cDnkxwFPt/2NcCg45fk19rv3i8ATyX51nRXORl+MlaSOucZvSR1ztBLUucMvSR1ztBLUucMvSR1ztBLUucMvSR1ztBLUuf+B23dJgNucajQAAAAAElFTkSuQmCC\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "execute_remotely(circuit)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**TASK:** Comment on the results" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "> \n", - "**Important:** Once you get the results, you may see that, in fact, most of the iterations resulted in `00` and `11`. The remaining options `01` and `10` are due to the immense difficulty with which quantum entanglement is preserved in nowadays labs' conditions. Nonetheless, these are still extraordinary results!" - ] - } - ], - "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.6.4" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/exercises/README.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/exercises/README.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/exercises/w4_01.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/exercises/w4_01.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/exercises/w4_01_s.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_4-Quantum_Facts/exercises/w4_01_s.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_5-Quantum_Algorithms/.ipynb_checkpoints/README-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_5-Quantum_Algorithms/.ipynb_checkpoints/README-checkpoint.ipynb deleted file mode 100755 index 17bd989b1..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_5-Quantum_Algorithms/.ipynb_checkpoints/README-checkpoint.ipynb +++ /dev/null @@ -1,56 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Week 5 - Quantum Algorithms (Introdution)\n", - "\n", - " * Quantum Oracles\n", - " * Quantum Reversible Computation\n", - " * Deutsch-Jozsa Problem Formulation\n", - " * Deutsch's Problem Formulation\n", - " * Deutsch's Algorithm\n", - " * Deutsch-Jozsa Algorithm\n", - " * Deutsch/Deutsch-Jozsa in Qiskit\n", - "\n", - "# Exercises\n", - " * Pen and paper verificatio of the math in the description of Deutsch's Algorithm [slides](slides.pdf)\n", - " * [Jupyter notebook with exercises](exercises/w5_01.ipynb): implementing Deutsch's Algorithm in Qiskit\n", - " * [Jupyter notebook with solutions](exercises/w5_01_s.ipynb)\n", - "\n", - "## Resources\n", - " * [PDF slides](slides.pdf)\n", - " * [slides src](latex/main.tex) Latex files and image resources used in the presentation (useful for PR on slide typos and such)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_5-Quantum_Algorithms/.ipynb_checkpoints/README-checkpoint.md b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_5-Quantum_Algorithms/.ipynb_checkpoints/README-checkpoint.md deleted file mode 100755 index 491d34f91..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_5-Quantum_Algorithms/.ipynb_checkpoints/README-checkpoint.md +++ /dev/null @@ -1,18 +0,0 @@ -# Week 5 - Quantum Algorithms (Introdution) - - * Quantum Oracles - * Quantum Reversible Computation - * Deutsch-Jozsa Problem Formulation - * Deutsch's Problem Formulation - * Deutsch's Algorithm - * Deutsch-Jozsa Algorithm - * Deutsch/Deutsch-Jozsa in Qiskit - -# Exercises - * Pen and paper verificatio of the math in the description of Deutsch's Algorithm [slides](slides.pdf) - * [Jupyter notebook with exercises](exercises/w5_01.ipynb): implementing Deutsch's Algorithm in Qiskit - * [Jupyter notebook with solutions](exercises/w5_01_s.ipynb) - -## Resources - * [PDF slides](slides.pdf) - * [slides src](latex/) Latex files and image resources used in the presentation (useful for PR on slide typos and such) diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_5-Quantum_Algorithms/README.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_5-Quantum_Algorithms/README.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_5-Quantum_Algorithms/exercises/.ipynb_checkpoints/README-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_5-Quantum_Algorithms/exercises/.ipynb_checkpoints/README-checkpoint.ipynb deleted file mode 100755 index f7e1efa94..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_5-Quantum_Algorithms/exercises/.ipynb_checkpoints/README-checkpoint.ipynb +++ /dev/null @@ -1,43 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "# Exercises\n", - " * Pen and paper verificatio of the math in the description of Deutsch's Algorithm [slides](../slides.pdf)\n", - " * [Jupyter notebook with exercises](w5_01.ipynb): implementing Deutsch's Algorithm in Qiskit\n", - " * [Jupyter notebook with solutions](w5_01_s.ipynb)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_5-Quantum_Algorithms/exercises/README.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_5-Quantum_Algorithms/exercises/README.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_5-Quantum_Algorithms/exercises/w5_01.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_5-Quantum_Algorithms/exercises/w5_01.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_5-Quantum_Algorithms/exercises/w5_01_s.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_5-Quantum_Algorithms/exercises/w5_01_s.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_6-Quantum_Search/.ipynb_checkpoints/README-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_6-Quantum_Search/.ipynb_checkpoints/README-checkpoint.ipynb deleted file mode 100755 index aae390012..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_6-Quantum_Search/.ipynb_checkpoints/README-checkpoint.ipynb +++ /dev/null @@ -1,53 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Week 6 - Quantum Search (Grover's Algorithm)\n", - "\n", - " * The Search Problem\n", - " * SAT Problem\n", - " * Grover's Algorithm Overview\n", - " * Phase Inversion\n", - " * Inversion about the Mean\n", - " * Quadratic speedup\n", - "\n", - "# Exercises\n", - " * [Jupyter notebook with tutorial](exercises/w6_01.ipynb): implementing Grover's Algorithm and solving a SAT problem of dimension 3, using local and remote (IBMQ) quantum devices\n", - "\n", - "## Resources\n", - " * [PDF slides](slides.pdf)\n", - " * [slides src](latex/main.tex) Latex files and image resources used in the presentation (useful for PR on slide typos and such)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_6-Quantum_Search/.ipynb_checkpoints/README-checkpoint.md b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_6-Quantum_Search/.ipynb_checkpoints/README-checkpoint.md deleted file mode 100755 index cca3f2df7..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_6-Quantum_Search/.ipynb_checkpoints/README-checkpoint.md +++ /dev/null @@ -1,15 +0,0 @@ -# Week 6 - Quantum Search (Grover's Algorithm) - - * The Search Problem - * SAT Problem - * Grover's Algorithm Overview - * Phase Inversion - * Inversion about the Mean - * Quadratic speedup - -# Exercises - * [Jupyter notebook with tutorial](exercises/w6_01.ipynb): implementing Grover's Algorithm and solving a SAT problem of dimension 3, using local and remote (IBMQ) quantum devices - -## Resources - * [PDF slides](slides.pdf) - * [slides src](latex/) Latex files and image resources used in the presentation (useful for PR on slide typos and such) diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_6-Quantum_Search/README.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_6-Quantum_Search/README.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_6-Quantum_Search/exercises/.ipynb_checkpoints/README-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_6-Quantum_Search/exercises/.ipynb_checkpoints/README-checkpoint.ipynb deleted file mode 100755 index 18c4c6c76..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_6-Quantum_Search/exercises/.ipynb_checkpoints/README-checkpoint.ipynb +++ /dev/null @@ -1,40 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Exercises\n", - " * [Jupyter notebook with tutorial](w6_01.ipynb): implementing Grover's Algorithm and solving a SAT problem of dimension 3, using local and remote (IBMQ) quantum devices\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_6-Quantum_Search/exercises/README.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_6-Quantum_Search/exercises/README.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_6-Quantum_Search/exercises/w6_01.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_6-Quantum_Search/exercises/w6_01.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_7-Quantum_Factorization/.ipynb_checkpoints/README-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_7-Quantum_Factorization/.ipynb_checkpoints/README-checkpoint.ipynb deleted file mode 100755 index 918b5d4ab..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_7-Quantum_Factorization/.ipynb_checkpoints/README-checkpoint.ipynb +++ /dev/null @@ -1,55 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Week 7 - Quantum Factorization (Shor's Algorithm)\n", - "\n", - " * The Prime Factorization Problem\n", - " * Cryptography Considerations\n", - " * Grover's Algorithm Overview\n", - " * Shor's Algorithm\n", - " * From Factorization to Period Finding\n", - " * Quantum Fourier Transform\n", - " * From Period to Factors\n", - "\n", - "# Exercises\n", - " * [Jupyter notebook 1 with tutorial](exercises/w7_01.ipynb): understanding the Quantum Fourier Transform on its own (this one is optional as it is very math-heavy for some students)\n", - " * [Jupyter notebook 2 with tutorial](exercises/w7_02.ipynb): understanding Shor's Algorithm step by step\n", - "\n", - "## Resources\n", - " * [PDF slides](slides.pdf)\n", - " * [slides src](latex/main.tex) Latex files and image resources used in the presentation (useful for PR on slide typos and such)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_7-Quantum_Factorization/.ipynb_checkpoints/README-checkpoint.md b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_7-Quantum_Factorization/.ipynb_checkpoints/README-checkpoint.md deleted file mode 100755 index 79d8c6cec..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_7-Quantum_Factorization/.ipynb_checkpoints/README-checkpoint.md +++ /dev/null @@ -1,17 +0,0 @@ -# Week 7 - Quantum Factorization (Shor's Algorithm) - - * The Prime Factorization Problem - * Cryptography Considerations - * Grover's Algorithm Overview - * Shor's Algorithm - * From Factorization to Period Finding - * Quantum Fourier Transform - * From Period to Factors - -# Exercises - * [Jupyter notebook 1 with tutorial](exercises/w7_01.ipynb): understanding the Quantum Fourier Transform on its own (this one is optional as it is very math-heavy for some students) - * [Jupyter notebook 2 with tutorial](exercises/w7_02.ipynb): understanding Shor's Algorithm step by step - -## Resources - * [PDF slides](slides.pdf) - * [slides src](latex/) Latex files and image resources used in the presentation (useful for PR on slide typos and such) diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_7-Quantum_Factorization/README.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_7-Quantum_Factorization/README.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_7-Quantum_Factorization/exercises/.ipynb_checkpoints/README-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_7-Quantum_Factorization/exercises/.ipynb_checkpoints/README-checkpoint.ipynb deleted file mode 100755 index dd5c4ea95..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_7-Quantum_Factorization/exercises/.ipynb_checkpoints/README-checkpoint.ipynb +++ /dev/null @@ -1,41 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Exercises\n", - " * [Jupyter notebook 1 with tutorial](w7_01.ipynb): understanding the Quantum Fourier Transform on its own (this one is optional as it is very math-heavy for some students)\n", - " * [Jupyter notebook 2 with tutorial](w7_02.ipynb): understanding Shor's Algorithm step by step\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_7-Quantum_Factorization/exercises/README.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_7-Quantum_Factorization/exercises/README.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_7-Quantum_Factorization/exercises/w7_01.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_7-Quantum_Factorization/exercises/w7_01.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_7-Quantum_Factorization/exercises/w7_02.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_7-Quantum_Factorization/exercises/w7_02.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/.ipynb_checkpoints/README-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/.ipynb_checkpoints/README-checkpoint.ipynb deleted file mode 100755 index 265d84712..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/.ipynb_checkpoints/README-checkpoint.ipynb +++ /dev/null @@ -1,58 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Week 8 - High Level Quantum Programming (qiskit-aqua)\n", - "\n", - " * Qiskit Aqua\n", - " * Quantum Supremacy\n", - " * Troubleshooting Qiskit Aqua\n", - " * High Level Grover's algorithm\n", - " * AI problems with aqua\n", - " * Optimization problems with aqua (MaxCut, Traveling Salesman)\n", - " * Chemistry with aqua\n", - "\n", - "# Exercises\n", - " * [Jupyter notebook 1 with tutorial](exercises/w8_01.ipynb): Grover's algorithm (High Level Quantum)\n", - " * [Jupyter notebook 2 with tutorial](exercises/w8_02.ipynb): Support Vector Machine for classification of Breast Cancer datapoints (AI)\n", - " * [Jupyter notebook 3 with tutorial](exercises/w8_03.ipynb): Maximum Cut problem (Optimization)\n", - " * [Jupyter notebook 4 with tutorial](exercises/w8_04.ipynb): Traveling Salesman problem (Optimization)\n", - " * [Jupyter notebook 5 with tutorial](exercises/w8_05.ipynb): Ground state oh H2 Molecule (Chemistry)\n", - "\n", - "## Resources\n", - " * [PDF slides](slides.pdf)\n", - " * [slides src](latex/main.tex) Latex files and image resources used in the presentation (useful for PR on slide typos and such)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/.ipynb_checkpoints/README-checkpoint.md b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/.ipynb_checkpoints/README-checkpoint.md deleted file mode 100755 index 997bb7b80..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/.ipynb_checkpoints/README-checkpoint.md +++ /dev/null @@ -1,20 +0,0 @@ -# Week 8 - High Level Quantum Programming (qiskit-aqua) - - * Qiskit Aqua - * Quantum Supremacy - * Troubleshooting Qiskit Aqua - * High Level Grover's algorithm - * AI problems with aqua - * Optimization problems with aqua (MaxCut, Traveling Salesman) - * Chemistry with aqua - -# Exercises - * [Jupyter notebook 1 with tutorial](exercises/w8_01.ipynb): Grover's algorithm (High Level Quantum) - * [Jupyter notebook 2 with tutorial](exercises/w8_02.ipynb): Support Vector Machine for classification of Breast Cancer datapoints (AI) - * [Jupyter notebook 3 with tutorial](exercises/w8_03.ipynb): Maximum Cut problem (Optimization) - * [Jupyter notebook 4 with tutorial](exercises/w8_04.ipynb): Traveling Salesman problem (Optimization) - * [Jupyter notebook 5 with tutorial](exercises/w8_05.ipynb): Ground state oh H2 Molecule (Chemistry) - -## Resources - * [PDF slides](slides.pdf) - * [slides src](latex/) Latex files and image resources used in the presentation (useful for PR on slide typos and such) diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/README.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/README.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/exercises/.ipynb_checkpoints/README-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/exercises/.ipynb_checkpoints/README-checkpoint.ipynb deleted file mode 100755 index 6c7a5f67f..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/exercises/.ipynb_checkpoints/README-checkpoint.ipynb +++ /dev/null @@ -1,44 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Exercises\n", - " * [Jupyter notebook 1 with tutorial](w8_01.ipynb): Grover's algorithm (High Level Quantum)\n", - " * [Jupyter notebook 2 with tutorial](w8_02.ipynb): Support Vector Machine for classification of Breast Cancer datapoints (AI)\n", - " * [Jupyter notebook 3 with tutorial](w8_03.ipynb): Maximum Cut problem (Optimization)\n", - " * [Jupyter notebook 4 with tutorial](w8_04.ipynb): Traveling Salesman problem (Optimization)\n", - " * [Jupyter notebook 5 with tutorial](w8_05.ipynb): Ground state oh H2 Molecule (Chemistry)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/exercises/README.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/exercises/README.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/exercises/w8_01.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/exercises/w8_01.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/exercises/w8_02.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/exercises/w8_02.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/exercises/w8_03.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/exercises/w8_03.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/exercises/w8_04.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/exercises/w8_04.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/exercises/w8_05.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_8-High_Level_Quantum_Programming/exercises/w8_05.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_9-State_of_the_Quantum_Art/.ipynb_checkpoints/README-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_9-State_of_the_Quantum_Art/.ipynb_checkpoints/README-checkpoint.ipynb deleted file mode 100755 index 9a4ad49d6..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_9-State_of_the_Quantum_Art/.ipynb_checkpoints/README-checkpoint.ipynb +++ /dev/null @@ -1,55 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Week 9 - State of the Quantum Art\n", - "\n", - " * Models of Quantum Computation\n", - " * Quantum Circuit\n", - " * Adiabatic Quantum Computation\n", - " * Measurement Based Quantum Computer\n", - " * Topological Quantum Computer\n", - " * Building Quantum Computers\n", - " * Implementing a Qubit\n", - " * Quantum Decoherence\n", - " * Quantum Error Correction\n", - " * Industrial Standpoint - Race for Quantum\n", - " * Closing Remarks\n", - "\n", - "## Resources\n", - " * [PDF slides](slides.pdf)\n", - " * [slides src](latex/main.tex) Latex files and image resources used in the presentation (useful for PR on slide typos and such)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_9-State_of_the_Quantum_Art/.ipynb_checkpoints/README-checkpoint.md b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_9-State_of_the_Quantum_Art/.ipynb_checkpoints/README-checkpoint.md deleted file mode 100755 index 224942fb4..000000000 --- a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_9-State_of_the_Quantum_Art/.ipynb_checkpoints/README-checkpoint.md +++ /dev/null @@ -1,17 +0,0 @@ -# Week 9 - State of the Quantum Art - - * Models of Quantum Computation - * Quantum Circuit - * Adiabatic Quantum Computation - * Measurement Based Quantum Computer - * Topological Quantum Computer - * Building Quantum Computers - * Implementing a Qubit - * Quantum Decoherence - * Quantum Error Correction - * Industrial Standpoint - Race for Quantum - * Closing Remarks - -## Resources - * [PDF slides](slides.pdf) - * [slides src](latex/) Latex files and image resources used in the presentation (useful for PR on slide typos and such) diff --git a/community/awards/teach_me_quantum_2018/TeachMeQ/Week_9-State_of_the_Quantum_Art/README.ipynb b/community/awards/teach_me_quantum_2018/TeachMeQ/Week_9-State_of_the_Quantum_Art/README.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/basic_intro2qc/QuantumComputingIntroduction.ipynb b/community/awards/teach_me_quantum_2018/basic_intro2qc/QuantumComputingIntroduction.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/.ipynb_checkpoints/B88_Grovers_Search_Solutions-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/.ipynb_checkpoints/B88_Grovers_Search_Solutions-checkpoint.ipynb deleted file mode 100755 index ad8e00410..000000000 --- a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/.ipynb_checkpoints/B88_Grovers_Search_Solutions-checkpoint.ipynb +++ /dev/null @@ -1,793 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
\n", - "\tprepared by Abuzer Yakaryilmaz (QuSoft@Riga) | November 10, 2018\n", - "
\n", - "
I have some macros here. If there is a problem with displaying mathematical formulas, please run me to load these macros.
\n", - "$ \\newcommand{\\bra}[1]{\\langle #1|} $\n", - "$ \\newcommand{\\ket}[1]{|#1\\rangle} $\n", - "$ \\newcommand{\\braket}[2]{\\langle #1|#2\\rangle} $\n", - "$ \\newcommand{\\inner}[2]{\\langle #1,#2\\rangle} $\n", - "$ \\newcommand{\\biginner}[2]{\\left\\langle #1,#2\\right\\rangle} $\n", - "$ \\newcommand{\\mymatrix}[2]{\\left( \\begin{array}{#1} #2\\end{array} \\right)} $\n", - "$ \\newcommand{\\myvector}[1]{\\mymatrix{c}{#1}} $\n", - "$ \\newcommand{\\myrvector}[1]{\\mymatrix{r}{#1}} $\n", - "$ \\newcommand{\\mypar}[1]{\\left( #1 \\right)} $\n", - "$ \\newcommand{\\mybigpar}[1]{ \\Big( #1 \\Big)} $\n", - "$ \\newcommand{\\sqrttwo}{\\frac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\dsqrttwo}{\\dfrac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\onehalf}{\\frac{1}{2}} $\n", - "$ \\newcommand{\\donehalf}{\\dfrac{1}{2}} $\n", - "$ \\newcommand{\\hadamard}{ \\mymatrix{rr}{ \\sqrttwo & \\sqrttwo \\\\ \\sqrttwo & -\\sqrttwo }} $\n", - "$ \\newcommand{\\vzero}{\\myvector{1\\\\0}} $\n", - "$ \\newcommand{\\vone}{\\myvector{0\\\\1}} $\n", - "$ \\newcommand{\\vhadamardzero}{\\myvector{ \\sqrttwo \\\\ \\sqrttwo } } $\n", - "$ \\newcommand{\\vhadamardone}{ \\myrvector{ \\sqrttwo \\\\ -\\sqrttwo } } $\n", - "$ \\newcommand{\\myarray}[2]{ \\begin{array}{#1}#2\\end{array}} $\n", - "$ \\newcommand{\\X}{ \\mymatrix{cc}{0 & 1 \\\\ 1 & 0} } $\n", - "$ \\newcommand{\\Z}{ \\mymatrix{rr}{1 & 0 \\\\ 0 & -1} } $\n", - "$ \\newcommand{\\Htwo}{ \\mymatrix{rrrr}{ \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} } } $\n", - "$ \\newcommand{\\CNOT}{ \\mymatrix{cccc}{1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 1 \\\\ 0 & 0 & 1 & 0} } $\n", - "$ \\newcommand{\\norm}[1]{ \\left\\lVert #1 \\right\\rVert } $" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Solutions for Grover's Search

" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "

Task 1

\n", - "\n", - "Design a quantum circuit with 4 qubits.\n", - "\n", - "Apply Hadamard to each qubit.\n", - "\n", - "Execute your circuit 1600 times.\n", - "\n", - "You should observe each basis state around 100 times.\n", - "\n", - "Reexecute your circuit 16000 times." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Solution

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# import all necessary objects and methods for quantum circuits\n", - "from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer\n", - "from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer\n", - "\n", - "qreg = QuantumRegister(4) # quantum register with 4 qubits\n", - "creg = ClassicalRegister(4) # classical register with 4 bits\n", - "mycircuit = QuantumCircuit(qreg,creg) # quantum circuit with quantum and classical registers\n", - "\n", - "# apply h-gate (Hadamard) to each qubit\n", - "for i in range(4):\n", - " mycircuit.h(qreg[i])\n", - "\n", - "# measure both qubits\n", - "mycircuit.measure(qreg,creg)\n", - " \n", - "# execute the circuit 1600 times, and print the outcomes\n", - "job = execute(mycircuit,Aer.get_backend('qasm_simulator'),shots=1600)\n", - "counts = job.result().get_counts(mycircuit)\n", - "for outcome in counts:\n", - " reverse_outcome = ''\n", - " for i in outcome:\n", - " reverse_outcome = i + reverse_outcome\n", - " print(reverse_outcome,\"is observed\",counts[outcome],\"times\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "

Task 2: Emulating Grover's search

\n", - "\n", - "For this task, you can use the methods given in notebook B80_Reflections.\n", - "\n", - "Set the value of $ k $ to 4. Then, the size of list is $ 2^k = 16 $.\n", - "\n", - "Pick the value of $ m $ as 3, the number of the marked elements.\n", - "\n", - "As described above, $ \\ket{u} = \\sqrt{\\frac{3}{16}} \\ket{u_{marked}} + \\sqrt{\\frac{13}{16}} \\ket{u_{unmarked}} $.\n", - "\n", - "Create a quantum circuit with single qubit.\n", - "\n", - "States $ \\ket{1} $ and $ \\ket{0} $ represents the quantum state $ \\ket{u_{marked}} $ and $ \\ket{u_{unmarked}}$, respectively.\n", - "\n", - "Then, $ \\ket{u} = \\sqrt{\\frac{13}{16}} \\ket{0} + \\sqrt{\\frac{3}{16}} \\ket{1} $.\n", - "\n", - "Determine the angle $ \\theta $, the angle between $ \\ket{u} $ and $ \\ket{0} $.\n", - "\n", - "Iterate Grover's search algorithm once by using your quantum circuit.\n", - "\n", - "For each reflection, use ry-gate (rotation).\n", - "
    \n", - "
  • Define a list to store all quantum states (with their labels) that will be visited.
  • \n", - "
  • Implement the first reflection on your qubit
  • \n", - "
  • Read the current quantum state and store it on your list
  • \n", - "
  • Implement the second reflection on your qubit
  • \n", - "
  • Read the current quantum state and store it on your list\n", - "
  • Draw all visited quantum states with their labels
  • \n", - "
  • Execute your circuit 100 times
  • \n", - "
\n", - "\n", - "Is this single iteration enough to observe state $ \\ket{1} $ more than state $ \\ket{0} $? " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Solution

" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Find angle theta ($\\theta$)

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# find the angle theta\n", - "\n", - "u2 = [(13/16)**0.5,(3/16)**0.5]\n", - "print(u2)\n", - "\n", - "from math import acos # acos is the inverse of function cosine\n", - "from math import pi \n", - "\n", - "def angle_between_two_quantum_states(quantum_state1,quantum_state2):\n", - " inner_product = quantum_state1[0] * quantum_state2[0] + quantum_state1[1] * quantum_state2[1]\n", - " return acos(inner_product) \n", - "\n", - "# angle between |u> and |0> \n", - "theta2 = angle_between_two_quantum_states(u2,[1,0])\n", - "print(theta2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

The previously used functions

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# COPY-PASTE the functions from the notebook \"B80_Reflections\"\n", - "\n", - "def amplitudes_of_a_quantum_state(quantum_circuit):\n", - " # import all necessary objects and methods for quantum circuits\n", - " from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer\n", - " \n", - " # the following code is used to get the quantum state of a quantum circuit\n", - " job = execute(quantum_circuit,Aer.get_backend('statevector_simulator'))\n", - " current_quantum_state=job.result().get_statevector(quantum_circuit) \n", - " \n", - " # now we read the real parts of the amplitudes\n", - " the_first_amplitude = current_quantum_state[0].real # amplitude of |0>\n", - " the_second_amplitude = current_quantum_state[1].real # amplitude of |1>\n", - " \n", - " return[the_first_amplitude,the_second_amplitude]\n", - "# end of function\n", - "\n", - "def visualize_quantum_states(quantum_states):\n", - " # import the useful tool for drawing figures in pythpn\n", - " from matplotlib.pyplot import plot, show, figure, Circle, axis, gca, annotate, arrow, text\n", - " # import the constant pi\n", - " from math import pi\n", - " \n", - " figure(figsize=(6,6), dpi=80) # size of the figure\n", - " gca().add_patch( Circle((0,0),1,color='black',fill=False) ) # draw the circle\n", - " # auxiliary points\n", - " plot(-1.3,0)\n", - " plot(1.3,0)\n", - " plot(0,1.3)\n", - " plot(0,-1.3)\n", - " # axes\n", - " arrow(0,0,1.1,0,head_width=0.04, head_length=0.08)\n", - " arrow(0,0,-1.1,0,head_width=0.04, head_length=0.08)\n", - " arrow(0,0,0,-1.1,head_width=0.04, head_length=0.08)\n", - " arrow(0,0,0,1.1,head_width=0.04, head_length=0.08)\n", - " \n", - " # draw all quantum states\n", - "\n", - " for quantum_state in quantum_states:\n", - " # show the quantum state as an arrow on the diagram\n", - " state_name = quantum_state[0] # label of the quantum state \n", - " x_value = quantum_state[1] # amplitude of |0>\n", - " y_value = quantum_state[2] # amplitude of |1>\n", - " # draw the arrow\n", - " arrow(0,0,x_value,y_value,head_width=0.04, head_length=0.04,color='blue')\n", - "\n", - " # the following code is used to write the name of quantum states\n", - " if x_value<0: text_x_value=x_value-0.1\n", - " else: text_x_value=x_value+0.05\n", - " if y_value<0: text_y_value=y_value-0.1\n", - " else: text_y_value=y_value+0.05 \n", - " text(text_x_value,text_y_value,state_name)\n", - "\n", - " show() # show the diagram\n", - "# end of function" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

One iteration of Grover's search algorithm

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# import all necessary objects and methods for quantum circuits\n", - "from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer\n", - "from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer\n", - "\n", - "\n", - "all_visited_quantum_states2 =[]\n", - "\n", - "\n", - "qreg2 = QuantumRegister(1) # quantum register with 1 qubit\n", - "creg2 = ClassicalRegister(1) # classical register with 1 bit\n", - "mycircuit2 = QuantumCircuit(qreg2,creg2) # quantum circuit with quantum and classical registers\n", - "\n", - "\n", - "# set the qubit to |u>\n", - "# rotate by theta2\n", - "# do not forget to multiply it by 2\n", - "mycircuit2.ry(2*theta2,qreg2[0])\n", - "\n", - "# read and store the current quantum state\n", - "[x,y] = amplitudes_of_a_quantum_state(mycircuit2)\n", - "all_visited_quantum_states2.append(['u',x,y])\n", - "\n", - "\n", - "# this is (-2*theta2) in the first iteration\n", - "rotation_angle_for_the_first_reflection2 = -2 * theta2\n", - "# this is always (2*theta2) more than (-1*rotation_angle_for_the_first_reflection2)\n", - "rotation_angle_for_the_second_reflection2 = (2*theta2) + (-1*rotation_angle_for_the_first_reflection2)\n", - "\n", - "# the first reflection: rotate by rotation_angle_for_the_first_reflection2\n", - "mycircuit2.ry(2*rotation_angle_for_the_first_reflection2,qreg2[0])\n", - "# read and store the current quantum state\n", - "[x,y] = amplitudes_of_a_quantum_state(mycircuit2)\n", - "all_visited_quantum_states2.append(['r',x,y]) # the label is r (reflected state)\n", - "\n", - "# the second reflection: rotate by rotation_angle_for_the_second_reflection2\n", - "mycircuit2.ry(2*rotation_angle_for_the_second_reflection2,qreg2[0])\n", - "# read and store the current quantum state\n", - "[x,y] = amplitudes_of_a_quantum_state(mycircuit2)\n", - "all_visited_quantum_states2.append(['n',x,y]) # the label is n (new state)\n", - " \n", - " \n", - "visualize_quantum_states(all_visited_quantum_states2)\n", - " \n", - " \n", - "# measure both qubits\n", - "mycircuit2.measure(qreg2,creg2)\n", - " \n", - " \n", - "# execute the circuit 100 times, and print the outcomes\n", - "job = execute(mycircuit2,Aer.get_backend('qasm_simulator'),shots=100)\n", - "counts2 = job.result().get_counts(mycircuit2)\n", - "for outcome in counts2:\n", - " reverse_outcome = ''\n", - " for i in outcome:\n", - " reverse_outcome = i + reverse_outcome\n", - " print(reverse_outcome,\"is observed\",counts2[outcome],\"times\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(all_visited_quantum_states2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
\n", - "\n", - "

Taks 3

\n", - "\n", - "For this task, you can use the methods given in notebook B80_Reflections .\n", - "\n", - "Set the value of $ k $ to 6. Then, the size of list is $ 2^k = 64 $.\n", - "\n", - "Pick the value of $ m $ as 1, the number of the marked elements.\n", - "\n", - "As described above, $ \\ket{u} = \\sqrt{\\frac{1}{64}} \\ket{u_{marked}} + \\sqrt{\\frac{63}{64}} \\ket{u_{unmarked}} $.\n", - "\n", - "Create a quantum circuit with single qubit.\n", - "\n", - "States $ \\ket{1} $ and $ \\ket{0} $ represents the quantum state $ \\ket{u_{marked}} $ and $ \\ket{u_{unmarked}}$, respectively.\n", - "\n", - "Then, $ \\ket{u} = \\sqrt{\\frac{63}{64}} \\ket{0} + \\sqrt{\\frac{1}{64}} \\ket{1} $.\n", - "\n", - "Determine the angle $ \\theta $, the angle between $ \\ket{u} $ and $ \\ket{0} $.\n", - "\n", - "Iterate Grover's search algorithm three times by using your quantum circuit.\n", - "\n", - "For each reflection, use ry-gate (rotation).\n", - "
    \n", - "
  • Define a list to store all quantum states (with their labels) that will be visited.
  • \n", - "
  • Iterate 3 times:\n", - "
      \n", - "
    • Implement the first reflection on your qubit
    • \n", - "
    • Read the current quantum state and store it on your list
    • \n", - "
    • Implement the second reflection on your qubit
    • \n", - "
    • Read the current quantum state and store it on your list
    • \n", - "
  • \n", - "
  • Draw all visited quantum states with their labels
  • \n", - "
  • Execute your circuit 100 times
  • \n", - "
\n", - "\n", - "Is 3 iterations enough to observe state $ \\ket{1} $ more than state $ \\ket{0} $?\n", - "\n", - "Try 4, 5, 6, 7, 8, 9, and 10 iterations.\n", - "\n", - "What is the best iteration number?" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Solution

" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Find angle theta ($\\theta$)

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# find the angle theta\n", - "\n", - "u3 = [(63/64)**0.5,(1/64)**0.5]\n", - "print(u3)\n", - "\n", - "from math import acos # acos is the inverse of function cosine\n", - "from math import pi \n", - "\n", - "def angle_between_two_quantum_states(quantum_state1,quantum_state2):\n", - " inner_product = quantum_state1[0] * quantum_state2[0] + quantum_state1[1] * quantum_state2[1]\n", - " return acos(inner_product) \n", - "\n", - "# angle between |u> and |0> \n", - "theta3 = angle_between_two_quantum_states(u3,[1,0])\n", - "print(theta3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

The previously used functions

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# COPY-PASTE the functions from the notebook \"B80_Reflections\"\n", - "\n", - "def amplitudes_of_a_quantum_state(quantum_circuit):\n", - " # import all necessary objects and methods for quantum circuits\n", - " from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer\n", - " \n", - " # the following code is used to get the quantum state of a quantum circuit\n", - " job = execute(quantum_circuit,Aer.get_backend('statevector_simulator'))\n", - " current_quantum_state=job.result().get_statevector(quantum_circuit) \n", - " \n", - " # now we read the real parts of the amplitudes\n", - " the_first_amplitude = current_quantum_state[0].real # amplitude of |0>\n", - " the_second_amplitude = current_quantum_state[1].real # amplitude of |1>\n", - " \n", - " return[the_first_amplitude,the_second_amplitude]\n", - "# end of function\n", - "\n", - "def visualize_quantum_states(quantum_states):\n", - " # import the useful tool for drawing figures in pythpn\n", - " from matplotlib.pyplot import plot, show, figure, Circle, axis, gca, annotate, arrow, text\n", - " # import the constant pi\n", - " from math import pi\n", - " \n", - " figure(figsize=(6,6), dpi=80) # size of the figure\n", - " gca().add_patch( Circle((0,0),1,color='black',fill=False) ) # draw the circle\n", - " # auxiliary points\n", - " plot(-1.3,0)\n", - " plot(1.3,0)\n", - " plot(0,1.3)\n", - " plot(0,-1.3)\n", - " # axes\n", - " arrow(0,0,1.1,0,head_width=0.04, head_length=0.08)\n", - " arrow(0,0,-1.1,0,head_width=0.04, head_length=0.08)\n", - " arrow(0,0,0,-1.1,head_width=0.04, head_length=0.08)\n", - " arrow(0,0,0,1.1,head_width=0.04, head_length=0.08)\n", - " \n", - " # draw all quantum states\n", - "\n", - " for quantum_state in quantum_states:\n", - " # show the quantum state as an arrow on the diagram\n", - " state_name = quantum_state[0] # label of the quantum state \n", - " x_value = quantum_state[1] # amplitude of |0>\n", - " y_value = quantum_state[2] # amplitude of |1>\n", - " # draw the arrow\n", - " arrow(0,0,x_value,y_value,head_width=0.04, head_length=0.04,color='blue')\n", - "\n", - " # the following code is used to write the name of quantum states\n", - " if x_value<0: text_x_value=x_value-0.1\n", - " else: text_x_value=x_value+0.05\n", - " if y_value<0: text_y_value=y_value-0.1\n", - " else: text_y_value=y_value+0.05 \n", - " text(text_x_value,text_y_value,state_name)\n", - "\n", - " show() # show the diagram\n", - "# end of function" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Five iterations of Grover's search algorithm

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# import all necessary objects and methods for quantum circuits\n", - "from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer\n", - "from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer\n", - "\n", - "\n", - "all_visited_quantum_states3 =[]\n", - "\n", - "\n", - "qreg3 = QuantumRegister(1) # quantum register with 1 qubit\n", - "creg3 = ClassicalRegister(1) # classical register with 1 bit\n", - "mycircuit3 = QuantumCircuit(qreg3,creg3) # quantum circuit with quantum and classical registers\n", - "\n", - "# set the qubit to |u>\n", - "# rotate by theta3\n", - "# do not forget to multiply it by 2\n", - "mycircuit3.ry(2*theta3,qreg3[0])\n", - "\n", - "# read and store the current quantum state\n", - "[x,y] = amplitudes_of_a_quantum_state(mycircuit3)\n", - "all_visited_quantum_states3.append(['u',x,y])\n", - "\n", - "# this is -2 * theta3 in the first iteration\n", - "rotation_angle_for_the_first_reflection3 = -2 * theta3\n", - "# this is always (2*theta3) more than (-1*rotation_angle_for_the_first_reflection3)\n", - "rotation_angle_for_the_second_reflection3 = (2*theta3) + (-1*rotation_angle_for_the_first_reflection3)\n", - "\n", - "for i in range(3): # three iterations # later check 4, 5, 6, 7, 8, 9, and 10\n", - "\n", - " # the first reflection: rotate by rotation_angle_for_the_first_reflection3\n", - " mycircuit3.ry(2*rotation_angle_for_the_first_reflection3,qreg3[0])\n", - " # read and store the current quantum state\n", - " [x,y] = amplitudes_of_a_quantum_state(mycircuit3)\n", - " all_visited_quantum_states3.append(['r'+str(i+1),x,y]) # the labels are r1, r2, ... (reflected states)\n", - "\n", - " # the second reflection: rotate by rotation_angle_for_the_second_reflection3\n", - " mycircuit3.ry(2*rotation_angle_for_the_second_reflection3,qreg3[0])\n", - " # read and store the current quantum state\n", - " [x,y] = amplitudes_of_a_quantum_state(mycircuit3)\n", - " all_visited_quantum_states3.append(['n'+str(i+1),x,y]) # the labels are n1, n2, ... (new states)\n", - " \n", - " # this will be increased by (-4*theta2) after each iteration\n", - " rotation_angle_for_the_first_reflection3 = rotation_angle_for_the_first_reflection3 -4* theta3\n", - " # this is always (2*theta2) more than (-1*rotation_angle_for_the_first_reflection3)\n", - " rotation_angle_for_the_second_reflection3 = (2*theta3) + (-1*rotation_angle_for_the_first_reflection3)\n", - "# end of iterations\n", - "\n", - "visualize_quantum_states(all_visited_quantum_states3)\n", - " \n", - "# measure both qubits\n", - "mycircuit3.measure(qreg3,creg3)\n", - " \n", - "# execute the circuit 100 times, and print the outcomes\n", - "job = execute(mycircuit3,Aer.get_backend('qasm_simulator'),shots=100)\n", - "counts3 = job.result().get_counts(mycircuit3)\n", - "for outcome in counts3:\n", - " reverse_outcome = ''\n", - " for i in outcome:\n", - " reverse_outcome = i + reverse_outcome\n", - " print(reverse_outcome,\"is observed\",counts3[outcome],\"times\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(all_visited_quantum_states3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
\n", - "\n", - "

Task 4

\n", - "\n", - "Repeat Task 3 for $ k = 8 $ and $ m = 1 $, but algorithmically find the best iteration number, say $B$. \n", - "\n", - "You may execute your circuit 1000 times to have more reliable results.\n", - "
\n", - " Hint:\n", - "\n", - "For each iteration number, you may check how many times the state $ \\ket{1} $ is observed. \n", - "

\n", - "This value should be at least 500.\n", - "\n", - "And, when this value starts to decrease, you may announce the previous iteration number as the best. \n", - "
\n", - "
\n", - "Our solution outputs $ B $ as 12 in every execution." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Solution

" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Find angle theta ($\\theta$)

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# find the angle theta\n", - "# k=8, 2^k = 256\n", - "\n", - "u4 = [(255/256)**0.5,(1/256)**0.5]\n", - "print(u4)\n", - "\n", - "from math import acos # acos is the inverse of function cosine\n", - "from math import pi \n", - "\n", - "def angle_between_two_quantum_states(quantum_state1,quantum_state2):\n", - " inner_product = quantum_state1[0] * quantum_state2[0] + quantum_state1[1] * quantum_state2[1]\n", - " return acos(inner_product) \n", - "\n", - "# angle between |u> and |0> \n", - "theta4 = angle_between_two_quantum_states(u4,[1,0])\n", - "print(theta4)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

The previously used functions

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# COPY-PASTE the functions from the notebook \"B80_Reflections\"\n", - "\n", - "def amplitudes_of_a_quantum_state(quantum_circuit):\n", - " # import all necessary objects and methods for quantum circuits\n", - " from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer\n", - " \n", - " # the following code is used to get the quantum state of a quantum circuit\n", - " job = execute(quantum_circuit,Aer.get_backend('statevector_simulator'))\n", - " current_quantum_state=job.result().get_statevector(quantum_circuit) \n", - " \n", - " # now we read the real parts of the amplitudes\n", - " the_first_amplitude = current_quantum_state[0].real # amplitude of |0>\n", - " the_second_amplitude = current_quantum_state[1].real # amplitude of |1>\n", - " \n", - " return[the_first_amplitude,the_second_amplitude]\n", - "# end of function\n", - "\n", - "def visualize_quantum_states(quantum_states):\n", - " # import the useful tool for drawing figures in pythpn\n", - " from matplotlib.pyplot import plot, show, figure, Circle, axis, gca, annotate, arrow, text\n", - " # import the constant pi\n", - " from math import pi\n", - " \n", - " figure(figsize=(6,6), dpi=80) # size of the figure\n", - " gca().add_patch( Circle((0,0),1,color='black',fill=False) ) # draw the circle\n", - " # auxiliary points\n", - " plot(-1.3,0)\n", - " plot(1.3,0)\n", - " plot(0,1.3)\n", - " plot(0,-1.3)\n", - " # axes\n", - " arrow(0,0,1.1,0,head_width=0.04, head_length=0.08)\n", - " arrow(0,0,-1.1,0,head_width=0.04, head_length=0.08)\n", - " arrow(0,0,0,-1.1,head_width=0.04, head_length=0.08)\n", - " arrow(0,0,0,1.1,head_width=0.04, head_length=0.08)\n", - " \n", - " # draw all quantum states\n", - "\n", - " for quantum_state in quantum_states:\n", - " # show the quantum state as an arrow on the diagram\n", - " state_name = quantum_state[0] # label of the quantum state \n", - " x_value = quantum_state[1] # amplitude of |0>\n", - " y_value = quantum_state[2] # amplitude of |1>\n", - " # draw the arrow\n", - " arrow(0,0,x_value,y_value,head_width=0.04, head_length=0.04,color='blue')\n", - "\n", - " # the following code is used to write the name of quantum states\n", - " if x_value<0: text_x_value=x_value-0.1\n", - " else: text_x_value=x_value+0.05\n", - " if y_value<0: text_y_value=y_value-0.1\n", - " else: text_y_value=y_value+0.05 \n", - " text(text_x_value,text_y_value,state_name)\n", - "\n", - " show() # show the diagram\n", - "# end of function" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Five iterations of Grover's search algorithm

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# import all necessary objects and methods for quantum circuits\n", - "from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer\n", - "from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer\n", - "\n", - "\n", - "how_many_times_state_one_observed = 0\n", - "\n", - "decrease = False\n", - "\n", - "number_of_iteration = 1\n", - "\n", - "while decrease == False:\n", - "\n", - " qreg4 = QuantumRegister(1) # quantum register with 1 qubit\n", - " creg4 = ClassicalRegister(1) # classical register with 1 bit\n", - " mycircuit4 = QuantumCircuit(qreg4,creg4) # quantum circuit with quantum and classical registers\n", - "\n", - " # set the qubit to |u>\n", - " # rotate by theta4\n", - " # do not forget to multiply it by 2\n", - " mycircuit4.ry(2*theta4,qreg4[0])\n", - "\n", - "\n", - " # this is -2 * theta4 in the first iteration\n", - " rotation_angle_for_the_first_reflection4 = -2 * theta4\n", - " # this is always (2*theta4) more than (-1*rotation_angle_for_the_first_reflection4)\n", - " rotation_angle_for_the_second_reflection4 = (2*theta4) + (-1*rotation_angle_for_the_first_reflection4)\n", - "\n", - " for i in range(number_of_iteration):\n", - " \n", - " # the first reflection: rotate by rotation_angle_for_the_first_reflection4\n", - " mycircuit4.ry(2*rotation_angle_for_the_first_reflection4,qreg4[0])\n", - "\n", - " # the second reflection: rotate by rotation_angle_for_the_second_reflcetion4\n", - " mycircuit4.ry(2*rotation_angle_for_the_second_reflection4,qreg4[0])\n", - " \n", - " # this will be increased by (-4*theta4) after each iteration\n", - " rotation_angle_for_the_first_reflection4 = rotation_angle_for_the_first_reflection4 -4* theta4\n", - " # this is always (2*theta4) more than (-1*rotation_angle_for_the_first_reflection4)\n", - " rotation_angle_for_the_second_reflection4 = (2*theta4) + (-1*rotation_angle_for_the_first_reflection4)\n", - " # end of iterations\n", - "\n", - " \n", - " # measure both qubits\n", - " mycircuit4.measure(qreg4,creg4)\n", - " \n", - " # execute the circuit 1000 times, and print the outcomes\n", - " job = execute(mycircuit4,Aer.get_backend('qasm_simulator'),shots=1000)\n", - " counts4 = job.result().get_counts(mycircuit4)\n", - " print(number_of_iteration,counts4) # print the outcomes\n", - " for outcome in counts4:\n", - " if outcome == '1': \n", - " # how_many_times_state_one_observed is more than 500 and has a less value than the previous one\n", - " # then it is time to STOP\n", - " if how_many_times_state_one_observed> 500 and how_many_times_state_one_observed > counts4[outcome]: \n", - " print(\"B is\",number_of_iteration-1)\n", - " decrease = True\n", - " else: # we should continue\n", - " how_many_times_state_one_observed = counts4[outcome] # update how_many_times_state_one_observed\n", - " number_of_iteration = number_of_iteration + 1 # increase number_of_iteration" - ] - } - ], - "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.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B08_Python_Basics_Variables_Solutions.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B08_Python_Basics_Variables_Solutions.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B10_Python_Basics_Loops_Solutions.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B10_Python_Basics_Loops_Solutions.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B12_Python_Basics_Conditionals_Solutions.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B12_Python_Basics_Conditionals_Solutions.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B14_Python_Basics_Lists_Solutions.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B14_Python_Basics_Lists_Solutions.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B16_Python_Lists_Vectors_Solutions.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B16_Python_Lists_Vectors_Solutions.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B18_Python_Lists_Inner_Product_Solutions.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B18_Python_Lists_Inner_Product_Solutions.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B20_Python_Lists_Matrices_Solutions.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B20_Python_Lists_Matrices_Solutions.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B22_Python_Lists_Tensor_Product_Solutions.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B22_Python_Lists_Tensor_Product_Solutions.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B24_One_Bit_Solution.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B24_One_Bit_Solution.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B26_Coin_Flip_Solutions.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B26_Coin_Flip_Solutions.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B28_Coin_Flip_Game_Solution.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B28_Coin_Flip_Game_Solution.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B32_Probabilistic_States_Solutions.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B32_Probabilistic_States_Solutions.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B36_Probabilistic_Operators_Solutions.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B36_Probabilistic_Operators_Solutions.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B42_Hadamard_Solution.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B42_Hadamard_Solution.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B46_Quantum_State_Solutions.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B46_Quantum_State_Solutions.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B48_Superposition_Solutions.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B48_Superposition_Solutions.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B56_Two_Qubits_Solutions.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B56_Two_Qubits_Solutions.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B60_Superdense_Coding_Solution.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B60_Superdense_Coding_Solution.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B64_Phase_Kickback_Solutions.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B64_Phase_Kickback_Solutions.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B88_Grovers_Search_Solutions.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze-solutions/B88_Grovers_Search_Solutions.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B01_ Acknowledgements-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B01_ Acknowledgements-checkpoint.ipynb deleted file mode 100755 index 9180dc446..000000000 --- a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B01_ Acknowledgements-checkpoint.ipynb +++ /dev/null @@ -1,63 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Acknowledgements

" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
\n", - "

QuSoft@Riga: Bronze

\n", - "\n", - "

\"Your First Step to Quantum Programming\"

\n", - "\n", - "QuSoft Riga has been preparing tutorials to teach programming quantum computers. \n", - "\n", - "Our first tutorial is Bronze. \n", - "
" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We thank to Katrina Kizenbaha from Riga TechGirls for her revisions on our notebooks on python.\n", - "\n", - "We thank to Martins Kalis (QuSoft@Riga) for his technical comments on python, qiskit, and our notebooks.\n", - "\n", - "We thank to Maksims Dimitrijevs (QuSoft@Riga) for his careful reading and corrections on our notebooks.\n", - "\n", - "We thank to QuSoft members Martins Kalis, Maksims Dimitrijevs, Aleksejs Naumovs Andis Draguns, and Matiss Apinis for their help and support.\n", - "\n", - "We thank to the students (DF@LU) attending QuSoft's meetings on each Friday (Fall 2018) for their comments while working with our notebooks.\n", - "
" - ] - } - ], - "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.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B02_cells_in_notebook-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B02_cells_in_notebook-checkpoint.ipynb deleted file mode 100755 index 8b0c28a7c..000000000 --- a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B02_cells_in_notebook-checkpoint.ipynb +++ /dev/null @@ -1,144 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# A jupyter notebook is composed by one or more cells.\n", - "# A cell is used to write and execute your codes.\n", - "# A cell is also used to write descriptions, notes, formulas, etc.\n", - "# You can format your descriptions by using HTML or LaTex codes.\n", - "# During this tutorial, you are expected to write only python codes.\n", - "# Interested readers may also use HTML and LaTex, but it is not necesary to complete this tutorial. \n", - "\n", - "#\n", - "# We explain basic usage of cells in Jupyter notebooks here\n", - "#\n", - "\n", - "# This is the first cell in this notebook.\n", - "# You can write Python code here, \n", - "# and then EXECUTE/RUN it by\n", - "# 1) pressing SHIFT+ENTER\n", - "# 2) clicking \"Run\" on the menu\n", - "\n", - "\n", - "# here is a few lines of python codes\n", - "\n", - "print(\"hello world\")\n", - "str=\"*\"\n", - "for i in range(5):\n", - " print(str)\n", - " str+=\"*\"\n", - "\n", - "# after executing this cell, you will see the outcomes immedeately after this cell\n", - "# you may change the range above and re-run this cell\n", - "\n", - "# after executing this cell, you can continue with the next cell" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# This is the second cell.\n", - "#\n", - "# When you double click after the last cell, a new cell appears automatically.\n", - "# It automatically happens when you execute the last cell as well. \n", - "#\n", - "# By using menu item \"Insert\", you may also add a new cell before or after the selected cell.\n", - "# When a cell is selected, you may delete it by using menu item \"Edit\".\n", - "#\n", - "# As you may notice, there are other editing options under \"Edit\",\n", - "# for example, copy/cut-paste cells and split-merge cells." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This is the third cell.
\n", - "There are four types of cells.
\n", - "The first type is called \"Code\", which is the default type, as the above two cells.
\n", - "This is a second type cell called \"Markdown\", which is used for explanatory texts.
\n", - "The type of any cell is shown on the toolbar under the menu bar (right-side). You can change the type of a cell from this pulldown menu.
\n", - "You can also determine the type by clicking on the menu item \"Cell\", and then the subitem \"Cell Type\".
\n", - "\n", - "You can write HTML and LaTex code here.
\n", - "Here we have very basic HTML codes: making the texts bold, italic, or underline, and inserting line breaks.\n", - "\n", - "By double clicking on this cell, you can see the code.
\n", - "By execucting this cell, you see the result text." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " This is the fourth cell.\n", - "
\n", - "Its type is also \"Markdown\".\n", - "\n", - "LaTex is used to show mathematical expressions, formulas, etc. \n", - "\n", - "For example, $ x^2 + y ^ 2 = \\frac{4}{9} $, $ \\sum_{i=1}^n (i+2)^{3} $, or $ \\left( \\begin{array}{rr} 1 & 0 & -1 \\\\ 2 & -2 & 0 \\\\ 3 & -1 & -2 \\end{array} \\right) $.\n", - "\n", - "By double clicking on this cell, you can see the code.
\n", - "By executing/running this cell, you can see the result text." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Self Practice

\n", - "
    \n", - "
  1. Please insert a new cell between this first and second cells. \n", - "
      \n", - "
    • Change its type to \"Markdown\".
    • \n", - "
    • Write down \"This is the 1.5th cell\" and some random text (Hello world, your name and surname, etc.).
    • \n", - "
    • Run it and check the result.
    • \n", - "
    \n", - "
  2. \n", - "
  3. Please insert a new cell between two markdown cells above.\n", - "
      \n", - "
    • Write as a comment \"# This is the 3.5th cell\".\n", - "
    • Use it as a \"Code\" cell. (By default, it is a code cell.)
    • \n", - "
    • Write a single line python code, e.g., print(\"hello world :-\")
    • \n", - "
    • Run your code.
    • \n", - "
    \n", - "
  4. \n", - "
  5. Cut the cell having the text \"This is the 1.5th cell\", and insert (paste) it after the cell having the text \"This is the 3.5th cell\".
  6. \n", - "
  7. Cut these two cells (\"1.5th and 3.5th\") together, and insert (paste) them as the top cells.
  8. \n", - "
  9. Delete the cell having the text \"This is the 1.5th cell\".
  10. \n", - "
  11. Reposition the cell having the text \"This is the 3.5th cell\" to its previous place.
  12. \n", - "
\n", - " " - ] - } - ], - "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.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B04_hello_from_quantum_world-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B04_hello_from_quantum_world-checkpoint.ipynb deleted file mode 100755 index 2840b4698..000000000 --- a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B04_hello_from_quantum_world-checkpoint.ipynb +++ /dev/null @@ -1,535 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
\n", - "\tprepared by Abuzer Yakaryilmaz (QuSoft@Riga) | November 02, 2018\n", - "
\n", - "
I have some macros here. If there is a problem with displaying mathematical formulas, please run me to load these macros.
\n", - "$ \\newcommand{\\bra}[1]{\\langle #1|} $\n", - "$ \\newcommand{\\ket}[1]{|#1\\rangle} $\n", - "$ \\newcommand{\\braket}[2]{\\langle #1|#2\\rangle} $\n", - "$ \\newcommand{\\inner}[2]{\\langle #1,#2\\rangle} $\n", - "$ \\newcommand{\\biginner}[2]{\\left\\langle #1,#2\\right\\rangle} $\n", - "$ \\newcommand{\\mymatrix}[2]{\\left( \\begin{array}{#1} #2\\end{array} \\right)} $\n", - "$ \\newcommand{\\myvector}[1]{\\mymatrix{c}{#1}} $\n", - "$ \\newcommand{\\myrvector}[1]{\\mymatrix{r}{#1}} $\n", - "$ \\newcommand{\\mypar}[1]{\\left( #1 \\right)} $\n", - "$ \\newcommand{\\mybigpar}[1]{ \\Big( #1 \\Big)} $\n", - "$ \\newcommand{\\sqrttwo}{\\frac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\dsqrttwo}{\\dfrac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\onehalf}{\\frac{1}{2}} $\n", - "$ \\newcommand{\\donehalf}{\\dfrac{1}{2}} $\n", - "$ \\newcommand{\\hadamard}{ \\mymatrix{rr}{ \\sqrttwo & \\sqrttwo \\\\ \\sqrttwo & -\\sqrttwo }} $\n", - "$ \\newcommand{\\vzero}{\\myvector{1\\\\0}} $\n", - "$ \\newcommand{\\vone}{\\myvector{0\\\\1}} $\n", - "$ \\newcommand{\\vhadamardzero}{\\myvector{ \\sqrttwo \\\\ \\sqrttwo } } $\n", - "$ \\newcommand{\\vhadamardone}{ \\myrvector{ \\sqrttwo \\\\ -\\sqrttwo } } $\n", - "$ \\newcommand{\\myarray}[2]{ \\begin{array}{#1}#2\\end{array}} $\n", - "$ \\newcommand{\\X}{ \\mymatrix{cc}{0 & 1 \\\\ 1 & 0} } $\n", - "$ \\newcommand{\\Z}{ \\mymatrix{rr}{1 & 0 \\\\ 0 & -1} } $\n", - "$ \\newcommand{\\Htwo}{ \\mymatrix{rrrr}{ \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} } } $\n", - "$ \\newcommand{\\CNOT}{ \\mymatrix{cccc}{1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 1 \\\\ 0 & 0 & 1 & 0} } $\n", - "$ \\newcommand{\\norm}[1]{ \\left\\lVert #1 \\right\\rVert } $" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Hello From Quantum World

\n", - "\n", - "This is our test file. \n", - "\n", - "Please run each cell one by one." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Sqaure brackets on the left sides of the code cells

\n", - "\n", - "
    \n", - "
  • Each pair of the brackets shows the execution counter of the cell.
  • \n", - "
  • If the cell has not been executed, the inside of the brackets is empty.
  • \n", - "
  • When the code cell is still running, there appears a single star inside the brackets [*].
  • \n", - "
  • When the execution is finished, there appears a number inside the brackets [number].
  • \n", - "
  • A cell can be executed many times. Each time it takes a new number (in increasing order).
  • \n", - "
\n", - "\n", - "The execution of a cell may take a few miliseconds, a few seconds, a few minutes, or much longer time.\n", - "\n", - " Therefore, you may not see any outcome until [*] is changed to [number]." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Python Test

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# I am a comment in python\n", - "\n", - "print(\"Hello From Quantum World :-)\")\n", - "\n", - "# please run me" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Quantum Circuit Test

\n", - "\n", - "Our quantum programs are designed as quantum curcits. \n", - "\n", - "Explanations will appear in the main tutorial.\n", - "\n", - "

We create a very simple quantum circuit

\n", - "\n", - "Please run the cell below, and wait until the execution is completed.\n", - "\n", - "Remark that we call a function or an object from a module in python as\n", - " \n", - "from module-name import function-name\n", - " \n", - "from module-name import object-name\n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer\n", - "from random import randrange\n", - "\n", - "# Create my circuit and register objects\n", - "qreg = QuantumRegister(2) # my quantum register\n", - "creg = ClassicalRegister(2) # my classical register \n", - "circuit = QuantumCircuit(qreg,creg) # my quantum circuit\n", - "\n", - "# let's apply a Hadamard gate to the first qubit\n", - "\n", - "circuit.h(qreg[0])\n", - "\n", - "# let's set the second qubit to |1>\n", - "circuit.x(qreg[1])\n", - "\n", - "# let's apply CNOT(first_qubit,second_qubit)\n", - "circuit.cx(qreg[0],qreg[1])\n", - "\n", - "# let's measure the both qubits\n", - "circuit.measure(qreg,creg)\n", - "\n", - "print(\"The execution was completed, and the circuit was created :)\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

We execute the circuit (our program) 1024 times in the local simulator

\n", - "\n", - "Each execution may have a different outcome (?).\n", - "\n", - "In our simple program, we expect to observe either 01 or 10 as the outcome in a single execution. \n", - "\n", - "We print the measurement results. \n", - "\n", - "Thus, we will see how many times '01' is observed and how many times '10' is observed.\n", - "\n", - "You may execute this cell a few times, and check the outcomes in each case." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "## execute the circuit 100 times\n", - "job = execute(circuit,Aer.get_backend('qasm_simulator'),shots=1024)\n", - "# get the result\n", - "counts = job.result().get_counts(circuit)\n", - "print(counts)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Draw the circuit

\n", - "\n", - "We can draw our circuit. \n", - "\n", - "If the circuit does not appear in the first run, please re-run the cell." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer\n", - "# draw the overall circuit \n", - "drawer(circuit)\n", - "# re-execute me if you DO NOT see the circuit diagram" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

IBMQ Test

\n", - "\n", - " The remaining part requires internet connection.\n", - "\n", - "We will execute our test circuit on IBM simulator, and then on one of IBM real qauntum computers.\n", - "\n", - " Please wait the execution of each cell to be completed, before executing the next cell." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Save your API on the disk

\n", - "\n", - "Please write YOUR IBM API TOKEN in the following cell, and then run the cell.\n", - "\n", - "(The instruction is given at the end of section \"Testing: First Program\" in the file bronze-start.html\n", - "\n", - "Once your YOUR IBM API TOKEN is saved on the disk, it can be directly used later." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from qiskit import IBMQ\n", - "\n", - "IBMQ.save_account('write YOUR IBM API TOKEN here')\n", - "\n", - "# Then, execute this cell" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

See the stored account(s)

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "IBMQ.stored_accounts()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Load our account(s)

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "IBMQ.load_accounts()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

See the active account(s)

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "IBMQ.active_accounts()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

See available backends

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "IBMQ.backends()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

See the currently operational real quantum computer(s)

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "IBMQ.backends(operational=True, simulator=False)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

See the least busy real quantum computer

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from qiskit.backends.ibmq import least_busy\n", - "least_busy(IBMQ.backends(simulator=False))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

IBMQ simulator

" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Use the simulator as backend

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "backend = least_busy(IBMQ.backends(simulator=True))\n", - "\n", - "backend.name()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Create a job for the backend

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from qiskit import compile\n", - "\n", - "qobj = compile(circuit, backend=backend, shots=1024)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Execute this job on the simulator

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "job = backend.run(qobj)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Check the result

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "result = job.result()\n", - "counts = result.get_counts()\n", - "print(counts)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

IBMQ real quantum computers (Optional)

\n", - "\n", - "Please read the following part to see IBM's policy for usage for the prototype real quantum computers. [accessed on October 28, 2018]\n", - "

\n", - "
\n", - " Frequently Asked Questions\n", - "
\n", - "https://quantumexperience.ng.bluemix.net/proxy/tutorial/full-user-guide/000-FAQ/000-Frequently_Asked_Questions.html\n", - "\n", - "How many experiments can I run?\n", - "\n", - "You can run as many experiments as you have Units to run; each experiment execution requires between 3 and 5 Units. No Units are required to perform simulations or to recall results of an experiment that was run previously.\n", - "\n", - "What happens when I run out of Units?\n", - "\n", - "You can still run simulations or recall the result of the experiments that have been run previously, but you must wait for the Units to replenish, which happens either once your execution has run off the queue, or 24 hours, whichever is greater.\n", - "
\n", - "\n", - "You can check your Units in your IBM Q Experience account (My Account > Advanced). " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Use the least busy real machine as backend

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "backend_real = least_busy(IBMQ.backends(simulator=False))\n", - "\n", - "backend_real.name()\n", - "\n", - "backend_real.status()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Execute the same job on a real machine

\n", - "\n", - "Depending on the number of pending jobs, it might take for a while to execute our job on the real machine.\n", - "\n", - " If you do not have enough Units, you should wait for 24 hours to execute your quantum program on a real machine. \n", - "\n", - " But, this would not be a problem to complete Bronze, because we use the local simulator for our tasks. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "qobj_real = compile(circuit, backend=backend_real, shots=1024)\n", - "\n", - "job_real = backend_real.run(qobj_real)\n", - "\n", - "job_real.queue_position()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Check the result

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "result_real = job_real.result()\n", - "counts_real = result_real.get_counts()\n", - "print(counts_real)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " You may finish this notebook before getting the outcomes, if it seems to take long time.\n", - "\n", - "You may observe more than two outcomes, different than the simulators. \n", - "\n", - "The expected outcomes '01' and '10' can still be observed more frequently, but we may also observe the unexpected outcomes '00' and '11'. Because, even after a single operation, the prototype quantum computers introduce some errors." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B06_Python_Quick_Reference-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B06_Python_Quick_Reference-checkpoint.ipynb deleted file mode 100755 index 51d166c53..000000000 --- a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B06_Python_Quick_Reference-checkpoint.ipynb +++ /dev/null @@ -1,789 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
\n", - "\tprepared by Abuzer Yakaryilmaz (QuSoft@Riga) | November 09, 2018\n", - "
\n", - "
I have some macros here. If there is a problem with displaying mathematical formulas, please run me to load these macros.
\n", - "$ \\newcommand{\\bra}[1]{\\langle #1|} $\n", - "$ \\newcommand{\\ket}[1]{|#1\\rangle} $\n", - "$ \\newcommand{\\braket}[2]{\\langle #1|#2\\rangle} $\n", - "$ \\newcommand{\\inner}[2]{\\langle #1,#2\\rangle} $\n", - "$ \\newcommand{\\biginner}[2]{\\left\\langle #1,#2\\right\\rangle} $\n", - "$ \\newcommand{\\mymatrix}[2]{\\left( \\begin{array}{#1} #2\\end{array} \\right)} $\n", - "$ \\newcommand{\\myvector}[1]{\\mymatrix{c}{#1}} $\n", - "$ \\newcommand{\\myrvector}[1]{\\mymatrix{r}{#1}} $\n", - "$ \\newcommand{\\mypar}[1]{\\left( #1 \\right)} $\n", - "$ \\newcommand{\\mybigpar}[1]{ \\Big( #1 \\Big)} $\n", - "$ \\newcommand{\\sqrttwo}{\\frac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\dsqrttwo}{\\dfrac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\onehalf}{\\frac{1}{2}} $\n", - "$ \\newcommand{\\donehalf}{\\dfrac{1}{2}} $\n", - "$ \\newcommand{\\hadamard}{ \\mymatrix{rr}{ \\sqrttwo & \\sqrttwo \\\\ \\sqrttwo & -\\sqrttwo }} $\n", - "$ \\newcommand{\\vzero}{\\myvector{1\\\\0}} $\n", - "$ \\newcommand{\\vone}{\\myvector{0\\\\1}} $\n", - "$ \\newcommand{\\vhadamardzero}{\\myvector{ \\sqrttwo \\\\ \\sqrttwo } } $\n", - "$ \\newcommand{\\vhadamardone}{ \\myrvector{ \\sqrttwo \\\\ -\\sqrttwo } } $\n", - "$ \\newcommand{\\myarray}[2]{ \\begin{array}{#1}#2\\end{array}} $\n", - "$ \\newcommand{\\X}{ \\mymatrix{cc}{0 & 1 \\\\ 1 & 0} } $\n", - "$ \\newcommand{\\Z}{ \\mymatrix{rr}{1 & 0 \\\\ 0 & -1} } $\n", - "$ \\newcommand{\\Htwo}{ \\mymatrix{rrrr}{ \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} } } $\n", - "$ \\newcommand{\\CNOT}{ \\mymatrix{cccc}{1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 1 \\\\ 0 & 0 & 1 & 0} } $\n", - "$ \\newcommand{\\norm}[1]{ \\left\\lVert #1 \\right\\rVert } $" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Python: Quick Reference

\n", - "
\n", - "\n", - "
" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "

Variables

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "number = 5 # integer\n", - "real = -3.4 # float\n", - "\n", - "name = 'Asja' # string\n", - "surname = \"Sarkana\" # string\n", - "\n", - "boolean1 = True # Boolean \n", - "boolean1 = False # Boolean " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "

Arithmetic operators

" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Basic operators

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "a = 13\n", - "b = 5\n", - "print(\"a =\",a)\n", - "print(\"b =\",b)\n", - "print()\n", - "\n", - "# basics operators\n", - "print(\"a + b =\",a+b)\n", - "print(\"a - b =\",a-b)\n", - "print(\"a * b =\",a*b)\n", - "print(\"a / b =\",a/b)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Integer division and modulus operators

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "a = 13\n", - "b = 5\n", - "print(\"a =\",a)\n", - "print(\"b =\",b)\n", - "print()\n", - "\n", - "# integer division\n", - "print(\"a//b =\",a//b)\n", - "\n", - "# modulus operator\n", - "print(\"a mod b =\",a % b)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Exponent operator

\n", - "\n", - "number\\*\\*exponent" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "b = 5\n", - "print(\"b =\",b)\n", - "print()\n", - "\n", - "print(\"b*b =\",b**2)\n", - "print(\"b*b*b =\",b**3)\n", - "print(\"sqrt(b)=\",b**0.5)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "

Objects

" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Lists

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# list\n", - "mylist = [10,8,6,4,2] \n", - "\n", - "print(mylist)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Tuple

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# tuple\n", - "mytuple=(1,4,5,'Asja') \n", - "\n", - "print(mytuple)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Dictionary

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# dictionary\n", - "mydictionary = {\n", - " 'name' : \"Asja\",\n", - " 'surname':'Sarkane',\n", - " 'age': 23\n", - "}\n", - "\n", - "print(mydictionary)\n", - "\n", - "print(mydictionary['surname'])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

List of the other objects or variables

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# list of the other objects or variables\n", - "list_of_other_objects =[\n", - " mylist,\n", - " mytuple,\n", - " 3,\n", - " \"Asja\",\n", - " mydictionary\n", - "]\n", - "\n", - "print(list_of_other_objects)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "

Size of an object

\n", - "\n", - "We use the method \"len()\" that takes an object as the input." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# length of a string\n", - "print(len(\"Asja Sarkane\"))\n", - "\n", - "# size of a list\n", - "print(len([1,2,3,4]))\n", - "\n", - "# size of a dictionary\n", - "mydictionary = { 'name' : \"Asja\", 'surname':'Sarkane', 'age': 23}\n", - "print(len(mydictionary))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "

Loops

" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

While-loop

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "i = 10\n", - "while i>0: # while condition(s):\n", - " print(i)\n", - " i = i - 1 " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

For-loop

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for i in range(10): # i is in [0,1,...,9]\n", - " print(i)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for i in range(-5,6): # i is in [-5,-4,...,0,...,4,5]\n", - " print(i)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for i in range(0,23,4): # i is in [0,4,8,12,16,20]\n", - " print(i)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for i in [3,8,-5,11]: \n", - " print(i)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for i in \"Sarkane\":\n", - " print(i)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# dictionary\n", - "mydictionary = {\n", - " 'name' : \"Asja\",\n", - " 'surname':'Sarkane',\n", - " 'age': 23,\n", - "}\n", - "\n", - "for key in mydictionary:\n", - " print(\"key is\",key,\"and its value is\",mydictionary[key])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "

Conditionals

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for a in range(4,7):\n", - " \n", - " # if condition(s)\n", - " if a<5: \n", - " print(a,\"is less than 5\")\n", - " \n", - " # elif conditions(s)\n", - " elif a==5: \n", - " print(a,\"is equal to 5\")\n", - " \n", - " # else\n", - " else:\n", - " print(a,\"is greater than 5\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "

Logical and Boolean operators

" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Logical operator \"and\"

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Logical operator \"and\"\n", - "i = -3\n", - "j = 4\n", - "if i<0 and j > 0: \n", - " print(i,\"is negative AND\",j,\"is positive\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Logical operator \"or\"

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Logical operator \"or\"\n", - "i = -2\n", - "j = 2\n", - "if i==2 or j == 2: \n", - " print(\"i OR j is 2: (\",i,\",\",j,\")\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Logical operator \"not\"

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Logical operator \"not\"\n", - "i = 3\n", - "if not (i==2):\n", - " print(i,\"is NOT equal to 2\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Operator \"equal to\"

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Operator \"equal to\"\n", - "i = -1\n", - "if i == -1:\n", - " print(i,\"is EQUAL TO -1\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Operator \"not equal to\"

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Operator \"not equal to\"\n", - "i = 4\n", - "if i != 3:\n", - " print(i,\"is NOT EQUAL TO 3\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Operator \"less than or equal to\"

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Operator \"not equal to\"\n", - "i = 2\n", - "if i <= 5:\n", - " print(i,\"is LESS THAN OR EQUAL TO 5\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Operator \"greater than or equal to\"

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Operator \"not equal to\"\n", - "i = 5\n", - "if i >= 1:\n", - " print(i,\"is GREATER THAN OR EQUAL TO 3\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "

Double list

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "A =[\n", - " [1,2,3],\n", - " [-2,-4,-6],\n", - " [3,6,9]\n", - "]\n", - "\n", - "# print all\n", - "print(A)\n", - "print()\n", - "\n", - "# print list by list\n", - "for list in A:\n", - " print(list)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "

List operations

" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Concatenation of two lists

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "list1 = [1,2,3]\n", - "list2 = [4,5,6]\n", - "\n", - "#concatenation of two lists\n", - "\n", - "list3 = list1 + list2\n", - "print(list3)\n", - "\n", - "list4 = list2 + list1\n", - "print(list4)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Appending a new element

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "list = [0,1,2]\n", - "\n", - "list.append(3)\n", - "print(list)\n", - "\n", - "list = list + [4]\n", - "print(list)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "

Functions

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def summation_of_integers(n):\n", - " summation = 0\n", - " for integer in range(n+1):\n", - " summation = summation + integer\n", - " return summation\n", - "\n", - "print(summation_of_integers(10))\n", - "print(summation_of_integers(20))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "

Random number

\n", - "\n", - "We can use method \"randrange()\"." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from random import randrange\n", - "\n", - "print(randrange(10),\"is picked randomly between 0 and 9\")\n", - " \n", - "print(randrange(-9,10),\"is picked randomly between -9 and 9\")\n", - "\n", - "print(randrange(0,20,3),\"is picked randomly from the list [0,3,6,9,12,15,18]\")" - ] - } - ], - "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.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B24_One_Bit-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B24_One_Bit-checkpoint.ipynb deleted file mode 100755 index f95288289..000000000 --- a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B24_One_Bit-checkpoint.ipynb +++ /dev/null @@ -1,539 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
\n", - "\tprepared by Abuzer Yakaryilmaz (QuSoft@Riga) | November 07, 2018\n", - "
\n", - "
I have some macros here. If there is a problem with displaying mathematical formulas, please run me to load these macros.
\n", - "$ \\newcommand{\\bra}[1]{\\langle #1|} $\n", - "$ \\newcommand{\\ket}[1]{|#1\\rangle} $\n", - "$ \\newcommand{\\braket}[2]{\\langle #1|#2\\rangle} $\n", - "$ \\newcommand{\\inner}[2]{\\langle #1,#2\\rangle} $\n", - "$ \\newcommand{\\biginner}[2]{\\left\\langle #1,#2\\right\\rangle} $\n", - "$ \\newcommand{\\mymatrix}[2]{\\left( \\begin{array}{#1} #2\\end{array} \\right)} $\n", - "$ \\newcommand{\\myvector}[1]{\\mymatrix{c}{#1}} $\n", - "$ \\newcommand{\\myrvector}[1]{\\mymatrix{r}{#1}} $\n", - "$ \\newcommand{\\mypar}[1]{\\left( #1 \\right)} $\n", - "$ \\newcommand{\\mybigpar}[1]{ \\Big( #1 \\Big)} $\n", - "$ \\newcommand{\\sqrttwo}{\\frac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\dsqrttwo}{\\dfrac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\onehalf}{\\frac{1}{2}} $\n", - "$ \\newcommand{\\donehalf}{\\dfrac{1}{2}} $\n", - "$ \\newcommand{\\hadamard}{ \\mymatrix{rr}{ \\sqrttwo & \\sqrttwo \\\\ \\sqrttwo & -\\sqrttwo }} $\n", - "$ \\newcommand{\\vzero}{\\myvector{1\\\\0}} $\n", - "$ \\newcommand{\\vone}{\\myvector{0\\\\1}} $\n", - "$ \\newcommand{\\vhadamardzero}{\\myvector{ \\sqrttwo \\\\ \\sqrttwo } } $\n", - "$ \\newcommand{\\vhadamardone}{ \\myrvector{ \\sqrttwo \\\\ -\\sqrttwo } } $\n", - "$ \\newcommand{\\myarray}[2]{ \\begin{array}{#1}#2\\end{array}} $\n", - "$ \\newcommand{\\X}{ \\mymatrix{cc}{0 & 1 \\\\ 1 & 0} } $\n", - "$ \\newcommand{\\Z}{ \\mymatrix{rr}{1 & 0 \\\\ 0 & -1} } $\n", - "$ \\newcommand{\\Htwo}{ \\mymatrix{rrrr}{ \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} } } $\n", - "$ \\newcommand{\\CNOT}{ \\mymatrix{cccc}{1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 1 \\\\ 0 & 0 & 1 & 0} } $\n", - "$ \\newcommand{\\norm}[1]{ \\left\\lVert #1 \\right\\rVert } $" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

One Bit

\n", - "\n", - "In daily life, we use decimal number system. It is also called base-10 system, because we have 10 digits:\n", - "\n", - "$ 0,~1,~2,~3,~4,~5,~6,~7,~8, \\mbox{ and } 9 $.\n", - "\n", - "In computer science, on the other hand, the widely used system is binary, which has only two digits:\n", - "\n", - "$ 0 $ and $ 1 $.\n", - "\n", - "One bit (or binary digit) is the basic unit of information used in computer science. \n", - "\n", - "It can also be seen as the smallest \"useful\" memory unit, which has two states named 0 and 1. \n", - "\n", - "One bit can be in (or store) either 0 or 1." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Four operators

\n", - "\n", - "How many different operators can be defined on a single bit?\n", - "\n", - "An operator, depending on the current state of the bit, updates the state of bit (the result may be the same state). \n", - "\n", - "We can apply four different operators to a single bit:\n", - "
    \n", - "
  1. Identity: $ I(0) = 0 $ and $ I(1) = 1 $
  2. \n", - "
  3. Negation: $ NOT(0) = 1 $ and $ NOT(1) = 0 $
  4. \n", - "
  5. Constant (Zero): $ ZERO(0) = 0 $ and $ ZERO(1) = 0 $
  6. \n", - "
  7. Constant (One): $ ONE(0) = 1 $ and $ ONE(1) = 1 $
  8. \n", - "
\n", - "The first operator is called IDENTITY, because it does not change the content/value of the bit.\n", - "\n", - "The second operator is named NOT, bacause it negates (flips) the value of bit. \n", - "\n", - "Remark that 0 and 1 also refers to Boolean values False and True, respectively, and, False is the negation of True, and True is the negation of False.\n", - "\n", - "The third (resp., fourth) operator returns a constant value 0 (resp., 1), whatever the input is." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Table representation

\n", - "\n", - "Let's represent the transition of each operator by a table. \n", - "\n", - "In each table,\n", - "
    \n", - "
  • the header (first row) representing the initial values,
  • \n", - "
  • the first column representing the final values,
  • \n", - "
  • we use 1 if there is a transition between two values, and,
  • \n", - "
  • we use 0 if there is no transition between two values.
  • \n", - "
\n", - "\n", - "The table representation of the identity operator is given below:\n", - "\n", - "$\n", - "I = \\begin{array}{c|cc} & \\mathbf{0} & \\mathbf{1} \\\\ \\hline \\mathbf{0} & 1 & 0 \\\\ \\mathbf{1} & 0 & 1 \\end{array}\n", - "$\n", - "\n", - "The values in bold are the initial and final values of the bits. The non-bold values represent the transitions.\n", - "
    \n", - "
  • The top-left non-bold 1 represents the transtion $ 0 \\rightarrow 0 $.
  • \n", - "
  • The bottom-right non-bold 1 represents the transtion $ 1 \\rightarrow 1 $.
  • \n", - "
  • The top-right non-bold 0 means that there is no transition from 1 to 0.
  • \n", - "
  • The bottom-left non-bold 0 means that there is no transition from 0 to 1.
  • \n", - "
\n", - "The reader may think the values 0 and 1 representing the transitions as True (On) and False (Off), respectively. \n", - "\n", - "Similarly, we can represent the other operators as below:\n", - "\n", - "$\n", - "NOT = \\begin{array}{c|cc} & \\mathbf{0} & \\mathbf{1} \\\\ \\hline \\mathbf{0} & 0 & 1 \\\\ \\mathbf{1} & 1 & 0 \\end{array}\n", - "~~~~~~~~\n", - "ZERO = \\begin{array}{c|cc} & \\mathbf{0} & \\mathbf{1} \\\\ \\hline \\mathbf{0} & 1 & 1 \\\\ \\mathbf{1} & 0 & 0 \\end{array}\n", - "~~~~~~~~\n", - "ONE = \\begin{array}{c|cc} & \\mathbf{0} & \\mathbf{1} \\\\ \\hline \\mathbf{0} & 0 & 0 \\\\ \\mathbf{1} & 1 & 1 \\end{array}\n", - ".\n", - "$" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Task 1

\n", - "\n", - "Convience yourself with the correctness of each table." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Reversibility and Irreversibility

\n", - "\n", - "After applying Identity or NOT operatotor, we can easily determine the initial value by checking the final value. \n", - "
    \n", - "
  • In the case of Identity operator, we simply say the same value.
  • \n", - "
  • In the case of NOT operator, we simply say the other value, i.e., if the final value is 0 (resp., 1), then we say 1 (resp., 0).
  • \n", - "
\n", - "\n", - "However, we cannot know the initial value by checking the final value after applying ZERO or ONE operator. \n", - "\n", - "Based on this observation, we can classify the operators into two types: Reversible and Irreversible.\n", - "
    \n", - "
  • If we can recover the initial value(s) from the final value(s), then the operator is called reversible like Identity and NOT operators.
  • \n", - "
  • If we cannot know the initial value(s) from the final value(s), then the operator is called irreversible like ZERO and ONE operators.
  • \n", - "
\n", - "\n", - " This classification is important, because, as will be seen later, the quantum evolution operators are reversible. \n", - "\n", - "The identity operator does not have any affect on the computation, and so it is not interesting.\n", - "\n", - "But we will widely use NOT operator in our quantum algortihms. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Our first quantum circuit

\n", - "\n", - "For our quantum programs, we will design quantum circuits.\n", - "\n", - "As a warm-up example, here we design a circuit with a single quantum bit.\n", - "\n", - "We also highlight the details on designing quantum circuits along with our codes." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# \n", - "# A quantum circuit is composed by quantum and classical bits.\n", - "#\n", - "\n", - "# here are the objects that we use to create a quantum circuit\n", - "from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit\n", - "\n", - "# we use a quantum register to keep our quantum bits.\n", - "qreg = QuantumRegister(1) # in this example we will use a single quantum bit\n", - "\n", - "# To get an information from a quantum bit, it must be measured. (More details will appear.)\n", - "# The measurement result is stored classically.\n", - "# Therefore, we also use a classical regiser with classical bits\n", - "creg = ClassicalRegister(1) # in this example we will use a single classical bit\n", - "\n", - "# now we can define our quantum circuit\n", - "# it is composed by a quantum and a classical register\n", - "mycircuit = QuantumCircuit(qreg,creg)\n", - "\n", - "# we apply operators on quantum bits\n", - "# operators are also called as gates\n", - "# we apply NOT operator represented as \"x\"\n", - "# operator is a part of the circuit, and we should specify the quantum bit as the parameter\n", - "mycircuit.x(qreg[0]) # (quantum) bits are enumerated starting from 0\n", - "# NOT operator or x-gate is applied to the first qubit of the quantum register\n", - "\n", - "# let's run our codes until now, and then draw our circuit\n", - "print(\"Everything looks fine, let's continue ...\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# we use matplotlib_circuit_drawer\n", - "# we shortly refer it as \"drawer\" in our codes\n", - "from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer\n", - "\n", - "# let's draw our circuit now \n", - "drawer(mycircuit)\n", - "# re-execute me if you DO NOT see the circuit diagram" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Congratulations! if you see your diagram :-)\n", - "\n", - " Remak: Qiskit has its own counters to enumerate the objects ($ q2_0 $, $ c2_0 $, etc.). \n", - "
    \n", - "
  • They might be useful for debugging, but currently you can simply discard this part.\n", - "
  • You may also notice that when you re-run the same codes, the index of objects will be increased.\n", - "
\n", - "\n", - "The value of the quantum bit is 0 at the beginning. Technically, we denote is as $ \\ket{0} $, called ket-notation.\n", - "\n", - "The value of the classical bit is also 0 at the beginning. \n", - "\n", - "Classical or quantum, each bit is represented as a straight line. You may think of it as a wire.\n", - "\n", - "The x-gate is shown as a square.\n", - "\n", - "The value of the quantum bit is expected to be $ \\ket{1} $ after the operator.\n", - "\n", - "Let's measure the first qubit (define a mesurement operator), and then execute our circuit and see the result." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# measurement is defined by associating a quantum bit to a classical bit\n", - "mycircuit.measure(qreg[0],creg[0])\n", - "# the result will be stored in the classical bit\n", - "\n", - "print(\"Everything looks fine, let's continue ...\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# let's draw the circuit again to see how the measurement is defined\n", - "drawer(mycircuit)\n", - "# reexecute me if you DO NOT see the circuit diagram" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# we are done with design of our circuit\n", - "# now we can execute it\n", - "# we execute quantum circuits many times (WHY?)\n", - "\n", - "# we use method \"execute\" and object \"Aer\" from qiskit library\n", - "from qiskit import execute, Aer\n", - "\n", - "# we create a job object for execution of the circuit\n", - "# there are three parameters\n", - "# 1. mycircuit\n", - "# 2. beckend on which it will be executed: we will use local simulator\n", - "# 3. how_many_times will it be executed, let's pick it as 1024\n", - "job = execute(mycircuit,Aer.get_backend('qasm_simulator'),shots=1024)\n", - "\n", - "# we can get the result of the outcome as follows\n", - "counts = job.result().get_counts(mycircuit)\n", - "print(counts)\n", - "\n", - "# usually quantum programs produce probabilistic outcomes " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We expect to see 1 in each execution, and so the output should be $ \\{\\mbox{'1'}:~1024\\} $. \n", - "\n", - "That is, the outcome 1 is measured 1024 times.\n", - "\n", - "The output is composed by pairs, and each pair showing the measurement outcome and how many times it was measured. \n", - "
\n", - "For example, if the output is $ \\{\\mbox{'0': 500, '1': 524}\\} $, then we know that the outcome 0 is measured 500 times and the outcome 1 is measured 524 times. \n", - "\n", - " Quantum programs usually give probabilistic outcomes. \n", - " \n", - "Therefore, we should execute them many times to get more reliable outcomes. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

My second quantum circuit

\n", - "\n", - "Let's create a quantum circuit with four quantum bits. \n", - "\n", - "We use almost the same code with small modifications. \n", - "\n", - "Our comments explain only the modifications." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# \n", - "# My second quantum circuit\n", - "#\n", - "\n", - "# we import all at once\n", - "from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer\n", - "from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer\n", - "\n", - "# we will use 4 quantum bits and 4 classical bits\n", - "qreg2 = QuantumRegister(4)\n", - "creg2 = ClassicalRegister(4)\n", - "\n", - "mycircuit2 = QuantumCircuit(qreg2,creg2)\n", - "\n", - "# I will apply x-gate to the first quantum bit twice\n", - "mycircuit2.x(qreg2[0])\n", - "mycircuit2.x(qreg2[0])\n", - "\n", - "# I will apply x-gate to the fourth quantum bit once\n", - "mycircuit2.x(qreg2[3])\n", - "\n", - "# I will apply x-gate to the third quantum bit three times\n", - "mycircuit2.x(qreg2[2])\n", - "mycircuit2.x(qreg2[2])\n", - "mycircuit2.x(qreg2[2])\n", - "\n", - "# I will apply x-gate to the second quantum bit four times\n", - "mycircuit2.x(qreg2[1])\n", - "mycircuit2.x(qreg2[1])\n", - "mycircuit2.x(qreg2[1])\n", - "mycircuit2.x(qreg2[1])\n", - "\n", - "# if the size of quantum and classical registers are the same, we can define measurements with a single line code\n", - "mycircuit2.measure(qreg2,creg2)\n", - "# then each quantum bit and classical bit is associated with respect to their indices\n", - "\n", - "# let's run our codes until now, and then draw our circuit\n", - "\n", - "print(\"Everything looks fine, let's continue ...\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "drawer(mycircuit2)\n", - "# re-execute me if you DO NOT see the circuit diagram" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Task 2

\n", - "\n", - "Guess the outcome by checking the circuit.\n", - "\n", - "Then, compare your guess with the result obtained after executing our circuit 500 times." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "job = execute(mycircuit2,Aer.get_backend('qasm_simulator'),shots=500)\n", - "counts = job.result().get_counts(mycircuit2)\n", - "print(counts)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

An important technical note:

\n", - "\n", - "In Qiskit the outcomes are read from the classical register bottom to top \n", - "$$ creg[3],~creg[2],~creg[1],~creg[0] $$\n", - "and so, we see the reverse of what we expected. \n", - "\n", - "If you think the overall output as a single number, then it is assumed that the upper bits are the least significant bits." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Reverse the output

\n", - "\n", - "Let's write a method to print the reverse the outcomes as we expected.\n", - "\n", - "You may use this method later." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def print_outcomes(counts): # takes a dictionary variable\n", - " for outcome in counts: # for each key-value in dictionary\n", - " reverse_outcome = ''\n", - " for i in outcome: # each string can be considered as a list of characters\n", - " reverse_outcome = i + reverse_outcome # each new symbol comes before the old symbol(s)\n", - " print(reverse_outcome,\"is observed\",counts[outcome],\"times\")\n", - "\n", - "job = execute(mycircuit2,Aer.get_backend('qasm_simulator'),shots=1024)\n", - "counts = job.result().get_counts(mycircuit2) # counts is a dictionary object in python\n", - "print_outcomes(counts)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Pick a random number

\n", - "\n", - "In your first circuit design task, you will be asked to apply x-gate randomly.\n", - "\n", - "Here is one of the method to pick a random number in python." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from random import randrange\n", - "n = 20\n", - "r=randrange(n) # pick a number from the list {0,1,...,n-1}\n", - "print(r)\n", - "\n", - "# test this method by using a loop\n", - "for i in range(10):\n", - " print(randrange(n))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Task 3

\n", - "\n", - "Design a quantum circuit with 10 quantum bits and 10 classical bits.\n", - "\n", - "For each quantum bit, flip a coin, and apply x-gate if the outcome is head.\n", - "\n", - "Measure your quantum bits.\n", - "\n", - "Execute your circuit 128 times.\n", - "\n", - "Repeat this task as mush as you want, and enjoy your random choices." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#\n", - "# your solution is here\n", - "#\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "click for our solution" - ] - } - ], - "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.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B26_Coin_Flip-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B26_Coin_Flip-checkpoint.ipynb deleted file mode 100755 index a124c87b4..000000000 --- a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B26_Coin_Flip-checkpoint.ipynb +++ /dev/null @@ -1,212 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
\n", - "\tprepared by Abuzer Yakaryilmaz (QuSoft@Riga) | November 07, 2018\n", - "
\n", - "
I have some macros here. If there is a problem with displaying mathematical formulas, please run me to load these macros.
\n", - "$ \\newcommand{\\bra}[1]{\\langle #1|} $\n", - "$ \\newcommand{\\ket}[1]{|#1\\rangle} $\n", - "$ \\newcommand{\\braket}[2]{\\langle #1|#2\\rangle} $\n", - "$ \\newcommand{\\inner}[2]{\\langle #1,#2\\rangle} $\n", - "$ \\newcommand{\\biginner}[2]{\\left\\langle #1,#2\\right\\rangle} $\n", - "$ \\newcommand{\\mymatrix}[2]{\\left( \\begin{array}{#1} #2\\end{array} \\right)} $\n", - "$ \\newcommand{\\myvector}[1]{\\mymatrix{c}{#1}} $\n", - "$ \\newcommand{\\myrvector}[1]{\\mymatrix{r}{#1}} $\n", - "$ \\newcommand{\\mypar}[1]{\\left( #1 \\right)} $\n", - "$ \\newcommand{\\mybigpar}[1]{ \\Big( #1 \\Big)} $\n", - "$ \\newcommand{\\sqrttwo}{\\frac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\dsqrttwo}{\\dfrac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\onehalf}{\\frac{1}{2}} $\n", - "$ \\newcommand{\\donehalf}{\\dfrac{1}{2}} $\n", - "$ \\newcommand{\\hadamard}{ \\mymatrix{rr}{ \\sqrttwo & \\sqrttwo \\\\ \\sqrttwo & -\\sqrttwo }} $\n", - "$ \\newcommand{\\vzero}{\\myvector{1\\\\0}} $\n", - "$ \\newcommand{\\vone}{\\myvector{0\\\\1}} $\n", - "$ \\newcommand{\\vhadamardzero}{\\myvector{ \\sqrttwo \\\\ \\sqrttwo } } $\n", - "$ \\newcommand{\\vhadamardone}{ \\myrvector{ \\sqrttwo \\\\ -\\sqrttwo } } $\n", - "$ \\newcommand{\\myarray}[2]{ \\begin{array}{#1}#2\\end{array}} $\n", - "$ \\newcommand{\\X}{ \\mymatrix{cc}{0 & 1 \\\\ 1 & 0} } $\n", - "$ \\newcommand{\\Z}{ \\mymatrix{rr}{1 & 0 \\\\ 0 & -1} } $\n", - "$ \\newcommand{\\Htwo}{ \\mymatrix{rrrr}{ \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} } } $\n", - "$ \\newcommand{\\CNOT}{ \\mymatrix{cccc}{1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 1 \\\\ 0 & 0 & 1 & 0} } $\n", - "$ \\newcommand{\\norm}[1]{ \\left\\lVert #1 \\right\\rVert } $" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Coin Flip: A Probabilistic Bit

\n", - "\n", - "

A fair coin

\n", - "\n", - "A coin has two sides: Head and Tail.\n", - "\n", - "After flipping a coin, we can get a Head or Tail. We can represent these two cases by a single bit:\n", - "
    \n", - "
  • 0 represents Head
  • \n", - "
  • 1 represents Tail
  • \n", - "
" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Flipping a fair coin

\n", - "\n", - "If our coin is fair, then the probability of obtaining a Head or Tail is equal:\n", - "\n", - "$ p= \\dfrac{1}{2} = 0.5 $.\n", - "\n", - "Coin-flipping can be defined as an operator:\n", - "
    \n", - "
  • $ FairCoin(Head) = \\frac{1}{2} Head + \\frac{1}{2}Tail $
  • \n", - "
  • $ FairCoin(Tail) = \\frac{1}{2} Head + \\frac{1}{2}Tail $
  • \n", - "
\n", - "$\n", - "FairCoin = \\begin{array}{c|cc} & \\mathbf{Head} & \\mathbf{Tail} \\\\ \\hline \\mathbf{Head} & \\dfrac{1}{2} & \\dfrac{1}{2} \\\\ \\mathbf{Tail} & \\dfrac{1}{2} & \\dfrac{1}{2} \\end{array}\n", - "$\n", - "\n", - "Or, by using 0 and 1:\n", - "\n", - "$\n", - "FairCoin = \\begin{array}{c|cc} & \\mathbf{0} & \\mathbf{1} \\\\ \\hline \\mathbf{0} & \\dfrac{1}{2} & \\dfrac{1}{2} \\\\ \\mathbf{1} & \\dfrac{1}{2} & \\dfrac{1}{2} \\end{array}\n", - "$" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Task 1: Simulating FairCoin in Python

\n", - "\n", - "Flip a fair coin 100 times. Calcuate the total number of heads and tails, and then compare them.\n", - "\n", - "Do the same experiment 1000 times.\n", - "\n", - "Do the same experiment 10,000 times.\n", - "\n", - "Do the same experiment 100,000 times.\n", - "\n", - "Do your results get close to the ideal case (the numbers of heads and tails are the same)?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# first we import a procedure for picking a random number\n", - "from random import randrange\n", - "# randrange(m) returns a number randomly from the list {0,1,...,m-1}\n", - "# randrange(10) returns a number randomly from the list {0,1,...,9}\n", - "# here is an example\n", - "r=randrange(5)\n", - "print(\"I picked a random number between 0 and 4, which is \",r)\n", - "\n", - "#\n", - "# your solution is here\n", - "#\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "click for our solution" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Flipping a biased coin

\n", - "\n", - "Our coin may have a bias. \n", - "\n", - "For example, the probability of getting head is greater than the probability of getting tail.\n", - "\n", - "Here is an example:\n", - "\n", - "$\n", - "BiasedCoin = \\begin{array}{c|cc} & \\mathbf{Head} & \\mathbf{Tail} \\\\ \\hline \\mathbf{Head} & 0.6 & 0.6 \\\\ \\mathbf{Tail} & 0.4 & 0.4 \\end{array}\n", - "$\n", - "\n", - "Or, by using 0 and 1 as the states:\n", - "\n", - "$\n", - "BiasedCoin = \\begin{array}{c|cc} & \\mathbf{0} & \\mathbf{1} \\\\ \\hline \\mathbf{0} & 0.6 & 0.6\\\\ \\mathbf{1} & 0.4 & 0.4 \\end{array}\n", - "$" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Task 2: Simulating BiasedCoin in Python

\n", - "\n", - "Flip the following biased coin 100 times. Calcuate the total number of heads and tails, and then compare them.\n", - "\n", - "$\n", - "BiasedCoin = \\begin{array}{c|cc} & \\mathbf{Head} & \\mathbf{Tail} \\\\ \\hline \\mathbf{Head} & 0.6 & 0.6 \\\\ \\mathbf{Tail} & 0.4 & 0.4 \\end{array}\n", - "$\n", - "\n", - "\n", - "Do the same experiment 1000 times.\n", - "\n", - "Do the same experiment 10,000 times.\n", - "\n", - "Do the same experiment 100,000 times.\n", - "\n", - "Do your results get close to the ideal case $ \\mypar{ \\dfrac{ \\mbox{# of heads} }{ \\mbox{# of tails} } = \\dfrac{0.6}{0.4} = 1.50000000 } $?" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "click for our solution" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# first we import a procedure for picking a random number\n", - "from random import randrange\n", - "#\n", - "# your solution is here\n", - "#\n" - ] - } - ], - "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.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B28_Coin_Flip_Game-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B28_Coin_Flip_Game-checkpoint.ipynb deleted file mode 100755 index a882167c3..000000000 --- a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B28_Coin_Flip_Game-checkpoint.ipynb +++ /dev/null @@ -1,221 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
\n", - "\tprepared by Abuzer Yakaryilmaz (QuSoft@Riga) | November 07, 2018\n", - "
\n", - "
I have some macros here. If there is a problem with displaying mathematical formulas, please run me to load these macros.
\n", - "$ \\newcommand{\\bra}[1]{\\langle #1|} $\n", - "$ \\newcommand{\\ket}[1]{|#1\\rangle} $\n", - "$ \\newcommand{\\braket}[2]{\\langle #1|#2\\rangle} $\n", - "$ \\newcommand{\\inner}[2]{\\langle #1,#2\\rangle} $\n", - "$ \\newcommand{\\biginner}[2]{\\left\\langle #1,#2\\right\\rangle} $\n", - "$ \\newcommand{\\mymatrix}[2]{\\left( \\begin{array}{#1} #2\\end{array} \\right)} $\n", - "$ \\newcommand{\\myvector}[1]{\\mymatrix{c}{#1}} $\n", - "$ \\newcommand{\\myrvector}[1]{\\mymatrix{r}{#1}} $\n", - "$ \\newcommand{\\mypar}[1]{\\left( #1 \\right)} $\n", - "$ \\newcommand{\\mybigpar}[1]{ \\Big( #1 \\Big)} $\n", - "$ \\newcommand{\\sqrttwo}{\\frac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\dsqrttwo}{\\dfrac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\onehalf}{\\frac{1}{2}} $\n", - "$ \\newcommand{\\donehalf}{\\dfrac{1}{2}} $\n", - "$ \\newcommand{\\hadamard}{ \\mymatrix{rr}{ \\sqrttwo & \\sqrttwo \\\\ \\sqrttwo & -\\sqrttwo }} $\n", - "$ \\newcommand{\\vzero}{\\myvector{1\\\\0}} $\n", - "$ \\newcommand{\\vone}{\\myvector{0\\\\1}} $\n", - "$ \\newcommand{\\vhadamardzero}{\\myvector{ \\sqrttwo \\\\ \\sqrttwo } } $\n", - "$ \\newcommand{\\vhadamardone}{ \\myrvector{ \\sqrttwo \\\\ -\\sqrttwo } } $\n", - "$ \\newcommand{\\myarray}[2]{ \\begin{array}{#1}#2\\end{array}} $\n", - "$ \\newcommand{\\X}{ \\mymatrix{cc}{0 & 1 \\\\ 1 & 0} } $\n", - "$ \\newcommand{\\Z}{ \\mymatrix{rr}{1 & 0 \\\\ 0 & -1} } $\n", - "$ \\newcommand{\\Htwo}{ \\mymatrix{rrrr}{ \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} } } $\n", - "$ \\newcommand{\\CNOT}{ \\mymatrix{cccc}{1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 1 \\\\ 0 & 0 & 1 & 0} } $\n", - "$ \\newcommand{\\norm}[1]{ \\left\\lVert #1 \\right\\rVert } $" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

A Game with two biased coins

\n", - "\n", - "Your friend Asja has one euro and one cent. \n", - "\n", - "Both coins are biased, and the probabilities of getting heads and tails are as follows:\n", - "
    \n", - "
  • one euro: head with probability $ 0.6 $ and tail with probability $ 0.4 $.
  • \n", - "
  • one cent: head with probability $ 0.3 $ and tail with probability $ 0.7 $.
  • \n", - "
\n", - "\n", - "Asja flips her coins based on the following protocol: \n", - "
    \n", - "
  1. she starts with flipping one euro,
  2. \n", - "
  3. whenever she gets a head, she flips one euro, and
  4. \n", - "
  5. whenever she gets a tail, she flips one cent.
  6. \n", - "
\n", - "\n", - "By using a single bit, we summarize all possible transitions of this game as follows:\n", - "\n", - "$\n", - "GameCoins = \\begin{array}{c|cc} & \\mathbf{Head} & \\mathbf{Tail} \\\\ \\hline \\mathbf{Head} & 0.6 & 0.3\\\\ \\mathbf{Tail} & 0.4 & 0.7 \\end{array} = \\begin{array}{c|cc} & \\mathbf{0} & \\mathbf{1} \\\\ \\hline \\mathbf{0} & 0.6 & 0.3 \\\\ \\mathbf{1} & 0.4 & 0.7 \\end{array}\n", - "$" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Task 1: Convience yourself

\n", - "\n", - "Please convience yourself about the correctness of transitions given in the table.\n", - "\n", - " Remark that there is no difference between getting head from one euro or getting head from one cent.\n", - " \n", - "Therefore, one bit is enough to represent all transitions.\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Tracing Asja's three coin tosses

\n", - "\n", - "Suppose that Asja secretly tosses her coins based on the defined protocol.\n", - "\n", - "By using python, we can calculate the probabilities of Asja getting head and tail after three coin tosses.\n", - "\n", - "Remark: In the previous two tasks, the ideal ratio was easy to calculate. We did our experiments and compared our results with the ideal ratio. \n", - "\n", - "Here we will calculate the exact probabilities (the ideal ratio) by using python. (We will not do experiment.)\n", - "\n", - "\n", - "We present our solution step by step." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#\n", - "# OUR SOLUTION\n", - "#\n", - "\n", - "# initial case\n", - "# We assume that the probability of getting head is 1 at the beginning,\n", - "# because Asja will start with one euro.\n", - "prob_head = 1\n", - "prob_tail = 0\n", - "\n", - "\n", - "#\n", - "# first coin-flip\n", - "#\n", - "\n", - "# if the last result was head\n", - "new_prob_head_from_head = prob_head * 0.6\n", - "new_prob_tail_from_head = prob_head * 0.4\n", - "\n", - "# if the last result was tail\n", - "# we know that prob_tail is 0 at the beginning \n", - "# but we still keep these two lines to have the same code for each iteration\n", - "new_prob_head_from_tail = prob_tail * 0.3\n", - "new_prob_tail_from_tail = prob_tail * 0.7\n", - "\n", - "# update the probabilities at the end of coin toss\n", - "prob_head = new_prob_head_from_head + new_prob_head_from_tail\n", - "prob_tail = new_prob_tail_from_head + new_prob_tail_from_tail\n", - "\n", - "#\n", - "# second coin-flip\n", - "#\n", - "# we do the same calculations\n", - "\n", - "new_prob_head_from_head = prob_head * 0.6\n", - "new_prob_tail_from_head = prob_head * 0.4\n", - "\n", - "new_prob_head_from_tail = prob_tail * 0.3\n", - "new_prob_tail_from_tail = prob_tail * 0.7\n", - "\n", - "prob_head = new_prob_head_from_head + new_prob_head_from_tail\n", - "prob_tail = new_prob_tail_from_head + new_prob_tail_from_tail\n", - "\n", - "#\n", - "# third coin-flip\n", - "#\n", - "# we do the same calculations\n", - "\n", - "new_prob_head_from_head = prob_head * 0.6\n", - "new_prob_tail_from_head = prob_head * 0.4\n", - "\n", - "new_prob_head_from_tail = prob_tail * 0.3\n", - "new_prob_tail_from_tail = prob_tail * 0.7\n", - "\n", - "prob_head = new_prob_head_from_head + new_prob_head_from_tail\n", - "prob_tail = new_prob_tail_from_head + new_prob_tail_from_tail\n", - "\n", - "# print prob_head and prob_tail\n", - "print(\"the probability of getting head\",prob_head)\n", - "print(\"the probability of getting tail\",prob_tail)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Task 2: Tracing ten biased coin tosses

\n", - "\n", - "By using python, calculate the probabilities of Asja getting head and tail after 10 coin tosses.\n", - "\n", - "$\n", - "GameCoins = \\begin{array}{c|cc} & \\mathbf{Head} & \\mathbf{Tail} \\\\ \\hline \\mathbf{Head} & 0.6 & 0.3\\\\ \\mathbf{Tail} & 0.4 & 0.7 \\end{array} = \\begin{array}{c|cc} & \\mathbf{0} & \\mathbf{1} \\\\ \\hline \\mathbf{0} & 0.6 & 0.3 \\\\ \\mathbf{1} & 0.4 & 0.7 \\end{array}\n", - "$\n", - "\n", - "Please use a loop in your solution." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#\n", - "# your solution is here\n", - "#\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "click for our solution" - ] - } - ], - "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.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B32_Probabilistic_States-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B32_Probabilistic_States-checkpoint.ipynb deleted file mode 100755 index 895dbba0c..000000000 --- a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B32_Probabilistic_States-checkpoint.ipynb +++ /dev/null @@ -1,260 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
\n", - "\tprepared by Abuzer Yakaryilmaz (QuSoft@Riga) | November 07, 2018\n", - "
\n", - "
I have some macros here. If there is a problem with displaying mathematical formulas, please run me to load these macros.
\n", - "$ \\newcommand{\\bra}[1]{\\langle #1|} $\n", - "$ \\newcommand{\\ket}[1]{|#1\\rangle} $\n", - "$ \\newcommand{\\braket}[2]{\\langle #1|#2\\rangle} $\n", - "$ \\newcommand{\\inner}[2]{\\langle #1,#2\\rangle} $\n", - "$ \\newcommand{\\biginner}[2]{\\left\\langle #1,#2\\right\\rangle} $\n", - "$ \\newcommand{\\mymatrix}[2]{\\left( \\begin{array}{#1} #2\\end{array} \\right)} $\n", - "$ \\newcommand{\\myvector}[1]{\\mymatrix{c}{#1}} $\n", - "$ \\newcommand{\\myrvector}[1]{\\mymatrix{r}{#1}} $\n", - "$ \\newcommand{\\mypar}[1]{\\left( #1 \\right)} $\n", - "$ \\newcommand{\\mybigpar}[1]{ \\Big( #1 \\Big)} $\n", - "$ \\newcommand{\\sqrttwo}{\\frac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\dsqrttwo}{\\dfrac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\onehalf}{\\frac{1}{2}} $\n", - "$ \\newcommand{\\donehalf}{\\dfrac{1}{2}} $\n", - "$ \\newcommand{\\hadamard}{ \\mymatrix{rr}{ \\sqrttwo & \\sqrttwo \\\\ \\sqrttwo & -\\sqrttwo }} $\n", - "$ \\newcommand{\\vzero}{\\myvector{1\\\\0}} $\n", - "$ \\newcommand{\\vone}{\\myvector{0\\\\1}} $\n", - "$ \\newcommand{\\vhadamardzero}{\\myvector{ \\sqrttwo \\\\ \\sqrttwo } } $\n", - "$ \\newcommand{\\vhadamardone}{ \\myrvector{ \\sqrttwo \\\\ -\\sqrttwo } } $\n", - "$ \\newcommand{\\myarray}[2]{ \\begin{array}{#1}#2\\end{array}} $\n", - "$ \\newcommand{\\X}{ \\mymatrix{cc}{0 & 1 \\\\ 1 & 0} } $\n", - "$ \\newcommand{\\Z}{ \\mymatrix{rr}{1 & 0 \\\\ 0 & -1} } $\n", - "$ \\newcommand{\\Htwo}{ \\mymatrix{rrrr}{ \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} } } $\n", - "$ \\newcommand{\\CNOT}{ \\mymatrix{cccc}{1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 1 \\\\ 0 & 0 & 1 & 0} } $\n", - "$ \\newcommand{\\norm}[1]{ \\left\\lVert #1 \\right\\rVert } $" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Probabilistic States

" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Suppose that Asja flips a fair coin secretly.\n", - "\n", - "Because we do not see the result, our information about the outcome will be probabilistic:\n", - "\n", - "$\\rightarrow$ The result is Head with probability $0.5$ and the result is Tail with probability $0.5$.\n", - "\n", - "If the coin has a bias $ \\dfrac{Pr(Head)}{Pr(Tail)} = \\dfrac{3}{1}$, then our information about the outcome is as follows:\n", - "\n", - "$\\rightarrow$ The result is Head with probability $ 0.75 $ and the result is Tail with probability $ 0.25 $." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Solution: The probability of getting Head is three times of the probability of getting Tail.\n", - "
    \n", - "
  • The total probability is 1.
  • \n", - "
  • We divide 1 into four parts (three parts for Head and one part is for Tail),\n", - "
  • $ \\dfrac{1}{4} = 0.25$,
  • \n", - "
  • and then give three parts for Head ($0.75$) and one part for Tail ($0.25$).
  • \n", - "
" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Listing probabilities as a column

\n", - "\n", - "We have two different outcomes: Head (0) and Tail (1).\n", - "\n", - "Then, we can use a column of size 2 to hold the probabilities of getting Head and getting Tail.\n", - "\n", - "For the fair coin, our information after the coin-flip is $ \\myvector{0.5 \\\\ 0.5} $. \n", - "\n", - "For the biased coin, it is $ \\myvector{0.75 \\\\ 0.25} $.\n", - "\n", - "The first entry refers to the probability of getting Head, and the second entry refers to the probability of getting Tail.\n", - "\n", - " $ \\myvector{0.5 \\\\ 0.5} $ and $ \\myvector{0.75 \\\\ 0.25} $ are examples of 2-dimensional (column) vectors." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Task 1

\n", - "\n", - "Suppose that Balvis secretly flips a coin having bias $ \\dfrac{Pr(Head)}{Pr(Tail)} = \\dfrac{1}{4}$.\n", - "\n", - "Represent your information about the outcome as a column vector." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Task 2

\n", - "\n", - "Suppose that Fyodor secretly rolls a loaded (tricky) dice with the bias \n", - "\n", - "$$ Pr(1):Pr(2):Pr(3):Pr(4):Pr(5):Pr(6) = 7:5:4:2:6:1 . $$\n", - "\n", - "Represent your information on the result as a column vector. Remark that the size of your column should be 6.\n", - "\n", - "You may use python for your calculations." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#\n", - "# You may use python for your calculations.\n", - "#\n", - "all_portions = [7,5,4,2,6,1];\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "click for our solution" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Vector representation

\n", - "\n", - "Suppose that we have a system with 4 distiguishable states: $ s_1 $, $s_2 $, $s_3$, and $s_4$. \n", - "\n", - "We expect the system to be in one of them at any moment. \n", - "\n", - "By using the language of probability, we can also say that the system is in one of the states with probability 1, and in any other state with probabilty 0. \n", - "\n", - "Then, by using our column representation, we can show each state as a column vector:\n", - "\n", - "$$\n", - " s_1 = \\myvector{1\\\\ 0 \\\\ 0 \\\\ 0}, s_2 = \\myvector{0 \\\\ 1 \\\\ 0 \\\\ 0}, s_3 = \\myvector{0 \\\\ 0 \\\\ 1 \\\\ 0}, \n", - " \\mbox{ and } s_4 = \\myvector{0 \\\\ 0 \\\\ 0 \\\\ 1}.\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This representation helps us to represent our knowledge on a system when it is in more than one state with certain probabilities. \n", - "\n", - "Remember the case in which the coins are tossed secretly. \n", - "\n", - "For example, suppose that the system is in state $ s_1 $, $ s_2 $, $ s_3 $, and $ s_4 $ with probabilities $ 0.20 $, $ 0.25 $, $ 0.40 $, and $ 0.15 $, respectively. \n", - "\n", - "(The total probability should be 1, i.e. $ 0.20+0.25+0.40+0.15 = 1.00 $)\n", - "\n", - "Then, we can say that the system is in the following probabilistic state:\n", - "$$\n", - " \\myvector{ 0.20 \\\\ 0.25 \\\\ 0.40 \\\\ 0.15 },\n", - "$$\n", - "where the summation of entries must be 1." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Thus, we can show all information as a single object. \n", - "\n", - "Nicely, this probabilistic state can also be written as the following summation:\n", - "\n", - "$$\n", - " 0.20 \\cdot \\myvector{1\\\\ 0 \\\\ 0 \\\\ 0} + 0.25 \\cdot \\myvector{0\\\\ 1 \\\\ 0 \\\\ 0} + 0.40 \\cdot \\myvector{0\\\\ 0 \\\\ 1 \\\\ 0} + 0.15 \\cdot \\myvector{0\\\\ 0 \\\\ 0 \\\\ 1} = \\myvector{0.20\\\\ 0 \\\\ 0 \\\\ 0} + \\myvector{0\\\\ 0.25 \\\\ 0 \\\\ 0} + \\myvector{0\\\\ 0 \\\\0.40 \\\\ 0} + \\myvector{0\\\\ 0 \\\\ 0 \\\\ 0.15 } = \\myvector{ 0.20 \\\\ 0.25 \\\\ 0.40 \\\\ 0.15 }.\n", - "$$\n", - "\n", - "Here we use two basic arithmetic rules about the vectors:\n", - "
    \n", - "
  1. when a vector is multiplied with a number, then each entry of the vector is multiplied with this number, and,
  2. \n", - "
  3. when two or more vectors are added up, the summation is done on the same entries." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Task 3

    \n", - "\n", - "Verify the following equality.\n", - "\n", - "$$\n", - " 2 \\cdot \\mymatrix{r}{1\\\\-2\\\\3\\\\0} - 3 \\cdot \\mymatrix{r}{0\\\\4\\\\1\\\\-1} = \\mymatrix{r}{2 \\\\ -16 \\\\ 3 \\\\ 3}\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Task 4

    \n", - "\n", - "For a system with 4 states, randomly create a probabilistic state, and print its entries, e.g., $ 0.16~~0.17~~0.02~~0.65 $.\n", - "\n", - "You may pick your random numbers between 0 and 100 (or 1000), and then divide each by 100 (or 1000) to represent it as a probability." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from random import randrange\n", - "\n", - "#\n", - "# your solution is here\n", - "#\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "click for our solution" - ] - } - ], - "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.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B46_Quantum_State-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B46_Quantum_State-checkpoint.ipynb deleted file mode 100755 index 1f84b1b25..000000000 --- a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B46_Quantum_State-checkpoint.ipynb +++ /dev/null @@ -1,212 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\tprepared by Abuzer Yakaryilmaz (QuSoft@Riga) | November 07, 2018\n", - "
    \n", - "
    I have some macros here. If there is a problem with displaying mathematical formulas, please run me to load these macros.
    \n", - "$ \\newcommand{\\bra}[1]{\\langle #1|} $\n", - "$ \\newcommand{\\ket}[1]{|#1\\rangle} $\n", - "$ \\newcommand{\\braket}[2]{\\langle #1|#2\\rangle} $\n", - "$ \\newcommand{\\inner}[2]{\\langle #1,#2\\rangle} $\n", - "$ \\newcommand{\\biginner}[2]{\\left\\langle #1,#2\\right\\rangle} $\n", - "$ \\newcommand{\\mymatrix}[2]{\\left( \\begin{array}{#1} #2\\end{array} \\right)} $\n", - "$ \\newcommand{\\myvector}[1]{\\mymatrix{c}{#1}} $\n", - "$ \\newcommand{\\myrvector}[1]{\\mymatrix{r}{#1}} $\n", - "$ \\newcommand{\\mypar}[1]{\\left( #1 \\right)} $\n", - "$ \\newcommand{\\mybigpar}[1]{ \\Big( #1 \\Big)} $\n", - "$ \\newcommand{\\sqrttwo}{\\frac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\dsqrttwo}{\\dfrac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\onehalf}{\\frac{1}{2}} $\n", - "$ \\newcommand{\\donehalf}{\\dfrac{1}{2}} $\n", - "$ \\newcommand{\\hadamard}{ \\mymatrix{rr}{ \\sqrttwo & \\sqrttwo \\\\ \\sqrttwo & -\\sqrttwo }} $\n", - "$ \\newcommand{\\vzero}{\\myvector{1\\\\0}} $\n", - "$ \\newcommand{\\vone}{\\myvector{0\\\\1}} $\n", - "$ \\newcommand{\\vhadamardzero}{\\myvector{ \\sqrttwo \\\\ \\sqrttwo } } $\n", - "$ \\newcommand{\\vhadamardone}{ \\myrvector{ \\sqrttwo \\\\ -\\sqrttwo } } $\n", - "$ \\newcommand{\\myarray}[2]{ \\begin{array}{#1}#2\\end{array}} $\n", - "$ \\newcommand{\\X}{ \\mymatrix{cc}{0 & 1 \\\\ 1 & 0} } $\n", - "$ \\newcommand{\\Z}{ \\mymatrix{rr}{1 & 0 \\\\ 0 & -1} } $\n", - "$ \\newcommand{\\Htwo}{ \\mymatrix{rrrr}{ \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} } } $\n", - "$ \\newcommand{\\CNOT}{ \\mymatrix{cccc}{1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 1 \\\\ 0 & 0 & 1 & 0} } $\n", - "$ \\newcommand{\\norm}[1]{ \\left\\lVert #1 \\right\\rVert } $" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Quantum State

    \n", - "\n", - "The overall probability must be 1 when we observe a quantum system.\n", - "\n", - "For example, the following vectors cannot be a valid quantum state:\n", - "\n", - "$$\n", - " \\myvector{ \\frac{1}{2} \\\\ \\frac{1}{2} } \n", - " \\mbox{ and }\n", - " \\myvector{ \\frac{\\sqrt{3}}{2} \\\\ \\frac{1}{\\sqrt{2}} }.\n", - "$$\n", - "\n", - "For the first vector: the probabilities of observing the states $\\ket{0} $ and $ \\ket{1} $ are $ \\frac{1}{4} $. \n", - "\n", - "So, the overall probability of getting a result is $ \\frac{1}{4} + \\frac{1}{4} = \\frac{1}{2} $, which is less than 1.\n", - "\n", - "For the second vector: the probabilities of observing the states $\\ket{0} $ and $ \\ket{1} $ are respectively $ \\frac{3}{4} $ and $ \\frac{1}{2} $. \n", - "\n", - "So, the overall probability of getting a result is $ \\frac{3}{4} + \\frac{1}{2} = \\frac{5}{4} $, which is greater than 1." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The summation of amplitude squares must be 1 for a valid quantum state." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In other words, a quantum state can be represented by a vector having length 1, and vice versa.\n", - "\n", - "The summation of amplitude squares gives the square of the length of vector.\n", - "\n", - "But, this summation is 1, and its sqaure root is also 1. So, we directly use the term length in the defintion.\n", - "\n", - "We represent a quantum state as $ \\ket{u} $ instead of $ u $.\n", - "\n", - "Remember the relation between the length and inner product: $ \\norm{u} = \\sqrt{\\inner{u}{u}} $.\n", - "\n", - "In quantum computation, we use almost the same notation for the inner product: $ \\braket{u}{u}$.\n", - "\n", - "$ \\norm{ \\ket{u} } = \\sqrt{ \\braket{u}{u} } = 1 $, or equivalently $ \\braket{u}{u} = 1 $." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Task 1

    \n", - "\n", - "Let $a$ and $b$ be real numbers.\n", - "\n", - "If the folllowing vectors are valid quantum states, then what can be the values of $a$ and $b$?\n", - "\n", - "$$\n", - " \\ket{v} = \\myrvector{a \\\\ -0.1 \\\\ -0.3 \\\\ 0.4 \\\\ 0.5}\n", - " ~~~~~ \\mbox{and} ~~~~~\n", - " \\ket{u} = \\myrvector{ \\frac{1}{\\sqrt{2}} \\\\ \\frac{1}{\\sqrt{b}} \\\\ -\\frac{1}{\\sqrt{3}} }.\n", - "$$" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#\n", - "# your code is here or you may find the values by hand (in mind)\n", - "#\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "click for our solution" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Quantum Operators

    \n", - "\n", - "Once the quantum state is defined, the definition of quantum operator is very easy.\n", - "\n", - "Any length preserving matrix is a quantum operator, and vice versa." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Task 2

    \n", - "\n", - "Remember Hadamard operator:\n", - "\n", - "$$\n", - " H = \\hadamard.\n", - "$$\n", - "\n", - "Let's randomly create a 2-dimensional quantum state, and test whether Hadamard operator preserves the length or not.\n", - "\n", - "Write a function that returns a randomly created 2-dimensional quantum state:\n", - "
      \n", - "
    • Pick a random value between 0 and 100
    • \n", - "
    • Divide it by 100
    • \n", - "
    • Take sqaure root of it
    • \n", - "
    • Randomly determine its sign ($+$ or $-$)
    • \n", - "
    • This is the first entry of the vector
    • \n", - "
    • Find an appropriate value for the second entry
    • \n", - "
    • Randomly determine its sign ($+$ or $-$)
    • \n", - "
    \n", - "\n", - "Write a function that determines whether a given vector is a valid quantum state or not.\n", - "\n", - "(Due to precision problem, the summation of squares may not be exactly 1 but very close to 1, e.g., 0.9999999999999998.)\n", - "\n", - "Repeat 10 times:\n", - "
      \n", - "
    • Randomly create a quantum state
    • \n", - "
    • Multiply Hadamard matrix with the randomly created quantum state
    • \n", - "
    • Check whether the result quantum state is valid
    • \n", - "
    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#\n", - "# your solution is here\n", - "#\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "click for our solution" - ] - } - ], - "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.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B48_Superposition-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B48_Superposition-checkpoint.ipynb deleted file mode 100755 index 6c416fd35..000000000 --- a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B48_Superposition-checkpoint.ipynb +++ /dev/null @@ -1,391 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\tprepared by Abuzer Yakaryilmaz (QuSoft@Riga) | November 07, 2018\n", - "
    \n", - "
    I have some macros here. If there is a problem with displaying mathematical formulas, please run me to load these macros.
    \n", - "$ \\newcommand{\\bra}[1]{\\langle #1|} $\n", - "$ \\newcommand{\\ket}[1]{|#1\\rangle} $\n", - "$ \\newcommand{\\braket}[2]{\\langle #1|#2\\rangle} $\n", - "$ \\newcommand{\\inner}[2]{\\langle #1,#2\\rangle} $\n", - "$ \\newcommand{\\biginner}[2]{\\left\\langle #1,#2\\right\\rangle} $\n", - "$ \\newcommand{\\mymatrix}[2]{\\left( \\begin{array}{#1} #2\\end{array} \\right)} $\n", - "$ \\newcommand{\\myvector}[1]{\\mymatrix{c}{#1}} $\n", - "$ \\newcommand{\\myrvector}[1]{\\mymatrix{r}{#1}} $\n", - "$ \\newcommand{\\mypar}[1]{\\left( #1 \\right)} $\n", - "$ \\newcommand{\\mybigpar}[1]{ \\Big( #1 \\Big)} $\n", - "$ \\newcommand{\\sqrttwo}{\\frac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\dsqrttwo}{\\dfrac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\onehalf}{\\frac{1}{2}} $\n", - "$ \\newcommand{\\donehalf}{\\dfrac{1}{2}} $\n", - "$ \\newcommand{\\hadamard}{ \\mymatrix{rr}{ \\sqrttwo & \\sqrttwo \\\\ \\sqrttwo & -\\sqrttwo }} $\n", - "$ \\newcommand{\\vzero}{\\myvector{1\\\\0}} $\n", - "$ \\newcommand{\\vone}{\\myvector{0\\\\1}} $\n", - "$ \\newcommand{\\vhadamardzero}{\\myvector{ \\sqrttwo \\\\ \\sqrttwo } } $\n", - "$ \\newcommand{\\vhadamardone}{ \\myrvector{ \\sqrttwo \\\\ -\\sqrttwo } } $\n", - "$ \\newcommand{\\myarray}[2]{ \\begin{array}{#1}#2\\end{array}} $\n", - "$ \\newcommand{\\X}{ \\mymatrix{cc}{0 & 1 \\\\ 1 & 0} } $\n", - "$ \\newcommand{\\Z}{ \\mymatrix{rr}{1 & 0 \\\\ 0 & -1} } $\n", - "$ \\newcommand{\\Htwo}{ \\mymatrix{rrrr}{ \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} } } $\n", - "$ \\newcommand{\\CNOT}{ \\mymatrix{cccc}{1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 1 \\\\ 0 & 0 & 1 & 0} } $\n", - "$ \\newcommand{\\norm}[1]{ \\left\\lVert #1 \\right\\rVert } $" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Superposition

    \n", - "\n", - "There is no classical counterpart of the concept \"superposition\".\n", - "\n", - "But, we can still use a classical analogy that might help us to give some intuitions.\n", - "\n", - "

    Probability distribution

    \n", - "\n", - "Suppose that Asja starts in $ \\myvector{1\\\\0} $ and secretly applies the probabilistic operator $ \\mymatrix{cc}{ 0.3 & 0.6 \\\\ 0.7 & 0.4 } $.\n", - "\n", - "Because she applies her operator secretly, our information about her state is probabilistic, which is calculated as\n", - "\n", - "$$\n", - " \\myvector{0.3 \\\\ 0.7} = \\mymatrix{cc}{ 0.3 & 0.6 \\\\ 0.7 & 0.4 } \\myvector{1\\\\0}.\n", - "$$\n", - "\n", - "Asja is either in state 0 or in state 1.\n", - "\n", - "However, from our point of view, Asja is in state 0 and state 1 with probabilities $ 0.3 $ and $ 0.7 $, respectively.\n", - "\n", - "We can say that Asja in a probability distribution of states 0 and 1, being in both states at the same time.\n", - "\n", - "On the other hand, if we observe Asja's state, then our information about Asja becomes deterministic: either $ \\myvector{1 \\\\ 0} $ or $ \\myvector{0 \\\\ 1} $.\n", - "\n", - "We can say that after measurement the probabilistic state $ \\myvector{0.3 \\\\ 0.7} $ collapses to either $ \\myvector{1 \\\\ 0} $ or $ \\myvector{0 \\\\ 1} $.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    The third experiment

    \n", - "\n", - "Now, we can explain the following experiment.\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " The initial Step \n", - "\n", - "The photon is in state $ \\ket{v_0} = \\vzero $." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " The first step \n", - "\n", - "Hadamard is applied:\n", - "\n", - "$ \\ket{v_1} = \\hadamard \\vzero = \\vhadamardzero $.\n", - "\n", - "At this point, the photon is in a superposition of state $ \\ket{0} $ and state $ \\ket{1} $, being in both states with the amplitudes $ \\frac{1}{\\sqrt{2}} $ and $ \\frac{1}{\\sqrt{2}} $, respectively.\n", - "\n", - "The state of photon is $ \\ket{v_1} = \\vhadamardzero $, and we can represent it also as follows:\n", - "\n", - "$ \\ket{v_1} = \\frac{1}{\\sqrt{2}} \\ket{0} + \\frac{1}{\\sqrt{2}} \\ket{1} $." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " The second step \n", - "\n", - "Hadamard is applied again:\n", - "\n", - "We write the affect of Hadamard on states $ \\ket{0} $ and $ \\ket{1} $ as follows:\n", - "\n", - "$ H \\ket{0} = \\frac{1}{\\sqrt{2}} \\ket{0} + \\frac{1}{\\sqrt{2}} \\ket{1} $\n", - "\n", - "$ H \\ket{1} = \\frac{1}{\\sqrt{2}} \\ket{0} - \\frac{1}{\\sqrt{2}} \\ket{1} $\n", - "\n", - "This representation helps us to see clearly why the state $ \\ket{1} $ disappears.\n", - "\n", - "Now, let's see the affect of Hadamard on the quantum state $ \\ket{v_1} = \\frac{1}{\\sqrt{2}} \\ket{0} + \\frac{1}{\\sqrt{2}} \\ket{1} $:\n", - "\n", - "$ \\ket{v_2} = H \\ket{v_1} = H \\mybigpar{ \\frac{1}{\\sqrt{2}} \\ket{0} + \\frac{1}{\\sqrt{2}} \\ket{1} } = \\frac{1}{\\sqrt{2}} H \\ket{0} + \\frac{1}{\\sqrt{2}} H \\ket{1} $\n", - "\n", - "We can replace $ H\\ket{0} $ and $ H\\ket{1} $ as described above.\n", - "\n", - "$ \\ket{v_2} $ is formed by the summation of the following terms:\n", - "\n", - "$ \\frac{1}{\\sqrt{2}} H \\ket{0} = \\frac{1}{2} \\ket{0} + \\frac{1}{2} \\ket{1} $\n", - "\n", - "$ \\frac{1}{\\sqrt{2}} H \\ket{1} = \\frac{1}{2} \\ket{0} - \\frac{1}{2} \\ket{1} $\n", - "\n", - "The amplitude of $ \\ket{0} $ becomes 1, but the amplitude of $ \\ket{1} $ becomes 0 because of cancellation.\n", - "\n", - "$ \\ket{v_2} = 1 \\cdot \\ket{0} + 0 \\cdot \\ket{1} = \\ket{0} $.\n", - "\n", - "The photon was in both states at the same time with certain amplitudes.\n", - "\n", - "After the second Hadamard, the results are interfered with each other.\n", - "\n", - "The interference can be constructive or destructive.\n", - "\n", - "In our examples, the resulting $ \\ket{0} $s are interfered constructively, but the resulting $ \\ket{1} $s are interfered destructively." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Observations

    \n", - "\n", - "Probabilistic systems: If there is a nonzero transition to a state, then it contributes to the probability of this state positively. \n", - "\n", - "Quantum systems: If there is a nonzero transition to a state, then we cannot make such an interpretation without knowing the other transtions to this state.\n", - "\n", - "If it is the only transition, then it contributes to the amplitude (and probability) of the state, and it does not matter whether the sign of the transition is positive or negative.\n", - "\n", - "If there is more than one transition, then depending on the summation of all transitions, we can determine whether a specific transition contributes or not.\n", - "\n", - "As a simple rule, if the final amplitude of the state and nonzero transition have the same sign, then it is a positive contribution; and, if they have the opposite signs, then it is a negative contribution." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Task 1

    \n", - "\n", - "[on paper]\n", - "\n", - "Start in state $ \\ket{u_0} = \\ket{1} $.\n", - "\n", - "Apply Hadamard operator to $ \\ket{u_0} $, i.e, find $ \\ket{u_1} = H \\ket{u_0} $.\n", - "\n", - "Apply Hadamard operator to $\\ket{u_1}$, i.e, find $ \\ket{u_2} = H \\ket{u_1} $.\n", - "\n", - "Observe the constructive and destructive interferences, when calculating $ \\ket{u_2} $." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Being in a superposition

    \n", - "\n", - "A quantum system can be in more than one state with nonzero amplitudes.\n", - "\n", - "Then, we say that our system is in a superposition of these states.\n", - "\n", - "When evolving from a superposition, the resulting transitions may affect each other constructively and destructively. \n", - "\n", - "This can happen only because of having both negative or positive amplitudes. \n", - "\n", - "Otherwise, all nonzero transitions are added up to each other as in probababilistic systems." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Measurement

    \n", - "\n", - "We can measure a quantum system, and then the system is observed in one of its states.\n", - "\n", - "This is the most basic measurement in quantum computing. \n", - "\n", - "(There are more generic measurement operators, but we will not cover them.)\n", - "\n", - "The probability of the system to be observed in a specified state is the square value of its amplitude.\n", - "
      \n", - "
    • If the amplitude of a state is zero, then this state cannot be observed.
    • \n", - "
    • If the amplitude of a state is nonzero, then this state can be observed.
    • \n", - "
    \n", - "\n", - "For example, if the system is in quantum state \n", - "\n", - "$$\n", - " \\myrvector{ -\\frac{\\sqrt{2}}{\\sqrt{3}} \\\\ \\frac{1}{\\sqrt{3}} },\n", - "$$\n", - "\n", - "then, after a measurement, we can observe the system in state $\\ket{0} $ with probability $ \\frac{2}{3} $ and in state $\\ket{1}$ with probability $ \\frac{1}{3} $.\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Collapsing

    \n", - "\n", - "After the measurement, the system collapses to the observed state, and so the system is no longer in a superposition.\n", - "\n", - "Thus, the information kept in a superposition is lost. \n", - "\n", - "In the above example, when the system is observed in state $\\ket{0}$, then the new state becomes $ \\myvector{1 \\\\ 0} $. \n", - "\n", - "If it is observed in state $\\ket{1}$, then the new state becomes $ \\myvector{0 \\\\ 1} $." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Task 2

    \n", - "\n", - "We have a quantum system with four states: $\\ket{00}$, $ \\ket{01} $, $\\ket{10}$, and $ \\ket{11} $.\n", - "\n", - "We can also say that our system has two qubits.\n", - "\n", - "\n", - "Suppose that the system is in the following state:\n", - "\n", - "$ \\myrvector{ \\dfrac{ 1 }{ \\sqrt{3} - \\sqrt{ 5 + 2\\sqrt{6}} } \\\\ \\\\ \\dfrac{1}{ \\sqrt{3} - \\sqrt{ 7 + 2\\sqrt{12} } } \\\\ \\\\\n", - " \\dfrac{ 1 }{ \\sqrt{5} - \\sqrt{ 13 + 2\\sqrt{40} } } \\\\ \\\\ \\dfrac{1}{ \\sqrt{ 7 } - \\sqrt{ 15 + 2 \\sqrt{56} } } }. $\n", - " \n", - " Find the probability of observing the system in state $\\ket{00}$, $ \\ket{01} $, $\\ket{10}$, or $ \\ket{11} $.\n", - " \n", - " You may write a function to calculate the dominator of each fraction automatically, where its value is determined by three values $a$, $ b$, and $ c $ by assuming the form $ \\sqrt{a} - \\sqrt{b + 2 \\sqrt{c} } $.\n", - " \n", - " Verify that the total probability is 1 (or almost 1)." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#\n", - "# your solution is here\n", - "#\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "click for our solution" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Z-gate (operator)

    \n", - "\n", - "The indentity operator $ I = \\mymatrix{cc}{1 & 0 \\\\ 0 & 1} $ does not affect the computation.\n", - "\n", - "What about the following operator?\n", - "\n", - "$ Z = \\Z $.\n", - "\n", - "It is very similar to the identity operator.\n", - "\n", - "Consider the quantum state $ \\ket{u} = \\myvector{ \\frac{3}{5} \\\\ \\frac{4}{5} } $.\n", - "\n", - "Let's calculate the new quantum state after appying $ Z $ to $ \\ket{u} $:\n", - "\n", - "$ \\ket{u'} = Z \\ket{u} = \\Z \\myvector{ \\frac{3}{5} \\\\ \\frac{4}{5} } = \\myrvector{ \\frac{3}{5} \\\\ -\\frac{4}{5} } $." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The quantum states $ \\ket{u} $ and $ \\ket{u'} $ look similar. \n", - "\n", - "The probabilities of observing the state 0 and state 1 are the same when the system is in $ \\ket{u} $ or $ \\ket{u'} $.\n", - "\n", - "On the other hand, they are far away from each other as shown below: \n", - "\n", - "\n", - "\n", - "For example, by applying Hadamard to each of them, the probability of observing the state 0 and state 1 may change (?)\n", - "\n", - "To observe this, we can do a simple experiment. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Task 3

    \n", - "\n", - "Create a quantum ciruit with 5 qubits.\n", - "\n", - "Apply h-gate (Hadamard operator) to each qubit.\n", - "\n", - "Apply z-gate ($Z$ operator) to randomly picked qubits. (e.g., $ mycircuit.z(qreg[i]) $)\n", - "\n", - "Apply h-gate to each qubit \n", - "\n", - "Measure each qubit.\n", - "\n", - "Execute your program 1000 times.\n", - "\n", - "Compare the outcomes of the qubits affected by z-gates, and the outcomes of the qubits not affected by z-gates.\n", - "\n", - "Does z-gate change the outcome?\n", - "\n", - "Why?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# let's import all necessary objects and methods for quantum circuits\n", - "from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer\n", - "from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer\n", - "# let's import randrange for random choices\n", - "from random import randrange\n", - "\n", - "#\n", - "# your code is here\n", - "#\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "click for our solution" - ] - } - ], - "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.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B60_Superdense_Coding-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B60_Superdense_Coding-checkpoint.ipynb deleted file mode 100755 index 4e0a54891..000000000 --- a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B60_Superdense_Coding-checkpoint.ipynb +++ /dev/null @@ -1,224 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\tprepared by Abuzer Yakaryilmaz (QuSoft@Riga) | November 07, 2018\n", - "
    \n", - "
    I have some macros here. If there is a problem with displaying mathematical formulas, please run me to load these macros.
    \n", - "$ \\newcommand{\\bra}[1]{\\langle #1|} $\n", - "$ \\newcommand{\\ket}[1]{|#1\\rangle} $\n", - "$ \\newcommand{\\braket}[2]{\\langle #1|#2\\rangle} $\n", - "$ \\newcommand{\\inner}[2]{\\langle #1,#2\\rangle} $\n", - "$ \\newcommand{\\biginner}[2]{\\left\\langle #1,#2\\right\\rangle} $\n", - "$ \\newcommand{\\mymatrix}[2]{\\left( \\begin{array}{#1} #2\\end{array} \\right)} $\n", - "$ \\newcommand{\\myvector}[1]{\\mymatrix{c}{#1}} $\n", - "$ \\newcommand{\\myrvector}[1]{\\mymatrix{r}{#1}} $\n", - "$ \\newcommand{\\mypar}[1]{\\left( #1 \\right)} $\n", - "$ \\newcommand{\\mybigpar}[1]{ \\Big( #1 \\Big)} $\n", - "$ \\newcommand{\\sqrttwo}{\\frac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\dsqrttwo}{\\dfrac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\onehalf}{\\frac{1}{2}} $\n", - "$ \\newcommand{\\donehalf}{\\dfrac{1}{2}} $\n", - "$ \\newcommand{\\hadamard}{ \\mymatrix{rr}{ \\sqrttwo & \\sqrttwo \\\\ \\sqrttwo & -\\sqrttwo }} $\n", - "$ \\newcommand{\\vzero}{\\myvector{1\\\\0}} $\n", - "$ \\newcommand{\\vone}{\\myvector{0\\\\1}} $\n", - "$ \\newcommand{\\vhadamardzero}{\\myvector{ \\sqrttwo \\\\ \\sqrttwo } } $\n", - "$ \\newcommand{\\vhadamardone}{ \\myrvector{ \\sqrttwo \\\\ -\\sqrttwo } } $\n", - "$ \\newcommand{\\myarray}[2]{ \\begin{array}{#1}#2\\end{array}} $\n", - "$ \\newcommand{\\X}{ \\mymatrix{cc}{0 & 1 \\\\ 1 & 0} } $\n", - "$ \\newcommand{\\Z}{ \\mymatrix{rr}{1 & 0 \\\\ 0 & -1} } $\n", - "$ \\newcommand{\\Htwo}{ \\mymatrix{rrrr}{ \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} } } $\n", - "$ \\newcommand{\\CNOT}{ \\mymatrix{cccc}{1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 1 \\\\ 0 & 0 & 1 & 0} } $\n", - "$ \\newcommand{\\norm}[1]{ \\left\\lVert #1 \\right\\rVert } $" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Superdense Coding

    \n", - "\n", - "Asja has a qubit, initially set to $ \\ket{0} $.\n", - "\n", - "Balvis has a qubit, initially set to $ \\ket{0} $." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Entanglement

    \n", - " \n", - "Asja applies Hadamard operator to her qubit. \n", - "\n", - "The quantum state of Asja's qubit is $ \\vhadamardzero $.\n", - "\n", - "Then, Asja and Balvis combine their qubits. Their quantum state is\n", - "\n", - "$ \\vhadamardzero \\otimes \\vzero = \\myvector{ \\frac{1}{\\sqrt{2}} \\\\ 0 \\\\ \\frac{1}{\\sqrt{2}} \\\\ 0 } $.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Asja and Balvis apply CNOT operator on two qubits.\n", - "\n", - "The new quantum state is\n", - "\n", - "$ \\CNOT \\myvector{ \\frac{1}{\\sqrt{2}} \\\\ 0 \\\\ \\frac{1}{\\sqrt{2}} \\\\ 0 } = \\myvector{ \\frac{1}{\\sqrt{2}} \\\\ 0 \\\\0 \\\\ \\frac{1}{\\sqrt{2}} } = \\frac{1}{\\sqrt{2}}\\ket{00} + \\frac{1}{\\sqrt{2}}\\ket{11} $.\n", - "\n", - "At this moment, Asja's and Balvis' qubits are correlated to each other.\n", - "\n", - "If we measure both qubits, we can observe either state $ \\ket{00} $ or state $ \\ket{11} $. \n", - "\n", - "Suppose that Asja observes her qubit secretly. \n", - "
      \n", - "
    • When Asja sees the result $ \\ket{0} $, then Balvis' qubit also collapses to state $ \\ket{0} $. Balvis cannot observe state $ \\ket{1} $.
    • \n", - "
    • When Asja sees the result $ \\ket{1} $, then Balvis' qubit also collapses to state $ \\ket{1} $. Balvis cannot observe state $ \\ket{0} $.
    • \n", - "
    \n", - " \n", - "Experimental results have confirmed that this happens even if there is a physical distance between Asja's and Balvis' qubits. \n", - "\n", - "It seems correlated quantum particales can affect each other instantly, even if they are in the different part of the universe. \n", - "\n", - "If two qubits are correlated in this way, then we say that they are entangled.\n", - "\n", - " Technical note: \n", - " \n", - "If the quantum state of two qubits can be written as $ \\ket{u} \\otimes \\ket{v} $, then two qubits are not correlated, where $ \\ket{u} $ and $ \\ket{v} $ are the quantum states of the first and second qubits.\n", - "\n", - "On the other hand, if the quantum state of two qubits cannot be written as $ \\ket{u} \\otimes \\ket{v} $, then there is an entanglement between the qubits.\n", - "\n", - "\n", - " Entangled qubits can be useful " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    The quantum commmunication

    \n", - "\n", - "After having the entanglement, Balvis takes his qubit and goes away.\n", - "\n", - "Asja will send two bits of information by only sending her qubit.\n", - "\n", - "Now, we describe this protocol." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Asja has two bits of classical information: $ a,b \\in \\{0,1\\} $. \n", - "\n", - "There are four possible values for the pair $ (a,b) $: $ (0,0), (0,1), (1,0),\\mbox{ or } (1,1) $. \n", - "\n", - "If $a$ is 1, then Asja applies z-gate, i.e., $ Z = \\Z $, to her qubit.\n", - "\n", - "If $b$ is 1, then Asja applies x-gate (NOT operator) to her qubit.\n", - "\n", - "Then, Asja sends her qubit to Balvis." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    After the communication

    \n", - "\n", - "Balvis has both qubits.\n", - "\n", - "Balvis applies cx-gate (CNOT operator), where Asja's qubit is the controller.\n", - "\n", - "Then, Balvis applies h-gate (Hadamard operator) to Asja's qubit.\n", - "\n", - "Balvis measures both qubits. \n", - "\n", - "The measurement result will be exactly $ (a,b) $." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Task 1

    \n", - "\n", - "Verify the correctness of the above protocol.\n", - "\n", - "For each pair of $ (a,b) \\in \\left\\{ (0,0), (0,1), (1,0),(1,1) \\right\\} $:\n", - "
      \n", - "
    • Create a quantum curcuit with two qubits: Asja's and Balvis' qubits.
    • \n", - "
    • Both are initially set to $ \\ket{0} $.
    • \n", - "
    • Apply h-gate (Hadamard) to the first qubit.
    • \n", - "
    • Apply cx-gate (CNOT) with parameters first-qubit and second-qubit.
    • \n", - "
    \n", - "\n", - "They are separated now.\n", - "\n", - "
      \n", - "
    • If $ a $ is 1, then apply z-gate to the first qubit.
    • \n", - "
    • If $ b $ is 1, then apply x-gate (NOT) to the first qubit.
    • \n", - "
    \n", - "\n", - "Asja sends her qubit to Balvis.\n", - "\n", - "
      \n", - "
    • Apply cx-gate (CNOT) with parameters first-qubit and second-qubit.
    • \n", - "
    • Apply h-gate (Hadamard) to the first qubit.
    • \n", - "
    • Measure both qubits, and compare the results with pair $ (a,b) $.
    • \n", - "
    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# import all necessary objects and methods for quantum circuits\n", - "from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer\n", - "from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer\n", - "\n", - "all_pairs = ['00','01','10','11']\n", - "\n", - "for pair in all_pairs:\n", - " #\n", - " # your code is here\n", - " #\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "click for our solution" - ] - } - ], - "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.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B88_Grovers_Search-checkpoint.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B88_Grovers_Search-checkpoint.ipynb deleted file mode 100755 index b965fe882..000000000 --- a/community/awards/teach_me_quantum_2018/bronze/bronze/.ipynb_checkpoints/B88_Grovers_Search-checkpoint.ipynb +++ /dev/null @@ -1,548 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\tprepared by Abuzer Yakaryilmaz (QuSoft@Riga) | November 10, 2018\n", - "
    \n", - "
    I have some macros here. If there is a problem with displaying mathematical formulas, please run me to load these macros.
    \n", - "$ \\newcommand{\\bra}[1]{\\langle #1|} $\n", - "$ \\newcommand{\\ket}[1]{|#1\\rangle} $\n", - "$ \\newcommand{\\braket}[2]{\\langle #1|#2\\rangle} $\n", - "$ \\newcommand{\\inner}[2]{\\langle #1,#2\\rangle} $\n", - "$ \\newcommand{\\biginner}[2]{\\left\\langle #1,#2\\right\\rangle} $\n", - "$ \\newcommand{\\mymatrix}[2]{\\left( \\begin{array}{#1} #2\\end{array} \\right)} $\n", - "$ \\newcommand{\\myvector}[1]{\\mymatrix{c}{#1}} $\n", - "$ \\newcommand{\\myrvector}[1]{\\mymatrix{r}{#1}} $\n", - "$ \\newcommand{\\mypar}[1]{\\left( #1 \\right)} $\n", - "$ \\newcommand{\\mybigpar}[1]{ \\Big( #1 \\Big)} $\n", - "$ \\newcommand{\\sqrttwo}{\\frac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\dsqrttwo}{\\dfrac{1}{\\sqrt{2}}} $\n", - "$ \\newcommand{\\onehalf}{\\frac{1}{2}} $\n", - "$ \\newcommand{\\donehalf}{\\dfrac{1}{2}} $\n", - "$ \\newcommand{\\hadamard}{ \\mymatrix{rr}{ \\sqrttwo & \\sqrttwo \\\\ \\sqrttwo & -\\sqrttwo }} $\n", - "$ \\newcommand{\\vzero}{\\myvector{1\\\\0}} $\n", - "$ \\newcommand{\\vone}{\\myvector{0\\\\1}} $\n", - "$ \\newcommand{\\vhadamardzero}{\\myvector{ \\sqrttwo \\\\ \\sqrttwo } } $\n", - "$ \\newcommand{\\vhadamardone}{ \\myrvector{ \\sqrttwo \\\\ -\\sqrttwo } } $\n", - "$ \\newcommand{\\myarray}[2]{ \\begin{array}{#1}#2\\end{array}} $\n", - "$ \\newcommand{\\X}{ \\mymatrix{cc}{0 & 1 \\\\ 1 & 0} } $\n", - "$ \\newcommand{\\Z}{ \\mymatrix{rr}{1 & 0 \\\\ 0 & -1} } $\n", - "$ \\newcommand{\\Htwo}{ \\mymatrix{rrrr}{ \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} } } $\n", - "$ \\newcommand{\\CNOT}{ \\mymatrix{cccc}{1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 1 \\\\ 0 & 0 & 1 & 0} } $\n", - "$ \\newcommand{\\norm}[1]{ \\left\\lVert #1 \\right\\rVert } $" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Grover's Search

    \n", - "\n", - "Grover's search algorithm is one of the well-known quantum algorithms.\n", - "\n", - "It finds a marked element in an unsorted list quadratically better than the classical algorithms.\n", - "\n", - "Grover's search algorithm iteratively applies two reflections.\n", - "\n", - "Its implementation is complicated, but its explanation is easy.\n", - "\n", - "Here, we describe Grover's search algorithm, and then emulate it on the unit circle. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Representation of data

    \n", - "\n", - "Suppose that we have 16 elements in our list.\n", - "\n", - "The list has marked and unmarked elements. (A marked element refers to a searching item.)\n", - "\n", - "Each quantum state will be associated with a different index of the list.\n", - "\n", - "Four qubits have 16 different states ($ \\ket{0000}, \\ldots, \\ket{1111} $), and so we use 4 qubits.\n", - "\n", - "We assume that when we keep the whole list \"quantumly\", we can check whether an item is marked or not in a single step by using its index.\n", - "\n", - "For example, if the element associated with the state $ \\ket{1101} $ is marked, then we can detect this by changing the sign of this state.\n", - "\n", - "We remind that changing the sign of a quantum state is one of the basic opearations.\n", - "\n", - "In general, if we have a list of size $ 2^k $, then we can use $ k $ qubits and associate each state with one of the item in the list." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Search in parallel

    \n", - "\n", - "We can access each element in the list with one of the basis states.\n", - "\n", - "We start in state $ \\ket{0000} $.\n", - "\n", - "Then, we apply Hadamard to each qubit.\n", - "\n", - "Remember that $ \\ket{0000} = \\ket{0} \\otimes \\ket{0} \\otimes \\ket{0} \\otimes \\ket{0} $, or equivalently $ \\ket{0000} = \\ket{0}\\ket{0}\\ket{0}\\ket{0} $ by omitting tensor symbol.\n", - "\n", - "After Hadamard operator, our quantum state is\n", - "\n", - "$ \\ket{u} = H\\ket{0} \\otimes H\\ket{0} \\otimes H\\ket{0} \\otimes H\\ket{0} $, which is\n", - "\n", - "$$\n", - " \\ket{u} =\n", - " \\mypar{ \\frac{1}{\\sqrt{2}} \\ket{0} + \\frac{1}{\\sqrt{2}} \\ket{1} } \\otimes\n", - " \\mypar{ \\frac{1}{\\sqrt{2}} \\ket{0} + \\frac{1}{\\sqrt{2}} \\ket{1} } \\otimes\n", - " \\mypar{ \\frac{1}{\\sqrt{2}} \\ket{0} + \\frac{1}{\\sqrt{2}} \\ket{1} } \\otimes\n", - " \\mypar{ \\frac{1}{\\sqrt{2}} \\ket{0} + \\frac{1}{\\sqrt{2}} \\ket{1} }.\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "From this tensor product, we can get every basis state of 4 qubits having the amplitude $ \\frac{1}{4} $:\n", - "\n", - "\n", - "$$\n", - " \\ket{u}= \\frac{1}{4} \\ket{0000} + \\frac{1}{4} \\ket{0001} + \\frac{1}{4} \\ket{0010} + \\frac{1}{4} \\ket{0011} \n", - " + \\cdots \\cdots + \\frac{1}{4} \\ket{1101} + \\frac{1}{4} \\ket{1110} + \\frac{1}{4} \\ket{1111}.\n", - "$$\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Thus, after Hadamard, we can access each index in parallel, \n", - "
         \n", - "because we are in a superposition of all basis states, or in a superposition of all indices of the list.\n", - "\n", - "However, the probability of observing any basis state at this moment is exponentially small: $ \\frac{1}{16} $. \n", - "\n", - "(It is $ \\frac{1}{2^k} $ if there are $ 2^k $ elements.)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Task 1

    \n", - "\n", - "Design a quantum circuit with 4 qubits.\n", - "\n", - "Apply Hadamard to each qubit.\n", - "\n", - "Execute your circuit 1600 times.\n", - "\n", - "You should observe each basis state around 100 times.\n", - "\n", - "Reexecute your circuit 16000 times." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# import all necessary objects and methods for quantum circuits\n", - "from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer\n", - "from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer\n", - "\n", - "#\n", - "# your solution is here\n", - "#\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "click for our solution" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Unit circle representation

    \n", - "\n", - "For representing quantum state $ \\ket{u} $, we need 16-dimensional space.\n", - "\n", - "But, we can map $\\ket{u} $ to 2-dimensional space.\n", - "\n", - "We have marked elements and unmarket elements. \n", - "\n", - "We can group the states associated with marked elements and the state associated with unmarked elements.\n", - "\n", - "Then, we can represent $ \\ket{u} $ as a summation of two quantum states $ \\ket{u} = a \\ket{u_{marked}} + b \\ket{u_{unmarked}} $.\n", - "\n", - "The states in $ \\ket{u_{marked}} $ and $ \\ket{u_{unmarked}} $ are different from each other.\n", - "\n", - "Therefore, they are orthogonal to each other. We can represent $ \\ket{u} = a \\ket{u_{marked}} + b \\ket{u_{unmarked}} $ in 2-dimension as below:" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Remark that if all elements are marked, then $ \\ket{u} = \\ket{u_{marked}} $, and if all elements are unmarked, then $ \\ket{u} = \\ket{u_{unmarked}}$.\n", - "\n", - "For example, if we have 3 marked elements in our example, then we can find our parameters as follows.\n", - "\n", - "Let the marked states be $ \\ket{marked1} , \\ket{marked2} , \\ket{marked3} $.\n", - "\n", - "Let the unmarked states be $ \\ket{unmarked1} , \\ket{unmarked2} , \\ldots, \\ket{unmarked13} $.\n", - "\n", - "In $ \\ket{u} $, each of this state has the amplitude $ \\frac{1}{\\sqrt{16}} $:\n", - "\n", - "$$\n", - " \\ket{u} = \\frac{1}{\\sqrt{16}} \\mypar{ \\ket{marked1} + \\ket{marked2} + \\ket{marked3} } +\n", - " \\frac{1}{\\sqrt{16}} \\mypar{ \\ket{unmarked1} + \\ket{unmarked2} + \\cdots + \\ket{unmarked13} }\n", - "$$\n", - "\n", - "Then, our parameters are\n", - "
      \n", - "
    • $ \\ket{u_{marked}} = \\frac{1}{\\sqrt{3}} \\mypar{ \\ket{marked1} + \\ket{marked2} + \\ket{marked3} } $ and
    • \n", - "
    • $ a = \\frac{\\sqrt{3}}{\\sqrt{16}} $; and,
    • \n", - "
    • $ \\ket{u_{unmarked}} = \\frac{1}{\\sqrt{13}} \\mypar{ \\ket{unmarked1} + \\ket{unmarked2} + \\cdots + \\ket{unmarked13} } $ and
    • \n", - "
    • $ b = \\frac{\\sqrt{13}}{\\sqrt{16}} $.
    • \n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The idea here is to select $ \\ket{u_{marked}} $ and $\\ket{u_{unmarked}} $ as quantum states, i.e., their lengths should be 1. \n", - "\n", - "In this way, we can also keep the ratio of $ \\frac{3}{13} $ as ratio of\n", - "
      \n", - "
    • the probability of observing a state in $ \\ket{u_{marked}} $ and
    • \n", - "
    • the probability of observing a state in $ \\ket{u_{unmarked}} $.
    • \n", - "
    \n", - "\n", - "Remark that the first probability is $ a^2 = \\frac{3}{16} $ and the second probability if $ b^2 = \\frac{13}{16} $." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " So, in general, if we have $ 2^k $ elements and $ m $ of them are marked, then $ a = \\frac{\\sqrt{m}}{\\sqrt{2^k}} $ and $ b= \\frac{\\sqrt{2^k - m}}{\\sqrt{2^k}} $. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    The idea behind Grover's search

    \n", - "\n", - "The idea behind Grover's search algorithm is that \n", - "
      \n", - "
    • the amplitudes of the marked elements can be quickly amplified,
    • \n", - "
    • and so the probability of observing one of the marked element quickly approches to 1.
    • \n", - "
    \n", - "\n", - "For \"quick\" amplification, we iteratively applies two reflections to our quantum states. \n", - "\n", - "The first reflection is a clockwise rotation, and the second rotation is counterclockwise. \n", - "\n", - "The second rotation always rotates twice of the first rotation. \n", - "\n", - "Therefore, our quantum state moves counterclockwise direction after two reflections." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "As an analogy, we consider the rotation on the unit circle with angle $ \\frac{\\pi}{8} $ that starts in $ \\ket{0} $. \n", - "
      \n", - "
    • After every 4 rotations, we visit in order $ \\ket{1} $, $ -\\ket{0} $, $ -\\ket{1} $, again $ \\ket{0} $, and so on.
    • \n", - "
    • Remark that the probability of observing the state $ \\ket{1} $ oscillates between increasing and decreasing while rotating.
    • \n", - "
    \n", - "\n", - "Similarly, when iterating Grover's search algorithm, we should be careful when to stop. \n", - "
      \n", - "
    • Because, after hitting a maximum value, these amplitudes are quickly decreased, and after hitting a minimum value, they are amplified again, and so on.
    • \n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    One iteration of the algorithm

    \n", - "\n", - "Once we have the unit circle representation, then we can describe the algorithm very easily.\n", - "\n", - "Grover's search algorithm simply iterates two reflection, which can be implemented as two rotations.\n", - "\n", - "The axis of the first reflection is the quantum state $ \\ket{u_{unmarked}} $.\n", - "\n", - "The axis of the second reflection is the first quantum state after Hadamard operators: $ \\ket{u} $.\n", - "\n", - "During all iterations, these axes are fixed. \n", - "\n", - "Remark that both of them depend on only the list and marked/unmarked elements." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Grover's search algorithm: \n", - "\n", - "Start in $ \\ket{u} $.\n", - "\n", - "Iteratively:\n", - "
      \n", - "
    1. Reflection over the first axis: Flip the sign of the states associated with the marked elements.\n", - "
    2. \n", - "
    3. Reflection over the second axis: Then, reflect the resulting quantum state over the $\\ket{u}$-axis.\n", - "
    4. \n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "After the first reflection: the current quantum state rotates with angle $ -2 \\theta $.\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "After the second reflection: the reflected state rotates with angle $ 4 \\theta $.\n", - "\n", - "\n", - "\n", - "Then, the angle of the new quantum state is $ 3 \\theta $." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The second iteration:\n", - "
      \n", - "
    • The angle of the new quantum state is $ 3 \\theta $.
    • \n", - "
    • After the first reflection (rotation by $ -6 \\theta $): The reflected quantum state has angle $ -3 \\theta $.
    • \n", - "
    • The angle between the reflected quantum state and the second reflection axis is $ 4 \\theta $.\n", - "
    • With the second reflection, the reflected quantum state rotates $ 8 \\theta $.
    • \n", - "
    • Thus, the angle of the newest state will be $ 5\\theta $.
    • \n", - "
    \n", - "\n", - "Hence after each iteration the angle of the quantum state will be increased by $ 2 \\theta $." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In this way, the quantum state iteratively approaches to $ \\ket{u_{marked}} $.\n", - "\n", - "If we do not stop the iterations, then it passes $ \\ket{u_{marked}} $, and starts to approaches $ - \\ket{u_{unmarked}} $.\n", - "\n", - "If the quantum state is sufficiently close to $ \\ket{u_{marked}} $ and we make a measurement, we can observe a marked element with high probability.\n", - "\n", - "This is also the place to stop the iterations." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Task 2: Emulating Grover's search

    \n", - "\n", - "For this task, you can use the methods given in notebook B80_Reflections.\n", - "\n", - "Set the value of $ k $ to 4. Then, the size of list is $ 2^k = 16 $.\n", - "\n", - "Pick the value of $ m $ as 3, the number of the marked elements.\n", - "\n", - "As described above, $ \\ket{u} = \\sqrt{\\frac{3}{16}} \\ket{u_{marked}} + \\sqrt{\\frac{13}{16}} \\ket{u_{unmarked}} $.\n", - "\n", - "Create a quantum circuit with single qubit.\n", - "\n", - "States $ \\ket{1} $ and $ \\ket{0} $ represents the quantum state $ \\ket{u_{marked}} $ and $ \\ket{u_{unmarked}}$, respectively.\n", - "\n", - "Then, $ \\ket{u} = \\sqrt{\\frac{13}{16}} \\ket{0} + \\sqrt{\\frac{3}{16}} \\ket{1} $.\n", - "\n", - "Determine the angle $ \\theta $, the angle between $ \\ket{u} $ and $ \\ket{0} $.\n", - "\n", - "Iterate Grover's search algorithm once by using your quantum circuit.\n", - "\n", - "For each reflection, use ry-gate (rotation).\n", - "
      \n", - "
    • Define a list to store all quantum states (with their labels) that will be visited.
    • \n", - "
    • Implement the first reflection on your qubit
    • \n", - "
    • Read the current quantum state and store it on your list
    • \n", - "
    • Implement the second reflection on your qubit
    • \n", - "
    • Read the current quantum state and store it on your list
    • \n", - "
    • Draw all visited quantum states with their labels
    • \n", - "
    • Execute your circuit 100 times
    • \n", - "
    \n", - "\n", - "Is this single iteration enough to observe state $ \\ket{1} $ more than state $ \\ket{0} $? " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#\n", - "# your solution\n", - "#\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "click for our solution" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Taks 3

    \n", - "\n", - "For this task, you can use the methods given in notebook B80_Reflections .\n", - "\n", - "Set the value of $ k $ to 6. Then, the size of list is $ 2^k = 64 $.\n", - "\n", - "Pick the value of $ m $ as 1, the number of the marked elements.\n", - "\n", - "As described above, $ \\ket{u} = \\sqrt{\\frac{1}{64}} \\ket{u_{marked}} + \\sqrt{\\frac{63}{64}} \\ket{u_{unmarked}} $.\n", - "\n", - "Create a quantum circuit with single qubit.\n", - "\n", - "States $ \\ket{1} $ and $ \\ket{0} $ represents the quantum state $ \\ket{u_{marked}} $ and $ \\ket{u_{unmarked}}$, respectively.\n", - "\n", - "Then, $ \\ket{u} = \\sqrt{\\frac{63}{64}} \\ket{0} + \\sqrt{\\frac{1}{64}} \\ket{1} $.\n", - "\n", - "Determine the angle $ \\theta $, the angle between $ \\ket{u} $ and $ \\ket{0} $.\n", - "\n", - "Iterate Grover's search algorithm three times by using your quantum circuit.\n", - "\n", - "For each reflection, use ry-gate (rotation).\n", - "
      \n", - "
    • Define a list to store all quantum states (with their labels) that will be visited.
    • \n", - "
    • Iterate 3 times:\n", - "
        \n", - "
      • Implement the first reflection on your qubit
      • \n", - "
      • Read the current quantum state and store it on your list
      • \n", - "
      • Implement the second reflection on your qubit
      • \n", - "
      • Read the current quantum state and store it on your list
      • \n", - "
    • \n", - "
    • Draw all visited quantum states with their labels
    • \n", - "
    • Execute your circuit 100 times
    • \n", - "
    \n", - "\n", - "Is 3 iterations enough to observe state $ \\ket{1} $ more than state $ \\ket{0} $?\n", - "\n", - "Try 4, 5, 6, 7, 8, 9, and 10 iterations.\n", - "\n", - "What is the best iteration number?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#\n", - "# your code is here\n", - "#\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "click for our solution" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Task 4

    \n", - "\n", - "Repeat Task 3 for $ k = 8 $ and $ m = 1 $, but algorithmically find the best iteration number, say $B$. \n", - "\n", - "You may execute your circuit 1000 times to have more reliable results.\n", - "
    \n", - " Hint:\n", - "\n", - "For each iteration number, you may check how many times the state $ \\ket{1} $ is observed. \n", - "

    \n", - "This value should be at least 500.\n", - "\n", - "And, when this value starts to decrease, you may announce the previous iteration number as the best. \n", - "
    \n", - "
    \n", - "Our solution outputs $ B $ as 12 in every execution." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "click for our solution" - ] - } - ], - "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.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B01_ Acknowledgements.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B01_ Acknowledgements.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B02_cells_in_notebook.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B02_cells_in_notebook.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B04_hello_from_quantum_world.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B04_hello_from_quantum_world.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B06_Python_Quick_Reference.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B06_Python_Quick_Reference.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B08_Python_Basics_Variables.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B08_Python_Basics_Variables.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B10_Python_Basics_Loops.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B10_Python_Basics_Loops.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B12_Python_Basics_Conditionals.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B12_Python_Basics_Conditionals.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B14_Python_Basics_Lists.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B14_Python_Basics_Lists.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B16_Lists_Vectors.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B16_Lists_Vectors.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B18_Lists_Inner_Product.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B18_Lists_Inner_Product.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B20_Lists_Matrices.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B20_Lists_Matrices.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B22_Lists_Tensor_Product.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B22_Lists_Tensor_Product.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B24_One_Bit.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B24_One_Bit.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B26_Coin_Flip.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B26_Coin_Flip.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B28_Coin_Flip_Game.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B28_Coin_Flip_Game.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B32_Probabilistic_States.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B32_Probabilistic_States.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B36_Probabilistic_Operators.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B36_Probabilistic_Operators.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B40_Quantum_Coin_flipping.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B40_Quantum_Coin_flipping.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B42_Hadamard.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B42_Hadamard.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B44_One_Qubit.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B44_One_Qubit.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B46_Quantum_State.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B46_Quantum_State.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B48_Superposition.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B48_Superposition.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B56_Two_Qubits.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B56_Two_Qubits.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B60_Superdense_Coding.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B60_Superdense_Coding.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B64_Phase_Kickback.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B64_Phase_Kickback.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B72_Rotations.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B72_Rotations.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B80_Reflections.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B80_Reflections.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze/B88_Grovers_Search.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze/B88_Grovers_Search.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/bronze/bronze_getting_started.ipynb b/community/awards/teach_me_quantum_2018/bronze/bronze_getting_started.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/intro2qc/1.Introduction.ipynb b/community/awards/teach_me_quantum_2018/intro2qc/1.Introduction.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/intro2qc/10.Quantum error correction.ipynb b/community/awards/teach_me_quantum_2018/intro2qc/10.Quantum error correction.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/intro2qc/2.Linear algebra.ipynb b/community/awards/teach_me_quantum_2018/intro2qc/2.Linear algebra.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/intro2qc/3.Quantum mechanics.ipynb b/community/awards/teach_me_quantum_2018/intro2qc/3.Quantum mechanics.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/intro2qc/4.Quantum computation.ipynb b/community/awards/teach_me_quantum_2018/intro2qc/4.Quantum computation.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/intro2qc/5. Writing a quantum program with QISKit.ipynb b/community/awards/teach_me_quantum_2018/intro2qc/5. Writing a quantum program with QISKit.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/intro2qc/6.First quantum algorithms.ipynb b/community/awards/teach_me_quantum_2018/intro2qc/6.First quantum algorithms.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/intro2qc/7.Quantum teleportation.ipynb b/community/awards/teach_me_quantum_2018/intro2qc/7.Quantum teleportation.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/intro2qc/8.Shor's algorithm.ipynb b/community/awards/teach_me_quantum_2018/intro2qc/8.Shor's algorithm.ipynb old mode 100755 new mode 100644 diff --git a/community/awards/teach_me_quantum_2018/intro2qc/9.Quantum criptography.ipynb b/community/awards/teach_me_quantum_2018/intro2qc/9.Quantum criptography.ipynb old mode 100755 new mode 100644