Average Error: 0.5 → 0.1
Time: 5.7s
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 r758636 = 60.0;
        double r758637 = x;
        double r758638 = y;
        double r758639 = r758637 - r758638;
        double r758640 = r758636 * r758639;
        double r758641 = z;
        double r758642 = t;
        double r758643 = r758641 - r758642;
        double r758644 = r758640 / r758643;
        double r758645 = a;
        double r758646 = 120.0;
        double r758647 = r758645 * r758646;
        double r758648 = r758644 + r758647;
        return r758648;
}

double f(double x, double y, double z, double t, double a) {
        double r758649 = 120.0;
        double r758650 = a;
        double r758651 = 60.0;
        double r758652 = x;
        double r758653 = y;
        double r758654 = r758652 - r758653;
        double r758655 = z;
        double r758656 = t;
        double r758657 = r758655 - r758656;
        double r758658 = r758654 / r758657;
        double r758659 = r758651 * r758658;
        double r758660 = fma(r758649, r758650, r758659);
        return r758660;
}

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.2
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 2020001 +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)))