0
$\begingroup$

I have a circuit $C$, which acting on a state $|\psi \rangle$ is equivalent to a Unitary $U$ acting on the state: $$C(|\psi \rangle) = U|\psi \rangle$$ Now, this circuit is just a Hamiltonian evolution, implying $U = e^{-iH}$, where $H$ is the hamiltonian. I want to obtain this Hamiltonian $H$ and calculate its expectation value for a list of circuits (as in, I get a state $|\phi \rangle$ from a circuit, and calculate $\langle \phi|H|\phi \rangle$). I tried forming this Hamiltonian using qiskit's Operator class, and inputting it into an Estimator, but was hit with an error saying that Operator class objects are not supported in Estimator. Is there any efficient way of doing this in Qiskit?

$\endgroup$
1
  • $\begingroup$ Maybe I just don't understand the question, but why would you want to calculate $\langle \phi | H | \phi \rangle$ instead of $\langle \phi | U | \phi \rangle$? $\endgroup$
    – diemilio
    Commented Jun 21 at 14:46

1 Answer 1

0
$\begingroup$

Not quite sure why you would want to do this, but here's the code to do it:

import numpy as np
from scipy.linalg import logm
from qiskit.quantum_info import Statevector, Operator, random_unitary

# Create random unitary U, which could come from a circuit
U = random_unitary(4)

# Compute matrix logarithm
H = logm(U)

# Initialize |ϕ⟩ to some arbitrary value
ϕ = 1/np.sqrt(2)*Statevector([1,0,0,1])

# Calculate ⟨ϕ|H|ϕ⟩
ϕ.expectation_value(H)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.