Average Error: 31.5 → 17.2
Time: 1.8s
Precision: binary64
\[\]
\[\]

Error

Bits error versus x

Bits error versus y

Target

Original31.5
Target17.3
Herbie17.2
\[\]

Derivation

  1. Split input into 3 regimes
  2. if x < -3.4475662606183263e130

    1. Initial program 56.9

      \[\]
    2. Taylor expanded around -inf 7.7

      \[\leadsto \]
    3. Simplified7.7

      \[\leadsto \]

    if -3.4475662606183263e130 < x < 1.8766509938470789e142

    1. Initial program 20.8

      \[\]

    if 1.8766509938470789e142 < x

    1. Initial program 60.5

      \[\]
    2. Taylor expanded around inf 8.5

      \[\leadsto \]
  3. Recombined 3 regimes into one program.
  4. Final simplification17.2

    \[\leadsto \]

Reproduce

herbie shell --seed 2020192 
(FPCore (x y)
  :name "Data.Octree.Internal:octantDistance  from Octree-0.5.4.2"
  :precision binary64

  :herbie-target
  (if (< x -1.1236950826599826e+145) (neg x) (if (< x 1.116557621183362e+93) (sqrt (+ (* x x) (* y y))) x))

  (sqrt (+ (* x x) (* y y))))