# Why does DSolve fail in this first order differential equation?

I am trying to solve the following first order differential equation: $$g'(R)=-2 \sqrt{R^2-g(R)}+2 R$$

By direct substitution it can be verified that an obvious solution is $$g(R)=R^2$$

ode=2R-2Sqrt[R^2-g[R]]-Derivative[1][g][R]
g[R_]:=R^2
ode==0


Giving True as expected.

However, using DSolve (Mathematica 11.2 for Windows 10):

Clear[g]
DSolve[ode==0, g[R], R]//FullSimplify//Expand


we find

{{g[R]->-1+E^(2 C[1])-2 R-2 Sqrt[-E^(2 C[1]) (1+R)^2]},
{g[R]->-1+E^(2 C[1])-2 R+2 Sqrt[-E^(2 C[1]) (1+R)^2]}}


As seen, Mathematica completely missed the correct solution!

Edit 1: For more details on the mathematics aspects of the solution (and the two branches of the solution), see my post at the Mathematics stack.

Edit 2: Adding initial conditions like $$g(0)=0$$ or $$g(1)=1$$, as suggested in the comments, unfortunately doesn't help.

Edit 3: Just for future reference I add the way I found to solve the ode and recover the $$R^2$$ solution. To do that define a new function $$y(R)$$ that should be zero when $$g(R)=R^2$$, in the following manner

g[R_] := R^2 (1 - y[R]^2)
ode1 = ode // FullSimplify // PowerExpand // FullSimplify;
DSolve[ode1 == 0, y[R], R] // Expand


which gives

{{y[R] -> 0}, {y[R] -> 1 + C[1]/R}}


The solution $$y[R] \rightarrow 0$$ implies $$g(R)=R^2$$ as expected.

After massaging the ODE as shown above, I can get Mathematica to give the correct solution, however I still don't understand why it failed in the first place.

So, my question is, why did DSolve fail in this simple example?

• If you integrating equation ,then where is integrating constant C[1] ? Feb 5, 2020 at 17:27
• The fact that you're getting two solutions here makes me wonder whether Mathematica is increasing the degree of the ODE (i.e., internally rewriting it in terms of ${g'}^2$), which then causes spurious results. Feb 5, 2020 at 19:44
• Also, how long does MM 11 take to find results for this equation? I'm running MM 12 on a Mac, and when I run your code it doesn't provide any results before I give up and abort the calculation (several minutes). Feb 5, 2020 at 19:45
• This is an interesting question. I've looked at numerical solutions given by NDSolve and I can't get it to give me the R^2 solution. Note that the DSolve doesn't really give two solutions: it gives two expressions, which can match different initial conditions. Feb 5, 2020 at 22:23
• @mikado: I think this is because the function $f(g,R) = -2 \sqrt{R^2 - g^2} + 2R$ is not Lipschitz continuous in $g$, which means (in particular) that we shouldn't expect there to be a unique solution for a given set of initial conditions (i.e., the Picard-Lindelöf theorem doesn't apply.) Numerical algorithms such as NDSolve kind of implicitly assume that the solution is unique. Feb 6, 2020 at 14:45

Usually a solution to an ODE needs as many constants as their degree. In this case, the solution

$$g(R) = R^2$$

doesn't requires such a constant. Analyzing the phase plane for this ODE we can observe that the initial conditions for a real solution should obey

$$R_0 \ge 0,\ \ g(R_0) \lt R_0^2$$

and for $$g(R)= R^2$$ we have a particular solution. Follows a plot showing the stream plot (phase plane) for this ODE, in red the particular solution and in green two solutions: for $$g(0) = 0$$ and for $$g(2+\epsilon^2) = 4$$

gr1 = StreamPlot[{1, -2 (Sqrt[x^2 - y] - x)}, {x, 0, 10}, {y, -1, 9}];
gr2 = ContourPlot[y == x^2, {x, 0, 10}, {y, -1, 9}, ContourStyle -> Red];
sol3 = NDSolve[{g'[r] == -2 Sqrt[-g[r] + r^2] + 2 r, g[0] == 0}, g, {r, 0, 10}][[1]];
gr3 = Plot[Evaluate[g[r] /. sol3], {r, 0, 10}, PlotStyle -> Green];
sol4 = NDSolve[{g'[r] == -2 Sqrt[-g[r] + r^2] + 2 r, g[2.01] == 4}, g, {r, 0, 10}][[1]];
gr4 = Plot[Evaluate[g[r] /. sol4], {r, 0, 10}, PlotStyle -> Green];
Show[gr1, gr4, gr3, gr2]


Not an answer, but might help getting help...

I evaluated the integral using the package NCAlgebra, which considers g as a noncommutative variable. You can see (it you click on the image...) that it transforms the DSolve into a Solve with two integration constants.

<< NC;
<< NCAlgebra;
DSolve[2 R - 2 Sqrt[R^2 - g[R]] - Derivative[1][g][R] == 0, g[R], R]


Maybe some gurus can infer what is happening from there (probably MMA transforms the ODE).

• Quite interesting indeed, but I'm not so sure how to proceed from there! thanks btw. Feb 6, 2020 at 15:24