I am trying to solve for y in the nonlinear homogeneous ordinary differential equation $$\frac{dy}{dt} = k(a-y)(b-y)$$. So far I have used the method shown in this question which is a separation of variables method, along with trying many U substitutions, integration factors and bernoulli's equation. I have tried solving the equation piece by piece by solving parts of it separately and adding the result, but I don't know how to treat the integration constants when combining the results.
I then went on to matlab to find the solution to the differential equation analytically by using the dsolve function with initial conditions of $y=0$ at $t=0$.
I have been able to verify my solution for the case when $a=b$ which is $y = a - \frac{a}{akt+1}$ using the boundary conditions. For that solution I simply used a variable change of $U = (a-y)^-1$ and then substituted y back at the end - this method is using bernoulli's equation.
Via the inspection of the matlab results for the general case where $0<a<b$ I have been able to see that the solution matlab gives seems to be $$y = a - \frac{b-a}{\exp(kt(b-a)+\ln(b/a))-1}$$ This is not certain as I had to use concrete numbers for the variables $a$, $b$ and $k$ and then figured out how they were featured in the answer(I made the variables prime so they would not be simplified in any of the manipulations and changed their values a couple of times to see the pattern).
However the answer I obtained, via the method which I linked to, i.e separation of variables by obtaining partial fractions, is $$y = a\frac{\exp(k(a-b)t)-1}{\exp(k(a-b)t+\ln(a/b))-1}$$ which I cannot show being the same as the answer I obtained via matlab.
In order to verify my answer I also tried taking the limit as $b$ tends to $a$, to see if I can get the same result as when $\frac{dy}{dt} = k(a-y)^2$ for the $a=b$ case, but I get a division by zero.
Any help is much appreciated!
$$\frac{dy}{dt} = k(a-y)(b-y)$$ I suppose $a \ne b$ $$\frac{dy}{(y-a)(y-b)}= k{dt} $$ use fraction decomposition : $$dy \left (\frac{1}{(a-b)(y-a)}+\frac {1}{(b-a)(y-b)} \right )= k{dt} $$ Integrate: $$\int dy \left (\frac{1}{(y-a)}-\frac {1}{(y-b)} \right )= (a-b)(kt+C) $$ $$\ln{|y-a|}-\ln{|y-b|}= (a-b)(kt+C) $$ $$\left |\frac {y-a}{y-b} \right |= e^{(a-b)(kt+C)} $$ $$y(1 -e^{(a-b)(kt+C)})=a-b e^{(a-b)(kt+C)} $$ $$y(t)=\dfrac {a-b e^{(a-b)(kt+C)} }{1 -e^{(a-b)(kt+C)}}$$
For $a =b$ $$\frac{dy}{(y-a)^2}= k{dt}$$ Substitute $u=y-a$ $$\frac{du}{u^2}= k{dt}$$ $$\frac{1}{u}= -kt+C$$ $$y-a= \frac{1}{ -kt+C}$$ $$y(t)=a+ \frac{1}{C -kt}$$