Say I am trying to find the first 5 eigenvalues of the differential equation $f''(x)=\lambda x f(x)$, on the interval [-1,0], with boundary conditions $f(-1)=f(0)=0$.
I will try to do this 3 ways, and compare them to values for the eigenvalues found via a WKB approximation.
Trying to solve this using NDEigenvalues without Dirichlet condition.
NDEigenvalues[{f''[x]/x}, f[x], {x, -1, 0}, 5]
{0., 25.6383, 95.9537, 210.72, 370.024}
Trying to solve this using NDEigenvalues with Dirichlet condition.
NDEigenvalues[{f''[x]/x, DirichletCondition[f[x] == 0, True]}, f[x], {x, -1, 0}, 5]
{0., 19.6448, 84.2639, 194.087, 349.122}
Trying to solve this using FindRoot.
First solve the differential equation analytically.
DSolve[{y''[x] == x A y[x]}, y[x], x]
{{y[x] -> AiryAi[A^(1/3) x] C[1] + AiryBi[A^(1/3) x] C[2]}}
The solution is in terms of Airy functions.
Now plug in the boundary conditions at $x=0$, and $x=-1$.
$f(0)=f(-1)\\ \rightarrow c_{1}\mathrm{Ai}(0)+c_{2}\mathrm{Bi}(0) = c_{1}\mathrm{Ai}(-A^{1/3})-c_{2}\mathrm{Bi}(-A^{1/3})\\ \rightarrow c_{1}\mathrm{Ai}(0)+c_{2}\mathrm{Bi}(0)-c_{1}\mathrm{Ai}(-A^{1/3})+c_{2}\mathrm{Bi}(-A^{1/3})=0$
Choose the constants to be $1$.
If FindRoot
is used now.
FindRoot[AiryAi[0] + AiryBi[0] - AiryAi[-A^(1/3)] - AiryBi[-A^(1/3)], {A, {0, 20, 85, 200, 350}}, WorkingPrecision -> 10]
{A -> {0, 0.2867307855, 88.39876753, 798.9989135, 354.8666727}}
And there is an error.
FindRoot:: Encountered a singular Jacobian at the point {A} = {0,0.2867307855,88.39876753,798.9989135,354.8666727}. Try perturbing the initial point(s).
This result isn't too surprising, as the Airy functions are not very nice.
If we try to clean up the equation that is being put in FindRoot
.
FindRoot[AiryBi[-A^(1/3)]/AiryAi[-A^(1/3)] - Sqrt[3], {A, {0, 20, 85, 200, 350}}, WorkingPrecision -> 10]
{A -> {0, 18.95626559, 81.88658338, 189.2209333, 340.9669591}}
WKB Approximation
A quick WKB approximation will tell you $A=\left(\frac{3 n \pi}{2}\right)^{2}$.
n = {0, 1, 2, 3, 4};
N[((3 n \[Pi])/2)^2]
{0., 22.2066, 88.8264, 199.859, 355.306}
Questions
Is one of these approaches more correct than the others? Comparing the results of the NDEigenvalues
to FindRoot
, the FindRoot
solutions are closer to the WKB approximation, especially at larger eigenvalues (e.g. 20 eigenvalues out).
Which version of the FindRoot
method is more correct? It is possible I am misusing/misunderstanding some things, so if anyone can point out any mistakes, optimizations, or even other methods, that would be very helpful. Thank You.
FindRoot
, the BCs are $f(-1)=f(0)=0$, not $f(-1)=f(0)$. You cannot choose both constants $c_1,c_2$ freely. $\endgroup$