<jupyter_start><jupyter_text>_*The EOH (Evolution of Hamiltonian) Algorithm*_This notebook demonstrates how to use the `Qiskit Aqua` library to invoke the EOH algorithm and process the result.Further information may be found for the algorithms in the online [Aqua documentation](https://qiskit.org/documentation/apidoc/qiskit.aqua.algorithms.html).For this particular demonstration, we illustrate the `EOH` algorithm. First, two `WeightedPauliOperator` instances we created are randomly generated Hamiltonians.<jupyter_code>import numpy as np
from qiskit import BasicAer
from qiskit.transpiler import PassManager
from qiskit.aqua import QuantumInstance
from qiskit.aqua.operators import MatrixOperator, op_converter
from qiskit.aqua.algorithms import EOH
from qiskit.aqua.components.initial_states import Custom

num_qubits = 2
temp = np.random.random((2 ** num_qubits, 2 ** num_qubits))
qubit_op = op_converter.to_weighted_pauli_operator(MatrixOperator(matrix=temp + temp.T))
temp = np.random.random((2 ** num_qubits, 2 ** num_qubits))
evo_op = op_converter.to_weighted_pauli_operator(MatrixOperator(matrix=temp + temp.T))<jupyter_output><empty_output><jupyter_text>For EOH, we would like to evolve some initial state (e.g. the uniform superposition state) with `evo_op` and do a measurement using `qubit_op`. Below, we illustrate how such an example dynamics process can be easily prepared.<jupyter_code>evo_time = 1
num_time_slices = 1
state_in = Custom(qubit_op.num_qubits, state='uniform')
eoh = EOH(qubit_op, state_in, evo_op, evo_time=evo_time, num_time_slices=num_time_slices)<jupyter_output><empty_output><jupyter_text>We can then configure the quantum backend and execute our `EOH` instance:<jupyter_code>backend = BasicAer.get_backend('statevector_simulator')
quantum_instance = QuantumInstance(backend)

ret = eoh.run(quantum_instance)
print('The result is\n{}'.format(ret))<jupyter_output>The result is
{'avg': (3.3315538738820436-1.1573250579094587e-16j), 'std_dev': 0.0}
{'fraction_non_alphanumeric': 0.0906801007556675, 'fraction_numerical': 0.022670025188916875, 'mean_word_length': 7.415254237288136, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '254299', 'license': 'Apache-2.0', 'n_tokens_mistral': 697, 'n_tokens_neox': 640, 'n_words': 172, 'path': 'aqua/eoh.ipynb', 'repo_name': 'dlyongemallo/qiskit-community-tutorials', 'size': '1985'}