Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Dancing with Qubits

You're reading from   Dancing with Qubits From qubits to algorithms, embark on the quantum computing journey shaping our future

Arrow left icon
Product type Paperback
Published in Mar 2024
Publisher Packt
ISBN-13 9781837636754
Length 684 pages
Edition 2nd Edition
Arrow right icon
Author (1):
Arrow left icon
Robert S. Sutor Robert S. Sutor
Author Profile Icon Robert S. Sutor
Robert S. Sutor
Arrow right icon
View More author details
Toc

Table of Contents (26) Chapters Close

Preface I Foundations
Why Quantum Computing FREE CHAPTER They’re Not Old, They’re Classics More Numbers Than You Can Imagine Planes and Circles and Spheres, Oh My Dimensions 6 What Do You Mean “Probably”? II Quantum Computing
One Qubit Two Qubits, Three Wiring Up the Circuits From Circuits to Algorithms Getting Physical III Advanced Topics
Considering NISQ Algorithms Introduction to Quantum Machine Learning Questions about the Future Afterword
A Quick Reference B Notices C Production Notes Other Books You May Enjoy
References
Index
Appendices

7.6 Professor Hadamard, meet Professor Pauli

Other than mapping the state of a qubit to a Bloch sphere and looking at it differently, what can you do with a qubit? This section looks at the operations, also called gates, which you can apply to a single qubit. Later, we expand our exploration to gates with multiple qubits as inputs and outputs. In Chapter 9, “Wiring Up the Circuits,” we build circuits with these gates to implement algorithms. gate$quantum gate$reversible

Here, for example, is a circuit with one qubit initialized to |0⟩ that performs one operation, X, and then measures the qubit. The result of the measurement is |m0.

A simple circuit with an X gate

Quantum gates are always reversible, but some other operations are not. Quantum gates correspond to unitary transformations. Measurement is irreversible, and so is the |0⟩ RESET operation described in section 7.6.14. operation$measurement operation$|0⟩ RESET`gate-style |0⟩ RESET`gate-style

When I include the measurement operation in a circuit in the next chapter and beyond, it looks like this: qubit$measurement measurement

The measurement operation

Measurement returns a |0⟩ or |1⟩. Mathematically, we do not worry about how it happens other than the probability.

Since a qubit state is a two-dimensional complex ket or vector, all quantum gates have 2-by-2 matrices with complex entries relative to some basis. This makes them small and very easy to manipulate. They are unitary matrices.

If A is a complex square matrix, then it is unitary if its adjoint A is also its inverse A–1. Hence AA = AA = I. The columns of A are orthonormal, as are the rows. matrix$unitary

|det(A)| = 1. This equality says the absolute value of the determinant is 1, not that the determinant is 1. Since it is a unit in C, the determinant is eφi for 0 ≤ φ < 2π.

The remainder of this section is a catalog of the most useful and commonly used 1-qubit quantum gates. As you will see, there is often more than one way to accomplish the same qubit state change. Why you would want to do so is the topic of Chapter 9, “Wiring Up the Circuits.”

7.6.1 The quantum ID gate

The ID gate does nothing, but we typically employ it when constructing or drawing circuits to show something happening to every qubit at every step. We can represent it by multiplication by I2, the 2-by-2 identity matrix. I2 is both unitary and Hermitian. gate$ID`gate-style ID`gate-style

When I include the ID gate in a circuit, it looks like this:

The quantum ID gate

We also put the ID gate in a circuit to indicate a place to pause or delay. Its presence allows, for example, researchers to calculate measurements of the decoherence of a qubit.

7.6.2 The quantum X gate

The X gate has the matrix gate$X`gate-style X`gate-style σx`italic matrix$σx σ0`italic matrix$σ0

Displayed math

and this is the Pauli X matrix, named after Wolfgang Pauli, who won the Nobel Prize in Physics in 1945 (Figure 7.14). σx is both unitary and Hermitian. I often use the same name (in this case, X) for both the gate and its matrix in the standard basis kets. When we are not considering the matrix with respect to a specific basic, we refer to the X operator. Pauli, Wolfgang Pauli$matrix matrix$Pauli operator$Pauli

We also consider I2 a Pauli matrix and refer to it as σ0.

 Figure 7.14: The physicist Wolfgang Pauli, 1900–1958

