Average Error: 0.4 → 0.1
Time: 4.2s
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 r938185 = 60.0;
        double r938186 = x;
        double r938187 = y;
        double r938188 = r938186 - r938187;
        double r938189 = r938185 * r938188;
        double r938190 = z;
        double r938191 = t;
        double r938192 = r938190 - r938191;
        double r938193 = r938189 / r938192;
        double r938194 = a;
        double r938195 = 120.0;
        double r938196 = r938194 * r938195;
        double r938197 = r938193 + r938196;
        return r938197;
}

double f(double x, double y, double z, double t, double a) {
        double r938198 = 120.0;
        double r938199 = a;
        double r938200 = 60.0;
        double r938201 = x;
        double r938202 = y;
        double r938203 = r938201 - r938202;
        double r938204 = z;
        double r938205 = t;
        double r938206 = r938204 - r938205;
        double r938207 = r938203 / r938206;
        double r938208 = r938200 * r938207;
        double r938209 = fma(r938198, r938199, r938208);
        return r938209;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

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

Derivation

  1. Initial program 0.4

    \[\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 *-un-lft-identity0.4

    \[\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 2019362 +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)))