I have the following differential equation for logistic growth as an initial value problem:
$$\dot x(t) = \lambda[K-x(t)]x(t),\quad x(t_0)=x_0$$
I also was given the analytical solution to it and need to show how to find it. I am allowed to use Maxima to solve it and have gotten quite far, but I am missing the final steps and need help.
The solution I want to reach is $$x(t) = K \left[1+ \left(\frac{K}{x_0}-1\right)e^{-\lambda K(t-t_0)}\right]^{-1}$$
Let me lay out my current progress:
Solving the equation for $\lambda$ gives
$$\lambda =-\frac{\frac{d}{d t} x}{{{\operatorname{x}(t)}^{2}}-K \operatorname{x}(t)}$$
Substitution and integration using Maxima eq2: integrate(1/((K-x)*x),x) = integrate(λ,t);
$$\frac{\log{(x)}}{K}-\frac{\log{\left( x-K\right) }}{K}=t \lambda$$
Adding integration parameter $C$ to the right-hand side and solving for $x$ using Maxima
eq4: log(x)/K - log(x-K)/K = t*λ+C;
solve(eq4,[x]);
$$\frac{\log{(x)}}{K}-\frac{\log{\left( x-K\right) }}{K}=t \lambda +C$$ $$\log{(x)}=K t \lambda +\log{\left( x-K\right) }+C K$$
Using $e$ on both sides with our initial value $x(t_0) = x_0$, solving for C we get
$${x_0}=\left( {x_0}-K\right) {{e}^{K\, {t_0} \lambda +C K}}$$ $$C=-\frac{K\, {t_0} \lambda -\log{\left( -\frac{{x_0}}{K-{x_0}}\right) }}{K}$$
We subsitute C back into eq4 an get
$$\frac{\log{(x)}}{K}-\frac{\log{\left( x-K\right) }}{K}=t \lambda -\frac{K\, {t_0} \lambda -\log{\left( -\frac{{x_0}}{K-{x_0}}\right) }}{K}$$
Solving for $x$ and using $e$ on both sides we reach
$$\log{(x)}=K\, \left( t \lambda -{t_0} \lambda \right) +\log{\left( \frac{{x_0}}{{x_0}-K}\right) }+\log{\left( x-K\right) }$$
$$x=\frac{\left( x-K\right) \, {x_0} {{e}^{K\, \left( t \lambda -{t_0} \lambda \right) }}}{{x_0}-K}$$
which is already very close to the solution I am looking for.
However, comparing this with Maxima's ìs(equal(...)) led to the result unknown.
Now I have difficulties finding the last transformations, to reach the desired result. Have I done everything correctly so far or is there some issue I have overlooked? How would I proceed from here? The transformations do not seem trivial to me, to get it into the same form.
Basically, Gonçalo is correct. I have overlooked that Maxima, even when told to solve for $x$ does not completely solve it. (compare eq4 above, there still is a $\log(x-K)$ on the rhs.)
We can solve this by writing it explicitly on the lhs and manually $e$ both sides as such:
$$\frac{\log{(x)}}{K}-\frac{\log{\left( x-K\right) }}{K}=t \lambda +C$$
$$\frac{x}{x-K}={{e}^{K\, \left( t \lambda +C\right) }}$$
(Solving this in Maxima for $x$ we get $x=\frac{K\, {{e}^{K t \lambda +C K}}}{{{e}^{K t \lambda +C K}}-1}$ )
We can now use our $C$ as calculated above and substitute it back in and solve for $x$
$$\frac{x}{x-K}={{e}^{K\, \left( t \lambda -\frac{K\, {t_0} \lambda -\log{\left( -\frac{{x_0}}{K-{x_0}}\right) }}{K}\right) }}$$
$$x=\frac{K\, {x_0} {{e}^{K t \lambda -K\, {t_0} \lambda }}}{{x_0} {{e}^{K t \lambda -K\, {t_0} \lambda }}-{x_0}+K}$$
We can now factor out $x_0$ and afterwards the whole $e^{\dots}$ as follows
$$x=\frac{K\, {x_0}\, {{e}^{K t \lambda -K\, {t_0} \lambda }}} {{x_0} ({{e}^{K t \lambda -K\, {t_0} \lambda }}-{1}+\frac{K}{x_0})} $$ $$ x=\frac{K\, {{e}^{K t \lambda -K\, {t_0} \lambda }}} {{{e}^{K t \lambda -K\, {t_0} \lambda }}-{1}+\frac{K}{x_0}}$$
and
$$x=\frac{K} {1 + (\frac{K}{x_0}-1) \cdot \frac{1}{{e}^{K t \lambda -K\, {t_0} \lambda }}}$$ $$ x=\frac{K} {1 + (\frac{K}{x_0}-1) \cdot {{e}^{K t_0 \lambda -K t \lambda }}} $$ $$ x=\frac{K} {1 + (\frac{K}{x_0}-1) \cdot e^{-\lambda K(t - t_0)}}$$
We have now reached our desired result, substituting back $x(t)$
$$x(t) = K [1 + (\frac{K}{x_0} - 1)e^{-\lambda K(t - t_0)}]^{-1}$$