I attacked this problem by making the substitution
$x = e^{-t}$. When subbing for the independent variable, we need to make careful use of the chain rule to express
$u(x), u'(x), u''(x)$ in terms of
$u(t), u'(t), u''(t)$.
ode = u''[x]+(u'[x]/x)-(u[x]/(x^2))+u[x]-u[x]^3 == 0;
sub = Exp[-t];
newode = ode /. {
u[x] -> u[t],
u'[x] -> u'[t]/D[sub, t],
u''[x] -> (u''[t] - D[sub, {t, 2}] u'[t]/D[sub, t])/D[sub, t]^2,
x -> sub
}
u[t] - E^(2 t) u[t] - u[t]^3 - E^(2 t) u'[t] + E^(2 t) (u'[t] + u''[t]) == 0
sol = NDSolveValue[{newode, u[1] == 0, u[0] == 1}, u[t], t] /. t -> Exp[-x];
sol /. x -> 0
0.
sol /. x -> 10^15
1.
Plot[Evaluate[sol], {x, 0, 10}, PlotRange -> All]
Here's my issue though... If I plug this solution into the original ODE, I don't get zero, so I think I did something wrong but I can't figure out where. In fact I am having the same issue with Hans Dolhaine's solution he posted above (his is sol2
in the plot below).
Maybe someone here can figure out where I went wrong? I feel it's a simple oversight.
Plot[Evaluate[{
D[sol, {x, 2}] + (D[sol, x]/x) - (sol/x^2) + sol - sol^3,
D[sol2, {x, 2}] + (D[sol2, x]/x) - (sol2/x^2) + sol2 - sol2^3
}], {x, 4, 20}, PlotRange -> All]