# solving first order nonlinear ode $\frac{dx}{a(b-x)^c} = dt$

I haven't taken ODEs, so apologies if this is a trivial question. I'm trying to understand a biology paper where there's an equation

$$\dot{n} = \frac{1}{\tau} \left(\frac{n^{max}-n}{n^{max}-1}\right)^\gamma (\lambda^{e}-\lambda^{o})$$

I can rewrite this as

$$\dot{n} = \frac{(\lambda^{e}-\lambda^{o})}{\tau(n^{max}-1)^\gamma} \left(n^{max}-n\right)^\gamma$$

So if I let $$x = n$$, $$a = \frac{(\lambda^{e}-\lambda^{o})}{\tau(n^{max}-1)^\gamma}$$, $$b=n^{max}$$, $$c = \gamma$$, then I have $$x' = a(b-x)^c$$

I want to solve this for $$x(t)$$. First, I recognized that

$$\frac{dx}{a(b-x)^c} = dt$$

I wanted to integrate both sides, so I tried

$$\int_{1}^{x(t)} \frac{1}{a(b-z)^c} dz = k_1 + t$$

As an example, I decided to let $$a = 2, b = 3, c = 0.5$$. This gave me,

\begin{align*} \int_{1}^{x(t)} \frac{1}{2(3-z)^{0.5}}dz &= k_1 + t\\ \sqrt{2}-\sqrt{3-x}&=k_1 + t\\ x(t) &= -k_1^2 -2k_1t+2\sqrt{2}(k_1+t)-t^2+1\\ \end{align*}

and for $$k_1=1,t=2$$, then $$x = 6\sqrt{2}-8$$

However, I plugged

solve[x' = 2(3-x)^0.5]


into Wolfram alpha and got

$$x(t) = 3-\frac{1}{4}(k_1+2t)^2$$

and for $$k_1=1,t=2$$, then $$x=-3.25$$.

Where am I going wrong?

Your integral on the left side is different than the original one in that it's a definite one, so there should be no constant, e.g., $$k_1$$ on the right side, plus your upper limit should be a constant, not $$x(t)$$ as you have. Finally, I'm not sure why you're using a lower bound of $$1$$.

Instead, you would get, using $$a = 2$$, $$b = 3$$ and $$c = 0.5$$,

\begin{aligned} \frac{dx}{2(3-x)^{0.5}} & = dt \\ -(3 - x)^{0.5} & = t + \frac{k_1}{2} \\ -(3 - x)^{0.5} & = \frac{1}{2}\left(k_1 + 2t\right) \\ 3 - x & = \frac{1}{4}\left(k_1 + 2t\right)^2 \\ x(t) & = 3 - \frac{1}{4}\left(k_1 + 2t\right)^2 \end{aligned}\tag{1}\label{eq1A}

I don't know why WolframAlpha effectively used $$\frac{k_1}{2}$$ instead of $$k_1$$ on the right side, but I guess it has to do with the particular solution algorithm they use. Anyway, now you can substitute your boundary values to get $$k_1$$, and then use this with the $$t$$ value you want to to get the corresponding value of $$x(t)$$.

There are several things to clear up. Let's start at $$\frac{dx}{2(3-x)^{0.5}}=dt$$. Say you don't know anything about the domain or initial condition, etc. Then it's true that if you find the antiderivatives $$F$$ and $$G$$ (that correspond to the additional constant being $$0$$ on both sides), you get $$F(x)+C_1=G(t)+C_2$$. Since $$C_1$$ and $$C_2$$ are arbitrary, you can throw $$C_1$$ to the other side and call a new arbitrary constant $$k_1=C_2-C_1$$. Then you have $$F(x)=G(t)+k_1$$. This is the standard convention to solving these problems.

Now where's the confusion? The problem is that in all of these steps, arbitrary constants pop out. Depending on how you format and "absorb" the constants (like I did with $$C_1$$ and $$C_2$$ above, the answer is going to look different, despite being the same.

To see how Wolfram did it, take the equation $$\frac{dx}{(3-x)^{0.5}}=2dt$$. Then following what I wrote above, we conclude $$F(x)=-2\sqrt{3-x}$$ and $$G(t)=2t$$. Hence \begin{align} -2\sqrt{3-x}&=2t+k_1 \qquad \text{(squaring)} \\ 4(3-x)&=(2t+k_1)^2. \end{align} After rearranging, it is clear that $$x=3-\frac{1}{4}(2t+k_1)^2$$. One reason why your answer is strange is that based on the bounds of your $$x$$ integral, it seems like you are assuming $$x(0)=1$$. If this is the case, there's no need to even worry about arbitrary constants since the point is to use the initial condition to solve for it.

One final point. If instead you took $$\frac{dx}{2(3-x)^{0.5}}=dt$$ and said $$-\sqrt{3-x}=t+k_1$$, you could square everything and solve and get $$x=3-(t+k_1)^2.$$ This appears different from the answer above, but it's really not since we can say $$x=3-(\frac{2}{2}(t+k_1))^2=3-\frac{1}{4}(2t+2k_1).$$ Since $$k_1$$ is arbitrary, it doesn't matter if you write $$k_1$$ or $$2k_1$$. This explains the discrepancy.

My advice: If you know $$x(0)=1$$, don't even bother with $$k_1$$. Just set it equal to $$0$$. This is consistent since if you did not do this, you would find that plugging in $$t=0$$ to the solution (yours, not Wolfram's) yields $$k_1=0$$.