MATHEMATICA TUTORIAL

# 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.
 Out[2]=
 Out[3]=
In this example, the equation and an initial condition are verified by substitution.
 Out[5]=
 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.
 Out[8]=
This substitutes the solution back into the equation.
 Out[9]=
The solution can be verified using Simplify.
 Out[10]=
Here is a linear PDE whose solution can be verified using Simplify.
 Out[12]=
 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.
 Out[15]=
 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.
 Out[19]=
 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.
 Out[21]=
This uses complex random values to verify the previous solution.
 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.
 Out[25]=
 Out[26]=
This verifies the solution by simplifying its derivative.
 Out[27]=

## Tutorial CollectionTutorial Collection

New to Mathematica? Find your learning path »
Have a question? Ask support »