MATLAB Answers

Absolute and relative tolerance definitions

688 views (last 30 days)
Julián Francisco
Julián Francisco on 22 Jan 2012
I am trying to understand the following Matlab definitions for RelTol and AbsTol parameters:
RelTol — This tolerance is a measure of the error relative to the size of each solution component. Roughly, it controls the number of correct digits in all solution components, except those smaller than thresholds AbsTol(i).
The default, 1e-3, corresponds to 0.1% accuracy.
AbsTol — AbsTol(i) is a threshold below which the value of the ith solution component is unimportant. The absolute error tolerances determine the accuracy when the solution approaches zero.
I do not understand why AbsTol determines the accuracy when the solution approaches zero (indeed, if the solution of my problem is a circular orbit of 7000 km radius this does not meet) and why RelTol controls the number of correct digits in all solution components, except those smaller than thresholds AbsTol(i). I would like to have simpler and understandable definitions.

Accepted Answer

Jan
Jan on 22 Jan 2012
The relative tolerance between two values X and Y is:
abs(X - Y) / min(abs(X), abs(Y))
But if X or Y becomes (near to) zero, the tolerance grows until infinity. Then the absolute tolerance is a better limit:
abs(X - Y)
[EDITED] The relative error "abs(X - Y) / min(abs(X), abs(Y))" determines the number of "equal digits" between X and Y, if X and Y are >> 1. Just try it:
abs(7000 - 6000) / min(abs(7000), abs(6000)) < 0.1 % FALSE
abs(7000 - 6900) / min(abs(7000), abs(6900)) < 0.1 % TRUE
abs(7000 - 6900) / min(abs(7000), abs(6900)) < 0.01 % FALSE
The term "equal digits" is not meant very strict here. This is more a rule of thumb.
But if you get near to zero, this measurement fails, because the division by a small number let explode distances. Then the absolute distance is applied as limit, because it is more likely to match the needs of the user.
Sometimes this method is applied to match large and small numbers:
abs(X - Y) / (1 + min(abs(X), abs(Y)))
[/EDITED]
But for real problems, neither the relative nor the absolute error are accurate in general:
There is no unique mathematically meaningful definition of "near to eachother" for two values. E.g. 1000001 and 1000000 can be assumed to be near to eachother using a relative tolerance. But 0.000001 and 1.000001 have the same distance and deciding if they are near or far apart depends on the physical definition of the value. If it is the temperature of water, the different values mean a totally different behaviour. If the values are the height of a measurement point relative to the sea level, measured in millimeter from a satellite, both values are almost equal.
In real scientific projects the metric used for the measurement of the local discretization error is very important. The integrator adjustes the step size to keep the local error under, but near to the specified tolerance. This sounds trivial, but imagine the simulation of the re-entrance of a spaceship and the trajectory is this vector:
y = [position; velocity; temperature inside; temperature surface]
While the temperature are relevant for the application, they do not influence the spacial motion of the body. In consequence the local error should not be controlled neither by relative or absolute tolerances of the temperatures! In addition it should not matter, if the position is measured in AU or meter, or relative to the sea level or to the center of the earth.
Conclusion: For an accurate integration the definition of the local error must consider the physical meaning of the components of the trajectory. Using AbsTol, RelTol and NormControl (see help odeset) is not powerful enough for an accurate integration. A better method is either a user-defined function to calculate a norm, or local scaling, which let all relevant values live near to 1.0.
  5 Comments
Julián Francisco
Julián Francisco on 24 Jan 2012
@Jan Simon: Thank you very much for your comments.

Sign in to comment.

More Answers (1)

Mike Hosea
Mike Hosea on 23 Jan 2012
The numerical method works with an error estimate, i.e. it computes an approximation for abs(x-x0), where x is the approximate solution and x0 is the exact solution. Let's call the error estimate E. The code will try to meet E < max(abstol,reltol*abs(x)). When abs(x) is larger than abstol/reltol, then only the relative error tolerance is important, so you are asking that E/abs(x) < reltol. E/abs(x) is an approximation of the relative error abs(x-x0)/abs(x0). So you essentially control the number of significant digits, as you have noted. However, when abs(x) is smaller than abstol/reltol, only the absolute error tolerance is used, so the error test in that case is E < abstol, which is approximately abs(x-x0) < abstol. Since relative error is undefined when the true solution is zero, you have to switch over to something besides relative error control when the solution component gets small. E.g. if x0 = 0, the approximation x = realmin has no correct significant digits, nary a one.
  3 Comments
Julián Francisco
Julián Francisco on 24 Jan 2012
@Mike Hosea: Thank you so much for your answer and comments.

Sign in to comment.

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!