Average Error: 0.4 → 0.1
Time: 5.2s
Precision: 64
\[\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120\]
\[\mathsf{fma}\left(120, a, \frac{60}{z - t} \cdot \left(x - y\right)\right)\]
\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120
\mathsf{fma}\left(120, a, \frac{60}{z - t} \cdot \left(x - y\right)\right)
double f(double x, double y, double z, double t, double a) {
        double r888363 = 60.0;
        double r888364 = x;
        double r888365 = y;
        double r888366 = r888364 - r888365;
        double r888367 = r888363 * r888366;
        double r888368 = z;
        double r888369 = t;
        double r888370 = r888368 - r888369;
        double r888371 = r888367 / r888370;
        double r888372 = a;
        double r888373 = 120.0;
        double r888374 = r888372 * r888373;
        double r888375 = r888371 + r888374;
        return r888375;
}

double f(double x, double y, double z, double t, double a) {
        double r888376 = 120.0;
        double r888377 = a;
        double r888378 = 60.0;
        double r888379 = z;
        double r888380 = t;
        double r888381 = r888379 - r888380;
        double r888382 = r888378 / r888381;
        double r888383 = x;
        double r888384 = y;
        double r888385 = r888383 - r888384;
        double r888386 = r888382 * r888385;
        double r888387 = fma(r888376, r888377, r888386);
        return r888387;
}

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 associate-/l*0.1

    \[\leadsto \mathsf{fma}\left(120, a, \color{blue}{\frac{60}{\frac{z - t}{x - y}}}\right)\]
  5. Using strategy rm
  6. Applied associate-/r/0.1

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

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

Reproduce

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

  :herbie-target
  (+ (/ 60 (/ (- z t) (- x y))) (* a 120))

  (+ (/ (* 60 (- x y)) (- z t)) (* a 120)))