I'm reading nonlinear control systems book. The author provides this example
$$
\dot{x} = r + x^2, \quad r < 0.
$$
I would like to compute the analytical solution for the proceeding ODE. My attempt is
$$
\begin{align}
\frac{dx}{dt} &= r + x^2 \\
\frac{dx}{r+x^2} &= dt \\
\int^{x(t)}_{x_0} \frac{1}{r+x^2} dx &= \int^{t}_{t_0} d\tau \\
\frac{\tan^{-1}\left(\frac{x}{\sqrt{r}}\right)}{\sqrt{r}} \Big|^{x(t)}_{x_0} &= (t-t_0)
\end{align}
$$
Now the problem with the assumption that $r<0$, how I can handle the substitution for the left side? I need to reach the final step where $x(t)$ is solely in the left side.
Best Answer
Let us consider
$$\dot x=x^2-1$$ for convenience.
When $|x|<1$, we solve the separable equation with
$$\frac{dx}{1-x^2}=-dt$$ and
$$\text{artanh }x-\text{artanh }x_0=t_0-t,$$
i.e.
$$x=\tanh(t_0-t+\text{artanh }x_0).$$
When $|x|>1$, we solve with
$$\text{arcoth }x-\text{arcoth }x_0=t_0-t,$$
i.e.
$$x=\coth(t_0-t+\text{arcoth }x_0).$$
Notice that this solution has a vertical asymptote at $t=t_0+\text{arcoth }x_0$.
Finally, $x=\pm1$ are two valid solutions.