Reader small image

You're reading from  Quantum Computing Algorithms

Product typeBook
Published inSep 2023
PublisherPackt
ISBN-139781804617373
Edition1st Edition
Right arrow
Author (1)
Barry Burd
Barry Burd
author image
Barry Burd

Barry Burd received a master's degree in computer science at Rutgers University and a Ph.D. in mathematics at the University of Illinois. As a teaching assistant in Champaign–Urbana, Illinois, he was elected five times to the university-wide List of Teachers Ranked as Excellent by Their Students. Since 1980, Dr. Burd has been a professor in the department of mathematics and computer science at Drew University in Madison, New Jersey. He has spoken at conferences in the United States, Europe, Australia, and Asia. In 2020, he was honored to be named a Java Champion. Dr. Burd lives in Madison, New Jersey, USA, where he spends most of his waking hours in front of a computer screen.
Read more about Barry Burd

Right arrow

What Is a Qubit?

“A qubit is a quantum bit.” That’s a nice soundbite, but what does it mean? In this chapter, we’ll do our best to answer that question.

To describe a qubit, we’ll start with a rough analogy. We’ll rely on some very informal (maybe even heretical) terminology and work our way to a more precise description.

Our description will take several forms. We’ll start by drawing a sharp distinction between qubits and classical bits. We’ll assert that a qubit’s value isn’t necessarily 0 or 1. Instead, a qubit’s value can be a number (of some kind) that’s between 0 and 1. To make this assertion more believable, we’ll explain how to implement qubits in a laboratory using elementary particles such as electrons and photons.

A bit can sit quietly on a thumb drive without ever being read by a computer of any kind. The bit’s value is 0 or 1, whether anyone ever reads the bit or...

Technical requirements

Every chapter in this book requires that you have access to a web browser. You can download each chapter’s Python code from the following GitHub link: https://github.com/PacktPublishing/Quantum-Computing-Algorithms.

A qubit’s values between 0 and 1

A bit’s value is either 0 or 1. In contrast, a qubit’s value can be |0, |1, or anything in between |0 and |1. But that’s not the whole story. Imagine a qubit that (in some way or other) is halfway between |0 and |1. This qubit has infinitely many different ways of being between |0 and |1. To understand this infinite number of ways, we need some visual aids.

Pictorially, each bit is on one of two points. Figure 2.1 shows these points:

Figure 2.1 – A bit’s value is either 0 or 1

Figure 2.1 – A bit’s value is either 0 or 1

In contrast, we can think of a qubit as being somewhere on the surface of a sphere. We call it a Bloch sphere. Here are some facts about the Bloch sphere:

  • A qubit on the Bloch sphere’s north pole has a value of |0. Figure 2.2 shows this sphere:
Figure 2.2 – A |0⟩ qubit

Figure 2.2 – A |0 qubit

    ...

Qubits and Qiskit

Chapter 1, New Ways to Think about Bits, introduced Jupyter notebooks and showed you how to multiply matrices in Python. In this chapter, we’ll up the ante with Qiskit code for qubits. We’ll write code to create qubits, modify qubits’ values using quantum operators, measure qubits, and then display the results.

Creating and running a quantum circuit

To create your first quantum computing program, follow these steps:

  1. Create a new Jupyter notebook by following Steps 1 through 3 in the Matrices in Python section in Chapter 1, New Ways to Think about Bits.
  2. In the cell at the top of the notebook, copy the following code, and then press Shift + Enter:
    from qiskit import QuantumRegister, \
        ClassicalRegister, QuantumCircuit
    qReg = QuantumRegister(1, 'q')
    cReg = ClassicalRegister(1, 'c')
    circuit = QuantumCircuit(qReg, cReg)
    circuit.h(qReg[0])
    circuit.measure(qReg[0], cReg[0])
    display(circuit...

Variations of this chapter’s code

This book doesn’t cover all the features of Qiskit’s extensive library, but it does cover enough of Qiskit to help you implement some important quantum computing algorithms. To this coverage, we have added some discussion of features that make Qiskit coding easier. Qiskit provides a dozen ways to accomplish any particular task, and this book describes two or three of them.

In the previous section, you learned one way to create and display quantum circuits. In this section, you’ll learn a few more tricks.

Drawing circuits

Consider the following code:

from qiskit import QuantumRegister, \    ClassicalRegister, QuantumCircuit
qReg = QuantumRegister(2, 'q')
qRegNew = QuantumRegister(2, 'qNew')
cReg = ClassicalRegister(2, 'c')
cRegNew = ClassicalRegister(1, 'cNew')
circuit = QuantumCircuit(qReg, qRegNew, cReg, cRegNew)
display(circuit.draw('latex&apos...

Summary

A qubit is like a bit, except that a qubit’s value can be between |0 and |1. What between means requires more explanation but, in this chapter, we described between in a statistical fashion.

There’s no way for us to determine that a single qubit’s state is between |0 and |1. Instead, being halfway between |0 and |1 means that, if you measure many such qubits, you get 0 approximately half the time and 1 all the other times. All we can do is record these measurement tallies. As my friend and colleague, Ashley Carter, once said, “Quantum mechanics isn’t about what “is.” Quantum mechanics is about what we can measure.

In the next chapter, we’ll use mathematics to describe qubits more precisely.

Questions

Alice stands up straight while she performs experiments with photons and filters. In each of the experiments, vertical refers to the way Alice is standing, and horizontal refers to the line of the floor:

  1. In the first experiment, 1,000 vertically polarized photons hit a vertically polarized filter. How many of the photons get through the filter?
  2. In the next experiment, 1,000 vertically polarized photons hit a horizontally polarized filter. How many of the photons get through the filter?
  3. In Alice’s next experiment, 1,000 vertically polarized photons hit a diagonally polarized filter. The ones that make it through hit another filter that’s diagonally polarized in the same direction as the first filter. Assuming that 500 photons made it through the first filter, how many of them make it through the second filter?
  4. In another experiment, 1,000 vertically polarized photons hit a diagonally polarized filter. The ones that make it through hit another...
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Quantum Computing Algorithms
Published in: Sep 2023Publisher: PacktISBN-13: 9781804617373
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.
undefined
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 $15.99/month. Cancel anytime

Author (1)

author image
Barry Burd

Barry Burd received a master's degree in computer science at Rutgers University and a Ph.D. in mathematics at the University of Illinois. As a teaching assistant in Champaign–Urbana, Illinois, he was elected five times to the university-wide List of Teachers Ranked as Excellent by Their Students. Since 1980, Dr. Burd has been a professor in the department of mathematics and computer science at Drew University in Madison, New Jersey. He has spoken at conferences in the United States, Europe, Australia, and Asia. In 2020, he was honored to be named a Java Champion. Dr. Burd lives in Madison, New Jersey, USA, where he spends most of his waking hours in front of a computer screen.
Read more about Barry Burd