Average Error: 0.1 → 0.0
Time: 5.6s
Precision: 64
\[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}\]
\[\frac{x - y}{z} \cdot 4 - 2\]
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
\frac{x - y}{z} \cdot 4 - 2
double f(double x, double y, double z) {
        double r32072535 = 4.0;
        double r32072536 = x;
        double r32072537 = y;
        double r32072538 = r32072536 - r32072537;
        double r32072539 = z;
        double r32072540 = 0.5;
        double r32072541 = r32072539 * r32072540;
        double r32072542 = r32072538 - r32072541;
        double r32072543 = r32072535 * r32072542;
        double r32072544 = r32072543 / r32072539;
        return r32072544;
}

double f(double x, double y, double z) {
        double r32072545 = x;
        double r32072546 = y;
        double r32072547 = r32072545 - r32072546;
        double r32072548 = z;
        double r32072549 = r32072547 / r32072548;
        double r32072550 = 4.0;
        double r32072551 = r32072549 * r32072550;
        double r32072552 = 2.0;
        double r32072553 = r32072551 - r32072552;
        return r32072553;
}

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. 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} - 2}\]
  4. Final simplification0.0

    \[\leadsto \frac{x - y}{z} \cdot 4 - 2\]

Reproduce

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

  :herbie-target
  (- (* 4.0 (/ x z)) (+ 2.0 (* 4.0 (/ y z))))

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