# How to numerically calculate quantum state distance using quantum metric?

In Ran Cheng's review of the quantum geometric tensor, eq. (11) gives the tensor as: $$Q_{\mu\nu}=\sum_{n\neq 0}\frac{\langle\phi_0|\partial_\mu H|\phi_n\rangle\langle\phi_n|\partial_\nu H|\phi_0\rangle}{(E_0-E_n)^2}.$$ Per eq. (6), we see that the quantum metric may be defined as: $$g_{\mu\nu}=\text{Re }Q_{\mu\nu}.$$ I now want to calculate the distance between two arbitrary quantum states of a two-level system parameterized by two variables $$(k_x,k_y)$$ using eq. (9): $$|\langle\phi(\lambda_F)|\phi(\lambda_I)\rangle|=1-\frac{1}{2}\int_{\lambda_I}^{\lambda_F} g_{\mu\nu}(\lambda)d\lambda^\mu d\lambda^\nu.$$

Could someone verify that the steps I'm taking are correct? The results of my numerical simulations seem suspicious.

1. Find the two eigenvectors of the 2-level Hamiltonian (not resulting in the nice standard eigenvectors discussed in Cheng's work).
2. Use these to calculate $$g_{k_x k_x},g_{k_x k_y},g_{k_y k_x}$$ and $$g_{k_y k_y}$$.
3. To perform the path integral, I first parameterize some path in $$k$$-space (for example using $$k_x (t) = \sin(t), k_y(t) = \cos(t)$$).
4. Plug these $$k_x(t),k_y(t)$$ into $$g_{\mu\nu}$$ found in step 2.
5. Using motivation from eq. (21) of the review, numerically integrate the following, for absolute value of some $$x$$ indicated by $$|x|$$: $$|\langle\phi(\lambda_F)|\phi(\lambda_I)\rangle|=1-\frac{1}{2}\int_{\lambda_I}^{\lambda_F} \sqrt{ \left|g_{k_x k_x} \left(\frac{dk_x}{dt}\right)^2\right|+ \left|g_{k_x k_y}\left(\frac{dk_x}{dt}\right)\left(\frac{dk_y}{dt}\right)\right|+ \left|g_{k_y k_x}\left(\frac{dk_y}{dt}\right)\left(\frac{dk_x}{dt}\right)\right|+ \left|g_{k_y k_y}\left(\frac{dk_y}{dt}\right)^2\right| } dt.$$ I am supposed to get an answer between $$0$$ and $$1$$, but I am not sure I incorporated/defined the metric correctly. Any advice?

UPDATE: As requested, here is (Mathematica) code that I used:

(* Some Hamiltonian H[kx,ky] with eigenvectors |n[kx,ky]>,|p[kx,ky]> \
and eigenvalues Energy[kx,ky]*)
m = 0.1;
sx = {{0, 1}, {1, 0}}; sy = {{0, -I}, {I, 0}}; sz = {{1, 0}, {0, -1}};
H[kx_, ky_] = m sz + kx sz + ky sy;
p[kx_, ky_] =
Eigenvectors[H[kx, ky]][[1]]/Norm[Eigenvectors[H[kx, ky]][[1]]];
n[kx_, ky_] =
Eigenvectors[H[kx, ky]][[2]]/Norm[Eigenvectors[H[kx, ky]][[2]]];
Energy[kx_, ky_] = Eigenvalues[H[kx, ky]];
(* Components of Quantum geometric tensor *)
Qxx[kx_, ky_] = ((Conjugate[n[kx, ky]] . D[H[kx, ky], kx] .
p[kx, ky]) (Conjugate[p[kx, ky]] . D[H[kx, ky], kx] .
n[kx, ky]))/(Energy[kx, ky][[2]] - Energy[kx, ky][[1]])^2;
Qxy[kx_, ky_] = ((Conjugate[n[kx, ky]] . D[H[kx, ky], kx] .
p[kx, ky]) (Conjugate[p[kx, ky]] . D[H[kx, ky], ky] .
n[kx, ky]))/(Energy[kx, ky][[2]] - Energy[kx, ky][[1]])^2;
Qyx[kx_, ky_] = ((Conjugate[n[kx, ky]] . D[H[kx, ky], ky] .
p[kx, ky]) (Conjugate[p[kx, ky]] . D[H[kx, ky], kx] .
n[kx, ky]))/(Energy[kx, ky][[2]] - Energy[kx, ky][[1]])^2;
Qyy[kx_, ky_] = ((Conjugate[n[kx, ky]] . D[H[kx, ky], ky] .
p[kx, ky]) (Conjugate[p[kx, ky]] . D[H[kx, ky], ky] .
n[kx, ky]))/(Energy[kx, ky][[2]] - Energy[kx, ky][[1]])^2;
(* For integral, parameterize by g the k-space path (qx[g],qy[g]) of \
radius r, center (kx0,ky0). *)
r = 1; kx0 = 0; ky0 = 0;
qx[g_] = kx0 + r Cos[g];
qy[g_] = ky0 + r Sin[g];
(* Derivatives of qx[g],qy[g] for integral metric*)
dqx[g_] = D[qx[g], g]; dqy[g_] = D[qy[g], g];
(* Components of metric tensor*)
gxx[kx_, ky_] = Re[Qxx[kx, ky]];
gxy[kx_, ky_] = Re[Qxy[kx, ky]];
gyx[kx_, ky_] = Re[Qyx[kx, ky]];
gyy[kx_, ky_] = Re[Qyy[kx, ky]];
(* Starting and ending points of g, for integration limits. If \
gend=2Pi, I expect the distance to = 0, since they are the same point \
as the parameterized path is then that of a closed circle. *)
gstart = 0;
gend = 3/4 Pi;
(* Quantum distance: I am not sure whether my definition of the \
metric is correct. *)
distance =
1 - (1/2) NIntegrate[
Sqrt[Abs[gxx[qx[g], qy[g]] dqx[g] dqx[g]] +
Abs[gxy[qx[g], qy[g]] dqx[g] dqy[g]] +
Abs[gyx[qx[g], qy[g]] dqy[g] dqx[g]] +
Abs[gyy[qx[g], qy[g]] dqy[g] dqy[g]]], {g, gstart, gend}]

• +1. Can you show us the MATLAB code you used and some example numbers (input and output)? I can try to see if I get the same output with the same input, or something else. Nov 29 '21 at 4:52
• @NikeDattani thanks. Unfortunately, I used Mathematica for the numerical integration. But I updated my post with my code. Nov 29 '21 at 5:13
• Maybe change the tolerance in NIntegrate? Nov 29 '21 at 7:52
• @NikeDattani thank you, do you know whether my definition/implementation of the metric tensor inside the integral is correct? I tried other variants as well. Nov 29 '21 at 16:36

## 1 Answer

The issue was the absolute values, and misunderstanding the notation. Per eq. (2) of this paper, we have: $$ds^2 =1-|\langle\phi(\lambda_F)|\phi(\lambda_I)\rangle| =\sum_{\mu\nu}g_{\mu\nu}(\lambda)d\lambda^\mu d\lambda^\nu$$

Then, to get the quantum distance, all I needed to do was get $$\int ds$$:

NIntegrate[Sqrt[gxx[g] + gxy[g] + gyx[g] + gyy[g]], {g, gstart, gend}],


where I re-defined the functions gxx, etc for convenience:

gxx[g_] = gxx[qx[g], qy[g]] dqx[g] dqx[g];
gxy[g_] = gxy[qx[g], qy[g]] dqx[g] dqy[g];
gyx[g_] = gyx[qx[g], qy[g]] dqy[g] dqx[g];
gyy[g_] = gyy[qx[g], qy[g]] dqy[g] dqy[g];


after re-defining each component in terms of parameter g alone:

gxx[g_]=gxx[qx[g],qy[g]]