# How to use VQE function in Qiskit

As part of a project I'm working on, I want to use VQE algorithm to calculate the minimal eigenvalue for given Hamiltonian. I use Qiskit on IBM UI online.

The Hamiltonian is given as a sum of tensor products

$$H = Z\otimes Z + Z \otimes X + ...$$

I don't understand two main points:

1. How should I pass the Hamiltonian to the VQE? should I pass it as a list? i.e. $$H = [Z\^Z, X\^Z]$$?
2. I understand that I need to create N circuits, where N is the number of tensor products which constitute the Hamiltonian, so that each circuit will handle another part of the Hamiltonian. Do I understand this correctly?

Thank you.

Try this:

from qiskit.aqua.operators import WeightedPauliOperator
dict = {
'paulis': [{"coeff": {"imag": 0.00, "real": 1 }, "label": "ZZ" },
{"coeff": {"imag": 0.00, "real": 1 }, "label": "XX" }
]
}
Operator = WeightedPauliOperator.from_dict(dict)


Now you can pass this operator to your VQE call:

VQE(operator= Operator, var_form= ... )

• Thank you for your comment. After few trials it appears that the expression doesn't need to be modified but needs to be passed as it is – user14092875 Oct 15 '20 at 4:48

After few trials, appears that VQE knows how to process this form of expression, so I just passed the mathematical expression as it is.

Thank you