Getting started with Development in Quantum Computing
By: Utkarsh Mehta
Tags: Ibm Q, Qbits, Quantum Computing, Qiskit

When Classical computers were just some registers on boards and scientists were performing basic functionality on them, that is the current state of Quantum computers right now.

So Quantum Researchers are working on developing new Circuits (these are Quantum Circuits made using gates that execute a particular operation) and Algorithms to find new use cases & applications for Quantum Computers.

Following companies are researching and developing Quantum computers:

So we are focusing on IBM here, as they have plugged their Quantum Computer worth millions to the cloud and provided access to the whole world for free.

So in order to work on Quantum Computer, you don’t need to be a Quantum Physicist.

You just need to understand the basics of Maths, other things you can pick up as you move forward.

IBM provides jupyter notebook-based environment on their website to code and test on their quantum computers or simulators. But it’s always better to work directly so from our system so let’s set up the working environment on our systems.

First Step, Download & Install Anaconda Python (make sure you download Python 3.7 version or more)

Second Step, Install Qiskit library using (terminal on Linux and Mac & Anaconda prompt on Windows) and following command,

pip install qiskit

Third Step, After qiskit installation type the following command in the same terminal.

jupyter notebook

So now you can start coding in python3 for IBM Quantum Computers from here.

So Jupyter Notebook makes it really easy to use Python 3 environment and for continuous development and the main feature I feel is that you can just write a line of code and press shift enter and see the output of that code immediately or you can shift between lines of code or fix bugs and rerun a particular block of code basically it just makes it really easy to develop and debug applications.

So, let’s create a Quantum Circuit,

Line wise explanation,

Import everything from qiskit. Get 2 quantum registers i.e. Qbits. Get 2 classical registers to measure the values in the quantum registers. Create a quantum circuit using registers. Matplotlib inline directive for graphics Draw the circuit which looks like following,

I know it looks confusing let draw it like we are not in '90s.

mpl stands for matplotlib

Now let’s add some gates. First up is H gate is also known as Hadamard Gate (https://www.quantum-inspire.com/kbase/hadamard/). In short, it sets the state of a single qubit in Superposition.

In superposition a quantum bit can be 0 and 1 at the same time.

So we added H gate on the first qbit. Moving ahead we will add a Controlled Not (CX) gate from qbit 0 to qbit 1.

So basically whenever qbit-0 is 1 then it will flip the value of qbit-1

if qbit-0 == 1 qbit-1 =Flip(qbit-1)

if qbit-0 = 1 & qbit-1 = 0 then CX will set qbit-1 to 1

if qbit-0 = 1 & qbit-1 = 1 then CX will set qbit-1 to 0

Now as we have a very basic circuit ready let’s add some measurements to this.

Here what we are doing is measuring all the qbits in qr and saving the values in all the classical bits cr.

Basically qbit-0 -> cbit-0 & qbit-1 -> cbit-1.

Now let’s run this code on a qasm_simulator, provided in qiskit.

So here we got the simulator from Aer which is a part of qiskit. Then we passed the circuit and simulator to execute the function again comes with qiskit.

Then in order to visualize the results we are using plot_histogram.

So you can see that we got almost 50/50 result for 00 && 11, and if you remember the way we designed the circuit, the H gate will make the output of q0 as 0 and 1, after that the CX gate will set the output of q1 as 1 when q0 is 1 or 0. So the output we got is right.

So guys this is it for now, in the next post I will introduce you to some new algorithms to use with quantum circuits and we will execute our quantum circuit on IBM quantum computers.

Thanks!! ✌️