# Numerical calculation of the Berry connection

I'm doing some numerical calculations involving Hermitian matrices, and derivatives of the eigenvectors. Essentially, I have an n x n, Hermitian matrix H(x), which is dependent on some continuous parameter (x). I then need to calculate the Berry connection for this system. So suppose $$U^\dagger(x) H(x) U(x) = \epsilon_n \delta_{nm}$$, I'm essentially computing $$i U^\dagger(x) \partial_x U(x) = \hat{A}$$.

To do this, I tried to evaluate $$H(x), H(x+\Delta x)$$, and obtained $$U(x),U(x+\Delta x)$$. I therefore approximated $$\hat{A} \approx i U^\dagger(x) (U(x+\Delta x )- U(x))/(\Delta x)$$. This is carried out in LAPACK, using HEEVD (CHEEVD), since H is Hermitian, and parametrized with double precision.

However, since the diagonalization at every x carries with it a random phase (apparently), the object $$\hat{A}$$ contains errors, and no longer represents just the derivative of the rotation matrix $$U$$. In fact, it even turns out to be non-Hermitian at some x points.

I imagine the solution has to be some sort of uniform gauge condition for all $$x$$, ensuring the smoothness of the connection. Is there anyway to add this, or implement this within LAPACK? I have so far been unsuccessful.

Thanks!

P.S. Naturally, the Berry connection is not gauge invariant, so it won't directly enter any physical observable. The issue is, however, that errors in the evaluation of $$\hat{A}$$ propagate directly to observable quantities, like the berry curvature for example. Quantities $$i[A,A]$$ suddenly contain disallowed imaginary parts, coming in from errors in $$\hat{A}$$.