# The lowest eigenvalues For an eigenproblem $H\psi = E\,\psi$ with $H = -\sum_i a_i\,\partial_i^2 + V(\mathbf{x})$, on a periodic domain or in free space, the lowest eigenvalues are found by an iteration that needs nothing of the operator but its action on a function. The modes of a shape in the plane are found by the same iteration, on the inverse of the operator. ## The operator on a grid On a uniform grid of a periodic domain a function is its Fourier series. The second derivatives multiply each wave by $\sum_i a_i k_i^2$, which is exact, and the potential multiplies the values at the points. So $H$ is applied with one transform there and one back. The matrix of $H$ is never formed: it is dense, and in three dimensions it would not fit. ## A block of vectors The iteration is the locally optimal block preconditioned conjugate gradient method of Knyazev. It holds a block of functions, a few more than the eigenvalues that are wanted. In each step 1. the residual $H\psi - \theta\psi$ of each function is taken, with its Rayleigh quotient $\theta$; 2. a preconditioner turns each residual into a correction; 3. the best functions are found in the space of the block, the corrections and the directions of the step before: the eigenvectors of $H$ in that small space, from a dense eigenproblem of three times the size of the block (Rayleigh and Ritz). The operator is applied once to each correction. Its action on every other function follows, since the new functions are combinations of old ones. The small eigenproblem needs the products of every pair of functions in the space: they are computed on all cores, each as a sum in eight parts whose order is fixed, so that the result does not depend on the number of cores. The directions of a step are made orthonormal in the small space, by their coefficients, and not as functions on the grid. As functions they are nearly combinations of the others once the iteration has almost arrived, and to make them orthogonal there would lose all their digits: the iteration would turn back and diverge. In the small space nothing is lost. ## The preconditioner A residual is turned into a correction by the inverse of the second derivatives, shifted: each wave is divided by $\sum_i a_i k_i^2 + s$. The shift $s$ is how far the eigenvalue lies above the lowest value of the potential, which bounds the energy of motion of its state, plus the smallest energy of motion of a wave of the grid. That takes the short waves out of the residual, which are what makes the plain iteration slow, and leaves the long ones as they are. Where the potential stands far above the state, the operator is the potential, and the second derivatives say little. There the residual is multiplied by $\sqrt{s/(s + V - V_{\min})}$ before and after, which makes the preconditioner about $1/(V - V_{\min})$ in those places and keeps it symmetric. It halves the iterations of an oscillator, and it is what makes a well with a steep wall converge at all. The iteration starts from the waves with the least energy of motion, as cosines and sines. It stops when the residual of every wanted eigenfunction has fallen to $10^{-10}$ of the largest Rayleigh quotient of the block. A function that has arrived gets no further correction. An iteration can only be as accurate as the products with its operator. If the residual has not halved in twelve steps and lies within ten times the tolerance, the iteration ends there, and the diagnostic `residual` says what it reached. On a shape, where the operator is a solve on a mesh that may be graded over many orders of size, that margin is wider: a residual of $10^{-7}$ still gives an eigenvalue to fourteen digits. ## The grid The planner solves on grids of 16, 24, 32, 48, … points along the longest period, each time starting from the eigenfunctions of the grid before, which are carried over by their Fourier series. It takes the first grid on which the Fourier coefficients of every eigenfunction, and of the potential times it, have fallen to $10^{-10}$ in the upper third of the waves. The solution on that grid is what `pm.solve` returns when it is given no plan: the fine grids start so close that they cost a few iterations each. The potential alone is not measured. On a ring it need not be smooth where the ring closes, as $x^2$ is not: that does no harm where the eigenfunctions have faded, and the product shows whether they have. An eigenvalue is more accurate than its eigenfunction: its error is the square of the error of the function. ## Free space: the box In free space the bound states are found, on a box that is long enough for them to have faded at its faces. There it does not matter that the grid closes on itself. The planner finds the box in four steps. 1. **Where the potential is lowest.** It looks at the potential along each free coordinate at distances that double, from $2^{-8}$ to $2^{20}$, and moves to the lowest value, three times over. A potential that keeps falling towards a point has a singularity there, and is refused. 2. **How wide a state is there.** The smallest length $L$ over which the potential rises by $a/L^2$, the energy of motion of a state of that width. A potential that never does binds nothing, and is refused. 3. **The eigenvalues, roughly.** A coarse solve on a box of six such widths to either side. 4. **How far the highest state reaches.** Beyond where the potential crosses its eigenvalue $E$, a state falls as $\exp(-\int\sqrt{(V - E)/a}\,dx)$. The box ends, on each side of each coordinate, where that has fallen to $10^{-10}$. If the potential does not stay above $E$, the state is not bound, and the problem is refused with that eigenvalue. Then the problem is solved on that box, and the box is made longer if the states have not fallen to $10^{-9}$ on its faces. The two sides of a coordinate have their own lengths: a Morse well, $8(1 - e^{-x})^2$, gets a box from −2.3 to 20.8. The grid of a box lies half a step inside it at either end, and closes after the length of the box whatever its number of points. So the grids of the planner hold the same waves, and the eigenfunctions of one are carried over to the next exactly. ## On a shape: the inverse On a [region of the plane](spectral-elements.md) the operator is the matrix of spectral elements, with the stiffness $K$ and the mass $M$: $K u = E\,M u$. Its action alone would serve badly, since a fine mesh has short waves that only a solve takes out. There the iteration runs on the inverse: on $-\sqrt{M}\,(K + \sigma M)^{-1}\sqrt{M}$, whose lowest eigenvalues are $-1/(E + \sigma)$ for the lowest $E$. They lie far apart, a dozen steps suffice, and the preconditioner is left out. Each application is a stationary solve with a sparse factorization that is computed once. The corrections of a step are solved for side by side, on a thread each. ## Accuracy and cost On periodic domains: | Problem | Grid | Iterations | Error of the eigenvalues | Time | |---|---|---|---|---| | Harmonic oscillator, 6 states, on a ring of the length 20 | 96 | 10 | $6\cdot10^{-15}$ | 0.01 s | | The well $-1/\cosh^2 x$, its bound state $E = -\tfrac12$ | 512 | 82 | $3\cdot10^{-16}$ | 0.01 s | | Oscillator in the plane, 6 states | $64^2$ | 80 | $10^{-14}$ | 0.2 s | | Oscillator in space, 4 states | $64^3$ | 63 | $10^{-13}$ | 2.4 s | | A lattice of wells in the plane, 4 states | $32^2$ | 27 | | 0.02 s | In free space, with the box found by the planner: | Problem | Box | Grid | Error of the eigenvalues | Time | |---|---|---|---|---| | Harmonic oscillator, 6 states | −8.7 to 8.7 | 96 | $9\cdot10^{-15}$ | 0.01 s | | The well $-1/\cosh^2 x$ | −27.7 to 27.7 | 512 | $10^{-16}$ | 0.02 s | | The Morse well $8(1 - e^{-x})^2$, 3 states | −2.3 to 20.8 | 384 | $4\cdot10^{-15}$ | 0.03 s | | Oscillator in the plane, 6 states | ±8.1 | $64^2$ | $10^{-14}$ | 0.2 s | | Oscillator in space, 4 states | ±7.9 | $64^3$ | $6\cdot10^{-14}$ | 5.9 s | The times are for `pm.solve` without a plan, and the iterations are those of all grids of the planner together. Nearly all of the time in space goes into the two finest grids. Mathieu's equation, $u'' + (a - 2q\cos 2x)\,u = 0$, for $q = 1.5$: the five lowest characteristic values agree to $10^{-9}$ with those of its matrix in the basis of waves. ## Limits - **Free or periodic directions, and shapes in the plane.** Between walls and on round domains the modes separate, and are taken from [collocation](cavity-modes.md) without an iteration, for constant coefficients only. - **Many eigenvalues.** The small eigenproblem and the combinations of the functions grow with the square of the size of the block. Forty modes of a disk take five seconds, a good part of it there. - **Bound states.** In free space a state that does not fade has no box. A state that is barely bound reaches far, and needs a long box with many points: the grid is uniform. - **The box follows the potential along the coordinates** through the point where it is lowest. A state that reaches furthest elsewhere is caught by the check on the faces, which lengthens the box. - **Second derivatives with constant coefficients, and a real potential.** No first derivatives, no medium, no weight that varies beside the eigenvalue. - **The lowest eigenvalues.** Not those near a given value, and not the highest. - **A smooth potential.** A singularity, as of $-1/r$, is refused in free space, and costs the spectral accuracy on a periodic domain. - **A plan of your own is solved from waves.** Only the planner starts a grid from the solution of the one before. - **Memory.** The iteration holds about six functions on the grid for each function of its block. ## Sources - A. V. Knyazev, "Toward the optimal preconditioned eigensolver: locally optimal block preconditioned conjugate gradient method", SIAM Journal on Scientific Computing 23 (2001). - J. A. Duersch, M. Shao, C. Yang, M. Gu, "A robust and efficient implementation of LOBPCG", SIAM Journal on Scientific Computing 40 (2018): the orthogonal basis of the small space.