Controlling the Precision of Results

In doing numerical operations like (RefLink[NDSolve, paclet:ref/NDSolve]) and (RefLink[NMinimize, paclet:ref/NMinimize]), the Wolfram Language by default uses machine numbers. But by setting the option (RefLink[WorkingPrecision, paclet:ref/WorkingPrecision])->n you can tell it to use arbitrary-precision numbers with n-digit precision.

This does a machine-precision computation of a numerical integral:

NIntegrate[Sin[Sin[x]],{x,0,1}]

This does the computation with 30-digit arbitrary-precision numbers:

NIntegrate[Sin[Sin[x]],{x,0,1},WorkingPrecision->30]

When you give a setting for (RefLink[WorkingPrecision, paclet:ref/WorkingPrecision]), this typically defines an upper limit on the precision of the results from a computation. But within this constraint you can tell the Wolfram Language how much precision and accuracy you want it to try to get. You should realize that for many kinds of numerical operations, increasing precision and accuracy goals by only a few digits can greatly increase the computation time required. Nevertheless, there are many cases where it is important to ensure that high precision and accuracy are obtained.

Options for controlling precision and accuracy.

This gives a result to 25-digit precision:

NIntegrate[Sin[Sin[x]],{x,0,1},WorkingPrecision->30,PrecisionGoal->25]

50-digit precision cannot be achieved with 30-digit working precision:

NIntegrate[Sin[Sin[x]],{x,0,1},WorkingPrecision->30,PrecisionGoal->50, MaxRecursion->20]

Given a particular setting for (RefLink[WorkingPrecision, paclet:ref/WorkingPrecision]), each of the functions for numerical operations in the Wolfram Language uses certain default settings for (RefLink[PrecisionGoal, paclet:ref/PrecisionGoal]) and (RefLink[AccuracyGoal, paclet:ref/AccuracyGoal]). Typical is the case of (RefLink[NDSolve, paclet:ref/NDSolve]), in which these default settings are equal to half the settings given for (RefLink[WorkingPrecision, paclet:ref/WorkingPrecision]).

The precision and accuracy goals normally apply both to the final results returned, and to various norms or error estimates for them. Functions for numerical operations in the Wolfram Language typically try to refine their results until either the specified precision goal or accuracy goal is reached. If the setting for either of these goals is (RefLink[Infinity, paclet:ref/Infinity]), then only the other goal is considered.

In doing ordinary numerical evaluation with (RefLink[N, paclet:ref/N])[expr,n], the Wolfram Language automatically adjusts its internal computations to achieve n-digit precision in the result. But in doing numerical operations on functions, it is in practice usually necessary to specify (RefLink[WorkingPrecision, paclet:ref/WorkingPrecision]) and (RefLink[PrecisionGoal, paclet:ref/PrecisionGoal]) more explicitly.