Intro to Quantum Computing

Intro to Quantum Computing

With the evolution of technology in the 21st century, a new term has been announced to the public, quantum computing, I'm sure many of us weren’t big fans of physics class, therefore quantum mechanics is probably a nightmare, yet, it is quite interesting that lead to the formation of the most powerful computing device on the face of the earth.

Quantum computing mainly focused on the principles of Quantum mechanics. It is well known now that computers today rely on two fundamental numbers, 0’s and 1’s, where 0 means the off part, and 1 is the one part. On the contrary, Quantum Computers rely on the laws of quantum mechanics, sound interesting?

First a brief history of quantum mechanics:

Quantum mechanics has a very small element to work with, a photon. It is the smallest discrete amount of the radiation of electromagnet, the simplest and the most basic unit of light. A quantum computer basic element is a photon, a photon is constantly moving, they never stop moving under any circumstances, and the speed of a photon is 2.998 x 10^8 m/s which is also known as the speed of light. Also, Einstein proved that light is a bunch of photons flowing.

Let us simplify the idea, photons are very fast, therefore, a quantum computer whose basic element is photon will be faster than classical computers.

Thus, quantum computers are needed due to their heavy computation, they can solve 99% of the large compilation problems that need superpowers.

Getting back to the idea of 1 and 0, a quantum computer will calculate the probability of a photon before measuring it, why is that? In quantum physics, all objects are measured after observation, so actually, you won’t know if the value of a particle is 0 or 1, not like classical computers, where if it is open, then definitely 1, otherwise it will be equal to 0, there is no in-between value.

So, a bit in classical computers is Qubits, for example, a Qubit can be a state of undefined properties of an object before being detected, for example, a spin of an electron.

Credit: Jason Petta, Physics Department, Princeton University

The complication of quantum computers is that unmeasured quantum states occur in a combination of superpositions. Just exactly when measuring a flipped coin in the air.

So, what is superposition?

Superposition is mainly the most fundamental principle of quantum mechanics, where it states that referring back to the waves in classical physics, any two or more quantum states can be added together where it will result in a valid quantum state.

Developing a functioning quantum computer necessitates keeping an item in a state of superposition long enough to perform different operations on it.

Nevertheless, when a superposition collides with components that are part of a measuring system, it drops its in-between state and becomes a boring old classical bit, which is known as decoherence.

Devices must be able to protect quantum states from decoherence while still allowing them to be read easily.

Different methods are approaching this difficulty from various perspectives, whether it is to utilize more robust quantum processes or to discover better techniques to detect faults.

For now, classical computers still can't handle the work that can be done by a quantum computer, yet the idea of a quantum computer is instead of spending 100 years solving a problem, we can run it and solve it in 10 minutes, and this is the idea of quantum computers. As Referring to big O, we can approximately be aware that the time of O((logN)k) represents the classical algorithm time, and up to O(logN) is taken by the quantum algorithm. Further, run time can largely vary: O(exp(L1/3(logL)2/3) is taken by classical computers, and O((L)3) for quantum computers, where L is the length of the number N of bits.

A Quantum Computing Hello World

We will state a simple “hello, world” quantum circuit, the different part of the quantum computing program compared to classical computer’s programs, is that a “hello, world!” doesn't show an output of the phrase, where it is the basic gates used in a quantum circuit, where you as a programmer will be sensing circuits and combine it with codes, so bear with me while I show you the most basic steps to initiate the “hello, World” circuit:

First, if you can recall discrete mathematics, then a quantum circuit will be so easy to implement.

Before starting with the Quantum Circuit will discuss the basic elements of the circuit, as you will see later, we used 3 basic elements; Hadamard gate, CNOT gate, measurement operations, will discuss each one first:

  • Hadamard gate single-qubit operation I'm not going into the math behind it, but this gate confuses the state of a single qubit where it doesn't matter if you add |0> or |1> qubit the output chances will be equal to measuring both of them on the other side.
  • CNOT gate also known as Controlled-not gate it is also the quantum xor, it has two inputs, therefore it will have two outputs, note that the target input is negated only if the control input is set to 1 so if it is 0 the gate has no effect.
  • Finally measuring operations, a measurement gate is used to implement the measurement when it is combined with gates, also it isn't a reversible operation.

Now starting with the steps:

  1. Adding H gate, Hadamard gate to q [0] – which is quantum state 0, Hadamard gate transform q [0] from |0> to (|0> + |1>) /√2.

2. Adding a CNOT gate to the circuit, the controlled not gate will be from q [0] to q [1], the job of the CNOT gate is to flip q [1] from 0 to 1 or 1 to 0, in this case, q [0] is 1.

3. Finally, we will be adding measurement operations, measurement operations are classical bits on the classical registers, there will be two measurements operations, the first one is on qubit 1 and the other one is on qubit 0.

Below you can see the Code of this Quantum Circuit:

include "";
qreg q [3];
creg c [3];
h q [0];
cx q [0], q [1];
measure q [0] -> c [0];
measure q [1] -> c [1];

So, we’ve done our “Hello, World '' quantum circuit where it was testing the bits. It is a bit hard to start reading about such a topic, but once you start it you can't stop it.  Now I will leave you with another question to see if you can solve it:

The algorithm of it is:

8-sided quantum dice that generate random results!

  1. Importing pyquil modules 2 – create a connection to QVM
  2. Apply Hadamond to three Qubit → 8, were 2 to the power of h
  3. Measure Qubit to Generate Results.
  4. Execute the program by running the QVM!


Quantum computers are yet in their early development phases, as it needs a room set to absolute zero, it is possible to assume that it will take a while before it gets distributed among the public. However, quantum computers are well known for their high computational power, whereas it solves intensive calculations at a glance. This will enhance different areas such as security by boosting the cryptographic algorithms, better AI that is based on large datasets that need large computational power, enhanced drug research since most medicinal researches require large datasets and molecular predictions, and better weather predictions since quantum computers do the tests and run all the data simultaneously.

If you have a problem and no one else can help. Maybe you can hire the Kalvad-Team.