Image for post
Image for post
Photo by Phil Hearing

QC — Programming with Quantum Gates (Single Qubits)

Quantum computing uses a different paradigm in writing programs. In this article, we describe the quantum gates — the basic units for quantum programming. If you are not familiar with Qubits, we will suggest you visit Part2 and Part 3 of this series first.

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Qubits manipulation

A superposition can be written as:

Image for post
Image for post
Image for post
Image for post

Quantum algorithm

So what is the general flow of a quantum algorithm? First, we prepare the superposition. Then we encode the problem information into the superposition and manipulate it in a high dimensional space. Finally, we apply interference to consolidate the superposition into fewer outcomes. (Note: there are other possibilities and omitted for simplicity.)

Image for post
Image for post
Source
Image for post
Image for post
Image for post
Image for post
Source: IBM
Image for post
Image for post

Hadamard Gate

One of the most common quantum gates is the Hadamard Gate.

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Source
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Global phase

Actually, a superposition can be represented as

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Pauli gates

Other single-qubit gates are pretty straightforward. So feel free to browse through the single-gate quickly. The next 3 Pauli gates rotate the superposition along x, y or z-axis.

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Phase shift

There are a few gates that rotate the vector around the z-axis, namely Z, S, and T-gate.

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Measurement

Here is the symbol in taking a measurement.

Image for post
Image for post

Identity matrix

An identity gate does nothing.

Image for post
Image for post
Image for post
Image for post

Next

In general, all these single-qubit operators is about moving the vector along the surface of the unit sphere. Let’s move to multi-qubit gates which are more tricky. These gates deal with entanglement which is extremely important in quantum computing.

Written by

Deep Learning

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store