...

/

Basic Quantum Simulator

Basic Quantum Simulator

In this lesson, we put together everything we have learned so far and create a basic quantum computing simulator.

In the last chapter, we learned the representation for quantum states, gates, and operations in NumPy. Now, we shall put together all those pieces and create a basic quantum computing simulator that runs small quantum circuits. As stated at the beginning of the chapter, this exercise of creating our own quantum simulator from scratch cements the understanding of the underlying mathematics and principles of quantum computing before we formally begin our discussion of practical quantum algorithms.

Disclaimer: this exercise draws inspiration from one of the screening tasks for the third cohort of the QOSF Mentorship Program.

In the following subsections, we will be building the simulator one step at a time. We will be going through the various function definitions and will look at the solution at the end of this lesson.

Defining the input

The input to our simulator will be a program (or circuit) that will take an nn qubit system, prepare them all in the 0|0\rangle state, apply a series of quantum gates, and then measure the result of this computation as a bit string.

We can define the circuit using a simple array of elements that describe the gate and target qubit(s) on which it acts. ...

Access this course and 1400+ top-rated courses and projects.