# From Bits to Qubits: The Quantum Leap

**Harnessing the Power of Entanglement for Computation — Part 2**

Before diving into Qubits and quantum gates, let’s refresh basic logic gates used in classical computing. Computers perform calculations in binary because the transistors that their processors are built from only have two states (1 and 0).

**Classical Computing and Logic Gates**

In classical computing, there are seven basic logic gates, which are the fundamental building blocks for more complex operations. These gates are used to perform basic logical operations on binary data (bits), where each bit can be in one of two states, represented as 0 or 1. The seven basic gates are:

**AND Gate:**Outputs true (1) only if both inputs are true (1).**OR Gate:**Outputs true (1) if at least one of the inputs is true (1).**NOT Gate (Inverter):**Outputs the opposite of the input; if the input is true (1), the output is false (0), and vice versa.**NAND Gate:**Outputs false (0) only if both inputs are true (1). It is the inverse of the AND gate.**NOR Gate:**Outputs true (1) only if both inputs are false (0). It is the inverse of the OR gate.**XOR Gate (Exclusive OR):**Outputs true (1) if the inputs are different; one true and one false.**XNOR Gate (Exclusive NOR):**Outputs true (1) if the inputs are the same; either both true or both false. It is the inverse of the XOR gate.

These basic gates can be combined in various ways to create more complex circuits, capable of performing intricate computations and tasks. In addition to these, there are various other derived or complex gates used in digital circuits, but the seven listed above are the foundational ones in classical logic gate theory.

**Qubits**

Similar to classical computing, quantum computers use qubits, which have two or more states that can be distinguished with a measurement. While classical bits are easy to measure and store information with, as these can be either 1 or 0, we will aim to measure qubits into 1 and 0 as well for these to be useful for computation. These two measurable states of a qubit are written as |0⟩ and |1⟩. These are called kets. You can visualize these as column vectors:

Another terminology that we will also come to later on is bra, written as:

These bra-ket together is called the Dirac notation.

Qubits can also exist in a superposition state, whereby it could exist in any combination of |0⟩ and |1⟩ (|ψ> = a|0⟩ + b|1⟩). This is what gives the quantum computer the edge over classical computing. The coefficients a and b can be any number, including a complex number. The relative magnitude of these two coefficients (squared magnitude) shows how much this superposition state behaves like |0⟩ or |1⟩.

**Quantum Gates**

In quantum computing, the concept of a fixed set of “basic” gates is not as straightforward as it is in classical computing. This is because quantum gates are fundamentally different from classical logic gates due to the principles of quantum mechanics, especially superposition and entanglement.

**Key Characteristics of Quantum Gates:**

- Continuous Operations: Unlike classical gates, which have discrete inputs and outputs (0 or 1), quantum gates manipulate qubits that exist in superpositions of states, leading to a continuous range of possible states. This means that quantum gates are represented by continuous transformations.
- Reversibility: Quantum gates are typically reversible, meaning that the input state can be derived from the output state. This is a requirement due to the unitary nature of quantum evolution.
- Commonly Used Gates: There are several quantum gates commonly used in quantum algorithms and quantum circuits. Unlike classical computing where you have a fixed set of basic gates, in quantum computing, you can theoretically have an infinite number of gates due to the continuous nature of quantum states. However, some gates are more commonly used, including:

**Pauli Gates (X, Y, Z Gates):**These gates rotate the qubit around the X, Y, and Z axes of the Bloch sphere (we will visit the Bloch sphere shortly).**Hadamard Gate (H Gate):**Creates a superposition of states from a single input qubit.**CNOT Gate (Controlled NOT):**A two-qubit gate that performs a NOT operation on the second qubit (target) only when the first qubit (control) is in a certain state.**Phase Shift Gates (S, T Gates):**Apply a phase shift to the qubit’s state.**Swap Gate:**Swaps the states of two qubits.

**What is a Bloch Sphere**

As discussed previously, qubits are not binary and can take an infinite number of different states during computation. We had previously defined it using the following equation: |ψ> = a|0⟩ + b|1⟩. To visualize these different states, we will utilize a Bloch sphere. The Bloch sphere is a representation of the state space of a qubit. The Bloch sphere provides a way to visualize this superposition, as well as other quantum phenomena like entanglement and quantum gates’ operations.

**Understanding the Bloch Sphere**

On the Bloch sphere, a qubit’s state is represented by a point on the surface of the sphere. The north and south poles of the sphere typically represent the states |0⟩ and |1⟩. Any point on the surface of the sphere represents a valid qubit state, which is generally a superposition of |0⟩ and |1⟩. The exact position on the sphere is determined by two angles, often denoted as θ (theta) and φ (phi). These angles define the probabilities of the qubit being measured in the |0⟩ or |1⟩ state.

The quantum gates, discussed previously, manipulate the state of qubits. On the Bloch sphere, these manipulations are represented as rotations of the point representing the qubit’s state.

**Pauli Gates (X, Y, Z):**

The X-gate rotates the qubit state around the X-axis of the Bloch sphere by 180 degrees. It’s equivalent to a NOT operation in classical computing, flipping |0⟩ to |1⟩ and vice versa.

The Y-gate rotates around the Y-axis (mapping |0⟩ to i|1⟩ and |1⟩ to -i|0⟩) and the Z-gate rotates around the Z-axis (leaving |0⟩ unchanged and mapping |1⟩ to -|1⟩).

**Hadamard Gate (H):**

The Hadamard gate creates a superposition, mapping |0⟩ to (|0⟩ + |1⟩)/√2 and |1⟩ to (|0⟩ — |1⟩)/√2. On the Bloch sphere, this corresponds to a rotation that takes the poles to the equator, creating a superposition of |0⟩ and |1⟩.

**Phase Shift Gates (S, T):**

These gates rotate the qubit state around the Z-axis by different amounts. The S-gate (also called the π/2 gate) and the T-gate (π/4 gate) apply specific phase shifts to the qubit state.

**CNOT Gate and Entanglement:**

The Controlled Not gate (CNOT or CX) acts on 2 qubits and will be one of the most important gates that you will be using. While the Bloch sphere represents the state of a single qubit, gates like the CNOT are two-qubit gates and involve changes in entanglement, which the Bloch sphere doesn’t directly visualize. The CNOT gate changes the state of one qubit conditional on the state of another, a fundamental operation for creating entangled states.

This is Part 2 in a series of articles on quantum computing. The links to all the parts are below: