Average Error: 0.4 → 0.1
Time: 12.8s
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 r507806 = 60.0;
        double r507807 = x;
        double r507808 = y;
        double r507809 = r507807 - r507808;
        double r507810 = r507806 * r507809;
        double r507811 = z;
        double r507812 = t;
        double r507813 = r507811 - r507812;
        double r507814 = r507810 / r507813;
        double r507815 = a;
        double r507816 = 120.0;
        double r507817 = r507815 * r507816;
        double r507818 = r507814 + r507817;
        return r507818;
}

double f(double x, double y, double z, double t, double a) {
        double r507819 = 120.0;
        double r507820 = a;
        double r507821 = 60.0;
        double r507822 = x;
        double r507823 = y;
        double r507824 = r507822 - r507823;
        double r507825 = z;
        double r507826 = t;
        double r507827 = r507825 - r507826;
        double r507828 = r507824 / r507827;
        double r507829 = r507821 * r507828;
        double r507830 = fma(r507819, r507820, r507829);
        return r507830;
}

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