It has the property that

Displayed math

It “flips” between |0⟩ and |1⟩. The classic not gate is gate$not`gate-style not`gate-style

Displayed math

The not gate is a “bit flip,” and, by analogy, we also say X is a bit flip. gate$bit flip

For |ψ⟩ = a|0⟩ + b|1⟩ in C2,

Displayed math

X reverses the probabilities of measuring |0⟩ and |1⟩.

In terms of the Bloch sphere, the X gate rotates by π around the x-axis. So, the poles are flipped, and points in the lower hemisphere move to the upper, and vice versa.

Since XX = ID, the X gate is its own inverse. This is reasonable because, in the classical case, it is also true that notnot is the identity operation.

When we considered rotations, we saw that the matrix for R3 that does a rotation around the x-axis by θ radians works like rotation

Displayed math

Plugging in θ = π, the rotation matrix is

Displayed math

In R3 standard coordinates, |0⟩ = (0, 0, 1) and |1⟩ = (0, 0, –1). Applying the rotation matrix, we get:

Displayed math

You can see this flipped |0⟩ and |1⟩. What about |+⟩ and |–⟩?

Displayed math

As you would expect from looking at the geometry of the Bloch sphere, it leaves these alone.

Exercise 7.18

What does the X gate do to |i and |–i?

Exercise 7.19

What are the eigenvectors and eigenvalues of σx in C2 relative to the standard basis?

When I include the X gate in a circuit, it looks like this:

The quantum X gate

You may also see it shown in some literature and software tools as a circle surrounding a plus sign:

The quantum X gate, alternative form

The horizontal line, called a wire, represents the qubit and its state. The input state enters on the left, the X unitary transformation is applied, and the new quantum state result comes out on the right side. wire

7.6.3 The quantum Z gate

The Z gate has the matrix gate$Z`gate-style Z`gate-style σz`italic matrix$σz

Displayed math

and this is the Pauli Z matrix. It rotates qubit states by π around the z-axis on the Bloch sphere. σz is both unitary and Hermitian. Pauli$matrix matrix$Pauli operator$Pauli

The Z gate swaps |+⟩ and |–⟩ as well as |i and |–i. It leaves |0⟩ and |1⟩ alone on the Bloch sphere.

Since ZZ = ID, the Z gate is its own inverse. If you rotate by π and then rotate by π again, you end up back where you started.

For |ψ⟩ = a|0⟩ + b|1⟩ in C2,

Displayed math

The probabilities of measuring |0⟩ and |1⟩ do not change after applying Z.

In C2, σz has eigenvalues +1 and –1 for eigenvectors |0⟩ and |1⟩, respectively. Per section 7.3.4, Z or σz is the observable for the standard computational basis |0⟩ and |1⟩.

Remember that |1⟩ and –|1⟩ = eπi |1⟩ in C2 map to the same point we are also calling |1⟩ on the Bloch sphere because they differ only by multiplication by a unit, –1 = eπi. If we express

Displayed math

then

Displayed math

We change the relative phase of |ψ to π plus that relative phase, adjusted to be between 0 and2π. This is a phase flip, and we call Z a phase flip gate. Since it reverses the sign of the second amplitude, it is also called a sign flip gate. gate$phase flip phase$flip gate$sign flip

When I include the Z gate in a circuit, it looks like this:

The quantum Z gate
Exercise 7.20

Show by calculation that XZ = – ZX.

7.6.4 The quantum Y gate

The Y gate has the matrix gate$Y`gate-style Y`gate-style σy`italic matrix$σy

Displayed math

and this is the Pauli Y matrix. It rotates qubit states by π around the y-axis on the Bloch sphere. σy is both unitary and Hermitian. Pauli$matrix matrix$Pauli operator$Pauli

It swaps |0⟩ and |1⟩ and so is a bit flip. It also interchanges |+⟩ and |–⟩ but leaves |i and |–i alone.

Since YY = ID, the Y gate is its own inverse.

For |ψ⟩ = a|0⟩ + b|1⟩ in C2,

Displayed math

From this, we can see that Y simultaneously does a bit flip and a phase flip. In C2, σy has eigenvalues +1 and –1 for eigenvectors |i and |–i, respectively.

