Consider a simple Hamiltonian coupling two qubits:

The eigenvectors are just the computational basis states , with eigenvalues . To implement the unitary which evolves by time , we need to build a gate with the following action on basis states:

As you will check in a moment, this can be done using the following (non-trivial) circuit involving CNOTs and a rotation:

where .


Implement the circuit drawn above, allowing for the specification of an initial computational basis state.

Tip. Try using qml.BasisState to prepare the basis state.

or to submit your code

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

Learning Objectives:

  • Describe the utility of diagonalizing a Hamiltonian for simulation, and diagonalize a simple case.
  • See how nontrivial computational problems can be encoded in ground states.