Bug Report: Falsely graded correct for I.11.1

After finishing I.11.1, I noticed that my answer is still wrong, from the plotter even though the codebook graded this as correct. Namely, I incorrectly used the qubits for the tensor product observable Z⊗Z.

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


@qml.qnode(dev)
def circuit_1(theta):
    """Implement the circuit and measure Z I and I Z.

    Args:
        theta (float): a rotation angle.

    Returns:
        float, float: The expectation values of the observables Z I, and I Z
    """
    ##################
    # YOUR CODE HERE #
    ##################
    qml.RX(theta, wires=0)
    qml.RY(2*theta, wires=1)
    return qml.expval(qml.PauliZ(wires=0)), qml.expval(qml.PauliZ(wires=1))


@qml.qnode(dev)
def circuit_2(theta):
    """Implement the circuit and measure Z Z.

    Args:
        theta (float): a rotation angle.

    Returns:
        float: The expectation value of the observable Z Z
    """

    ##################
    # YOUR CODE HERE #
    ##################
    qml.RX(theta, wires=0)
    qml.RY(2*theta, wires=1)
    return qml.expval(qml.PauliZ(wires=1) @ qml.PauliZ(wires=1)) # Missed error


def zi_iz_combination(ZI_results, IZ_results):
    """Implement a function that acts on the ZI and IZ results to
    produce the ZZ results. How do you think they should combine?

    Args:
        ZI_results (np.array[float]): Results from the expectation value of
            ZI in circuit_1.
        IZ_results (np.array[float]): Results from the expectation value of
            IZ in circuit_2.

    Returns:
        np.array[float]: A combination of ZI_results and IZ_results that
        produces results equivalent to measuring ZZ.
    """

    combined_results = np.zeros(len(ZI_results))

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

    combined_results = ZI_results*IZ_results

    return combined_results


theta = np.linspace(0, 2 * np.pi, 100)

# Run circuit 1, and process the results
circuit_1_results = np.array([circuit_1(t) for t in theta])

ZI_results = circuit_1_results[:, 0]
IZ_results = circuit_1_results[:, 1]
combined_results = zi_iz_combination(ZI_results, IZ_results)

# Run circuit 2
ZZ_results = np.array([circuit_2(t) for t in theta])

# Plot your results
plot = plotter(theta, ZI_results, IZ_results, ZZ_results, combined_results)

The coderbook should return “Incorrect” and comment that the second circuit is wrong.

FalseNegativeZ1⊗Z1

1 Like

Hi @mack.attack , welcome to the Forum!

Thank you very much for pointing this out!
We’ll investigate what happened in this case.

Thanks again for bringing it to our attention!

Hi @mack.attack ,

The codercise should be fixed now! Feel free to try it again if you want.