Average Error: 31.8 → 18.3
Time: 3.1s
Precision: binary64
\[\]
\[\]

Error

Bits error versus x

Bits error versus y

Target

Original31.8
Target17.8
Herbie18.3
\[\]

Derivation

  1. Split input into 3 regimes
  2. if x < -1.69098607420795857e60

    1. Initial program 44.5

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

      \[\leadsto \]
    3. Simplified12.0

      \[\leadsto \]

    if -1.69098607420795857e60 < x < 4.2484476987621222e82

    1. Initial program 22.6

      \[\]

    if 4.2484476987621222e82 < x

    1. Initial program 48.9

      \[\]
    2. Taylor expanded around inf 11.0

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

    \[\leadsto \]

Reproduce

herbie shell --seed 2020180 
(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))))