Average Error: 0.5 → 0.1
Time: 11.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 r894473 = 60.0;
        double r894474 = x;
        double r894475 = y;
        double r894476 = r894474 - r894475;
        double r894477 = r894473 * r894476;
        double r894478 = z;
        double r894479 = t;
        double r894480 = r894478 - r894479;
        double r894481 = r894477 / r894480;
        double r894482 = a;
        double r894483 = 120.0;
        double r894484 = r894482 * r894483;
        double r894485 = r894481 + r894484;
        return r894485;
}

double f(double x, double y, double z, double t, double a) {
        double r894486 = 120.0;
        double r894487 = a;
        double r894488 = 60.0;
        double r894489 = x;
        double r894490 = y;
        double r894491 = r894489 - r894490;
        double r894492 = z;
        double r894493 = t;
        double r894494 = r894492 - r894493;
        double r894495 = r894491 / r894494;
        double r894496 = r894488 * r894495;
        double r894497 = fma(r894486, r894487, r894496);
        return r894497;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

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

Derivation

  1. Initial program 0.5

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

    \[\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.5

    \[\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 2020045 +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)))