# Numerical solution of a differential equation with a condition on a parameter

I'm considering the Mazenko equation as it's written in https://doi.org/10.1103/PhysRevB.46.10594 (eq. 7)

$$$$f''+\left(\frac{1}{x}+\frac x 4 \right)f'+\frac \lambda \pi \,\tan\left(\frac \pi 2 f \right)=0\tag{7}$$$$

with initial conditions $$f(0) = 1, f'(0) = -\frac {\sqrt{2\lambda}} \pi$$.

It is known that the solution has two limits $$$$f(x) \sim 1-\alpha(\lambda)x+O(x^3)\qquad x\to 0.$$$$ $$$$f(x) \sim A(\lambda) \, x^{-(2-2\lambda)}\,\,e^{-x^2/8}+B(\lambda) \,x^{-2\lambda} \qquad x \gg 1$$$$ and I would like to use Mathematica to numerically find the particular value ($$\lambda_M\approx0.711$$) of $$\lambda$$ such that it would be $$B(\lambda)=0$$.

Integrating numerically around $$x=0$$ is going to be hard, because it is a singular point of the ODE. So let us integrate over the range $$x\in[1/L,L]$$, with $$L$$ very large. We are looking for $$\lambda$$ such that $$B(\lambda)=L^{2\lambda}f(L)=0$$. We solve this as follows.

Clear[B]
B[λ_?NumericQ, L_?NumericQ] := Module[{min = 1/L, max = L, f0, df0},
f0 = (1 + Sqrt[λ/2] 1/π (-2 min + 1/60  min^3 (3 + 2 λ) + (min^5 (-31 - 28 λ + 4 λ^2))/20800 + (5551 + 5782 λ - 4 λ^2 (623 + 54 λ))/145600000  min^7));
df0 = 1/(Sqrt[2] π) Sqrt[λ] (-2 + 1/20 min^2 (3 + 2 λ) + (min^4 (-31 - 28 λ + 4 λ^2))/4160 + (min^6 (5551 + 5782 λ - 4 λ^2 (623 + 54 λ)))/20800000);
(NDSolve[{f''[x] + (1/x + x/4) f'[x] + λ/π Tan[π/2 f[x]] == 0, f[min] == f0, f'[min] == df0}, f[x], {x, min, max}, WorkingPrecision -> 30, AccuracyGoal -> 25, PrecisionGoal -> 25, MaxSteps -> 100000][[1, 1, 2]] /. x -> max) max^(2 λ)
]


With this, the root can be found using

FindRoot[B[λ, 10], {λ, 7/10}, WorkingPrecision -> 30]


where I have taken $$L=10$$. Increasing the value of $$L$$ we get an increasingly more precise estimate of $$\lambda$$. I find $$\lambda=0.7112768967266...$$ and here is a plot that shows the error vs. $$L$$: