-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot get expectation value of list ops or composed ops #7743
Comments
I think you're not using the opflow instructions correctly here:
If you change the code as follows it seems to work: # ... as you had it
bound_11 = op_11.bind_parameters({param1: 0.832619845547938,
param2: 0.07103605819788694})
bounds1 = ops1.bind_parameters({param1: 0.832619845547938,
param2: 0.07103605819788694})
print(bound_11.eval())
print(bound1.eval()) |
Thank you for the observation! I see now how to do this. But I keep getting unexpected results! For example for the code below:
No matter what parameters I use, it always gives results: My understanding is that the code creates a circuit, puts the qubits in superposition via Hadamard, entangles them via CNOT and rotates around x axis in Bloch sphere. Shouldn't I get non-zero results here? Thanks again! |
Hmm I think the expectation value is correctly 0 as the Pauli Z operator you measure against introduces a phaseflip and makes the states orthogonal. To get a non-zero result, try rotating the qubit states e.g. around the Y-axis with the |
Since |
Environment
'qiskit-terra': '0.19.1',
'qiskit-aer': '0.10.2',
'qiskit': '0.34.1',
Python 3.8.12
OS=Amazon Linux, version 2
ID_LIKE="centos rhel fedora"
What is happening?
I am having trouble evaluating operators built from composed ops and list ops. I keep getting the error:
ValueError: Cannot compute overlap with StateFn or Operator if not Measurement. Try taking sf.adjoint() first to convert to measurement.
How can we reproduce the issue?
Copy/paste and run the code block below:
What should happen?
Should be able to get the expectation value of the operator.
Any suggestions?
No response
The text was updated successfully, but these errors were encountered: