Average Error: 37.6 → 25.8
Time: 4.3s
Precision: binary64
\[\]
\[\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original37.6
Target25.5
Herbie25.8
\[\]

Derivation

  1. Split input into 3 regimes
  2. if x < -2.2756566799824152e79

    1. Initial program 52.5

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

      \[\leadsto \]
    3. Simplified19.8

      \[\leadsto \]

    if -2.2756566799824152e79 < x < 1.90195743875216181e73

    1. Initial program 29.2

      \[\]

    if 1.90195743875216181e73 < x

    1. Initial program 51.7

      \[\]
    2. Taylor expanded around inf 20.3

      \[\leadsto \]
  3. Recombined 3 regimes into one program.
  4. Final simplification25.8

    \[\leadsto \]

Reproduce

herbie shell --seed 2020190 
(FPCore (x y z)
  :name "Data.Array.Repa.Algorithms.Pixel:doubleRmsOfRGB8 from repa-algorithms-3.4.0.1"
  :precision binary64

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

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