Solution (source code)

= Solution

The equation of motion is
$$
m\ddot x=-V'(x).
$$
Multiplication by $\dot x$ gives
$$
\frac d{dt}\left(\frac12m\dot x^2+V(x)\right)=\dot x(m\ddot x+V'(x))=0,
$$
so the <mechanical energy> $E=\frac12m\dot x^2+V(x)$ is conserved. On a segment where the direction of motion is fixed,
$$
\boxed{t-t_0=\pm\sqrt{\frac m2}\int_{x_0}^{x}\frac{du}{\sqrt{E-V(u)}}.}
$$