In this codercise, you are given an unnormalized vector

We can turn this into an equivalent, valid quantum state by normalizing it. Your task is to complete the function normalize_state so that, given and it normalizes this state to

Hint.

What we must do here is essentially rescale the coefficients of the state vector such that it has unit length. That is, there must be some complex number such that and Consider how you would do so for a

real-valued vector; then determine how to manipulate the amplitudes in the complex case.

# Here are the vector representations of |0> and |1>, for convenience
ket_0 = np.array([1, 0])
ket_1 = np.array([0, 1])


def normalize_state(alpha, beta):
"""Compute a normalized quantum state given arbitrary amplitudes.

Args:
alpha (complex): The amplitude associated with the |0> state.
beta (complex): The amplitude associated with the |1> state.

Returns:
np.array[complex]: A vector (numpy array) with 2 elements that represents
a normalized quantum state.
"""

##################
# YOUR CODE HERE #
##################

# CREATE A VECTOR [a', b'] BASED ON alpha AND beta SUCH THAT |a'|^2 + |b'|^2 = 1

# RETURN A VECTOR
pass

or to submit your code

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

Learning Objectives:

  • Write down a mathematical description of a qubit state in two different notations.
  • Define and give examples of what it means for a quantum system to be in a superposition of states.
  • State the relationship between amplitudes and measurement outcome probabilities, and what it means for a state to be normalized.
  • Explain how operations are mathematically applied to qubit states.