Average Error: 0.5 → 0.5
Time: 10.8s
Precision: 64
\[\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120\]
\[\mathsf{fma}\left(120, a, \frac{x \cdot 60}{z - t} - \frac{y \cdot 60}{z - t}\right)\]
\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120
\mathsf{fma}\left(120, a, \frac{x \cdot 60}{z - t} - \frac{y \cdot 60}{z - t}\right)
double f(double x, double y, double z, double t, double a) {
        double r937239 = 60.0;
        double r937240 = x;
        double r937241 = y;
        double r937242 = r937240 - r937241;
        double r937243 = r937239 * r937242;
        double r937244 = z;
        double r937245 = t;
        double r937246 = r937244 - r937245;
        double r937247 = r937243 / r937246;
        double r937248 = a;
        double r937249 = 120.0;
        double r937250 = r937248 * r937249;
        double r937251 = r937247 + r937250;
        return r937251;
}

double f(double x, double y, double z, double t, double a) {
        double r937252 = 120.0;
        double r937253 = a;
        double r937254 = x;
        double r937255 = 60.0;
        double r937256 = r937254 * r937255;
        double r937257 = z;
        double r937258 = t;
        double r937259 = r937257 - r937258;
        double r937260 = r937256 / r937259;
        double r937261 = y;
        double r937262 = r937261 * r937255;
        double r937263 = r937262 / r937259;
        double r937264 = r937260 - r937263;
        double r937265 = fma(r937252, r937253, r937264);
        return r937265;
}

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

    \[\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.5

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

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

    \[\leadsto \mathsf{fma}\left(120, a, \frac{x \cdot 60 + \color{blue}{\left(-y\right) \cdot 60}}{z - t}\right)\]
  8. Using strategy rm
  9. Applied distribute-lft-neg-out0.5

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

    \[\leadsto \mathsf{fma}\left(120, a, \frac{\color{blue}{x \cdot 60 - y \cdot 60}}{z - t}\right)\]
  11. Applied div-sub0.5

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

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

Reproduce

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