# Spurious solution to differential equation?

I have the differential equation

$$\frac{d}{dx}y = 2\sqrt{y}$$

which starts at $$x=0$$ with $$y=0$$. Wolfram Alpha says the solution is $$y=x^2$$.

I can see that when I insert this into the original equation. But I don't understand two things here.

1. Shouldn't $$y=0$$ also be a solution? But maybe that is only a Wolfram Alpha issue as it displays only one solution?

2. I don't understand how $$y=x^2$$ can "actually happen" in reality. With that I mean using a solver. Because when $$y=0$$ then also $$2\sqrt{y} = 0$$ and so $$y$$ should not ever change at all.

I can confirm this with Matlab:

y0=0;
ode45(@(t,y)(2*sqrt(y)),0:0.01:10,y0);


The code produces: So this is obviously the $$y=0$$ solution.

Is the $$y=x^2$$ some kind of spurious solution that doesn't "exist" in reality? If so how can we know when a solution is "bad"? Or if it does exist how can we get a solver to produce this output?

• $y = x^2$ is not a solution to $y' = 2\sqrt{y}$. The right hand side is by definition non-negative, which means all solutions to the equations has to be non-decreasing. Not sure why Wolfram alpha thinks that it is a solution..... Dec 28, 2021 at 16:23
• The solution of this particular problem is not unique. The function given by Wolfram Alpha solves the equation for $x \ge 0$ and the function $y = 0$ also solves it. Wolfram Alpha presumably uses separation of variables and Maple uses a numerical solver (Runge Kutta), two very different approaches which therefore don't agree on the result. Dec 28, 2021 at 16:23
• @ArcticChar $y = x^2$ is indeed one of the solutions of the ODE as Israel explained. For a positive initial condition, the solution conforms to the form $y(x) = (x - c)^2$. Though, $y(0) = 0$ is specified. Dec 28, 2021 at 16:33
• maybe Wolfram Alpha turns the equation into $y^{- 1/2} y'= 2$ and thereby (by mistake) discards the null solution. Dec 28, 2021 at 16:35
• @Hermis14 Indeed the answer below do not contradict with my comment. They restrict the solution to the interval $x\ge 0$, and it is clear that $y=x^2$ do not satisfy the ODE for any open neighborhood of $x=0$. Dec 28, 2021 at 16:37

Both $$y = x^2$$ and $$y = 0$$ are solutions for $$x \ge 0$$. $$y = \sqrt{x}$$ is not a solution for $$x < 0$$. There are "piecewise" solutions of the form $$y = \cases{0 & for x \le c\cr (x-c)^2 & for x \ge c\cr}$$

The point is that $$\sqrt{y}$$ is not Lipschitz continuous at $$0$$, so this equation does not satisfy the hypotheses of the Picard-Lindelöf Existence and Uniqueness Theorem for differential equations, and in this case the solution is not uniquely determined by an initial condition.

• Ok but how can I know what will happen "in reality"? So I am given two possible solutions because they are not unique. Do I just have to try out with a solver which solution will materialize in a simulation? Or is there some way to tell this beforehand? Dec 28, 2021 at 16:42
• @user3137490 What do you mean by in reality...? Dec 28, 2021 at 17:00
• Related to @mathcounterexamples.net 's comment: math.stackexchange.com/questions/1857355/… (see in particular comment #5 in my answer)
– Ian
Dec 28, 2021 at 17:04
• @mathcounterexamples.net Well I probably did not use the right term. What I mean with "in reality" is "in a simulation", so what a solver makes out of such equation. Although the solutions are not unique the solver outputs a unique solution namely $y=0$. Why is that? Why does the solver select exactly this solution and not the other one? How can I (in general) tell which solution will be "selected" by a solver, given an equation with multiple solutions? Dec 28, 2021 at 18:06
• Interesting that by "reality" you mean "simulation". In the other kind of reality, an actual physical or biological system that might be modelled by this differential equation, what is likely to happen is that the $y=0$ solution is highly unstable: sooner or later some random fluctuation will make $y$ slightly positive, and then it will follow one of the $y = (x-c)^2$ solutions. Dec 29, 2021 at 6:10

