Bug introduced in 8.0 or earlier and persisting through 14.0 or later
This is known ode that DSolve
generates a wrong extra solution.
Been there since 2010. I do not know if this was posted about here before or not. If it was, will delete this question. I did a search here and did not find one.
DSolve
gives two solutions to this ode. But only one is correct.
I've been trying to guess how the wrong solution could have been generated and at what point.
ClearAll[y,x]
DSolve[{y'[x]==2*y[x]* (x *Sqrt[y[x]]-1),y[0]==1},y[x],x]
The first solution above should not be there. To find how DSolve
came up with this, I solved this by hand to see where it could have gone wrong.
It seems this first solution could be generated if DSolve
evaluated or replaced $\sqrt 1$ to $\pm 1$ near the end, when finding the constant of integration. But this would be very strange thing to do. As we always take the positive root (principal root) of square root of a positive number.
Here is my solution
Solve
\begin{gather*}
\boxed{y^{\prime}-2 y \left(x \sqrt{y}-1\right)=0}
\end{gather*}
With initial conditions
$$
y \left(0\right) = 1
$$
This is a Bernoulli ODE.
\begin{align*} y' = -2 y +2 x y^{\frac{3}{2}} \tag{1} \end{align*} Dividing both sides of ODE (1) by $y^{\frac{3}{2}}$ gives \begin{align*} y'\frac{1}{y^{\frac{3}{2}}} &= -\frac{2}{\sqrt{y}} +2 x \tag{4} \end{align*} Let \begin{align*} w &=\frac{1}{\sqrt{y}} \tag{5} \end{align*} Taking derivative of equation (5) w.r.t $x$ gives \begin{align*} w' &= -\frac{1}{2 y^{\frac{3}{2}}}y' \tag{6} \end{align*} Substituting equations (5) and (6) into equation (4) gives \begin{align*} -2 w^{\prime}\left(x \right)&= -2 w \left(x \right)+2 x\\ w' &= w -x \tag{7} \end{align*} The above now is a linear ODE in $w \left(x \right)$. The integrating factor $\mu$ is \begin{align*} \mu &= {\mathrm e}^{-\int d x}\\ &= {\mathrm e}^{-x} \end{align*} Eq (7) becomes \begin{align*} \frac{\mathop{\mathrm{d}}}{ \mathop{\mathrm{d}x}}\left( \mu w\right) &= \left(\mu \right) \left(-x\right) \\ \frac{\mathop{\mathrm{d}}}{ \mathop{\mathrm{d}x}} \left(w \,{\mathrm e}^{-x}\right) &= -x {\mathrm e}^{-x} \end{align*} Integrating gives \begin{align*} w \,{\mathrm e}^{-x} &= \int{- x {\mathrm e}^{-x} \,\mathrm{d} x}\\ w \,{\mathrm e}^{-x} &= \left(x +1\right) {\mathrm e}^{-x} + c_1 \end{align*} Dividing both sides by the integrating factor $\mu={\mathrm e}^{-x}$ results in \begin{align*} w &= x +1+c_{1} {\mathrm e}^{x} \end{align*}
Replacing $w$ in the above by $\frac{1}{\sqrt{y}}$ using equation (5) gives the final solution.
$$
\frac{1}{\sqrt{y}} = x +1+c_{1} {\mathrm e}^{x}
$$
Initial conditions are now used to solve for $c_{1}$.
Substituting $x=0$ and $y=1$ in the above solution gives an equation to solve for the constant of integration. This is by taking $\sqrt{1}=1$. This gives \begin{align*} c_{1} = 0 \end{align*} Substituting $c_{1}$ found above in the general solution found above gives $$ \frac{1}{\sqrt{y}} = x +1 $$ Solving for $y \left(x \right)$ from the $\frac{1}{\sqrt{y \left(x \right)}} = x +1$ gives the following solution \begin{align*} y \left(x \right) &= \frac{1}{\left(x +1\right)^{2}} \end{align*}
Now, if DSolve
also used $\sqrt{1}=-1$, then $c_1=-2$ and this would result in that extra first solution DSolve
gave.
Question is: Do you think this is what happened? Or do you see another path that could have caused DSolve
to generate the first solution?
V 13.0 on windows 10
Dsolve
ing $y' = 2 \sqrt{y}$ -- omits the trivial solution, gives half-wrong solutions (note that the derivative is always nonnegative, but $y = (x-C)^2$ is decreasing half the time). The WA version (further wrong by omitting the arbitrarily horizontally translated solutions) is discussed here. $\endgroup$