Average Error: 0.1 → 0.0
Time: 9.0s
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 r55086881 = 4.0;
        double r55086882 = x;
        double r55086883 = y;
        double r55086884 = r55086882 - r55086883;
        double r55086885 = z;
        double r55086886 = 0.5;
        double r55086887 = r55086885 * r55086886;
        double r55086888 = r55086884 - r55086887;
        double r55086889 = r55086881 * r55086888;
        double r55086890 = r55086889 / r55086885;
        return r55086890;
}

double f(double x, double y, double z) {
        double r55086891 = 4.0;
        double r55086892 = x;
        double r55086893 = z;
        double r55086894 = r55086892 / r55086893;
        double r55086895 = y;
        double r55086896 = r55086895 / r55086893;
        double r55086897 = r55086894 - r55086896;
        double r55086898 = r55086891 * r55086897;
        double r55086899 = 2.0;
        double r55086900 = r55086898 - r55086899;
        return r55086900;
}

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. Simplified0.2

    \[\leadsto \color{blue}{\left(x - \mathsf{fma}\left(0.5, z, y\right)\right) \cdot \frac{4}{z}}\]
  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. Final simplification0.0

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

Reproduce

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