# Efficient ways of numerically calculating eigenenergies?

I want to calculate the eigenenergies of the ground state, first excited state and second excited state for the Hamiltonian:

$$H = (1-s)H_x + sH_z$$

for $$s=0, 0.01, 0.02, ..., 1$$. The Hamiltonian $$H_z$$ is diagonal, and the other one $$H_x=\sum_{i=1}^N \sigma_x^i$$. $$N$$ is typically around 10-30.

My current method is to formulate $$H_z$$ and $$H_x$$ as scipy DIA sparse matrices, calculate $$H$$ from them and use scipy.sparse.eigsh to calculate the lowest 3 eigenenergies.

However, once N approaches 20, it's really taking a toll on the performance of the computer. Is there anything I missed that can help lower the memory consumption or make the computation faster?

EDIT: To clarify, $$H$$, $$H_z$$ and $$H_x$$ are all $$2^N$$ dimensional (the system is a N-qubit system).

• Which is slower, the creation of the $H$ matrix, or the call to scipy.sparse.eigsh? If it is the latter, you likely have to look for some other basis in which to express your system... May 19, 2022 at 7:05
• I ran a quick test for a specific case of N=15, s=0.5: $H_z$ formulation takes 0.14 s, $H_x$ formulation takes 8.89 s, make $H$ from $H_z$ and $H_x$ takes 6.25 s, and using scipy.sparse.eigsh to calculate the lowest 3 eigenenergies of $H$ takes 76.63 s. But I don't think there would be any better basis since one of the components $H_z$ is already diagonal. May 19, 2022 at 7:24
• What is the dimensionality of $H$? May 19, 2022 at 7:41
• $H$, $H_z$ and $H_x$ are all $2^N$ dimensional (N-qubit system) May 19, 2022 at 7:45
• Since the complexity of diagonalization is in practice $O(d^3) = O(2^{3N})$, I don't think there is a way to make your code more efficient, as the diagonalization is already your bottleneck, and you are using a (hopefully well optimized) built-in method to do it. May 19, 2022 at 17:11