Average Error: 0.5 → 0.1
Time: 4.7s
Precision: 64
\[\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120\]
\[\mathsf{fma}\left(120, a, \frac{60}{z - t} \cdot \left(x - 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 \left(x - y\right)\right)
double f(double x, double y, double z, double t, double a) {
        double r807043 = 60.0;
        double r807044 = x;
        double r807045 = y;
        double r807046 = r807044 - r807045;
        double r807047 = r807043 * r807046;
        double r807048 = z;
        double r807049 = t;
        double r807050 = r807048 - r807049;
        double r807051 = r807047 / r807050;
        double r807052 = a;
        double r807053 = 120.0;
        double r807054 = r807052 * r807053;
        double r807055 = r807051 + r807054;
        return r807055;
}

double f(double x, double y, double z, double t, double a) {
        double r807056 = 120.0;
        double r807057 = a;
        double r807058 = 60.0;
        double r807059 = z;
        double r807060 = t;
        double r807061 = r807059 - r807060;
        double r807062 = r807058 / r807061;
        double r807063 = x;
        double r807064 = y;
        double r807065 = r807063 - r807064;
        double r807066 = r807062 * r807065;
        double r807067 = fma(r807056, r807057, r807066);
        return r807067;
}

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.1
\[\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 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. Final simplification0.1

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

Reproduce

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