Average Error: 0.5 → 0.1
Time: 6.4s
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 r871340 = 60.0;
        double r871341 = x;
        double r871342 = y;
        double r871343 = r871341 - r871342;
        double r871344 = r871340 * r871343;
        double r871345 = z;
        double r871346 = t;
        double r871347 = r871345 - r871346;
        double r871348 = r871344 / r871347;
        double r871349 = a;
        double r871350 = 120.0;
        double r871351 = r871349 * r871350;
        double r871352 = r871348 + r871351;
        return r871352;
}

double f(double x, double y, double z, double t, double a) {
        double r871353 = 120.0;
        double r871354 = a;
        double r871355 = 60.0;
        double r871356 = x;
        double r871357 = y;
        double r871358 = r871356 - r871357;
        double r871359 = z;
        double r871360 = t;
        double r871361 = r871359 - r871360;
        double r871362 = r871358 / r871361;
        double r871363 = r871355 * r871362;
        double r871364 = fma(r871353, r871354, r871363);
        return r871364;
}

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