concept superposition in category quantum computing

appears as: superposition, superposition
Quantum Computing for Developers: A Java-based introduction

This is an excerpt from Manning's book Quantum Computing for Developers: A Java-based introduction.

In quantum computing, the equivalent of the bit is the qubit. Similar to a bit, a qubit can hold the values '0' and '1'. But contrary to a bit, a qubit can also hold values that are "combinations" of the '0' and the '1' state. When this is the case, the qubit is in a so-called superposition state. While this may sound counterintuitive at first, it is actually exactly what is happening in nature, with a number of the most granular particles, and it is directly linked to the core ideas of quantum mechanics. The fact that this superposition state occurs in nature with very granular particles is a good indication that building quantum computers is very realistic. Classic computers ignore those quantum effects, and therefore the classic hardware can not be made smaller and smaller indefinitely without hitting the boundaries where quantum effects come into the picture.

When a qubit is measured, it will return '0' or '1' and not something in between. The relation between the superposition state of the qubit and the actual value when it is measured is explained in the next chapter. Very roughly, the superposition relates to how likely it is that a given qubit, when measured, will hold the value '0' or the value '1'.

In the previous chapter, we briefly mentioned superposition. It is one of the most fundamental concepts of Quantum Computing, and it is one of the reasons why Quantum Computers are expected to be able to run some applications much faster than classical computers.

In this chapter you will learn what superposition is, and how it is relevant in creating quantum algorithms. We will talk about a specific gate that brings a qubit in a superposition state, and we show a simple but very relevant sample that demonstrates superposition.

We try to keep the physical explanations to a minimal. The scientific work behind the physics is mind boggling, but it requires different skills and is less relevant to software development. Keep in mind that even for the most knowledgable persons Quantum Computing and its concepts are very difficult to grasp, so do not worry when the physical concepts behind superposition are not clear. What matters to the developer is how to use these concepts and write more suitable applications.

Figure 4.1. From superposition to the Hadamard gate.
ch4 mindpic
Learn Quantum Computing with Python and Q#

This is an excerpt from Manning's book Learn Quantum Computing with Python and Q#.

For instance, the "√2" part always has to be there, since vectors representing quantum states always have to be length one; that means we can sometimes be a little bit casual and write things like "|+⟩ = |0⟩ + |1⟩," relying on our audience to remember to divide by √2. If we’re giving a talk, or discussing quantum computing over some nice tea, we may say this as "ket plus is ket 0 plus ket 1," but the reuse of the word "plus" gets a little confusing without bras and kets to help. To emphasize verbally that addition allows us to represent superposition, we might say "the plus state is an equal superposition of zero and one" instead.

11.7 MULTIPLYING WITH QUBITS IN SUPERPOSITION

Of course, if all you could do with arithmetic on a quantum computer was to add one pair of integers at a time, there wouldn’t be any reason to do so using qubits instead of on your classical computer. Thankfully, the AddI and many other similar arithmetic operations work in superposition as well; a fact that you’ll need to use these arithmetic operations with phase estimation in the next part of the Chapter. Before jumping straight to that, though, it’s helpful to play around a little bit with what it means to add or multiply integers in superposition.

Here, you’ll get to see how to apply what you’ve learned about superposition to arithmetic as well by using the MultiplyByModularInteger as an example. Shortly, you’ll use the same operation to construct the oracle that you need for Shor’s factoring algorithm later, so it’s a pretty practical application as well!

First, let’s look at an operation that you can use to prepare a register in a superposition of two integers. In , you can see how to do so using what you learned about the ApplyXorInPlace operation from the previous section and what you learned about the Controlled functor from Chapter 9.

Listing 11.8. Operation to prepare a register in a superposition of integers.
open Microsoft.Quantum.Arithmetic;
open Microsoft.Quantum.Diagnostics;
open Microsoft.Quantum.Math;
 
operation PrepareSuperpositionOfTwoInts(                                 #1
    intPair : (Int, Int),
    register : LittleEndian,
)
: Unit is Adj + Ctl {
    using (ctrl = Qubit()) {
        H(ctrl);                                                         #2
 
        within {
            X(ctrl);                                                     #3
        } apply {
            Controlled ApplyXorInPlace(                                  #4
                [ctrl],
                (Fst(intPair), register)
            );
        }
        Controlled ApplyXorInPlace(                                      #5
            [ctrl],
            (Snd(intPair), register)
        );
        (ControlledOnInt(Snd(intPair), Y))(register!, ctrl);             #6
    }
}

Once you have a quantum register that represents the superposition of two integers, you can apply other arithmetic operations across that superposition. In listing 11.9, for instance, you can use the DumpMachine callable to see how the state of your register changes when using the MultiplyByModularInteger operation provided by the Q# standard libraries.

Listing 11.9. Example using the numerics library to multiply integers in superposition.
operation MultiplyInSuperpositionMod(
    superpositionInts : (Int, Int),
    multiplier : Int,
    modulus : Int
)
: Int {
    using (target = Qubit[BitSizeI(modulus)]) {                          #1
        let register = LittleEndian(target);
        PrepareSuperpositionOfTwoInts(superpositionInts, register);      #2
 
        Message("Before multiplication:");
        DumpMachine();
 
        MultiplyByModularInteger(                                        #3
            multiplier, modulus, register
        );
 
        Message("After multiplication:");
        DumpMachine();
 
        return MeasureInteger(register);                                 #4
    }
}
Figure 11.6. Output of multiplying 3 by 2 and 3 in superposition mod 8.
CH11 FIGxx multi screencap

You can see in that the registers correctly show a superposition of 2 and 3 before multiplication, and then show a superposition of 1 and 6 after. What would you expect the correct output to be? If we multiplied as you would normally, it should be 6 and 9, but since we are doing arithmetic mod 8, the 9 goes to 1. When we then measure that register we will get 6 half of the time and 1 the other half since they are in an equal superposition as you can see from the state amplitude bars depicted in .