Average Error: 31.8 → 17.7
Time: 1.5s
Precision: binary64
\[\]
\[\]

Error

Bits error versus x

Bits error versus y

Target

Original31.8
Target17.8
Herbie17.7
\[\]

Derivation

  1. Split input into 3 regimes
  2. if x < -8.5705357471445917e133

    1. Initial program 59.3

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

      \[\leadsto \]
    3. Simplified8.8

      \[\leadsto \]

    if -8.5705357471445917e133 < x < 8.64665372117908956e103

    1. Initial program 21.2

      \[\]

    if 8.64665372117908956e103 < x

    1. Initial program 51.9

      \[\]
    2. Taylor expanded around inf 10.9

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

    \[\leadsto \]

Reproduce

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