# Checking the solution of a differential equation with a given solution

I can't verify the solution of this differential equation.

 eqn = y'[x] == x*y[x]^(1/2)


where:

sol = {{y -> x^4/16}}


When I tried the ReplaceAll statement (/.) to verify the solution I get:

In:= eqn /. sol

Out= {Derivative[(x^4/16)][x] == x Sqrt[((x^4)/16)[x]]}


Instead of {True}. I have checked on:

And I can't figure out what I'm doing wrong. I'm just looking for some pointers or tips to see what I can do.

• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Michael E2 Aug 26 '16 at 3:06
• You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is also useful for learning how to format your questions and answers. You may also find this meta Q&A helpful. (Your post is not formatted so well at this point -- sorry. Don't format code as TeX. You want to make it easy to copy and paste back into Mathematica.) – Michael E2 Aug 26 '16 at 3:07

## 1 Answer

To verify ODE solution, use the functional method, as described in tutorial/DSolveSolutionVerification.html i.e. use y and not y[x] in the DSolve command.

Sometimes, as in this case, you have to help it a little also using Simplify as mentioned in the above link. For your example:

ClearAll[y, x]
ode = y'[x] == x Sqrt[y[x]];
sol = DSolve[ode, y, x]
Simplify[eq /. sol,
Assumptions -> Element[{x, C}, Reals] && x > 0 && C > 0] If you do not use the assumptions, then Mathematica does not know that the sqrt is real or complex. Here is without the assumptions:

ClearAll[y, x]
ode = y'[x] == x Sqrt[y[x]];
sol = DSolve[ode, y, x]
Simplify[eq /. sol] btw, I always wished Mathematica has an odetest() function as in Maple, as it makes it little easier. This is the same thing in Maple

ode := diff(y(x),x)= x*sqrt(y(x));
sol:=dsolve(ode,y(x));
odetest(sol,ode);
0


If the answer is zero, then the solution satisfies the ODE.

ps. I just saw your edit and you wanted to verify x^4/16. Ok, in this case, you write this:

ode = y'[x] == x Sqrt[y[x]];
sol2 = y -> Function[{x}, x^4/16];
Simplify[eq /. sol2, Assumptions -> x > 0] The idea is to use Function, so that it will work with derivatives.

• Thanks, i didn't know about the Assumptions option and was missing the Function thing, even though i read it i didn't quite got it. Now i see whats need to be done. :D, thanks again. – Leothan Aug 26 '16 at 3:36