Average Error: 0.1 → 0.0
Time: 17.4s
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) - 2\]
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
4 \cdot \left(\frac{x}{z} - \frac{y}{z}\right) - 2
double f(double x, double y, double z) {
        double r915468 = 4.0;
        double r915469 = x;
        double r915470 = y;
        double r915471 = r915469 - r915470;
        double r915472 = z;
        double r915473 = 0.5;
        double r915474 = r915472 * r915473;
        double r915475 = r915471 - r915474;
        double r915476 = r915468 * r915475;
        double r915477 = r915476 / r915472;
        return r915477;
}

double f(double x, double y, double z) {
        double r915478 = 4.0;
        double r915479 = x;
        double r915480 = z;
        double r915481 = r915479 / r915480;
        double r915482 = y;
        double r915483 = r915482 / r915480;
        double r915484 = r915481 - r915483;
        double r915485 = r915478 * r915484;
        double r915486 = 2.0;
        double r915487 = r915485 - r915486;
        return r915487;
}

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. Using strategy rm
  3. Applied clear-num0.3

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

    \[\leadsto \frac{1}{\color{blue}{\frac{\frac{z}{4}}{x - \mathsf{fma}\left(z, 0.5, y\right)}}}\]
  5. Taylor expanded around 0 0.0

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

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

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

Reproduce

herbie shell --seed 2020045 +o rules:numerics
(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))