Average Error: 22.3 → 0.1
Time: 2.4s
Precision: binary64
\[\]
\[\]

Error

Bits error versus x

Bits error versus y

Target

Original22.3
Target0.5
Herbie0.1
\[\]

Derivation

  1. Split input into 3 regimes
  2. if x < -1.3251322205262078e154

    1. Initial program 64.0

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

      \[\leadsto \]
    3. Simplified0

      \[\leadsto \]

    if -1.3251322205262078e154 < x < 2.497175538071421e116

    1. Initial program 0.0

      \[\]

    if 2.497175538071421e116 < x

    1. Initial program 53.6

      \[\]
    2. Taylor expanded around inf 0.3

      \[\leadsto \]
    3. Simplified0.3

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

    \[\leadsto \]

Reproduce

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