Average Error: 0.6 → 0.1
Time: 4.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 r827678 = 60.0;
        double r827679 = x;
        double r827680 = y;
        double r827681 = r827679 - r827680;
        double r827682 = r827678 * r827681;
        double r827683 = z;
        double r827684 = t;
        double r827685 = r827683 - r827684;
        double r827686 = r827682 / r827685;
        double r827687 = a;
        double r827688 = 120.0;
        double r827689 = r827687 * r827688;
        double r827690 = r827686 + r827689;
        return r827690;
}

double f(double x, double y, double z, double t, double a) {
        double r827691 = 120.0;
        double r827692 = a;
        double r827693 = 60.0;
        double r827694 = x;
        double r827695 = y;
        double r827696 = r827694 - r827695;
        double r827697 = z;
        double r827698 = t;
        double r827699 = r827697 - r827698;
        double r827700 = r827696 / r827699;
        double r827701 = r827693 * r827700;
        double r827702 = fma(r827691, r827692, r827701);
        return r827702;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original0.6
Target0.2
Herbie0.1
\[\frac{60}{\frac{z - t}{x - y}} + a \cdot 120\]

Derivation

  1. Initial program 0.6

    \[\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 2020039 +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)))