Could not figured it out what are the coefficient will be in H.4.2

In this code i have tried coeffs is an array of [-alpha, -alpha, -alpha, -alpha, - alpha] But I am getting error. Please help me out

n_bits = 5
dev = qml.device("default.qubit", wires=n_bits)
    
##################
# YOUR CODE HERE #
##################
coeffs = [1,1,1,1,1] # MODIFY THIS
obs = [qml.PauliZ(0),qml.PauliZ(1),qml.PauliZ(2),qml.PauliZ(3),qml.PauliZ(4)] # MODIFY THIS
H = qml.Hamiltonian(coeffs, obs)

@qml.qnode(dev)
def energy(init):
    """Circuit for measuring expectation value of Hamiltonian in a given state.
    
    Args:
        init (numpy.array(int)): An initial computational basis state, specified by five bits.

    Returns: 
        float: Expectation value of the Hamiltonian H.
    """
    qml.BasisState(init, wires=range(n_bits))
    return qml.expval(H)

Code is running very well in Local Compiler but what the coefficient this problem is seeking for I could not understand.

Hi @SUDHIR_KUMAR_SAHOO,

I think going back to what you are trying to code might be heplful. Look in more detail at the coefficients, terms and number of terms of the formula:
image

That should give you a hint on the number of coefficients and their value.

Cheers,
Erick

Thank you so much for help. Got your point.

2 Likes