Let's now consider two electrons in a magnetic field. If they are far away from each other, then the total Hamiltonian (energy) will just be a sum of Hamiltonians:

where is the Pauli acting on the first electron, and acts on the second. We've indexed these in the same way wires are indexed in PennyLane. Since the electrons are independent, the unitary which evolves this two-electron system in time is two copies of the unitary , . In circuit form:

Complete the function below for simulating two distant electrons in a magnetic field.

n_bits=2
dev = qml.device("default.qubit", wires=range(n_bits))

@qml.qnode(dev)
def two_distant_spins(B, time):
"""Circuit for evolving the state of two distant electrons in a magnetic field.
Args:
B (float): The strength of the field, assumed to point in the z direction.
time (float): The time we evolve the electron wavefunction for.

Returns:
array[complex]: The quantum state 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:

  • Derive the Trotter-Suzuki decomposition.
  • Use Trotterization to simulate a simple physical system.