Average Error: 0.1 → 0.0
Time: 13.2s
Precision: 64
\[\frac{4.0 \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.0\]
\frac{4.0 \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.0
double f(double x, double y, double z) {
        double r37385134 = 4.0;
        double r37385135 = x;
        double r37385136 = y;
        double r37385137 = r37385135 - r37385136;
        double r37385138 = z;
        double r37385139 = 0.5;
        double r37385140 = r37385138 * r37385139;
        double r37385141 = r37385137 - r37385140;
        double r37385142 = r37385134 * r37385141;
        double r37385143 = r37385142 / r37385138;
        return r37385143;
}

double f(double x, double y, double z) {
        double r37385144 = x;
        double r37385145 = z;
        double r37385146 = r37385144 / r37385145;
        double r37385147 = 0.5;
        double r37385148 = y;
        double r37385149 = r37385148 / r37385145;
        double r37385150 = r37385147 + r37385149;
        double r37385151 = r37385146 - r37385150;
        double r37385152 = 4.0;
        double r37385153 = r37385151 * r37385152;
        return r37385153;
}

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.0 \cdot \frac{x}{z} - \left(2.0 + 4.0 \cdot \frac{y}{z}\right)\]

Derivation

  1. Initial program 0.1

    \[\frac{4.0 \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.0}\]
  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.0\]
  5. Applied associate--l-0.0

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

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

Reproduce

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