If |ψ⟩ = a|0⟩ + b|1⟩ in C2, then a bit flip interchanges the coefficients of |0⟩ and |1⟩. A phase flip changes the sign of the coefficient of |1⟩. A simultaneous bit and phase flip does both:

Displayed math

When I include the Y gate in a circuit, it looks like this:

The quantum Y gate
Exercise 7.21

What is the 3-by-3 rotation matrix for the Y gate?

Exercise 7.22

Show by calculation that XY = –YX and ZY = –YZ.

7.6.5 The quantum H gate

The H gate, or H⊗1 or Hadamard gate, has the matrix gate$H`gate-style gate$H⊗1`gate-style gate$Hadamard H`gate-style gate$H⊗1`gate-style

Displayed math

operating on C2.

By matrix multiplication,

Displayed math

By linearity,

Displayed math
Exercise 7.23

Show that H |–⟩ = |1⟩.

The Hadamard gate, named after Jacques Hadamard (Figure 7.15), is one of the most frequently used gates in quantum computing. H is often the first gate applied in a circuit. When you read “put the qubit in superposition,” it usually means “take the qubit initialized in the |0⟩ state and apply H to it.”

 Figure 7.15: The mathematician Jacques Hadamard, 1865–1963

The Hadamard matrix is the change of basis matrix from {|0⟩, |1⟩} to {|+⟩, |–⟩}. Since HH = ID, the H gate is its own inverse. basis$change of

A change of basis from the computational basis {|0⟩, |1⟩} to the Hadamard basis {|+⟩, |–⟩} changes a bit flip X to a phase flip Z. basis$Hadamard

When I include the H gate in a circuit, it looks like this:

The quantum H or Hadamard gate

Consider |b, where b is 0 or 1. The expression (–1)b is 1 when b = 0 and –1 when b = 1.

For our H gate, we look at

Displayed math

and notice that

Displayed math

When b = 0, we have |0⟩ going to √2/2 (|0⟩ + |1⟩). For b = 1, we end up with √2/2 (|0⟩ – |1⟩).

Exercise 7.24

Using matrix calculations, show that X = HZH.

Exercise 7.25

What is HXH?

Exercise 7.26

What is the 3-by-3 matrix for the H gate on the Bloch sphere? It is the product of two 3-by-3 rotation matrices. What are they?

7.6.6 The quantum Rφz gates

We can generalize the phase-changing behavior of the Z gate by noting gate$Rφz`gate-style gate$Rφz`gate-style

Displayed math

This last form is the template for the collection of gates given the name Rφz:

Displayed math

|1⟩ is an eigenvector of Rφz with eigenvalue e φi.

This collection is infinite as φ can take on any radian value greater than or equal to 0 and less than 2π. These gates change the phase of a qubit state by φ. This is a parameterized z-rotation gate, with φ being the parameter. gate$parameterized

Exercise 7.27

What is the 3-by-3 rotation matrix for Rφz? For Z?

The inverse of Rφz is R2π-φz. R0z = ID. Rπz = Z.

When I include the Rφz gate in a circuit for a particular value of φ, it looks like this:

The quantum Z rotation gate

Since

Displayed math

an alternative form of the matrix for Rφz up to a global phase change is

Displayed math

eφi/2 is a complex unit, and multiplication by it is not observable when we measure.

7.6.7 The quantum S gate

The S gate is a shorthand for Rπ/2z. After applying, we adjust the phase to be greater than or equal to 0 and less than 2π: gate$S`gate-style S`gate-style

Displayed math

|1⟩ is an eigenvector of S with eigenvalue i.

Exercise 7.28

What is the 3-by-3 rotation matrix for the S gate?

When I include the S gate in a circuit, it looks like this:

The quantum S gate

Traditionally and confusingly, the S gate is also known as the π/4 gate. This is because we can express the matrix in this way: gate$π/4

Displayed math

The unit factor eπi/4 in front does not have an observable effect on the quantum state of the result of applying S. Some authors call S “the phase gate,” but I won’t. gate$phase phase gate

7.6.8 The quantum S gate

The S (pronounced “S dagger”) gate is a shorthand for R3π/2z = Rπ/2z. After applying, we adjust the phase to be greater than or equal to 0 and less than 2π: gate$S`gate-style S`gate-style

