5
$\begingroup$

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[6]:= eqn /. sol

Out[6]= {Derivative[1][(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.

$\endgroup$
  • $\begingroup$ 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! $\endgroup$ – Michael E2 Aug 26 '16 at 3:06
  • $\begingroup$ 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.) $\endgroup$ – Michael E2 Aug 26 '16 at 3:07
4
$\begingroup$

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.

Mathematica graphics

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[1]}, Reals] && x > 0 && C[1] > 0]

Mathematica graphics

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]

Mathematica graphics

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]

Mathematica graphics

The idea is to use Function, so that it will work with derivatives.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Leothan Aug 26 '16 at 3:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.