Average Error: 38.3 → 27.0
Time: 3.6s
Precision: binary64
\[\]
\[\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original38.3
Target25.7
Herbie27.0
\[\]

Derivation

  1. Split input into 4 regimes
  2. if x < -1.04843673512673666e83

    1. Initial program 52.8

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

      \[\leadsto \]
    3. Simplified19.5

      \[\leadsto \]

    if -1.04843673512673666e83 < x < -1.4341076108923288e-274 or 3.02876797301242108e-270 < x < 1.9243525779759927e64

    1. Initial program 29.8

      \[\]

    if -1.4341076108923288e-274 < x < 3.02876797301242108e-270

    1. Initial program 31.4

      \[\]
    2. Taylor expanded around 0 47.1

      \[\leadsto \]

    if 1.9243525779759927e64 < x

    1. Initial program 50.8

      \[\]
    2. Taylor expanded around inf 20.2

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

    \[\leadsto \]

Reproduce

herbie shell --seed 2020180 
(FPCore (x y z)
  :name "FRP.Yampa.Vector3:vector3Rho from Yampa-0.10.2"
  :precision binary64

  :herbie-target
  (if (< z -6.396479394109776e+136) (neg z) (if (< z 7.320293694404182e+117) (sqrt (+ (+ (* z z) (* x x)) (* y y))) z))

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