Average Error: 0.2 → 0.0
Time: 2.5s
Precision: 64
\[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}\]
\[4 \cdot \frac{x - y}{z} + \left(-2\right)\]
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
4 \cdot \frac{x - y}{z} + \left(-2\right)
double f(double x, double y, double z) {
        double r880356 = 4.0;
        double r880357 = x;
        double r880358 = y;
        double r880359 = r880357 - r880358;
        double r880360 = z;
        double r880361 = 0.5;
        double r880362 = r880360 * r880361;
        double r880363 = r880359 - r880362;
        double r880364 = r880356 * r880363;
        double r880365 = r880364 / r880360;
        return r880365;
}

double f(double x, double y, double z) {
        double r880366 = 4.0;
        double r880367 = x;
        double r880368 = y;
        double r880369 = r880367 - r880368;
        double r880370 = z;
        double r880371 = r880369 / r880370;
        double r880372 = r880366 * r880371;
        double r880373 = 2.0;
        double r880374 = -r880373;
        double r880375 = r880372 + r880374;
        return r880375;
}

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.2
Target0.0
Herbie0.0
\[4 \cdot \frac{x}{z} - \left(2 + 4 \cdot \frac{y}{z}\right)\]

Derivation

  1. Initial program 0.2

    \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}\]
  2. Taylor expanded around 0 0.0

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

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

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

Reproduce

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