Skip to main content
2 of 2
improved wording
bbgodfrey
  • 62.1k
  • 18
  • 92
  • 160

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.

enter image description here

bbgodfrey
  • 62.1k
  • 18
  • 92
  • 160