# NDSolve second order diff eq with two boundary conditions?

I'm trying to reproduce some results from a paper. The problem is the following:

As you can see they say they can solve that equation with NDSolve. But there is no initial condition for y'. I tried:

ode=y''[x]==(6x-x^2)/0.9*y'[x]+(r+s)/0.9*y[x]
NDSolve[{ode,y[0]==1,y[300]==0},y,{x,-3,6}]


The potential and the D value are similar to the ones used in the paper. I used x=300 as a reasonable value for inifinity in the context of the problem. But I get the following error: Encountered non-numerical value for a derivative at x==0

How do you think this can be solved? PD: s is fixed to zero afterwards.

• What is r and s? – DiSp0sablE_H3r0 May 19 at 10:17
• If I fix r=2.5 and s=0 (which the authors apparently do after the integration), then the error is the computation time. – Julia May 19 at 10:31
• I don't understand how anyone can integrate numerically with undetermined/unspecified coefficients to be honest. – DiSp0sablE_H3r0 May 19 at 10:41
• Actually we can use ParametericNDSolve[] with k=r+s as parameter. – Alex Trounev May 19 at 10:59
• @AlexTrounev I was actually thinking of an initial condition at 0 with a random parameter, call it y0, and do ParametricNDSolve[] with that as a parameter. – DiSp0sablE_H3r0 May 19 at 11:03

This is meant to be an extended comment that is of some use hopefully.

There are a couple of issues that I can spot.

1. You have not assigned any values to the r and s parameters.Let's fix that.

r = 1;

s = 3;

2. The other thing that does not make much sense to me is that you include a boundary value at infinity and you solve until another point before that.

The reason it does not make much sense, is simple enough to see. To demonstrate consider the toy model problem with infinity at five and we are solving all the way to three. We run

sltn = NDSolve[{ode, y[0] == 1, y[5] == 0}, y, {x, -3, 3}];
(y[x] /. sltn) /. x -> 5


The error that you are getting when you try to evaluate y[x] should clarify what I mentioned earlier.

I assume that this might by a typo in the OP and push through.

Let's say that $$\infty = 5$$ and use the following

ode = y''[x] == (6 x - x^2)/0.9*y'[x] + (r + s)/0.9*y[x];
sltn = NDSolve[{ode, y[0] == 1, y[5] == 0}, y, {x, -3, 5},
Method -> "ExplicitRungeKutta"];


The above solves all the way to "infinity" with a boundary condition at infinity and returns a solution that you can plot and see

Plot[y[x] /. sltn, {x, -3, 5}, PlotRange -> {{-3, 5}, {-10, 10}}]


You can of course also set the boundary condition at infinity=5 and solve all the way out to 7 and get a result without errors. But in this way, 5 does not correspond to infinity anymore. I am just including it for completeness.