Average Error: 0.5 → 0.1
Time: 5.5s
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 r707532 = 60.0;
        double r707533 = x;
        double r707534 = y;
        double r707535 = r707533 - r707534;
        double r707536 = r707532 * r707535;
        double r707537 = z;
        double r707538 = t;
        double r707539 = r707537 - r707538;
        double r707540 = r707536 / r707539;
        double r707541 = a;
        double r707542 = 120.0;
        double r707543 = r707541 * r707542;
        double r707544 = r707540 + r707543;
        return r707544;
}

double f(double x, double y, double z, double t, double a) {
        double r707545 = 120.0;
        double r707546 = a;
        double r707547 = 60.0;
        double r707548 = x;
        double r707549 = y;
        double r707550 = r707548 - r707549;
        double r707551 = z;
        double r707552 = t;
        double r707553 = r707551 - r707552;
        double r707554 = r707550 / r707553;
        double r707555 = r707547 * r707554;
        double r707556 = fma(r707545, r707546, r707555);
        return r707556;
}

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.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 2020001 +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)))