Average Error: 0.5 → 0.1
Time: 6.3s
Precision: 64
\[\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120\]
\[\mathsf{fma}\left(120, a, 60 \cdot \frac{x - y}{z - t}\right)\]
\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120
\mathsf{fma}\left(120, a, 60 \cdot \frac{x - y}{z - t}\right)
double f(double x, double y, double z, double t, double a) {
        double r833077 = 60.0;
        double r833078 = x;
        double r833079 = y;
        double r833080 = r833078 - r833079;
        double r833081 = r833077 * r833080;
        double r833082 = z;
        double r833083 = t;
        double r833084 = r833082 - r833083;
        double r833085 = r833081 / r833084;
        double r833086 = a;
        double r833087 = 120.0;
        double r833088 = r833086 * r833087;
        double r833089 = r833085 + r833088;
        return r833089;
}

double f(double x, double y, double z, double t, double a) {
        double r833090 = 120.0;
        double r833091 = a;
        double r833092 = 60.0;
        double r833093 = x;
        double r833094 = y;
        double r833095 = r833093 - r833094;
        double r833096 = z;
        double r833097 = t;
        double r833098 = r833096 - r833097;
        double r833099 = r833095 / r833098;
        double r833100 = r833092 * r833099;
        double r833101 = fma(r833090, r833091, r833100);
        return r833101;
}

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.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 *-un-lft-identity0.5

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

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

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

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

Reproduce

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