Average Error: 0.5 → 0.5
Time: 3.8s
Precision: 64
\[\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120\]
\[\mathsf{fma}\left(120, a, \frac{60 \cdot x + 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{60 \cdot x + 60 \cdot \left(-y\right)}{z - t}\right)
double f(double x, double y, double z, double t, double a) {
        double r826390 = 60.0;
        double r826391 = x;
        double r826392 = y;
        double r826393 = r826391 - r826392;
        double r826394 = r826390 * r826393;
        double r826395 = z;
        double r826396 = t;
        double r826397 = r826395 - r826396;
        double r826398 = r826394 / r826397;
        double r826399 = a;
        double r826400 = 120.0;
        double r826401 = r826399 * r826400;
        double r826402 = r826398 + r826401;
        return r826402;
}

double f(double x, double y, double z, double t, double a) {
        double r826403 = 120.0;
        double r826404 = a;
        double r826405 = 60.0;
        double r826406 = x;
        double r826407 = r826405 * r826406;
        double r826408 = y;
        double r826409 = -r826408;
        double r826410 = r826405 * r826409;
        double r826411 = r826407 + r826410;
        double r826412 = z;
        double r826413 = t;
        double r826414 = r826412 - r826413;
        double r826415 = r826411 / r826414;
        double r826416 = fma(r826403, r826404, r826415);
        return r826416;
}

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.1
Herbie0.5
\[\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 sub-neg0.5

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

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

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

Reproduce

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