Average Error: 0.4 → 0.1
Time: 19.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 r745361 = 60.0;
        double r745362 = x;
        double r745363 = y;
        double r745364 = r745362 - r745363;
        double r745365 = r745361 * r745364;
        double r745366 = z;
        double r745367 = t;
        double r745368 = r745366 - r745367;
        double r745369 = r745365 / r745368;
        double r745370 = a;
        double r745371 = 120.0;
        double r745372 = r745370 * r745371;
        double r745373 = r745369 + r745372;
        return r745373;
}

double f(double x, double y, double z, double t, double a) {
        double r745374 = 120.0;
        double r745375 = a;
        double r745376 = 60.0;
        double r745377 = x;
        double r745378 = y;
        double r745379 = r745377 - r745378;
        double r745380 = z;
        double r745381 = t;
        double r745382 = r745380 - r745381;
        double r745383 = r745379 / r745382;
        double r745384 = r745376 * r745383;
        double r745385 = fma(r745374, r745375, r745384);
        return r745385;
}

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 2019305 +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)))