Average Error: 0.5 → 0.1
Time: 10.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 r971852 = 60.0;
        double r971853 = x;
        double r971854 = y;
        double r971855 = r971853 - r971854;
        double r971856 = r971852 * r971855;
        double r971857 = z;
        double r971858 = t;
        double r971859 = r971857 - r971858;
        double r971860 = r971856 / r971859;
        double r971861 = a;
        double r971862 = 120.0;
        double r971863 = r971861 * r971862;
        double r971864 = r971860 + r971863;
        return r971864;
}

double f(double x, double y, double z, double t, double a) {
        double r971865 = 120.0;
        double r971866 = a;
        double r971867 = 60.0;
        double r971868 = x;
        double r971869 = y;
        double r971870 = r971868 - r971869;
        double r971871 = z;
        double r971872 = t;
        double r971873 = r971871 - r971872;
        double r971874 = r971870 / r971873;
        double r971875 = r971867 * r971874;
        double r971876 = fma(r971865, r971866, r971875);
        return r971876;
}

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.1
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 2020043 +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)))