I have a unitary gate $U$, which is applied on some $n$-qubit quantum circuit ($n=7$ for my scenario). I wish to find the $n$-qubit state, which is the eigenvector (and possibly eigenvalues) of this unitary in Qiskit's latest version. How do I do that?


1 Answer 1


You can simply use numpy:

from qiskit.circuit.library import XGate

gate = XGate()

# Get the underlying array
unitary_matrix = gate.to_matrix()
# Or you can get it like this
from qiskit.quantum_info import Operator
unitary_matrix = Operator(gate).data

# Now you can compute the eigenvalues and eigenvectors using numpy
import numpy as np
eigenvalues, eigenvectors = np.linalg.eig(unitary_matrix)

# [ 1.+0.j -1.+0.j]

# [[ 0.70710678-0.j  0.70710678+0.j]
#  [ 0.70710678+0.j -0.70710678-0.j]]

This process generalizes for any gate: simply apply Operator on them and query their data attribute to get a numpy array, and let numpy handle the eigendecomposition.


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.