uxarray.utils.computing.acc_sqrt_re

Contents

uxarray.utils.computing.acc_sqrt_re#

uxarray.utils.computing.acc_sqrt_re(value, error=0.0)#

Accurate square root: return (root, correction) s.t. root+correction ≈ sqrt(value+error).

Mirrors accusphgeom::numeric::acc_sqrt_re from eft.hpp. Computes root = fl(sqrt(value)), measures the rounding error of root*root via two_prod, then recovers a correction term from the residual. When error is provided (e.g. the lo half of a compensated sum), it is folded into the residual so the correction accounts for the full compensated input.

Parameters:
  • value (float) – Non-negative scalar (the hi part of a compensated value).

  • error (float, optional) – Low-order correction to value (default 0.0).

Returns:

  • root (float) – Rounded sqrt, fl(sqrt(value)).

  • correction (float) – Additive correction; root + correction ≈ sqrt(value + error) to ~1 ulp.

References

Rump, S. M. (2023). Fast and accurate computation of the Euclidean norm of a vector. Japan Journal of Industrial and Applied Mathematics, 40. https://doi.org/10.1007/s13160-023-00593-8