Question: The force acting on a body depends on the displacement $x(t)$ of the body from the origin.
This dependence is given by

$$ F(x) = 
\begin{cases}
F\_0 - mg, &-L < &x < 0,\\
-mg,& &x > 0.
\end{cases}
$$

where $L$ is a positive number, $F\_0 > 0$ is a constant resting force and $g$ is the gravitational acceleration of Earth.

Newton's second law gives $m\ddot{x} = F(x)$ and we impose the initial conditions $\dot{x}(0) = 0, x(0) = -L.$

How does one solve an equation like this? My main problem is that if we restrict to the branch $x > 0$ we get $x = -g\frac{t^2}{2} + At + B$. I don't know if I am allowed to plug in the boundary conditions here, but if I were to, I would get $x = -g\frac{t^2}{2} - L$. But this function is clearly always negative, so then how could this satisfy the branch $x>0$?

Any tips or clarifications?

Answer: 
$$\int\frac{\cos t}{\sin^2 t-\cos^2 t}dt$$

Use $\cos^2 t = 1-\sin^2 t$ to modify the denominator
$$\int\frac{\cos t}{2\sin^2 t-1}dt$$
Substitute $u=\sin t$, $du =\cos t \, dt$
$$\int\frac{1}{2u^2-1}du$$
Now integrate using partial fractions or otherwise.
**Other approach**

Put $ x=\sinh(t) $ with

$$dx=\cosh(t)dt$$

$$\sqrt{x^2+1}=\sqrt{\sinh^2(t)+1}=\cosh(t)$$

$$x^2-1=(\sinh^2(t)-1)$$

It becomes
$$\int \frac{dt}{(\sinh(t)+1)(\sinh(t)-1)}$$

$$=\frac 12\int (\frac{1}{\sinh(t)-1}-\frac{1}{\sinh(t)+1})dt$$