Average Error: 0.4 → 0.1
Time: 4.9s
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 r1018355 = 60.0;
        double r1018356 = x;
        double r1018357 = y;
        double r1018358 = r1018356 - r1018357;
        double r1018359 = r1018355 * r1018358;
        double r1018360 = z;
        double r1018361 = t;
        double r1018362 = r1018360 - r1018361;
        double r1018363 = r1018359 / r1018362;
        double r1018364 = a;
        double r1018365 = 120.0;
        double r1018366 = r1018364 * r1018365;
        double r1018367 = r1018363 + r1018366;
        return r1018367;
}

double f(double x, double y, double z, double t, double a) {
        double r1018368 = 120.0;
        double r1018369 = a;
        double r1018370 = 60.0;
        double r1018371 = x;
        double r1018372 = y;
        double r1018373 = r1018371 - r1018372;
        double r1018374 = z;
        double r1018375 = t;
        double r1018376 = r1018374 - r1018375;
        double r1018377 = r1018373 / r1018376;
        double r1018378 = r1018370 * r1018377;
        double r1018379 = fma(r1018368, r1018369, r1018378);
        return r1018379;
}

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. Using strategy rm
  8. Applied div-inv0.2

    \[\leadsto \mathsf{fma}\left(120, a, \color{blue}{\left(60 \cdot \frac{1}{z - t}\right)} \cdot \left(x - y\right)\right)\]
  9. Using strategy rm
  10. Applied associate-*l*0.2

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

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

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

Reproduce

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