File epsilon.h#

namespace sym

Variables

template<typename Scalar>
constexpr Scalar kDefaultEpsilon = Scalar(10.0) * std::numeric_limits<Scalar>::epsilon()#

kDefaultEpsilon is a small positive number for avoiding numerical singularities.

It is based on numerical epsilon (the difference between 1.0 and the next floating point number), scaled up for safety.

An example of where kDefaultEpsilon might be used is in the evaluation of sin(x - 1) / (x - 1), which, at x = 1, evaluates to 0/0, i.e., NaN. This is despite the fact that the limit as x -> 1 is well defined (itself equaling 1).

If we used x + copysign(kDefaultEpsilon, x) instead of x, we’d avoid the singularity and get a nearly correct answer (due to the continuity of the function).

For more information on epsilons and how to use them, see symforce/notebooks/epsilon_sandbox.ipynb

const template double kDefaultEpsilon< double >
const template float kDefaultEpsilon< float >
constexpr double kDefaultEpsilond = kDefaultEpsilon<double>#
constexpr float kDefaultEpsilonf = kDefaultEpsilon<float>#