Average Error: 0.4 → 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 r874779 = 60.0;
        double r874780 = x;
        double r874781 = y;
        double r874782 = r874780 - r874781;
        double r874783 = r874779 * r874782;
        double r874784 = z;
        double r874785 = t;
        double r874786 = r874784 - r874785;
        double r874787 = r874783 / r874786;
        double r874788 = a;
        double r874789 = 120.0;
        double r874790 = r874788 * r874789;
        double r874791 = r874787 + r874790;
        return r874791;
}

double f(double x, double y, double z, double t, double a) {
        double r874792 = 120.0;
        double r874793 = a;
        double r874794 = 60.0;
        double r874795 = x;
        double r874796 = y;
        double r874797 = r874795 - r874796;
        double r874798 = z;
        double r874799 = t;
        double r874800 = r874798 - r874799;
        double r874801 = r874797 / r874800;
        double r874802 = r874794 * r874801;
        double r874803 = fma(r874792, r874793, r874802);
        return r874803;
}

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