<s>[INST] Solving this Bernoulli ODE I have the following nonlinear ODE which I am trying to solve. 
$$
\begin{align}
\frac{dr}{dt} &= ar(1-r) + b (1-r)^2\\
&= (b-2a) r^2 + (a+2b)r + b 
\end{align}
$$
We then let $r = y + z$. 
$$
\begin{align}
y ' 
&= (b-2a) (y-z)^2 + (a+2b)(y-z) + b\\
&= (b-2a) y^2 + y(2z(b-2a)+(a+2b))+((b-2a)z^2+(a+2b)z + b)
\end{align}
$$
We then determine $z$ such that $(b-2a)z^2+(a+2b)z + b=0$, generating the Bernoulli equation:
$$
y'-sy=(b-2a)y^2\qquad \text{where}\qquad s=\pm\sqrt{a^2+12ab}. 
$$
Let $h = y^{-1}$ then $h' = -y^{-2}y'$ or $-h' = y^{-2}y'$ before dividing the Bernoulli equation by $y^2$. 
$$
\begin{align}
y^{-2} y' + sy^{-1} &= (b-2a)\\
-h' + s h &= (b-2a)\\
h' - s h &= (2a-b)
\end{align}
$$
The integrating factor $\eta(t) = e^{\int dt (-s)} =  e^{-st}$
$$
 e^{-s t} h' - e^{-s t} sh =  e^{-s t}(2a -b)\\
 \frac{d}{dt}(e^{-st}h) = e^{-s t}(2a -b)
$$
We then integrate the R.H.S by parts with $u = 2a-b$, $dv = e^{-st}dt$, $v = -\frac 1 s e^{-st}$, $du = 0$.
$$
\int e^{-s t}(2a -b) dt = -\frac 1 s (2a-b)e^{-st}+c
$$
To give,
$$
e^{-st}h =  -\frac 1 s (2a-b)e^{-st}+c
$$
Divide this by $e^{-st}$. 
$$
h = - \frac {(2a-b)}{s} + ce^{st}
$$
We then simply insert the substitution back in $h=y^{-1}$.
$$
y = \frac{s}{-(2a-b) - cse^{st}}
$$
We can then reconstruct $r$ using $y$ and $z$.
$$
r = \frac{s}{-(2a-b) - cse^{st}} + \frac{-a-2b \pm s}{2(b-2a)}
$$
Any help is appreciated and the final solution is:
$$
r(t) = \frac{e^{at} -1}{ e^{at} - 1 + (a/b)}
$$
 [/INST] if $$r=y+z$$ it must be
$$y'=(b-2a)(y+z)^2+(a+2b)(y+z)+b$$
</s>