Average Error: 31.3 → 17.6
Time: 3.4s
Precision: binary64
\[\]
\[\]

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Split input into 4 regimes
  2. if x < -3.8911963948436084e148

    1. Initial program 62.5

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

      \[\leadsto \]
    3. Simplified7.3

      \[\leadsto \]

    if -3.8911963948436084e148 < x < -7.0195584571619032e-182 or -1.05288433537404246e-271 < x < 4.84533569762603965e122

    1. Initial program 19.6

      \[\]

    if -7.0195584571619032e-182 < x < -1.05288433537404246e-271

    1. Initial program 32.2

      \[\]
    2. Taylor expanded around 0 34.9

      \[\leadsto \]

    if 4.84533569762603965e122 < x

    1. Initial program 56.3

      \[\]
    2. Taylor expanded around inf 8.9

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

    \[\leadsto \]

Reproduce

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