I have three related questions (labeled Q1, Q2, and Q3 below):
Exercise A. At $x=0$, $y=2$. Also, $\frac{\mathrm{d}y}{\mathrm{d}x}=y\left(1-y\right)$. Find $y$ in terms of $x$.
Attempt I
Rearrange: $\frac{\mathrm{d}x}{\mathrm{d}y}=\frac{1}{y\left(1-y\right)}$
Integrate: $x=\int\frac{1}{y\left(1-y\right)}\mathrm{d}y=\int\frac{1}{y}+\frac{1}{1-y}\mathrm{d}y=\ln\left|y\right|-\ln\left|1-y\right|+C_{1}=\ln\left|\frac{y}{1-y}\right|+C_{1}$
Rearrange: $\ln\left|\frac{y}{1-y}\right|=x-C_{1}$ or $\left|\frac{y}{1-y}\right|=\mathrm{e}^{x-C_{1}}\overset{1}{=}C_{2}\mathrm{e}^{x}$ (set $C_{2}=\mathrm{e}^{-C_{1}}$).
Given $\left(x,y\right)=\left(0,2\right)$, $C_{2}=2$. Now $\left|\frac{y}{1-y}\right|=2e^{x}$.
- If $0\leq y<1$, then $\left|\frac{y}{1-y}\right|=\frac{y}{1-y}=2\mathrm{e}^{x}$ or $\frac{1-y}{y}=\frac{1}{2\mathrm{e}^{x}}$ or $\frac{1}{y}=\frac{1+2\mathrm{e}^{x}}{2\mathrm{e}^{x}}$ or $y\overset{2}{=}\frac{2\mathrm{e}^{x}}{1+2\mathrm{e}^{x}}$. But $\left(x,y\right)=\left(0,2\right)$ does not satisfy $\overset{2}{=}$. And so,
Q1: Here we can simply discard $\overset{2}{=}$? (It's true that $\left(x,y\right)=\left(0,2\right)$ does not satisfy $\overset{2}{=}$, but how do I know that $\overset{2}{=}$ is now completely irrelevant to my answer?)
- If instead $y<0$ or $y>1$, then $\left|\frac{y}{1-y}\right|=\frac{y}{y-1}=2\mathrm{e}^{x}$ or $\frac{y-1}{y}=\frac{1}{2\mathrm{e}^{x}}$ or $\frac{-1}{y}=\frac{1-2\mathrm{e}^{x}}{2\mathrm{e}^{x}}$ or $y\overset{3}{=}\frac{2\mathrm{e}^{x}}{2\mathrm{e}^{x}-1}$. We verify that $\left(x,y\right)=\left(0,2\right)$ satisfies $\overset{3}{=}$. And so,
Q2: Here we may conclude $\overset{3}{=}$ is our answer? (Again, related to Q1, how do I know that $\overset{2}{=}$ is completely irrelevant?)
Attempt II
Rewrite $\overset{1}{=}$ as $\frac{y}{1-y}\overset{4}{=}\pm C_{2}\mathrm{e}^{x}=C_{3}\mathrm{e}^{x}$ (set $C_{3}\overset{5}{=}\pm C_{2}$). Given $\left(x,y\right)=\left(0,2\right)$, $C_{3}=-2$. So, $\frac{y}{1-y}=-2\mathrm{e}^{x}$ or $y\overset{3}{=}\frac{2\mathrm{e}^{x}}{2\mathrm{e}^{x}-1}$. So, same as Attempt 1, we conclude $\overset{3}{=}$ is our answer. This seems to work, but
Q3: Is the procedure given in $\overset{4}{=}$ and $\overset{5}{=}$ legitimate? How is it that we seem to be able to get rid of the $\pm$ simply by making a substitution?
Consider Example B: Say instead I'm given the equation $q^{2}=p+1$ and that at $p=0$, $q=1$. I take square roots: $q=\pm\sqrt{p+1}$. Now similarly, can I legitimately write $q=C\sqrt{p+1}$ (where I've set $C=\pm1$)? Given $\left(p,q\right)=\left(0,1\right)$, $C=1$ and so I conclude $q=\sqrt{p+1}$? This doesn't seem legit to me. (Is there maybe some difference between Example B and Exercise A?)
Related: Question regarding usage of absolute value within natural log in solution of differential equation Removing absolute value signs when solving differential equations and constant solutions
Actually, all your questions are back to one question: existence and uniqueness for the solution of differential equation. Let's see it step by step.
Note this is an autonomous differential equation, and you can immediately find two trivial solutions, $y=0$ and $y=1$, but none of them satisify initial conditions.
After you wrote it as $$\frac{dx}{dy}=\frac{1}{y(1-y)}\tag{1}$$
you can treat $y$ as independent variable and $x=x(y)$. Hence, $y=0, y=1$ become singularities for eq.(1). The entire $y$-axis is divided into three regions: $$I_1=(-\infty, 0)\cup I_2=(0, 1)\cup I_3=(1, \infty)$$ By the Existence and Uniqueness theorem, the solution is uniquely determined on the interval where your initial condition belongs to, and before the solution (curve) hits the nearest singularity. You can find more details on this existence and uniqueness with my answer on another example here.
For this problem, the initial condition is at $(0, 2)$, and $2>1$, which means your solution is uniquely determined on the inverval $I_3$, namely, $y\in(1, \infty)$, and before it hits the nearest singularity, namely, $y\neq 1$.
After you integrate and reach this step, since we have already known $y\in(1, \infty)$, you can safely remove the absolute value, hence
$$\ln\left(\frac{y}{y-1}\right)=x-C_{1}\Rightarrow \frac{y}{y-1}=C_2 e^x$$
Plug in initial condition $(0,2)$, you get $C_2=2$. The final step is to determine the domain of $x$, by using the domain of $y$, which gives:
$$\frac{y}{y-1}=2 e^x,~~~y\in(1,\infty)\Leftrightarrow x\in (-\ln2, \infty)$$
The solution is:
$$\boxed{y=\frac{2 e^x}{2e^x-1},~~~x\in (-\ln2, \infty)}$$