Average Error: 0.4 → 0.1
Time: 27.7s
Precision: 64
\[\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120\]
\[\mathsf{fma}\left(120, a, 60 \cdot \frac{x - y}{z - t}\right)\]
\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120
\mathsf{fma}\left(120, a, 60 \cdot \frac{x - y}{z - t}\right)
double f(double x, double y, double z, double t, double a) {
        double r543981 = 60.0;
        double r543982 = x;
        double r543983 = y;
        double r543984 = r543982 - r543983;
        double r543985 = r543981 * r543984;
        double r543986 = z;
        double r543987 = t;
        double r543988 = r543986 - r543987;
        double r543989 = r543985 / r543988;
        double r543990 = a;
        double r543991 = 120.0;
        double r543992 = r543990 * r543991;
        double r543993 = r543989 + r543992;
        return r543993;
}

double f(double x, double y, double z, double t, double a) {
        double r543994 = 120.0;
        double r543995 = a;
        double r543996 = 60.0;
        double r543997 = x;
        double r543998 = y;
        double r543999 = r543997 - r543998;
        double r544000 = z;
        double r544001 = t;
        double r544002 = r544000 - r544001;
        double r544003 = r543999 / r544002;
        double r544004 = r543996 * r544003;
        double r544005 = fma(r543994, r543995, r544004);
        return r544005;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original0.4
Target0.2
Herbie0.1
\[\frac{60}{\frac{z - t}{x - y}} + a \cdot 120\]

Derivation

  1. Initial program 0.4

    \[\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120\]
  2. Simplified0.4

    \[\leadsto \color{blue}{\mathsf{fma}\left(120, a, \frac{60 \cdot \left(x - y\right)}{z - t}\right)}\]
  3. Using strategy rm
  4. Applied *-un-lft-identity0.4

    \[\leadsto \mathsf{fma}\left(120, a, \frac{60 \cdot \left(x - y\right)}{\color{blue}{1 \cdot \left(z - t\right)}}\right)\]
  5. Applied times-frac0.1

    \[\leadsto \mathsf{fma}\left(120, a, \color{blue}{\frac{60}{1} \cdot \frac{x - y}{z - t}}\right)\]
  6. Simplified0.1

    \[\leadsto \mathsf{fma}\left(120, a, \color{blue}{60} \cdot \frac{x - y}{z - t}\right)\]
  7. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(120, a, 60 \cdot \frac{x - y}{z - t}\right)\]

Reproduce

herbie shell --seed 2019199 +o rules:numerics
(FPCore (x y z t a)
  :name "Data.Colour.RGB:hslsv from colour-2.3.3, B"

  :herbie-target
  (+ (/ 60.0 (/ (- z t) (- x y))) (* a 120.0))

  (+ (/ (* 60.0 (- x y)) (- z t)) (* a 120.0)))