Average Error: 0.1 → 0.0
Time: 1.2s
Precision: 64
\[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}\]
\[4 \cdot \left(\frac{x}{z} - \frac{y}{z}\right) + \left(-2\right)\]
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
4 \cdot \left(\frac{x}{z} - \frac{y}{z}\right) + \left(-2\right)
double f(double x, double y, double z) {
        double r857487 = 4.0;
        double r857488 = x;
        double r857489 = y;
        double r857490 = r857488 - r857489;
        double r857491 = z;
        double r857492 = 0.5;
        double r857493 = r857491 * r857492;
        double r857494 = r857490 - r857493;
        double r857495 = r857487 * r857494;
        double r857496 = r857495 / r857491;
        return r857496;
}

double f(double x, double y, double z) {
        double r857497 = 4.0;
        double r857498 = x;
        double r857499 = z;
        double r857500 = r857498 / r857499;
        double r857501 = y;
        double r857502 = r857501 / r857499;
        double r857503 = r857500 - r857502;
        double r857504 = r857497 * r857503;
        double r857505 = 2.0;
        double r857506 = -r857505;
        double r857507 = r857504 + r857506;
        return r857507;
}

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

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

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

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

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

Reproduce

herbie shell --seed 2019353 
(FPCore (x y z)
  :name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
  :precision binary64

  :herbie-target
  (- (* 4 (/ x z)) (+ 2 (* 4 (/ y z))))

  (/ (* 4 (- (- x y) (* z 0.5))) z))