# Finding "missing" solutions of differential equation with NDSolve

I was working with NDSolve, and suddenly this question, appeared, so I decide to try something:

Define a differential equation:

sole = DSolve[{D[n[x] (x)^4, x] == (n[x])^(1/2), n[1] == 1}, n, x]


Plot the results

Plot[Evaluate[n[x] /. sole], {x, 0.4, 1}]


Now I tried to solve the same differential equation numerically

  sol = NDSolve[{D[n[x] (x)^4, x] == (n[x])^(1/2), n[1] == 1}, n, {x, 0.4, 1}]


Plot the results

  Plot[n[x] /. sol, {x, 0.4, 1}]


Now mathematica gives only one plot

Question

What happened to the other solution?

• DSolve appears to be spitting out an unacceptable solution. I believe the blue curve satisfies the differential equation D[n[x] (x)^4, x] == -(n[x])^(1/2), whereas the orange curve satisfies the differential equation D[n[x] (x)^4, x] == (n[x])^(1/2). Commented Jul 2, 2020 at 17:14
• I think that you are right. However I don't understand why mathematica put a minus sign in this equation D[n[x] (x)^4, x] == -(n[x])^(1/2) Commented Jul 2, 2020 at 17:20
• Mathmatica does some symbolic pre-processing of differential equations, and perhaps there was a mistake in that, or perhaps it doesn't like it when ODE's that don't satisfy the uniqueness theorem show up. I don't know. Note that DSolve[D[n[x] (x)^4, x] == (n[x])^(1/2), n[x], x] yields only one solution. Something about that initial condition is making Mathematica choke. Commented Jul 2, 2020 at 17:22
• I didn't take in account the uniqueness theorem, so my next question will be really basic: If I take in account the uniqueness theorem, then the differential equation only has 1 solution? Commented Jul 2, 2020 at 17:33

## 1 Answer

Amplifying on comment by @march

Clear["Global*"]

eqns = {D[n[x] (x)^4, x] == (n[x])^(1/2), n[1] == 1};

sole = DSolve[eqns, n, x]

(* {{n -> Function[{x}, (1 + 2 x + x^2)/(4 x^6)]}, {n ->
Function[{x}, (1 - 6 x + 9 x^2)/(4 x^6)]}} *)


Verify the solutions

eqns /. sole // FullSimplify[#, x >= 1/3] &

(* {{False, True}, {True, True}} *)


Only the second solution is valid. This is the solution that matches the numeric result.

In general extraneous solutions are a risk and solutions should be verified.

For numeric results you can check whether the results are "reasonably" close.

sol = NDSolve[eqns, n, {x, 2/5, 1}, WorkingPrecision -> 50][[1]];

Table[(Subtract @@@ eqns) /. sol, {x, 2/5, 1, 1/10}] // N

(* {{-6.2961*10^-29, 0.}, {-2.50343*10^-10, 0.}, {4.90958*10^-9,
0.}, {5.45647*10^-9, 0.}, {-3.10546*10^-10, 0.}, {9.492*10^-10, 0.}, {0.,
0.}} *)
`
• I wonder if this then should be labeled as a bug? Commented Jul 2, 2020 at 17:23
• Suppose that you have a complicated differential equation, that only can be solved numerically, then, how do you know that the numerical result really is the solution of the differential equation? Commented Jul 2, 2020 at 17:27
• I'm sorry I don't understand what do you mean with "reasonably" close. Can you explain a little bit more? Commented Jul 4, 2020 at 21:02
• @Cruz - for any equation Abs[LHS-RHS] should evaluate to zero. For a numerical solution there will generally be a non-zero value. What small value is acceptable will depend on the problem. Whatever threshold is deemed acceptable is what defines reasonably close. Commented Jul 4, 2020 at 21:35