How to solve this relatively simple non-linear ODE? I'm having troubles in simplifying a differential equation to find its solutions.  Consider this ODE:
$$
    \frac{1}{r} \, \frac{d}{dr} \Bigl( \frac{r}{B} \, \frac{d B}{dr} \Bigr) = k \, B^2, \tag{1}
$$
where $k$ is just a real constant and $B(r)$ is the function to be found.  I already know one solution of this equation (it was found by guessing, trial and errors):
$$
B(r) = \frac{\beta}{1 + \lambda r^2}, \tag{2}
$$
where $\beta$ and $\lambda = k \beta^2 / 4$ are arbitrary constants.  My goal is to transform (1) into an integral so I could find back the solution (2).  I'm yet unable to find a change of variable that makes that equation solvable analyticaly.  I tried $u = 1/B$, and $B = e^{\phi(r)}$ (and few other trials).  Any idea how to solve (1)?
 A: Since the equation features only multiplication and division,
it is worth checking whether it has some kind of homogeneous continuous group of symmetries. Indeed, it is straight-forward to check that the one-parameter Lie group of transformations
\begin{align}
& r \, \mapsto \, e^{s}r\\
& B \, \mapsto \, e^{-s}B
\end{align}
leaves the equation
$$\frac{1}{r} \frac{d}{dr}\left(\frac{r}{B} \frac{dB}{dr}\right) \,=\, k\, B^2$$ invariant (unchanged) Furthermore, the quantity $$C = rB$$ is also invariant under the action of the one-parameter group of symmetries. The vector field that generates this group of transformation is
$$r\,\frac{\partial }{\partial  r} \, -\, B\,\frac{\partial }{\partial  B}$$
Now, using the invariant quantity $C$, we can construct a change of variables (a local diffeomorphism) that rectifies the latter vector field. In other words, if we define the change of variables
\begin{align}
&s = \ln(r)\\
&C = rB
\end{align}
with inverse
\begin{align}
&r = e^s\\
&B = e^{-s}\,C
\end{align}
the vector field above transforms into
$$r\,\frac{\partial }{\partial  r} \, -\, B\,\frac{\partial }{\partial  B} \, =\, \frac{\partial }{\partial s}$$ and so, in the new coordinates $s, \,C$ the original equation should be invariant under the simple translation-transformation \begin{align} &s \mapsto s + \tilde{s}\\ &C \mapsto C \end{align} which means that the transformed equation should not depend explicitly on the new $s$ variable. Indeed, since $dr = e^s ds$  we can write the equation in the new coordinates as follows:
$$\frac{1}{r} \frac{d}{dr}\left(\frac{r}{B} \frac{dB}{dr}\right) \,=\, k\, B^2$$
$$\frac{1}{e^s} \, \frac{d}{e^sds}\left(\frac{e^s}{e^{-s}\,C} \frac{d}{e^s ds}\Big(e^{-s}\,C\Big)\right) \,=\, k\, \big(e^{-s}\,C\big)^2$$
$$e^{-2s} \, \frac{d}{ds}\left(\frac{e^s}{C} \frac{d}{ds}\Big(e^{-s}\,C\Big)\right) \,=\, k\, e^{-2s}\,C^2$$
$$\frac{d}{ds}\left(\frac{e^s}{C} \frac{d}{ds}\Big(e^{-s}\,C\Big)\right) \,=\, k\, C^2$$
$$\frac{d}{ds}\left(\frac{e^s}{C} \Big(e^{-s}\,\frac{dC}{ds} - e^{-s}\,C\Big)\right) \,=\, k\, C^2$$
$$\frac{d}{ds}\left(\frac{e^s}{C} \, e^{-s}\, \Big(\frac{dC}{ds} - C\Big)\right) \,=\, k\, C^2$$
$$\frac{d}{ds}\left(\frac{1}{C}\, \Big(\frac{dC}{ds} - C\Big)\right) \,=\, k\, C^2$$
$$\frac{d}{ds}\left(\frac{1}{C}\, \frac{dC}{ds} - 1\right) \,=\, k\, C^2$$
so now it is clear that the equation in the new variables is
$$\frac{d}{ds}\left(\frac{1}{C}\, \frac{dC}{ds}\right) \,=\, k\, C^2$$ and does not depend on the variable $s$ explicitly.
The next step is to introduce the extra variable
$$P \, =\, \frac{1}{C}\, \frac{dC}{ds}$$ which turns the equation into
$$\frac{dP}{ds} \, =\, k\,C^2$$ and as a result of this substitution, we obtain the following system of differential equations
\begin{align}
&\frac{dC}{ds} \, =\, C \, P\\
&\\
&\frac{dP}{ds} \, =\, k\,C^2
\end{align} We can try to find a first integral of the latter system as follows
\begin{align}
&\frac{dP}{dC} \, =\, \frac{k\,C^2}{C\,P} 
\end{align}
\begin{align}
&\frac{dP}{dC} \, =\, \frac{k\,C}{P}\\
\end{align}
$$P\,dP \, =\, k\,C \,dC $$
so after integrating both sides
$$P^2 \,=\, k\,C^2 \, +\, b$$
where $b$ is an arbitrary constant. Substituting back $$P \,=\, \frac{1}{C} \, \frac{dC}{ds}$$ we obtain the separable, integrable, differential equation
$$\left(\frac{1}{C}\,\frac{dC}{ds}\right)^2 \, =\, k\,C^2 \, +\, b$$
$$\frac{1}{C}\,\frac{dC}{ds}\, =\, \pm \sqrt{\,k\,C^2 \, +\, b\,}$$
$$\frac{dC}{ds}\, =\, \pm\, C\,\sqrt{\,k\,C^2 \, +\, b\,}$$
The solution to the latter equation
can be obtain by integrating
$$\pm\int \, \frac{dC}{C\,\sqrt{\,k\,C^2 \, +\, b\,}} \, =\, \int ds$$
and, consequently, it can be written in implicit form as follows
$$\mp\,\frac{1}{\sqrt{b}}\, \tanh^{-1}\left(\sqrt{\,1 \, + \,\frac{k}{b} \,C^2\,}\right) \, =\, s - a$$
where $a$ is another arbitrary constant. Rewrite it
$$\sqrt{\,1 \, + \,\frac{k}{b} \,C^2\,} \, =\,\tanh\Big( \mp \sqrt{b}\,(s - a)\,\Big)$$
$$1 \, + \,\frac{k}{b} \,C^2\, =\,\tanh^2\Big( \mp \sqrt{b}\,(s - a)\,\Big)$$
$$\frac{k}{b} \,C^2\, =\,\tanh^2\Big( \mp \sqrt{b}\,(s - a)\,\Big) \, -\, 1$$
and solve for $C$
$$C\, =\,\pm\,\sqrt{\,\frac{b}{k}\,\tanh^2\Big( \mp \sqrt{b}\,(s - a)\,\Big) \, -\, \frac{b}{k}\,}$$
Finally, return to the original variables
\begin{align}
&s = \ln(r)\\
&C = rB
\end{align}
which leave us with the solution
$$r\,B\, =\,\pm\,\sqrt{\,\frac{b}{k}\,\tanh^2\Big( \mp \sqrt{b}\,\big(\ln(r) - a\big)\,\Big) \, -\, \frac{b}{k}\,}$$ or explicitly
$$B\, =\,\pm\,\frac{1}{r}\sqrt{\,\frac{b}{k}\,\tanh^2\Big( \mp \sqrt{b}\,\big(\ln(r) - a\big)\,\Big) \, -\, \frac{b}{k}\,}$$
After relabling the constants $\alpha = \mp\,a \,\sqrt{b}$ and $\beta = \mp\,\sqrt{b}$, one can write the final solution as follows
$$B\, =\,\pm\,\frac{1}{r}\sqrt{\,\frac{\beta^2}{k}\,\tanh^2\Big( \beta\,\ln(r) - \alpha\,\Big) \, -\, \frac{\beta^2}{k}\,}$$
$$B\, =\,\pm\,\frac{\beta}{r}\sqrt{\,-\,\frac{1}{k \, \cosh^2\Big( \beta\,\ln(r) - \alpha\,\Big)} \,}$$
$$B\, =\,\pm\,\frac{\beta}{\sqrt{-\,k\,}\,}\,\frac{1}{\,r \, \cosh\Big( \beta\,\ln(r) - \alpha\,\Big)}$$
$$B\, =\,\pm\,\frac{\beta}{\sqrt{-\,k\,}\,}\,\frac{1}{\,r \, \cosh\Big( \beta\,\ln(r) - \alpha\,\Big)}$$
so maybe it simplifies to something like this
$$B\, =\,\,\frac{\beta}{\sqrt{-\,k\,}\,}\, \frac{2 \, \lambda \,\, r^{\beta-1}}{\,1 \, + \,  \lambda^2 \,\, r^{2\beta}}$$
where the constant $\lambda = \pm e^{-\alpha}$
