# How to verify a solution of an ordinary differential equation?

Given an ordinary differential equation with initial conditions

eq = u a[u] + (16 + u^2 + 2 u a[u] (12 + u a[u] (6 + u a[u]))) a'[u] == 0
ic = a[0] == -1/2


How can I analytically verify that

sol = a[u]^2 (2 + a[u] u)^2 == 1 + a[u] u


represents its implicit solution? Please, avoid numerical demonstrations. Assume also that DSolve cannot solve the given equation. I am explicitly interested in algebraic demonstration that would work in more complicated cases.

• Did you try implicitly differentiating the solution to find a’[u] and substituting that into the equation? Commented Jan 15 at 21:01
• @Ghoster Clever! Why didn't you post an answer? Commented Jan 15 at 22:08

You can't plugin in the implicit solution as is, need to first solve for a[u] from it. This gives 3 solutions. Then verify each one, one by one.

Maple can verify implicit solutions directly, without first solving for each solution. But Mathematica as far as I know, can't as of now.

eq = u  a[u] + (16 + u^2 + 2  u  a[u]  (12 + u  a[u]  (6 + u  a[u])))  a'[u] == 0
ic = a[0] == -1/2
sol = a[u]^2  (2 + a[u]  u)^2 == 1 + a[u]  u
explicit=a[u]/.Solve[sol,a[u]]
trialSol = a -> Function[{u}, Evaluate[First@explicit]]
eq /. trialSol // FullSimplify


But this solution did not verify the IC

ic /. trialSol // FullSimplify


Gives

Do the same for the result of the solutions, like this

Verified in Maple that your solution verifies the ode and the IC, using odetest directly. So need to work more on figuring out why Mathematica does not verify the IC. Looks like a limit issue,

eq := u*a(u)+(16 + u^2 + 2*u*a(u)*(12 + u*a(u)*(6 + u*a(u))))*diff(a(u),u)=0;
ic := a(0) = -1/2;
sol := a(u)^2*(2 + a(u)*u)^2 = 1 + a(u)*u;
odetest(sol,[eq,ic])


Gives [0,0] which means both the solution and IC was verified correct.

It will be useful if Mathematica had odetest function which is built-in to make it easier to verify the solutions of an ode.

Notice also that Mathematica DSolve has no option to return an implicit solution. It tries to always return an explicit solution. It will also be good to have such an option in future versions of DSolve

Reference

https://reference.wolfram.com/language/howto/CheckTheResultsOfDSolve.html

• Indeed, would be good if MA had this functionality. It seems to be a pure algebraic problem. I tried to handle it with Eliminate and PolynomialReduce, but somehow stuck. The problem with your solution is that it generates multiple branches and one needs to verify one by one. Out of curiosity, is Maple able to return this implicit solution? Commented Jan 15 at 22:33
• and one needs to verify one by one. Yes. This is the limitation of using Function method to verify solution. This is the method that Mathematica help pages recommend to use to verify ode solution (added link above). Otherwise, you'd have to do it the hard way, i.e. plugin in the dependent variable and all its derivatives into the ode and simplify. Commented Jan 15 at 22:51
• Out of curiosity, is Maple able to return this implicit solution? Maple returns 3 solutions. One of them implicit, It is written different, using $\ln$ but it looks like it could be simplified to the one you showed. I did not try. Need to raise both sides to exp and simplify. !Mathematica graphics Here it is in plain text -1/2*ln(4*a(u)^2*u^2+16*u*a(u)+u^2+16)+ln(2+u*a(u))-ln(a(u))+Pi*I = 0 Commented Jan 15 at 22:54
• Thank you, very useful. I will wait a day or two before accepting your solution as I still have hope that someone will propose how to emulate Maple's odetest function for implicit polynomial solutions and how to test the initial conditions. Commented Jan 16 at 8:56