Curious solutions of x' = Sqrt(x), x(0)=4

Consider the solution of $x'=\sqrt{x}$, $x(0)=4$ using DSolve.

DSolve[{x'[t] == Sqrt[x[t]], x[0] == 4}, x[t], t]

(*{{x[t] -> 1/4 (16 - 8 t + t^2)}, {x[t] ->
1/4 (16 + 8 t + t^2)}}*)


I don't see how $x(t)=\frac14(16-8t+t^2)$, or equivalently, $x(t)=\frac14(4-t)^2$, can be a solution. Consider the following code and graphical output.

vp = VectorPlot[{1, Sqrt[x]}, {t, -10, 10}, {x, 0, 10},
VectorStyle -> {GrayLevel[0.8]},
VectorScale -> {0.045, 0.9, None}];
plt = Plot[1/4 (4 - t)^2, {t, -10, 10}];
Show[vp, plt, GridLines -> Automatic]


Clearly, not a solution. This can also be verified by checking algebraically. If $x(t)=\frac14(4-t)^2$, then $$x'(t)=\frac12(t-4),$$ and \begin{align*} \sqrt{x}&=\sqrt{\frac14(4-t)^2}\\ &=\frac{|4-t|}{2}\\ &=\frac12(t-4), \end{align*} only if \begin{align*} 4-t&\le 0\\ -t&\le -4\\ t&\ge 4, \end{align*} which agrees with the image above. Hence, even though the initial condition $x(0)=4$ is satisfied, the answer only satisfies the original ODE if $t\ge 4$.

So, why does DSolve produce this answer?

• Interesting. Note also that the second solution doesn't work for $t \leq -4$, by much the same logic. It appears that Mathematica is integrating through the point $x = 0$ even when it shouldn't. – Michael Seifert May 12 '15 at 17:22
• @MichaelSeifert. True, but it does satisfy the differential equation for $t\ge -4$ and it satisfies the initial condition $x(0)=4$. So that one works on the interval of existence $(-\infty,-4]$. – David May 12 '15 at 17:52
• I suspect that DSolve is "rationalizing" the differential equation as an early step, turning it into an equation of first order but second degree. The result of this process would be $(x')^2 = x$, and both of the solutions given above satisfy this equation with the given initial conditions. Usually Mathematica is hyper-sensitive about square roots and absolute values, though, so it's still a little puzzling. – Michael Seifert May 12 '15 at 18:57
• You are forgetting that there two square roots for a positive number. You must change the sign of the square root when x[t] crosses the branch cut at t = 4. Further you are not drawing the vector field correctly. See my answer for details. – m_goldberg May 12 '15 at 19:59
• DSolve[{x'[t] == Surd[x[t], 2], x[0] == 4}, x[t], t] – chuy May 12 '15 at 20:09

In a sense, the returned solutions are valid, but only over a restricted domain. We can determine the domain for each solution with something like

Reduce[ode && -Infinity < t < Infinity /. sol, t]


We can join the domain with the corresponding solution via ConditionExpression.

ode = {x'[t] == Sqrt[x[t]], x[0] == 4};
dsol = DSolve[ode, x, t];


In the form of x -> function:

intermediate = {x -> Function @@ {t,
ConditionalExpression[x[t] /. #,
Reduce[And @@ ode && -Infinity < t < Infinity /. #, t]]}} & /@ dsol
(*
{{x -> Function[t, ConditionalExpression[1/4 (16 - 8 t + t^2), t >= 4]]},
{x -> Function[t, ConditionalExpression[1/4 (16 + 8 t + t^2), t >= -4]]}}
*)


Now, these are solutions, but only one is defined at t == 0. We can select the correct one.

newsols = Select[intermediate, (x[0] /. #) =!= Undefined &]
(*
{{x -> Function[t, ConditionalExpression[1/4 (16 + 8 t + t^2), t >= -4]]}}
*)


Both of the dsol solutions are solutions to the rationalized ODE x'[t]^2 == x[t], and almost certainly that is from whence the extraneous solution arises.