Home

rtol

rtol, short for relative tolerance, is a parameter used in numerical computing to specify when two floating-point values are considered close. It is often paired with an absolute tolerance (atol) to form a closeness criterion that accounts for both relative and absolute differences.

A common formulation compares two numbers a and b using the condition |a - b| <= atol + rtol

rtol is widely used in testing and numerical verification. Functions such as isclose and allclose in scientific

Choosing values for rtol depends on the numerical method and precision. Typical rtol values range from 1e-5

See also: isclose, allclose, tolerance, numerical precision.

*
|b|
(or,
in
some
variations,
rtol
*
max(|a|,
|b|)).
This
means
that
allowable
error
scales
with
the
magnitude
of
the
values,
while
the
absolute
tolerance
handles
near-zero
comparisons.
Different
libraries
may
adopt
slightly
different
variants
of
the
formula,
but
the
same
general
idea
applies:
rtol
handles
relative
error,
while
atol
handles
fixed,
magnitude-independent
error.
computing
libraries
expose
rtol
(and
atol)
as
parameters.
For
example,
numpy.isclose(a,
b,
rtol=1e-5,
atol=1e-8)
uses
a
small
relative
tolerance
and
a
tiny
absolute
tolerance
to
determine
closeness.
PyTorch
provides
similar
options
in
its
allclose
function.
to
1e-8,
with
smaller
values
for
higher
precision
computations
or
more
sensitive
results.
When
the
reference
value
b
is
zero,
the
criterion
relies
entirely
on
atol,
making
a
nonzero
rtol
ineffective
in
that
case.