Average Error: 0.1 → 0.1
Time: 9.4s
Precision: 64
\[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}\]
\[\frac{4 \cdot \left(x - y\right)}{z} - 2\]
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
\frac{4 \cdot \left(x - y\right)}{z} - 2
double f(double x, double y, double z) {
        double r539361 = 4.0;
        double r539362 = x;
        double r539363 = y;
        double r539364 = r539362 - r539363;
        double r539365 = z;
        double r539366 = 0.5;
        double r539367 = r539365 * r539366;
        double r539368 = r539364 - r539367;
        double r539369 = r539361 * r539368;
        double r539370 = r539369 / r539365;
        return r539370;
}

double f(double x, double y, double z) {
        double r539371 = 4.0;
        double r539372 = x;
        double r539373 = y;
        double r539374 = r539372 - r539373;
        double r539375 = r539371 * r539374;
        double r539376 = z;
        double r539377 = r539375 / r539376;
        double r539378 = 2.0;
        double r539379 = r539377 - r539378;
        return r539379;
}

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.1
\[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. Simplified0.0

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

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

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

    \[\leadsto 4 \cdot \color{blue}{\frac{x - y}{z}} - 2\]
  7. Applied associate-*r/0.1

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

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

Reproduce

herbie shell --seed 2019235 +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))