# Second Order ODE (Bessel Function) with a dependent variable in the BC

I have obtained an analytic solution to the following problem however I lack the knowledge to generate a numerical solution using mathematica. I'm reaching out to get an idea of what functions I may need to apply or how I can go about solving this problem numerically.

I am trying to solve the following Second Order ODE:

eq = x^2 u''[x] + 2 x u'[x] - m^2 x u[x] == 0;


I am trying to solve this ODE with the following boundary conditions:

BC1 = u[L] == ub;
BC2 = u'[0] == m u[x];


However the issue that I am having is defining the second boundary condition in Mathematica.

The solution to the ODE is a set of Bessel Functions. I can solve this analytically by applying L'hospital's rule for the 2nd boundary condition. However I am not certain how I should go about applying this in Mathematica.

Simply specifying the above and plugging them into NDSolve does not generate a solution (as it should not):

soln = NDSolve[{eq, BC1, BC2}, u, x]


I would appreciate any insights into solving this problem.

• Your second boundary condition looks incorrect, since its right-hand part depends upon u[x]. In general the equation itself solves nicely analytically (check DSolve[eq, u[x], x][[1, 1]] , so you, indeed, might go ahead analytically – Alexei Boulbitch Oct 7 '15 at 8:05
• Hi Alexei, thank you for your feedback, it is a tricky problem. One way of solving this problem numerically could be to utilize a shooting method and guessing an initial value for u'[x] or u[x] in the 2nd BC. It has been done in Matlab I just dont know how to adapt it in Mathematica. As you pointed out, an analytic solution does come together really nicely if one were to use L'hospital's Rule when x ->0, I was hoping to use a set of replacement rules or perhaps implement limits to tell Mathematica to solve a modified version of the ODE above for when x=0. – Valentin Oct 7 '15 at 12:19
• Look, you can apply L'Hopital's rule, or find a limit in Mma, no problem, or apply a shooting method. However, the boundary condition u'[0] == m u[x]  looks for me incorrect. – Alexei Boulbitch Oct 7 '15 at 14:00
• I guess BC2 is actually $u'(x)=m u(x)$ when $x\to 0$? – xzczd Jan 6 '16 at 5:49