# Having error with solving BVP problem

I am trying to solve this differential equation but using my approach:

sol2[bc2_] := NDSolveValue[{χ''[x] == (χ^3/2)/Sqrt[x], χ[0] == bc2, χ[10] == 0},
χ, {x, 0, 10}];
χ2 = sol2[NMinimize[(bc2 - 1)^2, bc2][[-1, -1, -1]], {0, 1}]
Plot[{χ2[x]}, {x, 0, 10}]


I got a wrong result

How can I implement my method correctly ? Thank you.

• Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. Commented Apr 19, 2020 at 0:41

The code contains a few minor errors:

• The computation must start a tiny distance fromx = 0, because the ODE is singular there. (I used x0 = 10^-8 but verified that the solution was insensitive to small changes.)
• Replace χ^3/2 by χ[x]^3/2 in the ODE.
• Delete , {0, 1} from second equation.

However, the main issue is that the solution is strongly dependent on the choice of χ2'[x] near x == 0. Hence, the Shooting option must be employed explicitly, and a good guess given.

x0 = 10^-8;
sol2[bc2_] := NDSolveValue[{χ''[x] == (χ[x]^3/2)/Sqrt[x], χ[x0] == bc2, χ[10] == 0},
χ, {x, x0, 10}, Method -> {"Shooting", "StartingInitialConditions" -> {χ'[x0] == -.85}}]
χ2 = sol2[NMinimize[(bc2 - 1)^2, bc2][[-1, -1, -1]]];
Plot[{χ2[x]}, {x, x0, 10}]


I obtained the guess for χ'[x0] == -.85 by experimentation.

• Thank you very much for an elegant solution. In my code for the NMinimize[(bc2 - 1)^2, bc2][[-1, -1, -1]], I don't know what is the purpose of [-1,-1,-1] ? Can you elaborate on that option ? Commented Apr 19, 2020 at 0:37
• NMinimize returns {0., {bc2 -> 1.}}.  [-1,-1,-1] extracts .1. See the documentation for Part. Commented Apr 19, 2020 at 0:47
• @bbgodfrey (+1) What is the reason for NMinimize in this code? It looks like method "Shooting" getting solution it self. Commented Apr 19, 2020 at 11:45
• @AlexTrounev You are correct that NMinimize serves no substantive purpose in the answer. I retained it from the question, because I assumed that the OP planned to apply the code to a more challenging problem. Commented Apr 19, 2020 at 12:03
• @bbgodfrey (+1) from me. Commented Apr 19, 2020 at 12:26