Average Error: 21.2 → 0.5
Time: 1.6s
Precision: binary64
\[\]
\[\]

Error

Bits error versus x

Bits error versus y

Target

Original21.2
Target0.4
Herbie0.5
\[\]

Derivation

  1. Split input into 3 regimes
  2. if x < -8.9999582525827406e135

    1. Initial program 57.1

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

      \[\leadsto \]
    3. Simplified0.3

      \[\leadsto \]

    if -8.9999582525827406e135 < x < 5.73985145420372766e55

    1. Initial program 0.0

      \[\]

    if 5.73985145420372766e55 < x

    1. Initial program 39.5

      \[\]
    2. Taylor expanded around inf 1.7

      \[\leadsto \]
    3. Simplified1.7

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

    \[\leadsto \]

Reproduce

herbie shell --seed 2020179 
(FPCore (x y)
  :name "Linear.Quaternion:$clog from linear-1.19.1.3"
  :precision binary64

  :herbie-target
  (if (< x -1.5097698010472593e+153) (neg (+ (* 0.5 (/ y x)) x)) (if (< x 5.582399551122541e+57) (sqrt (+ (* x x) y)) (+ (* 0.5 (/ y x)) x)))

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