I have to compute $\langle\psi_1(\theta)|H_1|\psi_1(\theta)\rangle$
where $$H_1 = X_1Z_2 +3Y_0Y_4$$
psi1 = RealAmplitudes(5, reps=2)
H1 = SparsePauliOp.from_list([("XZ", 1),("YY",3)])
theta1 = np.linspace(0,1,5*3)
with Session(service=service, backend=backend):
options = Options(simulator={"seed_simulator": 42}, resilience_level=0)
estimator = Estimator(options=options)
job = estimator.run(circuits=[psi1],
parameter_values=[list(theta1)],
observables=[H1])
result = job.result()
Though, I'm getting the below error:
Traceback (most recent call last):
Input In [52] in <cell line: 3>
job = estimator.run(circuits=[psi1],
File /opt/conda/lib/python3.8/site-packages/qiskit_ibm_runtime/estimator.py:249 in run
return super().run(
File /opt/conda/lib/python3.8/site-packages/qiskit/primitives/base/base_estimator.py:227 in run
self._cross_validate_circuits_observables(circuits, observables)
File /opt/conda/lib/python3.8/site-packages/qiskit/primitives/base/base_estimator.py:283 in _cross_validate_circuits_observables
raise ValueError(
ValueError: The number of qubits of the 0-th circuit (5) does not match the number of qubits of the 0-th observable (2).
Can anyone tell me what actually is causing this issue and how can this be solved?