Average Error: 38.2 → 26.7
Time: 3.4s
Precision: binary64
\[\]
\[\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original38.2
Target26.2
Herbie26.7
\[\]

Derivation

  1. Split input into 4 regimes
  2. if x < -1.95445500961015716e112

    1. Initial program 55.6

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

      \[\leadsto \]
    3. Simplified17.7

      \[\leadsto \]

    if -1.95445500961015716e112 < x < -6.7336058996915783e-215 or -1.81250657436522472e-266 < x < 3.2526274382715766e104

    1. Initial program 29.7

      \[\]
    2. Taylor expanded around 0 29.8

      \[\leadsto \]
    3. Simplified29.8

      \[\leadsto \]

    if -6.7336058996915783e-215 < x < -1.81250657436522472e-266

    1. Initial program 34.0

      \[\]
    2. Using strategy rm
    3. Applied sqrt-div34.1

      \[\leadsto \]
    4. Simplified34.1

      \[\leadsto \]
    5. Taylor expanded around 0 47.1

      \[\leadsto \]

    if 3.2526274382715766e104 < x

    1. Initial program 55.2

      \[\]
    2. Using strategy rm
    3. Applied sqrt-div55.2

      \[\leadsto \]
    4. Simplified55.2

      \[\leadsto \]
    5. Taylor expanded around inf 18.5

      \[\leadsto \]
  3. Recombined 4 regimes into one program.
  4. Final simplification26.7

    \[\leadsto \]

Reproduce

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