I am using a Runge-Kutta fourth order method to solve numerically the usual equation of motion of a background scalar field in curved spacetime with a quartic potential:
$\phi^{''}=-3\left(1+\frac{H^{'}}{3H}\right)\phi^{'}-\lambda\phi^3/H^2$,
$'$ denoting the derivative w.r.t. the e-folds number $\textrm{d}N=H\textrm{d}t$ and, from the Friedmann equation:
$H^2=\frac{\lambda \phi^4}{4}\frac{1}{3M_{Pl}^2-(1/2)\phi^{'2}}$;
$H^{'}=-\frac{1}{2M_{Pl}^2}H\phi^{'2}$.
The problem comes when integrating backwards using as the initial conditions the final values I got after integrating forward. The outcome blow up without matching the values obtained before, when integrating forward. I simply do not understand where the problem is as both the equation and the code are not unknown whatsoever. Firstly, I integrated from 0 to 64 e-folds. Then I simply reverse the integration direction.
I attach the code too:
def rk4trial(f,v0,t0,tf,n,V):
t=np.linspace(t0,tf,n)
h=t[1]-t[0]
v=np.array((n+1)*[v0])
for j in range(n):
k1=f(v[j],t[j])*h
k2=f(v[j]+(1/2)*k1,t[j]+(1/2)*h)*h
k3=f(v[j]+(1/2)*k2,t[j]+(1/2)*h)*h
k4=f(v[j]+k3,t[j]+h)*h
v[j+1]=v[j]+(k1+2*k2+2*k3+k4)/6
return v, t, h
def Fdet(v,t):
phi, sigma = v
H=(((lamb/4)*phi**4)/(3*mpl**2-(1/2)*sigma**2))**(1/2)
HH=-((1/2)*(sigma/H)**2)*(1/mpl**2)
return np.array([sigma,-3*(1+HH/3)*sigma-lamb*phi**3/(H**2)])