Average Error: 0.3 → 0.1
Time: 4.9s
Precision: 64
\[\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120\]
\[\mathsf{fma}\left(120, a, \frac{60}{z - t} \cdot x + \frac{60}{z - t} \cdot \left(-y\right)\right)\]
\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120
\mathsf{fma}\left(120, a, \frac{60}{z - t} \cdot x + \frac{60}{z - t} \cdot \left(-y\right)\right)
double f(double x, double y, double z, double t, double a) {
        double r822826 = 60.0;
        double r822827 = x;
        double r822828 = y;
        double r822829 = r822827 - r822828;
        double r822830 = r822826 * r822829;
        double r822831 = z;
        double r822832 = t;
        double r822833 = r822831 - r822832;
        double r822834 = r822830 / r822833;
        double r822835 = a;
        double r822836 = 120.0;
        double r822837 = r822835 * r822836;
        double r822838 = r822834 + r822837;
        return r822838;
}

double f(double x, double y, double z, double t, double a) {
        double r822839 = 120.0;
        double r822840 = a;
        double r822841 = 60.0;
        double r822842 = z;
        double r822843 = t;
        double r822844 = r822842 - r822843;
        double r822845 = r822841 / r822844;
        double r822846 = x;
        double r822847 = r822845 * r822846;
        double r822848 = y;
        double r822849 = -r822848;
        double r822850 = r822845 * r822849;
        double r822851 = r822847 + r822850;
        double r822852 = fma(r822839, r822840, r822851);
        return r822852;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original0.3
Target0.2
Herbie0.1
\[\frac{60}{\frac{z - t}{x - y}} + a \cdot 120\]

Derivation

  1. Initial program 0.3

    \[\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120\]
  2. Simplified0.3

    \[\leadsto \color{blue}{\mathsf{fma}\left(120, a, \frac{60 \cdot \left(x - y\right)}{z - t}\right)}\]
  3. Using strategy rm
  4. Applied associate-/l*0.1

    \[\leadsto \mathsf{fma}\left(120, a, \color{blue}{\frac{60}{\frac{z - t}{x - y}}}\right)\]
  5. Using strategy rm
  6. Applied associate-/r/0.1

    \[\leadsto \mathsf{fma}\left(120, a, \color{blue}{\frac{60}{z - t} \cdot \left(x - y\right)}\right)\]
  7. Using strategy rm
  8. Applied sub-neg0.1

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

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

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

Reproduce

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