Average Error: 0.5 → 0.1
Time: 18.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 r661667 = 60.0;
        double r661668 = x;
        double r661669 = y;
        double r661670 = r661668 - r661669;
        double r661671 = r661667 * r661670;
        double r661672 = z;
        double r661673 = t;
        double r661674 = r661672 - r661673;
        double r661675 = r661671 / r661674;
        double r661676 = a;
        double r661677 = 120.0;
        double r661678 = r661676 * r661677;
        double r661679 = r661675 + r661678;
        return r661679;
}

double f(double x, double y, double z, double t, double a) {
        double r661680 = 120.0;
        double r661681 = a;
        double r661682 = 60.0;
        double r661683 = x;
        double r661684 = y;
        double r661685 = r661683 - r661684;
        double r661686 = z;
        double r661687 = t;
        double r661688 = r661686 - r661687;
        double r661689 = r661685 / r661688;
        double r661690 = r661682 * r661689;
        double r661691 = fma(r661680, r661681, r661690);
        return r661691;
}

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