In this post we introduce the qubit and some ways to manipulate it.
A qubit is a two level quantum mechanical system. Our qubit starts off straightforward enough: if it is in state , when we want to see what bit it represents it will be a 1, and if it is in state , when we measure it to store it in a classical bit, we will always get a 0.
But the qubit is special because it allows for superpositions. A superposition is when the qubit is in a combination of state and state . For example let's think about an unknown superposition, we will call it . The state can be written as , where are parameters to describe the superposition. We are now not so sure about what we will get when we measure our qubit. We will still get 0 or 1, but the chances our qubit is found at 0 is related to the size of and the chances our qubit is found at 1 is related to the size of .
To understand this we can visualize one qubit using what is called the Bloch sphere.
The state can be represented by any point on the sphere, depending on . In quantum mechanics, we cannot observe a quantum state directly. We can only do a measurement that will give us a 0 or a 1. That is, we can store the measurement of the qubit in a classical bit. Imagine now that we can make repeated measurements. We will get a picture of how likely we are to measure 1 and how likely we are to measure 0. For the state our measurement to determine if it is or will tell us the probabilities are to be and to be .
Measuring superpositions gives probabilistic outcomes.
A qubit by itself is not very useful unless we can control it. For this, we apply operations to a qubit to change the state. The operations can be represented as gates on a quantum circuit gates.
Here we introduce some of the most common gates.
Can you guess what the Y gate does?
Right, it rotates by about the Y-axis. Similarly the Z gate would rotate by around the Z-axis.
There's one more gate we should discuss, the Hadamard gate. It's a combination of two rotations, about the Z-axis and about the Y-axis. The H gate takes a state and creates a equal superpositions of and .
When you look at quantum circuits, note this gate appears often at the beginning of many circuits, as creating superpositions is a common step to start doing quantum computations.
There are a few other common single-qubit gates such as S and T, among others.
In the project linked here, you can get started with one-qubit quantum circuit operations using QASM. Yeah, go ahead. All you need start playing with qubits is to change with the code there. Delete the "//" of some the commented lines to play with some of the gates in the code, and see the effect on the qubit. Then run the code. Due to the probabilistic nature of quantum mechanics, make sure to play with different numbers of iterations. 10 or more work well, but try also 1 and 100. Think of this as your one-qubit sandbox.
For more details on QASM, check out its documentation here.
Here is a list of some of the one-qubit gates featured in this exercise.
z // pi rotation about the Z-axis x // pi rotation about the X-axis y // pi rotation about the Y-axis h // The combination of two rotations, pi about the Z-axis followed by pi/2 about the Y-axis s // S-gate, square root of Z gate sdg // conjugate of S-gate t // Phase-gate, conjugate of square root of S-gate tdg // conjugate of Phase-gate x(0) // rotation around X-axis y(0) // rotation around Y-axis z(0) // rotation around Z axis
Think you've got the hang of it? Try solving the RubiQ's Sphere!