Skip to main content

Section 1.2 Building Quantum Circuits

Quantum computing operations harness quantum properties to have outputs that are not possible with classical computers. For this reason, we represent quantum programs and quantum state differently than in classical computing.
In this part of the lesson, we will learn some basic quantum operations that can be implented by classical computers and introduce a drag-and-drop tool (Q.js) you can use to build build quantum circuits. In future lessons, you will use this tool to explore the behavior of quantum operations that cause properties not possible with classical computers.

Section 1.2.1 Qubit: A quantum bit

Grace Hopper invented the compiler, which allowed programmers to often ignore the 1’s and 0’s in the machine and use higher level languages. Unfortunately, the unique features of quantum computing reveal themselves on single bits, and algorithms are still designed at the bit level. Therefore, we will operate on single bits, not integers or larger numbers.
A quantum bit, or qubit, holds a 0 or 1, just like a classical bit. However, a single qubit also holds other interesting information that we will explore throughout this course. Today, we will only use the 0 and 1. To go along with the more complex state, the representation uses slightly different syntax. We will begin that now - instead of just writing 0 or 1, we will write |0⟩ and |1⟩. Later, we will learn more about what those symbols mean.
To make it easier to visualize, we will use a white ball for |0⟩ and a black ball for |1⟩.

Section 1.2.2 Q Gate #1: NOT

Quantum operations are called gates. The simplest operation is the NOT, or X, gate. From a classical perspective, it toggles the value between 0 and 1. That is, if the input is 0, the output is 1, and vice versa.

Checkpoint 1.2.1. NOT Gate Check #1.

    What is the output of this circuit?
  • ◯ |0⟩
  • Yes! Starting with: ◯ |0⟩; apply the first NOT operation: ⬤ |1⟩; and apply the second NOT operation: ◯ |0⟩
  • ⬤ |1⟩
  • Did you apply the NOT operation two times?
Hint.
Apply the NOT gate twice.

Checkpoint 1.2.2. NOT Gate Check #2.

    What is the output of this circuit?
  • ◯ |0⟩
  • There were only two "eat cookie" operations.
  • ⬤ |1⟩
  • Yes! Starting with: ⬤ |1⟩; apply the first NOT operation: ◯ |0⟩; and apply the second NOT operation: ⬤ |1⟩
Hint.
Apply the NOT gate twice.

Checkpoint 1.2.3. NOT Gate Check #3.

    What is the output of this circuit?
  • ◯ |0⟩
  • Yes! Starting with: ⬤ |1⟩; apply the first NOT operation: ◯ |0⟩; apply the second NOT operation: ⬤ |1⟩; and apply the third NOT operation: ◯ |0⟩
  • ⬤ |1⟩
  • Did you apply the NOT operation three times?
Hint.
Apply the NOT gate three times.

Section 1.2.3 Build a Quantum Circuit

In this section, we introduce the interactive quantum circuit builder.
There are three operations that operate well on qubits in the simple states of |0⟩ and |1⟩: NOT, SWAP, and CNOT
Below is your first circuit to build using the circuit builder’s explore mode. Drag and drop the pictures of the gates onto the circuit. In explore mode, every time you make a change, it provides feedback. You can ignore the feedback until you think you are done!!
The SWAP gate is a two-qubit gate. Create the SWAP gate by dragging , which will be two diamonds in this widget. Place the two diamonds on the two wires in the same column. Click on them so they are both highlighted, then click on the "S" button to connect them.
Now let’s try building a circuit with a controlled gate - just like the controlled increment we saw in the math example. Put a spot on one the control wire and the gate on the target wire. Click on them to make sure they are both highlighted, then click the "C" button to connect them.
I am leaving in this last one because it had a bug when I tried it - it always said I was not correct, even when I completed the circuit.
You have attempted 1 of 4 activities on this page.