# Why NDSolve can not solve this second-order nonlinear ODE

I try to solve:

eq[t_] := ddf[t] + a'[t]/a[t] df[t] + 6 f[t] - 3  a[t]^2  f[t]^2

with

f[t_] := Exp[(1/2)*(-2*(Derivative[1][a][t]/a[t]) +
Sqrt[4*(Derivative[1][a][t]^2/a[t]^2) - 4*a[t]^2*k[t]^2])*t]

df[t_] := D[f[t], t]

ddf[t_] := D[f[t], {t,2}]

and:

k[t_] := Sqrt[(3 t Derivative[1][a][t]^2 + a[t] (Derivative[1][a][t] -
t (a^\[Prime]\[Prime])[t])) (-t Derivative[1][a][t]^2 +
a[t] (Derivative[1][a][t] + t (a^\[Prime]\[Prime])[t]))]/Sqrt[
a[t]^4 (a[t] + t Derivative[1][a][t])^2]

I try to solve numerically by NDSolve :

NDSolve[{eq[t]==0,a[0] == 1, a'[1] == 1, a'[1] == 1, a[1] == 1}, {a[t]}, {t, 1, 10},
PrecisionGoal -> 5 ]

The initial conditions are so arbitrary and can be changed.

However NDSolve stuck and the MA code hangs. I tried to use AsymptoticDSolveValue but no output as well.

I know that after all the substitution the eq[t] is somehow complicated and has $$a[t]^3$$ terms, so that I use four constrains, but I hope to find a way it can be solved by MA.

Any help is appreciated!

• you do not have df[t] defined. You do not have ddf[t] defined. Your ode seems to be second order. Yet, you are giving 4 initial/BC, and one of them is second order. This is wrong. Commented Jan 10 at 10:49
• I added the functions definitions. Also I modified the initial conditions. Thanks @Nasser Commented Jan 10 at 10:56
• actually your ode is 4th order. But it was hidden. Commented Jan 10 at 11:05

The initial conditions are so arbitrary and can be changed.

If you make your IC's start at the start of the domain, it works. You are integrating the ode from 1 on, but you had an IC at zero. This makes life harder for NDSolve.

NDSolve[{ode, ic}, a, {t, 1, 2}, Method -> {"StiffnessSwitching"}]

I changed your IC's to the following: (since you have 4th order ode)

ode=eq[t]==0;
ic={a[1]==1,a'[1]==1,a''[1]==1,a'''[1]==0}

Your eq[t] is too complicated, so will not copy your code here again :)

Trying to solve for larger domain than 2.2 gives

Additional changes to options for NDSolve might help with this issue.

V 14.0 on windows.