# Finding Eigenvectors of a Unitary in a Quantum circuit

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?

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)

print(eigenvalues)
# [ 1.+0.j -1.+0.j]

print(eigenvectors)
# [[ 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.