Average Error: 0.1 → 0.0
Time: 12.9s
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 r38628348 = 4.0;
        double r38628349 = x;
        double r38628350 = y;
        double r38628351 = r38628349 - r38628350;
        double r38628352 = z;
        double r38628353 = 0.5;
        double r38628354 = r38628352 * r38628353;
        double r38628355 = r38628351 - r38628354;
        double r38628356 = r38628348 * r38628355;
        double r38628357 = r38628356 / r38628352;
        return r38628357;
}

double f(double x, double y, double z) {
        double r38628358 = x;
        double r38628359 = z;
        double r38628360 = r38628358 / r38628359;
        double r38628361 = 0.5;
        double r38628362 = y;
        double r38628363 = r38628362 / r38628359;
        double r38628364 = r38628361 + r38628363;
        double r38628365 = r38628360 - r38628364;
        double r38628366 = 4.0;
        double r38628367 = r38628365 * r38628366;
        return r38628367;
}

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 +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))