Hi, I noticed that the docstring in the code template contains an error; the template reads
n_bits=2
dev = qml.device("default.qubit", wires=range(n_bits))
@qml.qnode(dev)
def two_close_spins_X(alpha, beta, time, n):
"""Circuit for evolving the state of two electrons with an X coupling.
Args:
beta (float): The strength of the field, assumed to point in the z direction.
alpha (float): The strength of the coupling between electrons.
time (float): The time we evolve the electron wavefunction for.
n (int): The number of steps in our Trotterization.
Returns:
array[complex]: The quantum state after evolution.
"""
##################
# YOUR CODE HERE #
##################
return qml.state()
when it should read something like:
n_bits=2
dev = qml.device("default.qubit", wires=range(n_bits))
@qml.qnode(dev)
def two_close_spins_X(alpha, beta, time, n):
"""Circuit for evolving the state of two electrons with an X coupling.
Args:
alpha (float): The coefficient related to the strength of the field, assumed to point in the z direction.
beta (float): The coefficient related to the strength of the coupling between electrons.
time (float): The time we evolve the electron wavefunction for.
n (int): The number of steps in our Trotterization.
Returns:
array[complex]: The quantum state after evolution.
"""
##################
# YOUR CODE HERE #
##################
return qml.state()
the prose before this looks correct, and the solution expects the corrected description of input parameters as well.
Codercise H.5.3 has a typo in the docstring as well; the code template reads:
dev = qml.device("default.qubit", wires=range(n_bits))
def ham_close_spins(alpha, J):
"""Creates the Hamiltonian for two close spins.
Args:
B (float): The strength of the field, assumed to point in the z direction.
J (list[float]): A vector of coupling [J_X, J_Y, J_Z].
Returns:
qml.Hamiltonian: The Hamiltonian of the system.
"""
##################
# YOUR CODE HERE #
##################
coeffs = [] # MODIFY THIS
obs = [] # MODIFY THIS
return # Return the Hamiltonian using qml.dot
it should read something like:
dev = qml.device("default.qubit", wires=range(n_bits))
def ham_close_spins(alpha, J):
"""Creates the Hamiltonian for two close spins.
Args:
alpha (float): The coefficient related to the strength of the field, assumed to point in the z direction.
J (list[float]): A vector of coupling coefficients [J_X, J_Y, J_Z].
Returns:
qml.Hamiltonian: The Hamiltonian of the system.
"""
##################
# YOUR CODE HERE #
##################
coeffs = [] # MODIFY THIS
obs = [] # MODIFY THIS
return # Return the Hamiltonian using qml.dot