Average Error: 0.5 → 0.5
Time: 11.3s
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 r1024174 = 60.0;
        double r1024175 = x;
        double r1024176 = y;
        double r1024177 = r1024175 - r1024176;
        double r1024178 = r1024174 * r1024177;
        double r1024179 = z;
        double r1024180 = t;
        double r1024181 = r1024179 - r1024180;
        double r1024182 = r1024178 / r1024181;
        double r1024183 = a;
        double r1024184 = 120.0;
        double r1024185 = r1024183 * r1024184;
        double r1024186 = r1024182 + r1024185;
        return r1024186;
}

double f(double x, double y, double z, double t, double a) {
        double r1024187 = 120.0;
        double r1024188 = a;
        double r1024189 = x;
        double r1024190 = 60.0;
        double r1024191 = r1024189 * r1024190;
        double r1024192 = z;
        double r1024193 = t;
        double r1024194 = r1024192 - r1024193;
        double r1024195 = r1024191 / r1024194;
        double r1024196 = y;
        double r1024197 = r1024196 * r1024190;
        double r1024198 = r1024197 / r1024194;
        double r1024199 = r1024195 - r1024198;
        double r1024200 = fma(r1024187, r1024188, r1024199);
        return r1024200;
}

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