# Using the Full Qubit

Newcomers to quantum computing learn that the states of individual qubits can be represented graphically with Bloch Spheres. And although these unit spheres have x, y, and z axes (called bases), we learn that we can only measure the z basis. Therefore, we can determine the probabilities of measuring a 0 or a 1, giving us the latitude if we think of the sphere as a globe, but we cannot determine the longitude, or the east-west position around the globe.

My workaround draws inspiration from superdense coding and quantum state tomography; my references are listed at the end of this article. In retrospect, the paper should have been sufficient, but I credit the book because credit is due.

Start with any pure state you desire.

If you’re new enough to wonder why I am starting with qubit 2 instead of qubit 0, it’s because the device matters. The specific hardware that I might run this circuit on has qubits arranged in a way in which I could actually start with qubit 0, but this circuit is part of a larger circuit that requires the additional connectivity afforded by qubit 2. You’ll see this measurement circuit again in a separate article after I complete the other part of the full circuit.

This is something that you don’t learn immediately, by the way, but it’s definitely important. You will want to learn how to optimize your circuit for specific devices, but that’s beyond the scope of this article.

This CNOT entangles qubit 2 and qubit 0. Consequently, qubit 0 will measure whatever qubit 2 would measure at this point, if we were to measure qubit 2 at this point. And if we were to measure qubit 2 at this point, we would measure the z basis. Therefore, measuring qubit 0 will measure the z basis of the quantum state.

The Hadamard gate on qubit 2 rotates the state in a manner that we can now measure the x basis. It’s actually that simple. Think of it as rotating the Bloch Sphere so that the x axis is now vertical instead of the z axis. That’s not what actually happens, but the important thing is that a measurement at this point gives us an x measurement instead of a z measurement.

Using the CNOT, we can then entangle qubit 2 and qubit 1. A measurement on qubit 1, following the earlier explanation, therefore measures the x basis of the quantum state.

This Hadamard gate simply reverses the previous one. Think of it as putting the x axis back where it belongs, returning the z axis to its proper vertical position. Again, that’s not what actually happens. However, measurement at this point would once again be a z measurement, no longer an x measurement.

Measuring the y basis is the most elusive measurement to find; in fact, the linked article might be the only place I’ve seen it in easy-to-decipher circuit form. The S dagger gate and the Hadamard gate essentially rotate the y axis to the vertical position, borrowing the previous analogy with measuring the x basis.

It is worth noting that Hadamard-S dagger-Hadamard can be reduced to only one operation. I left it as is for explanation purposes. However, it is always worth analyzing transpiled circuits to find ways to optimize your code. This particular instance doesn’t matter from a performance standpoint, but it’s nice to know when you can write one line of code instead of three.

You usually see measurements performed in order, but that’s customizable. Here, I measure qubit 1 first to get the x basis, followed by qubit 2 to measure the y basis, and then followed by qubit 0 to measure the z basis. That’s just personal preference to make the output more readable.

For the quantum state that I selected — a pi/4 theta rotation and a pi/4 phi rotation — 000 is the result that I was looking for. Fortunately, despite decoherence, it is the top result. There are ways to improve the fidelity using Python and IBM’s Qiskit library, but this is merely a proof of concept.

You can also cheat and start with three qubits in the same state. Simply Hadamard-measure one for the x basis, S-dagger-Hadamard-measure another for the y basis, and measure the last one for the z basis. Fidelity will improve due to shorter circuit depth, but practicality will drop sharply.

**References**

(superdense coding)

Hidary, J.D. - Quantum Computing_ An Applied Approach-Springer International Publishing (2019)

(basis measurements)

https://arxiv.org/abs/1804.03719