# Boundary conditions shooting method

I am trying to solve the differential equation

$\frac{d^{2}y}{dr^2}+(\frac{1}{r}+1)y=0$

with the boundary conditions

$y(r) \rightarrow r \frac{dy}{dr}(0)$ as $r \rightarrow 0$ and $y(r) \rightarrow \sin(kr+\delta)$ as $r \rightarrow \infty$.

I know that the shooting method is the way to go, but am having trouble figuring out how to implement the boundary conditions.

Are the following lines of code in Mathematica alright? I have not yet wrapped it around a root-finding algorithm.

diffeq = {y''[r] + ((1/r) + 1) y[r] == 0, y[0] == 0, y'[0] == 5};
sol = NDSolve[diffeq, y, {r, 0, 200}, Method -> "ExplicitRungeKutta"];


Now, how do I check that the first boundary condition is satisfied by the solution?

Also, I know that the value of y[0] is to be changed and the code run until the second boundary condition is satisfied. What check should I use for that? Do I just check if the solution lies between -1 and 1 as $r \rightarrow \infty$.

Why not solve the problem exactly?

You will find that the asymptotics does not fit what you requested but contains an additional logarithmic phase.

yy[r_] = y[r] /.
DSolve[y''[r] + (1 + 1/r) y[r] == 0 && y[0] == 0 && y'[0] == 5, y[r],
r][[1]] // Quiet

(*
Out[151]= 5 E^(-I r) r Hypergeometric1F1[1 + I/2, 2, 2 I r]
*)


Checking the intial values: OK

{yy[0], yy'[0]}

(* Out[152]= {0, 5} *)


The asymptotic expansion is

s = Series[yy[r], {r, ∞, 1}] // Normal

(*
Out[156]= E^(-I r) r^(-(I/
2)) ((5 (-2 I)^(-1 - I/2))/Gamma[1 - I/2] + (
5 (2 I)^(-1 + I/2) E^(2 I r) r^I)/Gamma[1 + I/2])
*)


Letting

z = (5 ((-2 I)^(-1 - I/2)) )/Gamma[1 - I/2];


and defining modulus ρ and phase δ of z by

z = ρ Exp[I δ];


the asymptotic expansion becomes

s1 = ρ Cos[r + 1/2 Log[r] - δ];


The numeric values are

{ρ, δ} = {1.3796613460821034, 0.9801644376094962};