Average Error: 0.4 → 0.4
Time: 13.6s
Precision: 64
\[\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120\]
\[\mathsf{fma}\left(120, a, \frac{x \cdot 60 + 60 \cdot \left(-y\right)}{z - t}\right)\]
\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120
\mathsf{fma}\left(120, a, \frac{x \cdot 60 + 60 \cdot \left(-y\right)}{z - t}\right)
double f(double x, double y, double z, double t, double a) {
        double r588263 = 60.0;
        double r588264 = x;
        double r588265 = y;
        double r588266 = r588264 - r588265;
        double r588267 = r588263 * r588266;
        double r588268 = z;
        double r588269 = t;
        double r588270 = r588268 - r588269;
        double r588271 = r588267 / r588270;
        double r588272 = a;
        double r588273 = 120.0;
        double r588274 = r588272 * r588273;
        double r588275 = r588271 + r588274;
        return r588275;
}

double f(double x, double y, double z, double t, double a) {
        double r588276 = 120.0;
        double r588277 = a;
        double r588278 = x;
        double r588279 = 60.0;
        double r588280 = r588278 * r588279;
        double r588281 = y;
        double r588282 = -r588281;
        double r588283 = r588279 * r588282;
        double r588284 = r588280 + r588283;
        double r588285 = z;
        double r588286 = t;
        double r588287 = r588285 - r588286;
        double r588288 = r588284 / r588287;
        double r588289 = fma(r588276, r588277, r588288);
        return r588289;
}

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.4
\[\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 sub-neg0.4

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

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

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

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

Reproduce

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