Average Error: 0.4 → 0.4
Time: 16.2s
Precision: 64
\[\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120\]
\[\mathsf{fma}\left(120, a, \frac{x \cdot 60 + 60 \cdot \left(-y\right)}{z - t}\right)\]
\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120
\mathsf{fma}\left(120, a, \frac{x \cdot 60 + 60 \cdot \left(-y\right)}{z - t}\right)
double f(double x, double y, double z, double t, double a) {
        double r615165 = 60.0;
        double r615166 = x;
        double r615167 = y;
        double r615168 = r615166 - r615167;
        double r615169 = r615165 * r615168;
        double r615170 = z;
        double r615171 = t;
        double r615172 = r615170 - r615171;
        double r615173 = r615169 / r615172;
        double r615174 = a;
        double r615175 = 120.0;
        double r615176 = r615174 * r615175;
        double r615177 = r615173 + r615176;
        return r615177;
}

double f(double x, double y, double z, double t, double a) {
        double r615178 = 120.0;
        double r615179 = a;
        double r615180 = x;
        double r615181 = 60.0;
        double r615182 = r615180 * r615181;
        double r615183 = y;
        double r615184 = -r615183;
        double r615185 = r615181 * r615184;
        double r615186 = r615182 + r615185;
        double r615187 = z;
        double r615188 = t;
        double r615189 = r615187 - r615188;
        double r615190 = r615186 / r615189;
        double r615191 = fma(r615178, r615179, r615190);
        return r615191;
}

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.4
\[\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 sub-neg0.4

    \[\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.4

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

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

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

Reproduce

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