Average Error: 0.1 → 0.0
Time: 9.6s
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 r41657035 = 4.0;
        double r41657036 = x;
        double r41657037 = y;
        double r41657038 = r41657036 - r41657037;
        double r41657039 = z;
        double r41657040 = 0.5;
        double r41657041 = r41657039 * r41657040;
        double r41657042 = r41657038 - r41657041;
        double r41657043 = r41657035 * r41657042;
        double r41657044 = r41657043 / r41657039;
        return r41657044;
}

double f(double x, double y, double z) {
        double r41657045 = x;
        double r41657046 = z;
        double r41657047 = r41657045 / r41657046;
        double r41657048 = 0.5;
        double r41657049 = y;
        double r41657050 = r41657049 / r41657046;
        double r41657051 = r41657048 + r41657050;
        double r41657052 = r41657047 - r41657051;
        double r41657053 = 4.0;
        double r41657054 = r41657052 * r41657053;
        return r41657054;
}

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 2019163 
(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))