Average Error: 0.5 → 0.1
Time: 5.2s
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 r827871 = 60.0;
        double r827872 = x;
        double r827873 = y;
        double r827874 = r827872 - r827873;
        double r827875 = r827871 * r827874;
        double r827876 = z;
        double r827877 = t;
        double r827878 = r827876 - r827877;
        double r827879 = r827875 / r827878;
        double r827880 = a;
        double r827881 = 120.0;
        double r827882 = r827880 * r827881;
        double r827883 = r827879 + r827882;
        return r827883;
}

double f(double x, double y, double z, double t, double a) {
        double r827884 = 120.0;
        double r827885 = a;
        double r827886 = 60.0;
        double r827887 = x;
        double r827888 = y;
        double r827889 = r827887 - r827888;
        double r827890 = z;
        double r827891 = t;
        double r827892 = r827890 - r827891;
        double r827893 = r827889 / r827892;
        double r827894 = r827886 * r827893;
        double r827895 = fma(r827884, r827885, r827894);
        return r827895;
}

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