Average Error: 0.5 → 0.4
Time: 14.4s
Precision: 64
\[\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120\]
\[\mathsf{fma}\left(120, a, \frac{\left(x - y\right) \cdot 60}{z - t}\right)\]
\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120
\mathsf{fma}\left(120, a, \frac{\left(x - y\right) \cdot 60}{z - t}\right)
double f(double x, double y, double z, double t, double a) {
        double r441018 = 60.0;
        double r441019 = x;
        double r441020 = y;
        double r441021 = r441019 - r441020;
        double r441022 = r441018 * r441021;
        double r441023 = z;
        double r441024 = t;
        double r441025 = r441023 - r441024;
        double r441026 = r441022 / r441025;
        double r441027 = a;
        double r441028 = 120.0;
        double r441029 = r441027 * r441028;
        double r441030 = r441026 + r441029;
        return r441030;
}

double f(double x, double y, double z, double t, double a) {
        double r441031 = 120.0;
        double r441032 = a;
        double r441033 = x;
        double r441034 = y;
        double r441035 = r441033 - r441034;
        double r441036 = 60.0;
        double r441037 = r441035 * r441036;
        double r441038 = z;
        double r441039 = t;
        double r441040 = r441038 - r441039;
        double r441041 = r441037 / r441040;
        double r441042 = fma(r441031, r441032, r441041);
        return r441042;
}

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.4
\[\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 *-commutative0.4

    \[\leadsto \mathsf{fma}\left(120, a, \frac{\color{blue}{\left(x - y\right) \cdot 60}}{z - t}\right)\]
  5. Final simplification0.4

    \[\leadsto \mathsf{fma}\left(120, a, \frac{\left(x - y\right) \cdot 60}{z - t}\right)\]

Reproduce

herbie shell --seed 2019212 +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)))