So far, we've been looking at phases that have an exact -bit binary expansion. Now, we will analyze the performance of the QPE algorithm for phases that have a value that cannot be exactly represented using bits, and see what happens when we increase the number of estimation wires. In the following exercise, we will define an estimation window. The estimation window is a tuple of the two most likely outcomes. We would expect the eigenphase (i.e., the phase angle , associated with the eigenvalue ) to be between the two values of the estimation window.

Using the QPE algorithm, estimate the two most likely outcomes of the eigenphase of the eigenvector of a unitary operator. The function qpe(unitary, estimation_wires, target_wires) is provided for you and returns a list of probabilities on the estimation wires. Since this involves testing your solution for a different number of estimation wires, please change the return value of the variable done to True when you are finished with testing.

dev = qml.device("default.qubit", wires=10)

def fractional_binary_to_decimal(binary_fraction, wires):
return float(binary_fraction/ 2 ** len(wires))

def phase_window(probs, estimation_wires):
""" Given an array of probabilities, return the phase window of the
unitary's eigenvalue
Args:
probs (array[float]): Probabilities on the estimation wires.
estimation_wires (list[int]): List of estimation wires
Returns:
(float, float): the lower and upper bound of the phase
"""

##################
# YOUR CODE HERE #
##################
bound_1 = 0 # MOST LIKELY OUTCOME
bound_2 = 0 # SECOND MOST LIKELY OUTCOME
return (bound_1, bound_2)


# Test your solution

# You can increase the number of estimation wires to a maximum of range(0, 9)
estimation_wires = range(0, 3)

# The target is set to the last qubit
target_wires = [9]

# Define the unitary
U = np.array([[1, 0], [0, np.exp((2*np.pi*1j/7))]])

or to submit your code

To interact with codercises, please switch to a larger screen size.

Learning Objectives:

  • Analyze the QPE for phases that do not have a -bit binary expansion.