Average Error: 0.4 → 0.1
Time: 6.8s
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 r826416 = 60.0;
        double r826417 = x;
        double r826418 = y;
        double r826419 = r826417 - r826418;
        double r826420 = r826416 * r826419;
        double r826421 = z;
        double r826422 = t;
        double r826423 = r826421 - r826422;
        double r826424 = r826420 / r826423;
        double r826425 = a;
        double r826426 = 120.0;
        double r826427 = r826425 * r826426;
        double r826428 = r826424 + r826427;
        return r826428;
}

double f(double x, double y, double z, double t, double a) {
        double r826429 = 120.0;
        double r826430 = a;
        double r826431 = 60.0;
        double r826432 = x;
        double r826433 = y;
        double r826434 = r826432 - r826433;
        double r826435 = z;
        double r826436 = t;
        double r826437 = r826435 - r826436;
        double r826438 = r826434 / r826437;
        double r826439 = r826431 * r826438;
        double r826440 = fma(r826429, r826430, r826439);
        return r826440;
}

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