I'm trying to solve linear (non-self-adjoint) boundary-value problems to as high precision as possible (optimally 1e-15). For example, the below code solves for the first 5 eigenvalues of the harmonic oscillator,
$$ -u'' + V(x) u = Eu $$
where $V(x) = x^2$ which should be solved subject to $u \to 0$ as $|x| \to \pm\infty$. It then outputs the error compared to the exact values of
$$E_n = (2n + 1), \quad n = 0, 1, \ldots $$
xmax = 100;
numeigs = 5;
maxcell = 0.01;
V[x_] := x^2
Leq = -u''[x] + V[x]*u[x];
{vals, funs} =
NDEigensystem[Leq, u[x], {x, -xmax, xmax}, numeigs,
Method -> {"SpatialDiscretization" -> {"FiniteElement", \
{"MeshOptions" -> {MaxCellMeasure -> maxcell}}}}];
vals - Table[(2*n + 1), {n, 0, numeigs - 1}]
with errors:
{2.64357*10^-11, 1.82258*10^-10, 6.51789*10^-10, 1.64085*10^-9,
3.36012*10^-9}
There are two key parameters: the xmax
condition should tend to infinity and the maxcell
should tend to zero. I've tried raising and lowering both but I can't seem to get better than 1e-10 at the first eigenvalue.
I've also tried adding something like this:
arnoldcond :=
"Eigensystem" -> {"Arnoldi", "MaxIterations" -> Infinity,
Tolerance -> 10^(-20)};
but it doesn't seem to help much and to be honest I have no idea what that "Tolerance" actually does.
Additional reference [1] Gaining precision/accuracy with NDEigenvalues