Qiskit is an open-source quantum software development kit developed by IBM that provides help writing quantum computing programs and embeds them into different backends (statevector backend, unitary backend, openQASM backend) basic building blocks in a python programming language. Thus, Qiskit can build programs with basic quantum modules delivered by the package. One of the basics of Qiskit is quantum circuits. This article will discuss an overview of quantum computing, terminology, and working with Qiskit and visualizing the results.

## Quantum computing

Quantum computing is the field of computer science that mainly focuses on modern physics principles of quantum theory. Principles of quantum theories illustrate the behaviour of matters and energy at atomic and subatomic levels. Similarly, quantum computing explains quantum phenomena like quantum bits, superposition, etc. The quantum computing field comes in a field where the tasks are so difficult that normal computing phenomena cannot solve them. We use quantum bits or Qubits, which can be considered the memory unit. Whereas in conventional classical computing, bits represent the information by the computer. Qubits are one of the basic terminologies of quantum computing. However, there are many terminologies which we don’t know at a very basic level. We will learn the terminologies in the next steps, and it can be useful for us using python and the Qiskit package.

#### THE BELAMY

##### Sign up for your weekly dose of what's up in emerging technology.

## Getting started with Qiskit

Very basic thing about Qiskit is that it works in two stages. One of the stages is the build stage, where we make different quantum circuits and, using those circuits, we reach the solution. Then, after completing the building part or reaching the solution, we go into the next stage, which is called execute stage, where we try to run our build or solution in the different backends (statevector backend, unitary backend, openQASM backend) after completing the run we process the data in the build for desired output.

**Quantum circuit**

Quantum circuits can be considered the flow of sequential computation on quantum data, or we can call a quantum circuit the sequence of quantum gates. The basis of quanSo the computing is quantum circuits. Let’s see how we can generate the circuit using Qiskit in google colab.

Installing the Qiskit package.

Input:

`!pip install qiskit`

Importing the libraries.

Input:

```
import numpy as np
from qiskit import *
```

Building the circuit

As we discussed first fundamental of Qiskit is the quantum circuit; we can make a circuit using QuantumCircuit()

Input:

`ircuits = QuantumCircuit(4)`

Here we have created a circuit with the quantum register of 4 qubits.

After creating the circuit, we can add operations to manipulate the qubits. In the next step, we would be adding four operations on it.

Input:

```
circuits.h(0)
circuits.cx(0, 1)
circuits.cx(0, 2)
circuits.cx(0, 3)
```

Output:

Here in the above input on qubit 0, we have added h gate for superposition. And in entanglement, we have added operation for three qubits. Cx gate will control the qubit 0 and qubit one and will put the qubit in the bell state. Similarly, the cx gate in second place will control the qubit 0 and 2, and the final gate will control the qubit 0 and qubit three and put the qubit in ghz state.

We can also visualize the circuit.

Input:

`circuits.draw()`

Output:

In this circuit visualization we can see that the start qubit is on the upside, and the following qubits are on the downside side of the H gate. Therefore, the flow of the circuit will be left to the right.

As discussed earlier in the article, we have built the circuit and can now execute the circuit using qiskit modules. Qiskit’s Aer package provides the facility for simulation of circuit using different backends

Qiskit provides different backends for the simulation part in quantum computing.

The first backend we will implement for simulation is statevector_simulater, which returns a quantum state as a complex vector of **2**^{n . }**^{ }** dimension, where n is the number of qubits.

Importing the library.

Input:

`from qiskit import Aer`

Defining the job and executing it with statevector simulator

Input:

`job = execute(circuits, Aer.get_backend('statevector_simulator'))`

After compilation of the backend simulator, we can check for the status and results.

Input:

`job.status()`

Output:

Input:

```
result = job.result()
print(result)
```

Output:

We can also look for the state vector of the circuit.

Input:

```
outputstate = result.get_statevector(circuits, decimals=3)
print(outputstate)
```

Output:

We can also visualize the state density of the circuits component.

Input:

```
from qiskit.visualization import plot_state_city
plot_state_city(outputstate)
```

Output:

Qiskit also provides the unitary backend for simulation. This simulation results the **2****^{n}** ⨯

**2**

**dimensions vector.**

^{n}Input:

```
backend = Aer.get_backend('unitary_simulator')
job = execute(circuits, backend)
result = job.result()
```

Let’s check for the final solution.

Input:

`print(result.get_unitary(circuits, decimals=3))`

Output:

Input:

```
outputstate = result.get_unitary(circuits, decimals=3)
plot_state_city(outputstate)
```

Output:

We can also make OpenQASM backend with qiksit. Till now, we were simulating on the ideal circuit. In real life experiments, circuits are terminated by measuring each qubit. And without measurement, we can not gain information about the state.

Including measurement, simulation requires adding measurement on the circuit to use OpenQASM.

Creating the circuit:

Input:

```
meas = QuantumCircuit(4, 4)
meas.barrier(range(4))
meas.measure(range(4), range(4))
qc = circuits + meas
```

Visualizing the circuit.

Input:

`qc.draw()`

Output:

This circuit consists of 4 qubits and one classical register, and four measurements to map the outcome of the qubits.

Let’s simulate this circuit using OpenQASM backend.

Defining the object

Input:

`backend_sim = Aer.get_backend('qasm_simulator')`

Executing the object on the circuit.

Input:

`job_sim = execute(qc, backend_sim, shots=1024)`

Let’s check the results of the job.

Input:

`result_sim.status`

Output:

Input:

```
counts = result_sim.get_counts(qc)
print(counts)
```

Output:

Here in the output, we have asked for counts of zeros and ones, and we can see that we had some good accuracy. Where 50 per cent of the time. The output is zero. We can also visualize this count in a histogram using qiskit.

Input:

```
from qiskit.visualization import plot_histogram
plot_histogram(counts)
```

Output:

Here is the article we have seen about quantum computing and how we can perform at a basic level using the Qiskit package. There are various applications of quantum computing like Cybersecurity, artificial intelligence, financial modelling, computational biology etc. since quantum computing provides results that normal or classical computers cannot gain, it can make machine learning models work faster than the classical way.

**References**

- Qiskit package
- Google colab for python codes