Average Error: 0.4 → 0.1
Time: 14.4s
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 r590652 = 60.0;
        double r590653 = x;
        double r590654 = y;
        double r590655 = r590653 - r590654;
        double r590656 = r590652 * r590655;
        double r590657 = z;
        double r590658 = t;
        double r590659 = r590657 - r590658;
        double r590660 = r590656 / r590659;
        double r590661 = a;
        double r590662 = 120.0;
        double r590663 = r590661 * r590662;
        double r590664 = r590660 + r590663;
        return r590664;
}

double f(double x, double y, double z, double t, double a) {
        double r590665 = 120.0;
        double r590666 = a;
        double r590667 = 60.0;
        double r590668 = x;
        double r590669 = y;
        double r590670 = r590668 - r590669;
        double r590671 = z;
        double r590672 = t;
        double r590673 = r590671 - r590672;
        double r590674 = r590670 / r590673;
        double r590675 = r590667 * r590674;
        double r590676 = fma(r590665, r590666, r590675);
        return r590676;
}

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.1
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 2019306 +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)))