Average Error: 0.1 → 0.0
Time: 10.5s
Precision: 64
\[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}\]
\[\left(\frac{x}{z} - \left(0.5 + \frac{y}{z}\right)\right) \cdot 4\]
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
\left(\frac{x}{z} - \left(0.5 + \frac{y}{z}\right)\right) \cdot 4
double f(double x, double y, double z) {
        double r44126551 = 4.0;
        double r44126552 = x;
        double r44126553 = y;
        double r44126554 = r44126552 - r44126553;
        double r44126555 = z;
        double r44126556 = 0.5;
        double r44126557 = r44126555 * r44126556;
        double r44126558 = r44126554 - r44126557;
        double r44126559 = r44126551 * r44126558;
        double r44126560 = r44126559 / r44126555;
        return r44126560;
}

double f(double x, double y, double z) {
        double r44126561 = x;
        double r44126562 = z;
        double r44126563 = r44126561 / r44126562;
        double r44126564 = 0.5;
        double r44126565 = y;
        double r44126566 = r44126565 / r44126562;
        double r44126567 = r44126564 + r44126566;
        double r44126568 = r44126563 - r44126567;
        double r44126569 = 4.0;
        double r44126570 = r44126568 * r44126569;
        return r44126570;
}

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. Simplified0.0

    \[\leadsto \color{blue}{\left(\frac{x - y}{z} - 0.5\right) \cdot 4}\]
  3. Using strategy rm
  4. Applied div-sub0.0

    \[\leadsto \left(\color{blue}{\left(\frac{x}{z} - \frac{y}{z}\right)} - 0.5\right) \cdot 4\]
  5. Applied associate--l-0.0

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

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

Reproduce

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