what am I doing wrong with this ODE? I have an ODE $$\dot x=ax-x^2$$
What is wrong with my solution?
Substitute $z=kx^{-1}$ gives
$$-\frac k {z^2}\dot z=\frac {ak}{z} -\frac {k^2}{z^2}$$
i.e. 
$$\dot z =-a\left(z-\frac k a\right)$$
separation of variables gives
$$\ln\left(z-\frac k a\right)=-at +c$$
remove logarithm:
$$z-\frac k a =e^{-at +c}$$
substiute $x$ back in
$$\frac k x - \frac k a=e^{-at +c}$$
$$x=\frac  k {e^{-at +c}+\frac k a}$$
This cannot possibly be correct, since $k$ should not be in the final solution. What am I doing wrong?
 A: The equation
$$ \dot x=ax-x^2 $$
is a Bernoulli equation which can be turned into a linear first order equation by an appropriate substitution. First, rewrite the equation in the form
$$ \dot x-ax=-x^2 $$
Then multiply both sides by $x^{-2}$ to obtain the equation
$$ x^{-2}\dot x-ax^{-1}=-1\tag{1} $$
This equation motivates the substitution $z=x^{-1}$, and this substitution also gives us the useful fact that
$$ \dot z=-x^{-2}\dot x $$
This differs from the first term of equation $(1)$ only in sign, so we multiply equation $(1)$ by $-1$ to obtain
$$ -x^{-2}\dot x+ax^{-1}=1 $$
which can be rewritten in terms of $z$ to give the linear first order equation
$$ \dot z+az=1 \tag{2}$$
The integrating factor of equation $(2)$ is $\mu=\exp\left(\int a\,dt\right)=e^{at}$ giving
$$ \dot ze^{at}+aze^{at}=e^{at} \tag{3}$$
But the left hand side of equation $(3)$ is just the derivative of $ze^{at}$ so we can rewrite equation $(3)$ as
$$ \left(ze^{at}\right)^\prime=e^{at}\tag{4} $$
Integrating both sides of equation $(4)$ gives the result
$$ ze^{at}=\frac{1}{a}\left(e^{at}+c\right)\tag{5} $$
Therefore
\begin{eqnarray}
z&=&\frac{1}{a}\left(1+ce^{-at}\right)\\
x^{-1}&=&\frac{1}{a}\left(1+ce^{-at}\right)\\
x&=&\frac{a}{1+ce^{-at}}
\end{eqnarray}
A: Your solution is fine, mostly. Except for I can't help but wonder, just as @HansLundmark asked in the comments: what's the point of introducing this extra constant $k$? It doesn't do anything useful. The solution will work just as fine (if not better) if you simply substitute $z=x^{-1}$. But now that you've introduced it, it became part of your equation, and so it shouldn't surprise you that it's in the answer too.
One little issue is with your integration after separation of variables. The left-hand side should be $\color{blue}{\ln\left|z-\frac{k}{a}\right|}$ rather than $\color{red}{\ln\left(z-\frac{k}{a}\right)}$. It's important because then we get
$$\left|z-\frac{k}{a}\right|=e^{-at+c} \implies z-\frac{k}{a}=\pm e^{-at+c}=\pm e^ce^{-at}=C_1e^{-at},$$
where $C_1$ is a new arbitrary constant, which can be any real number. (Technically speaking, $C_1=\pm e^c$ runs through all nonzero reals; but we can additionally observe that $C_1=0$ corresponds to a stationary solution.) In your solution you essentially ended up with $e^c$ as that constant, losing half of its possible values. After making this correction, we end up with the answer in the form
$$x=\frac{k}{\pm e^{-at+c}+\frac{k}{a}}=\frac{k}{C_1e^{-at}+\frac{k}{a}}.$$
Now, here's how you can that your solution (especially after being corrected) is in fact independent of $k$ and coincides with the solution obtained by any other method. Let's divide both the numerator and denominator by $k$:
$$x=\frac{k}{C_1e^{-at}+\frac{k}{a}}=\frac{1}{\frac{C_1}{k}e^{-at}+\frac{1}{a}}=\frac{1}{C_2e^{-at}+\frac{1}{a}},$$
where $C_2$ is yet another constant. So your answer is in fact independent of $k$, except for a different choice of the arbitrary constant. To simplify it a little further, we can also multiply both the numerator and denominator by $a$:
$$x=\frac{1}{C_2e^{-at}+\frac{1}{a}}=\frac{a}{aC_2e^{-at}+1}=\frac{a}{C_3e^{-at}+1},$$
where $C_3$ is …
