Average Error: 0.5 → 0.1
Time: 11.5s
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 r877642 = 60.0;
        double r877643 = x;
        double r877644 = y;
        double r877645 = r877643 - r877644;
        double r877646 = r877642 * r877645;
        double r877647 = z;
        double r877648 = t;
        double r877649 = r877647 - r877648;
        double r877650 = r877646 / r877649;
        double r877651 = a;
        double r877652 = 120.0;
        double r877653 = r877651 * r877652;
        double r877654 = r877650 + r877653;
        return r877654;
}

double f(double x, double y, double z, double t, double a) {
        double r877655 = 120.0;
        double r877656 = a;
        double r877657 = 60.0;
        double r877658 = x;
        double r877659 = y;
        double r877660 = r877658 - r877659;
        double r877661 = z;
        double r877662 = t;
        double r877663 = r877661 - r877662;
        double r877664 = r877660 / r877663;
        double r877665 = r877657 * r877664;
        double r877666 = fma(r877655, r877656, r877665);
        return r877666;
}

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.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.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 2020046 +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)))