Average Error: 0.4 → 0.1
Time: 21.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 r1281010 = 60.0;
        double r1281011 = x;
        double r1281012 = y;
        double r1281013 = r1281011 - r1281012;
        double r1281014 = r1281010 * r1281013;
        double r1281015 = z;
        double r1281016 = t;
        double r1281017 = r1281015 - r1281016;
        double r1281018 = r1281014 / r1281017;
        double r1281019 = a;
        double r1281020 = 120.0;
        double r1281021 = r1281019 * r1281020;
        double r1281022 = r1281018 + r1281021;
        return r1281022;
}

double f(double x, double y, double z, double t, double a) {
        double r1281023 = 120.0;
        double r1281024 = a;
        double r1281025 = 60.0;
        double r1281026 = x;
        double r1281027 = y;
        double r1281028 = r1281026 - r1281027;
        double r1281029 = z;
        double r1281030 = t;
        double r1281031 = r1281029 - r1281030;
        double r1281032 = r1281028 / r1281031;
        double r1281033 = r1281025 * r1281032;
        double r1281034 = fma(r1281023, r1281024, r1281033);
        return r1281034;
}

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 2019235 +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)))