Unitaries evolving a quantum system arise from a special operator called the Hamiltonian, which measures the system's energy. According to Schrödinger's equation, for a system with Hamiltonian , the corresponding unitary evolving it for a time is

For example, if the physical system in question is a tiny magnet in a big external magnetic field pointing in the direction, the Hamiltonian is

where is the Pauli , C is the charge of the electron, and kg its mass. We've lumped some of the constants into for convenience. The operator has eigenvalue when the magnet is aligned, and when anti-aligned, so the energy is indeed lower in the first case:

To get the unitary according to , we must exponentiate , which is simply a rotation:

Use this result to build the evolve_rotation circuit that applies the evolution operator to a qubit. This operator will depend on the magnetic field B and the time during which the evolution occurs.

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

@qml.qnode(dev)
def evolve_rotation(B, time):
"""Simulates an electron (initial state |0>) in a magnetic field, using a
Z rotation.
Args:
B (float): The strength of the field, assumed to point in the z direction.
time (float): The time we evolve the electron state for.

Returns:
array[complex]: The state of the system after evolution.
"""
e = 1.6e-19
m_e = 9.1e-31
alpha = B*e/(2*m_e)
##################
# YOUR CODE HERE #
##################
return qml.state()

or to submit your code

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

Learning Objectives:

  • Define a Hamiltonian and explain what it means with respect to a quantum system.
  • Compute unitary evolution for a simple, single-qubit physical system.