Efficiently computing (a - K) / (a + K) with improved accuracy

后端 未结 6 1731
抹茶落季
抹茶落季 2021-02-18 15:44

In various contexts, for example for the argument reduction for mathematical functions, one needs to compute (a - K) / (a + K), where a is a positive v

6条回答
  •  清酒与你
    2021-02-18 16:29

    I don't really have an answer (proper floating point error analyses are very tedious) but a few observations:

    • Fast reciprocal instructions (such as RCPSS) are not as accurate as division, so you may see a reduction in accuracy if using these.
    • m is computed exactly if a ∈ [0.5×Kb, 21+n×Kb), where Kb is the power of 2 below K (or K itself if K is a power of 2), and n is the number of trailing zeros in the significand of K (i.e. if K is a power of 2, then n=23).
    • This is similar to a simplified form of the div2 algorithm from Dekker (1971): to expand the range (particularly the lower bound), you'll probably have to incorporate more correction terms from this (i.e. store m as the sum of 2 floats, or use a double).

提交回复
热议问题