Average Error: 0.1 → 0.0
Time: 22.5s
Precision: 64
\[\frac{4.0 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}\]
\[4.0 \cdot \left(\frac{x}{z} - \frac{y}{z}\right) - 2.0\]
\frac{4.0 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
4.0 \cdot \left(\frac{x}{z} - \frac{y}{z}\right) - 2.0
double f(double x, double y, double z) {
        double r40564458 = 4.0;
        double r40564459 = x;
        double r40564460 = y;
        double r40564461 = r40564459 - r40564460;
        double r40564462 = z;
        double r40564463 = 0.5;
        double r40564464 = r40564462 * r40564463;
        double r40564465 = r40564461 - r40564464;
        double r40564466 = r40564458 * r40564465;
        double r40564467 = r40564466 / r40564462;
        return r40564467;
}

double f(double x, double y, double z) {
        double r40564468 = 4.0;
        double r40564469 = x;
        double r40564470 = z;
        double r40564471 = r40564469 / r40564470;
        double r40564472 = y;
        double r40564473 = r40564472 / r40564470;
        double r40564474 = r40564471 - r40564473;
        double r40564475 = r40564468 * r40564474;
        double r40564476 = 2.0;
        double r40564477 = r40564475 - r40564476;
        return r40564477;
}

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. Taylor expanded around 0 0.0

    \[\leadsto \color{blue}{4.0 \cdot \frac{x}{z} - \left(4.0 \cdot \frac{y}{z} + 2.0\right)}\]
  3. Simplified0.0

    \[\leadsto \color{blue}{4.0 \cdot \frac{x - y}{z} - 2.0}\]
  4. Using strategy rm
  5. Applied div-sub0.0

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

    \[\leadsto 4.0 \cdot \left(\frac{x}{z} - \frac{y}{z}\right) - 2.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))