Average Error: 0.1 → 0.0
Time: 9.8s
Precision: 64
\[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}\]
\[4 \cdot \left(\frac{x}{z} - \frac{y}{z}\right) - 2\]
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
4 \cdot \left(\frac{x}{z} - \frac{y}{z}\right) - 2
double f(double x, double y, double z) {
        double r958265 = 4.0;
        double r958266 = x;
        double r958267 = y;
        double r958268 = r958266 - r958267;
        double r958269 = z;
        double r958270 = 0.5;
        double r958271 = r958269 * r958270;
        double r958272 = r958268 - r958271;
        double r958273 = r958265 * r958272;
        double r958274 = r958273 / r958269;
        return r958274;
}

double f(double x, double y, double z) {
        double r958275 = 4.0;
        double r958276 = x;
        double r958277 = z;
        double r958278 = r958276 / r958277;
        double r958279 = y;
        double r958280 = r958279 / r958277;
        double r958281 = r958278 - r958280;
        double r958282 = r958275 * r958281;
        double r958283 = 2.0;
        double r958284 = r958282 - r958283;
        return r958284;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.1
Target0.0
Herbie0.0
\[4 \cdot \frac{x}{z} - \left(2 + 4 \cdot \frac{y}{z}\right)\]

Derivation

  1. Initial program 0.1

    \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}\]
  2. Using strategy rm
  3. Applied associate-/l*0.2

    \[\leadsto \color{blue}{\frac{4}{\frac{z}{\left(x - y\right) - z \cdot 0.5}}}\]
  4. Simplified0.2

    \[\leadsto \frac{4}{\color{blue}{\frac{z}{x - \mathsf{fma}\left(z, 0.5, y\right)}}}\]
  5. Taylor expanded around 0 0.0

    \[\leadsto \color{blue}{4 \cdot \frac{x}{z} - \left(4 \cdot \frac{y}{z} + 2\right)}\]
  6. Simplified0.0

    \[\leadsto \color{blue}{4 \cdot \left(\frac{x}{z} - \frac{y}{z}\right) - 2}\]
  7. Final simplification0.0

    \[\leadsto 4 \cdot \left(\frac{x}{z} - \frac{y}{z}\right) - 2\]

Reproduce

herbie shell --seed 2020045 +o rules:numerics
(FPCore (x y z)
  :name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
  :precision binary64

  :herbie-target
  (- (* 4 (/ x z)) (+ 2 (* 4 (/ y z))))

  (/ (* 4 (- (- x y) (* z 0.5))) z))