822 views (last 30 days)

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.

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.

Jan
on 23 Jan 2012

@Julian: If your trajectory has two components y=[y1; y2] and while y1 is near to 7000 (e.g. the position), y2 is near to 0 (e.g. the speed). Then controlling the local discretization error inside the integrator cannot use the same method for both components. Therefore for [y>AbsTol] the relative tolerance is used, and for [y<=AbsTol] the absolute tolerance. As you can see by interpreting the formulas or by a tiny numerical experiment, the absolute tolerance does *not necessarily* determine the correct number of digits. It does depend on the decision, what exactly "near" to zero means for your physical object: If you measure the height of a supertanker above the sea-level, 1mm and 0.00001mm are very near and the number of "valid" digits is determined by the absolute tolerance. But if you measure the thickness of a goldfilm, 1mm and 0.00001mm are totally different.

This means, that even then question is not logical. If the trajectory is "near" to zero, the term "correct digits" is not well-defined anymore.

I'm using a hand-coded ODE45 integrator, which let the user define a norm-function for the local discretization error and event functions, which can influence the parameters. In addition it can use the sensitivity matrix (dependency of the trajectory to small variations of the initial value) to control the stepsize. Unfortunately I do not find the time to polish the function for posting it in the FEX. Therefore aksing the technical support would be a good idea. If they are fast, an improved integrator can be included in Matlab 2012b.

Mike Hosea
on 23 Jan 2012

Mike Hosea
on 23 Jan 2012

Jan
on 23 Jan 2012

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

Start Hunting!
## 0 Comments

Sign in to comment.