The equation $$y' = 2\sqrt{y}$$ is a first order, nonlinear, autonomous, constant coefficient ordinary differential equation (DE). Since it is first order and autonomous, it is susceptible to separation of variables, and WA says as much. So we obtain $$2 \sqrt{y} + C_1 = \int \frac{\mathrm{d}y}{\sqrt{y}} = \int 2 \,\mathrm{d}x = 2x + C_2$$ Assuming $$y \geq 0$$ for all $$x$$, this can be simplified to $$y = x^2 + 2Cx + C^2, y \geq 0$$. Since WA (and Mathematica) ignore constants of integration in antiderivatives, WA only writes "$$y = x^2$$". However, this hides an important property of autonomous systems: horizontally translating a solution produces another solution. We can exhibit that translatability in our solution: $$y = x^2 + 2Cx + C^2 = (x+C)^2$$ and plugging back into the original equation, $$2(x+C) = y' = 2 \sqrt{y} = 2\sqrt{(x+C)^2} = 2|x+C| \text{,}$$ which requires $$x \geq -C$$ (or, equivalently, $$y' \geq 0$$). So separation of variables has given us the family of solutions $$y = (x+C)^2, x \geq -C$$.

The original DE is nonlinear so there is no promise that finding a single family of solutions exhausts the solution space. For any homogeneous linear DE, $$y = 0$$ is a solution. This system is not homogeneous and linear, but it is autonomous and the right-hand side, $$2\sqrt{y}$$, has a zero at $$y = 0$$, so we are lucky enough to also have the additional solution $$y = 0$$.

From what we have done so far, there could well be more isolated solutions or solution families we have not found. Nonlinear DEs do not come with the existence and uniqueness guarantees that linear DEs do and we would need some sort of uniqueness to be certain we had exhausted the set of solutions.

However, what we have done shows the following: you can glue the $$y =0$$ solution on $$(-\infty, -C)$$ to the half-parabola $$(x+C)^2, x \geq -C$$ and get another solution. That is, the solution $$y = 0$$ can, at any time, suddenly jump off the $$x$$-axis along a positive half-parabola, all the while satisfying the given DE. If that seems impossible, note that the equation is satisfied by $$y' = y = 0$$ and both the $$y =0$$ solution and the half-parabola have $$y' = y = 0$$ at the gluing point. We might think that there should be some difference in higher derivatives. There is, but that doesn't change any of the analysis so far.

One result is that the initial condition $$y(0) =0$$ does not pick out a single solution. Uncountably many solutions pass through the origin, differing only in the point on the nonnegative $$x$$-axis that is the vertex of their parabola, except for the one additional solution that never leaves the $$x$$-axis. This is very different from linear DEs, where only one solution passes through a particular initial condition.

If we differentiate the given equation, we obtain $$y'' = y' y^{-1/2} \text{.}$$ The right-hand side is undefined at $$y = 0$$, so we cannot trust that this equation tells us anything about solutions to the original equation when $$y = 0$$. If we blindly substitute the original equation, we obtain $$y'' = \frac{2\sqrt{y}}{\sqrt{y}} = 2, y \neq 0$$. Of course, this is true for all the half-parabola solutions. This bad behaviour at $$y = 0$$ tells us something odd/interesting should be occurring at/near the solution $$y = 0$$ and that this oddness/interestingness is caused by the square root in $$\sqrt{y}$$.

Let's take a brief detour to discuss WolframAlpha's and Mathematica's handling of branched functions. These pieces of software are variously oblivious, silently switching branches (the WA solution you reference), or meticulously careful about branches. There are two branches of the (real) square root. The nonnegative branch is denoted "$$\sqrt{\ }$$", the square root function, and the other branch is obtained by negation. Unfortunately, these pieces of software may ignore our notation and/or switch branches without warning. If we study the DE, but switch the branch of the square root, we analyze $$y' = -2\sqrt{y} \text{.}$$ Doing so, we still get $$y = 0$$ and we get the left-halves of unit parabolas with vertices on the $$x$$-axis -- the mirror images of the families of parabolas solving the first equation. So, for this choice of square root, the general solutions are descending half-parabolas that turn into the $$y= 0$$ solution when they reach their vertices on the $$x$$-axis. Perhaps this seems less weird than the "spontaneous jumping away" from the $$x$$-axis that we got with the original equation, but both behaviours are and should seem equally weird.

But this highlights how WA's whole parabola solution has an interpretation:

• pick a positively opening unit parabola with vertex on the $$x$$-axis,
• on the left half of the parabola, pick the nonpositive branch of the square root and see that the parabola satisfies the DE,
• at the vertex of the parabola, observe that the equation is satisfied with either choice of the branch of the square root, and
• on the right half of the parabola, pick the nonnegative branch of the square root and see that the parabola continues to satisfy the DE.

This is, of course, bogus, because the notation "$$\sqrt{y}$$" denotes the square root function (which is the nonnegative branch), not "some freely changing branch of the square root". That is, once we have all agreed that "$$\sqrt{y}$$" means the nonnegative branch of the square root, then WA's $$y=x^2$$ is wrong. "In reality", only the ascending halves of these parabolas are solutions to the given DE and these solutions are obtained for "generic" initial conditions. Only special initial conditions give the $$y=0$$ solution.

This discussion of branches and $$y''$$ has ranged a bit, but it has been preparation for answering your second question.

The $$y^{-1/2}$$ in the second derivative, $$y'' = y' y^{-1/2}$$, has very rapidly changing behaviour for small, positive $$y$$, but the parabola solutions are very slowly varying there. This is a (not entirely satisfactory) signal that the DE can be stiff for certain numerical methods. It is worth pointing out that ode45 is used to "Solve nonstiff differential equations", so we should generically expect that this solver has trouble with stiffness. There are aspects of stiffness present in the transition from $$y = 0$$ to $$y > 0$$ so we should expect that this solver may be unable to reproduce that transition. (In fact, I don't expect any numerical solver to switch from the $$y=0$$ solution to a half-parabola solution unless it is so numerically noisy that it can't follow the $$y=0$$ solution, which would make it largely useless for any other problem.)

What happens "in reality" is that ode45 happily follows half-parabola solutions when given an initial condition off the $$x$$-axis. That means that for almost all initial conditions (i.e., $$y(x_0) = y_0 > 0$$ for any $$x_0 \in \Bbb{R}$$), ode45 happily follows a half-parabola solution. But for the special initial conditions on the boundary of these (i.e., $$y(x_0) = 0$$ for any $$x_0 \in \Bbb{R}$$), ode45 follows the $$y = 0$$ solution.

So, if anything, the $$y=0$$ solution is the weird solution that traps the solver. ode45 should follow the right half of a WA solution if given an initial condition that doesn't trap it in the $$y=0$$ solution.

I'm somewhat curious what ode45 does with the "other square root branch" equation when given various initial conditions above the $$x$$-axis. I expect it follows their parabolas down to the $$x$$-axis but I'm not sure if it's ever lucky enough to subsequently follow the $$y = 0$$ solution or is routinely unlucky enough to overshoot to $$y < 0$$ and abort due to non-real evaluation of $$\sqrt{y}$$.

A brief comment on nonnegativity of $$y$$ that can be used to avoid the non-real evaluation problem mentioned above. One way to enforce that $$\sqrt{y}$$ always exists is to replace $$y$$ with a function that is always nonnegative. One way is to write $$y = u^2$$, where $$u$$ is a new real-valued dependent variable. The resulting DE is $$(u^2)'=2|u|$$. Passing $$(u^2)'=2u$$ to WA, the solutions are $$u = 0$$ and $$u = x+C$$, from which $$y = 0$$ and $$y = (x+C)^2$$. Passing $$(u^2)'=-2u$$ to WA, the solutions are $$u = 0$$ and $$y = -x + C$$, from which $$y = 0$$ and $$y=(x+C)^2$$. So WA can give the exceptional $$y = 0$$ solutions as well as misrepresenting the family of half-parabola solutions. We have to be smart enough to figure out how to glue the solutions to the two equations together so that the resulting solutions satisfy the version with absolute values -- when $$u \geq 0$$, $$2|u| = 2u$$ and when $$u \leq 0$$, $$2|u| = -2u$$, effectively expressing the choice of branch of the square root as choice of sign of $$u$$.

There are other ways to enforce nonnegativity of $$y$$. For instance, set $$y = \mathrm{e}^v$$ and remember that $$y(x) = \mathrm{e}^{v(x) + 2 \pi \mathrm{i} k}$$ for any integer $$k$$. The DE becomes $$\frac{\mathrm{d}}{\mathrm{d}x} \mathrm{e}^{v(x) + 2 \pi \mathrm{i} k} = 2 \mathrm{e}^{\frac{1}{2}v(x) + \pi \mathrm{i} k}, k \in \Bbb{Z} \text{.}$$ (Here we encode the choice of branch of the square root in the expression "$$\pi \mathrm{i} k$$" by our choice of even or odd $$k$$.) The difficulty with this method is the initial condition, $$v(0) = -\infty$$, which we might recognize is ... problematic for a numerical solver. Even if a solver could somehow start at $$-\infty$$, it can only subsequently take finite steps, arriving at $$-\infty$$. So we have, perhaps, found another way to express that a $$y(x_0) = 0$$ initial condition traps solvers on the solution $$y = 0$$, but any positive initial condition, $$y(x_0) = y_0 > 0$$ yields a completely adequate numerical solution along a half-parabola.

There is no one-size-fits-all way to handle nonlinear DEs. So there is no generic answer to your question about recognizing "bad" solutions. When facing a new, unfamiliar nonlinear DE, expect that some solutions may be found by applying techniques you know, some solutions may require techniques you don't know, and you have no way to know if you've found all the solutions. The longer you work with nonlinear DEs and watch/read what others do with them, the more "techniques you know" you will have for addressing a new one. You may find that certain nonlinear equations do have complete solution techniques, e.g., Bernoulli differential equations, but you will learn that these are exceptional -- generic nonlinear DEs are complicated.

• Wow this is quite a lot to digest, thank you for the detailed answer! For info: I checked the "other" equation $y' = -2\sqrt{y}$ and $y(0)=1$ with ode45. If called without output argument, after reaching $y=0$ it displays the error: Error updating the ODEPLOT window. Solution data may have been corrupted. Argument Y cannot be complex. If called with output as [t,y]=ode45(@(t,y)(-2*sqrt(y)),0:0.01:10,1); it returns a complex solution with negative real part after reaching $y<0$. Jan 2, 2022 at 10:19
• @user3137490 : Yup. It overshoots. Exactly hitting zero using a numerical method is ... hard. Jan 2, 2022 at 18:56