I'm having trouble solving this ODE:
$$\ddot x = \mu \dot x^2 - g, \space \space x(0)=x_0$$
This is the ODE that determines the equation of motion of an object with air resistance. $\mu$ is a positive constant. This is what I've done:
Let $\dot x = v$ we have $v(0) = 0$ by assumption and the equation becomes:
$$\dot v = \mu v^2 - g$$
This is a Riccati differential equation. Recall that a Riccati differential equation has the form
$$\dot x = h(t) + f(t) x + g(t)x^2$$
In our case is $h(t) = -g$, $f(t) = 0$ and $g(t) = \mu$
To solve this kind of differential equations one has to guess a solution, which in this case I found be:
$$v_p(t) = \sqrt{g \over \mu}$$
$\implies y = {1 \over {v- \sqrt{g \over n}}}$ $\implies y(0) = \sqrt{n\over g}$ to find the solution $v(t)$ one has to solve the following differential equation:
$$\dot y = -(f(t) + 2v_pg(t))y-g(t)$$
This is what I've done:
\begin{align} \dot y & = -(f(t) + 2v_pg(t))y-g(t) \\ & \dot y = -2 \sqrt{g\mu }\space y - \mu \space & (1) \end{align}
Now this is a linear inhomogeneous differential equation an the solution is given by the sum of the homogeneous solution $y_h(t)$ with the particular solution $y_p (t)$ The homogeneous solution comes from:
$$\dot y = -2 \sqrt{g\mu }\space y \implies y_h = y(0) e^{-2 \sqrt{g\mu }}$$
for the particular solution $y_p(t)$ is a little bit more complicated then to find it I substituted
$$y_p(t) = y(0)(t)e^{-2 \sqrt{g\mu }} = C_1 (t)e^{-2 \sqrt{g\mu }}$$
in the equation (1). This is what I get:
\begin{align} y_p(t)& =C_1(t)' e^{-2 \sqrt{g\mu }} -2 \sqrt{g\mu }C_1(t)e^{-2 \sqrt{g\mu }} = -2 \sqrt{g\mu }C_1(t)e^{-2 \sqrt{g\mu }} - \mu \end{align} \begin{align} \iff C_1(t)' e^{-2 \sqrt{g\mu }} & = -\mu \end{align}
$$ \iff C_1(t) = {-\mu \over {2 \sqrt{g\mu }}}e^{2 \sqrt{g\mu }}$$
summarizing we have
$$y(t) = {1 \over v - \sqrt {g \over n}} = C_1(t)e^{-2 \sqrt{g\mu }} + y_h(t)= {-\mu \over {2 \sqrt{g\mu }}}e^{2 \sqrt{g\mu }}e^{-2 \sqrt{g\mu }} + y(0) e^{-2 \sqrt{g\mu }} $$
$$= {-\mu \over {2 \sqrt{g\mu }}} + y(0) e^{-2 \sqrt{g\mu }}$$
from here I tried to solve $y = {1 \over {v- \sqrt{g \over n}}}$ with respect to $v$ and then solve the last ODE $v = \dot x$ but I think that something has gone wrong.
Is there an alternative way to solve the original ODE? Is the method I've used the only one?
As you asked for methods I decided to post an alternative. Here we use the trick of eliminating the inhomogeneity.
First, consider only the equation for $v(t)=\dot{x}(t)$,
$$\dot{v}=\mu v^2-g.$$ The inhomogeneity $-g$ prevents us from simple integration of the ODE, so let's make it disappear by defining $w(t)=v(t)-\gamma$, which leads to
$$\dot{w}=\mu w^2+2\mu\gamma w+\mu\gamma^2-g.$$ We see that the choice $\gamma=\sqrt{g/\mu}$ kills the constant term, leadig to the homogenous equation for $w$: $$\frac{dw}{dt}=\mu w^2+2\sqrt{\mu g}w,$$ which now can directly be integrated:
$$\int_{w_0}^{w(t)} \frac{dw}{\mu w^2+2\sqrt{\mu g}w}=\int_0 ^t dt.$$ This can be solved using $\int dt/(at^2+bt)=-(2/b)\text{artanh} (2at/b+1)$ (for $b>0$) which gives
$$\frac{-1}{\sqrt{\mu g}}\text{artanh}\left( \mu w+1 \right)-C=t$$ with some integration constant $C$. We can solve this for $w$ and obtain $$w(t)=\sqrt{\frac{g}{\mu}}\left( \tanh[-\sqrt{\mu g}(t+C)]-1 \right).$$ Transforming back to our original function $v$ gives $$v(t)=w(t)+\gamma=\sqrt{\frac{g}{\mu}} \tanh[-\sqrt{\mu g}(t+C)],$$ and from the initial condition $v(0)=0$ it follows that $C=0$.
Now you can integrate $v=\dot{x}$ to get the position solution using that $\int dt \tanh(t)=\ln (\cosh x)$ arriving at
where the integration constant has been chosen such that $x(0)=x_0$.