Average Error: 21.9 → 0.0
Time: 2.3s
Precision: binary64
\[\]
\[\]

Error

Bits error versus x

Bits error versus y

Target

Original21.9
Target0.5
Herbie0.0
\[\]

Derivation

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

    1. Initial program 64.0

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

      \[\leadsto \]
    3. Simplified0

      \[\leadsto \]

    if -1.33525539405981467e154 < x < 9.94522109174082653e135

    1. Initial program 0.0

      \[\]

    if 9.94522109174082653e135 < x

    1. Initial program 57.4

      \[\]
    2. Taylor expanded around inf 0.1

      \[\leadsto \]
    3. Simplified0.1

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

    \[\leadsto \]

Reproduce

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