Displayed math

|1⟩ is an eigenvector of S with eigenvalue i.

The gate gets its name because the matrix for S is the adjoint of the S matrix:

Displayed math
Exercise 7.29

What is the 3-by-3 rotation matrix for the S?

When I include the S gate in a circuit, it looks like this:

The quantum adjoint S or S dagger gate

7.6.9 The quantum T gate

The T gate is a shorthand for Rπ/4z. After applying, we adjust the phase to be greater than or equal to 0 and less than 2π: gate$T`gate-style T`gate-style

Displayed math

|1⟩ is an eigenvector of T with eigenvalue √2/2 + √2/2i.

Exercise 7.30

What is the 3-by-3 rotation matrix for the T gate?

We can get the S by applying the T twice: S = TT.

When I include the T gate in a circuit, it looks like this:

The quantum T gate

The T gate is also known as the π/8 gate. We can write its matrix as gate$π/8

Displayed math

The unit factor eπi/8 in front does not have an observable effect on the quantum state of the result of applying T.

7.6.10 The quantum T gate

The T  gate (pronounced “T dagger”) is a shorthand for R7π/4z = Rπ/4z. After applying, we adjust the phase to be greater than or equal to 0 and less than 2π: gate$T`gate-style T`gate-style

Displayed math

|1⟩ is an eigenvector of T  with eigenvalue √2/2 – √2/2i.

It gets its name because the matrix for T  is the adjoint of the T matrix:

Displayed math
Exercise 7.31

What is the 3-by-3 rotation matrix for the T  gate?

We can get the T by applying the T  twice: S = T T .

When I include the T  gate in a circuit, it looks like this:

The quantum adjoint T or T dagger gate

7.6.11 The quantum Phφ global phase gate

Our next 1-qubit parameterized gate is the global phase gate Phφ: gate$Ph`gate-style Ph`gate-style

Displayed math

Phφ has no observable effect on the qubit when it is measured.

Exercise 7.32

What gate do you get when φ = 0?

Exercise 7.33

How does this differ from the Rφz gate?

When I include the Phφ gate in a circuit, it looks like this:

The quantum global phase gate

7.6.12 The quantum Rφx and Rφy gates

Just as Rφz is an arbitrary rotation around the z-axis, we can define gates that rotate around the x- and y-axes: gate$Rφx`gate-style gate$Rφx`gate-style gate$Rφy`gate-style gate$Rφy`gate-style

Displayed math

and

Displayed math

These are parameterized x- and y-rotation gates, with φ being the parameter. gate$parameterized

When I include these gates in circuits, they look like this:

The quantum X rotation gate The quantum Y rotation gate
Exercise 7.34

Show that H = XRπ/2y.

7.6.13 The quantum √NOT gate

Another gate used in the quantum computing literature is the “square root of NOT” gate. It has the matrix gate$√NOT`gate-style √NOT`gate-style

Displayed math

Squaring this, √NOT√NOT, we get

Displayed math

The X gate is the quantum version of not, and that’s how this gate gets its name.

Exercise 7.35

Show that √NOT is unitary. What is its determinant? What does it do to |0⟩ and |1⟩?

When I include this gate in a circuit, it looks like this:

The quantum square root of NOT gate

The adjoint of this gate has the matrix

Displayed math
Exercise 7.36

What is the square of the adjoint of the “square root of NOT” gate?

When I include this gate in a circuit, it looks like this:

The quantum adjoint square root of NOT gate
Exercise 7.37

What are the matrices for the √Y and √Z gates? gate$√Y`gate-style √Y`gate-style gate$√Z`gate-style √Z`gate-style

7.6.14 The quantum |0⟩ RESET operation

Though it is not a reversible unitary operation, and hence, not a gate, some quantum computing software environments allow you to reset a qubit in the middle of a circuit to |0⟩. This operation, denoted |0⟩ RESET, is convenient if you use a qubit as a temporary scratchpad for multiple values within an algorithm. operation$|0⟩ RESET`gate-style |0⟩ RESET`gate-style

This operation may make your code nonportable across different quantum computing architectures and software development kits.

When I include this operation in a circuit, it looks like this:

The |0> RESET operation
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime