Verification of the Solution

The solution given by DSolve can be verified using various methods. The easiest method involves substituting the solution back into the equation. If the result is True, the solution is valid.

In this simple example, the solution is verified by substitution. Note that the first argument to DSolve is assigned to eqn for convenience in later work.
In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=
In this example, the equation and an initial condition are verified by substitution.
In[4]:=
Click for copyable input
In[5]:=
Click for copyable input
Out[5]=
In[6]:=
Click for copyable input
Out[6]=

Sometimes the result of the substitution is more complicated than True or False. Such examples can be verified by using Simplify to simplify the result of the substitution. If the simplified result is True, the solution is valid.

Here is the general solution for a second-order inhomogeneous equation.
In[7]:=
Click for copyable input
In[8]:=
Click for copyable input
Out[8]=
This substitutes the solution back into the equation.
In[9]:=
Click for copyable input
Out[9]=
The solution can be verified using Simplify.
In[10]:=
Click for copyable input
Out[10]=
Here is a linear PDE whose solution can be verified using Simplify.
In[11]:=
Click for copyable input
In[12]:=
Click for copyable input
Out[12]=
In[13]:=
Click for copyable input
Out[13]=

If the equation involves special functions, it may be necessary to use FullSimplify to verify the solution.

Here is an example of this type involving Bessel's functions.
In[14]:=
Click for copyable input
In[15]:=
Click for copyable input
Out[15]=
In[16]:=
Click for copyable input
Out[16]=

If the solution is large or if Simplify and FullSimplify do not succeed in verifying the solution, a numerical check can be made by using RandomReal or RandomComplex to generate values for all the variables and parameters in the problem. It is advisable in such cases to repeat the check with several sets of random values.

Here is an example where numerical verification is useful.
In[17]:=
Click for copyable input
In[18]:=
Click for copyable input
In[19]:=
Click for copyable input
Out[19]=
In[20]:=
Click for copyable input
Out[20]=

Although numerical checks cannot verify a solution with certainty, more rigorous checks can be made by using higher precision or by allowing the variables to take complex values.

This verifies the previous solution with higher precision.
In[21]:=
Click for copyable input
Out[21]=
This uses complex random values to verify the previous solution.
In[22]:=
Click for copyable input
In[23]:=
Click for copyable input
Out[23]=

The previous methods are of use only when the solution is available in explicit form. The final example shows how to verify the solution of a first-order ODE when it is given in implicit form.

This solves a first-order ODE.
In[24]:=
Click for copyable input
In[25]:=
Click for copyable input
Out[25]=
In[26]:=
Click for copyable input
Out[26]=
This verifies the solution by simplifying its derivative.
In[27]:=
Click for copyable input
Out[27]=
New to Mathematica? Find your learning path »
Have a question? Ask support »