I am writing a most basic circuit in qiskit as follows:
from qiskit import QuantumCircuit
from qiskit.quantum_info import Pauli
from qiskit_aer.primitives import Estimator
qc = QuantumCircuit(2)
qc.draw(output="mpl", filename='img.png')
ZI = Pauli("ZI")
IZ = Pauli("IZ")
ops=[ZI,IZ]
estimator=Estimator()
job=estimator.run([qc]*len(ops), ops)
result=job.result()
print(result)
I get the result as values=array([1., 1.]) with the drawn circuit showing two initialized qubits with no gates as expected.
Now, if I add qc.x(0) after initializing the circuit, the drawn circuit shows the NOT gate on the zeroth qubit as expected, but the result is values=array([ 1., -1.]). The expectation value of the first qubit is flipped instead of the zeroth one.
Similarly, the result is opposite if I add the NOT gate to the first qubit. Why is this happening?