How to find out the critical angle of a ball separating the circle? 
Question: Let function $x:\mathbf R_+\to[0,2\pi]$ satisfying the second-order nonlinear ODE
  \begin{equation}
\left\{
\begin{aligned}
\ddot x(t) &= \sin x(t)-\cos x(t)+{\dot x(t)}^2, \quad t>0; \\
x(0) &= 0, \\
\dot x(0) &= \epsilon,
\end{aligned}\right.
\end{equation}
  where $0<\epsilon\ll1$ is a given constant. Suppose that there exist a $t_0\in\mathbf R_+$ such that ${\dot x(t_0)}^2=\cos x(t_0)$. Then how to find out the value $x(t_0)$?


Actually the question arises from the following physical phenomenon: 
A small ball starts from the north pole of a large vertical circle with a sufficient small initial velocity, and then falls outside. For simplicity, we normalize all the coefficients like the gravitational acceleration, the radius of the circle and the friction factor, and neglect the size of the ball. Then it's easy to derive that the angle of the vertical line with the line connecting ball and center of circle satisfies the kinematic equation presented above, and the time $t_0$ is exactly the moment that the ball separates from the circle with critical angle $x(t_0)$.

If the friction is not involved, then the equation of the angle degenerates into
$$\ddot x = \sin x,$$
and the question can be trivially solved by applying the first integral in the theory of ODEs.
But how to solve the case that the friction is involved? That is, how to solve the general question described above analytically? The key difficulty is that the ODE in Question seems not to possess a first integral. I have no idea then...
Any comments or hints will be appreciated. TIA!
 A: Be carefull the derivative here is taken according to the variable t
$$ y''(t)=\sin(y)-\cos(y)+(y')^2$$
Substitutte $p=y'=\frac {dy}{dt}$ and $p'=\frac {dp}{dy}$
From now the derivative is taken according to y:
$$ p' p =\sin(y)-\cos(y)+p^2$$
$$\frac 12 (p^2)' =\sin(y)-\cos(y)+p^2$$
Substitute $h=p^2$
$$ h' -2h=2(\sin(y)-\cos(y))$$
Which is simple to solve. $e^{-2y}$ as an integrating factor:
$$ (he^{-2y})'=2e^{-2y}(\sin(y)-\cos(y))$$
Just integrate now
 $$ he^{-2y}=2\int e^{-2y}(\sin(y)-\cos(y))dy$$
 $$ h(y)=2e^{2y}\int e^{-2y}(\sin(y)-\cos(y))dy$$
 $$ p^2=2e^{2y}\int e^{-2y}(\sin(y)-\cos(y))dy$$
$$.......$$
Evaluate the integral then substitute back $p=\frac {dy}{dt}$

Old solution 
$$p' p =\sin(y)-\cos(y)+p^2$$
Divide by $p^3 ( \ne 0)$
$$ \frac {p'}{p^2} =\frac {\sin(y)-\cos(y)} {p^3}+ \frac 1 p$$
$$- \left(\frac {1}{p}\right)' =\frac {\sin(y)-\cos(y)} {p^3}+ \frac 1 p$$
Substitute $g= \dfrac 1p$
$$ -g' =({\sin(y)-\cos(y)} ){g^3}+g$$
$$ \boxed {g'(y)+g(y) =(\cos(y) -\sin(y)) {g^3(y)}}$$
Bernoulli's equation. 
