## How Do I Check My Results in Mathematica?

Mathematica is one of the most reliable pieces of software ever written, and every version must pass a great number of tests before it is shipped. But no piece of software is perfect, and on the user side there may always be typos or errors in inputs. Of course, the first line of defense against incorrect results is common sense. For example, one should always ask: Is the order of magnitude plausible? Is the result plausible?

Additionally, there are some simple tests you can do in Mathematica to check your results without a lot of effort. In more complex cases, more complex tests might be necessary.

Substitute the Result Back into the Problem

In many cases, you can simply put the result back into the original problem and see if the result really solves the problem.

For example, take the result to this well-known problem.

/. is shortcut notation for ReplaceAll, and % refers to the last result Mathematica returned. Using FullSimplify gives {True, True}, showing that both results returned satisfy the equation.

The same method works for the differential equation solver DSolve and other commands that return rules.

You can easily substitute multiple results too.

For many other operations, you can simply use the inverse command as in this example.

Numerical Tests

Substitute the Result Back into the Original Problem

Let's compare the numerical solution to a differential equation with machine precision with a numerical solution with a higher-precision setting.

The following plot shows the logarithm of the difference between the numerical solution and the differential equation with the default setting of WorkingPrecision (black) and with WorkingPrecision set to 22 (red).

As you can see, the numerical errors are significantly smaller when using the higher working precision. The rather high first value is an artifact. The tradeoff for using higher precision is, of course, increased calculation times.